kernel: bump 4.19 to 4.19.96
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0642-drm-modes-Support-modes-names-on-the-command-line.patch
1 From 2cea4924c69b6be5cfe8d976810ccf76a3991230 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime.ripard@bootlin.com>
3 Date: Wed, 19 Jun 2019 12:17:50 +0200
4 Subject: [PATCH] drm/modes: Support modes names on the command line
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 commit 3aeeb13d899627fe2b86bdbdcd0927cf7192234f upstream.
10 Minor conflict resolution as upstream has moved functions
11 from drm_fb_helper.c to a new drm_client_modeset.c
12
13 The drm subsystem also uses the video= kernel parameter, and in the
14 documentation refers to the fbdev documentation for that parameter.
15
16 However, that documentation also says that instead of giving the mode using
17 its resolution we can also give a name. However, DRM doesn't handle that
18 case at the moment. Even though in most case it shouldn't make any
19 difference, it might be useful for analog modes, where different standards
20 might have the same resolution, but still have a few different parameters
21 that are not encoded in the modes (NTSC vs NTSC-J vs PAL-M for example).
22
23 Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
24 Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
25 Link: https://patchwork.freedesktop.org/patch/msgid/18443e0c3bdbbd16cea4ec63bc7f2079b820b43b.1560783090.git-series.maxime.ripard@bootlin.com
26 ---
27 drivers/gpu/drm/drm_connector.c | 3 +-
28 drivers/gpu/drm/drm_fb_helper.c | 4 +++
29 drivers/gpu/drm/drm_modes.c | 62 ++++++++++++++++++++++++---------
30 include/drm/drm_connector.h | 7 ++++
31 4 files changed, 59 insertions(+), 17 deletions(-)
32
33 --- a/drivers/gpu/drm/drm_connector.c
34 +++ b/drivers/gpu/drm/drm_connector.c
35 @@ -135,8 +135,9 @@ static void drm_connector_get_cmdline_mo
36 connector->force = mode->force;
37 }
38
39 - DRM_DEBUG_KMS("cmdline mode for connector %s %dx%d@%dHz%s%s%s\n",
40 + DRM_DEBUG_KMS("cmdline mode for connector %s %s %dx%d@%dHz%s%s%s\n",
41 connector->name,
42 + mode->name ? mode->name : "",
43 mode->xres, mode->yres,
44 mode->refresh_specified ? mode->refresh : 60,
45 mode->rb ? " reduced blanking" : "",
46 --- a/drivers/gpu/drm/drm_fb_helper.c
47 +++ b/drivers/gpu/drm/drm_fb_helper.c
48 @@ -2104,6 +2104,10 @@ struct drm_display_mode *drm_pick_cmdlin
49 prefer_non_interlace = !cmdline_mode->interlace;
50 again:
51 list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) {
52 + /* Check (optional) mode name first */
53 + if (!strcmp(mode->name, cmdline_mode->name))
54 + return mode;
55 +
56 /* check width/height */
57 if (mode->hdisplay != cmdline_mode->xres ||
58 mode->vdisplay != cmdline_mode->yres)
59 --- a/drivers/gpu/drm/drm_modes.c
60 +++ b/drivers/gpu/drm/drm_modes.c
61 @@ -1586,7 +1586,7 @@ bool drm_mode_parse_command_line_for_con
62 struct drm_cmdline_mode *mode)
63 {
64 const char *name;
65 - bool parse_extras = false;
66 + bool named_mode = false, parse_extras = false;
67 unsigned int bpp_off = 0, refresh_off = 0;
68 unsigned int mode_end = 0;
69 char *bpp_ptr = NULL, *refresh_ptr = NULL, *extra_ptr = NULL;
70 @@ -1605,8 +1605,22 @@ bool drm_mode_parse_command_line_for_con
71
72 name = mode_option;
73
74 - if (!isdigit(name[0]))
75 - return false;
76 + /*
77 + * This is a bit convoluted. To differentiate between the
78 + * named modes and poorly formatted resolutions, we need a
79 + * bunch of things:
80 + * - We need to make sure that the first character (which
81 + * would be our resolution in X) is a digit.
82 + * - However, if the X resolution is missing, then we end up
83 + * with something like x<yres>, with our first character
84 + * being an alpha-numerical character, which would be
85 + * considered a named mode.
86 + *
87 + * If this isn't enough, we should add more heuristics here,
88 + * and matching unit-tests.
89 + */
90 + if (!isdigit(name[0]) && name[0] != 'x')
91 + named_mode = true;
92
93 /* Try to locate the bpp and refresh specifiers, if any */
94 bpp_ptr = strchr(name, '-');
95 @@ -1617,6 +1631,9 @@ bool drm_mode_parse_command_line_for_con
96
97 refresh_ptr = strchr(name, '@');
98 if (refresh_ptr) {
99 + if (named_mode)
100 + return false;
101 +
102 refresh_off = refresh_ptr - name;
103 mode->refresh_specified = true;
104 }
105 @@ -1633,12 +1650,16 @@ bool drm_mode_parse_command_line_for_con
106 parse_extras = true;
107 }
108
109 - ret = drm_mode_parse_cmdline_res_mode(name, mode_end,
110 - parse_extras,
111 - connector,
112 - mode);
113 - if (ret)
114 - return false;
115 + if (named_mode) {
116 + strncpy(mode->name, name, mode_end);
117 + } else {
118 + ret = drm_mode_parse_cmdline_res_mode(name, mode_end,
119 + parse_extras,
120 + connector,
121 + mode);
122 + if (ret)
123 + return false;
124 + }
125 mode->specified = true;
126
127 if (bpp_ptr) {
128 @@ -1666,14 +1687,23 @@ bool drm_mode_parse_command_line_for_con
129 extra_ptr = refresh_end_ptr;
130
131 if (extra_ptr) {
132 - int remaining = strlen(name) - (extra_ptr - name);
133 + if (!named_mode) {
134 + int len = strlen(name) - (extra_ptr - name);
135
136 - /*
137 - * We still have characters to process, while
138 - * we shouldn't have any
139 - */
140 - if (remaining > 0)
141 - return false;
142 + ret = drm_mode_parse_cmdline_extra(extra_ptr, len,
143 + connector, mode);
144 + if (ret)
145 + return false;
146 + } else {
147 + int remaining = strlen(name) - (extra_ptr - name);
148 +
149 + /*
150 + * We still have characters to process, while
151 + * we shouldn't have any
152 + */
153 + if (remaining > 0)
154 + return false;
155 + }
156 }
157
158 return true;
159 --- a/include/drm/drm_connector.h
160 +++ b/include/drm/drm_connector.h
161 @@ -765,6 +765,13 @@ struct drm_connector_funcs {
162 */
163 struct drm_cmdline_mode {
164 /**
165 + * @name:
166 + *
167 + * Name of the mode.
168 + */
169 + char name[DRM_DISPLAY_MODE_LEN];
170 +
171 + /**
172 * @specified:
173 *
174 * Has a mode been read from the command-line?