Skip to contentSkip to conversation

lib: included igt_edid.h in igt_kms.c

PATCH In review Thomas Wood 2 participants 3 messages Sep 8, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: included igt_edid.h in igt_kms.c

Include the generic_edid array inside igt_kms.c to avoid having to include it separately in tests. This also means it can be included in the i-g-t kms section of the documentation.

---
 docs/reference/intel-gpu-tools/Makefile.am              |  3 ++-
 docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml |  1 -
 lib/igt_edid.h                                          |  2 +-
 lib/igt_kms.c                                           |  2 ++
 lib/igt_kms.h                                           | 17 +++++++++++++++++
 tests/kms_3d.c                                          |  1 -
 tests/kms_force_connector.c                             |  1 -
 7 files changed, 22 insertions(+), 5 deletions(-)
docs/reference/intel-gpu-tools/Makefile.am +2 -1
index 3368e3e..05f604f 100644
@@ -60,7 +60,8 @@ EXTRA_HFILES=
 # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
 IGNORE_HFILES=gen6_render.h gen7_media.h gen7_render.h gen8_media.h \
 	      gen8_render.h i830_reg.h i915_3d.h i915_pciids.h i915_reg.h \
-	      intel_reg.h debug.h instdone.h media_fill.h rendercopy.h
+	      igt_edid.h intel_reg.h debug.h instdone.h media_fill.h \
+	      rendercopy.h
 
 # Images to copy into HTML directory.
 # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +0 -1
index 3d9caf8..68ca8d4 100644
@@ -25,7 +25,6 @@
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_io.xml"/>
-    <xi:include href="xml/igt_edid.xml"/>
 
   </chapter>
   <index id="api-index-full">
lib/igt_edid.h +1 -1
index 27373b7..7711841 100644
@@ -29,7 +29,7 @@
 
 #define EDID_LENGTH 128
 
