[PATCH v4 0/5] drm: add SimpleDRM driver

From: Noralf TrÃnnes
Date: Mon Aug 22 2016 - 16:26:06 EST


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 main changes in this fourth version:

The gem code has been reworked to match that of the udl driver. This
has led me to drop PRIME support since it was not trivial to implement.

The fbdev emulation doesn't use the native framebuffer directly, but uses
the framebuffer flushing/blitting functionality. This means that fbdev mmap
doesn't work anymore as noted in an udl commit message
(see note in simpledrm_fbdev.c).

Also added a patch to export of_chosen so the driver can be built as a module
and added drm_fb_helper_set_suspend_lock() that takes the console lock.

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 3:
of:
- Export of_chosen so simpledrm can be built as a module
drm_fb_helper:
- Add drm_fb_helper_set_suspend_lock()
simpledrm:
- Reworked gem code to match udl
- Dropped PRIME support
- Dropped dirty_info_property, it's gone
- Don't use drm_device.platformdev it's deprecated
- Remove struct sdrm_device #ifdef's
- Split out sdrm_fb_init() from sdrm_fb_create(), needed by fbdev code
- Simplify drm_clip validation by extending the check in
sdrm_dirty() and drop the one in sdrm_blit()
- Removed sdrm_dirty_all_unlocked() which was unused.
fbdev:
- 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.
remove_conflicting_framebuffers:
- drm_device.platformdev is deprecated, use to_platform_device(ddev->dev).
- fb_helper might have been released in sdrm_fbdev_fb_destroy(),
so open code drm_fb_helper_release_fbi()
- Strengthen the test in sdrm_fbdev_event_notify() that we're the one.

Changes from version 2:
- Remove superfluos module.h includes
- Move includes from header to source files
- Set plane.fb before flushing in pipe update, or else the previous one
gets flushed
- Added check for vblank event in sdrm_display_pipe_update()
fbdev:
- Switch to using drm_fb_helper in preparation for future panic handling
which needs an enabled pipeline.
- Don't forget to free fb_info when kicked out.

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


Noralf TrÃnnes (5):
of: Add EXPORT_SYMBOL for of_chosen
drm/fb-helper: Add drm_fb_helper_set_suspend_lock()
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/drm_fb_helper.c | 57 +++
drivers/gpu/drm/simpledrm/Kconfig | 27 ++
drivers/gpu/drm/simpledrm/Makefile | 4 +
drivers/gpu/drm/simpledrm/simpledrm.h | 93 +++++
drivers/gpu/drm/simpledrm/simpledrm_damage.c | 235 ++++++++++++
drivers/gpu/drm/simpledrm/simpledrm_drv.c | 550 +++++++++++++++++++++++++++
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 259 +++++++++++++
drivers/gpu/drm/simpledrm/simpledrm_gem.c | 202 ++++++++++
drivers/gpu/drm/simpledrm/simpledrm_kms.c | 248 ++++++++++++
drivers/of/base.c | 1 +
include/drm/drm_fb_helper.h | 9 +
13 files changed, 1688 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