dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH libdrm 05/11] tests: Move name tables to libutil
Date: Sun, 25 Jan 2015 01:24:55 +0200	[thread overview]
Message-ID: <2224555.u8x3AgUysX@avalon> (raw)
In-Reply-To: <1422029304-1926-6-git-send-email-thierry.reding@gmail.com>

Hi Thierry,

Thank you for the patch.

On Friday 23 January 2015 17:08:18 Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> These tables are duplicated in several places, so move them into libutil
> so that they can be shared.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  tests/modetest/modetest.c  |  50 ++-----------------
>  tests/proptest/Makefile.am |   4 +-
>  tests/proptest/proptest.c  |  40 +--------------
>  tests/util/Makefile.am     |   2 +
>  tests/util/kms.c           | 122 ++++++++++++++++++++++++++++++++++++++++++
>  tests/util/kms.h           |  33 ++++++++++++
>  6 files changed, 165 insertions(+), 86 deletions(-)
>  create mode 100644 tests/util/kms.c
>  create mode 100644 tests/util/kms.h
> 
> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> index b610956adfcb..d5fd99ebe1fd 100644
> --- a/tests/modetest/modetest.c
> +++ b/tests/modetest/modetest.c
> @@ -61,6 +61,7 @@
> 
>  #include "util/common.h"
>  #include "util/format.h"
> +#include "util/kms.h"
>  #include "util/pattern.h"
> 
>  #include "buffers.h"
> @@ -123,11 +124,6 @@ static inline int64_t U642I64(uint64_t val)
>  	return (int64_t)*((int64_t *)&val);
>  }
> 
> -struct type_name {
> -	int type;
> -	const char *name;
> -};
> -
>  #define type_name_fn(res) \
>  const char * res##_str(int type) {			\
>  	unsigned int i;					\
> @@ -138,44 +134,6 @@ const char * res##_str(int type) {			\
>  	return "(invalid)";				\
>  }
> 
> -struct type_name encoder_type_names[] = {
> -	{ DRM_MODE_ENCODER_NONE, "none" },
> -	{ DRM_MODE_ENCODER_DAC, "DAC" },
> -	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
> -	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
> -	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
> -};
> -
> -static type_name_fn(encoder_type)
> -
> -struct type_name connector_status_names[] = {
> -	{ DRM_MODE_CONNECTED, "connected" },
> -	{ DRM_MODE_DISCONNECTED, "disconnected" },
> -	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
> -};
> -
> -static type_name_fn(connector_status)
> -
> -struct type_name connector_type_names[] = {
> -	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
> -	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
> -	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
> -	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
> -	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
> -	{ DRM_MODE_CONNECTOR_Composite, "composite" },
> -	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
> -	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
> -	{ DRM_MODE_CONNECTOR_Component, "component" },
> -	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
> -	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
> -	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
> -	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
> -	{ DRM_MODE_CONNECTOR_TV, "TV" },
> -	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
> -};
> -
> -static type_name_fn(connector_type)
> -
>  #define bit_name_fn(res)					\
>  const char * res##_str(int type) {				\
>  	unsigned int i;						\
> @@ -235,7 +193,7 @@ static void dump_encoders(struct device *dev)
>  		printf("%d\t%d\t%s\t0x%08x\t0x%08x\n",
>  		       encoder->encoder_id,
>  		       encoder->crtc_id,
> -		       encoder_type_str(encoder->encoder_type),
> +		       util_lookup_encoder_type_name(encoder->encoder_type),
>  		       encoder->possible_crtcs,
>  		       encoder->possible_clones);
>  	}
> @@ -379,8 +337,8 @@ static void dump_connectors(struct device *dev)
>  		printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\t",
>  		       connector->connector_id,
>  		       connector->encoder_id,
> -		       connector_status_str(connector->connection),
> -		       connector_type_str(connector->connector_type),
> +		       util_lookup_connector_status_name(connector->connection),
> +		       util_lookup_connector_type_name(connector->connector_type),
>  		       connector->mmWidth, connector->mmHeight,
>  		       connector->count_modes);
> 
> diff --git a/tests/proptest/Makefile.am b/tests/proptest/Makefile.am
> index f81a3c00846b..c615489b9a92 100644
> --- a/tests/proptest/Makefile.am
> +++ b/tests/proptest/Makefile.am
> @@ -1,5 +1,6 @@
>  AM_CFLAGS = \
>  	-I$(top_srcdir)/include/drm \
> +	-I$(top_srcdir)/tests \
>  	-I$(top_srcdir)
> 
>  noinst_PROGRAMS = \
> @@ -8,4 +9,5 @@ noinst_PROGRAMS = \
>  proptest_SOURCES = \
>  	proptest.c
>  proptest_LDADD = \
> -	$(top_builddir)/libdrm.la
> +	$(top_builddir)/libdrm.la \
> +	$(top_builddir)/tests/util/libutil.la
> diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
> index ee3fa408a310..b442d583d528 100644
> --- a/tests/proptest/proptest.c
> +++ b/tests/proptest/proptest.c
> @@ -45,44 +45,6 @@ static inline int64_t U642I64(uint64_t val)
>  int fd;
>  drmModeResPtr res = NULL;
> 
> -const char *connector_type_str(uint32_t type)
> -{
> -	switch (type) {
> -	case DRM_MODE_CONNECTOR_Unknown:
> -		return "Unknown";
> -	case DRM_MODE_CONNECTOR_VGA:
> -		return "VGA";
> -	case DRM_MODE_CONNECTOR_DVII:
> -		return "DVI-I";
> -	case DRM_MODE_CONNECTOR_DVID:
> -		return "DVI-D";
> -	case DRM_MODE_CONNECTOR_DVIA:
> -		return "DVI-A";
> -	case DRM_MODE_CONNECTOR_Composite:
> -		return "Composite";
> -	case DRM_MODE_CONNECTOR_SVIDEO:
> -		return "SVIDEO";
> -	case DRM_MODE_CONNECTOR_LVDS:
> -		return "LVDS";
> -	case DRM_MODE_CONNECTOR_Component:
> -		return "Component";
> -	case DRM_MODE_CONNECTOR_9PinDIN:
> -		return "9PinDin";
> -	case DRM_MODE_CONNECTOR_DisplayPort:
> -		return "DisplayPort";
> -	case DRM_MODE_CONNECTOR_HDMIA:
> -		return "HDMI-A";
> -	case DRM_MODE_CONNECTOR_HDMIB:
> -		return "HDMI-B";
> -	case DRM_MODE_CONNECTOR_TV:
> -		return "TV";
> -	case DRM_MODE_CONNECTOR_eDP:
> -		return "eDP";
> -	default:
> -		return "Invalid";
> -	}
> -}
> -
>  /* dump_blob and dump_prop shamelessly copied from ../modetest/modetest.c
> */ static void
>  dump_blob(uint32_t blob_id)
> @@ -226,7 +188,7 @@ static void listConnectorProperties(void)
>  		}
> 
>  		printf("Connector %u (%s-%u)\n", c->connector_id,
> -		       connector_type_str(c->connector_type),
> +		       util_lookup_connector_type_name(c->connector_type),
>  		       c->connector_type_id);
> 
>  		listObjectProperties(c->connector_id,
> diff --git a/tests/util/Makefile.am b/tests/util/Makefile.am
> index 1a2519fbea89..c00574484867 100644
> --- a/tests/util/Makefile.am
> +++ b/tests/util/Makefile.am
> @@ -12,6 +12,8 @@ libutil_la_SOURCES = \
>  	common.h \
>  	format.c \
>  	format.h \
> +	kms.c \
> +	kms.h \
>  	pattern.c \
>  	pattern.h
> 
> diff --git a/tests/util/kms.c b/tests/util/kms.c
> new file mode 100644
> index 000000000000..a271ca047c4e
> --- /dev/null
> +++ b/tests/util/kms.c
> @@ -0,0 +1,122 @@
> +/*
> + * Copyright 2008 Tungsten Graphics
> + *   Jakob Bornecrantz <jakob@tungstengraphics.com>
> + * Copyright 2008 Intel Corporation
> + *   Jesse Barnes <jesse.barnes@intel.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the
> "Software"), + * to deal in the Software without restriction, including
> without limitation + * the rights to use, copy, modify, merge, publish,
> distribute, sublicense, + * and/or sell copies of the Software, and to
> permit persons to whom the + * Software is furnished to do so, subject to
> the following conditions: + *
> + * The above copyright notice and this permission notice shall be included
> in + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE.
> + */
> +
> +/*
> + * This fairly simple test program dumps output in a similar format to the
> + * "xrandr" tool everyone knows & loves.  It's necessarily slightly
> different + * since the kernel separates outputs into encoder and connector
> structures, + * each with their own unique ID.  The program also allows
> test testing of the + * memory management and mode setting APIs by allowing
> the user to specify a + * connector and mode to use for mode setting.  If
> all works as expected, a + * blue background should be painted on the
> monitor attached to the specified + * connector after the selected mode is
> set.
> + *
> + * TODO: use cairo to write the mode info on the selected output once
> + *       the mode has been programmed, along with possible test patterns.
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include <stdint.h>
> +#include <stdlib.h>
> +
> +#include "xf86drmMode.h"
> +
> +#include "common.h"
> +
> +struct type_name {
> +	unsigned int type;
> +	const char *name;
> +};
> +
> +static const char *util_lookup_type_name(unsigned int type,
> +					 const struct type_name *table,
> +					 unsigned int count)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < count; i++)
> +		if (table[i].type == type)
> +			return table[i].name;
> +
> +	return NULL;
> +}
> +
> +static const struct type_name encoder_type_names[] = {
> +	{ DRM_MODE_ENCODER_NONE, "none" },
> +	{ DRM_MODE_ENCODER_DAC, "DAC" },
> +	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
> +	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
> +	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
> +	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
> +	{ DRM_MODE_ENCODER_DSI, "DSI" },
> +	{ DRM_MODE_ENCODER_DPMST, "DisplayPort MST" },
> +};
> +
> +const char *util_lookup_encoder_type_name(unsigned int type)
> +{
> +	return util_lookup_type_name(type, encoder_type_names,
> +				     ARRAY_SIZE(encoder_type_names));
> +}
> +
> +static const struct type_name connector_status_names[] = {
> +	{ DRM_MODE_CONNECTED, "connected" },
> +	{ DRM_MODE_DISCONNECTED, "disconnected" },
> +	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
> +};
> +
> +const char *util_lookup_connector_status_name(unsigned int status)
> +{
> +	return util_lookup_type_name(status, connector_status_names,
> +				     ARRAY_SIZE(connector_status_names));
> +}
> +
> +static const struct type_name connector_type_names[] = {
> +	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
> +	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
> +	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
> +	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
> +	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
> +	{ DRM_MODE_CONNECTOR_Composite, "composite" },
> +	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
> +	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
> +	{ DRM_MODE_CONNECTOR_Component, "component" },
> +	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
> +	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
> +	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
> +	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
> +	{ DRM_MODE_CONNECTOR_TV, "TV" },
> +	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
> +	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
> +	{ DRM_MODE_CONNECTOR_DSI, "DSI" },
> +};
> +
> +const char *util_lookup_connector_type_name(unsigned int type)
> +{
> +	return util_lookup_type_name(type, connector_type_names,
> +				     ARRAY_SIZE(connector_type_names));
> +}
> diff --git a/tests/util/kms.h b/tests/util/kms.h
> new file mode 100644
> index 000000000000..fa9ab69983ac
> --- /dev/null
> +++ b/tests/util/kms.h
> @@ -0,0 +1,33 @@
> +/*
> + * Copyright 2008 Tungsten Graphics
> + *   Jakob Bornecrantz <jakob@tungstengraphics.com>
> + * Copyright 2008 Intel Corporation
> + *   Jesse Barnes <jesse.barnes@intel.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the
> "Software"), + * to deal in the Software without restriction, including
> without limitation + * the rights to use, copy, modify, merge, publish,
> distribute, sublicense, + * and/or sell copies of the Software, and to
> permit persons to whom the + * Software is furnished to do so, subject to
> the following conditions: + *
> + * The above copyright notice and this permission notice shall be included
> in + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE.
> + */
> +
> +#ifndef UTIL_KMS_H
> +#define UTIL_KMS_H
> +
> +const char *util_lookup_encoder_type_name(unsigned int type);
> +const char *util_lookup_connector_status_name(unsigned int type);
> +const char *util_lookup_connector_type_name(unsigned int type);
> +
> +#endif /* UTIL_KMS_H */

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-01-24 23:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 16:08 [PATCH libdrm 00/11] Random assortment of fixes and enhancements Thierry Reding
2015-01-23 16:08 ` [PATCH libdrm 01/11] libdrm: valgrind-clear a few more IOCTL arguments Thierry Reding
2015-01-24 23:19   ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 02/11] libdrm: Remove gratuitous blank lines Thierry Reding
2015-01-24 23:19   ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 03/11] libdrm: Make indentation consistent Thierry Reding
2015-01-24 23:20   ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 04/11] tests: Split helpers into library Thierry Reding
2015-01-24 23:24   ` Laurent Pinchart
2015-01-29 15:27   ` [PATCH 04.1/11] SQUASH: tests: misc cleanups Emil Velikov
2015-01-29 15:27   ` [PATCH 04.2/11] SQUASH: util: add android build Emil Velikov
2015-01-23 16:08 ` [PATCH libdrm 05/11] tests: Move name tables to libutil Thierry Reding
2015-01-24 23:24   ` Laurent Pinchart [this message]
2015-01-29 15:28   ` [PATCH 05.1/11] SQUASH: util: add the kms.[ch] to makefile.sources Emil Velikov
2015-01-23 16:08 ` [PATCH libdrm 06/11] xf86drmMode.h: Use consistent padding Thierry Reding
2015-01-24 23:26   ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 07/11] xf86drmMode.h: Add DisplayPort MST encoder type Thierry Reding
2015-01-24 23:40   ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 08/11] tests: modetest: Accept connector names Thierry Reding
2015-01-24 23:56   ` Laurent Pinchart
2015-01-26 10:14     ` Thierry Reding
2015-01-26 10:24       ` Laurent Pinchart
2015-01-23 16:08 ` [PATCH libdrm 09/11] tests: Add libkms-test library Thierry Reding
2015-01-29 15:30   ` [PATCH 09.1/11] SQUASH: libkms-test: add missing header to the distribution Emil Velikov
2015-01-23 16:08 ` [PATCH libdrm 10/11] tests: kms: Implement CRTC stealing test Thierry Reding
2015-01-29 15:30   ` [PATCH 10.1/11] SQUASH: kms-steal-crtc: link against cairo Emil Velikov
2015-01-23 16:08 ` [PATCH libdrm 11/11] tests: kms: Implement universal planes test Thierry Reding
2015-01-29 15:31   ` [PATCH 11.1/11] SQUASH: kms-universal-planes: link against cairo Emil Velikov
2015-01-29 15:36 ` [PATCH libdrm 00/11] Random assortment of fixes and enhancements Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2224555.u8x3AgUysX@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox