* [PATCH 0/2] media: i2c: adv7604: Fix handling of video adjustments
@ 2023-02-10 22:56 Laurent Pinchart
2023-02-10 22:56 ` [PATCH 1/2] media: i2c: adv7604: Enable video adjustment Laurent Pinchart
2023-02-10 22:56 ` [PATCH 2/2] media: i2c: adv7604: Fix range of hue control Laurent Pinchart
0 siblings, 2 replies; 7+ messages in thread
From: Laurent Pinchart @ 2023-02-10 22:56 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Hans Verkuil
Hello,
This small series fixes two issues with video adjustments (brightness,
contrast, saturation and hue) in the adv7604 driver. Patch 1/2 makes
those controls effective (they currently have no effect), and patch 2/2
fixes the range of the hue control.
I have successfully tested the series with an ADV7612. The ADV7604 and
ADV7611 documentation of the hue control differs from the ADV7612, but I
believe that's because earlier documentation was incorrect. It could
still be useful to test the series with an ADV7604 or ADV7611.
In patch 2/2 I've decided to represent the hue value as an unsigned
8-bit integer, mapping to the [0°, 360°[ range. Using a signed value
would map to the [-180°, 180°[ range instead, without making any other
difference (and without requiring any modification to the patch other
than changing the range). I don't have a strong preference between the
two options, and I'm pretty sure we can freely pick one without any fear
of an impact on existing userspace applications as patch 1/2 shows that
the hue control has currently no effect.
Laurent Pinchart (2):
media: i2c: adv7604: Enable video adjustment
media: i2c: adv7604: Fix range of hue control
drivers/media/i2c/adv7604.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] media: i2c: adv7604: Enable video adjustment
2023-02-10 22:56 [PATCH 0/2] media: i2c: adv7604: Fix handling of video adjustments Laurent Pinchart
@ 2023-02-10 22:56 ` Laurent Pinchart
2023-02-15 12:49 ` Hans Verkuil
2023-02-10 22:56 ` [PATCH 2/2] media: i2c: adv7604: Fix range of hue control Laurent Pinchart
1 sibling, 1 reply; 7+ messages in thread
From: Laurent Pinchart @ 2023-02-10 22:56 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Hans Verkuil
The video adjustments (contrast, brightness, saturation and hue) are
ignored by default by the device when the VID_ADJ_EN bit is clear. The
corresponding V4L2 controls exposed by the drivers have thus no effect.
Fix this by setting the VID_ADJ_EN bit.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/i2c/adv7604.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 9d218962d7c8..3af0e67f9edb 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1805,6 +1805,9 @@ static void select_input(struct v4l2_subdev *sd)
v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n",
__func__, state->selected_input);
}
+
+ /* Enable video adjustment (contrast, saturation, brightness and hue) */
+ cp_write_clr_set(sd, 0x3e, 0x80, 0x80);
}
static int adv76xx_s_routing(struct v4l2_subdev *sd,
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] media: i2c: adv7604: Fix range of hue control
2023-02-10 22:56 [PATCH 0/2] media: i2c: adv7604: Fix handling of video adjustments Laurent Pinchart
2023-02-10 22:56 ` [PATCH 1/2] media: i2c: adv7604: Enable video adjustment Laurent Pinchart
@ 2023-02-10 22:56 ` Laurent Pinchart
2023-02-11 9:11 ` Sergei Shtylyov
2023-02-15 12:49 ` Hans Verkuil
1 sibling, 2 replies; 7+ messages in thread
From: Laurent Pinchart @ 2023-02-10 22:56 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Hans Verkuil
The ADV7604, ADV7611 and ADV7612 software manuals different the CP_HUE
value differently:
- For ADV7604 and ADV7611, the hue is specified as an unsigned 8-bit
value, and calculated as
(CP_HUE[7:0] * 180) / 256 - 90
with the range set to [-90°, 90°]. Additionally, the values 0x00, 0x0f
and 0xff are documented as corresponding to -90°, 0° and 90°
respectively.
- For ADV7612, the hue is specified as a signed 8-bit value in the range
[0°, 360°[ without any formula. Additionally, the value 0x00 is
documented as corresponding to 0°.
The ADV7604 and ADV7611 documentation is clearly wrong as the example
values don't correspond to the formula. Furthermore, the [-90°, 90°]
range seems incorrect as it would cover only half of the hue space.
The ADV7612 documentation is better, although the range should likely be
[-180°, 180°[ if the value is signed. Given that the values wrap around,
this makes no difference in practice.
The hue values have been verified on ADV7612 to follow the
documentation. There is a high chance they do as well on ADV7604 and
ADV7611.
In any case, all software manuals document the register as 8-bit, so the
current range of the V4L2 hue control [0, 128] is not correct. Expand it
to cover the full 8-bit space, using unsigned values to avoid breaking
any application that may rely on 128 being a valid value.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/i2c/adv7604.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 3af0e67f9edb..3d0898c4175e 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3548,7 +3548,7 @@ static int adv76xx_probe(struct i2c_client *client)
v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
V4L2_CID_SATURATION, 0, 255, 1, 128);
v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
- V4L2_CID_HUE, 0, 128, 1, 0);
+ V4L2_CID_HUE, 0, 255, 1, 0);
ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops,
V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] media: i2c: adv7604: Fix range of hue control
2023-02-10 22:56 ` [PATCH 2/2] media: i2c: adv7604: Fix range of hue control Laurent Pinchart
@ 2023-02-11 9:11 ` Sergei Shtylyov
2023-02-13 11:12 ` Laurent Pinchart
2023-02-15 12:49 ` Hans Verkuil
1 sibling, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2023-02-11 9:11 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: linux-renesas-soc, Hans Verkuil
Hello!
On 2/11/23 1:56 AM, Laurent Pinchart wrote:
> The ADV7604, ADV7611 and ADV7612 software manuals different the CP_HUE
s/different/document/?
> value differently:
>
> - For ADV7604 and ADV7611, the hue is specified as an unsigned 8-bit
> value, and calculated as
>
> (CP_HUE[7:0] * 180) / 256 - 90
>
> with the range set to [-90°, 90°]. Additionally, the values 0x00, 0x0f
> and 0xff are documented as corresponding to -90°, 0° and 90°
> respectively.
>
> - For ADV7612, the hue is specified as a signed 8-bit value in the range
> [0°, 360°[ without any formula. Additionally, the value 0x00 is
> documented as corresponding to 0°.
>
> The ADV7604 and ADV7611 documentation is clearly wrong as the example
> values don't correspond to the formula. Furthermore, the [-90°, 90°]
> range seems incorrect as it would cover only half of the hue space.
>
> The ADV7612 documentation is better, although the range should likely be
> [-180°, 180°[ if the value is signed. Given that the values wrap around,
> this makes no difference in practice.
>
> The hue values have been verified on ADV7612 to follow the
> documentation. There is a high chance they do as well on ADV7604 and
> ADV7611.
>
> In any case, all software manuals document the register as 8-bit, so the
> current range of the V4L2 hue control [0, 128] is not correct. Expand it
> to cover the full 8-bit space, using unsigned values to avoid breaking
> any application that may rely on 128 being a valid value.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] media: i2c: adv7604: Fix range of hue control
2023-02-11 9:11 ` Sergei Shtylyov
@ 2023-02-13 11:12 ` Laurent Pinchart
0 siblings, 0 replies; 7+ messages in thread
From: Laurent Pinchart @ 2023-02-13 11:12 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-media, linux-renesas-soc, Hans Verkuil
Hi Sergei,
On Sat, Feb 11, 2023 at 12:11:17PM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 2/11/23 1:56 AM, Laurent Pinchart wrote:
>
> > The ADV7604, ADV7611 and ADV7612 software manuals different the CP_HUE
>
> s/different/document/?
Indeed. I'll fix this in v2, but will wait for Hans to test the patches
on ADV7604 and/or ADV7611 before sending the new version.
> > value differently:
> >
> > - For ADV7604 and ADV7611, the hue is specified as an unsigned 8-bit
> > value, and calculated as
> >
> > (CP_HUE[7:0] * 180) / 256 - 90
> >
> > with the range set to [-90°, 90°]. Additionally, the values 0x00, 0x0f
> > and 0xff are documented as corresponding to -90°, 0° and 90°
> > respectively.
> >
> > - For ADV7612, the hue is specified as a signed 8-bit value in the range
> > [0°, 360°[ without any formula. Additionally, the value 0x00 is
> > documented as corresponding to 0°.
> >
> > The ADV7604 and ADV7611 documentation is clearly wrong as the example
> > values don't correspond to the formula. Furthermore, the [-90°, 90°]
> > range seems incorrect as it would cover only half of the hue space.
> >
> > The ADV7612 documentation is better, although the range should likely be
> > [-180°, 180°[ if the value is signed. Given that the values wrap around,
> > this makes no difference in practice.
> >
> > The hue values have been verified on ADV7612 to follow the
> > documentation. There is a high chance they do as well on ADV7604 and
> > ADV7611.
> >
> > In any case, all software manuals document the register as 8-bit, so the
> > current range of the V4L2 hue control [0, 128] is not correct. Expand it
> > to cover the full 8-bit space, using unsigned values to avoid breaking
> > any application that may rely on 128 being a valid value.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> [...]
>
> MBR, Sergey
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] media: i2c: adv7604: Enable video adjustment
2023-02-10 22:56 ` [PATCH 1/2] media: i2c: adv7604: Enable video adjustment Laurent Pinchart
@ 2023-02-15 12:49 ` Hans Verkuil
0 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2023-02-15 12:49 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: linux-renesas-soc
On 10/02/2023 23:56, Laurent Pinchart wrote:
> The video adjustments (contrast, brightness, saturation and hue) are
> ignored by default by the device when the VID_ADJ_EN bit is clear. The
> corresponding V4L2 controls exposed by the drivers have thus no effect.
> Fix this by setting the VID_ADJ_EN bit.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/i2c/adv7604.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 9d218962d7c8..3af0e67f9edb 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -1805,6 +1805,9 @@ static void select_input(struct v4l2_subdev *sd)
> v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n",
> __func__, state->selected_input);
> }
> +
> + /* Enable video adjustment (contrast, saturation, brightness and hue) */
> + cp_write_clr_set(sd, 0x3e, 0x80, 0x80);
> }
>
> static int adv76xx_s_routing(struct v4l2_subdev *sd,
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] media: i2c: adv7604: Fix range of hue control
2023-02-10 22:56 ` [PATCH 2/2] media: i2c: adv7604: Fix range of hue control Laurent Pinchart
2023-02-11 9:11 ` Sergei Shtylyov
@ 2023-02-15 12:49 ` Hans Verkuil
1 sibling, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2023-02-15 12:49 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: linux-renesas-soc
On 10/02/2023 23:56, Laurent Pinchart wrote:
> The ADV7604, ADV7611 and ADV7612 software manuals different the CP_HUE
> value differently:
>
> - For ADV7604 and ADV7611, the hue is specified as an unsigned 8-bit
> value, and calculated as
>
> (CP_HUE[7:0] * 180) / 256 - 90
>
> with the range set to [-90°, 90°]. Additionally, the values 0x00, 0x0f
> and 0xff are documented as corresponding to -90°, 0° and 90°
> respectively.
>
> - For ADV7612, the hue is specified as a signed 8-bit value in the range
> [0°, 360°[ without any formula. Additionally, the value 0x00 is
> documented as corresponding to 0°.
>
> The ADV7604 and ADV7611 documentation is clearly wrong as the example
> values don't correspond to the formula. Furthermore, the [-90°, 90°]
> range seems incorrect as it would cover only half of the hue space.
>
> The ADV7612 documentation is better, although the range should likely be
> [-180°, 180°[ if the value is signed. Given that the values wrap around,
> this makes no difference in practice.
>
> The hue values have been verified on ADV7612 to follow the
> documentation. There is a high chance they do as well on ADV7604 and
> ADV7611.
>
> In any case, all software manuals document the register as 8-bit, so the
> current range of the V4L2 hue control [0, 128] is not correct. Expand it
> to cover the full 8-bit space, using unsigned values to avoid breaking
> any application that may rely on 128 being a valid value.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/i2c/adv7604.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 3af0e67f9edb..3d0898c4175e 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -3548,7 +3548,7 @@ static int adv76xx_probe(struct i2c_client *client)
> v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
> V4L2_CID_SATURATION, 0, 255, 1, 128);
> v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
> - V4L2_CID_HUE, 0, 128, 1, 0);
> + V4L2_CID_HUE, 0, 255, 1, 0);
> ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops,
> V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
> 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
Tested with the adv7604.
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Thank you for looking at this!
Hans
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-15 12:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-10 22:56 [PATCH 0/2] media: i2c: adv7604: Fix handling of video adjustments Laurent Pinchart
2023-02-10 22:56 ` [PATCH 1/2] media: i2c: adv7604: Enable video adjustment Laurent Pinchart
2023-02-15 12:49 ` Hans Verkuil
2023-02-10 22:56 ` [PATCH 2/2] media: i2c: adv7604: Fix range of hue control Laurent Pinchart
2023-02-11 9:11 ` Sergei Shtylyov
2023-02-13 11:12 ` Laurent Pinchart
2023-02-15 12:49 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox