Skip to contentSkip to conversation

Add HDMI infoframe helpers

PATCH Superseded Thierry Reding 2 participants 21 messages Jan 14, 2013 – Jan 18, 2013

Subsystems (8)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add HDMI infoframe helpers

The first two patches are of a janitorial nature, the first converting the drm_num_cea_modes constant to unsigned and the second adding a few missing forward declarations in order to fix build issues.

Patch 3 adds generic helpers to pack a structures that describe HDMI AVI, audio, vendor-specific or SPD infoframes into the binary format specified in the HDMI specification. The resulting binary buffer should be easily programmable into the HDMI controller.

Patch 4 provides a helper to fill an HDMI AVI infoframe with data from a struct drm_display_mode.

Patch 5 adds the DRM EDID helpers (including the new DRM HDMI helper from patch 4) to the DRM DocBook documentation.

Patch 6, 7 and 8 move the Tegra, Intel and Radeon drivers over to the new helpers. Patch 7 was contributed by Intel's Paulo Zanoni.

Finally, patch 9 removes the drm_mode_cea_vic() function which is a duplicate implementation of the older drm_match_cea_mode().

I haven't gotten around to converting the Exynos driver reimplementation because it isn't as trivial as the others. Nouveau also has some code to write infoframes and I'll see if I can convert those next.

One item that I have on my TODO list is the ACR computations requested by Christian König. My schedule has been really busy lately, so I'm not sure how long it will take until I get to it. I'd appreciate it if we could merge this series without the ACR implementation in order to get at least the numerous infoframe reimplementations cleaned up and to prevent others from getting in.

Thierry

Paulo Zanoni (1):
drm/i915: Use generic HDMI infoframe helpers

Thierry Reding (8):
drm: Make drm_num_cea_modes unsigned
drm: Add some missing forward declarations
video: Add generic HDMI infoframe helpers
drm: Add HDMI infoframe helpers
drm: Add EDID helper documentation
drm/tegra: Use generic HDMI infoframe helpers
drm/radeon: Use generic HDMI infoframe helpers
drm: Remove duplicate drm_mode_cea_vic()

 Documentation/DocBook/drm.tmpl          |   4 +
 drivers/gpu/drm/Kconfig                 |   1 +
 drivers/gpu/drm/drm_edid.c              |  45 +++--
 drivers/gpu/drm/drm_edid_modes.h        |   2 +-
 drivers/gpu/drm/i915/intel_drv.h        |  62 +-----
 drivers/gpu/drm/i915/intel_hdmi.c       | 186 +++++++++---------
 drivers/gpu/drm/i915/intel_sdvo.c       |  21 +-
 drivers/gpu/drm/radeon/evergreen_hdmi.c |  85 ++------
 drivers/gpu/drm/radeon/r600_hdmi.c      | 134 ++++---------
 drivers/gpu/drm/tegra/Kconfig           |   1 +
 drivers/gpu/drm/tegra/hdmi.c            | 226 +++++++++++-----------
 drivers/gpu/drm/tegra/hdmi.h            | 189 ------------------
 drivers/video/Kconfig                   |   3 +
 drivers/video/Makefile                  |   1 +
 drivers/video/hdmi.c                    | 332 ++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h                  |   6 +-
 include/drm/drm_edid.h                  |   6 +
 include/linux/hdmi.h                    | 221 +++++++++++++++++++++
 18 files changed, 883 insertions(+), 642 deletions(-)
 create mode 100644 drivers/video/hdmi.c
 create mode 100644 include/linux/hdmi.h
Signature · 6 lines
1.8.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 1/9 drm: Make drm_num_cea_modes unsigned

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
Signature · 1 line
1.8.1
#2 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 13 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_edid_modes.h +0 -0
index 5dbf7d2..d65d863 100644

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 5 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#3 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 9 lines · Ville Syrjälä
Quoted 8 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 10 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Actually I was thinking about maybe writing a patch to move the table out of the header and into drm_edid.c (or drm_cea.c?) to make it less easy to create duplicates of the table. In that case, using the ARRAY_SIZE macro directly wouldn't be an option.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 24 lines · Thierry Reding
Quoted 9 lines · Ville Syrjälä
Quoted 8 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 10 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Quoted 4 lines

Actually I was thinking about maybe writing a patch to move the table out of the header and into drm_edid.c (or drm_cea.c?) to make it less easy to create duplicates of the table. In that case, using the ARRAY_SIZE macro directly wouldn't be an option.

Well drm_edid.c is the only one accessing these tables anyway, so it they would be in drm_edid.c and static, you could still use ARRAY_SIZE().

Not that I really like the idea of polluting drm_edid.c with all these massive tables.

Too bad cpp doesn't support this kind of thing:
#if __BASE_FILE__ != "drm_edid.c"
#error ...
#endif

Signature · 2 lines
Ville Syrjälä
Intel OTC
#5 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 30 lines · Ville Syrjälä
Quoted 24 lines · Thierry Reding
Quoted 9 lines · Ville Syrjälä
Quoted 8 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 10 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Quoted 4 lines

Actually I was thinking about maybe writing a patch to move the table out of the header and into drm_edid.c (or drm_cea.c?) to make it less easy to create duplicates of the table. In that case, using the ARRAY_SIZE macro directly wouldn't be an option.

Quoted 6 lines

Well drm_edid.c is the only one accessing these tables anyway, so it they would be in drm_edid.c and static, you could still use ARRAY_SIZE().

Not that I really like the idea of polluting drm_edid.c with all these massive tables.

There's also the possibility to put the tables along with the functions that access them into a drm_edid_modes.c.

Quoted 4 lines

Too bad cpp doesn't support this kind of thing:
#if __BASE_FILE__ != "drm_edid.c"
#error ...
#endif

We could fake that by protecting the tables using #ifdef NEED_CEA_MODES and define NEED_CEA_MODES in drm_edid.c before the drm_edid_modes.h file is included.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 41 lines · Thierry Reding
Quoted 30 lines · Ville Syrjälä
Quoted 24 lines · Thierry Reding
Quoted 9 lines · Ville Syrjälä
Quoted 8 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 10 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Quoted 4 lines

Actually I was thinking about maybe writing a patch to move the table out of the header and into drm_edid.c (or drm_cea.c?) to make it less easy to create duplicates of the table. In that case, using the ARRAY_SIZE macro directly wouldn't be an option.

Quoted 6 lines

Well drm_edid.c is the only one accessing these tables anyway, so it they would be in drm_edid.c and static, you could still use ARRAY_SIZE().

Not that I really like the idea of polluting drm_edid.c with all these massive tables.

There's also the possibility to put the tables along with the functions that access them into a drm_edid_modes.c.

Quoted 8 lines
Quoted 4 lines

Too bad cpp doesn't support this kind of thing:
#if __BASE_FILE__ != "drm_edid.c"
#error ...
#endif

We could fake that by protecting the tables using #ifdef NEED_CEA_MODES and define NEED_CEA_MODES in drm_edid.c before the drm_edid_modes.h file is included.

Yeah, I suppose there's no better way to do that. It's a bit ugly though.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#7 lore raw

Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Quoted 47 lines · Ville Syrjälä
Quoted 46 lines · Thierry Reding
Quoted 30 lines · Ville Syrjälä
Quoted 24 lines · Thierry Reding
Quoted 9 lines · Ville Syrjälä
Quoted 8 lines · Thierry Reding

Since the variable's value is the size of an array, we can assume that it will never be negative.

---
 drivers/gpu/drm/drm_edid_modes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/drm_edid_modes.h static const struct drm_display_mode edid_cea_modes[] = { · line 774

Quoted 10 lines
drivers/gpu/drm/drm_edid_modes.h +1 -1
index 5dbf7d2..d65d863 100644
@@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
 };
-static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
+static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);

Why do we even have these num_foo things? I think it would be clearer to use ARRAY_SIZE(foo) directly where appropriate.

Quoted 4 lines

Actually I was thinking about maybe writing a patch to move the table out of the header and into drm_edid.c (or drm_cea.c?) to make it less easy to create duplicates of the table. In that case, using the ARRAY_SIZE macro directly wouldn't be an option.

Quoted 6 lines

Well drm_edid.c is the only one accessing these tables anyway, so it they would be in drm_edid.c and static, you could still use ARRAY_SIZE().

Not that I really like the idea of polluting drm_edid.c with all these massive tables.

There's also the possibility to put the tables along with the functions that access them into a drm_edid_modes.c.

Quoted 4 lines

Too bad cpp doesn't support this kind of thing:
#if __BASE_FILE__ != "drm_edid.c"
#error ...
#endif

Quoted 6 lines
Quoted 3 lines

We could fake that by protecting the tables using #ifdef NEED_CEA_MODES and define NEED_CEA_MODES in drm_edid.c before the drm_edid_modes.h file is included.

Yeah, I suppose there's no better way to do that. It's a bit ugly though.

What about moving them to a separate file altogether? It would involve moving the do_cea_modes() as well, but that would need to be called from drm_edid.c, so it isn't very pretty either.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

PATCH v3 2/9 drm: Add some missing forward declarations

In reply to Thierry Reding

The drm_file and drm_clip_rect structures are used throughout the file but they are never declared nor pulled in through an include. Add forward declarations to make them available.

---
 include/drm/drm_crtc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/drm/drm_crtc.h +2 -1
index 00d78b5..dd62ca0 100644
@@ -38,7 +38,8 @@ struct drm_device;
 struct drm_mode_set;
 struct drm_framebuffer;
 struct drm_object_properties;
-
+struct drm_file;
+struct drm_clip_rect;
 
 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
Signature · 1 line
1.8.1
#9 lore raw

PATCH v3 3/9 video: Add generic HDMI infoframe helpers

In reply to Thierry Reding

Add generic helpers to pack HDMI infoframes into binary buffers.

---
Changes in v2:
- add support for audio, vendor-specific and SPD infoframes
- add various validity checks on infoframes
- factor out checksum computation

Changes in v3:
- introduce HDMI_INFOFRAME_HEADER_SIZE
- fix SPD infoframe SDI field offset

 drivers/video/Kconfig  |   3 +
 drivers/video/Makefile |   1 +
 drivers/video/hdmi.c   | 332 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/hdmi.h   | 221 ++++++++++++++++++++++++++++++++
 4 files changed, 557 insertions(+)
 create mode 100644 drivers/video/hdmi.c
 create mode 100644 include/linux/hdmi.h
drivers/video/Kconfig +3 -0
index 807c7fa..baa3f90 100644
@@ -54,6 +54,9 @@ config OF_VIDEOMODE
 	help
 	  helper to get videomodes from the devicetree
 
+config HDMI
+	bool
+
 menuconfig FB
 	tristate "Support for frame buffer devices"
 	---help---
drivers/video/Makefile +1 -0
index f592f3b..0b50082 100644
@@ -5,6 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_VGASTATE)            += vgastate.o
+obj-$(CONFIG_HDMI)                += hdmi.o
 obj-y                             += fb_notify.o
 obj-$(CONFIG_FB)                  += fb.o
 fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
drivers/video/hdmi.c new file +332 -0

332 lines not on this page · raw message

include/linux/hdmi.h new file +221 -0

221 lines not on this page · raw message

Signature · 1 line
1.8.1
#10 lore raw

Re: [PATCH v3 3/9] video: Add generic HDMI infoframe helpers

Quoted 80 lines · Thierry Reding

Add generic helpers to pack HDMI infoframes into binary buffers.

---
Changes in v2:
- add support for audio, vendor-specific and SPD infoframes
- add various validity checks on infoframes
- factor out checksum computation

Changes in v3:
- introduce HDMI_INFOFRAME_HEADER_SIZE
- fix SPD infoframe SDI field offset

 drivers/video/Kconfig  |   3 +
 drivers/video/Makefile |   1 +
 drivers/video/hdmi.c   | 332 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/hdmi.h   | 221 ++++++++++++++++++++++++++++++++
 4 files changed, 557 insertions(+)
 create mode 100644 drivers/video/hdmi.c
 create mode 100644 include/linux/hdmi.h
drivers/video/Kconfig +3 -0
index 807c7fa..baa3f90 100644
@@ -54,6 +54,9 @@ config OF_VIDEOMODE
 	help
 	  helper to get videomodes from the devicetree
 
+config HDMI
+	bool
+
 menuconfig FB
 	tristate "Support for frame buffer devices"
 	---help---
drivers/video/Makefile +1 -0
index f592f3b..0b50082 100644
@@ -5,6 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_VGASTATE)            += vgastate.o
+obj-$(CONFIG_HDMI)                += hdmi.o
 obj-y                             += fb_notify.o
 obj-$(CONFIG_FB)                  += fb.o
 fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
drivers/video/hdmi.c new file +27 -0
new file mode 100644
index 0000000..a84e606
@@ -0,0 +1,332 @@
+/*
+ * Copyright (C) 2012 Avionic Design GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/bitops.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/hdmi.h>
+#include <linux/string.h>
+
+static void hdmi_infoframe_checksum(void *buffer, size_t size)
+{
+	u8 *ptr = buffer;
+	u8 csum = 0;
+	size_t i;
+
+	/* compute checksum */
+	for (i = 0; i < size; i++)
+		csum += ptr[i];
+
+	ptr[3] = 256 - csum;
+}
+

drivers/video/hdmi.c line 37

