summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-06-21 14:40:10 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-06-21 15:03:41 +0200
commitb336af7ccc70d05e695b4eee55a8e03645d21348 (patch)
treef31d82563dcfc4004a9980d8e92a09288003858b
parent972cb1c49b47a4c8775e24024c5b825a0990ee65 (diff)
sensor: Support setting gains selectively
Setting a gain value to OMAP3_ISP_SENSOR_GAIN_KEEP will prevent that gain from being set. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--isp/controls.c29
-rw-r--r--isp/omap3isp.h6
2 files changed, 22 insertions, 13 deletions
diff --git a/isp/controls.c b/isp/controls.c
index 4939ae0..b189f7b 100644
--- a/isp/controls.c
+++ b/isp/controls.c
@@ -380,19 +380,26 @@ int omap3_isp_sensor_set_gain(struct omap3_isp_device *isp, unsigned int gain)
return v4l2_subdev_set_controls(isp->sensor.entity, ARRAY_SIZE(ctrls), ctrls);
}
-int omap3_isp_sensor_set_gains(struct omap3_isp_device *isp, unsigned int red,
- unsigned int green, unsigned int blue)
+int omap3_isp_sensor_set_gains(struct omap3_isp_device *isp,
+ int red, int green, int blue)
{
struct v4l2_ext_control ctrls[4];
+ unsigned int i = 0;
- ctrls[0].id = V4L2_CID_GAIN_RED;
- ctrls[0].value = red;
- ctrls[1].id = V4L2_CID_GAIN_GREEN1;
- ctrls[1].value = green;
- ctrls[2].id = V4L2_CID_GAIN_GREEN2;
- ctrls[2].value = green;
- ctrls[3].id = V4L2_CID_GAIN_BLUE;
- ctrls[3].value = blue;
+ if (red != OMAP3_ISP_SENSOR_GAIN_KEEP) {
+ ctrls[i].id = V4L2_CID_GAIN_RED;
+ ctrls[i++].value = red;
+ }
+ if (green != OMAP3_ISP_SENSOR_GAIN_KEEP) {
+ ctrls[i].id = V4L2_CID_GAIN_GREEN1;
+ ctrls[i++].value = green;
+ ctrls[i].id = V4L2_CID_GAIN_GREEN2;
+ ctrls[i++].value = green;
+ }
+ if (blue != OMAP3_ISP_SENSOR_GAIN_KEEP) {
+ ctrls[i].id = V4L2_CID_GAIN_BLUE;
+ ctrls[i++].value = blue;
+ }
- return v4l2_subdev_set_controls(isp->sensor.entity, ARRAY_SIZE(ctrls), ctrls);
+ return v4l2_subdev_set_controls(isp->sensor.entity, i, ctrls);
}
diff --git a/isp/omap3isp.h b/isp/omap3isp.h
index 1e9489f..545c82c 100644
--- a/isp/omap3isp.h
+++ b/isp/omap3isp.h
@@ -86,12 +86,14 @@ int omap3_isp_preview_set_saturation(struct omap3_isp_device *isp, float value);
int omap3_isp_preview_set_gain(struct omap3_isp_device *isp, float gain);
int omap3_isp_preview_set_white_balance(struct omap3_isp_device *isp, float gains[4]);
+#define OMAP3_ISP_SENSOR_GAIN_KEEP -1
+
int omap3_isp_sensor_get_exposure(struct omap3_isp_device *isp,
unsigned int *exposure);
int omap3_isp_sensor_set_exposure(struct omap3_isp_device *isp,
unsigned int exposure);
int omap3_isp_sensor_set_gain(struct omap3_isp_device *isp, unsigned int gain);
-int omap3_isp_sensor_set_gains(struct omap3_isp_device *isp, unsigned int red,
- unsigned int green, unsigned int blue);
+int omap3_isp_sensor_set_gains(struct omap3_isp_device *isp,
+ int red, int green, int blue);
#endif