79cfa56e847f99deae28f8b5a99b1e3b79cf9e20
[openwrt/staging/zorun.git] /
1 From bc4d8c5519c74b9bdf4d35369ba76bac01be8ca2 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Mon, 18 Nov 2019 16:51:25 +0100
4 Subject: [PATCH] drm/modes: parse_cmdline: Accept extras directly
5 after mode combined with options
6
7 Commit cfb0881b8f621b656a9e23b31944a5db94cf5842 upstream.
8
9 Before this commit it was impossible to combine an extra mode argument
10 specified directly after the resolution with an option, e.g.
11 video=HDMI-1:720x480e,rotate=180 would not work, either the "e" to force
12 enable would need to be dropped or the ",rotate=180", otherwise the
13 mode_option would not be accepted.
14
15 This commit fixes this by setting parse_extras to true in this case, so
16 that drm_mode_parse_cmdline_res_mode() parses the extra arguments directly
17 after the resolution.
18
19 Acked-by: Maxime Ripard <mripard@kernel.org>
20 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
21 Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-4-hdegoede@redhat.com
22 ---
23 drivers/gpu/drm/drm_modes.c | 1 +
24 .../gpu/drm/selftests/drm_cmdline_selftests.h | 1 +
25 .../drm/selftests/test-drm_cmdline_parser.c | 24 +++++++++++++++++++
26 3 files changed, 26 insertions(+)
27
28 --- a/drivers/gpu/drm/drm_modes.c
29 +++ b/drivers/gpu/drm/drm_modes.c
30 @@ -1794,6 +1794,7 @@ bool drm_mode_parse_command_line_for_con
31 mode_end = refresh_off;
32 } else if (options_ptr) {
33 mode_end = options_off;
34 + parse_extras = true;
35 } else {
36 mode_end = strlen(name);
37 parse_extras = true;
38 --- a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
39 +++ b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
40 @@ -61,3 +61,4 @@ cmdline_test(drm_cmdline_test_margin_opt
41 cmdline_test(drm_cmdline_test_multiple_options)
42 cmdline_test(drm_cmdline_test_invalid_option)
43 cmdline_test(drm_cmdline_test_bpp_extra_and_option)
44 +cmdline_test(drm_cmdline_test_extra_and_option)
45 --- a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
46 +++ b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
47 @@ -1018,6 +1018,30 @@ static int drm_cmdline_test_bpp_extra_an
48 return 0;
49 }
50
51 +static int drm_cmdline_test_extra_and_option(void *ignored)
52 +{
53 + struct drm_cmdline_mode mode = { };
54 +
55 + FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480e,rotate=180",
56 + &no_connector,
57 + &mode));
58 + FAIL_ON(!mode.specified);
59 + FAIL_ON(mode.xres != 720);
60 + FAIL_ON(mode.yres != 480);
61 + FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180);
62 +
63 + FAIL_ON(mode.refresh_specified);
64 + FAIL_ON(mode.bpp_specified);
65 +
66 + FAIL_ON(mode.rb);
67 + FAIL_ON(mode.cvt);
68 + FAIL_ON(mode.interlace);
69 + FAIL_ON(mode.margins);
70 + FAIL_ON(mode.force != DRM_FORCE_ON);
71 +
72 + return 0;
73 +}
74 +
75 #include "drm_selftest.c"
76
77 static int __init test_drm_cmdline_init(void)