[Intel-gfx] [PATCH] drm: Perform cmdline mode parsing during connector initialisation
From: Chris Wilson ch...@chris-wilson.co.uk i915.ko has a custom fbdev initialisation routine that aims to preserve the current mode set by the BIOS, unless overruled by the user. The user's wishes are determined by what, if any, mode is specified on the command line (via the video= parameter). However, that command line mode is first parsed by drm_fb_helper_initial_config() which is called after i915.ko's custom initial_config() as a fallback method. So in order for us to honour it, we need to move the cmdline parser earlier. If we perform the connector cmdline parsing as soon as we initialise the connector, that cmdline mode and forced status is then available even if the fbdev helper is not compiled in or never called. We also then expose the cmdline user mode in the connector mode lists. v2: Rebase after connector-name upheaval. v3: Adapt mga200 to look for the cmdline mode in the new place. Nicely simplifies things while at that. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk (v2) Cc: Jesse Barnes jbar...@virtuousgeek.org Cc: Ville Syrjälä ville.syrj...@linux.intel.com Cc: Daniel Vetter daniel.vet...@ffwll.ch Reviewed-by: Jesse Barnes jbar...@virtuousgeek.org (v2) Cc: dri-de...@lists.freedesktop.org Cc: Julia Lemire jlem...@matrox.com Cc: Dave Airlie airl...@redhat.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch --- drivers/gpu/drm/drm_crtc.c | 55 + drivers/gpu/drm/drm_fb_helper.c| 64 ++ drivers/gpu/drm/drm_modes.c| 1 + drivers/gpu/drm/drm_probe_helper.c | 17 + drivers/gpu/drm/mgag200/mgag200_mode.c | 20 +++ include/drm/drm_crtc.h | 1 + include/drm/drm_fb_helper.h| 1 - 7 files changed, 82 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 3c4a62169f28..d3f1e0033475 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -852,6 +852,59 @@ static void drm_mode_remove(struct drm_connector *connector, } /** + * drm_connector_get_cmdline_mode - reads the user's cmdline mode + * @connector: connector to quwery + * @mode: returned mode + * + * The kernel supports per-connector configration of its consoles through + * use of the video= parameter. This function parses that option and + * extracts the user's specified mode (or enable/disable status) for a + * particular connector. This is typically only used during the early fbdev + * setup. + */ +static void drm_connector_get_cmdline_mode(struct drm_connector *connector) +{ + struct drm_cmdline_mode *mode = connector-cmdline_mode; + char *option = NULL; + + if (fb_get_options(connector-name, option)) + return; + + if (!drm_mode_parse_command_line_for_connector(option, + connector, + mode)) + return; + + if (mode-force) { + const char *s; + + switch (mode-force) { + case DRM_FORCE_OFF: + s = OFF; + break; + case DRM_FORCE_ON_DIGITAL: + s = ON - dig; + break; + default: + case DRM_FORCE_ON: + s = ON; + break; + } + + DRM_INFO(forcing %s connector %s\n, connector-name, s); + connector-force = mode-force; + } + + DRM_DEBUG_KMS(cmdline mode for connector %s %dx%d@%dHz%s%s%s\n, + connector-name, + mode-xres, mode-yres, + mode-refresh_specified ? mode-refresh : 60, + mode-rb ? reduced blanking : , + mode-margins ? with margins : , + mode-interlace ? interlaced : ); +} + +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device * @connector: the connector to init @@ -903,6 +956,8 @@ int drm_connector_init(struct drm_device *dev, connector-edid_blob_ptr = NULL; connector-status = connector_status_unknown; + drm_connector_get_cmdline_mode(connector); + list_add_tail(connector-head, dev-mode_config.connector_list); dev-mode_config.num_connector++; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d139eddb3d61..9a91ee69af2b 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -171,60 +171,6 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, } EXPORT_SYMBOL(drm_fb_helper_remove_one_connector); -static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) -{ - struct drm_fb_helper_connector *fb_helper_conn; - int i; - - for
Re: [Intel-gfx] [PATCH] drm: Perform cmdline mode parsing during connector initialisation
When getting this patch for -collector I noticed it conflicts with mgag200 and break its compilation. On Wed, Jun 11, 2014 at 3:55 AM, Chris Wilson ch...@chris-wilson.co.uk wrote: i915.ko has a custom fbdev initialisation routine that aims to preserve the current mode set by the BIOS, unless overruled by the user. The user's wishes are determined by what, if any, mode is specified on the command line (via the video= parameter). However, that command line mode is first parsed by drm_fb_helper_initial_config() which is called after i915.ko's custom initial_config() as a fallback method. So in order for us to honour it, we need to move the cmdline parser earlier. If we perform the connector cmdline parsing as soon as we initialise the connector, that cmdline mode and forced status is then available even if the fbdev helper is not compiled in or never called. We also then expose the cmdline user mode in the connector mode lists. v2: Rebase after connector-name upheaval. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk Cc: Jesse Barnes jbar...@virtuousgeek.org Cc: Ville Syrjälä ville.syrj...@linux.intel.com Cc: Daniel Vetter daniel.vet...@ffwll.ch Reviewed-by: Jesse Barnes jbar...@virtuousgeek.org Cc: dri-de...@lists.freedesktop.org --- drivers/gpu/drm/drm_crtc.c | 55 drivers/gpu/drm/drm_fb_helper.c| 64 ++ drivers/gpu/drm/drm_modes.c| 1 + drivers/gpu/drm/drm_probe_helper.c | 17 ++ include/drm/drm_crtc.h | 1 + include/drm/drm_fb_helper.h| 1 - 6 files changed, 77 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index fe94cc10cd35..b9de156515b6 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -819,6 +819,59 @@ static void drm_mode_remove(struct drm_connector *connector, } /** + * drm_connector_get_cmdline_mode - reads the user's cmdline mode + * @connector: connector to quwery + * @mode: returned mode + * + * The kernel supports per-connector configration of its consoles through + * use of the video= parameter. This function parses that option and + * extracts the user's specified mode (or enable/disable status) for a + * particular connector. This is typically only used during the early fbdev + * setup. + */ +static void drm_connector_get_cmdline_mode(struct drm_connector *connector) +{ + struct drm_cmdline_mode *mode = connector-cmdline_mode; + char *option = NULL; + + if (fb_get_options(connector-name, option)) + return; + + if (!drm_mode_parse_command_line_for_connector(option, + connector, + mode)) + return; + + if (mode-force) { + const char *s; + + switch (mode-force) { + case DRM_FORCE_OFF: + s = OFF; + break; + case DRM_FORCE_ON_DIGITAL: + s = ON - dig; + break; + default: + case DRM_FORCE_ON: + s = ON; + break; + } + + DRM_INFO(forcing %s connector %s\n, connector-name, s); + connector-force = mode-force; + } + + DRM_DEBUG_KMS(cmdline mode for connector %s %dx%d@%dHz%s%s%s\n, + connector-name, + mode-xres, mode-yres, + mode-refresh_specified ? mode-refresh : 60, + mode-rb ? reduced blanking : , + mode-margins ? with margins : , + mode-interlace ? interlaced : ); +} + +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device * @connector: the connector to init @@ -870,6 +923,8 @@ int drm_connector_init(struct drm_device *dev, connector-edid_blob_ptr = NULL; connector-status = connector_status_unknown; + drm_connector_get_cmdline_mode(connector); + list_add_tail(connector-head, dev-mode_config.connector_list); dev-mode_config.num_connector++; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d5d8cea1a679..18988dc3de91 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -105,60 +105,6 @@ fail: } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); -static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) -{ - struct drm_fb_helper_connector *fb_helper_conn; - int i; - - for (i = 0; i fb_helper-connector_count; i++) { - struct drm_cmdline_mode *mode; - struct
[Intel-gfx] [PATCH] drm: Perform cmdline mode parsing during connector initialisation
i915.ko has a custom fbdev initialisation routine that aims to preserve the current mode set by the BIOS, unless overruled by the user. The user's wishes are determined by what, if any, mode is specified on the command line (via the video= parameter). However, that command line mode is first parsed by drm_fb_helper_initial_config() which is called after i915.ko's custom initial_config() as a fallback method. So in order for us to honour it, we need to move the cmdline parser earlier. If we perform the connector cmdline parsing as soon as we initialise the connector, that cmdline mode and forced status is then available even if the fbdev helper is not compiled in or never called. We also then expose the cmdline user mode in the connector mode lists. v2: Rebase after connector-name upheaval. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk Cc: Jesse Barnes jbar...@virtuousgeek.org Cc: Ville Syrjälä ville.syrj...@linux.intel.com Cc: Daniel Vetter daniel.vet...@ffwll.ch Reviewed-by: Jesse Barnes jbar...@virtuousgeek.org Cc: dri-de...@lists.freedesktop.org --- drivers/gpu/drm/drm_crtc.c | 55 drivers/gpu/drm/drm_fb_helper.c| 64 ++ drivers/gpu/drm/drm_modes.c| 1 + drivers/gpu/drm/drm_probe_helper.c | 17 ++ include/drm/drm_crtc.h | 1 + include/drm/drm_fb_helper.h| 1 - 6 files changed, 77 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index fe94cc10cd35..b9de156515b6 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -819,6 +819,59 @@ static void drm_mode_remove(struct drm_connector *connector, } /** + * drm_connector_get_cmdline_mode - reads the user's cmdline mode + * @connector: connector to quwery + * @mode: returned mode + * + * The kernel supports per-connector configration of its consoles through + * use of the video= parameter. This function parses that option and + * extracts the user's specified mode (or enable/disable status) for a + * particular connector. This is typically only used during the early fbdev + * setup. + */ +static void drm_connector_get_cmdline_mode(struct drm_connector *connector) +{ + struct drm_cmdline_mode *mode = connector-cmdline_mode; + char *option = NULL; + + if (fb_get_options(connector-name, option)) + return; + + if (!drm_mode_parse_command_line_for_connector(option, + connector, + mode)) + return; + + if (mode-force) { + const char *s; + + switch (mode-force) { + case DRM_FORCE_OFF: + s = OFF; + break; + case DRM_FORCE_ON_DIGITAL: + s = ON - dig; + break; + default: + case DRM_FORCE_ON: + s = ON; + break; + } + + DRM_INFO(forcing %s connector %s\n, connector-name, s); + connector-force = mode-force; + } + + DRM_DEBUG_KMS(cmdline mode for connector %s %dx%d@%dHz%s%s%s\n, + connector-name, + mode-xres, mode-yres, + mode-refresh_specified ? mode-refresh : 60, + mode-rb ? reduced blanking : , + mode-margins ? with margins : , + mode-interlace ? interlaced : ); +} + +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device * @connector: the connector to init @@ -870,6 +923,8 @@ int drm_connector_init(struct drm_device *dev, connector-edid_blob_ptr = NULL; connector-status = connector_status_unknown; + drm_connector_get_cmdline_mode(connector); + list_add_tail(connector-head, dev-mode_config.connector_list); dev-mode_config.num_connector++; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index d5d8cea1a679..18988dc3de91 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -105,60 +105,6 @@ fail: } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); -static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) -{ - struct drm_fb_helper_connector *fb_helper_conn; - int i; - - for (i = 0; i fb_helper-connector_count; i++) { - struct drm_cmdline_mode *mode; - struct drm_connector *connector; - char *option = NULL; - - fb_helper_conn = fb_helper-connector_info[i]; - connector = fb_helper_conn-connector; - mode = fb_helper_conn-cmdline_mode; - - /* do something on return - turn off connector maybe
[Intel-gfx] [PATCH] drm: Perform cmdline mode parsing during connector initialisation
i915.ko has a custom fbdev initialisation routine that aims to preserve the current mode set by the BIOS, unless overruled by the user. The user's wishes are determined by what, if any, mode is specified on the command line (via the video= parameter). However, that command line mode is first parsed by drm_fb_helper_initial_config() which is called after i915.ko's custom initial_config() as a fallback method. So in order for us to honour it, we need to move the cmdline parser earlier. If we perform the connector cmdline parsing as soon as we initialise the connector, that cmdline mode and forced status is then available even if the fbdev helper is not compiled in or never called. We also then expose the cmdline user mode in the connector mode lists. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk Cc: Jesse Barnes jbar...@virtuousgeek.org Cc: Ville Syrjälä ville.syrj...@linux.intel.com Cc: Daniel Vetter daniel.vet...@ffwll.ch --- drivers/gpu/drm/drm_crtc.c | 56 +++ drivers/gpu/drm/drm_fb_helper.c| 64 ++-- drivers/gpu/drm/drm_modes.c|1 + drivers/gpu/drm/drm_probe_helper.c | 17 ++ drivers/gpu/drm/i915/intel_drv.h |5 --- include/drm/drm_crtc.h |1 + include/drm/drm_fb_helper.h|1 - 7 files changed, 78 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 461d19b..93c9198 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -799,6 +799,60 @@ static void drm_mode_remove(struct drm_connector *connector, } /** + * drm_connector_get_cmdline_mode - reads the user's cmdline mode + * @connector: connector to quwery + * @mode: returned mode + * + * The kernel supports per-connector configration of its consoles through + * use of the video= parameter. This function parses that option and + * extracts the user's specified mode (or enable/disable status) for a + * particular connector. This is typically only used during the early fbdev + * setup. + */ +static void drm_connector_get_cmdline_mode(struct drm_connector *connector) +{ + struct drm_cmdline_mode *mode = connector-cmdline_mode; + char *option = NULL; + + if (fb_get_options(drm_get_connector_name(connector), option)) + return; + + if (!drm_mode_parse_command_line_for_connector(option, + connector, + mode)) + return; + + if (mode-force) { + const char *s; + + switch (mode-force) { + case DRM_FORCE_OFF: + s = OFF; + break; + case DRM_FORCE_ON_DIGITAL: + s = ON - dig; + break; + default: + case DRM_FORCE_ON: + s = ON; + break; + } + + DRM_INFO(forcing %s connector %s\n, +drm_get_connector_name(connector), s); + connector-force = mode-force; + } + + DRM_DEBUG_KMS(cmdline mode for connector %s %dx%d@%dHz%s%s%s\n, + drm_get_connector_name(connector), + mode-xres, mode-yres, + mode-refresh_specified ? mode-refresh : 60, + mode-rb ? reduced blanking : , + mode-margins ? with margins : , + mode-interlace ? interlaced : ); +} + +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device * @connector: the connector to init @@ -842,6 +896,8 @@ int drm_connector_init(struct drm_device *dev, connector-edid_blob_ptr = NULL; connector-status = connector_status_unknown; + drm_connector_get_cmdline_mode(connector); + list_add_tail(connector-head, dev-mode_config.connector_list); dev-mode_config.num_connector++; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index e95ed58..c3b53f9 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -105,60 +105,6 @@ fail: } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); -static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) -{ - struct drm_fb_helper_connector *fb_helper_conn; - int i; - - for (i = 0; i fb_helper-connector_count; i++) { - struct drm_cmdline_mode *mode; - struct drm_connector *connector; - char *option = NULL; - - fb_helper_conn = fb_helper-connector_info[i]; - connector = fb_helper_conn-connector; - mode = fb_helper_conn-cmdline_mode; - - /* do something on return - turn off connector maybe */ -
Re: [Intel-gfx] [PATCH] drm: Perform cmdline mode parsing during connector initialisation
On Thu, 15 May 2014 10:54:36 +0100 Chris Wilson ch...@chris-wilson.co.uk wrote: i915.ko has a custom fbdev initialisation routine that aims to preserve the current mode set by the BIOS, unless overruled by the user. The user's wishes are determined by what, if any, mode is specified on the command line (via the video= parameter). However, that command line mode is first parsed by drm_fb_helper_initial_config() which is called after i915.ko's custom initial_config() as a fallback method. So in order for us to honour it, we need to move the cmdline parser earlier. If we perform the connector cmdline parsing as soon as we initialise the connector, that cmdline mode and forced status is then available even if the fbdev helper is not compiled in or never called. We also then expose the cmdline user mode in the connector mode lists. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk Cc: Jesse Barnes jbar...@virtuousgeek.org Cc: Ville Syrjälä ville.syrj...@linux.intel.com Cc: Daniel Vetter daniel.vet...@ffwll.ch --- drivers/gpu/drm/drm_crtc.c | 56 +++ drivers/gpu/drm/drm_fb_helper.c| 64 ++-- drivers/gpu/drm/drm_modes.c|1 + drivers/gpu/drm/drm_probe_helper.c | 17 ++ drivers/gpu/drm/i915/intel_drv.h |5 --- include/drm/drm_crtc.h |1 + include/drm/drm_fb_helper.h|1 - 7 files changed, 78 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 461d19b..93c9198 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -799,6 +799,60 @@ static void drm_mode_remove(struct drm_connector *connector, } /** + * drm_connector_get_cmdline_mode - reads the user's cmdline mode + * @connector: connector to quwery + * @mode: returned mode + * + * The kernel supports per-connector configration of its consoles through + * use of the video= parameter. This function parses that option and + * extracts the user's specified mode (or enable/disable status) for a + * particular connector. This is typically only used during the early fbdev + * setup. + */ +static void drm_connector_get_cmdline_mode(struct drm_connector *connector) +{ + struct drm_cmdline_mode *mode = connector-cmdline_mode; + char *option = NULL; + + if (fb_get_options(drm_get_connector_name(connector), option)) + return; + + if (!drm_mode_parse_command_line_for_connector(option, +connector, +mode)) + return; + + if (mode-force) { + const char *s; + + switch (mode-force) { + case DRM_FORCE_OFF: + s = OFF; + break; + case DRM_FORCE_ON_DIGITAL: + s = ON - dig; + break; + default: + case DRM_FORCE_ON: + s = ON; + break; + } + + DRM_INFO(forcing %s connector %s\n, + drm_get_connector_name(connector), s); + connector-force = mode-force; + } + + DRM_DEBUG_KMS(cmdline mode for connector %s %dx%d@%dHz%s%s%s\n, + drm_get_connector_name(connector), + mode-xres, mode-yres, + mode-refresh_specified ? mode-refresh : 60, + mode-rb ? reduced blanking : , + mode-margins ? with margins : , + mode-interlace ? interlaced : ); +} + +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device * @connector: the connector to init @@ -842,6 +896,8 @@ int drm_connector_init(struct drm_device *dev, connector-edid_blob_ptr = NULL; connector-status = connector_status_unknown; + drm_connector_get_cmdline_mode(connector); + list_add_tail(connector-head, dev-mode_config.connector_list); dev-mode_config.num_connector++; diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index e95ed58..c3b53f9 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -105,60 +105,6 @@ fail: } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); -static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) -{ - struct drm_fb_helper_connector *fb_helper_conn; - int i; - - for (i = 0; i fb_helper-connector_count; i++) { - struct drm_cmdline_mode *mode; - struct drm_connector *connector; - char *option = NULL; - - fb_helper_conn = fb_helper-connector_info[i]; - connector = fb_helper_conn-connector; - mode =