Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1457175 > unrolled thread

[PATCH v2 0/3] drm: add SimpleDRM driver

Started byNoralf Trønnes <noralf@tronnes.org>
First post2016-08-05 17:50 +0200
Last post2016-08-05 17:50 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/3] drm: add SimpleDRM driver Noralf Trønnes <noralf@tronnes.org> - 2016-08-05 17:50 +0200
    [PATCH v2 3/3] drm: simpledrm: honour remove_conflicting_framebuffers() Noralf Trønnes <noralf@tronnes.org> - 2016-08-05 17:50 +0200

#1457175 — [PATCH v2 0/3] drm: add SimpleDRM driver

FromNoralf Trønnes <noralf@tronnes.org>
Date2016-08-05 17:50 +0200
Subject[PATCH v2 0/3] drm: add SimpleDRM driver
Message-ID<s2PxL-YZ-3@gated-at.bofh.it>
This patchset adds the simpledrm driver by David Herrmann based on a
patchset[1] from 2014. That patchset also included patches for kicking
out simpledrm by real drivers. I have stayed away from that since it
involves another subsystem and I would probably be unable to answer any
questions about the implementation.

Two major changes in this version:

I have tried to address Daniel Vetter's concern that there's no way to
kick out/handover simpledrm to the real hw-driver. My solution relies
on the fb notifier, so I don't know how robust that actually is. I've
read that there's lot's of problems with it, at least in the drm context.
A test using the vc4 driver on Raspberry Pi successfully removed simpledrm.

Luc Verhaegen alerted me to the fact that I missed support for clocks, and
in fact more additions to the Device Tree binding document that has happen
after David wrote this driver. I lifted the code verbatim from simplefb.c.
I have not tested the functionality, but I assume it will work since I
didn't make any functional changes, only changed function and variable names.


I have tested simpledrm on a Raspberry Pi B+ with U-boot setting up the
framebuffer and producing this node (legacy, not under /chosen):

/ {
        framebuffer@1e887000 {
                compatible = "simple-framebuffer";
                reg = <0x1e887000 0x36c600>;
                format = "r5g6b5";
                width = <1824>;
                height = <984>;
                stride = <3648>;
                status = "okay";
        };

I have only tested with fbcon and modetest (XR24,RG16).


Noralf.


Changes from version 1:
- Move platform_set_drvdata() before drm_dev_register()
- Remove drm_legacy_mmap() call.
- Set mode_config.{min,max}_{width,height} to the actual dimensions
  of the native framebuffer
- Remove plane positioning since it won't work with the simple display pipe,
  meaning sdrm_display_pipe_check() isn't necessary either
- Support the additions to the Device Tree binding document, including
  clocks, regulators and having the node under /chosen
fbdev:
- Honour remove_conflicting_framebuffers()

Changes from previous version[2]:
- Remove FB_SIMPLE=n dependency to avoid kconfig recursive error
- Changed module name to match kconfig help text: sdrm -> simpledrm
- Use drm_simple_display_pipe
- Replace deprecated drm_platform_init()
- sdrm_dumb_create(): drm_gem_object_unreference() -> *_unlocked()
- sdrm_dumb_map_offset(): drm_gem_object_lookup() remove drm_device parameter
- sdrm_drm_mmap() changes:
  Remove struct_mutex locking
  Add drm_vma_offset_{lock,unlock}_lookup()
  drm_mmap() -> drm_legacy_mmap()
- dma_buf_begin_cpu_access() doesn't require start and length anymore
- Use drm_cvt_mode() instead of open coding a mode
- Fix format conversion. In the intermediate step, store the 8/6/5 bit color
  value in the upper part of the 16-bit color variable, not the lower.
- Support clips == NULL in sdrm_dirty()
- Set mode_config.preferred_depth
- Attach mode_config.dirty_info_property to connector
fbdev:
- 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

[1] https://lists.freedesktop.org/archives/dri-devel/2014-January/052584.html
[2] https://lists.freedesktop.org/archives/dri-devel/2014-January/052594.html


Further history:

[PATCH v4 0/6] SimpleDRM Driver
https://lists.freedesktop.org/archives/dri-devel/2013-September/044638.html

[PATCH v2 00/14] Platform Framebuffers and SimpleDRM
https://lists.freedesktop.org/archives/dri-devel/2013-July/041090.html

[RFC 0/6] SimpleDRM Driver (was: dvbe driver)
https://lists.freedesktop.org/archives/dri-devel/2013-June/040386.html

[PATCH 0/9] System Framebuffer Bus (sysfb)
https://lists.freedesktop.org/archives/dri-devel/2013-February/035013.html


Noralf Trønnes (3):
  drm: add SimpleDRM driver
  drm: simpledrm: add fbdev fallback support
  drm: simpledrm: honour remove_conflicting_framebuffers()

 drivers/gpu/drm/Kconfig                      |   2 +
 drivers/gpu/drm/Makefile                     |   1 +
 drivers/gpu/drm/simpledrm/Kconfig            |  27 ++
 drivers/gpu/drm/simpledrm/Makefile           |   5 +
 drivers/gpu/drm/simpledrm/simpledrm.h        | 129 +++++++
 drivers/gpu/drm/simpledrm/simpledrm_damage.c | 304 +++++++++++++++
 drivers/gpu/drm/simpledrm/simpledrm_drv.c    | 545 +++++++++++++++++++++++++++
 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c  | 200 ++++++++++
 drivers/gpu/drm/simpledrm/simpledrm_gem.c    | 273 ++++++++++++++
 drivers/gpu/drm/simpledrm/simpledrm_kms.c    | 267 +++++++++++++
 10 files changed, 1753 insertions(+)
 create mode 100644 drivers/gpu/drm/simpledrm/Kconfig
 create mode 100644 drivers/gpu/drm/simpledrm/Makefile
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm.h
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_damage.c
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_drv.c
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_gem.c
 create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_kms.c

--
2.8.2

[toc] | [next] | [standalone]


#1457185 — [PATCH v2 3/3] drm: simpledrm: honour remove_conflicting_framebuffers()

FromNoralf Trønnes <noralf@tronnes.org>
Date2016-08-05 17:50 +0200
Subject[PATCH v2 3/3] drm: simpledrm: honour remove_conflicting_framebuffers()
Message-ID<s2PxM-YZ-45@gated-at.bofh.it>
In reply to#1457175
There is currently no non-fbdev mechanism in place to kick out
simpledrm when the real hw-driver is probed. As a stop gap until
that is in place, honour remove_conflicting_framebuffers() and
delete the simple-framebuffer platform device when it's called.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/gpu/drm/simpledrm/Kconfig           |  5 ++++
 drivers/gpu/drm/simpledrm/Makefile          |  2 +-
 drivers/gpu/drm/simpledrm/simpledrm.h       |  9 +++++++
 drivers/gpu/drm/simpledrm/simpledrm_drv.c   |  3 +++
 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 40 +++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/simpledrm/Kconfig b/drivers/gpu/drm/simpledrm/Kconfig
index 9454536..6205b17 100644
--- a/drivers/gpu/drm/simpledrm/Kconfig
+++ b/drivers/gpu/drm/simpledrm/Kconfig
@@ -16,6 +16,11 @@ config DRM_SIMPLEDRM
 	  If fbdev support is enabled, this driver will also provide an fbdev
 	  compatibility layer.
 
+	  WARNING
+	  fbdev must be enabled for simpledrm to disable itself when a real
+	  hw-driver is probed. It relies on remove_conflicting_framebuffers()
+	  to be called by the hw-driver.
+
 	  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 7087245..4b4bcdd 100644
--- a/drivers/gpu/drm/simpledrm/Makefile
+++ b/drivers/gpu/drm/simpledrm/Makefile
@@ -1,5 +1,5 @@
 simpledrm-y :=	simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \
 		simpledrm_damage.o
-simpledrm-$(CONFIG_DRM_FBDEV_EMULATION) += simpledrm_fbdev.o
+simpledrm-$(CONFIG_FB) += 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 eb18d59..16f7e03 100644
--- a/drivers/gpu/drm/simpledrm/simpledrm.h
+++ b/drivers/gpu/drm/simpledrm/simpledrm.h
@@ -100,6 +100,8 @@ struct sdrm_framebuffer {
 void sdrm_fbdev_init(struct sdrm_device *sdrm);
 void sdrm_fbdev_cleanup(struct sdrm_device *sdrm);
 void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state);
+void sdrm_fbdev_kickout_init(void);
+void sdrm_fbdev_kickout_exit(void);
 
 #else
 
@@ -115,6 +117,13 @@ static inline void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state)
 {
 }
 
