Commit 68a9ca45 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Hans Verkuil

media: i2c: adv7604: Fix range of hue control

The ADV7604, ADV7611 and ADV7612 software manuals document 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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 4c5681ac
...@@ -3548,7 +3548,7 @@ static int adv76xx_probe(struct i2c_client *client) ...@@ -3548,7 +3548,7 @@ static int adv76xx_probe(struct i2c_client *client)
v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
V4L2_CID_SATURATION, 0, 255, 1, 128); V4L2_CID_SATURATION, 0, 255, 1, 128);
v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, 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, ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops,
V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC, V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC); 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
......
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