[PATCH 49/72] imx-drm: imx-ldb: Add DDC support

2014-11-04 Thread Philipp Zabel
Am Freitag, den 31.10.2014, 15:54 -0700 schrieb Steve Longerbeam:
> Add support for reading EDID over Display Data Channel. If no DDC
> adapter is available, falls back to hardcoded EDID or display-timings
> node as before.
> 
> Signed-off-by: Steve Longerbeam 

Acked-by: Philipp Zabel 

regards
Philipp



[PATCH 49/72] imx-drm: imx-ldb: Add DDC support

2014-10-31 Thread Steve Longerbeam
Add support for reading EDID over Display Data Channel. If no DDC
adapter is available, falls back to hardcoded EDID or display-timings
node as before.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/imx-drm/imx-ldb.c |   39 +
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/imx-drm/imx-ldb.c 
b/drivers/staging/imx-drm/imx-ldb.c
index 1eb632f..6c16cf2 100644
--- a/drivers/staging/imx-drm/imx-ldb.c
+++ b/drivers/staging/imx-drm/imx-ldb.c
@@ -61,6 +61,7 @@ struct imx_ldb_channel {
struct drm_connector connector;
struct drm_encoder encoder;
struct device_node *child;
+   struct i2c_adapter *ddc;
int chno;
void *edid;
int edid_len;
@@ -103,6 +104,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector 
*connector)

imx_ldb_entry_dbg(imx_ldb_ch);

+   if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
+   imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
+
if (imx_ldb_ch->edid) {
drm_mode_connector_update_edid_property(connector,
imx_ldb_ch->edid);
@@ -529,6 +533,7 @@ static int imx_ldb_bind(struct device *dev, struct device 
*master, void *data)

for_each_child_of_node(np, child) {
struct imx_ldb_channel *channel;
+   struct device_node *ddc_node;

ret = of_property_read_u32(child, "reg", &i);
if (ret || i < 0 || i > 1)
@@ -547,14 +552,30 @@ static int imx_ldb_bind(struct device *dev, struct device 
*master, void *data)
channel->chno = i;
channel->child = child;

-   edidp = of_get_property(child, "edid", &channel->edid_len);
-   if (edidp) {
-   channel->edid = kmemdup(edidp, channel->edid_len,
-   GFP_KERNEL);
-   } else {
-   ret = of_get_drm_display_mode(child, &channel->mode, 0);
-   if (!ret)
-   channel->mode_valid = 1;
+   ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
+   if (ddc_node) {
+   channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
+   of_node_put(ddc_node);
+   }
+
+   if (!channel->ddc) {
+   /* if no DDC available, fallback to hardcoded EDID */
+   dev_dbg(dev, "no ddc available\n");
+
+   edidp = of_get_property(child, "edid",
+   &channel->edid_len);
+   if (edidp) {
+   channel->edid = kmemdup(edidp,
+   channel->edid_len,
+   GFP_KERNEL);
+   } else {
+   /* fallback to display-timings node */
+   ret = of_get_drm_display_mode(child,
+ &channel->mode,
+ 0);
+   if (!ret)
+   channel->mode_valid = 1;
+   }
}

ret = of_property_read_u32(child, "fsl,data-width", &datawidth);
@@ -616,6 +637,8 @@ static void imx_ldb_unbind(struct device *dev, struct 
device *master,

channel->connector.funcs->destroy(&channel->connector);
channel->encoder.funcs->destroy(&channel->encoder);
+
+   i2c_put_adapter(channel->ddc);
}
 }

-- 
1.7.9.5