Quoted 10 lines
drivers/video/hdmi.c new file +10 -0
+/**
+ * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
+ * @frame: HDMI AVI infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
+{
+	if (!frame)
+		return -EINVAL;

There's quite a bit of error checking all around which seems a bit pointless since this is all internal stuff. Any errors are bugs in some driver code, so just letting the thing oops would be fine in my opinion.

Quoted 151 lines
drivers/video/hdmi.c new file +151 -0
+	memset(frame, 0, sizeof(*frame));
+
+	frame->type = HDMI_INFOFRAME_TYPE_AVI;
+	frame->version = 2;
+	frame->length = 13;
+
+	return 0;
+}
+EXPORT_SYMBOL(hdmi_avi_infoframe_init);
+
+/**
+ * hdmi_avi_infoframe_pack() - write HDMI AVI infoframe to binary buffer
+ * @frame: HDMI AVI infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers. Also computes the checksum as required by section 5.3.5 of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
+				size_t size)
+{
+	u8 *ptr = buffer;
+	size_t length;
+
+	if (!frame || !buffer)
+		return -EINVAL;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, length);
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;
+	ptr[3] = 0; /* checksum */
+
+	/* start infoframe payload */
+	ptr += HDMI_INFOFRAME_HEADER_SIZE;
+
+	ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3);
+
+	if (frame->active_info_valid)
+		ptr[0] |= BIT(4);
+
+	if (frame->horizontal_bar_valid)
+		ptr[0] |= BIT(3);
+
+	if (frame->vertical_bar_valid)
+		ptr[0] |= BIT(2);
+
+	ptr[1] = ((frame->colorimetry & 0x3) << 6) |
+		 ((frame->picture_aspect & 0x3) << 4) |
+		 (frame->active_aspect & 0xf);
+
+	ptr[2] = ((frame->extended_colorimetry & 0x7) << 4) |
+		 ((frame->quantization_range & 0x3) << 2) |
+		 (frame->nups & 0x3);
+
+	if (frame->itc)
+		ptr[2] |= BIT(7);
+
+	ptr[3] = frame->video_code & 0x7f;
+
+	ptr[4] = ((frame->ycc_quantization_range & 0x3) << 6) |
+		 ((frame->content_type & 0x3) << 4) |
+		 (frame->pixel_repeat & 0xf);
+
+	ptr[5] = frame->top_bar & 0xff;
+	ptr[6] = (frame->top_bar >> 8) & 0xff;
+	ptr[7] = frame->bottom_bar & 0xff;
+	ptr[8] = (frame->bottom_bar >> 8) & 0xff;
+	ptr[9] = frame->left_bar & 0xff;
+	ptr[10] = (frame->left_bar >> 8) & 0xff;
+	ptr[11] = frame->right_bar & 0xff;
+	ptr[12] = (frame->right_bar >> 8) & 0xff;
+
+	hdmi_infoframe_checksum(buffer, length);
+
+	return length;
+}
+EXPORT_SYMBOL(hdmi_avi_infoframe_pack);
+
+/**
+ * hdmi_spd_infoframe_init() - initialize an HDMI SPD infoframe
+ * @frame: HDMI SPD infoframe
+ * @vendor: vendor string
+ * @product: product string
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
+			    const char *vendor, const char *product)
+{
+	if (!frame)
+		return -EINVAL;
+
+	memset(frame, 0, sizeof(*frame));
+
+	frame->type = HDMI_INFOFRAME_TYPE_SPD;
+	frame->version = 1;
+	frame->length = 25;
+
+	strncpy(frame->vendor, vendor, sizeof(frame->vendor));
+	strncpy(frame->product, product, sizeof(frame->product));
+
+	return 0;
+}
+EXPORT_SYMBOL(hdmi_spd_infoframe_init);
+
+/**
+ * hdmi_spd_infoframe_pack() - write HDMI SPD infoframe to binary buffer
+ * @frame: HDMI SPD infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers. Also computes the checksum as required by section 5.3.5 of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
+				size_t size)
+{
+	u8 *ptr = buffer;
+	size_t length, i;
+
+	if (!frame || !buffer)
+		return -EINVAL;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, length);
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;

drivers/video/hdmi.c line 199

Quoted 10 lines
drivers/video/hdmi.c new file +10 -0
+	ptr[3] = 0; /* checksum */
+
+	/* start infoframe payload */
+	ptr += HDMI_INFOFRAME_HEADER_SIZE;
+
+	for (i = 0; i < sizeof(frame->vendor); i++)
+		ptr[i] = frame->vendor[i];
+
+	for (i = 0; i < sizeof(frame->product); i++)
+		ptr[8 + i] = frame->product[i];

memcpy()

