Commit 516613c1 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] adv7604: log infoframes

Add support for logging the detected InfoFrames for the adv76xx. Helps in
debugging what is actually received on the HDMI link.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent b4dbad8f
...@@ -197,6 +197,7 @@ config VIDEO_ADV7183 ...@@ -197,6 +197,7 @@ config VIDEO_ADV7183
config VIDEO_ADV7604 config VIDEO_ADV7604
tristate "Analog Devices ADV7604 decoder" tristate "Analog Devices ADV7604 decoder"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && GPIOLIB depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && GPIOLIB
select HDMI
---help--- ---help---
Support for the Analog Devices ADV7604 video decoder. Support for the Analog Devices ADV7604 video decoder.
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/hdmi.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -95,6 +96,13 @@ struct adv76xx_format_info { ...@@ -95,6 +96,13 @@ struct adv76xx_format_info {
u8 op_format_sel; u8 op_format_sel;
}; };
struct adv76xx_cfg_read_infoframe {
const char *desc;
u8 present_mask;
u8 head_addr;
u8 payload_addr;
};
struct adv76xx_chip_info { struct adv76xx_chip_info {
enum adv76xx_type type; enum adv76xx_type type;
...@@ -2127,46 +2135,67 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) ...@@ -2127,46 +2135,67 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
/*********** avi info frame CEA-861-E **************/ /*********** avi info frame CEA-861-E **************/
static void print_avi_infoframe(struct v4l2_subdev *sd) static const struct adv76xx_cfg_read_infoframe adv76xx_cri[] = {
{ "AVI", 0x01, 0xe0, 0x00 },
{ "Audio", 0x02, 0xe3, 0x1c },
{ "SDP", 0x04, 0xe6, 0x2a },
{ "Vendor", 0x10, 0xec, 0x54 }
};
static int adv76xx_read_infoframe(struct v4l2_subdev *sd, int index,
union hdmi_infoframe *frame)
{ {
uint8_t buffer[32];
u8 len;
int i; int i;
u8 buf[14];
u8 avi_len;
u8 avi_ver;
if (!is_hdmi(sd)) { if (!(io_read(sd, 0x60) & adv76xx_cri[index].present_mask)) {
v4l2_info(sd, "receive DVI-D signal (AVI infoframe not supported)\n"); v4l2_info(sd, "%s infoframe not received\n",
return; adv76xx_cri[index].desc);
return -ENOENT;
} }
if (!(io_read(sd, 0x60) & 0x01)) {
v4l2_info(sd, "AVI infoframe not received\n"); for (i = 0; i < 3; i++)
return; buffer[i] = infoframe_read(sd,
adv76xx_cri[index].head_addr + i);
len = buffer[2] + 1;
if (len + 3 > sizeof(buffer)) {
v4l2_err(sd, "%s: invalid %s infoframe length %d\n", __func__,
adv76xx_cri[index].desc, len);
return -ENOENT;
} }
if (io_read(sd, 0x83) & 0x01) { for (i = 0; i < len; i++)
v4l2_info(sd, "AVI infoframe checksum error has occurred earlier\n"); buffer[i + 3] = infoframe_read(sd,
io_write(sd, 0x85, 0x01); /* clear AVI_INF_CKS_ERR_RAW */ adv76xx_cri[index].payload_addr + i);
if (io_read(sd, 0x83) & 0x01) {
v4l2_info(sd, "AVI infoframe checksum error still present\n"); if (hdmi_infoframe_unpack(frame, buffer) < 0) {
io_write(sd, 0x85, 0x01); /* clear AVI_INF_CKS_ERR_RAW */ v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__,
} adv76xx_cri[index].desc);
return -ENOENT;
} }
return 0;
}
avi_len = infoframe_read(sd, 0xe2); static void adv76xx_log_infoframes(struct v4l2_subdev *sd)
avi_ver = infoframe_read(sd, 0xe1); {
v4l2_info(sd, "AVI infoframe version %d (%d byte)\n", int i;
avi_ver, avi_len);
if (avi_ver != 0x02) if (!is_hdmi(sd)) {
v4l2_info(sd, "receive DVI-D signal, no infoframes\n");
return; return;
}
for (i = 0; i < 14; i++) for (i = 0; i < ARRAY_SIZE(adv76xx_cri); i++) {
buf[i] = infoframe_read(sd, i); union hdmi_infoframe frame;
struct i2c_client *client = v4l2_get_subdevdata(sd);
v4l2_info(sd, if (adv76xx_read_infoframe(sd, i, &frame))
"\t%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", return;
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], hdmi_infoframe_log(KERN_INFO, &client->dev, &frame);
buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]); }
} }
static int adv76xx_log_status(struct v4l2_subdev *sd) static int adv76xx_log_status(struct v4l2_subdev *sd)
...@@ -2302,7 +2331,7 @@ static int adv76xx_log_status(struct v4l2_subdev *sd) ...@@ -2302,7 +2331,7 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
v4l2_info(sd, "Deep color mode: %s\n", deep_color_mode_txt[(hdmi_read(sd, 0x0b) & 0x60) >> 5]); v4l2_info(sd, "Deep color mode: %s\n", deep_color_mode_txt[(hdmi_read(sd, 0x0b) & 0x60) >> 5]);
print_avi_infoframe(sd); adv76xx_log_infoframes(sd);
} }
return 0; return 0;
......
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