-static const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {
 	{
 	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
 	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
lib/igt_kms.c +2 -0
index 3a850f1..26794f2 100644
@@ -43,6 +43,8 @@
 #include "igt_aux.h"
 #include "intel_chipset.h"
 
+#include "igt_edid.h"
+
 /*
  * There hasn't been a release of libdrm containing these #define's yet, so
  * copy them here to allow compilation to succeed in the mean time.
lib/igt_kms.h +17 -0
index 921afef..23f73b1 100644
@@ -127,6 +127,12 @@ enum kmstest_force_connector_state {
 	FORCE_CONNECTOR_OFF
 };
 
+/**
+ * EDID_LENGTH:
+ *
+ * Length of an EDID block, in bytes.
+ */
+#define EDID_LENGTH 128
 
 /**
  * kmstest_generic_edid:
@@ -136,6 +142,8 @@ enum kmstest_force_connector_state {
  * @EDID_WSXGA: 1680x1050
  * @EDID_FHD: 1920x1080
  * @MAX_EDIDS: Size of #generic_edid array
+ *
+ * Index of items in the #generic_edid array.
  */
 enum kmstest_generic_edid {
 	EDID_XGA,   /* 1024x768 */
@@ -147,6 +155,15 @@ enum kmstest_generic_edid {
 	MAX_EDIDS
 };
 
+/**
+ * generic_edid:
+ *
+ * An array of generic EDID blocks, with each item corresponding to the entries
+ * in #kmstest_generic_edid.
+ */
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH];
+
+
 bool kmstest_force_connector(int fd, drmModeConnector *connector,
 			     enum kmstest_force_connector_state state);
 void kmstest_edid_add_3d(const unsigned char *edid, size_t length, unsigned char *new_edid_ptr[], size_t *new_length);
tests/kms_3d.c +0 -1
index c11873b..9bf252c 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 igt_simple_main
 {
tests/kms_force_connector.c +0 -1
index 7dba68a..adb73a0 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 int
 main (int argc, char **argv)
Signature · 1 line
1.9.3
#1 lore raw
Quoted 3 lines · Thomas Wood

Include the generic_edid array inside igt_kms.c to avoid having to include it separately in tests. This also means it can be included in the i-g-t kms section of the documentation.

You can just include igt_edid.h from igt_kms.h and add the corresponding note in the documentation like we do for igt_fb.[hc] already. That way we have nice doc splits and the simplest possible interface for tests.

Quoted 43 lines
---
 docs/reference/intel-gpu-tools/Makefile.am              |  3 ++-
 docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml |  1 -
 lib/igt_edid.h                                          |  2 +-
 lib/igt_kms.c                                           |  2 ++
 lib/igt_kms.h                                           | 17 +++++++++++++++++
 tests/kms_3d.c                                          |  1 -
 tests/kms_force_connector.c                             |  1 -
 7 files changed, 22 insertions(+), 5 deletions(-)
docs/reference/intel-gpu-tools/Makefile.am +2 -1
index 3368e3e..05f604f 100644
@@ -60,7 +60,8 @@ EXTRA_HFILES=
 # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
 IGNORE_HFILES=gen6_render.h gen7_media.h gen7_render.h gen8_media.h \
 	      gen8_render.h i830_reg.h i915_3d.h i915_pciids.h i915_reg.h \
-	      intel_reg.h debug.h instdone.h media_fill.h rendercopy.h
+	      igt_edid.h intel_reg.h debug.h instdone.h media_fill.h \
+	      rendercopy.h
 
 # Images to copy into HTML directory.
 # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +0 -1
index 3d9caf8..68ca8d4 100644
@@ -25,7 +25,6 @@
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_io.xml"/>
-    <xi:include href="xml/igt_edid.xml"/>
 
   </chapter>
   <index id="api-index-full">
lib/igt_edid.h +0 -0
index 27373b7..7711841 100644

lib/igt_edid.h line 32

Quoted 5 lines
lib/igt_edid.h +1 -1
@@ -29,7 +29,7 @@
 
 #define EDID_LENGTH 128
 
-static const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {

But if you want to move something then imo this here should go into a .c file - global variable definitions in headers just aint pretty ;-)

Cheers, Daniel

Quoted 89 lines
lib/igt_edid.h +0 -0
 	{
 	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
 	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
lib/igt_kms.c +2 -0
index 3a850f1..26794f2 100644
@@ -43,6 +43,8 @@
 #include "igt_aux.h"
 #include "intel_chipset.h"
 
+#include "igt_edid.h"
+
 /*
  * There hasn't been a release of libdrm containing these #define's yet, so
  * copy them here to allow compilation to succeed in the mean time.
lib/igt_kms.h +17 -0
index 921afef..23f73b1 100644
@@ -127,6 +127,12 @@ enum kmstest_force_connector_state {
 	FORCE_CONNECTOR_OFF
 };
 
+/**
+ * EDID_LENGTH:
+ *
+ * Length of an EDID block, in bytes.
+ */
+#define EDID_LENGTH 128
 
 /**
  * kmstest_generic_edid:
@@ -136,6 +142,8 @@ enum kmstest_force_connector_state {
  * @EDID_WSXGA: 1680x1050
  * @EDID_FHD: 1920x1080
  * @MAX_EDIDS: Size of #generic_edid array
+ *
+ * Index of items in the #generic_edid array.
  */
 enum kmstest_generic_edid {
 	EDID_XGA,   /* 1024x768 */
@@ -147,6 +155,15 @@ enum kmstest_generic_edid {
 	MAX_EDIDS
 };
 
+/**
+ * generic_edid:
+ *
+ * An array of generic EDID blocks, with each item corresponding to the entries
+ * in #kmstest_generic_edid.
+ */
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH];
+
+
 bool kmstest_force_connector(int fd, drmModeConnector *connector,
 			     enum kmstest_force_connector_state state);
 void kmstest_edid_add_3d(const unsigned char *edid, size_t length, unsigned char *new_edid_ptr[], size_t *new_length);
tests/kms_3d.c +0 -1
index c11873b..9bf252c 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 igt_simple_main
 {
tests/kms_force_connector.c +0 -1
index 7dba68a..adb73a0 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 int
 main (int argc, char **argv)
Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
Quoted 11 lines · Daniel Vetter
Quoted 1 line · Thomas Wood

Include the generic_edid array inside igt_kms.c to avoid having to

include

Quoted 1 line

it separately in tests. This also means it can be included in the i-g-t

kms

Quoted 1 line

section of the documentation.

You can just include igt_edid.h from igt_kms.h and add the corresponding note in the documentation like we do for igt_fb.[hc] already. That way we have nice doc splits and the simplest possible interface for tests.

Including igt_edid.h in igt_kms.h causes problems with multiple definitions of generic_edid when linking, so this was a way of avoiding that. The intention was that igt_kms.h would not be included from anywhere else, so the definition would effectively be in igt_kms.c.

However, moving the definition into a .c file (as suggested below) would perhaps be slightly nicer and avoid potential confusion.

Quoted 146 lines
Quoted 9 lines
---
 docs/reference/intel-gpu-tools/Makefile.am              |  3 ++-
 docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml |  1 -
 lib/igt_edid.h                                          |  2 +-
 lib/igt_kms.c                                           |  2 ++
 lib/igt_kms.h                                           | 17

+++++++++++++++++

Review

Quoted 5 lines
 tests/kms_3d.c                                          |  1 -
 tests/kms_force_connector.c                             |  1 -
 7 files changed, 22 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/docs/reference/intel-gpu-tools/Makefile.am

Review

Quoted 14 lines

index 3368e3e..05f604f 100644

docs/reference/intel-gpu-tools/Makefile.am +2 -1
@@ -60,7 +60,8 @@ EXTRA_HFILES=
 # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
 IGNORE_HFILES=gen6_render.h gen7_media.h gen7_render.h gen8_media.h \
            gen8_render.h i830_reg.h i915_3d.h i915_pciids.h i915_reg.h \
-           intel_reg.h debug.h instdone.h media_fill.h rendercopy.h
+           igt_edid.h intel_reg.h debug.h instdone.h media_fill.h \
+           rendercopy.h
 
 # Images to copy into HTML directory.
 # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
(quoted diff) +0 -0

b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml

Quoted 16 lines

index 3d9caf8..68ca8d4 100644

docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +0 -1
@@ -25,7 +25,6 @@
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_io.xml"/>
-    <xi:include href="xml/igt_edid.xml"/>
 
   </chapter>
   <index id="api-index-full">
lib/igt_edid.h +0 -0
index 27373b7..7711841 100644

lib/igt_edid.h line 32

Quoted 5 lines
lib/igt_edid.h +1 -1
@@ -29,7 +29,7 @@
 
 #define EDID_LENGTH 128
 
-static const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {

But if you want to move something then imo this here should go into a .c file - global variable definitions in headers just aint pretty ;-)

Cheers, Daniel

Quoted 8 lines
lib/igt_edid.h +0 -0
      {
      0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
      0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
lib/igt_kms.c +0 -0
index 3a850f1..26794f2 100644

lib/igt_kms.c line 49

Quoted 7 lines
lib/igt_kms.c +2 -0
@@ -43,6 +43,8 @@
 #include "igt_aux.h"
 #include "intel_chipset.h"
 
+#include "igt_edid.h"
+
 /*
  * There hasn't been a release of libdrm containing these #define's

yet, so

Quoted 28 lines
lib/igt_kms.c +0 -0
  * copy them here to allow compilation to succeed in the mean time.
lib/igt_kms.h +8 -0
index 921afef..23f73b1 100644
@@ -127,6 +127,12 @@ enum kmstest_force_connector_state {
      FORCE_CONNECTOR_OFF
 };
 
+/**
+ * EDID_LENGTH:
+ *
+ * Length of an EDID block, in bytes.
+ */
+#define EDID_LENGTH 128
 
 /**
  * kmstest_generic_edid:
@@ -136,6 +142,8 @@ enum kmstest_force_connector_state {
  * @EDID_WSXGA: 1680x1050
  * @EDID_FHD: 1920x1080
  * @MAX_EDIDS: Size of #generic_edid array
+ *
+ * Index of items in the #generic_edid array.
  */
 enum kmstest_generic_edid {
      EDID_XGA,   /* 1024x768 */

lib/igt_kms.h enum kmstest_generic_edid { · line 161

Quoted 7 lines
lib/igt_kms.h +4 -0
@@ -147,6 +155,15 @@ enum kmstest_generic_edid {
      MAX_EDIDS
 };
 
+/**
+ * generic_edid:
+ *
+ * An array of generic EDID blocks, with each item corresponding to the

entries

lib/igt_kms.h enum kmstest_generic_edid {

Quoted 8 lines
lib/igt_kms.h +5 -0
+ * in #kmstest_generic_edid.
+ */
+const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH];
+
+
 bool kmstest_force_connector(int fd, drmModeConnector *connector,
                           enum kmstest_force_connector_state state);
 void kmstest_edid_add_3d(const unsigned char *edid, size_t length,

unsigned char *new_edid_ptr[], size_t *new_length);

Quoted 27 lines
tests/kms_3d.c +0 -1
index c11873b..9bf252c 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 igt_simple_main
 {
tests/kms_force_connector.c +0 -2
index 7dba68a..adb73a0 100644
@@ -25,7 +25,6 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 int
 main (int argc, char **argv)
--

1.9.3

Quoted 10 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx