diff mbox

[i-g-t] lib: included igt_edid.h in igt_kms.c

Message ID 1410174741-13649-1-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Sept. 8, 2014, 11:12 a.m. UTC
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.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 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(-)

Comments

Daniel Vetter Sept. 8, 2014, 12:07 p.m. UTC | #1
On Mon, Sep 08, 2014 at 12:12:21PM +0100, Thomas Wood wrote:
> 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.

> 
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> ---
>  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(-)
> 
> diff --git a/docs/reference/intel-gpu-tools/Makefile.am b/docs/reference/intel-gpu-tools/Makefile.am
> index 3368e3e..05f604f 100644
> --- a/docs/reference/intel-gpu-tools/Makefile.am
> +++ b/docs/reference/intel-gpu-tools/Makefile.am
> @@ -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
> diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> index 3d9caf8..68ca8d4 100644
> --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> @@ -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">
> diff --git a/lib/igt_edid.h b/lib/igt_edid.h
> index 27373b7..7711841 100644
> --- a/lib/igt_edid.h
> +++ b/lib/igt_edid.h
> @@ -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

>  	{
>  	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
>  	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 3a850f1..26794f2 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -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.
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 921afef..23f73b1 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -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);
> diff --git a/tests/kms_3d.c b/tests/kms_3d.c
> index c11873b..9bf252c 100644
> --- a/tests/kms_3d.c
> +++ b/tests/kms_3d.c
> @@ -25,7 +25,6 @@
>  #include "igt_core.h"
>  #include "igt_kms.h"
>  #include "drmtest.h"
> -#include "igt_edid.h"
>  
>  igt_simple_main
>  {
> diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
> index 7dba68a..adb73a0 100644
> --- a/tests/kms_force_connector.c
> +++ b/tests/kms_force_connector.c
> @@ -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
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Thomas Wood Sept. 8, 2014, 12:48 p.m. UTC | #2
On 8 September 2014 13:07, Daniel Vetter <daniel@ffwll.ch> wrote:

> On Mon, Sep 08, 2014 at 12:12:21PM +0100, Thomas Wood wrote:
> > 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.
>

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.



>
> >
> > Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> > ---
> >  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(-)
> >
> > diff --git a/docs/reference/intel-gpu-tools/Makefile.am
> b/docs/reference/intel-gpu-tools/Makefile.am
> > index 3368e3e..05f604f 100644
> > --- a/docs/reference/intel-gpu-tools/Makefile.am
> > +++ b/docs/reference/intel-gpu-tools/Makefile.am
> > @@ -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
> > diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> > index 3d9caf8..68ca8d4 100644
> > --- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> > +++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
> > @@ -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">
> > diff --git a/lib/igt_edid.h b/lib/igt_edid.h
> > index 27373b7..7711841 100644
> > --- a/lib/igt_edid.h
> > +++ b/lib/igt_edid.h
> > @@ -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
>
> >       {
> >       0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
> >       0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> > diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> > index 3a850f1..26794f2 100644
> > --- a/lib/igt_kms.c
> > +++ b/lib/igt_kms.c
> > @@ -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.
> > diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> > index 921afef..23f73b1 100644
> > --- a/lib/igt_kms.h
> > +++ b/lib/igt_kms.h
> > @@ -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);
> > diff --git a/tests/kms_3d.c b/tests/kms_3d.c
> > index c11873b..9bf252c 100644
> > --- a/tests/kms_3d.c
> > +++ b/tests/kms_3d.c
> > @@ -25,7 +25,6 @@
> >  #include "igt_core.h"
> >  #include "igt_kms.h"
> >  #include "drmtest.h"
> > -#include "igt_edid.h"
> >
> >  igt_simple_main
> >  {
> > diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
> > index 7dba68a..adb73a0 100644
> > --- a/tests/kms_force_connector.c
> > +++ b/tests/kms_force_connector.c
> > @@ -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
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
>
diff mbox

Patch

diff --git a/docs/reference/intel-gpu-tools/Makefile.am b/docs/reference/intel-gpu-tools/Makefile.am
index 3368e3e..05f604f 100644
--- a/docs/reference/intel-gpu-tools/Makefile.am
+++ b/docs/reference/intel-gpu-tools/Makefile.am
@@ -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
diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 3d9caf8..68ca8d4 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -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">
diff --git a/lib/igt_edid.h b/lib/igt_edid.h
index 27373b7..7711841 100644
--- a/lib/igt_edid.h
+++ b/lib/igt_edid.h
@@ -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,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 3a850f1..26794f2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -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.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 921afef..23f73b1 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -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);
diff --git a/tests/kms_3d.c b/tests/kms_3d.c
index c11873b..9bf252c 100644
--- a/tests/kms_3d.c
+++ b/tests/kms_3d.c
@@ -25,7 +25,6 @@ 
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
-#include "igt_edid.h"
 
 igt_simple_main
 {
diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
index 7dba68a..adb73a0 100644
--- a/tests/kms_force_connector.c
+++ b/tests/kms_force_connector.c
@@ -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)