From: Rahul Sharma <rahul.sharma@samsung.com>
To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
alsa-devel@alsa-project.org, linux-fbdev@vger.kernel.org
Cc: tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com,
broonie@opensource.wolfsonmicro.com, inki.dae@samsung.com,
kyungmin.park@samsung.com, r.sh.open@gmail.com,
joshi@samsung.com
Subject: [RFC PATCH v2 2/5] drm/edid: temporarily exposing generic edid-read interface from drm
Date: Thu, 07 Feb 2013 11:49:26 +0000 [thread overview]
Message-ID: <1360238951-7022-1-git-send-email-rahul.sharma@samsung.com> (raw)
It exposes generic interface from drm_edid.c to get the edid data and length
by any display entity. Once I get clear idea about edid handling in CDF, I need
to revert these temporary changes.
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
---
drivers/gpu/drm/drm_edid.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 5a3770f..567a565 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/module.h>
+#include <video/display.h>
#include <drm/drmP.h>
#include <drm/drm_edid.h>
#include "drm_edid_modes.h"
@@ -386,6 +387,93 @@ out:
return NULL;
}
+int generic_drm_do_get_edid(struct i2c_adapter *adapter,
+ struct display_entity_edid *edid)
+{
+ int i, j = 0, valid_extensions = 0;
+ u8 *block, *new;
+ bool print_bad_edid = 0;
+
+ block = kmalloc(EDID_LENGTH, GFP_KERNEL);
+ if (!block)
+ return -ENOMEM;
+
+ /* base block fetch */
+ for (i = 0; i < 4; i++) {
+ if (drm_do_probe_ddc_edid(adapter, block, 0, EDID_LENGTH))
+ goto out;
+ if (drm_edid_block_valid(block, 0, print_bad_edid))
+ break;
+ if (i = 0 && drm_edid_is_zero(block, EDID_LENGTH))
+ goto carp;
+ }
+ if (i = 4)
+ goto carp;
+
+ /* if there's no extensions, we're done */
+ if (block[0x7e] = 0) {
+ edid->edid = block;
+ edid->len = EDID_LENGTH;
+ return 0;
+ }
+
+ new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL);
+ if (!new)
+ goto out;
+ block = new;
+ edid->len = (block[0x7e] + 1) * EDID_LENGTH;
+
+ for (j = 1; j <= block[0x7e]; j++) {
+ for (i = 0; i < 4; i++) {
+ if (drm_do_probe_ddc_edid(adapter,
+ block + (valid_extensions + 1) * EDID_LENGTH,
+ j, EDID_LENGTH))
+ goto out;
+ if (drm_edid_block_valid(block + (valid_extensions + 1)*
+ EDID_LENGTH, j, print_bad_edid)) {
+ valid_extensions++;
+ break;
+ }
+ }
+ if (i = 4)
+ DRM_DEBUG_KMS("Ignoring inv lock %d.\n", j);
+ }
+
+ if (valid_extensions != block[0x7e]) {
+ block[EDID_LENGTH-1] += block[0x7e] - valid_extensions;
+ block[0x7e] = valid_extensions;
+ new = krealloc(block, (valid_extensions + 1)*
+ EDID_LENGTH, GFP_KERNEL);
+ if (!new)
+ goto out;
+ block = new;
+ edid->len = (valid_extensions + 1) * EDID_LENGTH;
+ }
+
+ edid->edid = block;
+ return 0;
+
+carp:
+ if (print_bad_edid)
+ DRM_DEBUG_KMS("[ERROR]: EDID block %d invalid.\n", j);
+
+out:
+ kfree(block);
+ return -ENOMEM;
+}
+
+
+int generic_drm_get_edid(struct i2c_adapter *adapter,
+ struct display_entity_edid *edid)
+{
+ int ret = -EINVAL;
+ if (drm_probe_ddc(adapter))
+ ret = generic_drm_do_get_edid(adapter, edid);
+
+ return ret;
+}
+EXPORT_SYMBOL(generic_drm_get_edid);
+
/**
* Probe DDC presence.
*
--
1.8.0
next reply other threads:[~2013-02-07 11:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 11:49 Rahul Sharma [this message]
2013-02-07 13:28 ` [RFC PATCH v2 2/5] drm/edid: temporarily exposing generic edid-read interface from drm Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360238951-7022-1-git-send-email-rahul.sharma@samsung.com \
--to=rahul.sharma@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=joshi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=r.sh.open@gmail.com \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).