Re: [PATCH v4 4/5] drm: simpledrm: add fbdev fallback support
On Mon, Aug 22, 2016 at 10:25:24PM +0200, Noralf Trønnes wrote: > Create a simple fbdev device during SimpleDRM setup so legacy user-space > and fbcon can use it. > > Original work by David Herrmann. > > Cc: dh.herrm...@gmail.com > Signed-off-by: Noralf Trønnes> --- > > Changes from version 3: > - Remove #ifdef CONFIG_DRM_FBDEV_EMULATION > - Use drm_fb_helper_set_suspend_lock() > - Don't access the native framebuffer directly, but do blitting here as well. > - Use the drm_fb_helper_sys_*() functions instead of the cfb versions. > - Remove FBINFO_CAN_FORCE_OUTPUT flag which doesn't work now. > - Pass struct drm_fb_helper around instead of struct sdrm_fbdev. > > Changes from version 2: > - Switch to using drm_fb_helper in preparation for future panic handling > which needs an enabled pipeline. > > Changes from version 1: > No changes > > Changes from previous version: > - Remove the DRM_SIMPLEDRM_FBDEV kconfig option and use DRM_FBDEV_EMULATION > - Suspend fbcon/fbdev when the pipeline is enabled, resume in lastclose > - Add FBINFO_CAN_FORCE_OUTPUT flag so we get oops'es on the console > > drivers/gpu/drm/simpledrm/Kconfig | 3 + > drivers/gpu/drm/simpledrm/Makefile | 2 +- > drivers/gpu/drm/simpledrm/simpledrm.h | 5 + > drivers/gpu/drm/simpledrm/simpledrm_drv.c | 4 + > drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 201 > > drivers/gpu/drm/simpledrm/simpledrm_kms.c | 14 ++ > 6 files changed, 228 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c > > diff --git a/drivers/gpu/drm/simpledrm/Kconfig > b/drivers/gpu/drm/simpledrm/Kconfig > index f45b25d..3257590 100644 > --- a/drivers/gpu/drm/simpledrm/Kconfig > +++ b/drivers/gpu/drm/simpledrm/Kconfig > @@ -13,6 +13,9 @@ config DRM_SIMPLEDRM > SimpleDRM supports "simple-framebuffer" DeviceTree objects and > compatible platform framebuffers. > > + If fbdev support is enabled, this driver will also provide an fbdev > + compatibility layer that supports fbcon, mmap is not supported. > + > If unsure, say Y. > > To compile this driver as a module, choose M here: the > diff --git a/drivers/gpu/drm/simpledrm/Makefile > b/drivers/gpu/drm/simpledrm/Makefile > index f6a62dc..5474f7f 100644 > --- a/drivers/gpu/drm/simpledrm/Makefile > +++ b/drivers/gpu/drm/simpledrm/Makefile > @@ -1,4 +1,4 @@ > simpledrm-y := simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \ > - simpledrm_damage.o > + simpledrm_damage.o simpledrm_fbdev.o > > obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o > diff --git a/drivers/gpu/drm/simpledrm/simpledrm.h > b/drivers/gpu/drm/simpledrm/simpledrm.h > index 0739581..d4eb52c 100644 > --- a/drivers/gpu/drm/simpledrm/simpledrm.h > +++ b/drivers/gpu/drm/simpledrm/simpledrm.h > @@ -16,6 +16,7 @@ > #include > > struct simplefb_format; > +struct drm_fb_helper; > struct regulator; > struct clk; > > @@ -23,6 +24,7 @@ struct sdrm_device { > struct drm_device *ddev; > struct drm_simple_display_pipe pipe; > struct drm_connector conn; > + struct drm_fb_helper *fb_helper; > > /* framebuffer information */ > const struct simplefb_format *fb_sformat; > @@ -42,6 +44,7 @@ struct sdrm_device { > struct regulator **regulators; > }; > > +void sdrm_lastclose(struct drm_device *ddev); > int sdrm_drm_modeset_init(struct sdrm_device *sdrm); > > int sdrm_dirty(struct drm_framebuffer *fb, > @@ -82,5 +85,7 @@ struct sdrm_framebuffer { > int sdrm_fb_init(struct drm_device *ddev, struct sdrm_framebuffer *fb, >const struct drm_mode_fb_cmd2 *mode_cmd, >struct sdrm_gem_object *obj); > +void sdrm_fbdev_init(struct sdrm_device *sdrm); > +void sdrm_fbdev_cleanup(struct sdrm_device *sdrm); > > #endif /* SDRM_DRV_H */ > diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c > b/drivers/gpu/drm/simpledrm/simpledrm_drv.c > index 17c1b55..fe752c6 100644 > --- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c > +++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c > @@ -47,6 +47,7 @@ static const struct vm_operations_struct sdrm_gem_vm_ops = { > static struct drm_driver sdrm_drm_driver = { > .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, > .fops = _drm_fops, > + .lastclose = sdrm_lastclose, > > .gem_free_object = sdrm_gem_free_object, > .gem_vm_ops = _gem_vm_ops, > @@ -451,6 +452,8 @@ static int sdrm_simplefb_probe(struct platform_device > *pdev) > if (ret) > goto err_regulators; > > + sdrm_fbdev_init(sdrm); > + > DRM_INFO("Initialized %s on minor %d\n", ddev->driver->name, >ddev->primary->index); > > @@ -476,6 +479,7 @@ static int sdrm_simplefb_remove(struct platform_device > *pdev) > struct drm_device *ddev = platform_get_drvdata(pdev); > struct sdrm_device *sdrm = ddev->dev_private; > > +
Re: [PATCH v4 4/5] drm: simpledrm: add fbdev fallback support
On Mon, Aug 22, 2016 at 10:25:24PM +0200, Noralf Trønnes wrote: > Create a simple fbdev device during SimpleDRM setup so legacy user-space > and fbcon can use it. > > Original work by David Herrmann. > > Cc: dh.herrm...@gmail.com > Signed-off-by: Noralf Trønnes > --- > > Changes from version 3: > - Remove #ifdef CONFIG_DRM_FBDEV_EMULATION > - Use drm_fb_helper_set_suspend_lock() > - Don't access the native framebuffer directly, but do blitting here as well. > - Use the drm_fb_helper_sys_*() functions instead of the cfb versions. > - Remove FBINFO_CAN_FORCE_OUTPUT flag which doesn't work now. > - Pass struct drm_fb_helper around instead of struct sdrm_fbdev. > > Changes from version 2: > - Switch to using drm_fb_helper in preparation for future panic handling > which needs an enabled pipeline. > > Changes from version 1: > No changes > > Changes from previous version: > - Remove the DRM_SIMPLEDRM_FBDEV kconfig option and use DRM_FBDEV_EMULATION > - Suspend fbcon/fbdev when the pipeline is enabled, resume in lastclose > - Add FBINFO_CAN_FORCE_OUTPUT flag so we get oops'es on the console > > drivers/gpu/drm/simpledrm/Kconfig | 3 + > drivers/gpu/drm/simpledrm/Makefile | 2 +- > drivers/gpu/drm/simpledrm/simpledrm.h | 5 + > drivers/gpu/drm/simpledrm/simpledrm_drv.c | 4 + > drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 201 > > drivers/gpu/drm/simpledrm/simpledrm_kms.c | 14 ++ > 6 files changed, 228 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c > > diff --git a/drivers/gpu/drm/simpledrm/Kconfig > b/drivers/gpu/drm/simpledrm/Kconfig > index f45b25d..3257590 100644 > --- a/drivers/gpu/drm/simpledrm/Kconfig > +++ b/drivers/gpu/drm/simpledrm/Kconfig > @@ -13,6 +13,9 @@ config DRM_SIMPLEDRM > SimpleDRM supports "simple-framebuffer" DeviceTree objects and > compatible platform framebuffers. > > + If fbdev support is enabled, this driver will also provide an fbdev > + compatibility layer that supports fbcon, mmap is not supported. > + > If unsure, say Y. > > To compile this driver as a module, choose M here: the > diff --git a/drivers/gpu/drm/simpledrm/Makefile > b/drivers/gpu/drm/simpledrm/Makefile > index f6a62dc..5474f7f 100644 > --- a/drivers/gpu/drm/simpledrm/Makefile > +++ b/drivers/gpu/drm/simpledrm/Makefile > @@ -1,4 +1,4 @@ > simpledrm-y := simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \ > - simpledrm_damage.o > + simpledrm_damage.o simpledrm_fbdev.o > > obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o > diff --git a/drivers/gpu/drm/simpledrm/simpledrm.h > b/drivers/gpu/drm/simpledrm/simpledrm.h > index 0739581..d4eb52c 100644 > --- a/drivers/gpu/drm/simpledrm/simpledrm.h > +++ b/drivers/gpu/drm/simpledrm/simpledrm.h > @@ -16,6 +16,7 @@ > #include > > struct simplefb_format; > +struct drm_fb_helper; > struct regulator; > struct clk; > > @@ -23,6 +24,7 @@ struct sdrm_device { > struct drm_device *ddev; > struct drm_simple_display_pipe pipe; > struct drm_connector conn; > + struct drm_fb_helper *fb_helper; > > /* framebuffer information */ > const struct simplefb_format *fb_sformat; > @@ -42,6 +44,7 @@ struct sdrm_device { > struct regulator **regulators; > }; > > +void sdrm_lastclose(struct drm_device *ddev); > int sdrm_drm_modeset_init(struct sdrm_device *sdrm); > > int sdrm_dirty(struct drm_framebuffer *fb, > @@ -82,5 +85,7 @@ struct sdrm_framebuffer { > int sdrm_fb_init(struct drm_device *ddev, struct sdrm_framebuffer *fb, >const struct drm_mode_fb_cmd2 *mode_cmd, >struct sdrm_gem_object *obj); > +void sdrm_fbdev_init(struct sdrm_device *sdrm); > +void sdrm_fbdev_cleanup(struct sdrm_device *sdrm); > > #endif /* SDRM_DRV_H */ > diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c > b/drivers/gpu/drm/simpledrm/simpledrm_drv.c > index 17c1b55..fe752c6 100644 > --- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c > +++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c > @@ -47,6 +47,7 @@ static const struct vm_operations_struct sdrm_gem_vm_ops = { > static struct drm_driver sdrm_drm_driver = { > .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, > .fops = _drm_fops, > + .lastclose = sdrm_lastclose, > > .gem_free_object = sdrm_gem_free_object, > .gem_vm_ops = _gem_vm_ops, > @@ -451,6 +452,8 @@ static int sdrm_simplefb_probe(struct platform_device > *pdev) > if (ret) > goto err_regulators; > > + sdrm_fbdev_init(sdrm); > + > DRM_INFO("Initialized %s on minor %d\n", ddev->driver->name, >ddev->primary->index); > > @@ -476,6 +479,7 @@ static int sdrm_simplefb_remove(struct platform_device > *pdev) > struct drm_device *ddev = platform_get_drvdata(pdev); > struct sdrm_device *sdrm = ddev->dev_private; > > +
[PATCH v4 4/5] drm: simpledrm: add fbdev fallback support
Create a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it. Original work by David Herrmann. Cc: dh.herrm...@gmail.com Signed-off-by: Noralf Trønnes--- Changes from version 3: - Remove #ifdef CONFIG_DRM_FBDEV_EMULATION - Use drm_fb_helper_set_suspend_lock() - Don't access the native framebuffer directly, but do blitting here as well. - Use the drm_fb_helper_sys_*() functions instead of the cfb versions. - Remove FBINFO_CAN_FORCE_OUTPUT flag which doesn't work now. - Pass struct drm_fb_helper around instead of struct sdrm_fbdev. Changes from version 2: - Switch to using drm_fb_helper in preparation for future panic handling which needs an enabled pipeline. Changes from version 1: No changes Changes from previous version: - Remove the DRM_SIMPLEDRM_FBDEV kconfig option and use DRM_FBDEV_EMULATION - Suspend fbcon/fbdev when the pipeline is enabled, resume in lastclose - Add FBINFO_CAN_FORCE_OUTPUT flag so we get oops'es on the console drivers/gpu/drm/simpledrm/Kconfig | 3 + drivers/gpu/drm/simpledrm/Makefile | 2 +- drivers/gpu/drm/simpledrm/simpledrm.h | 5 + drivers/gpu/drm/simpledrm/simpledrm_drv.c | 4 + drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 201 drivers/gpu/drm/simpledrm/simpledrm_kms.c | 14 ++ 6 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c diff --git a/drivers/gpu/drm/simpledrm/Kconfig b/drivers/gpu/drm/simpledrm/Kconfig index f45b25d..3257590 100644 --- a/drivers/gpu/drm/simpledrm/Kconfig +++ b/drivers/gpu/drm/simpledrm/Kconfig @@ -13,6 +13,9 @@ config DRM_SIMPLEDRM SimpleDRM supports "simple-framebuffer" DeviceTree objects and compatible platform framebuffers. + If fbdev support is enabled, this driver will also provide an fbdev + compatibility layer that supports fbcon, mmap is not supported. + If unsure, say Y. To compile this driver as a module, choose M here: the diff --git a/drivers/gpu/drm/simpledrm/Makefile b/drivers/gpu/drm/simpledrm/Makefile index f6a62dc..5474f7f 100644 --- a/drivers/gpu/drm/simpledrm/Makefile +++ b/drivers/gpu/drm/simpledrm/Makefile @@ -1,4 +1,4 @@ simpledrm-y := simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \ - simpledrm_damage.o + simpledrm_damage.o simpledrm_fbdev.o obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o diff --git a/drivers/gpu/drm/simpledrm/simpledrm.h b/drivers/gpu/drm/simpledrm/simpledrm.h index 0739581..d4eb52c 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm.h +++ b/drivers/gpu/drm/simpledrm/simpledrm.h @@ -16,6 +16,7 @@ #include struct simplefb_format; +struct drm_fb_helper; struct regulator; struct clk; @@ -23,6 +24,7 @@ struct sdrm_device { struct drm_device *ddev; struct drm_simple_display_pipe pipe; struct drm_connector conn; + struct drm_fb_helper *fb_helper; /* framebuffer information */ const struct simplefb_format *fb_sformat; @@ -42,6 +44,7 @@ struct sdrm_device { struct regulator **regulators; }; +void sdrm_lastclose(struct drm_device *ddev); int sdrm_drm_modeset_init(struct sdrm_device *sdrm); int sdrm_dirty(struct drm_framebuffer *fb, @@ -82,5 +85,7 @@ struct sdrm_framebuffer { int sdrm_fb_init(struct drm_device *ddev, struct sdrm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd, struct sdrm_gem_object *obj); +void sdrm_fbdev_init(struct sdrm_device *sdrm); +void sdrm_fbdev_cleanup(struct sdrm_device *sdrm); #endif /* SDRM_DRV_H */ diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c b/drivers/gpu/drm/simpledrm/simpledrm_drv.c index 17c1b55..fe752c6 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c +++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c @@ -47,6 +47,7 @@ static const struct vm_operations_struct sdrm_gem_vm_ops = { static struct drm_driver sdrm_drm_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, .fops = _drm_fops, + .lastclose = sdrm_lastclose, .gem_free_object = sdrm_gem_free_object, .gem_vm_ops = _gem_vm_ops, @@ -451,6 +452,8 @@ static int sdrm_simplefb_probe(struct platform_device *pdev) if (ret) goto err_regulators; + sdrm_fbdev_init(sdrm); + DRM_INFO("Initialized %s on minor %d\n", ddev->driver->name, ddev->primary->index); @@ -476,6 +479,7 @@ static int sdrm_simplefb_remove(struct platform_device *pdev) struct drm_device *ddev = platform_get_drvdata(pdev); struct sdrm_device *sdrm = ddev->dev_private; + sdrm_fbdev_cleanup(sdrm); drm_dev_unregister(ddev); drm_mode_config_cleanup(ddev); diff --git a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c new file mode 100644 index 000..c6596ad --- /dev/null +++
[PATCH v4 4/5] drm: simpledrm: add fbdev fallback support
Create a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it. Original work by David Herrmann. Cc: dh.herrm...@gmail.com Signed-off-by: Noralf Trønnes --- Changes from version 3: - Remove #ifdef CONFIG_DRM_FBDEV_EMULATION - Use drm_fb_helper_set_suspend_lock() - Don't access the native framebuffer directly, but do blitting here as well. - Use the drm_fb_helper_sys_*() functions instead of the cfb versions. - Remove FBINFO_CAN_FORCE_OUTPUT flag which doesn't work now. - Pass struct drm_fb_helper around instead of struct sdrm_fbdev. Changes from version 2: - Switch to using drm_fb_helper in preparation for future panic handling which needs an enabled pipeline. Changes from version 1: No changes Changes from previous version: - Remove the DRM_SIMPLEDRM_FBDEV kconfig option and use DRM_FBDEV_EMULATION - Suspend fbcon/fbdev when the pipeline is enabled, resume in lastclose - Add FBINFO_CAN_FORCE_OUTPUT flag so we get oops'es on the console drivers/gpu/drm/simpledrm/Kconfig | 3 + drivers/gpu/drm/simpledrm/Makefile | 2 +- drivers/gpu/drm/simpledrm/simpledrm.h | 5 + drivers/gpu/drm/simpledrm/simpledrm_drv.c | 4 + drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 201 drivers/gpu/drm/simpledrm/simpledrm_kms.c | 14 ++ 6 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c diff --git a/drivers/gpu/drm/simpledrm/Kconfig b/drivers/gpu/drm/simpledrm/Kconfig index f45b25d..3257590 100644 --- a/drivers/gpu/drm/simpledrm/Kconfig +++ b/drivers/gpu/drm/simpledrm/Kconfig @@ -13,6 +13,9 @@ config DRM_SIMPLEDRM SimpleDRM supports "simple-framebuffer" DeviceTree objects and compatible platform framebuffers. + If fbdev support is enabled, this driver will also provide an fbdev + compatibility layer that supports fbcon, mmap is not supported. + If unsure, say Y. To compile this driver as a module, choose M here: the diff --git a/drivers/gpu/drm/simpledrm/Makefile b/drivers/gpu/drm/simpledrm/Makefile index f6a62dc..5474f7f 100644 --- a/drivers/gpu/drm/simpledrm/Makefile +++ b/drivers/gpu/drm/simpledrm/Makefile @@ -1,4 +1,4 @@ simpledrm-y := simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \ - simpledrm_damage.o + simpledrm_damage.o simpledrm_fbdev.o obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o diff --git a/drivers/gpu/drm/simpledrm/simpledrm.h b/drivers/gpu/drm/simpledrm/simpledrm.h index 0739581..d4eb52c 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm.h +++ b/drivers/gpu/drm/simpledrm/simpledrm.h @@ -16,6 +16,7 @@ #include struct simplefb_format; +struct drm_fb_helper; struct regulator; struct clk; @@ -23,6 +24,7 @@ struct sdrm_device { struct drm_device *ddev; struct drm_simple_display_pipe pipe; struct drm_connector conn; + struct drm_fb_helper *fb_helper; /* framebuffer information */ const struct simplefb_format *fb_sformat; @@ -42,6 +44,7 @@ struct sdrm_device { struct regulator **regulators; }; +void sdrm_lastclose(struct drm_device *ddev); int sdrm_drm_modeset_init(struct sdrm_device *sdrm); int sdrm_dirty(struct drm_framebuffer *fb, @@ -82,5 +85,7 @@ struct sdrm_framebuffer { int sdrm_fb_init(struct drm_device *ddev, struct sdrm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd, struct sdrm_gem_object *obj); +void sdrm_fbdev_init(struct sdrm_device *sdrm); +void sdrm_fbdev_cleanup(struct sdrm_device *sdrm); #endif /* SDRM_DRV_H */ diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c b/drivers/gpu/drm/simpledrm/simpledrm_drv.c index 17c1b55..fe752c6 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c +++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c @@ -47,6 +47,7 @@ static const struct vm_operations_struct sdrm_gem_vm_ops = { static struct drm_driver sdrm_drm_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, .fops = _drm_fops, + .lastclose = sdrm_lastclose, .gem_free_object = sdrm_gem_free_object, .gem_vm_ops = _gem_vm_ops, @@ -451,6 +452,8 @@ static int sdrm_simplefb_probe(struct platform_device *pdev) if (ret) goto err_regulators; + sdrm_fbdev_init(sdrm); + DRM_INFO("Initialized %s on minor %d\n", ddev->driver->name, ddev->primary->index); @@ -476,6 +479,7 @@ static int sdrm_simplefb_remove(struct platform_device *pdev) struct drm_device *ddev = platform_get_drvdata(pdev); struct sdrm_device *sdrm = ddev->dev_private; + sdrm_fbdev_cleanup(sdrm); drm_dev_unregister(ddev); drm_mode_config_cleanup(ddev); diff --git a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c new file mode 100644 index 000..c6596ad --- /dev/null +++