Skip to contentSkip to conversation

DRM: omapdrm DRM/KMS driver for TI OMAP platforms

PATCH In review Rob Clark 2 participants 2 messages Oct 23, 2011 – Oct 25, 2011

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 DRM: omapdrm DRM/KMS driver for TI OMAP platforms

From: Rob Clark <[email protected]>

A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev) and omap_vout (v4l2 display) drivers in the past, this driver uses the DSS2 driver to access the display hardware, including support for HDMI, DVI, and various types of LCD panels. And it implements GEM support for buffer allocation (for KMS as well as offscreen buffers used by the xf86-video-omap userspace xorg driver).

The driver maps CRTCs to overlays, encoders to overlay-managers, and connectors to dssdev's. Note that this arrangement might change slightly when support for drm_plane overlays is added.

For GEM support, non-scanout buffers are using the shmem backed pages provided by GEM core (In drm_gem_object_init()). In the case of scanout buffers, which need to be physically contiguous, those are allocated with CMA and use drm_gem_private_object_init().

See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git

Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302

Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://lwn.net/Articles/459397/

History:

v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error handling cleanup, refactor attach/detach pages into common drm functions, split non-userspace-facing API into omap_priv.h, remove plugin API

v1: original

---
 drivers/staging/Kconfig                  |    2 +
 drivers/staging/Makefile                 |    1 +
 drivers/staging/omapdrm/Kconfig          |   24 +
 drivers/staging/omapdrm/Makefile         |    9 +
 drivers/staging/omapdrm/TODO.txt         |   32 ++
 drivers/staging/omapdrm/omap_connector.c |  371 ++++++++++++++
 drivers/staging/omapdrm/omap_crtc.c      |  327 ++++++++++++
 drivers/staging/omapdrm/omap_drv.c       |  810 ++++++++++++++++++++++++++++++
 drivers/staging/omapdrm/omap_drv.h       |  124 +++++
 drivers/staging/omapdrm/omap_encoder.c   |  173 +++++++
 drivers/staging/omapdrm/omap_fb.c        |  261 ++++++++++
 drivers/staging/omapdrm/omap_fbdev.c     |  304 +++++++++++
 drivers/staging/omapdrm/omap_gem.c       |  769 ++++++++++++++++++++++++++++
 drivers/video/omap2/omapfb/Kconfig       |    2 +-
 include/drm/Kbuild                       |    1 +
 include/drm/omap_drm.h                   |  123 +++++
 include/drm/omap_priv.h                  |   42 ++
 17 files changed, 3374 insertions(+), 1 deletions(-)
 create mode 100644 drivers/staging/omapdrm/Kconfig
 create mode 100644 drivers/staging/omapdrm/Makefile
 create mode 100644 drivers/staging/omapdrm/TODO.txt
 create mode 100644 drivers/staging/omapdrm/omap_connector.c
 create mode 100644 drivers/staging/omapdrm/omap_crtc.c
 create mode 100644 drivers/staging/omapdrm/omap_drv.c
 create mode 100644 drivers/staging/omapdrm/omap_drv.h
 create mode 100644 drivers/staging/omapdrm/omap_encoder.c
 create mode 100644 drivers/staging/omapdrm/omap_fb.c
 create mode 100644 drivers/staging/omapdrm/omap_fbdev.c
 create mode 100644 drivers/staging/omapdrm/omap_gem.c
 create mode 100644 include/drm/omap_drm.h
 create mode 100644 include/drm/omap_priv.h
drivers/staging/Kconfig +2 -0
index eac0a7f..e748f67 100644
@@ -150,4 +150,6 @@ source "drivers/staging/mei/Kconfig"
 
 source "drivers/staging/nvec/Kconfig"
 
+source "drivers/staging/omapdrm/Kconfig"
+
 endif # STAGING
drivers/staging/Makefile +1 -0
index 20be112..3a8d920 100644
@@ -66,3 +66,4 @@ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)	+= ste_rmi4/
 obj-$(CONFIG_DRM_PSB)		+= gma500/
 obj-$(CONFIG_INTEL_MEI)		+= mei/
 obj-$(CONFIG_MFD_NVEC)		+= nvec/
+obj-$(CONFIG_DRM_OMAP)		+= omapdrm/
drivers/staging/omapdrm/Kconfig new file +24 -0
new file mode 100644
index 0000000..1ec24f2
@@ -0,0 +1,24 @@
+
+config DRM_OMAP
+	tristate "OMAP DRM"
+	depends on DRM && !CONFIG_FB_OMAP2
+	select DRM_KMS_HELPER
+	select OMAP2_DSS
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	default n
+	help
+	  DRM display driver for OMAP2/3/4 based boards.
+
+config DRM_OMAP_NUM_CRTCS
+	int "Number of CRTCs"
+	range 1 10
+	default 1  if ARCH_OMAP2 || ARCH_OMAP3
+	default 2  if ARCH_OMAP4
+	depends on DRM_OMAP
+	help
+	  Select the number of video overlays which can be used as framebuffers.
+	  The remaining overlays are reserved for video.
+
drivers/staging/omapdrm/Makefile new file +9 -0
new file mode 100644
index 0000000..d0d6c20
@@ -0,0 +1,9 @@
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI)
+#
+
+ccflags-y := -Iinclude/drm -Werror
+omapdrm-y := omap_drv.o omap_crtc.o omap_encoder.o omap_connector.o omap_fb.o omap_fbdev.o omap_gem.o
+
+obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
drivers/staging/omapdrm/TODO.txt new file +32 -0
new file mode 100644
index 0000000..17781c9
@@ -0,0 +1,32 @@
+TODO
+. check error handling/cleanup paths
+. add drm_plane / overlay support
+. add video decode/encode support (via syslink3 + codec-engine)
+. still some rough edges with flipping.. event back to userspace should
+  really come after VSYNC interrupt
+. where should we do eviction (detatch_pages())?  We aren't necessarily
+  accessing the pages via a GART, so maybe we need some other threshold
+  to put a cap on the # of pages that can be pin'd.  (It is mostly only
+  of interest in case you have a swap partition/file.. which a lot of
+  these devices do not.. but it doesn't hurt for the driver to do the
+  right thing anyways.)
+  . Use mm_shrinker to trigger unpinning pages.  Need to figure out how
+    to handle next issue first (I think?)
+  . Note TTM already has some mm_shrinker stuff..  maybe an argument to
+    move to TTM?  Or maybe something that could be factored out in common?
+. GEM/shmem backed pages can have existing mappings (kernel linear map,
+  etc..), which isn't really ideal.
+. Revisit GEM sync object infrastructure.. TTM has some framework for this
+  already.  Possibly this could be refactored out and made more common?
+  There should be some way to do this with less wheel-reinvention.
+. Review DSS vs KMS mismatches.  The omap_dss_device is sort of part encoder,
+  part connector.  Which results in a bit of duct tape to fwd calls from
+  encoder to connector.  Possibly this could be done a bit better.
+
+Userspace:
+. git://github.com/robclark/xf86-video-omap.git
+
+Currently tested on
+. OMAP3530 beagleboard
+. OMAP4430 pandaboard
+. OMAP4460 pandaboard
drivers/staging/omapdrm/omap_connector.c new file +371 -0

371 lines not on this page · raw message

drivers/staging/omapdrm/omap_crtc.c new file +327 -0

327 lines not on this page · raw message

drivers/staging/omapdrm/omap_drv.c new file +810 -0

810 lines not on this page · raw message

drivers/staging/omapdrm/omap_drv.h new file +124 -0

124 lines not on this page · raw message

drivers/staging/omapdrm/omap_encoder.c new file +173 -0

173 lines not on this page · raw message

drivers/staging/omapdrm/omap_fb.c new file +261 -0

261 lines not on this page · raw message

drivers/staging/omapdrm/omap_fbdev.c new file +304 -0

304 lines not on this page · raw message

drivers/staging/omapdrm/omap_gem.c new file +769 -0

555 lines not on this page · raw message

drivers/video/omap2/omapfb/Kconfig +1 -1
index 83d3fe7..4ea17dc 100644

Lines of this file are not shown. View the raw message.

include/drm/Kbuild +1 -0
index 3a60ac8..78d451c 100644

Lines of this file are not shown. View the raw message.

include/drm/omap_drm.h new file +123 -0

123 lines not on this page · raw message

include/drm/omap_priv.h new file +42 -0

42 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.5.4

Part of the diff is not shown here. View the raw message.

Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Rob Clark

From: Rob Clark <[email protected]>

A DRM display driver for TI OMAP platform. Similar to omapfb (fbdev) and omap_vout (v4l2 display) drivers in the past, this driver uses the DSS2 driver to access the display hardware, including support for HDMI, DVI, and various types of LCD panels. And it implements GEM support for buffer allocation (for KMS as well as offscreen buffers used by the xf86-video-omap userspace xorg driver).

The driver maps CRTCs to overlays, encoders to overlay-managers, and connectors to dssdev's. Note that this arrangement might change slightly when support for drm_plane overlays is added.

For GEM support, non-scanout buffers are using the shmem backed pages provided by GEM core (In drm_gem_object_init()). In the case of scanout buffers, which need to be physically contiguous, those are allocated with CMA and use drm_gem_private_object_init().

See userspace xorg driver:
git://github.com/robclark/xf86-video-omap.git

Refer to this link for CMA (Continuous Memory Allocator):
http://lkml.org/lkml/2011/8/19/302

Links to previous versions of the patch:
v1: http://lwn.net/Articles/458137/
v2: http://lwn.net/Articles/459397/

History:

v4: bit of rework of encoder/connector _dpms() code, modeset_init()
rework to not use nested functions, update TODO.txt
v3: minor cleanups, improved error handling for dev_load(), some minor
API changes that will be needed later for tiled buffer support
v2: replace omap_vram with CMA for scanout buffer allocation, remove
unneeded functions, use dma_addr_t for physical addresses, error handling cleanup, refactor attach/detach pages into common drm functions, split non-userspace-facing API into omap_priv.h, remove plugin API

Quoted 3 lines

v1: original

I think this has already seen way too many iterations for a simple -staging merge ... ;-)

drivers/staging/omapdrm/omap_drv.c line 235

Quoted 9 lines
drivers/staging/omapdrm/omap_drv.c new file +9 -0
+	/* if we couldn't find another connected connector, lets start
+	 * looking at the unconnected connectors:
+	 *
+	 * note: it might not be immediately apparent, but thanks to
+	 * the !mgr check in both this loop and the one above, the only
+	 * way to enter this loop is with *j == priv->num_connectors,
+	 * so idx can never go negative.
+	 */
+	while (*j < 2 * priv->num_connectors && !mgr) {

This loop here is still pretty ... strange. Might want to clean that up as the first patch when merged. Why no just a simple?

	for (j = 0; j < num_connectors; j++)
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48