linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] [media] adv7842 fixes
@ 2014-03-19  9:43 Martin Bugge
  2014-03-19  9:43 ` [PATCH 1/3] [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq Martin Bugge
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Martin Bugge @ 2014-03-19  9:43 UTC (permalink / raw)
  To: linux-media

This patch series applies a few fixes for adv7842 from Cisco's internal tree.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq.
  2014-03-19  9:43 [PATCH 0/3] [media] adv7842 fixes Martin Bugge
@ 2014-03-19  9:43 ` Martin Bugge
  2014-03-19  9:43 ` [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame Martin Bugge
  2014-03-19  9:43 ` [PATCH 3/3] [media] adv7842: Disable access to EDID DDC lines before chip power up Martin Bugge
  2 siblings, 0 replies; 6+ messages in thread
From: Martin Bugge @ 2014-03-19  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Martin Bugge

This was the reason for enabling the HDMI/DVI-D mode irq in the first place.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
---
 drivers/media/i2c/adv7842.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 636ac08..5d79c57 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2000,6 +2000,7 @@ static int adv7842_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
 	if (irq_status[5] & 0x08) {
 		v4l2_dbg(1, debug, sd, "%s: irq %s mode\n", __func__,
 			 (io_read(sd, 0x65) & 0x08) ? "HDMI" : "DVI");
+		set_rgb_quantization_range(sd);
 		if (handled)
 			*handled = true;
 	}
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame
  2014-03-19  9:43 [PATCH 0/3] [media] adv7842 fixes Martin Bugge
  2014-03-19  9:43 ` [PATCH 1/3] [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq Martin Bugge
@ 2014-03-19  9:43 ` Martin Bugge
  2014-03-19 10:13   ` Hans Verkuil
  2014-03-19  9:43 ` [PATCH 3/3] [media] adv7842: Disable access to EDID DDC lines before chip power up Martin Bugge
  2 siblings, 1 reply; 6+ messages in thread
From: Martin Bugge @ 2014-03-19  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Martin Bugge

Decode and display any received SPD InfoFrame in log-status.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
---
 drivers/media/i2c/adv7842.c | 76 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 5d79c57..805a117 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2243,6 +2243,81 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
 		v4l2_info(sd, "\t%s %s\n", y10_txt[avi.y10], q10_txt[avi.q10]);
 }
 
+static const char *sdi_txt(u8 code)
+{
+	switch (code) {
+	case 0x00: return "unknown";
+	case 0x01: return "Digital STB";
+	case 0x02: return "DVD player";
+	case 0x03: return "D-VHS";
+	case 0x04: return "HDD Videorecorder";
+	case 0x05: return "DVC";
+	case 0x06: return "DSC";
+	case 0x07: return "Video CD";
+	case 0x08: return "Game";
+	case 0x09: return "PC general";
+	case 0x0a: return "Blu-Ray Disc (BD)";
+	case 0x0b: return "Super Audio CD";
+	}
+	return "Reserved";
+}
+
+static void print_spd_info_frame(struct v4l2_subdev *sd)
+{
+	int i;
+	u8 spd_type;
+	u8 spd_ver;
+	u8 spd_len;
+	u8 spd_crc;
+	u8 buf[32];
+	u8 vn[8];
+	u8 pd[16];
+	u8 sdi;
+
+	if (!(hdmi_read(sd, 0x05) & 0x80)) {
+		v4l2_info(sd, "receive DVI-D signal (SDP infoframe not supported)\n");
+		return;
+	}
+	if (!(io_read(sd, 0x60) & 0x04)) {
+		v4l2_info(sd, "SDP infoframe not received\n");
+		return;
+	}
+
+	if (io_read(sd, 0x88) & 0x40) {
+		v4l2_info(sd, "SPD infoframe checksum error has occurred earlier\n");
+		io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
+		if (io_read(sd, 0x88) & 0x40) {
+			v4l2_info(sd, "SPD infoframe checksum error still present\n");
+			io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
+		}
+	}
+
+	spd_type = infoframe_read(sd, 0xe6) & 0x7f;
+	spd_ver = infoframe_read(sd, 0xe7);
+	spd_len = infoframe_read(sd, 0xe8);
+	spd_crc = infoframe_read(sd, 0x2a);
+
+	v4l2_info(sd, "SPD infoframe type %d, version %d, crc 0x%x, len %d\n",
+		  spd_type, spd_ver, spd_crc, spd_len);
+
+	if (spd_type != 0x03)
+		return;
+	if (spd_ver != 0x01)
+		return;
+
+	memset(buf, 0, sizeof(buf));
+	for (i = 0; i < 25 && i < spd_len; i++)
+		buf[i] = infoframe_read(sd, i + 0x2b);
+
+	snprintf(vn, 8, buf);
+	snprintf(pd, 16, buf + 8);
+	sdi = buf[24];
+
+	v4l2_info(sd, "\tVendor Name: %s\n", vn);
+	v4l2_info(sd, "\tProduct Description: %s\n", pd);
+	v4l2_info(sd, "\tSource Device Information: %s (%d)\n", sdi_txt(sdi), sdi);
+}
+
 static const char * const prim_mode_txt[] = {
 	"SDP",
 	"Component",
@@ -2455,6 +2530,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
 			deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]);
 
 	print_avi_infoframe(sd);
+	print_spd_info_frame(sd);
 	return 0;
 }
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] [media] adv7842: Disable access to EDID DDC lines before chip power up.
  2014-03-19  9:43 [PATCH 0/3] [media] adv7842 fixes Martin Bugge
  2014-03-19  9:43 ` [PATCH 1/3] [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq Martin Bugge
  2014-03-19  9:43 ` [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame Martin Bugge
@ 2014-03-19  9:43 ` Martin Bugge
  2 siblings, 0 replies; 6+ messages in thread
From: Martin Bugge @ 2014-03-19  9:43 UTC (permalink / raw)
  To: linux-media; +Cc: Martin Bugge

In core_init make sure access to EDID DDC lines are disabled
before chip is powered up. Also DISABLE_AUTO_EDID before power up.
The correct setting is applied later when setting the EDID.
Some sources (MAC) kept on reading EDID even when Hotplug was low
and in the short period in core_init before the DDC lines was enabled
read a corrupt EDID.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
---
 drivers/media/i2c/adv7842.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 805a117..3b3bd42 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2687,6 +2687,12 @@ static int adv7842_core_init(struct v4l2_subdev *sd)
 
 	disable_input(sd);
 
+	/*
+	 * Disable I2C access to internal EDID ram from HDMI DDC ports
+	 * Disable auto edid enable when leaving powerdown mode
+	 */
+	rep_write_and_or(sd, 0x77, 0xd3, 0x20);
+
 	/* power */
 	io_write(sd, 0x0c, 0x42);   /* Power up part and power down VDP */
 	io_write(sd, 0x15, 0x80);   /* Power up pads */
@@ -2767,9 +2773,6 @@ static int adv7842_core_init(struct v4l2_subdev *sd)
 
 	enable_input(sd);
 
-	/* disable I2C access to internal EDID ram from HDMI DDC ports */
-	rep_write_and_or(sd, 0x77, 0xf3, 0x00);
-
 	if (pdata->hpa_auto) {
 		/* HPA auto, HPA 0.5s after Edid set and Cable detect */
 		hdmi_write(sd, 0x69, 0x5c);
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame
  2014-03-19  9:43 ` [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame Martin Bugge
@ 2014-03-19 10:13   ` Hans Verkuil
  2014-03-19 11:24     ` Martin Bugge (marbugge)
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Verkuil @ 2014-03-19 10:13 UTC (permalink / raw)
  To: Martin Bugge; +Cc: linux-media

Hi Martin,

On 03/19/14 10:43, Martin Bugge wrote:
> Decode and display any received SPD InfoFrame in log-status.

This is really quite standardized data. I looked around in the kernel
and I found this very nice header: include/linux/hdmi.h and source
drivers/video/hdmi.c.

I would suggest that the adv7842 driver fills the hdmi_spd_infoframe
struct and calls a function in v4l2_dv_timings.c to log the contents.

That way it can also be used by e.g. adv7604. We really should be using
this header for other frame types as well.

Actually, I think you should ask on the dri-devel mailinglist (with a
CC to the active maintainers of the hdmi.c source, see 'git log') whether
creating an hdmi_spd_infoframe_log function would be useful to add to
hdmi.c. If they don't like it, then we stick it in v4l2_dv_timings.c. If
they do like it, we can just add it to hdmi.c. It's something that is
primarily useful for receivers, and not so much for transmitters, so they
might not want it in the hdmi.c source.

> 
> Signed-off-by: Martin Bugge <marbugge@cisco.com>
> ---
>  drivers/media/i2c/adv7842.c | 76 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
> 
> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
> index 5d79c57..805a117 100644
> --- a/drivers/media/i2c/adv7842.c
> +++ b/drivers/media/i2c/adv7842.c
> @@ -2243,6 +2243,81 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
>  		v4l2_info(sd, "\t%s %s\n", y10_txt[avi.y10], q10_txt[avi.q10]);
>  }
>  
> +static const char *sdi_txt(u8 code)
> +{
> +	switch (code) {
> +	case 0x00: return "unknown";

"unknown" -> "Unknown"

to be consistent with the others.

Regards,

	Hans

> +	case 0x01: return "Digital STB";
> +	case 0x02: return "DVD player";
> +	case 0x03: return "D-VHS";
> +	case 0x04: return "HDD Videorecorder";
> +	case 0x05: return "DVC";
> +	case 0x06: return "DSC";
> +	case 0x07: return "Video CD";
> +	case 0x08: return "Game";
> +	case 0x09: return "PC general";
> +	case 0x0a: return "Blu-Ray Disc (BD)";
> +	case 0x0b: return "Super Audio CD";
> +	}
> +	return "Reserved";
> +}
> +
> +static void print_spd_info_frame(struct v4l2_subdev *sd)
> +{
> +	int i;
> +	u8 spd_type;
> +	u8 spd_ver;
> +	u8 spd_len;
> +	u8 spd_crc;
> +	u8 buf[32];
> +	u8 vn[8];
> +	u8 pd[16];
> +	u8 sdi;
> +
> +	if (!(hdmi_read(sd, 0x05) & 0x80)) {
> +		v4l2_info(sd, "receive DVI-D signal (SDP infoframe not supported)\n");
> +		return;
> +	}
> +	if (!(io_read(sd, 0x60) & 0x04)) {
> +		v4l2_info(sd, "SDP infoframe not received\n");
> +		return;
> +	}
> +
> +	if (io_read(sd, 0x88) & 0x40) {
> +		v4l2_info(sd, "SPD infoframe checksum error has occurred earlier\n");
> +		io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
> +		if (io_read(sd, 0x88) & 0x40) {
> +			v4l2_info(sd, "SPD infoframe checksum error still present\n");
> +			io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
> +		}
> +	}
> +
> +	spd_type = infoframe_read(sd, 0xe6) & 0x7f;
> +	spd_ver = infoframe_read(sd, 0xe7);
> +	spd_len = infoframe_read(sd, 0xe8);
> +	spd_crc = infoframe_read(sd, 0x2a);
> +
> +	v4l2_info(sd, "SPD infoframe type %d, version %d, crc 0x%x, len %d\n",
> +		  spd_type, spd_ver, spd_crc, spd_len);
> +
> +	if (spd_type != 0x03)
> +		return;
> +	if (spd_ver != 0x01)
> +		return;
> +
> +	memset(buf, 0, sizeof(buf));
> +	for (i = 0; i < 25 && i < spd_len; i++)
> +		buf[i] = infoframe_read(sd, i + 0x2b);
> +
> +	snprintf(vn, 8, buf);
> +	snprintf(pd, 16, buf + 8);
> +	sdi = buf[24];
> +
> +	v4l2_info(sd, "\tVendor Name: %s\n", vn);
> +	v4l2_info(sd, "\tProduct Description: %s\n", pd);
> +	v4l2_info(sd, "\tSource Device Information: %s (%d)\n", sdi_txt(sdi), sdi);
> +}
> +
>  static const char * const prim_mode_txt[] = {
>  	"SDP",
>  	"Component",
> @@ -2455,6 +2530,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
>  			deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]);
>  
>  	print_avi_infoframe(sd);
> +	print_spd_info_frame(sd);
>  	return 0;
>  }
>  
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame
  2014-03-19 10:13   ` Hans Verkuil
@ 2014-03-19 11:24     ` Martin Bugge (marbugge)
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Bugge (marbugge) @ 2014-03-19 11:24 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

Thank you Hans

On 19/03/14 11:13, Hans Verkuil wrote:
> Hi Martin,
>
> On 03/19/14 10:43, Martin Bugge wrote:
>> Decode and display any received SPD InfoFrame in log-status.
> This is really quite standardized data. I looked around in the kernel
> and I found this very nice header: include/linux/hdmi.h and source
> drivers/video/hdmi.c.
>
> I would suggest that the adv7842 driver fills the hdmi_spd_infoframe
> struct and calls a function in v4l2_dv_timings.c to log the contents.
>
> That way it can also be used by e.g. adv7604. We really should be using
> this header for other frame types as well.
>
> Actually, I think you should ask on the dri-devel mailinglist (with a
> CC to the active maintainers of the hdmi.c source, see 'git log') whether
> creating an hdmi_spd_infoframe_log function would be useful to add to
> hdmi.c. If they don't like it, then we stick it in v4l2_dv_timings.c. If
> they do like it, we can just add it to hdmi.c. It's something that is
> primarily useful for receivers, and not so much for transmitters, so they
> might not want it in the hdmi.c source.
Yes you are right, it could be nice to have decoding of these Packets in 
a common place.
I have added the same code to adv7604 as well so its already duplicated. 
I will look into it.
I think the two other patches should apply ok. They are bug fixes.

Regards,
Martin

>
>> Signed-off-by: Martin Bugge <marbugge@cisco.com>
>> ---
>>   drivers/media/i2c/adv7842.c | 76 +++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 76 insertions(+)
>>
>> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
>> index 5d79c57..805a117 100644
>> --- a/drivers/media/i2c/adv7842.c
>> +++ b/drivers/media/i2c/adv7842.c
>> @@ -2243,6 +2243,81 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
>>   		v4l2_info(sd, "\t%s %s\n", y10_txt[avi.y10], q10_txt[avi.q10]);
>>   }
>>   
>> +static const char *sdi_txt(u8 code)
>> +{
>> +	switch (code) {
>> +	case 0x00: return "unknown";
> "unknown" -> "Unknown"
>
> to be consistent with the others.
>
> Regards,
>
> 	Hans
>
>> +	case 0x01: return "Digital STB";
>> +	case 0x02: return "DVD player";
>> +	case 0x03: return "D-VHS";
>> +	case 0x04: return "HDD Videorecorder";
>> +	case 0x05: return "DVC";
>> +	case 0x06: return "DSC";
>> +	case 0x07: return "Video CD";
>> +	case 0x08: return "Game";
>> +	case 0x09: return "PC general";
>> +	case 0x0a: return "Blu-Ray Disc (BD)";
>> +	case 0x0b: return "Super Audio CD";
>> +	}
>> +	return "Reserved";
>> +}
>> +
>> +static void print_spd_info_frame(struct v4l2_subdev *sd)
>> +{
>> +	int i;
>> +	u8 spd_type;
>> +	u8 spd_ver;
>> +	u8 spd_len;
>> +	u8 spd_crc;
>> +	u8 buf[32];
>> +	u8 vn[8];
>> +	u8 pd[16];
>> +	u8 sdi;
>> +
>> +	if (!(hdmi_read(sd, 0x05) & 0x80)) {
>> +		v4l2_info(sd, "receive DVI-D signal (SDP infoframe not supported)\n");
>> +		return;
>> +	}
>> +	if (!(io_read(sd, 0x60) & 0x04)) {
>> +		v4l2_info(sd, "SDP infoframe not received\n");
>> +		return;
>> +	}
>> +
>> +	if (io_read(sd, 0x88) & 0x40) {
>> +		v4l2_info(sd, "SPD infoframe checksum error has occurred earlier\n");
>> +		io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
>> +		if (io_read(sd, 0x88) & 0x40) {
>> +			v4l2_info(sd, "SPD infoframe checksum error still present\n");
>> +			io_write(sd, 0x8a, 0x40); /* clear SPD_INF_CKS_ERR_RAW */
>> +		}
>> +	}
>> +
>> +	spd_type = infoframe_read(sd, 0xe6) & 0x7f;
>> +	spd_ver = infoframe_read(sd, 0xe7);
>> +	spd_len = infoframe_read(sd, 0xe8);
>> +	spd_crc = infoframe_read(sd, 0x2a);
>> +
>> +	v4l2_info(sd, "SPD infoframe type %d, version %d, crc 0x%x, len %d\n",
>> +		  spd_type, spd_ver, spd_crc, spd_len);
>> +
>> +	if (spd_type != 0x03)
>> +		return;
>> +	if (spd_ver != 0x01)
>> +		return;
>> +
>> +	memset(buf, 0, sizeof(buf));
>> +	for (i = 0; i < 25 && i < spd_len; i++)
>> +		buf[i] = infoframe_read(sd, i + 0x2b);
>> +
>> +	snprintf(vn, 8, buf);
>> +	snprintf(pd, 16, buf + 8);
>> +	sdi = buf[24];
>> +
>> +	v4l2_info(sd, "\tVendor Name: %s\n", vn);
>> +	v4l2_info(sd, "\tProduct Description: %s\n", pd);
>> +	v4l2_info(sd, "\tSource Device Information: %s (%d)\n", sdi_txt(sdi), sdi);
>> +}
>> +
>>   static const char * const prim_mode_txt[] = {
>>   	"SDP",
>>   	"Component",
>> @@ -2455,6 +2530,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
>>   			deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]);
>>   
>>   	print_avi_infoframe(sd);
>> +	print_spd_info_frame(sd);
>>   	return 0;
>>   }
>>   
>>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-19 11:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19  9:43 [PATCH 0/3] [media] adv7842 fixes Martin Bugge
2014-03-19  9:43 ` [PATCH 1/3] [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq Martin Bugge
2014-03-19  9:43 ` [PATCH 2/3] [media] adv7842: Source Product Description (SPD) InfoFrame Martin Bugge
2014-03-19 10:13   ` Hans Verkuil
2014-03-19 11:24     ` Martin Bugge (marbugge)
2014-03-19  9:43 ` [PATCH 3/3] [media] adv7842: Disable access to EDID DDC lines before chip power up Martin Bugge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).