diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-06-28 11:43:01 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-12 13:35:46 -0300 |
commit | fd74246d2ade37cd477178652448410a35bdaca0 (patch) | |
tree | dff71bf9820163b116acb8fb99bff332ccc1432c /drivers/media/i2c/adv7842.c | |
parent | 0a25a0125194639507cf24319d02f5de63d182b5 (diff) |
[media] adv7604/adv7842: fix quantization range handling
Fix a number of bugs that appeared when support for mediabus formats was
added:
- Support for V4L2_DV_RGB_RANGE_FULL/LIMITED should only be enabled
for HDMI RGB formats, not for YCbCr formats. Since, as the name
says, this setting is for RGB only. So read the InfoFrame to check
the format.
- the quantization range for the pixelport depends on whether the
mediabus code is RGB or not: if it is RGB, then produce full range
RGB values, otherwise produce limited range YCbCr values.
This means that the op_656_range and alt_data_sat fields of the
platform data are no longer used and these will be removed in a
following patch.
- when setting up a new format the RGB quantization range settings
were never updated. Do so, since this depends on the format.
- fix the log_status output which was confusing and incorrect.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/i2c/adv7842.c')
-rw-r--r-- | drivers/media/i2c/adv7842.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 100bd3f96b59..8c2a52e280af 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -1184,6 +1184,10 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) struct adv7842_state *state = to_state(sd); bool rgb_output = io_read(sd, 0x02) & 0x02; bool hdmi_signal = hdmi_read(sd, 0x05) & 0x80; + u8 y = HDMI_COLORSPACE_RGB; + + if (hdmi_signal && (io_read(sd, 0x60) & 1)) + y = infoframe_read(sd, 0x01) >> 5; v4l2_dbg(2, debug, sd, "%s: RGB quantization range: %d, RGB out: %d, HDMI: %d\n", __func__, state->rgb_quantization_range, @@ -1191,6 +1195,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) adv7842_set_gain(sd, true, 0x0, 0x0, 0x0); adv7842_set_offset(sd, true, 0x0, 0x0, 0x0); + io_write_clr_set(sd, 0x02, 0x04, rgb_output ? 0 : 4); switch (state->rgb_quantization_range) { case V4L2_DV_RGB_RANGE_AUTO: @@ -1240,6 +1245,9 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) break; } + if (y != HDMI_COLORSPACE_RGB) + break; + /* RGB limited range (16-235) */ io_write_and_or(sd, 0x02, 0x0f, 0x00); @@ -1251,6 +1259,9 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd) break; } + if (y != HDMI_COLORSPACE_RGB) + break; + /* RGB full range (0-255) */ io_write_and_or(sd, 0x02, 0x0f, 0x10); @@ -2058,6 +2069,7 @@ static void adv7842_setup_format(struct adv7842_state *state) io_write_clr_set(sd, 0x04, 0xe0, adv7842_op_ch_sel(state)); io_write_clr_set(sd, 0x05, 0x01, state->format->swap_cb_cr ? ADV7842_OP_SWAP_CB_CR : 0); + set_rgb_quantization_range(sd); } static int adv7842_get_format(struct v4l2_subdev *sd, @@ -2777,11 +2789,11 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd) rgb_quantization_range_txt[state->rgb_quantization_range]); v4l2_info(sd, "Input color space: %s\n", input_color_space_txt[reg_io_0x02 >> 4]); - v4l2_info(sd, "Output color space: %s %s, saturator %s\n", + v4l2_info(sd, "Output color space: %s %s, alt-gamma %s\n", (reg_io_0x02 & 0x02) ? "RGB" : "YCbCr", - (reg_io_0x02 & 0x04) ? "(16-235)" : "(0-255)", - ((reg_io_0x02 & 0x04) ^ (reg_io_0x02 & 0x01)) ? - "enabled" : "disabled"); + (((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ? + "(16-235)" : "(0-255)", + (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); v4l2_info(sd, "Color space conversion: %s\n", csc_coeff_sel_rb[cp_read(sd, 0xf4) >> 4]); @@ -2985,11 +2997,7 @@ static int adv7842_core_init(struct v4l2_subdev *sd) io_write(sd, 0x15, 0x80); /* Power up pads */ /* video format */ - io_write(sd, 0x02, - 0xf0 | - pdata->alt_gamma << 3 | - pdata->op_656_range << 2 | - pdata->alt_data_sat << 0); + io_write(sd, 0x02, 0xf0 | pdata->alt_gamma << 3); io_write_and_or(sd, 0x05, 0xf0, pdata->blank_data << 3 | pdata->insert_av_codes << 2 | pdata->replicate_av_codes << 1); |