Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: mchehab@kernel.org
Subject: [PATCH 08/24] ccs: Add support for analogue gain coefficient controls
Date: Mon,  7 Dec 2020 23:15:14 +0200	[thread overview]
Message-ID: <20201207211530.21180-9-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20201207211530.21180-1-sakari.ailus@linux.intel.com>

Add four controls for reading CCS analogue gain coefficients. The
values are constants that are device specific.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/ccs/ccs-core.c | 38 ++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 47879f9bfe20..c51197318c3a 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -28,6 +28,7 @@
 #include <linux/v4l2-mediabus.h>
 #include <media/v4l2-fwnode.h>
 #include <media/v4l2-device.h>
+#include <uapi/linux/ccs.h>
 
 #include "ccs.h"
 
@@ -771,14 +772,46 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
 	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
 	int rval;
 
-	rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 13);
+	rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 17);
 	if (rval)
 		return rval;
 
 	sensor->pixel_array->ctrl_handler.lock = &sensor->mutex;
 
 	switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) {
-	case CCS_ANALOG_GAIN_CAPABILITY_GLOBAL:
+	case CCS_ANALOG_GAIN_CAPABILITY_GLOBAL: {
+		struct {
+			const char *name;
+			u32 id;
+			s32 value;
+		} const gain_ctrls[] = {
+			{ "Analogue Gain m0", V4L2_CID_CCS_ANALOGUE_GAIN_M0,
+			  CCS_LIM(sensor, ANALOG_GAIN_M0), },
+			{ "Analogue Gain c0", V4L2_CID_CCS_ANALOGUE_GAIN_C0,
+			  CCS_LIM(sensor, ANALOG_GAIN_C0), },
+			{ "Analogue Gain m1", V4L2_CID_CCS_ANALOGUE_GAIN_M1,
+			  CCS_LIM(sensor, ANALOG_GAIN_M1), },
+			{ "Analogue Gain c1", V4L2_CID_CCS_ANALOGUE_GAIN_C1,
+			  CCS_LIM(sensor, ANALOG_GAIN_C1), },
+		};
+		struct v4l2_ctrl_config ctrl_cfg = {
+			.type = V4L2_CTRL_TYPE_INTEGER,
+			.ops = &ccs_ctrl_ops,
+			.flags = V4L2_CTRL_FLAG_READ_ONLY,
+			.step = 1,
+		};
+		unsigned int i;
+
+		for (i = 0; i < ARRAY_SIZE(gain_ctrls); i++) {
+			ctrl_cfg.name = gain_ctrls[i].name;
+			ctrl_cfg.id = gain_ctrls[i].id;
+			ctrl_cfg.min = ctrl_cfg.max = ctrl_cfg.def =
+				gain_ctrls[i].value;
+
+			v4l2_ctrl_new_custom(&sensor->pixel_array->ctrl_handler,
+					     &ctrl_cfg, NULL);
+		}
+
 		v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler,
 				  &ccs_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
 				  CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN),
@@ -787,6 +820,7 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
 				      1U),
 				  CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN));
 	}
+	}
 
 	if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) ==
 	    CCS_DIGITAL_GAIN_CAPABILITY_GLOBAL ||
-- 
2.29.2


  parent reply	other threads:[~2020-12-07 21:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 21:15 [PATCH 00/24] Additional CCS feature support Sakari Ailus
2020-12-07 21:15 ` [PATCH 01/24] ccs: Add digital gain support Sakari Ailus
2020-12-07 21:15 ` [PATCH 02/24] ccs: Add support for old-style SMIA digital gain Sakari Ailus
2020-12-07 21:15 ` [PATCH 03/24] ccs: Remove analogue gain field Sakari Ailus
2020-12-07 21:15 ` [PATCH 04/24] ccs: Only add analogue gain control if the device supports it Sakari Ailus
2020-12-07 21:15 ` [PATCH 05/24] v4l: uapi: Add user control base for CCS controls Sakari Ailus
2020-12-07 21:15 ` [PATCH 06/24] Documentation: ccs: Add user documentation for the CCS driver Sakari Ailus
2020-12-07 21:15 ` [PATCH 07/24] v4l: uapi: ccs: Add controls for analogue gain constants Sakari Ailus
2020-12-11 11:39   ` [PATCH v1.1 " Sakari Ailus
2020-12-07 21:15 ` Sakari Ailus [this message]
2020-12-07 21:15 ` [PATCH 09/24] v4l: uapi: ccs: Add controls for CCS alternative analogue gain Sakari Ailus
2020-12-07 21:15 ` [PATCH 10/24] ccs: Add support for alternate analogue global gain Sakari Ailus
2020-12-07 21:15 ` [PATCH 11/24] ccs: Add debug prints for MSR registers Sakari Ailus
2020-12-07 21:15 ` [PATCH 12/24] v4l: uapi: ccs: Add CCS controls for shading correction Sakari Ailus
2020-12-07 21:15 ` [PATCH 13/24] ccs: Add shading correction and luminance correction level controls Sakari Ailus
2020-12-07 21:15 ` [PATCH 14/24] ccs: Get the endpoint by port rather than any next endpoint Sakari Ailus
2020-12-07 21:15 ` [PATCH 15/24] ccs: Don't change the I²C address just for software reset Sakari Ailus
2020-12-07 21:15 ` [PATCH 16/24] ccs: Only do software reset if we have no hardware reset Sakari Ailus
2020-12-07 21:15 ` [PATCH 17/24] ccs: Wait until software reset is done Sakari Ailus
2021-01-12 16:49   ` Mauro Carvalho Chehab
2021-01-12 17:12     ` Sakari Ailus
2020-12-07 21:15 ` [PATCH 18/24] ccs: Hardware requires a delay after starting the clock of lifting reset Sakari Ailus
2020-12-07 21:15 ` [PATCH 19/24] ccs: Add a sanity check for external clock frequency Sakari Ailus
2020-12-07 21:15 ` [PATCH 20/24] ccs: Support and default to auto PHY control Sakari Ailus
2020-12-07 21:15 ` [PATCH 21/24] Documentation: Include CCS PLL calculator to CCS driver documentation Sakari Ailus
2020-12-07 21:15 ` [PATCH 22/24] ccs-pll: Switch from standard integer types to kernel ones Sakari Ailus
2020-12-07 21:15 ` [PATCH 23/24] ccs: " Sakari Ailus
2020-12-07 21:15 ` [PATCH 24/24] Revert "media: ccs-pll: Fix MODULE_LICENSE" Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201207211530.21180-9-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox