[PATCH 11/18] media: microchip-isc: expose hue and saturation as v4l2 controls
Balamanikandan Gunasundar
balamanikandan.gunasundar at microchip.com
Thu Oct 9 08:52:44 PDT 2025
Expose hue and saturation as adjustable controls allowing users to modify
it. Write the user specified values to the hardware registers. Additionally
write the brightness and contrast values to the registers that were
missing.
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar at microchip.com>
---
.../platform/microchip/microchip-isc-base.c | 17 +++++++++++++++++
.../platform/microchip/microchip-isc-regs.h | 3 +++
.../media/platform/microchip/microchip-isc.h | 2 ++
3 files changed, 22 insertions(+)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index e6d7f59893ac..ce22b4789ebd 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1520,6 +1520,7 @@ static int isc_s_ctrl(struct v4l2_ctrl *ctrl)
struct isc_device *isc = container_of(ctrl->handler,
struct isc_device, ctrls.handler);
struct isc_ctrls *ctrls = &isc->ctrls;
+ struct regmap *regmap = isc->regmap;
if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
return 0;
@@ -1527,9 +1528,19 @@ static int isc_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrls->brightness = ctrl->val & ISC_CBC_BRIGHT_MASK;
+ regmap_write(regmap, ISC_CBC_BRIGHT + isc->offsets.cbc, ctrls->brightness);
break;
case V4L2_CID_CONTRAST:
ctrls->contrast = ctrl->val & ISC_CBC_CONTRAST_MASK;
+ regmap_write(regmap, ISC_CBC_CONTRAST + isc->offsets.cbc, ctrls->contrast);
+ break;
+ case V4L2_CID_HUE:
+ ctrls->hue = ctrl->val & ISC_CBCHS_HUE_MASK;
+ regmap_write(regmap, ISC_CBCHS_HUE, ctrls->hue);
+ break;
+ case V4L2_CID_SATURATION:
+ ctrls->saturation = ctrl->val & ISC_CBCHS_SAT_MASK;
+ regmap_write(regmap, ISC_CBCHS_SAT, ctrls->saturation);
break;
case V4L2_CID_GAMMA:
ctrls->gamma_index = ctrl->val;
@@ -1538,6 +1549,10 @@ static int isc_s_ctrl(struct v4l2_ctrl *ctrl)
return -EINVAL;
}
+ mutex_lock(&isc->awb_mutex);
+ isc_update_profile(isc);
+ mutex_unlock(&isc->awb_mutex);
+
return 0;
}
@@ -1714,6 +1729,8 @@ static int isc_ctrl_init(struct isc_device *isc)
ctrls->brightness = 0;
v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
+ v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HUE, -180, 180, 1, 0);
+ v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION, 0, 100, 1, 16);
v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1, 1);
isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
V4L2_CID_AUTO_WHITE_BALANCE,
diff --git a/drivers/media/platform/microchip/microchip-isc-regs.h b/drivers/media/platform/microchip/microchip-isc-regs.h
index e77e1d9a1db8..2593bd533cac 100644
--- a/drivers/media/platform/microchip/microchip-isc-regs.h
+++ b/drivers/media/platform/microchip/microchip-isc-regs.h
@@ -270,8 +270,11 @@
/* Hue Register */
#define ISC_CBCHS_HUE 0x4e0
+#define ISC_CBCHS_HUE_MASK GENMASK(8, 0)
+
/* Saturation Register */
#define ISC_CBCHS_SAT 0x4e4
+#define ISC_CBCHS_SAT_MASK GENMASK(11, 0)
/* Offset for SUB422 register specific to sama5d2 product */
#define ISC_SAMA5D2_SUB422_OFFSET 0
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index 5245e2790268..7afba3c04dfb 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -139,6 +139,8 @@ struct isc_ctrls {
u32 brightness;
u32 contrast;
+ u32 hue;
+ u32 saturation;
u8 gamma_index;
#define ISC_WB_NONE 0
#define ISC_WB_AUTO 1
--
2.34.1
More information about the linux-arm-kernel
mailing list