Commit ee25e211 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: ccs: Add support for analogue gain coefficient controls

Add four controls for reading CCS analogue gain coefficients. The
values are constants that are device specific.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent a8a2d75b
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/v4l2-mediabus.h> #include <linux/v4l2-mediabus.h>
#include <media/v4l2-fwnode.h> #include <media/v4l2-fwnode.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <uapi/linux/ccs.h>
#include "ccs.h" #include "ccs.h"
...@@ -771,14 +772,46 @@ static int ccs_init_controls(struct ccs_sensor *sensor) ...@@ -771,14 +772,46 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
int rval; 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) if (rval)
return rval; return rval;
sensor->pixel_array->ctrl_handler.lock = &sensor->mutex; sensor->pixel_array->ctrl_handler.lock = &sensor->mutex;
switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) { 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, v4l2_ctrl_new_std(&sensor->pixel_array->ctrl_handler,
&ccs_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, &ccs_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN), CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN),
...@@ -787,6 +820,7 @@ static int ccs_init_controls(struct ccs_sensor *sensor) ...@@ -787,6 +820,7 @@ static int ccs_init_controls(struct ccs_sensor *sensor)
1U), 1U),
CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN)); CCS_LIM(sensor, ANALOG_GAIN_CODE_MIN));
} }
}
if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) == if (CCS_LIM(sensor, DIGITAL_GAIN_CAPABILITY) ==
CCS_DIGITAL_GAIN_CAPABILITY_GLOBAL || CCS_DIGITAL_GAIN_CAPABILITY_GLOBAL ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment