diff mbox

[v4,1/3] drm/edid: Add drm_edid_get_monitor_name()

Message ID 1460654317-31288-1-git-send-email-jim.bride@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

jim.bride@linux.intel.com April 14, 2016, 5:18 p.m. UTC
In order to include monitor name information in debugfs
output we needed to add a function that would extract the
monitor name from the EDID, and that function needed to
reside in the file  where the rest of the EDID helper
functions are implemented.

v2: Refactor to have drm_edid_get_monitor_name() and drm_edid_to_eld()
    use a common helper function to extract the monitor name from the
    edid. [Jani] + rebase.

v3: Minor changes suggested by Jani + rebase.

v4: Few more minor changes suggested by Jani + rebase.

cc: dri-devel@lists.freedesktop.org
cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 51 ++++++++++++++++++++++++++++++++++++++--------
 include/drm/drm_crtc.h     |  2 ++
 2 files changed, 44 insertions(+), 9 deletions(-)

Comments

Daniel Vetter April 15, 2016, 12:37 p.m. UTC | #1
On Fri, Apr 15, 2016 at 06:26:18AM -0000, Patchwork wrote:
> == Series Details ==
> 
> Series: series starting with [v4,1/3] drm/edid: Add drm_edid_get_monitor_name()
> URL   : https://patchwork.freedesktop.org/series/5731/
> State : failure
> 
> == Summary ==
> 
> Series 5731v1 Series without cover letter
> http://patchwork.freedesktop.org/api/1.0/series/5731/revisions/1/mbox/
> 
> 
> bdw-ultra        total:203  pass:179  dwarn:0   dfail:0   fail:1   skip:23 
> bsw-nuc-2        total:202  pass:162  dwarn:0   dfail:0   fail:1   skip:39 
> byt-nuc          total:202  pass:164  dwarn:0   dfail:0   fail:0   skip:38 
> hsw-brixbox      total:203  pass:178  dwarn:0   dfail:0   fail:1   skip:24 
> ivb-t430s        total:203  pass:174  dwarn:0   dfail:0   fail:1   skip:28 
> skl-i7k-2        total:203  pass:177  dwarn:0   dfail:0   fail:1   skip:25 
> skl-nuci5        total:203  pass:191  dwarn:0   dfail:0   fail:1   skip:11 
> snb-dellxps      total:203  pass:164  dwarn:0   dfail:0   fail:1   skip:38 
> snb-x220t        total:203  pass:164  dwarn:0   dfail:0   fail:2   skip:37 
> BOOT FAILED for ilk-hp8440p

Discussed with Tomi, this box isn't wired up with a reset switch and
therefore can die on unrelated bad kernels. Without CI being able to
figure this out.

So should be fairly safe to ignore (but I'm not really happy that we don't
have more reliable information).

Applied all 3 patches to drm-misc, for easier merging.
-Daniel

> 
> Results at /archive/results/CI_IGT_test/Patchwork_1905/
> 
> c7583aec08ba04e2336bd9879a10f30d4e0cdc60 drm-intel-nightly: 2016y-04m-14d-14h-53m-34s UTC integration manifest
> 2171235 drm/i915/dp/mst: Add source port info to debugfs output
> b92ba82 drm/dp/mst: Enhance DP MST debugfs output
> c6df32b drm/edid: Add drm_edid_get_monitor_name()
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 558ef9f..96b181a 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3293,6 +3293,46 @@  monitor_name(struct detailed_timing *t, void *data)
 		*(u8 **)data = t->data.other_data.data.str.str;
 }
 
+static int get_monitor_name(struct edid *edid, char name[13])
+{
+	char *edid_name = NULL;
+	int mnl;
+
+	if (!edid || !name)
+		return 0;
+
+	drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
+	for (mnl = 0; edid_name && mnl < 13; mnl++) {
+		if (edid_name[mnl] == 0x0a)
+			break;
+
+		name[mnl] = edid_name[mnl];
+	}
+
+	return mnl;
+}
+
+/**
+ * drm_edid_get_monitor_name - fetch the monitor name from the edid
+ * @edid: monitor EDID information
+ * @name: pointer to a character array to hold the name of the monitor
+ * @bufsize: The size of the name buffer (should be at least 14 chars.)
+ *
+ */
+void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
+{
+	int name_length;
+	char buf[13];
+	
+	if (bufsize <= 0)
+		return;
+
+	name_length = min(get_monitor_name(edid, buf), bufsize - 1);
+	memcpy(name, buf, name_length);
+	name[name_length] = '\0';
+}
+EXPORT_SYMBOL(drm_edid_get_monitor_name);
+
 /**
  * drm_edid_to_eld - build ELD from EDID
  * @connector: connector corresponding to the HDMI/DP sink
@@ -3306,7 +3346,6 @@  void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 {
 	uint8_t *eld = connector->eld;
 	u8 *cea;
-	u8 *name;
 	u8 *db;
 	int total_sad_count = 0;
 	int mnl;
@@ -3320,14 +3359,8 @@  void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 		return;
 	}
 
-	name = NULL;
-	drm_for_each_detailed_block((u8 *)edid, monitor_name, &name);
-	/* max: 13 bytes EDID, 16 bytes ELD */
-	for (mnl = 0; name && mnl < 13; mnl++) {
-		if (name[mnl] == 0x0a)
-			break;
-		eld[20 + mnl] = name[mnl];
-	}
+	mnl = get_monitor_name(edid, eld + 20);
+
 	eld[4] = (cea[1] << 5) | mnl;
 	DRM_DEBUG_KMS("ELD monitor %s\n", eld + 20);
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8cb377c..6d46842 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -2500,6 +2500,8 @@  extern int drm_edid_header_is_valid(const u8 *raw_edid);
 extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
 				 bool *edid_corrupt);
 extern bool drm_edid_is_valid(struct edid *edid);
+extern void drm_edid_get_monitor_name(struct edid *edid, char *name,
+				      int buflen);
 
 extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
 							 char topology[8]);