Quoted 269 lines
drivers/video/hdmi.c new file +133 -0
+
+	ptr[24] = frame->sdi;
+
+	hdmi_infoframe_checksum(buffer, length);
+
+	return length;
+}
+EXPORT_SYMBOL(hdmi_spd_infoframe_pack);
+
+/**
+ * hdmi_audio_infoframe_init() - initialize an HDMI audio infoframe
+ * @frame: HDMI audio infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame)
+{
+	if (!frame)
+		return -EINVAL;
+
+	memset(frame, 0, sizeof(*frame));
+
+	frame->type = HDMI_INFOFRAME_TYPE_AUDIO;
+	frame->version = 1;
+	frame->length = 10;
+
+	return 0;
+}
+EXPORT_SYMBOL(hdmi_audio_infoframe_init);
+
+/**
+ * hdmi_audio_infoframe_pack() - write HDMI audio infoframe to binary buffer
+ * @frame: HDMI audio infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers. Also computes the checksum as required by section 5.3.5 of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
+				  void *buffer, size_t size)
+{
+	unsigned char channels;
+	u8 *ptr = buffer;
+	size_t length;
+
+	if (!frame || !buffer)
+		return -EINVAL;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, length);
+
+	if (frame->channels >= 2)
+		channels = frame->channels - 1;
+	else
+		channels = 0;
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;
+	ptr[3] = 0; /* checksum */
+
+	/* start infoframe payload */
+	ptr += HDMI_INFOFRAME_HEADER_SIZE;
+
+	ptr[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7);
+	ptr[1] = ((frame->sample_frequency & 0x7) << 2) |
+		 (frame->sample_size & 0x3);
+	ptr[2] = 0;
+	ptr[3] = frame->channel_allocation;
+	ptr[4] = (frame->level_shift_value & 0xf) << 3;
+
+	if (frame->downmix_inhibit)
+		ptr[4] |= BIT(7);
+
+	hdmi_infoframe_checksum(buffer, length);
+
+	return length;
+}
+EXPORT_SYMBOL(hdmi_audio_infoframe_pack);
+
+/**
+ * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary
+ *                                buffer
+ * @frame: HDMI vendor infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers. Also computes the checksum as required by section 5.3.5 of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
+				   void *buffer, size_t size)
+{
+	u8 *ptr = buffer;
+	size_t length;
+
+	if (!frame || !buffer)
+		return -EINVAL;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, length);
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;
+	ptr[3] = 0; /* checksum */
+
+	memcpy(&ptr[HDMI_INFOFRAME_HEADER_SIZE], frame->data, frame->length);
+
+	hdmi_infoframe_checksum(buffer, length);
+
+	return length;
+}
+EXPORT_SYMBOL(hdmi_vendor_infoframe_pack);
include/linux/hdmi.h new file +130 -0
new file mode 100644
index 0000000..47d59b1
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2012 Avionic Design GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_HDMI_H_
+#define __LINUX_HDMI_H_
+
+#include <linux/types.h>
+
+enum hdmi_infoframe_type {
+	HDMI_INFOFRAME_TYPE_VENOR = 0x81,
+	HDMI_INFOFRAME_TYPE_AVI = 0x82,
+	HDMI_INFOFRAME_TYPE_SPD = 0x83,
+	HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
+};
+
+#define HDMI_INFOFRAME_HEADER_SIZE  4
+#define HDMI_AVI_INFOFRAME_SIZE    13
+#define HDMI_SPD_INFOFRAME_SIZE    25
+#define HDMI_AUDIO_INFOFRAME_SIZE  10
+
+enum hdmi_colorspace {
+	HDMI_COLORSPACE_RGB,
+	HDMI_COLORSPACE_YUV422,
+	HDMI_COLORSPACE_YUV444,
+};
+
+enum hdmi_scan_mode {
+	HDMI_SCAN_MODE_NONE,
+	HDMI_SCAN_MODE_OVERSCAN,
+	HDMI_SCAN_MODE_UNDERSCAN,
+};
+
+enum hdmi_colorimetry {
+	HDMI_COLORIMETRY_NONE,
+	HDMI_COLORIMETRY_ITU_601,
+	HDMI_COLORIMETRY_ITU_709,
+	HDMI_COLORIMETRY_EXTENDED,
+};
+
+enum hdmi_picture_aspect {
+	HDMI_PICTURE_ASPECT_NONE,
+	HDMI_PICTURE_ASPECT_4_3,
+	HDMI_PICTURE_ASPECT_16_9,
+};
+
+enum hdmi_active_aspect {
+	HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
+	HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
+	HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
+	HDMI_ACTIVE_ASPECT_PICTURE = 8,
+	HDMI_ACTIVE_ASPECT_4_3 = 9,
+	HDMI_ACTIVE_ASPECT_16_9 = 10,
+	HDMI_ACTIVE_ASPECT_14_9 = 11,
+	HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
+	HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
+	HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
+};
+
+enum hdmi_extended_colorimetry {
+	HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
+	HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
+	HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
+	HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
+	HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
+};
+
+enum hdmi_quantization_range {
+	HDMI_QUANTIZATION_RANGE_DEFAULT,
+	HDMI_QUANTIZATION_RANGE_LIMITED,
+	HDMI_QUANTIZATION_RANGE_FULL,
+};
+
+/* non-uniform picture scaling */
+enum hdmi_nups {
+	HDMI_NUPS_UNKNOWN,
+	HDMI_NUPS_HORIZONTAL,
+	HDMI_NUPS_VERTICAL,
+	HDMI_NUPS_BOTH,
+};
+
+enum hdmi_ycc_quantization_range {
+	HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
+	HDMI_YCC_QUANTIZATION_RANGE_FULL,
+};
+
+enum hdmi_content_type {
+	HDMI_CONTENT_TYPE_NONE,
+	HDMI_CONTENT_TYPE_PHOTO,
+	HDMI_CONTENT_TYPE_CINEMA,
+	HDMI_CONTENT_TYPE_GAME,
+};
+
+struct hdmi_avi_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	enum hdmi_colorspace colorspace;
+	bool active_info_valid;
+	bool horizontal_bar_valid;
+	bool vertical_bar_valid;
+	enum hdmi_scan_mode scan_mode;
+	enum hdmi_colorimetry colorimetry;
+	enum hdmi_picture_aspect picture_aspect;
+	enum hdmi_active_aspect active_aspect;
+	bool itc;
+	enum hdmi_extended_colorimetry extended_colorimetry;
+	enum hdmi_quantization_range quantization_range;
+	enum hdmi_nups nups;
+	unsigned char video_code;
+	enum hdmi_ycc_quantization_range ycc_quantization_range;
+	enum hdmi_content_type content_type;
+	unsigned char pixel_repeat;
+	unsigned short top_bar;
+	unsigned short bottom_bar;
+	unsigned short left_bar;
+	unsigned short right_bar;
+};
+
+int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
+ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
+				size_t size);
+
+enum hdmi_spd_sdi {
+	HDMI_SPD_SDI_UNKNOWN,
+	HDMI_SPD_SDI_DSTB,

include/linux/hdmi.h line 140

Quoted 10 lines
include/linux/hdmi.h new file +10 -0
+	HDMI_SPD_SDI_DVDP,
+	HDMI_SPD_SDI_DVHS,
+	HDMI_SPD_SDI_HDDVR,
+	HDMI_SPD_SDI_DVC,
+	HDMI_SPD_SDI_DSC,
+	HDMI_SPD_SDI_VCD,
+	HDMI_SPD_SDI_GAME,
+	HDMI_SPD_SDI_PC,
+	HDMI_SPD_SDI_BD,
+	HDMI_SPD_SDI_SCD,

I believe SACD is a more correct name.

HD DVD and PMP are missing from this list.

Quoted 22 lines
include/linux/hdmi.h new file +22 -0
+};
+
+struct hdmi_spd_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	char vendor[8];
+	char product[16];
+	enum hdmi_spd_sdi sdi;
+};
+
+int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
+			    const char *vendor, const char *product);
+ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
+				size_t size);
+
+enum hdmi_audio_coding_type {
+	HDMI_AUDIO_CODING_TYPE_STREAM,
+	HDMI_AUDIO_CODING_TYPE_IEC_60958,
+	HDMI_AUDIO_CODING_TYPE_AC3,
+	HDMI_AUDIO_CODING_TYPE_MPEG1,
+	HDMI_AUDIO_CODING_TYPE_MP3,

include/linux/hdmi.h line 172

Quoted 10 lines
include/linux/hdmi.h new file +10 -0
+	HDMI_AUDIO_CODING_TYPE_MPEG2,
+	HDMI_AUDIO_CODING_TYPE_AAC,
+	HDMI_AUDIO_CODING_TYPE_DTS,
+	HDMI_AUDIO_CODING_TYPE_ATRAC,
+	HDMI_AUDIO_CODING_TYPE_ONE_BIT_AUDIO,
+	HDMI_AUDIO_CODING_TYPE_DOLBY_DIGITAL_PLUS,
+	HDMI_AUDIO_CODING_TYPE_DTS_HD,
+	HDMI_AUDIO_CODING_TYPE_MAT_MLP,
+	HDMI_AUDIO_CODING_TYPE_DST,
+	HDMI_AUDIO_CODING_TYPE_WMPRO,

These don't always quite match the names in CEA-861-E. Wouldn't it be better to use matching names?

Also the audio coding extension type is missing.

Quoted 56 lines
include/linux/hdmi.h new file +49 -0
+};
+
+enum hdmi_audio_sample_size {
+	HDMI_AUDIO_SAMPLE_SIZE_STREAM,
+	HDMI_AUDIO_SAMPLE_SIZE_16,
+	HDMI_AUDIO_SAMPLE_SIZE_20,
+	HDMI_AUDIO_SAMPLE_SIZE_24,
+};
+
+enum hdmi_audio_sample_frequency {
+	HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
+	HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
+};
+
+struct hdmi_audio_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	unsigned char channels;
+	enum hdmi_audio_coding_type coding_type;
+	enum hdmi_audio_sample_size sample_size;
+	enum hdmi_audio_sample_frequency sample_frequency;
+	unsigned char channel_allocation;
+	unsigned char level_shift_value;
+	bool downmix_inhibit;
+
+};
+
+int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
+ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
+				  void *buffer, size_t size);
+
+struct hdmi_vendor_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	u8 data[27];
+};
+
+ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
+				   void *buffer, size_t size);
+
+#endif /* _DRM_HDMI_H */
Signature · 6 lines
1.8.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel OTC
#11 lore raw

Re: [PATCH v3 3/9] video: Add generic HDMI infoframe helpers

Quoted 2 lines · Ville Syrjälä
Quoted 1 line · Thierry Reding

Add generic helpers to pack HDMI infoframes into binary buffers.

[...]

Quoted 7 lines
Quoted 7 lines
drivers/video/hdmi.c new file +7 -0
+/**
+ * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
+ * @frame: HDMI AVI infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
Quoted 8 lines

drivers/video/hdmi.c line 37

Quoted 3 lines
drivers/video/hdmi.c new file +3 -0
+{
+	if (!frame)
+		return -EINVAL;

There's quite a bit of error checking all around which seems a bit pointless since this is all internal stuff. Any errors are bugs in some driver code, so just letting the thing oops would be fine in my opinion.

Okay, I can remove some of the more obvious checks. Checking for space requirements might still be useful, so I'll leave that in.

Quoted 2 lines
Quoted 2 lines
drivers/video/hdmi.c new file +2 -0
+ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
+				size_t size)

[...]

Quoted 7 lines

drivers/video/hdmi.c line 199

Quoted 5 lines
drivers/video/hdmi.c new file +5 -0
+	for (i = 0; i < sizeof(frame->vendor); i++)
+		ptr[i] = frame->vendor[i];
+
+	for (i = 0; i < sizeof(frame->product); i++)
+		ptr[8 + i] = frame->product[i];

memcpy()

Done.

Quoted 7 lines
Quoted 7 lines
include/linux/hdmi.h new file +7 -0
+enum hdmi_spd_sdi {
+	HDMI_SPD_SDI_UNKNOWN,
+	HDMI_SPD_SDI_DSTB,
+	HDMI_SPD_SDI_DVDP,
+	HDMI_SPD_SDI_DVHS,
+	HDMI_SPD_SDI_HDDVR,
+	HDMI_SPD_SDI_DVC,
Quoted 8 lines

include/linux/hdmi.h line 140

Quoted 6 lines
include/linux/hdmi.h new file +6 -0
+	HDMI_SPD_SDI_DSC,
+	HDMI_SPD_SDI_VCD,
+	HDMI_SPD_SDI_GAME,
+	HDMI_SPD_SDI_PC,
+	HDMI_SPD_SDI_BD,
+	HDMI_SPD_SDI_SCD,

I believe SACD is a more correct name.

Done.

Quoted 1 line

HD DVD and PMP are missing from this list.

I can't find any reference to those in CEA-861-D. HDMI 1.4 doesn't have them either. Can you provide any pointers?

Quoted 11 lines
Quoted 11 lines
include/linux/hdmi.h new file +11 -0
+enum hdmi_audio_coding_type {
+	HDMI_AUDIO_CODING_TYPE_STREAM,
+	HDMI_AUDIO_CODING_TYPE_IEC_60958,
+	HDMI_AUDIO_CODING_TYPE_AC3,
+	HDMI_AUDIO_CODING_TYPE_MPEG1,
+	HDMI_AUDIO_CODING_TYPE_MP3,
+	HDMI_AUDIO_CODING_TYPE_MPEG2,
+	HDMI_AUDIO_CODING_TYPE_AAC,
+	HDMI_AUDIO_CODING_TYPE_DTS,
+	HDMI_AUDIO_CODING_TYPE_ATRAC,
+	HDMI_AUDIO_CODING_TYPE_ONE_BIT_AUDIO,
Quoted 8 lines

include/linux/hdmi.h line 172

Quoted 5 lines
include/linux/hdmi.h new file +5 -0
+	HDMI_AUDIO_CODING_TYPE_DOLBY_DIGITAL_PLUS,
+	HDMI_AUDIO_CODING_TYPE_DTS_HD,
+	HDMI_AUDIO_CODING_TYPE_MAT_MLP,
+	HDMI_AUDIO_CODING_TYPE_DST,
+	HDMI_AUDIO_CODING_TYPE_WMPRO,

These don't always quite match the names in CEA-861-E. Wouldn't it be better to use matching names?

Are HD-DVD and PMP above listed in CEA-861-E? I'll need to find a copy of it and will go over this again and match the names to those in the document.

Quoted 1 line

Also the audio coding extension type is missing.

I assume this is also part of CEA-861-E as I can't find a reference in -D?

Thanks for reviewing,
Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw

Re: [PATCH v3 3/9] video: Add generic HDMI infoframe helpers

Quoted 52 lines · Thierry Reding
Quoted 2 lines · Ville Syrjälä
Quoted 1 line · Thierry Reding

Add generic helpers to pack HDMI infoframes into binary buffers.

[...]

Quoted 7 lines
Quoted 7 lines
drivers/video/hdmi.c new file +7 -0
+/**
+ * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
+ * @frame: HDMI AVI infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
Quoted 8 lines

drivers/video/hdmi.c line 37

Quoted 3 lines
drivers/video/hdmi.c new file +3 -0
+{
+	if (!frame)
+		return -EINVAL;

There's quite a bit of error checking all around which seems a bit pointless since this is all internal stuff. Any errors are bugs in some driver code, so just letting the thing oops would be fine in my opinion.

Okay, I can remove some of the more obvious checks. Checking for space requirements might still be useful, so I'll leave that in.

Quoted 2 lines
Quoted 2 lines
drivers/video/hdmi.c new file +2 -0
+ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
+				size_t size)

[...]

Quoted 7 lines

drivers/video/hdmi.c line 199

Quoted 5 lines
drivers/video/hdmi.c new file +5 -0
+	for (i = 0; i < sizeof(frame->vendor); i++)
+		ptr[i] = frame->vendor[i];
+
+	for (i = 0; i < sizeof(frame->product); i++)
+		ptr[8 + i] = frame->product[i];

memcpy()

Done.

Quoted 7 lines
Quoted 7 lines
include/linux/hdmi.h new file +7 -0
+enum hdmi_spd_sdi {
+	HDMI_SPD_SDI_UNKNOWN,
+	HDMI_SPD_SDI_DSTB,
+	HDMI_SPD_SDI_DVDP,
+	HDMI_SPD_SDI_DVHS,
+	HDMI_SPD_SDI_HDDVR,
+	HDMI_SPD_SDI_DVC,
Quoted 8 lines

include/linux/hdmi.h line 140

Quoted 6 lines
include/linux/hdmi.h new file +6 -0
+	HDMI_SPD_SDI_DSC,
+	HDMI_SPD_SDI_VCD,
+	HDMI_SPD_SDI_GAME,
+	HDMI_SPD_SDI_PC,
+	HDMI_SPD_SDI_BD,
+	HDMI_SPD_SDI_SCD,

I believe SACD is a more correct name.

Quoted 6 lines

Done.

Quoted 1 line

HD DVD and PMP are missing from this list.

I can't find any reference to those in CEA-861-D. HDMI 1.4 doesn't have them either. Can you provide any pointers?

CEA-861-E has them.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
include/linux/hdmi.h new file +11 -0
+enum hdmi_audio_coding_type {
+	HDMI_AUDIO_CODING_TYPE_STREAM,
+	HDMI_AUDIO_CODING_TYPE_IEC_60958,
+	HDMI_AUDIO_CODING_TYPE_AC3,
+	HDMI_AUDIO_CODING_TYPE_MPEG1,
+	HDMI_AUDIO_CODING_TYPE_MP3,
+	HDMI_AUDIO_CODING_TYPE_MPEG2,
+	HDMI_AUDIO_CODING_TYPE_AAC,
+	HDMI_AUDIO_CODING_TYPE_DTS,
+	HDMI_AUDIO_CODING_TYPE_ATRAC,
+	HDMI_AUDIO_CODING_TYPE_ONE_BIT_AUDIO,
Quoted 8 lines

include/linux/hdmi.h line 172

Quoted 5 lines
include/linux/hdmi.h new file +5 -0
+	HDMI_AUDIO_CODING_TYPE_DOLBY_DIGITAL_PLUS,
+	HDMI_AUDIO_CODING_TYPE_DTS_HD,
+	HDMI_AUDIO_CODING_TYPE_MAT_MLP,
+	HDMI_AUDIO_CODING_TYPE_DST,
+	HDMI_AUDIO_CODING_TYPE_WMPRO,

These don't always quite match the names in CEA-861-E. Wouldn't it be better to use matching names?

Quoted 3 lines

Are HD-DVD and PMP above listed in CEA-861-E? I'll need to find a copy of it and will go over this again and match the names to those in the document.

Great.

Quoted 4 lines
Quoted 1 line

Also the audio coding extension type is missing.

I assume this is also part of CEA-861-E as I can't find a reference in -D?

Yeah, I only checked against CEA-861-E.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#13 lore raw

PATCH v3 4/9 drm: Add HDMI infoframe helpers

In reply to Thierry Reding

Add a generic helper to fill in an HDMI AVI infoframe with data extracted from a DRM display mode.

---
Changes in v2:
- reuse CEA modes defined in drm_edid_modes.h
- don't use pixel aspect ratio for picture aspect

Changes in v3:
- move implementation into drm_edid.[ch]

 drivers/gpu/drm/Kconfig    |  1 +
 drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  6 ++++++
 3 files changed, 40 insertions(+)
drivers/gpu/drm/Kconfig +1 -0
index 983201b..92d2294 100644
@@ -7,6 +7,7 @@
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
 	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
+	select HDMI
 	select I2C
 	select I2C_ALGOBIT
 	select DMA_SHARED_BUFFER
drivers/gpu/drm/drm_edid.c +33 -0
index 5a3770f..1cfafc0 100644
@@ -29,6 +29,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/hdmi.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
@@ -2098,3 +2099,35 @@ uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode)
 	return 0;
 }
 EXPORT_SYMBOL(drm_mode_cea_vic);
+
+/**
+ * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
+ *                                              data from a DRM display mode
+ * @frame: HDMI AVI infoframe
+ * @mode: DRM display mode
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
+					 const struct drm_display_mode *mode)
+{
+	int err;
+
+	if (!frame || !mode)
+		return -EINVAL;
+
+	err = hdmi_avi_infoframe_init(frame);
+	if (err < 0)
+		return err;
+
+	frame->video_code = drm_match_cea_mode(mode);
+	if (!frame->video_code)
+		return 0;
+
+	frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;
+	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
include/drm/drm_edid.h +6 -0
index 0cac551..5da1b4a 100644
@@ -247,6 +247,8 @@ struct edid {
 struct drm_encoder;
 struct drm_connector;
 struct drm_display_mode;
+struct hdmi_avi_infoframe;
+
 void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid);
 int drm_av_sync_delay(struct drm_connector *connector,
 		      struct drm_display_mode *mode);
@@ -254,4 +256,8 @@ struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
 				     struct drm_display_mode *mode);
 int drm_load_edid_firmware(struct drm_connector *connector);
 
+int
+drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
+					 const struct drm_display_mode *mode);
+
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
1.8.1
#14 lore raw

PATCH v3 5/9 drm: Add EDID helper documentation

In reply to Thierry Reding

Add a reference section about the EDID helper functions to the DRM documentation.

---
 Documentation/DocBook/drm.tmpl | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/DocBook/drm.tmpl +4 -0
index 4ee2304..34249bb 100644
@@ -2111,6 +2111,10 @@ void intel_crt_init(struct drm_device *dev)
 !Iinclude/drm/drm_dp_helper.h
 !Edrivers/gpu/drm/drm_dp_helper.c
     </sect2>
+    <sect2>
+      <title>EDID Helper Functions Reference</title>
+!Edrivers/gpu/drm/drm_edid.c
+    </sect2>
   </sect1>
 
   <!-- Internals: vertical blanking -->
Signature · 1 line
1.8.1
#15 lore raw

PATCH v3 6/9 drm/tegra: Use generic HDMI infoframe helpers

In reply to Thierry Reding

Use the generic HDMI infoframe helpers to get rid of the NVIDIA Tegra reimplementation.

---
 drivers/gpu/drm/tegra/Kconfig |   1 +
 drivers/gpu/drm/tegra/hdmi.c  | 226 ++++++++++++++++++++----------------------
 drivers/gpu/drm/tegra/hdmi.h  | 189 -----------------------------------
 3 files changed, 110 insertions(+), 306 deletions(-)
drivers/gpu/drm/tegra/Kconfig +1 -0
index 721483b..50d9c94 100644
@@ -4,6 +4,7 @@ config DRM_TEGRA
 	select DRM_KMS_HELPER
 	select DRM_GEM_CMA_HELPER
 	select DRM_KMS_CMA_HELPER
+	select DRM_HDMI
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
drivers/gpu/drm/tegra/hdmi.c +109 -117

303 lines not on this page · raw message

drivers/gpu/drm/tegra/hdmi.h +0 -189

195 lines not on this page · raw message

Signature · 1 line
1.8.1
#16 lore raw

PATCH v3 7/9 drm/i915: Use generic HDMI infoframe helpers

In reply to Thierry Reding

From: Paulo Zanoni <[email protected]>

Use the generic HDMI infoframe helpers to get rid of the duplicate implementation in the i915 driver.

This patch is based on the initial patch by Thierry Reding, but with a different approach.

TODO:
- The SDVO part is totally untested. I am not sure if the buffer size on the SDVO code must be a multiple of 4.
- The HDMI part was tested only on SNB/CPT.
- The patch is forcing pixel_repeat to 1 so I can properly test the patch. Remove this before the final version.
- The correctnes of this patch depends on a fix on patch "video: add Generic HDMI infoframe helpers"

---
 drivers/gpu/drm/i915/intel_drv.h  |  62 +------------
 drivers/gpu/drm/i915/intel_hdmi.c | 186 ++++++++++++++++++++------------------
 drivers/gpu/drm/i915/intel_sdvo.c |  21 ++---
 3 files changed, 112 insertions(+), 157 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +3 -59
index 8a1bd4a..f7c237d 100644
@@ -26,6 +26,7 @@
 #define __INTEL_DRV_H__
 
 #include <linux/i2c.h>
+#include <linux/hdmi.h>
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
 #include <drm/drm_crtc.h>
@@ -276,63 +277,6 @@ struct cxsr_latency {
 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
 
-#define DIP_HEADER_SIZE	5
-
-#define DIP_TYPE_AVI    0x82
-#define DIP_VERSION_AVI 0x2
-#define DIP_LEN_AVI     13
-#define DIP_AVI_PR_1    0
-#define DIP_AVI_PR_2    1
-
-#define DIP_TYPE_SPD	0x83
-#define DIP_VERSION_SPD	0x1
-#define DIP_LEN_SPD	25
-#define DIP_SPD_UNKNOWN	0
-#define DIP_SPD_DSTB	0x1
-#define DIP_SPD_DVDP	0x2
-#define DIP_SPD_DVHS	0x3
-#define DIP_SPD_HDDVR	0x4
-#define DIP_SPD_DVC	0x5
-#define DIP_SPD_DSC	0x6
-#define DIP_SPD_VCD	0x7
-#define DIP_SPD_GAME	0x8
-#define DIP_SPD_PC	0x9
-#define DIP_SPD_BD	0xa
-#define DIP_SPD_SCD	0xb
-
-struct dip_infoframe {
-	uint8_t type;		/* HB0 */
-	uint8_t ver;		/* HB1 */
-	uint8_t len;		/* HB2 - body len, not including checksum */
-	uint8_t ecc;		/* Header ECC */
-	uint8_t checksum;	/* PB0 */
-	union {
-		struct {
-			/* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
-			uint8_t Y_A_B_S;
-			/* PB2 - C 7:6, M 5:4, R 3:0 */
-			uint8_t C_M_R;
-			/* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
-			uint8_t ITC_EC_Q_SC;
-			/* PB4 - VIC 6:0 */
-			uint8_t VIC;
-			/* PB5 - YQ 7:6, CN 5:4, PR 3:0 */
-			uint8_t YQ_CN_PR;
-			/* PB6 to PB13 */
-			uint16_t top_bar_end;
-			uint16_t bottom_bar_start;
-			uint16_t left_bar_end;
-			uint16_t right_bar_start;
-		} __attribute__ ((packed)) avi;
-		struct {
-			uint8_t vn[8];
-			uint8_t pd[16];
-			uint8_t sdi;
-		} __attribute__ ((packed)) spd;
-		uint8_t payload[27];
-	} __attribute__ ((packed)) body;
-} __attribute__((packed));
-
 struct intel_hdmi {
 	u32 sdvox_reg;
 	int ddc_bus;
@@ -341,7 +285,8 @@ struct intel_hdmi {
 	bool has_audio;
 	enum hdmi_force_audio force_audio;
 	void (*write_infoframe)(struct drm_encoder *encoder,
-				struct dip_infoframe *frame);
+				uint8_t *frame, ssize_t len,
+				enum hdmi_infoframe_type type);
 	void (*set_infoframes)(struct drm_encoder *encoder,
 			       struct drm_display_mode *adjusted_mode);
 };
