All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm: Print pretty names for pixel formats
@ 2013-06-07 15:43 ville.syrjala
  2013-06-07 15:43 ` [PATCH 2/4] drm/i915: " ville.syrjala
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-07 15:43 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Foo Bar <foo@bar.com>

Rather than just printing the pixel format as a hex number, decode the
fourcc into human readable form, and also decode the LE vs. BE flag.

Keep printing the raw hex number too in case it contains non-printable
characters.

Some examples what the new drm_get_format_name() produces:
DRM_FORMAT_XRGB8888: "XR24 little-endian (0x34325258)"
DRM_FORMAT_YUYV: "YUYV little-endian (0x56595559)"
DRM_FORMAT_RGB565|DRM_FORMAT_BIG_ENDIAN: "RG16 big-endian (0xb6314752)"
Unprintable characters: "D??? big-endian (0xff7f0244)"

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 29 +++++++++++++++++++++++++++--
 include/drm/drm_crtc.h     |  1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e7e9242..079996a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -29,6 +29,7 @@
  *      Dave Airlie <airlied@linux.ie>
  *      Jesse Barnes <jesse.barnes@intel.com>
  */
+#include <linux/ctype.h>
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/export.h>
@@ -252,6 +253,28 @@ char *drm_get_connector_status_name(enum drm_connector_status status)
 }
 EXPORT_SYMBOL(drm_get_connector_status_name);
 
+static char printable_char(int c)
+{
+	return isascii(c) && isprint(c) ? c : '?';
+}
+
+char *drm_get_format_name(uint32_t format)
+{
+	static char buf[32];
+
+	snprintf(buf, sizeof(buf),
+		 "%c%c%c%c %s-endian (0x%08x)",
+		 printable_char(format & 0xff),
+		 printable_char((format >> 8) & 0xff),
+		 printable_char((format >> 16) & 0xff),
+		 printable_char((format >> 24) & 0x7f),
+		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
+		 format);
+
+	return buf;
+}
+EXPORT_SYMBOL(drm_get_format_name);
+
 /**
  * drm_mode_object_get - allocate a new modeset identifier
  * @dev: DRM device
@@ -1834,7 +1857,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 		if (fb->pixel_format == plane->format_types[i])
 			break;
 	if (i == plane->format_count) {
-		DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", fb->pixel_format);
+		DRM_DEBUG_KMS("Invalid pixel format %s\n",
+			      drm_get_format_name(fb->pixel_format));
 		ret = -EINVAL;
 		goto out;
 	}
@@ -2312,7 +2336,8 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
 
 	ret = format_check(r);
 	if (ret) {
-		DRM_DEBUG_KMS("bad framebuffer format 0x%08x\n", r->pixel_format);
+		DRM_DEBUG_KMS("bad framebuffer format %s\n",
+			      drm_get_format_name(r->pixel_format));
 		return ret;
 	}
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index adb3f9b..2cbbfd4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1094,5 +1094,6 @@ extern int drm_format_num_planes(uint32_t format);
 extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
+extern char *drm_get_format_name(uint32_t format);
 
 #endif /* __DRM_CRTC_H__ */
-- 
1.8.1.5

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] drm/i915: Print pretty names for pixel formats
  2013-06-07 15:43 [PATCH 1/4] drm: Print pretty names for pixel formats ville.syrjala
@ 2013-06-07 15:43 ` ville.syrjala
  2013-06-07 15:43   ` ville.syrjala
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-07 15:43 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Use drm_get_format_name to print more readable pixel format names
in debug output.

Also unify the debug messages to say "unsupported pixel format",
which better describes what is going on.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 92fd0d4..d4886dc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9030,7 +9030,8 @@ int intel_framebuffer_init(struct drm_device *dev,
 	case DRM_FORMAT_XRGB1555:
 	case DRM_FORMAT_ARGB1555:
 		if (INTEL_INFO(dev)->gen > 3) {
-			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
+			DRM_DEBUG("unsupported pixel format: %s\n",
+				  drm_get_format_name(mode_cmd->pixel_format));
 			return -EINVAL;
 		}
 		break;
@@ -9041,7 +9042,8 @@ int intel_framebuffer_init(struct drm_device *dev,
 	case DRM_FORMAT_XBGR2101010:
 	case DRM_FORMAT_ABGR2101010:
 		if (INTEL_INFO(dev)->gen < 4) {
-			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
+			DRM_DEBUG("unsupported pixel format: %s\n",
+				  drm_get_format_name(mode_cmd->pixel_format));
 			return -EINVAL;
 		}
 		break;
@@ -9050,12 +9052,14 @@ int intel_framebuffer_init(struct drm_device *dev,
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_VYUY:
 		if (INTEL_INFO(dev)->gen < 5) {
-			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
+			DRM_DEBUG("unsupported pixel format: %s\n",
+				  drm_get_format_name(mode_cmd->pixel_format));
 			return -EINVAL;
 		}
 		break;
 	default:
-		DRM_DEBUG("unsupported pixel format 0x%08x\n", mode_cmd->pixel_format);
+		DRM_DEBUG("unsupported pixel format: %s\n",
+			  drm_get_format_name(mode_cmd->pixel_format));
 		return -EINVAL;
 	}
 
-- 
1.8.1.5

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] fb: Make fb_get_options() 'name' parameter const
  2013-06-07 15:43 [PATCH 1/4] drm: Print pretty names for pixel formats ville.syrjala
@ 2013-06-07 15:43   ` ville.syrjala
  2013-06-07 15:43   ` ville.syrjala
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-07 15:43 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev

From: Ville Syrj채l채 <ville.syrjala@linux.intel.com>

The string isn't modified so make it const.

Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: Ville Syrj채l채 <ville.syrjala@linux.intel.com>
---
 drivers/video/fbmem.c | 2 +-
 include/linux/fb.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 098bfc6..d8d5779 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1881,7 +1881,7 @@ static int ofonly __read_mostly;
  *
  * NOTE: Needed to maintain backwards compatibility
  */
-int fb_get_options(char *name, char **option)
+int fb_get_options(const char *name, char **option)
 {
 	char *opt, *options = NULL;
 	int retval = 0;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index d49c60f..ffac70a 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -624,7 +624,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3
 extern void fb_set_suspend(struct fb_info *info, int state);
 extern int fb_get_color_depth(struct fb_var_screeninfo *var,
 			      struct fb_fix_screeninfo *fix);
-extern int fb_get_options(char *name, char **option);
+extern int fb_get_options(const char *name, char **option);
 extern int fb_new_modelist(struct fb_info *info);
 
 extern struct fb_info *registered_fb[FB_MAX];
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] fb: Make fb_get_options() 'name' parameter const
@ 2013-06-07 15:43   ` ville.syrjala
  0 siblings, 0 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-07 15:43 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	linux-fbdev

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The string isn't modified so make it const.

Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/video/fbmem.c | 2 +-
 include/linux/fb.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 098bfc6..d8d5779 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1881,7 +1881,7 @@ static int ofonly __read_mostly;
  *
  * NOTE: Needed to maintain backwards compatibility
  */
-int fb_get_options(char *name, char **option)
+int fb_get_options(const char *name, char **option)
 {
 	char *opt, *options = NULL;
 	int retval = 0;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index d49c60f..ffac70a 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -624,7 +624,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3
 extern void fb_set_suspend(struct fb_info *info, int state);
 extern int fb_get_color_depth(struct fb_var_screeninfo *var,
 			      struct fb_fix_screeninfo *fix);
-extern int fb_get_options(char *name, char **option);
+extern int fb_get_options(const char *name, char **option);
 extern int fb_new_modelist(struct fb_info *info);
 
 extern struct fb_info *registered_fb[FB_MAX];
-- 
1.8.1.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] drm: Constify the pretty-print functions
  2013-06-07 15:43 [PATCH 1/4] drm: Print pretty names for pixel formats ville.syrjala
  2013-06-07 15:43 ` [PATCH 2/4] drm/i915: " ville.syrjala
  2013-06-07 15:43   ` ville.syrjala
@ 2013-06-07 15:43 ` ville.syrjala
  2013-06-07 16:03   ` Daniel Vetter
  2013-06-19  0:53   ` Laurent Pinchart
  2013-06-07 20:09 ` [PATCH 1/4] drm: Print pretty names for pixel formats Dave Airlie
  3 siblings, 2 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-07 15:43 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The structures and strings involved with various pretty-print functions
aren't meant to be modified, so make them all const. The exception is
drm_connector_enum_list which does get modified in drm_connector_init().

While at it move the drm_get_connector_status_name() prototype from
drmP.h to drm_crtc.h where it belongs.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 30 +++++++++++++++---------------
 include/drm/drmP.h         |  1 -
 include/drm/drm_crtc.h     | 17 +++++++++--------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 079996a..44c3421 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
 
 /* Avoid boilerplate.  I'm tired of typing. */
 #define DRM_ENUM_NAME_FN(fnname, list)				\
