diff mbox series

[v2,3/4] drm/modes: Add initializer macro DRM_MODE_INIT()

Message ID 20220816134853.12468-4-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/probe-helper, modes: Helpers for single-mode displays | expand

Commit Message

Thomas Zimmermann Aug. 16, 2022, 1:48 p.m. UTC
The macro DRM_MODE_INIT() initializes an instance of
struct drm_display_mode with typical parameters. Convert simpledrm
and also update the macro DRM_SIMPLE_MODE().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/tiny/simpledrm.c | 23 ++++++++-------------
 include/drm/drm_modes.h          | 35 +++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 19 deletions(-)

Comments

kernel test robot Aug. 22, 2022, 1 a.m. UTC | #1
Hi Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on next-20220819]
[cannot apply to linus/master v6.0-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/drm-probe-helper-modes-Helpers-for-single-mode-displays/20220816-215250
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
reproduce:
        # https://github.com/intel-lab-lkp/linux/commit/25770aac56aeff6f55419ea4316406ddbb29385f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Thomas-Zimmermann/drm-probe-helper-modes-Helpers-for-single-mode-displays/20220816-215250
        git checkout 25770aac56aeff6f55419ea4316406ddbb29385f
        make menuconfig
        # enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS, CONFIG_WARN_ABI_ERRORS
        make htmldocs

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> ./include/drm/drm_modes.h:168: warning: expecting prototype for DRM_SIMPLE_MODE_INIT(). Prototype was for DRM_MODE_INIT() instead

vim +168 ./include/drm/drm_modes.h

   133	
   134	#define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
   135		.name = nm, .status = 0, .type = (t), .clock = (c), \
   136		.hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
   137		.htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
   138		.vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
   139		.vscan = (vs), .flags = (f)
   140	
   141	/**
   142	 * DRM_MODE_RES_MM - Calculates the display size from resolution and DPI
   143	 * @res: The resolution in pixel
   144	 * @dpi: The number of dots per inch
   145	 */
   146	#define DRM_MODE_RES_MM(res, dpi)	\
   147		(((res) * 254ul) / ((dpi) * 10ul))
   148	
   149	#define __DRM_MODE_INIT(pix, hd, vd, hd_mm, vd_mm) \
   150		.type = DRM_MODE_TYPE_DRIVER, .clock = (pix), \
   151		.hdisplay = (hd), .hsync_start = (hd), .hsync_end = (hd), \
   152		.htotal = (hd), .vdisplay = (vd), .vsync_start = (vd), \
   153		.vsync_end = (vd), .vtotal = (vd), .width_mm = (hd_mm), \
   154		.height_mm = (vd_mm)
   155	
   156	/**
   157	 * DRM_SIMPLE_MODE_INIT - Initialize display mode
   158	 * @hz: Vertical refresh rate in Hertz
   159	 * @hd: Horizontal resolution, width
   160	 * @vd: Vertical resolution, height
   161	 * @hd_mm: Display width in millimeters
   162	 * @vd_mm: Display height in millimeters
   163	 *
   164	 * This macro initializes a &drm_display_mode that contains information about
   165	 * refresh rate, resolution and physical size.
   166	 */
   167	#define DRM_MODE_INIT(hz, hd, vd, hd_mm, vd_mm) \
 > 168		__DRM_MODE_INIT((hd) * (vd) * (hz) / 1000 /* kHz */, hd, vd, hd_mm, vd_mm)
   169
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
index 5bed4d564104..404290760c60 100644
--- a/drivers/gpu/drm/tiny/simpledrm.c
+++ b/drivers/gpu/drm/tiny/simpledrm.c
@@ -30,16 +30,6 @@ 
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-/*
- * Assume a monitor resolution of 96 dpi to
- * get a somewhat reasonable screen size.
- */
-#define RES_MM(d)	\
-	(((d) * 254ul) / (96ul * 10ul))
-
-#define SIMPLEDRM_MODE(hd, vd)	\
-	DRM_SIMPLE_MODE(hd, vd, RES_MM(hd), RES_MM(vd))
-
 /*
  * Helpers for simplefb
  */
@@ -641,10 +631,15 @@  static const struct drm_mode_config_funcs simpledrm_mode_config_funcs = {
 static struct drm_display_mode simpledrm_mode(unsigned int width,
 					      unsigned int height)
 {
-	struct drm_display_mode mode = { SIMPLEDRM_MODE(width, height) };
-
-	mode.clock = mode.hdisplay * mode.vdisplay * 60 / 1000 /* kHz */;
-	drm_mode_set_name(&mode);
+	/*
+	 * Assume a monitor resolution of 96 dpi to
+	 * get a somewhat reasonable screen size.
+	 */
+	const struct drm_display_mode mode = {
+		DRM_MODE_INIT(60, width, height,
+			      DRM_MODE_RES_MM(width, 96ul),
+			      DRM_MODE_RES_MM(height, 96ul))
+	};
 
 	return mode;
 }
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index a80ae9639e96..bb932806f029 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -138,6 +138,35 @@  enum drm_mode_status {
 	.vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
 	.vscan = (vs), .flags = (f)
 
+/**
+ * DRM_MODE_RES_MM - Calculates the display size from resolution and DPI
+ * @res: The resolution in pixel
+ * @dpi: The number of dots per inch
+ */
+#define DRM_MODE_RES_MM(res, dpi)	\
+	(((res) * 254ul) / ((dpi) * 10ul))
+
+#define __DRM_MODE_INIT(pix, hd, vd, hd_mm, vd_mm) \
+	.type = DRM_MODE_TYPE_DRIVER, .clock = (pix), \
+	.hdisplay = (hd), .hsync_start = (hd), .hsync_end = (hd), \
+	.htotal = (hd), .vdisplay = (vd), .vsync_start = (vd), \
+	.vsync_end = (vd), .vtotal = (vd), .width_mm = (hd_mm), \
+	.height_mm = (vd_mm)
+
+/**
+ * DRM_SIMPLE_MODE_INIT - Initialize display mode
+ * @hz: Vertical refresh rate in Hertz
+ * @hd: Horizontal resolution, width
+ * @vd: Vertical resolution, height
+ * @hd_mm: Display width in millimeters
+ * @vd_mm: Display height in millimeters
+ *
+ * This macro initializes a &drm_display_mode that contains information about
+ * refresh rate, resolution and physical size.
+ */
+#define DRM_MODE_INIT(hz, hd, vd, hd_mm, vd_mm) \
+	__DRM_MODE_INIT((hd) * (vd) * (hz) / 1000 /* kHz */, hd, vd, hd_mm, vd_mm)
+
 /**
  * DRM_SIMPLE_MODE - Simple display mode
  * @hd: Horizontal resolution, width
@@ -149,11 +178,7 @@  enum drm_mode_status {
  * resolution and physical size.
  */
 #define DRM_SIMPLE_MODE(hd, vd, hd_mm, vd_mm) \
-	.type = DRM_MODE_TYPE_DRIVER, .clock = 1 /* pass validation */, \
-	.hdisplay = (hd), .hsync_start = (hd), .hsync_end = (hd), \
-	.htotal = (hd), .vdisplay = (vd), .vsync_start = (vd), \
-	.vsync_end = (vd), .vtotal = (vd), .width_mm = (hd_mm), \
-	.height_mm = (vd_mm)
+	__DRM_MODE_INIT(1 /* pass validation */, hd, vd, hd_mm, vd_mm)
 
 #define CRTC_INTERLACE_HALVE_V	(1 << 0) /* halve V values for interlacing */
 #define CRTC_STEREO_DOUBLE	(1 << 1) /* adjust timings for stereo modes */