@@ -433,7 +378,6 @@ extern struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
 extern bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
 				  const struct drm_display_mode *mode,
 				  struct drm_display_mode *adjusted_mode);
-extern void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
 extern bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg,
 			    bool is_sdvob);
 extern void intel_dvo_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_hdmi.c +100 -86

364 lines not on this page · raw message

drivers/gpu/drm/i915/intel_sdvo.c +9 -12
index c275bf0..e4abb55 100644
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/export.h>
+#include <linux/hdmi.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
@@ -948,20 +949,16 @@ static bool intel_sdvo_write_infoframe(struct intel_sdvo *intel_sdvo,
 
 static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)
 {
-	struct dip_infoframe avi_if = {
-		.type = DIP_TYPE_AVI,
-		.ver = DIP_VERSION_AVI,
-		.len = DIP_LEN_AVI,
-	};
-	uint8_t sdvo_data[4 + sizeof(avi_if.body.avi)];
+	uint8_t sdvo_data[HDMI_AVI_INFOFRAME_SIZE +
+			  HDMI_INFOFRAME_HEADER_SIZE];
+	struct hdmi_avi_infoframe frame;
+	ssize_t len;
 
-	intel_dip_infoframe_csum(&avi_if);
+	len = hdmi_avi_infoframe_init(&frame);
+	WARN(len < 0, "hdmi_avi_infoframe_init failed!\n");
 
-	/* sdvo spec says that the ecc is handled by the hw, and it looks like
-	 * we must not send the ecc field, either. */
-	memcpy(sdvo_data, &avi_if, 3);
-	sdvo_data[3] = avi_if.checksum;
-	memcpy(&sdvo_data[4], &avi_if.body, sizeof(avi_if.body.avi));
+	len = hdmi_avi_infoframe_pack(&frame, sdvo_data, sizeof(sdvo_data));
+	WARN(len < 0, "hdmi_avi_infoframe_pack failed!\n");
 
 	return intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_AVI_IF,
 					  SDVO_HBUF_TX_VSYNC,
Signature · 1 line
1.8.1
#17 lore raw

PATCH v3 8/9 drm/radeon: Use generic HDMI infoframe helpers

In reply to Thierry Reding

Use the generic HDMI infoframe helpers to get rid of the duplicate implementation in the radeon driver.

---
 drivers/gpu/drm/radeon/evergreen_hdmi.c |  85 +++++---------------
 drivers/gpu/drm/radeon/r600_hdmi.c      | 134 ++++++++++----------------------
 2 files changed, 58 insertions(+), 161 deletions(-)
drivers/gpu/drm/radeon/evergreen_hdmi.c +19 -66
index 327c08b..4fdecc2 100644
@@ -24,6 +24,7 @@
  * Authors: Christian König
  *          Rafał Miłecki
  */
+#include <linux/hdmi.h>
 #include <drm/drmP.h>
 #include <drm/radeon_drm.h>
 #include "radeon.h"
@@ -54,79 +55,18 @@ static void evergreen_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t cloc
 }
 
 /*
- * calculate the crc for a given info frame
- */
-static void evergreen_hdmi_infoframe_checksum(uint8_t packetType,
-					 uint8_t versionNumber,
-					 uint8_t length,
-					 uint8_t *frame)
-{
-	int i;
-	frame[0] = packetType + versionNumber + length;
-	for (i = 1; i <= length; i++)
-		frame[0] += frame[i];
-	frame[0] = 0x100 - frame[0];
-}
-
-/*
  * build a HDMI Video Info Frame
  */
-static void evergreen_hdmi_videoinfoframe(
-	struct drm_encoder *encoder,
-	uint8_t color_format,
-	int active_information_present,
-	uint8_t active_format_aspect_ratio,
-	uint8_t scan_information,
-	uint8_t colorimetry,
-	uint8_t ex_colorimetry,
-	uint8_t quantization,
-	int ITC,
-	uint8_t picture_aspect_ratio,
-	uint8_t video_format_identification,
-	uint8_t pixel_repetition,
-	uint8_t non_uniform_picture_scaling,
-	uint8_t bar_info_data_valid,
-	uint16_t top_bar,
-	uint16_t bottom_bar,
-	uint16_t left_bar,
-	uint16_t right_bar
-)
+static void evergreen_hdmi_update_avi_infoframe(struct drm_encoder *encoder,
+						void *buffer, size_t size)
 {
 	struct drm_device *dev = encoder->dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 	struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 	uint32_t offset = dig->afmt->offset;
+	uint8_t *frame = buffer + 3;
 
-	uint8_t frame[14];
-
-	frame[0x0] = 0;
-	frame[0x1] =
-		(scan_information & 0x3) |
-		((bar_info_data_valid & 0x3) << 2) |
-		((active_information_present & 0x1) << 4) |
-		((color_format & 0x3) << 5);
-	frame[0x2] =
-		(active_format_aspect_ratio & 0xF) |
-		((picture_aspect_ratio & 0x3) << 4) |
-		((colorimetry & 0x3) << 6);
-	frame[0x3] =
-		(non_uniform_picture_scaling & 0x3) |
-		((quantization & 0x3) << 2) |
-		((ex_colorimetry & 0x7) << 4) |
-		((ITC & 0x1) << 7);
-	frame[0x4] = (video_format_identification & 0x7F);
-	frame[0x5] = (pixel_repetition & 0xF);
-	frame[0x6] = (top_bar & 0xFF);
-	frame[0x7] = (top_bar >> 8);
-	frame[0x8] = (bottom_bar & 0xFF);
-	frame[0x9] = (bottom_bar >> 8);
-	frame[0xA] = (left_bar & 0xFF);
-	frame[0xB] = (left_bar >> 8);
-	frame[0xC] = (right_bar & 0xFF);
-	frame[0xD] = (right_bar >> 8);
-
-	evergreen_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
 	/* Our header values (type, version, length) should be alright, Intel
 	 * is using the same. Checksum function also seems to be OK, it works
 	 * fine for audio infoframe. However calculated value is always lower
@@ -154,7 +94,10 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 	struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+	u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
+	struct hdmi_avi_infoframe frame;
 	uint32_t offset;
+	ssize_t err;
 
 	/* Silent, r600_hdmi_enable will raise WARN for us */
 	if (!dig->afmt->enabled)
@@ -200,9 +143,19 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
 
 	WREG32(HDMI_GC + offset, 0); /* unset HDMI_GC_AVMUTE */
 
-	evergreen_hdmi_videoinfoframe(encoder, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-				      0, 0, 0, 0, 0, 0);
+	err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode);
+	if (err < 0) {
+		DRM_ERROR("failed to setup AVI infoframe: %zd\n", err);
+		return;
+	}
+
+	err = hdmi_avi_infoframe_pack(&frame, buffer, sizeof(buffer));
+	if (err < 0) {
+		DRM_ERROR("failed to pack AVI infoframe: %zd\n", err);
+		return;
+	}
 
+	evergreen_hdmi_update_avi_infoframe(encoder, buffer, sizeof(buffer));
 	evergreen_hdmi_update_ACR(encoder, mode->clock);
 
 	/* it's unknown what these bits do excatly, but it's indeed quite useful for debugging */
drivers/gpu/drm/radeon/r600_hdmi.c +39 -95

196 lines not on this page · raw message

Signature · 6 lines
1.8.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

PATCH v3 9/9 drm: Remove duplicate drm_mode_cea_vic()

In reply to Thierry Reding

The same function had already been merged with a different name. Remove the duplicate one but reuse some of its kerneldoc fragments for the existing implementation.

---
 drivers/gpu/drm/drm_edid.c | 30 +++++++-----------------------
 include/drm/drm_crtc.h     |  3 +--
 2 files changed, 8 insertions(+), 25 deletions(-)
drivers/gpu/drm/drm_edid.c +7 -23
index 1cfafc0..0acd6f3 100644
@@ -1514,11 +1514,14 @@ u8 *drm_find_cea_extension(struct edid *edid)
 }
 EXPORT_SYMBOL(drm_find_cea_extension);
 
-/*
- * Looks for a CEA mode matching given drm_display_mode.
- * Returns its CEA Video ID code, or 0 if not found.
+/**
+ * drm_match_cea_mode - look for a CEA mode matching given mode
+ * @mode: display mode
+ *
+ * Returns the CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861
+ * mode.
  */
-u8 drm_match_cea_mode(struct drm_display_mode *to_match)
+u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 {
 	struct drm_display_mode *cea_mode;
 	u8 mode;
@@ -2082,25 +2085,6 @@ int drm_add_modes_noedid(struct drm_connector *connector,
 EXPORT_SYMBOL(drm_add_modes_noedid);
 
 /**
- * drm_mode_cea_vic - return the CEA-861 VIC of a given mode
- * @mode: mode
- *
- * RETURNS:
- * The VIC number, 0 in case it's not a CEA-861 mode.
- */
-uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode)
-{
-	uint8_t i;
-
-	for (i = 0; i < drm_num_cea_modes; i++)
-		if (drm_mode_equal(mode, &edid_cea_modes[i]))
-			return i + 1;
-
-	return 0;
-}
-EXPORT_SYMBOL(drm_mode_cea_vic);
-
-/**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
  * @frame: HDMI AVI infoframe
include/drm/drm_crtc.h +1 -2
index dd62ca0..d0f3927 100644
@@ -1031,7 +1031,7 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 				    void *data, struct drm_file *file_priv);
 extern u8 *drm_find_cea_extension(struct edid *edid);
-extern u8 drm_match_cea_mode(struct drm_display_mode *to_match);
+extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 extern bool drm_detect_hdmi_monitor(struct edid *edid);
 extern bool drm_detect_monitor_audio(struct edid *edid);
 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
@@ -1048,7 +1048,6 @@ extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
 				int GTF_2C, int GTF_K, int GTF_2J);
 extern int drm_add_modes_noedid(struct drm_connector *connector,
 				int hdisplay, int vdisplay);
-extern uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode);
 
 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);
Signature · 1 line
1.8.1
#19 lore raw

Re: [PATCH v3 9/9] drm: Remove duplicate drm_mode_cea_vic()

Quoted 3 lines · Thierry Reding

The same function had already been merged with a different name. Remove the duplicate one but reuse some of its kerneldoc fragments for the existing implementation.

And I just used that function. Oh well ;)

Personally I would have kept the other function instead since it has a more descriptive name, but I can't be bothered to care enough to complain too much.

The patch could be moved to the beginning of the series, so it can be merged w/o being blocked by the more invasive stuff. Well, assuming that the more invasive stuff still needs discussing.

Quoted 83 lines
---
 drivers/gpu/drm/drm_edid.c | 30 +++++++-----------------------
 include/drm/drm_crtc.h     |  3 +--
 2 files changed, 8 insertions(+), 25 deletions(-)
drivers/gpu/drm/drm_edid.c +7 -23
index 1cfafc0..0acd6f3 100644
@@ -1514,11 +1514,14 @@ u8 *drm_find_cea_extension(struct edid *edid)
 }
 EXPORT_SYMBOL(drm_find_cea_extension);
 
-/*
- * Looks for a CEA mode matching given drm_display_mode.
- * Returns its CEA Video ID code, or 0 if not found.
+/**
+ * drm_match_cea_mode - look for a CEA mode matching given mode
+ * @mode: display mode
+ *
+ * Returns the CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861
+ * mode.
  */
-u8 drm_match_cea_mode(struct drm_display_mode *to_match)
+u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 {
 	struct drm_display_mode *cea_mode;
 	u8 mode;
@@ -2082,25 +2085,6 @@ int drm_add_modes_noedid(struct drm_connector *connector,
 EXPORT_SYMBOL(drm_add_modes_noedid);
 
 /**
- * drm_mode_cea_vic - return the CEA-861 VIC of a given mode
- * @mode: mode
- *
- * RETURNS:
- * The VIC number, 0 in case it's not a CEA-861 mode.
- */
-uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode)
-{
-	uint8_t i;
-
-	for (i = 0; i < drm_num_cea_modes; i++)
-		if (drm_mode_equal(mode, &edid_cea_modes[i]))
-			return i + 1;
-
-	return 0;
-}
-EXPORT_SYMBOL(drm_mode_cea_vic);
-
-/**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
  * @frame: HDMI AVI infoframe
include/drm/drm_crtc.h +1 -2
index dd62ca0..d0f3927 100644
@@ -1031,7 +1031,7 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 				    void *data, struct drm_file *file_priv);
 extern u8 *drm_find_cea_extension(struct edid *edid);
-extern u8 drm_match_cea_mode(struct drm_display_mode *to_match);
+extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 extern bool drm_detect_hdmi_monitor(struct edid *edid);
 extern bool drm_detect_monitor_audio(struct edid *edid);
 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
@@ -1048,7 +1048,6 @@ extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
 				int GTF_2C, int GTF_K, int GTF_2J);
 extern int drm_add_modes_noedid(struct drm_connector *connector,
 				int hdisplay, int vdisplay);
-extern uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode);
 
 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);
Signature · 6 lines
1.8.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel OTC
#20 lore raw

Re: [PATCH v3 9/9] drm: Remove duplicate drm_mode_cea_vic()

Quoted 10 lines · Ville Syrjälä
Quoted 3 lines · Thierry Reding

The same function had already been merged with a different name. Remove the duplicate one but reuse some of its kerneldoc fragments for the existing implementation.

And I just used that function. Oh well ;)

Personally I would have kept the other function instead since it has a more descriptive name, but I can't be bothered to care enough to complain too much.

drm_mode_cea_vic() was introduced later, so I preferred the older variant.

Quoted 3 lines

The patch could be moved to the beginning of the series, so it can be merged w/o being blocked by the more invasive stuff. Well, assuming that the more invasive stuff still needs discussing.

I had it at the beginning of the series, then realized that I hadn't updated the i915 driver properly. So I cheated a bit and just moved the patch instead of updating i915 and then resolving the conflict in the subsequent i915 HDMI helper patch. =)

If the series can't be merged as-is, I can work this in for the next version.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel