drm,fbdev: Move video= option to drivers/video
Subsystems (6)
Thomas Zimmermann
maintainercover drm,fbdev: Move video= option to drivers/video
The kernel's video= option sets the initial video mode. It is shared by fbdev and DRM, but located within the fbdev code. Move it to drivers/video/ and adapt callers. Allows DRM (and others) to use the option without depending on fbdev.
While at it, fix the interface of the lookup functions. This requires a number of changes. First clarify the ownership of the option string in patch 2. The helper fb_get_options() returns the video= parameter's value. It's sometimes a copy and sometimes the original string. Hence callers, mostly fbdev drivers, have just leaked the returned string. Change this to always duplicate the option string in fb_get_options() and transfer ownership of the copy to the caller. We can then start to fix the memory leaks in the fbdev drivers.
There's a global video= setting and a number of per-output settings. In patches 3 to 5, support explicit lookup of the global video option and lookup the string in fbdev's modedb and in a PS3 driver. Then avoid exporting the global setting's internal state variable in patch 6.
Finally, in patches 7 to 11, move the video= option to drivers/video. It can be used directly in DRM and a PS3 driver. This fixes any memory leaks from the returned option string. For fbdev drivers, the helper fb_get_options() remains as an adapter aroudn the new interface.
Tested with DRM and fbdev and built for the PS3.
Thomas Zimmermann (11):
fbdev: Fix contact info in fb_cmdline.c
fbdev: Transfer video= option strings to caller; clarify ownership
fbdev: Support NULL for name in option-string lookup drivers/ps3: Read video= option with fb_get_option()
fbdev: Read video= option with fb_get_option() in modedb
fbdev: Unexport fb_mode_option
fbdev: Move option-string lookup into helper
fbdev: Handle video= parameter in video/cmdline.c driver/ps3: Include <video/cmdline.h> for mode parsing
drm: Include <video/cmdline.h> for mode parsing
drm: Fix comment on mode parsing
drivers/gpu/drm/Kconfig | 2 +- drivers/gpu/drm/drm_connector.c | 9 +- drivers/gpu/drm/drm_modes.c | 3 +- drivers/ps3/ps3av.c | 9 +- drivers/video/Kconfig | 3 + drivers/video/Makefile | 1 + drivers/video/cmdline.c | 133 ++++++++++++++++++++++++++ drivers/video/fbdev/Kconfig | 5 +- drivers/video/fbdev/core/Makefile | 3 +- drivers/video/fbdev/core/fb_cmdline.c | 94 +++++------------- drivers/video/fbdev/core/modedb.c | 8 +- include/linux/fb.h | 1 - include/video/cmdline.h | 20 ++++ 13 files changed, 202 insertions(+), 89 deletions(-) create mode 100644 drivers/video/cmdline.c create mode 100644 include/video/cmdline.h
base-commit: 1a019dd7a5d25f7c1c9b77931138290e28947e6a
Signature · 1 line
2.39.1
Thomas Zimmermann
maintainerPATCH 1/11 fbdev: Fix contact info in fb_cmdline.c
Fix Daniel's email address. No functional changes.
--- drivers/video/fbdev/core/fb_cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fb_cmdline.c +1 -1
@@ -12,7 +12,7 @@* for more details. * * Authors: -* Vetter <[email protected]> +* Daniel Vetter <[email protected]> */ #include <linux/init.h> #include <linux/fb.h>
Signature · 1 line
2.39.1
Re: [PATCH 01/11] fbdev: Fix contact info in fb_cmdline.c
Quoted 5 lines · Thomas Zimmermann
Fix Daniel's email address. No functional changes.
Signed-off-by Thomas Zimmermann <[email protected]>Cc Daniel Vetter <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 2/11 fbdev: Transfer video= option strings to caller; clarify ownership
In reply to Thomas ZimmermannIn fb_get_options(), always duplicate the returned option string and transfer ownership of the memory to the function's caller.
Until now, only the global option string got duplicated and transferred to the caller; the per-driver options were owned by fb_get_options(). In the end, it was impossible for the function's caller to detect if it had to release the string's memory buffer. Hence, all calling drivers leak the memory buffer. The leaks have existed ever since, but drivers only call fb_get_option() once as part of module initialization. So the amount of leaked memory is not significant.
Fix the semantics of fb_get_option() by unconditionally transferring ownership of the memory buffer to the caller. Later patches can resolve the memory leaks in the fbdev drivers.
--- drivers/video/fbdev/core/fb_cmdline.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/video/fbdev/core/fb_cmdline.c +12 -4
@@ -30,13 +30,17 @@ EXPORT_SYMBOL_GPL(fb_mode_option);* (video=<name>:<options>) * @option: the option will be stored here * +* The caller owns the string returned in @option and is +* responsible for releasing the memory. +* * NOTE: Needed to maintain backwards compatibility */ int fb_get_options (const char *name,char **option) { -char *opt, *options =NULL ; +const char *options =NULL ;int retval =0 ;int name_len =strlen (name), i; +char *opt;if (name_len && ofonly &&strncmp (name,"offb" ,4 )) retval =1 ;
@@ -55,12 +59,16 @@ int fb_get_options(const char *name, char **option) }/* No match, pass global option */ if (!options && option && fb_mode_option) - options =kstrdup (fb_mode_option,GFP_KERNEL ); + options = fb_mode_option;if (options && !strncmp (options,"off" ,3 )) retval =1 ; -if (option) - *option = options; +if (option) { +if (options) + *option =kstrdup (options,GFP_KERNEL ); +else + *option =NULL ; + }return retval; }
Signature · 1 line
2.39.1
Re: [PATCH 02/11] fbdev: Transfer video= option strings to caller; clarify ownership
Quoted 17 lines · Thomas Zimmermann
In
fb_get_options(), always duplicate the returned option string and transfer ownership of the memory to the function's caller.Until now, only the global option string got duplicated and transferred to the caller; the per-driver options were owned by
fb_get_options(). In the end, it was impossible for the function's caller to detect if it had to release the string's memory buffer. Hence, all calling drivers leak the memory buffer. The leaks have existed ever since, but drivers only callfb_get_option()once as part of module initialization. So the amount of leaked memory is not significant.Fix the semantics of
fb_get_option()by unconditionally transferring ownership of the memory buffer to the caller. Later patches can resolve the memory leaks in the fbdev drivers.Signed-off-by Thomas Zimmermann <[email protected]>---
[...]
drivers/video/fbdev/core/fb_cmdline.c int fb_get_options(const char *name, char **option) · line 71
Quoted 7 lines
drivers/video/fbdev/core/fb_cmdline.c +6
-0+if (option) { +if (options) + *option =kstrdup (options,GFP_KERNEL ); +else + *option =NULL ; + }
I know the old code wasn't checking if kstrdup() succeeded, but you should do it here and let the caller know. And same if (!options). So I guess the following check can be added (to be consistent with the rest of the code):
if (!*option) retval = 1;
Quoted 4 lines
return retval;
}Signature · 1 line
2.39.1
Best regards,
Javier
Thomas Zimmermann
maintainerRe: [PATCH 02/11] fbdev: Transfer video= option strings to caller; clarify ownership
Hi
Am 17.02.23 um 09:37 schrieb Javier Martinez Canillas:
Quoted 22 lines
Quoted 17 lines · Thomas Zimmermann
In
fb_get_options(), always duplicate the returned option string and transfer ownership of the memory to the function's caller.Until now, only the global option string got duplicated and transferred to the caller; the per-driver options were owned by
fb_get_options(). In the end, it was impossible for the function's caller to detect if it had to release the string's memory buffer. Hence, all calling drivers leak the memory buffer. The leaks have existed ever since, but drivers only callfb_get_option()once as part of module initialization. So the amount of leaked memory is not significant.Fix the semantics of
fb_get_option()by unconditionally transferring ownership of the memory buffer to the caller. Later patches can resolve the memory leaks in the fbdev drivers.Signed-off-by Thomas Zimmermann <[email protected]>---
[...]
Quoted 9 lines
drivers/video/fbdev/core/fb_cmdline.c int fb_get_options(const char *name, char **option) · line 71
Quoted 7 lines
drivers/video/fbdev/core/fb_cmdline.c +6
-0+if (option) { +if (options) + *option =kstrdup (options,GFP_KERNEL ); +else + *option =NULL ; + }I know the old code wasn't checking if
kstrdup()succeeded, but you should
Kstrdup uses kmalloc, which already warns about failed allocations. I think it's discouraged to warn again. (Wasn't there a warning in sparse or checkpatch?) So I'd rather leave it as is.
Quoted 5 lines
do it here and let the caller know. And same if (!options). So I guess the following check can be added (to be consistent with the rest of the code):
if (!*option) retval = 1;
Why is that needed for consistency?
Retval is the state of the output: enabled or not. If there are no options, retval should be 0(=enabled). 1(=disabled) is only set by video=off or that ofonly thing.
Best regards
Thomas
Quoted 9 lines
Quoted 5 lines
return retval;
}Signature · 1 line
2.39.1Best regards,
Javier
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Javier Martinez Canillas
Reviewed-byRe: [PATCH 02/11] fbdev: Transfer video= option strings to caller; clarify ownership
Quoted 35 lines · Thomas Zimmermann
Hi
Am 17.02.23 um 09:37 schrieb Javier Martinez Canillas:
Quoted 22 lines
Quoted 17 lines · Thomas Zimmermann
In
fb_get_options(), always duplicate the returned option string and transfer ownership of the memory to the function's caller.Until now, only the global option string got duplicated and transferred to the caller; the per-driver options were owned by
fb_get_options(). In the end, it was impossible for the function's caller to detect if it had to release the string's memory buffer. Hence, all calling drivers leak the memory buffer. The leaks have existed ever since, but drivers only callfb_get_option()once as part of module initialization. So the amount of leaked memory is not significant.Fix the semantics of
fb_get_option()by unconditionally transferring ownership of the memory buffer to the caller. Later patches can resolve the memory leaks in the fbdev drivers.Signed-off-by Thomas Zimmermann <[email protected]>---
[...]
Quoted 9 lines
drivers/video/fbdev/core/fb_cmdline.c int fb_get_options(const char *name, char **option) · line 71
Quoted 7 lines
drivers/video/fbdev/core/fb_cmdline.c +6
-0+if (option) { +if (options) + *option =kstrdup (options,GFP_KERNEL ); +else + *option =NULL ; + }I know the old code wasn't checking if
kstrdup()succeeded, but you should
Quoted 4 lines
Kstrdup uses kmalloc, which already warns about failed allocations. I think it's discouraged to warn again. (Wasn't there a warning in sparse or checkpatch?) So I'd rather leave it as is.
I didn't mean to warn but to return an error code.
Quoted 12 lines
Quoted 5 lines
do it here and let the caller know. And same if (!options). So I guess the following check can be added (to be consistent with the rest of the code):
if (!*option) retval = 1;Why is that needed for consistency?
Retval is the state of the output: enabled or not. If there are no options, retval should be 0(=enabled). 1(=disabled) is only set by video=off or that ofonly thing.
Ah, I see. I misundertood what retval was about. Forget this comment then.
Maybe while you are there could have another patch to document the return value in the fb_get_options() kernel-doc?
And this patch looks good to me too after your explanations.
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 3/11 fbdev: Support NULL for name in option-string lookup
In reply to Thomas ZimmermannIgnore the per-driver video options if no driver name has been specified to fb_get_option(). Return the global options in this case.
--- drivers/video/fbdev/core/fb_cmdline.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fb_cmdline.c +6 -1
@@ -39,13 +39,18 @@ int fb_get_options(const char *name, char **option) {const char *options =NULL ;int retval =0 ; -int name_len =strlen (name), i; +size_t name_len;char *opt; +if (name) + name_len =strlen (name); +if (name_len && ofonly &&strncmp (name,"offb" ,4 )) retval =1 ;if (name_len && !retval) { +unsigned int i; +for (i =0 ; i <FB_MAX ; i++) {if (video_options[i] ==NULL )continue ;
Signature · 1 line
2.39.1
Re: [PATCH 03/11] fbdev: Support NULL for name in option-string lookup
Quoted 6 lines · Thomas Zimmermann
Ignore the per-driver video options if no driver name has been specified to
fb_get_option(). Return the global options in this case.Signed-off-by Thomas Zimmermann <[email protected]>---
I think you need to update the kernel-doc as well to mention that @name could be NULL ?
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 4/11 drivers/ps3: Read video= option with fb_get_option()
In reply to Thomas ZimmermannGet the kernel's global video= parameter with fb_get_option(). Done to unexport the internal fbdev state fb_mode_config. No functional changes.
--- drivers/ps3/ps3av.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/ps3/ps3av.c +9 -2
@@ -921,6 +921,9 @@ EXPORT_SYMBOL_GPL(ps3av_audio_mute);static int ps3av_probe (struct ps3_system_bus_device *dev) { +#ifdef CONFIG_FB +char *mode_option =NULL ; +#endif int res;int id;
@@ -969,8 +972,12 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)ps3av_get_hw_conf (ps3av);#ifdef CONFIG_FB -if (fb_mode_option && !strcmp (fb_mode_option,"safe" )) - safe_mode =1 ; +fb_get_options (NULL , &mode_option); +if (mode_option) { +if (!strcmp (mode_option,"safe" )) + safe_mode =1 ; +kfree (mode_option); + }#endif /* CONFIG_FB */ id =ps3av_auto_videomode (&ps3av->av_hw_conf);if (id <0 ) {
Signature · 1 line
2.39.1
Geoff Levand
maintainerRe: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()
Hi Thomas,
Quoted 8 lines · Thomas Zimmermann
Get the kernel's global video= parameter with
fb_get_option(). Done to unexport the internal fbdev statefb_mode_config. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/ps3/ps3av.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
I wanted to test these changes on the PS3, but got this error when trying to apply this patch set to Linux-6.2-rc7:
Applying: fbdev: Handle video= parameter in video/cmdline.c
error: patch failed: drivers/gpu/drm/Kconfig:10
error: drivers/gpu/drm/Kconfig: patch does not apply
Is there a Linux kernel revision that these will apply to, or is there a git repository I can pull them from?
-Geoff
Thomas Zimmermann
maintainerRe: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()
Hi
Am 12.02.23 um 17:53 schrieb Geoff Levand:
Quoted 15 lines
Hi Thomas,
Quoted 8 lines · Thomas Zimmermann
Get the kernel's global video= parameter with
fb_get_option(). Done to unexport the internal fbdev statefb_mode_config. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/ps3/ps3av.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)I wanted to test these changes on the PS3, but got this error when trying to apply this patch set to Linux-6.2-rc7:
Quoted 6 lines
Applying: fbdev: Handle video= parameter in
video/cmdline.c
error: patch failed:drivers/gpu/drm/Kconfig:10
error:drivers/gpu/drm/Kconfig: patch does not applyIs there a Linux kernel revision that these will apply to, or is there a git repository I can pull them from?
Thanks for testing. My base version is a recent DRM development tree. The repo is at https://cgit.freedesktop.org/drm/drm-tip/, the branch is drm-tip.
If acceptable, I'd later like to merge the PS3 patches through DRM trees.
Best regards
Thomas
Quoted 2 lines
-Geoff
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Re: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()
Hi,
Quoted 14 lines · Thomas Zimmermann
Am 12.02.23 um 17:53 schrieb Geoff Levand:
Quoted 13 lines · Thomas Zimmermann
Quoted 8 lines
Get the kernel's global video= parameter with
fb_get_option(). Done to unexport the internal fbdev statefb_mode_config. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/ps3/ps3av.c| 11 +++++++++--1 file changed, 9 insertions(+), 2 deletions(-)I wanted to test these changes on the PS3, but got this error when trying to apply this patch set to Linux-6.2-rc7:
Quoted 8 lines
Quoted 6 lines
Applying: fbdev: Handle video= parameter in
video/cmdline.c
error: patch failed:drivers/gpu/drm/Kconfig:10
error:drivers/gpu/drm/Kconfig: patch does not applyIs there a Linux kernel revision that these will apply to, or is there a git repository I can pull them from?
Thanks for testing. My base version is a recent DRM development tree. The repo is at https://cgit.freedesktop.org/drm/drm-tip/, the branch is drm-tip.
I tested the drm-tip branch at c54b5fcf3e68 on PS3 and it seemed to work OK.
Re: [PATCH 04/11] drivers/ps3: Read video= option with fb_get_option()
In reply to Thomas ZimmermannQuoted 6 lines · Thomas Zimmermann
Get the kernel's global video= parameter with
fb_get_option(). Done to unexport the internal fbdev statefb_mode_config. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 5/11 fbdev: Read video= option with fb_get_option() in modedb
In reply to Thomas ZimmermannGet the kernel's global video= parameter with fb_get_option(). Done to unexport the internal fbdev state fb_mode_config. No functional changes.
--- drivers/video/fbdev/core/modedb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/core/modedb.c +6 -2
@@ -620,6 +620,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,const struct fb_videomode *default_mode, unsigned int default_bpp) { + char *mode_option_buf = NULL;int i;/* Set up defaults */
@@ -635,8 +636,10 @@ int fb_find_mode(struct fb_var_screeninfo *var, default_bpp =8 ;/* Did the user specify a video mode? */ -if (!mode_option) - mode_option = fb_mode_option; +if (!mode_option) { +fb_get_options (NULL , &mode_option_buf); + mode_option = mode_option_buf; + }if (mode_option) {const char *name = mode_option;unsigned int namelen =strlen (name);
@@ -715,6 +718,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, res_specified =1 ; } done: +kfree (mode_option_buf);if (cvt) {struct fb_videomode cvt_mode;int ret;
Signature · 1 line
2.39.1
Re: [PATCH 05/11] fbdev: Read video= option with fb_get_option() in modedb
Quoted 6 lines · Thomas Zimmermann
Get the kernel's global video= parameter with
fb_get_option(). Done to unexport the internal fbdev statefb_mode_config. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 6/11 fbdev: Unexport fb_mode_option
In reply to Thomas ZimmermannThere are no external users of fb_mode_option. Unexport the variable and declare it static.
--- drivers/video/fbdev/core/fb_cmdline.c | 4 +--- include/linux/fb.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/video/fbdev/core/fb_cmdline.c +1 -3
@@ -18,11 +18,9 @@#include <linux/fb.h> static char *video_options[FB_MAX ]__read_mostly ; +static const char *fb_mode_option__read_mostly ;static int ofonly__read_mostly ; -const char *fb_mode_option; -EXPORT_SYMBOL_GPL (fb_mode_option); -/** * fb_get_options - get kernel boot parameters * @name: framebuffer name as it would appear in
include/linux/fb.h +0 -1
@@ -764,7 +764,6 @@ struct dmt_videomode {const struct fb_videomode *mode; }; -extern const char *fb_mode_option;extern const struct fb_videomode vesa_modes[];extern const struct dmt_videomode dmt_modes[];
Signature · 1 line
2.39.1
Re: [PATCH 06/11] fbdev: Unexport fb_mode_option
Quoted 5 lines · Thomas Zimmermann
There are no external users of
fb_mode_option. Unexport the variable and declare it static.Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 7/11 fbdev: Move option-string lookup into helper
In reply to Thomas ZimmermannMove the lookup of the option string into an internal helper. No functional changes.
--- drivers/video/fbdev/core/fb_cmdline.c | 60 ++++++++++++++++----------- 1 file changed, 36 insertions(+), 24 deletions(-)
drivers/video/fbdev/core/fb_cmdline.c +36 -24
@@ -21,6 +21,36 @@ static char *video_options[FB_MAX] __read_mostly;static const char *fb_mode_option__read_mostly ;static int ofonly__read_mostly ; +static const char *__fb_get_options (const char *name) +{ +const char *options =NULL ; +size_t name_len =0 ; + +if (name) + name_len =strlen (name); + +if (name_len) { +unsigned int i; +const char *opt; + +for (i =0 ; i <ARRAY_SIZE (video_options); ++i) { +if (!video_options[i]) +continue ; +if (video_options[i][0 ] =='\0' ) +continue ; + opt = video_options[i]; +if (!strncmp (opt, name, name_len) && opt[name_len] ==':' ) + options = opt + name_len +1 ; + } + } + +/* No match, return global options */ +if (!options) + options = fb_mode_option; + +return options; +} +/** * fb_get_options - get kernel boot parameters * @name: framebuffer name as it would appear in
@@ -35,36 +65,18 @@ static int ofonly __read_mostly;*/ int fb_get_options (const char *name,char **option) { -const char *options =NULL ;int retval =0 ; -size_t name_len; -char *opt; +const char *options; -if (name) - name_len =strlen (name); - -if (name_len && ofonly &&strncmp (name,"offb" ,4 )) +if (name && ofonly &&strncmp (name,"offb" ,4 )) retval =1 ; -if (name_len && !retval) { -unsigned int i; + options =__fb_get_options (name); -for (i =0 ; i <FB_MAX ; i++) { -if (video_options[i] ==NULL ) -continue ; -if (!video_options[i][0 ]) -continue ; - opt = video_options[i]; -if (!strncmp (name, opt, name_len) && - opt[name_len] ==':' ) - options = opt + name_len +1 ; - } +if (options) { +if (!strncmp (options,"off" ,3 )) + retval =1 ; } -/* No match, pass global option */ -if (!options && option && fb_mode_option) - options = fb_mode_option; -if (options && !strncmp (options,"off" ,3 )) - retval =1 ;if (option) {if (options)
Signature · 1 line
2.39.1
Re: [PATCH 07/11] fbdev: Move option-string lookup into helper
Quoted 5 lines · Thomas Zimmermann
Move the lookup of the option string into an internal helper. No functional changes.
Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 8/11 fbdev: Handle video= parameter in video/cmdline.c
In reply to Thomas ZimmermannHandle the command-line parameter video= in video/cmdline.c. Implement the fbdev helper fb_get_options() on top. Will allows to handle the kernel parameter in DRM without fbdev dependencies.
Note that __video_get_options() has the meaning of its return value inverted compared to fb_get_options(). The new helper returns true if the adapter has been enabled, and false otherwise.
There is the ofonly parameter, which disables output for non-OF-based framebuffers. It is only for offb and looks like a workaround. The actual purpose it not clear to me. Use 'video=off' or 'nomodeset' instead.
--- drivers/gpu/drm/Kconfig | 2 +- drivers/video/Kconfig | 3 + drivers/video/Makefile | 1 + drivers/video/cmdline.c | 133 ++++++++++++++++++++++++++ drivers/video/fbdev/Kconfig | 5 +- drivers/video/fbdev/core/Makefile | 3 +- drivers/video/fbdev/core/fb_cmdline.c | 93 +++--------------- include/video/cmdline.h | 20 ++++ 8 files changed, 172 insertions(+), 88 deletions(-) create mode 100644 drivers/video/cmdline.c create mode 100644 include/video/cmdline.h
drivers/gpu/drm/Kconfig +1 -1
@@ -10,13 +10,13 @@ menuconfig DRM depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA select DRM_PANEL_ORIENTATION_QUIRKS select HDMI - select FB_CMDLINE select I2C select DMA_SHARED_BUFFER select SYNC_FILE # gallium uses SYS_kcmp for os_same_file_description() to de-duplicate # device and dmabuf fd. Let's make sure that is available for our userspace. select KCMP + select VIDEO_CMDLINE select VIDEO_NOMODESET help Kernel-level support for the Direct Rendering Infrastructure (DRI)
drivers/video/Kconfig +3 -0
@@ -11,6 +11,9 @@ config APERTURE_HELPERS Support tracking and hand-over of aperture ownership. Required by graphics drivers for firmware-provided framebuffers. +config VIDEO_CMDLINE + bool + config VIDEO_NOMODESET bool default n
drivers/video/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_APERTURE_HELPERS) += aperture.o obj-$(CONFIG_VGASTATE) += vgastate.o +obj-$(CONFIG_VIDEO_CMDLINE) += cmdline.o obj-$(CONFIG_VIDEO_NOMODESET) += nomodeset.o obj-$(CONFIG_HDMI) += hdmi.o
drivers/video/cmdline.c new file +133 -0
133 lines not on this page · raw message
drivers/video/fbdev/Kconfig +1 -4
@@ -3,16 +3,13 @@ # fbdev configuration # -config FB_CMDLINE - bool - config FB_NOTIFY bool menuconfig FB tristate "Support for frame buffer devices" - select FB_CMDLINE select FB_NOTIFY + select VIDEO_CMDLINE help The frame buffer device provides an abstraction for the graphics hardware. It represents the frame buffer of some video hardware and
drivers/video/fbdev/core/Makefile +1 -2
@@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_FB_CMDLINE) += fb_cmdline.o obj-$(CONFIG_FB_NOTIFY) += fb_notify.o obj-$(CONFIG_FB) += fb.o fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ - modedb.o fbcvt.o + modedb.o fbcvt.o fb_cmdline.o fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE),y)
drivers/video/fbdev/core/fb_cmdline.c +12 -81
117 lines not on this page · raw message
include/video/cmdline.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef VIDEO_CMDLINE_H +#define VIDEO_CMDLINE_H + +#include <linux/types.h> + +#if defined(CONFIG_VIDEO_CMDLINE ) +const char *video_get_options (const char *name); + +/* exported for compatibility with fbdev; don't use in new code */ +bool __video_get_options (const char *name,const char **option,bool is_of); +#else +static inline const char *video_get_options (const char *name) +{ +return NULL ; +} +#endif + +#endif
Signature · 1 line
2.39.1
Re: [PATCH 08/11] fbdev: Handle video= parameter in video/cmdline.c
Quoted 4 lines · Thomas Zimmermann
Handle the command-line parameter video= in
video/cmdline.c. Implement the fbdev helperfb_get_options()on top. Will allows to handle the kernel parameter in DRM without fbdev dependencies.
Quoted 8 lines
Note that
__video_get_options()has the meaning of its return value inverted compared tofb_get_options(). The new helper returns true if the adapter has been enabled, and false otherwise.There is the ofonly parameter, which disables output for non-OF-based framebuffers. It is only for offb and looks like a workaround. The actual purpose it not clear to me. Use 'video=off' or 'nomodeset' instead.
s/it/is
Quoted 2 lines
Signed-off-by Thomas Zimmermann <[email protected]>---
[..]
Quoted 1 line
+#include <
linux/fb.h> /* forFB_MAX*/
I believe including <uapi/linux/fb.h> is enough here.
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 9/11 driver/ps3: Include <video/cmdline.h> for mode parsing
In reply to Thomas ZimmermannInclude <video/cmdline.h> in ps3av.c to get video_get_options() and avoid the dependency on <linux/fb.h>. The replaced function fb_get_options() is just a tiny wrapper around video_get_opions(). No functional changes.
--- drivers/ps3/ps3av.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/ps3/ps3av.c +6 -12
@@ -11,13 +11,14 @@#include <linux/delay.h> #include <linux/notifier.h> #include <linux/ioctl.h> -#include <linux/fb.h> #include <linux/slab.h> #include <asm/firmware.h> #include <asm/ps3av.h> #include <asm/ps3.h> +#include <video/cmdline.h> +#include "vuart.h" #define BUFSIZE 4096/* vuart buf size */
@@ -921,9 +922,7 @@ EXPORT_SYMBOL_GPL(ps3av_audio_mute);static int ps3av_probe (struct ps3_system_bus_device *dev) { -#ifdef CONFIG_FB -char *mode_option =NULL ; -#endif +const char *mode_option;int res;int id;
@@ -971,14 +970,9 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)ps3av_get_hw_conf (ps3av); -#ifdef CONFIG_FB -fb_get_options (NULL , &mode_option); -if (mode_option) { -if (!strcmp (mode_option,"safe" )) - safe_mode =1 ; -kfree (mode_option); - } -#endif /* CONFIG_FB */ + mode_option =video_get_options (NULL ); +if (mode_option && !strcmp (mode_option,"safe" )) + safe_mode =1 ; id =ps3av_auto_videomode (&ps3av->av_hw_conf);if (id <0 ) {printk (KERN_ERR "%s: invalid id :%d\n" , __func__, id);
Signature · 1 line
2.39.1
Re: [PATCH 09/11] driver/ps3: Include <video/cmdline.h> for mode parsing
Quoted 7 lines · Thomas Zimmermann
Include <
video/cmdline.h> inps3av.cto getvideo_get_options()and avoid the dependency on <linux/fb.h>. The replaced functionfb_get_options()is just a tiny wrapper aroundvideo_get_opions(). No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 10/11 drm: Include <video/cmdline.h> for mode parsing
In reply to Thomas ZimmermannInclude <video/cmdline.h> in drm_connector.c to get video_get_options() and avoid the dependency on <linux/fb.h>. The replaced function fb_get_options() is just a tiny wrapper around video_get_opions(). No functional changes.
Include <linux/property.h> to get fwnode_handle_put(), which had been provided via <linux/fb.h>.
--- drivers/gpu/drm/drm_connector.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_connector.c +6 -3
@@ -33,9 +33,11 @@#include <drm/drm_sysfs.h> #include <drm/drm_utils.h> -#include <linux/fb.h> +#include <linux/property.h> #include <linux/uaccess.h> +#include <video/cmdline.h> +#include "drm_crtc_internal.h" #include "drm_internal.h"
@@ -154,9 +156,10 @@ EXPORT_SYMBOL(drm_get_connector_type_name); static void drm_connector_get_cmdline_mode(struct drm_connector *connector) { struct drm_cmdline_mode *mode = &connector->cmdline_mode; - char *option = NULL; + const char *option; - if (fb_get_options(connector->name, &option)) + option = video_get_options(connector->name); + if (!option) return; if (!drm_mode_parse_command_line_for_connector(option,
Signature · 1 line
2.39.1
Re: [PATCH 10/11] drm: Include <video/cmdline.h> for mode parsing
Quoted 10 lines · Thomas Zimmermann
Include <
video/cmdline.h> indrm_connector.cto getvideo_get_options()and avoid the dependency on <linux/fb.h>. The replaced functionfb_get_options()is just a tiny wrapper aroundvideo_get_opions(). No functional changes.Include <
linux/property.h> to getfwnode_handle_put(), which had been provided via <linux/fb.h>.Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier
Thomas Zimmermann
maintainerPATCH 11/11 drm: Fix comment on mode parsing
In reply to Thomas ZimmermannDo not claim that there's a default mode in the video= option parser. if no option string has been given, the parser does nothing.
--- drivers/gpu/drm/drm_modes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_modes.c +1 -2
@@ -2339,8 +2339,7 @@ static int drm_mode_parse_cmdline_named_mode(const char *name,* @mode: preallocated drm_cmdline_mode structure to fill out * * This parses @mode_option command line modeline for modes and options to -* configure the connector. If @mode_option is NULL the default command line -* modeline in fb_mode_option will be parsed instead. +* configure the connector. * * This uses the same parameters as the fb modedb.c, except for an extra * force-enable, force-enable-digital and force-disable bit at the end::
Signature · 1 line
2.39.1
Re: [PATCH 11/11] drm: Fix comment on mode parsing
Quoted 5 lines · Thomas Zimmermann
Do not claim that there's a default mode in the video= option parser. if no option string has been given, the parser does nothing.
Signed-off-by Thomas Zimmermann <[email protected]>---
Best regards,
Javier