+static inline void sdrm_fbdev_kickout_init(void)
+{
+}
+
+static inline void sdrm_fbdev_kickout_exit(void)
+{
+}
 #endif
 
 #endif /* SDRM_DRV_H */
diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c b/drivers/gpu/drm/simpledrm/simpledrm_drv.c
index 88ad717c..a329e4c 100644
--- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c
+++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c
@@ -526,12 +526,15 @@ static int __init sdrm_init(void)
 		}
 	}
 
+	sdrm_fbdev_kickout_init();
+
 	return 0;
 }
 module_init(sdrm_init);
 
 static void __exit sdrm_exit(void)
 {
+	sdrm_fbdev_kickout_exit();
 	platform_driver_unregister(&sdrm_simplefb_driver);
 }
 module_exit(sdrm_exit);
diff --git a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
index b83646b..0d64352 100644
--- a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
+++ b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
@@ -24,6 +24,7 @@
 #include "simpledrm.h"
 
 struct sdrm_fbdev {
+	struct sdrm_device *sdrm;
 	u32 palette[16];
 };
 
@@ -76,7 +77,16 @@ void sdrm_fbdev_init(struct sdrm_device *sdrm)
 	if (!info)
 		goto err_out;
 
+	info->apertures = alloc_apertures(1);
+	if (!info->apertures)
+		goto err_free;
+
+	info->apertures->ranges[0].base = sdrm->fb_base;
+	info->apertures->ranges[0].size = sdrm->fb_size;
+
 	fb = info->par;
+	fb->sdrm = sdrm;
+
 	info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE |
 		      FBINFO_CAN_FORCE_OUTPUT;
 	info->pseudo_palette = fb->palette;
@@ -158,3 +168,33 @@ void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state)
 	fb_set_suspend(sdrm->fbdev, state);
 	console_unlock();
 }
+
+static int sdrm_fbdev_event_notify(struct notifier_block *self,
+				   unsigned long action, void *data)
+{
+	struct fb_event *event = data;
+	struct fb_info *info = event->info;
+	struct sdrm_fbdev *sfb = info->par;
+
+	if (sfb && sfb->sdrm && sfb->sdrm->fbdev == info &&
+	    action == FB_EVENT_FB_UNREGISTERED) {
+		sfb->sdrm->fbdev = NULL; /* don't run sdrm_fbdev_cleanup() */
+		platform_device_del(sfb->sdrm->ddev->platformdev);
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block sdrm_fbdev_event_notifier = {
+	.notifier_call  = sdrm_fbdev_event_notify,
+};
+
+void sdrm_fbdev_kickout_init(void)
+{
+	fb_register_client(&sdrm_fbdev_event_notifier);
+}
+
+void sdrm_fbdev_kickout_exit(void)
+{
+	fb_unregister_client(&sdrm_fbdev_event_notifier);
+}
-- 
2.8.2

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web