-	char *fnname(int val)					\
+	const char *fnname(int val)				\
 	{							\
 		int i;						\
 		for (i = 0; i < ARRAY_SIZE(list); i++) {	\
@@ -105,7 +105,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
 /*
  * Global properties
  */
-static struct drm_prop_enum_list drm_dpms_enum_list[] =
+static const struct drm_prop_enum_list drm_dpms_enum_list[] =
 {	{ DRM_MODE_DPMS_ON, "On" },
 	{ DRM_MODE_DPMS_STANDBY, "Standby" },
 	{ DRM_MODE_DPMS_SUSPEND, "Suspend" },
@@ -117,7 +117,7 @@ DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
 /*
  * Optional properties
  */
-static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
+static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
 {
 	{ DRM_MODE_SCALE_NONE, "None" },
 	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
@@ -125,7 +125,7 @@ static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
 	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
 };
 
-static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
+static const struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
 {
 	{ DRM_MODE_DITHERING_OFF, "Off" },
 	{ DRM_MODE_DITHERING_ON, "On" },
@@ -135,7 +135,7 @@ static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
 /*
  * Non-global properties, but "required" for certain connectors.
  */
-static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
+static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
 {
 	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
 	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
@@ -144,7 +144,7 @@ static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
 
 DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
 
-static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
+static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
 {
 	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
 	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
@@ -154,7 +154,7 @@ static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
 DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
 		 drm_dvi_i_subconnector_enum_list)
 
-static struct drm_prop_enum_list drm_tv_select_enum_list[] =
+static const struct drm_prop_enum_list drm_tv_select_enum_list[] =
 {
 	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
 	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
@@ -165,7 +165,7 @@ static struct drm_prop_enum_list drm_tv_select_enum_list[] =
 
 DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
 
-static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
+static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
 {
 	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
 	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
@@ -177,7 +177,7 @@ static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
 DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
 		 drm_tv_subconnector_enum_list)
 
-static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
+static const struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
 	{ DRM_MODE_DIRTY_OFF,      "Off"      },
 	{ DRM_MODE_DIRTY_ON,       "On"       },
 	{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" },
@@ -185,7 +185,7 @@ static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
 
 struct drm_conn_prop_enum_list {
 	int type;
-	char *name;
+	const char *name;
 	int count;
 };
 
@@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
 	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0},
 };
 
-static struct drm_prop_enum_list drm_encoder_enum_list[] =
+static const struct drm_prop_enum_list drm_encoder_enum_list[] =
 {	{ DRM_MODE_ENCODER_NONE, "None" },
 	{ DRM_MODE_ENCODER_DAC, "DAC" },
 	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
@@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[] =
 	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
 };
 
-char *drm_get_encoder_name(struct drm_encoder *encoder)
+const char *drm_get_encoder_name(const struct drm_encoder *encoder)
 {
 	static char buf[32];
 
@@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder)
 }
 EXPORT_SYMBOL(drm_get_encoder_name);
 
-char *drm_get_connector_name(struct drm_connector *connector)
+const char *drm_get_connector_name(const struct drm_connector *connector)
 {
 	static char buf[32];
 
@@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector *connector)
 }
 EXPORT_SYMBOL(drm_get_connector_name);
 
-char *drm_get_connector_status_name(enum drm_connector_status status)
+const char *drm_get_connector_status_name(enum drm_connector_status status)
 {
 	if (status == connector_status_connected)
 		return "connected";
@@ -258,7 +258,7 @@ static char printable_char(int c)
 	return isascii(c) && isprint(c) ? c : '?';
 }
 
-char *drm_get_format_name(uint32_t format)
+const char *drm_get_format_name(uint32_t format)
 {
 	static char buf[32];
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b06f5af..e931a65 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1598,7 +1598,6 @@ extern void drm_sysfs_destroy(void);
 extern int drm_sysfs_device_add(struct drm_minor *minor);
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 extern void drm_sysfs_device_remove(struct drm_minor *minor);
-extern char *drm_get_connector_status_name(enum drm_connector_status status);
 extern int drm_sysfs_connector_add(struct drm_connector *connector);
 extern void drm_sysfs_connector_remove(struct drm_connector *connector);
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 2cbbfd4..53c33e2 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane *plane);
 
 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
 
-extern char *drm_get_connector_name(struct drm_connector *connector);
-extern char *drm_get_dpms_name(int val);
-extern char *drm_get_dvi_i_subconnector_name(int val);
-extern char *drm_get_dvi_i_select_name(int val);
-extern char *drm_get_tv_subconnector_name(int val);
-extern char *drm_get_tv_select_name(int val);
+extern const char *drm_get_connector_name(const struct drm_connector *connector);
+extern const char *drm_get_connector_status_name(enum drm_connector_status status);
+extern const char *drm_get_dpms_name(int val);
+extern const char *drm_get_dvi_i_subconnector_name(int val);
+extern const char *drm_get_dvi_i_select_name(int val);
+extern const char *drm_get_tv_subconnector_name(int val);
+extern const char *drm_get_tv_select_name(int val);
 extern void drm_fb_release(struct drm_file *file_priv);
 extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
 extern bool drm_probe_ddc(struct i2c_adapter *adapter);
@@ -994,7 +995,7 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 extern int drm_mode_create_dithering_property(struct drm_device *dev);
 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
-extern char *drm_get_encoder_name(struct drm_encoder *encoder);
+extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
 
 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
 					     struct drm_encoder *encoder);
@@ -1094,6 +1095,6 @@ extern int drm_format_num_planes(uint32_t format);
 extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
-extern char *drm_get_format_name(uint32_t format);
+extern const char *drm_get_format_name(uint32_t format);
 
 #endif /* __DRM_CRTC_H__ */
-- 
1.8.1.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] drm: Constify the pretty-print functions
  2013-06-07 15:43 ` [PATCH 4/4] drm: Constify the pretty-print functions ville.syrjala
@ 2013-06-07 16:03   ` Daniel Vetter
  2013-06-19  0:53   ` Laurent Pinchart
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2013-06-07 16:03 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, dri-devel

On Fri, Jun 07, 2013 at 06:43:07PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The structures and strings involved with various pretty-print functions
> aren't meant to be modified, so make them all const. The exception is
> drm_connector_enum_list which does get modified in drm_connector_init().
> 
> While at it move the drm_get_connector_status_name() prototype from
> drmP.h to drm_crtc.h where it belongs.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Looks good to me, and probably simplest if we merge everything (including
drm/i915 parts) through drm-next. On the series:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_crtc.c | 30 +++++++++++++++---------------
>  include/drm/drmP.h         |  1 -
>  include/drm/drm_crtc.h     | 17 +++++++++--------
>  3 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 079996a..44c3421 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -92,7 +92,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
>  
>  /* Avoid boilerplate.  I'm tired of typing. */
>  #define DRM_ENUM_NAME_FN(fnname, list)				\
> -	char *fnname(int val)					\
> +	const char *fnname(int val)				\
>  	{							\
>  		int i;						\
>  		for (i = 0; i < ARRAY_SIZE(list); i++) {	\
> @@ -105,7 +105,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
>  /*
>   * Global properties
>   */
> -static struct drm_prop_enum_list drm_dpms_enum_list[] =
> +static const struct drm_prop_enum_list drm_dpms_enum_list[] =
>  {	{ DRM_MODE_DPMS_ON, "On" },
>  	{ DRM_MODE_DPMS_STANDBY, "Standby" },
>  	{ DRM_MODE_DPMS_SUSPEND, "Suspend" },
> @@ -117,7 +117,7 @@ DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
>  /*
>   * Optional properties
>   */
> -static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
>  {
>  	{ DRM_MODE_SCALE_NONE, "None" },
>  	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
> @@ -125,7 +125,7 @@ static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
>  	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
>  };
>  
> -static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
>  {
>  	{ DRM_MODE_DITHERING_OFF, "Off" },
>  	{ DRM_MODE_DITHERING_ON, "On" },
> @@ -135,7 +135,7 @@ static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
>  /*
>   * Non-global properties, but "required" for certain connectors.
>   */
> -static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -144,7 +144,7 @@ static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
>  
>  DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
>  
> -static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -154,7 +154,7 @@ static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
>  DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
>  		 drm_dvi_i_subconnector_enum_list)
>  
> -static struct drm_prop_enum_list drm_tv_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -165,7 +165,7 @@ static struct drm_prop_enum_list drm_tv_select_enum_list[] =
>  
>  DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
>  
> -static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -177,7 +177,7 @@ static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
>  DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
>  		 drm_tv_subconnector_enum_list)
>  
> -static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
> +static const struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
>  	{ DRM_MODE_DIRTY_OFF,      "Off"      },
>  	{ DRM_MODE_DIRTY_ON,       "On"       },
>  	{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" },
> @@ -185,7 +185,7 @@ static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
>  
>  struct drm_conn_prop_enum_list {
>  	int type;
> -	char *name;
> +	const char *name;
>  	int count;
>  };
>  
> @@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
>  	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0},
>  };
>  
> -static struct drm_prop_enum_list drm_encoder_enum_list[] =
> +static const struct drm_prop_enum_list drm_encoder_enum_list[] =
>  {	{ DRM_MODE_ENCODER_NONE, "None" },
>  	{ DRM_MODE_ENCODER_DAC, "DAC" },
>  	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
> @@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[] =
>  	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
>  };
>  
> -char *drm_get_encoder_name(struct drm_encoder *encoder)
> +const char *drm_get_encoder_name(const struct drm_encoder *encoder)
>  {
>  	static char buf[32];
>  
> @@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder)
>  }
>  EXPORT_SYMBOL(drm_get_encoder_name);
>  
> -char *drm_get_connector_name(struct drm_connector *connector)
> +const char *drm_get_connector_name(const struct drm_connector *connector)
>  {
>  	static char buf[32];
>  
> @@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector *connector)
>  }
>  EXPORT_SYMBOL(drm_get_connector_name);
>  
> -char *drm_get_connector_status_name(enum drm_connector_status status)
> +const char *drm_get_connector_status_name(enum drm_connector_status status)
>  {
>  	if (status == connector_status_connected)
>  		return "connected";
> @@ -258,7 +258,7 @@ static char printable_char(int c)
>  	return isascii(c) && isprint(c) ? c : '?';
>  }
>  
> -char *drm_get_format_name(uint32_t format)
> +const char *drm_get_format_name(uint32_t format)
>  {
>  	static char buf[32];
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index b06f5af..e931a65 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1598,7 +1598,6 @@ extern void drm_sysfs_destroy(void);
>  extern int drm_sysfs_device_add(struct drm_minor *minor);
>  extern void drm_sysfs_hotplug_event(struct drm_device *dev);
>  extern void drm_sysfs_device_remove(struct drm_minor *minor);
> -extern char *drm_get_connector_status_name(enum drm_connector_status status);
>  extern int drm_sysfs_connector_add(struct drm_connector *connector);
>  extern void drm_sysfs_connector_remove(struct drm_connector *connector);
>  
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 2cbbfd4..53c33e2 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane *plane);
>  
>  extern void drm_encoder_cleanup(struct drm_encoder *encoder);
>  
> -extern char *drm_get_connector_name(struct drm_connector *connector);
> -extern char *drm_get_dpms_name(int val);
> -extern char *drm_get_dvi_i_subconnector_name(int val);
> -extern char *drm_get_dvi_i_select_name(int val);
> -extern char *drm_get_tv_subconnector_name(int val);
> -extern char *drm_get_tv_select_name(int val);
> +extern const char *drm_get_connector_name(const struct drm_connector *connector);
> +extern const char *drm_get_connector_status_name(enum drm_connector_status status);
> +extern const char *drm_get_dpms_name(int val);
> +extern const char *drm_get_dvi_i_subconnector_name(int val);
> +extern const char *drm_get_dvi_i_select_name(int val);
> +extern const char *drm_get_tv_subconnector_name(int val);
> +extern const char *drm_get_tv_select_name(int val);
>  extern void drm_fb_release(struct drm_file *file_priv);
>  extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
>  extern bool drm_probe_ddc(struct i2c_adapter *adapter);
> @@ -994,7 +995,7 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  extern int drm_mode_create_dithering_property(struct drm_device *dev);
>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
> -extern char *drm_get_encoder_name(struct drm_encoder *encoder);
> +extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
>  
>  extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
>  					     struct drm_encoder *encoder);
> @@ -1094,6 +1095,6 @@ extern int drm_format_num_planes(uint32_t format);
>  extern int drm_format_plane_cpp(uint32_t format, int plane);
>  extern int drm_format_horz_chroma_subsampling(uint32_t format);
>  extern int drm_format_vert_chroma_subsampling(uint32_t format);
> -extern char *drm_get_format_name(uint32_t format);
> +extern const char *drm_get_format_name(uint32_t format);
>  
>  #endif /* __DRM_CRTC_H__ */
> -- 
> 1.8.1.5
> 
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] drm: Print pretty names for pixel formats
  2013-06-07 15:43 [PATCH 1/4] drm: Print pretty names for pixel formats ville.syrjala
                   ` (2 preceding siblings ...)
  2013-06-07 15:43 ` [PATCH 4/4] drm: Constify the pretty-print functions ville.syrjala
@ 2013-06-07 20:09 ` Dave Airlie
  2013-06-07 20:35   ` Ville Syrjälä
  3 siblings, 1 reply; 14+ messages in thread
From: Dave Airlie @ 2013-06-07 20:09 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, dri-devel

On Sat, Jun 8, 2013 at 1:43 AM,  <ville.syrjala@linux.intel.com> wrote:
> From: Foo Bar <foo@bar.com>

^ ??

git config error?

Dave.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] drm: Print pretty names for pixel formats
  2013-06-07 20:09 ` [PATCH 1/4] drm: Print pretty names for pixel formats Dave Airlie
@ 2013-06-07 20:35   ` Ville Syrjälä
  2013-06-07 21:33     ` Dave Airlie
  0 siblings, 1 reply; 14+ messages in thread
From: Ville Syrjälä @ 2013-06-07 20:35 UTC (permalink / raw)
  To: Dave Airlie; +Cc: intel-gfx, dri-devel

On Sat, Jun 08, 2013 at 06:09:42AM +1000, Dave Airlie wrote:
> On Sat, Jun 8, 2013 at 1:43 AM,  <ville.syrjala@linux.intel.com> wrote:
> > From: Foo Bar <foo@bar.com>
> 
> ^ ??
> 
> git config error?

Whoops. Sorry about that. I created the original patch on a test
machine where I apparently had been too lazy to set up my git
correctly. And then I used suppress-cc=author to avoid spamming
myself too much, so I didn't notice it when sending the mail.

Do you want a fixed patch, or will you take care of it on your end?

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] drm: Print pretty names for pixel formats
  2013-06-07 20:35   ` Ville Syrjälä
@ 2013-06-07 21:33     ` Dave Airlie
  2013-06-10  8:15       ` [PATCH v2] " ville.syrjala
  0 siblings, 1 reply; 14+ messages in thread
From: Dave Airlie @ 2013-06-07 21:33 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

On Sat, Jun 8, 2013 at 6:35 AM, Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
> On Sat, Jun 08, 2013 at 06:09:42AM +1000, Dave Airlie wrote:
>> On Sat, Jun 8, 2013 at 1:43 AM,  <ville.syrjala@linux.intel.com> wrote:
>> > From: Foo Bar <foo@bar.com>
>>
>> ^ ??
>>
>> git config error?
>
> Whoops. Sorry about that. I created the original patch on a test
> machine where I apparently had been too lazy to set up my git
> correctly. And then I used suppress-cc=author to avoid spamming
> myself too much, so I didn't notice it when sending the mail.
>
> Do you want a fixed patch, or will you take care of it on your end?

can you resend that one, otherwise i'll probably forget when I pick it up :-)

Dave.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] drm: Print pretty names for pixel formats
  2013-06-07 21:33     ` Dave Airlie
@ 2013-06-10  8:15       ` ville.syrjala
  0 siblings, 0 replies; 14+ messages in thread
From: ville.syrjala @ 2013-06-10  8:15 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Rather than just printing the pixel format as a hex number, decode the
fourcc into human readable form, and also decode the LE vs. BE flag.

Keep printing the raw hex number too in case it contains non-printable
characters.

Some examples what the new drm_get_format_name() produces:
DRM_FORMAT_XRGB8888: "XR24 little-endian (0x34325258)"
DRM_FORMAT_YUYV: "YUYV little-endian (0x56595559)"
DRM_FORMAT_RGB565|DRM_FORMAT_BIG_ENDIAN: "RG16 big-endian (0xb6314752)"
Unprintable characters: "D??? big-endian (0xff7f0244)"

v2: Fix patch author

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 29 +++++++++++++++++++++++++++--
 include/drm/drm_crtc.h     |  1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e7e9242..079996a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -29,6 +29,7 @@
  *      Dave Airlie <airlied@linux.ie>
  *      Jesse Barnes <jesse.barnes@intel.com>
  */
+#include <linux/ctype.h>
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/export.h>
@@ -252,6 +253,28 @@ char *drm_get_connector_status_name(enum drm_connector_status status)
 }
 EXPORT_SYMBOL(drm_get_connector_status_name);
 
+static char printable_char(int c)
+{
+	return isascii(c) && isprint(c) ? c : '?';
+}
+
+char *drm_get_format_name(uint32_t format)
+{
+	static char buf[32];
+
+	snprintf(buf, sizeof(buf),
+		 "%c%c%c%c %s-endian (0x%08x)",
+		 printable_char(format & 0xff),
+		 printable_char((format >> 8) & 0xff),
+		 printable_char((format >> 16) & 0xff),
+		 printable_char((format >> 24) & 0x7f),
+		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
+		 format);
+
+	return buf;
+}
+EXPORT_SYMBOL(drm_get_format_name);
+
 /**
  * drm_mode_object_get - allocate a new modeset identifier
  * @dev: DRM device
@@ -1834,7 +1857,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 		if (fb->pixel_format == plane->format_types[i])
 			break;
 	if (i == plane->format_count) {
-		DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", fb->pixel_format);
+		DRM_DEBUG_KMS("Invalid pixel format %s\n",
+			      drm_get_format_name(fb->pixel_format));
 		ret = -EINVAL;
 		goto out;
 	}
@@ -2312,7 +2336,8 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
 
 	ret = format_check(r);
 	if (ret) {
-		DRM_DEBUG_KMS("bad framebuffer format 0x%08x\n", r->pixel_format);
+		DRM_DEBUG_KMS("bad framebuffer format %s\n",
+			      drm_get_format_name(r->pixel_format));
 		return ret;
 	}
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index adb3f9b..2cbbfd4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1094,5 +1094,6 @@ extern int drm_format_num_planes(uint32_t format);
 extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
+extern char *drm_get_format_name(uint32_t format);
 
 #endif /* __DRM_CRTC_H__ */
-- 
1.8.1.5

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] fb: Make fb_get_options() 'name' parameter const
  2013-06-07 15:43   ` ville.syrjala
@ 2013-06-10 14:22     ` Jean-Christophe PLAGNIOL-VILLARD
  -1 siblings, 0 replies; 14+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-06-10 14:22 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Tomi Valkeinen, linux-fbdev, dri-devel

On 18:43 Fri 07 Jun     , ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The string isn't modified so make it const.
> 
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: linux-fbdev@vger.kernel.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Applied

Best Regards,
J.
> ---
>  drivers/video/fbmem.c | 2 +-
>  include/linux/fb.h    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 098bfc6..d8d5779 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1881,7 +1881,7 @@ static int ofonly __read_mostly;
>   *
>   * NOTE: Needed to maintain backwards compatibility
>   */
> -int fb_get_options(char *name, char **option)
> +int fb_get_options(const char *name, char **option)
>  {
>  	char *opt, *options = NULL;
>  	int retval = 0;
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index d49c60f..ffac70a 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -624,7 +624,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3
>  extern void fb_set_suspend(struct fb_info *info, int state);
>  extern int fb_get_color_depth(struct fb_var_screeninfo *var,
>  			      struct fb_fix_screeninfo *fix);
> -extern int fb_get_options(char *name, char **option);
> +extern int fb_get_options(const char *name, char **option);
>  extern int fb_new_modelist(struct fb_info *info);
>  
>  extern struct fb_info *registered_fb[FB_MAX];
> -- 
> 1.8.1.5
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] fb: Make fb_get_options() 'name' parameter const
@ 2013-06-10 14:22     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 14+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-06-10 14:22 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, Tomi Valkeinen, linux-fbdev, dri-devel

On 18:43 Fri 07 Jun     , ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The string isn't modified so make it const.
> 
> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: linux-fbdev@vger.kernel.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Applied

Best Regards,
J.
> ---
>  drivers/video/fbmem.c | 2 +-
>  include/linux/fb.h    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 098bfc6..d8d5779 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1881,7 +1881,7 @@ static int ofonly __read_mostly;
>   *
>   * NOTE: Needed to maintain backwards compatibility
>   */
> -int fb_get_options(char *name, char **option)
> +int fb_get_options(const char *name, char **option)
>  {
>  	char *opt, *options = NULL;
>  	int retval = 0;
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index d49c60f..ffac70a 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -624,7 +624,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3
>  extern void fb_set_suspend(struct fb_info *info, int state);
>  extern int fb_get_color_depth(struct fb_var_screeninfo *var,
>  			      struct fb_fix_screeninfo *fix);
> -extern int fb_get_options(char *name, char **option);
> +extern int fb_get_options(const char *name, char **option);
>  extern int fb_new_modelist(struct fb_info *info);
>  
>  extern struct fb_info *registered_fb[FB_MAX];
> -- 
> 1.8.1.5
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] drm: Constify the pretty-print functions
  2013-06-07 15:43 ` [PATCH 4/4] drm: Constify the pretty-print functions ville.syrjala
  2013-06-07 16:03   ` Daniel Vetter
@ 2013-06-19  0:53   ` Laurent Pinchart
  2013-06-19  1:36     ` Dave Airlie
  1 sibling, 1 reply; 14+ messages in thread
From: Laurent Pinchart @ 2013-06-19  0:53 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Hi Ville,

On Friday 07 June 2013 18:43:07 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The structures and strings involved with various pretty-print functions
> aren't meant to be modified, so make them all const. The exception is
> drm_connector_enum_list which does get modified in drm_connector_init().
> 
> While at it move the drm_get_connector_status_name() prototype from
> drmP.h to drm_crtc.h where it belongs.

This breaks compilation on drm-next:

drivers/gpu/drm/drm_fb_helper.c: In function 
‘drm_fb_helper_parse_command_line’:
drivers/gpu/drm/drm_fb_helper.c:127:3: warning: passing argument 1 of 
‘fb_get_options’ discards ‘const’ qualifier from pointer target type [enabled 
by default]
In file included from drivers/gpu/drm/drm_fb_helper.c:35:0:
include/linux/fb.h:627:12: note: expected ‘char *’ but argument is of type 
‘const char 

> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 30 +++++++++++++++---------------
>  include/drm/drmP.h         |  1 -
>  include/drm/drm_crtc.h     | 17 +++++++++--------
>  3 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 079996a..44c3421 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -92,7 +92,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
> 
>  /* Avoid boilerplate.  I'm tired of typing. */
>  #define DRM_ENUM_NAME_FN(fnname, list)				\
> -	char *fnname(int val)					\
> +	const char *fnname(int val)				\
>  	{							\
>  		int i;						\
>  		for (i = 0; i < ARRAY_SIZE(list); i++) {	\
> @@ -105,7 +105,7 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
>  /*
>   * Global properties
>   */
> -static struct drm_prop_enum_list drm_dpms_enum_list[] =
> +static const struct drm_prop_enum_list drm_dpms_enum_list[] =
>  {	{ DRM_MODE_DPMS_ON, "On" },
>  	{ DRM_MODE_DPMS_STANDBY, "Standby" },
>  	{ DRM_MODE_DPMS_SUSPEND, "Suspend" },
> @@ -117,7 +117,7 @@ DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
>  /*
>   * Optional properties
>   */
> -static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
>  {
>  	{ DRM_MODE_SCALE_NONE, "None" },
>  	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
> @@ -125,7 +125,7 @@ static struct drm_prop_enum_list
> drm_scaling_mode_enum_list[] = { DRM_MODE_SCALE_ASPECT, "Full aspect" },
>  };
> 
> -static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
> +static const struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
>  {
>  	{ DRM_MODE_DITHERING_OFF, "Off" },
>  	{ DRM_MODE_DITHERING_ON, "On" },
> @@ -135,7 +135,7 @@ static struct drm_prop_enum_list
> drm_dithering_mode_enum_list[] = /*
>   * Non-global properties, but "required" for certain connectors.
>   */
> -static struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -144,7 +144,7 @@ static struct drm_prop_enum_list
> drm_dvi_i_select_enum_list[] =
> 
>  DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
> 
> -static struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
> {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_DVID,      "DVI-D"     }, /* DVI-I  */
> @@ -154,7 +154,7 @@ static struct drm_prop_enum_list
> drm_dvi_i_subconnector_enum_list[] =
> DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
>  		 drm_dvi_i_subconnector_enum_list)
> 
> -static struct drm_prop_enum_list drm_tv_select_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_select_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -165,7 +165,7 @@ static struct drm_prop_enum_list
> drm_tv_select_enum_list[] =
> 
>  DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
> 
> -static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
> +static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
>  {
>  	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
>  	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
> @@ -177,7 +177,7 @@ static struct drm_prop_enum_list
> drm_tv_subconnector_enum_list[] =
> DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
>  		 drm_tv_subconnector_enum_list)
> 
> -static struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
> +static const struct drm_prop_enum_list drm_dirty_info_enum_list[] = {
>  	{ DRM_MODE_DIRTY_OFF,      "Off"      },
>  	{ DRM_MODE_DIRTY_ON,       "On"       },
>  	{ DRM_MODE_DIRTY_ANNOTATE, "Annotate" },
> @@ -185,7 +185,7 @@ static struct drm_prop_enum_list
> drm_dirty_info_enum_list[] = {
> 
>  struct drm_conn_prop_enum_list {
>  	int type;
> -	char *name;
> +	const char *name;
>  	int count;
>  };
> 
> @@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list
> drm_connector_enum_list[] = { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0},
>  };
> 
> -static struct drm_prop_enum_list drm_encoder_enum_list[] =
> +static const struct drm_prop_enum_list drm_encoder_enum_list[] =
>  {	{ DRM_MODE_ENCODER_NONE, "None" },
>  	{ DRM_MODE_ENCODER_DAC, "DAC" },
>  	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
> @@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[]
> = { DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
>  };
> 
> -char *drm_get_encoder_name(struct drm_encoder *encoder)
> +const char *drm_get_encoder_name(const struct drm_encoder *encoder)
>  {
>  	static char buf[32];
> 
> @@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder)
>  }
>  EXPORT_SYMBOL(drm_get_encoder_name);
> 
> -char *drm_get_connector_name(struct drm_connector *connector)
> +const char *drm_get_connector_name(const struct drm_connector *connector)
>  {
>  	static char buf[32];
> 
> @@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector
> *connector) }
>  EXPORT_SYMBOL(drm_get_connector_name);
> 
> -char *drm_get_connector_status_name(enum drm_connector_status status)
> +const char *drm_get_connector_status_name(enum drm_connector_status status)
> {
>  	if (status == connector_status_connected)
>  		return "connected";
> @@ -258,7 +258,7 @@ static char printable_char(int c)
>  	return isascii(c) && isprint(c) ? c : '?';
>  }
> 
> -char *drm_get_format_name(uint32_t format)
> +const char *drm_get_format_name(uint32_t format)
>  {
>  	static char buf[32];
> 
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index b06f5af..e931a65 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1598,7 +1598,6 @@ extern void drm_sysfs_destroy(void);
>  extern int drm_sysfs_device_add(struct drm_minor *minor);
>  extern void drm_sysfs_hotplug_event(struct drm_device *dev);
>  extern void drm_sysfs_device_remove(struct drm_minor *minor);
> -extern char *drm_get_connector_status_name(enum drm_connector_status
> status); extern int drm_sysfs_connector_add(struct drm_connector
> *connector); extern void drm_sysfs_connector_remove(struct drm_connector
> *connector);
> 
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 2cbbfd4..53c33e2 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane
> *plane);
> 
>  extern void drm_encoder_cleanup(struct drm_encoder *encoder);
> 
> -extern char *drm_get_connector_name(struct drm_connector *connector);
> -extern char *drm_get_dpms_name(int val);
> -extern char *drm_get_dvi_i_subconnector_name(int val);
> -extern char *drm_get_dvi_i_select_name(int val);
> -extern char *drm_get_tv_subconnector_name(int val);
> -extern char *drm_get_tv_select_name(int val);
> +extern const char *drm_get_connector_name(const struct drm_connector
> *connector); +extern const char *drm_get_connector_status_name(enum
> drm_connector_status status); +extern const char *drm_get_dpms_name(int
> val);
> +extern const char *drm_get_dvi_i_subconnector_name(int val);
> +extern const char *drm_get_dvi_i_select_name(int val);
> +extern const char *drm_get_tv_subconnector_name(int val);
> +extern const char *drm_get_tv_select_name(int val);
>  extern void drm_fb_release(struct drm_file *file_priv);
>  extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct
> drm_mode_group *group); extern bool drm_probe_ddc(struct i2c_adapter
> *adapter);
> @@ -994,7 +995,7 @@ extern int drm_mode_create_tv_properties(struct
> drm_device *dev, int num_formats extern int
> drm_mode_create_scaling_mode_property(struct drm_device *dev); extern int
> drm_mode_create_dithering_property(struct drm_device *dev); extern int
> drm_mode_create_dirty_info_property(struct drm_device *dev); -extern char
> *drm_get_encoder_name(struct drm_encoder *encoder);
> +extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
> 
>  extern int drm_mode_connector_attach_encoder(struct drm_connector
> *connector, struct drm_encoder *encoder);
> @@ -1094,6 +1095,6 @@ extern int drm_format_num_planes(uint32_t format);
>  extern int drm_format_plane_cpp(uint32_t format, int plane);
>  extern int drm_format_horz_chroma_subsampling(uint32_t format);
>  extern int drm_format_vert_chroma_subsampling(uint32_t format);
> -extern char *drm_get_format_name(uint32_t format);
> +extern const char *drm_get_format_name(uint32_t format);
> 
>  #endif /* __DRM_CRTC_H__ */
-- 
Regards,

Laurent Pinchart

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] drm: Constify the pretty-print functions
  2013-06-19  0:53   ` Laurent Pinchart
@ 2013-06-19  1:36     ` Dave Airlie
  0 siblings, 0 replies; 14+ messages in thread
From: Dave Airlie @ 2013-06-19  1:36 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: intel-gfx, dri-devel

On Wed, Jun 19, 2013 at 10:53 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi Ville,
>
> On Friday 07 June 2013 18:43:07 ville.syrjala@linux.intel.com wrote:
>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>
>> The structures and strings involved with various pretty-print functions
>> aren't meant to be modified, so make them all const. The exception is
>> drm_connector_enum_list which does get modified in drm_connector_init().
>>
>> While at it move the drm_get_connector_status_name() prototype from
>> drmP.h to drm_crtc.h where it belongs.
>
> This breaks compilation on drm-next:
>
> drivers/gpu/drm/drm_fb_helper.c: In function
> ‘drm_fb_helper_parse_command_line’:
> drivers/gpu/drm/drm_fb_helper.c:127:3: warning: passing argument 1 of
> ‘fb_get_options’ discards ‘const’ qualifier from pointer target type [enabled
> by default]
> In file included from drivers/gpu/drm/drm_fb_helper.c:35:0:
> include/linux/fb.h:627:12: note: expected ‘char *’ but argument is of type
> ‘const char

The fix is in the fbdev tree, which appears not to be in -next, fail.

Dave.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-19  1:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-07 15:43 [PATCH 1/4] drm: Print pretty names for pixel formats ville.syrjala
2013-06-07 15:43 ` [PATCH 2/4] drm/i915: " ville.syrjala
2013-06-07 15:43 ` [PATCH 3/4] fb: Make fb_get_options() 'name' parameter const ville.syrjala
2013-06-07 15:43   ` ville.syrjala
2013-06-10 14:22   ` Jean-Christophe PLAGNIOL-VILLARD
2013-06-10 14:22     ` Jean-Christophe PLAGNIOL-VILLARD
2013-06-07 15:43 ` [PATCH 4/4] drm: Constify the pretty-print functions ville.syrjala
2013-06-07 16:03   ` Daniel Vetter
2013-06-19  0:53   ` Laurent Pinchart
2013-06-19  1:36     ` Dave Airlie
2013-06-07 20:09 ` [PATCH 1/4] drm: Print pretty names for pixel formats Dave Airlie
2013-06-07 20:35   ` Ville Syrjälä
2013-06-07 21:33     ` Dave Airlie
2013-06-10  8:15       ` [PATCH v2] " ville.syrjala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.