@@ -21,6 +21,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <media/cec-edid.h>
+#include <drm/drm_edid.h>
/*
* This EDID is expected to be a CEA-861 compliant, which means that there are
@@ -82,8 +83,8 @@ static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int size)
return 0;
}
-u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
- unsigned int *offset)
+u16 cec_get_raw_edid_phys_addr(const u8 *edid, unsigned int size,
+ unsigned int *offset)
{
unsigned int loc = cec_get_edid_spa_location(edid, size);
@@ -93,6 +94,16 @@ u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
return CEC_PHYS_ADDR_INVALID;
return (edid[loc] << 8) | edid[loc + 1];
}
+EXPORT_SYMBOL_GPL(cec_get_raw_edid_phys_addr);
+
+u16 cec_get_edid_phys_addr(const struct edid *edid)
+{
+ if (!edid || edid->extensions == 0)
+ return CEC_PHYS_ADDR_INVALID;
+
+ return cec_get_raw_edid_phys_addr((u8 *)edid,
+ EDID_LENGTH * (edid->extensions + 1), NULL);
+}
EXPORT_SYMBOL_GPL(cec_get_edid_phys_addr);
void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr)
@@ -1712,9 +1712,8 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments);
state->edid.complete = true;
- ed.phys_addr = cec_get_edid_phys_addr(state->edid.data,
- state->edid.segments * 256,
- NULL);
+ ed.phys_addr = cec_get_raw_edid_phys_addr(state->edid.data,
+ state->edid.segments * 256, NULL);
/* report when we have all segments
but report only for segment 0
*/
@@ -2305,7 +2305,8 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
edid->blocks = 2;
return -E2BIG;
}
- pa = cec_get_edid_phys_addr(edid->edid, edid->blocks * 128, &spa_loc);
+ pa = cec_get_raw_edid_phys_addr(edid->edid,
+ edid->blocks * 128, &spa_loc);
err = cec_phys_addr_validate(pa, &pa, NULL);
if (err)
return err;
@@ -802,7 +802,7 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port)
if (!state->hdmi_edid.present)
return 0;
- pa = cec_get_edid_phys_addr(edid, 256, &spa_loc);
+ pa = cec_get_raw_edid_phys_addr(edid, 256, &spa_loc);
err = cec_phys_addr_validate(pa, &pa, NULL);
if (err)
return err;
@@ -1736,7 +1736,8 @@ int vidioc_s_edid(struct file *file, void *_fh,
edid->blocks = dev->edid_max_blocks;
return -E2BIG;
}
- phys_addr = cec_get_edid_phys_addr(edid->edid, edid->blocks * 128, NULL);
+ phys_addr = cec_get_raw_edid_phys_addr(edid->edid,
+ edid->blocks * 128, NULL);
ret = cec_phys_addr_validate(phys_addr, &phys_addr, NULL);
if (ret)
return ret;
@@ -27,7 +27,7 @@
((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf
/**
- * cec_get_edid_phys_addr() - find and return the physical address
+ * cec_get_raw_edid_phys_addr() - find and return the physical address
*
* @edid: pointer to the EDID data
* @size: size in bytes of the EDID data
@@ -37,8 +37,19 @@
*
* Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none.
*/
-u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
- unsigned int *offset);
+u16 cec_get_raw_edid_phys_addr(const u8 *edid, unsigned int size,
+ unsigned int *offset);
+
+struct edid;
+
+/**
+ * cec_get_edid_phys_addr() - find and return the physical address
+ *
+ * @edid: pointer to struct edid
+ *
+ * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none.
+ */
+u16 cec_get_edid_phys_addr(const struct edid *edid);
/**
* cec_set_edid_phys_addr() - find and set the physical address