Commit 937fce13 authored by Tomi Valkeinen's avatar Tomi Valkeinen

OMAP: DSS2: HDMI: clean up edid reading & fix checksum

Clean up reading of EDID by passing direct address to the block being
read, instead of start address of the whole EDID memory area. Rewrite
the loop which reads the EDID.

This also fixes the checksum calculation, which used to calculate the
checksum only for the first block.

Cc: Mythri P K <mythripk@ti.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 032b8ea5
...@@ -92,8 +92,7 @@ struct ti_hdmi_ip_ops { ...@@ -92,8 +92,7 @@ struct ti_hdmi_ip_ops {
void (*phy_disable)(struct hdmi_ip_data *ip_data); void (*phy_disable)(struct hdmi_ip_data *ip_data);
int (*read_edid)(struct hdmi_ip_data *ip_data, int (*read_edid)(struct hdmi_ip_data *ip_data, u8 *edid, int len);
u8 *pedid, u16 max_length);
int (*pll_enable)(struct hdmi_ip_data *ip_data); int (*pll_enable)(struct hdmi_ip_data *ip_data);
...@@ -114,8 +113,7 @@ struct hdmi_ip_data { ...@@ -114,8 +113,7 @@ struct hdmi_ip_data {
}; };
int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data); int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data);
void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data); void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data);
int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data, int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data, u8 *edid, int len);
u8 *pedid, u16 max_length);
void ti_hdmi_4xxx_wp_video_start(struct hdmi_ip_data *ip_data, bool start); void ti_hdmi_4xxx_wp_video_start(struct hdmi_ip_data *ip_data, bool start);
int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data); int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data);
void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data); void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data);
......
...@@ -310,8 +310,8 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data, ...@@ -310,8 +310,8 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
u8 *pedid, int ext) u8 *pedid, int ext)
{ {
void __iomem *base = hdmi_core_sys_base(ip_data); void __iomem *base = hdmi_core_sys_base(ip_data);
u32 i, j; u32 i;
char checksum = 0; char checksum;
u32 offset = 0; u32 offset = 0;
/* HDMI_CORE_DDC_STATUS_IN_PROG */ /* HDMI_CORE_DDC_STATUS_IN_PROG */
...@@ -354,21 +354,31 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data, ...@@ -354,21 +354,31 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
return -EIO; return -EIO;
} }
i = ext * 128; for (i = 0; i < 0x80; ++i) {
j = 0; int t;
while (((REG_GET(base, HDMI_CORE_DDC_STATUS, 4, 4) == 1) ||
(REG_GET(base, HDMI_CORE_DDC_STATUS, 2, 2) == 0)) &&
j < 128) {
if (REG_GET(base, HDMI_CORE_DDC_STATUS, 2, 2) == 0) { /* IN_PROG */
/* FIFO not empty */ if (REG_GET(base, HDMI_CORE_DDC_STATUS, 4, 4) == 0) {
pedid[i++] = REG_GET(base, HDMI_CORE_DDC_DATA, 7, 0); DSSERR("operation stopped when reading edid\n");
j++; return -EIO;
}
t = 0;
/* FIFO_EMPTY */
while (REG_GET(base, HDMI_CORE_DDC_STATUS, 2, 2) == 1) {
if (t++ > 10000) {
DSSERR("timeout reading edid\n");
return -ETIMEDOUT;
}
udelay(1);
} }
pedid[i] = REG_GET(base, HDMI_CORE_DDC_DATA, 7, 0);
} }
for (j = 0; j < 128; j++) checksum = 0;
checksum += pedid[j]; for (i = 0; i < 0x80; ++i)
checksum += pedid[i];
if (checksum != 0) { if (checksum != 0) {
pr_err("E-EDID checksum failed!!\n"); pr_err("E-EDID checksum failed!!\n");
...@@ -379,40 +389,31 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data, ...@@ -379,40 +389,31 @@ static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
} }
int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data, int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data,
u8 *pedid, u16 max_length) u8 *edid, int len)
{ {
int r = 0, n = 0, i = 0; int r, l;
int max_ext_blocks = (max_length / 128) - 1;
int len; if (len < 128)
return -EINVAL;
r = hdmi_core_ddc_init(ip_data); r = hdmi_core_ddc_init(ip_data);
if (r) if (r)
return r; return r;
r = hdmi_core_ddc_edid(ip_data, pedid, 0); r = hdmi_core_ddc_edid(ip_data, edid, 0);
if (r) if (r)
return r; return r;
len = 128; l = 128;
n = pedid[0x7e];
/*
* README: need to comply with max_length set by the caller.
* Better implementation should be to allocate necessary
* memory to store EDID according to nb_block field found
* in first block
*/
if (n > max_ext_blocks)
n = max_ext_blocks;
for (i = 1; i <= n; i++) { if (len >= 128 * 2 && edid[0x7e] > 0) {
r = hdmi_core_ddc_edid(ip_data, pedid, i); r = hdmi_core_ddc_edid(ip_data, edid + 0x80, 1);
if (r) if (r)
return r; return r;
len += 128; l += 128;
} }
return len; return l;
} }
static void hdmi_core_init(struct hdmi_core_video_config *video_cfg, static void hdmi_core_init(struct hdmi_core_video_config *video_cfg,
......
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