[PATCHv3 0/4] drm/msm: A DRM/KMS driver for snapdragon SoCs

Rob Clark robdclark at gmail.com
Sat Aug 17 13:27:59 PDT 2013

This patchset can also be found here, for easier browsing:

  git://people.freedesktop.org/~robclark/linux drm-next

In userspace, I've a libdrm branch with libdrm_freedreno updated to
work on top of either this driver or the downstream android kgsl+fbdev


And the DDX has been updated to either use kms with this driver, or
the downstream android drivers.  Note that page flipping requires kms:


And finally mesa/gallium with a few minor tweaks, mostly updates to
the loader to load on either "msm" or legacy/downstream "kgsl":


I have started adding DSI panel support, although there are still some
things to debug, and in general it isn't ready to merge yet.  But if
you are curious, it can be found here:


v1: original
v2: only changed patch is a3xx gpu (fix timespec vs ioctl issue,
    drop setparam ioctl for now).  I've left out the two debugfs
    patches, until I have a chance to attempt to make drm core
    move minor creation (or at least debugfs) until after load.
    I've also added a small note about why cmdstream validation
    is not required in the commit-msg of the a3xx gpu patch.
v3: fix the unlock/unpin order as pointed out by Maarten Lankhorst,
    and a few little tweaks to prepare things better for DSI

NOTES from the previous RFCs:

In the current snapdragon SoC's, we have (at least) 3 different
display controller blocks at play:
 + MDP3 - ?? seems to be what is on geeksphone peak device
 + MDP4 - S3 (APQ8060, touchpad), S4-pro (APQ8064, nexus4 & ifc6410)
 + MDSS - snapdragon 800

(I don't have a completely clear picture on which display controller
maps to which part #)

Plus a handful of blocks around them for HDMI/DSI/etc output.

And on gpu side of things:
 + zero, one, or two 2d cores (z180)
 + and either a2xx or a3xx 3d core.

But, HDMI/DSI/etc blocks seem like they can be shared across multiple
display controller blocks.  And I for sure don't want to have to deal
with N different kms devices from xf86-video-freedreno.  Plus, it
seems like we can do some clever tricks like use GPU to trigger
pageflip after rendering completes (ie. have the kms/crtc code build
up gpu cmdstream to update scanout and write FLUSH register after).

So, the approach is one drm driver, with some modularity.  Different
'struct msm_kms' implementations, depending on display controller.
And one or more 'struct msm_gpu' for the various different gpu sub-

The kms module provides the plane, crtc, and encoder objects, and
loads whatever connectors are appropriate.

For MDP4, the mapping is:

  plane   -> PIPE{RGBn,VGn}              \
  crtc    -> OVLP{n} + DMA{P,S,E} (??)   |-> MDP "device"
  encoder -> DTV/LCDC/DSI (within MDP4)  /
  connector -> HDMI/DSI/etc              --> other device(s)

Since the irq's that drm core mostly cares about are vblank/framedone,
we'll let msm_mdp4_kms provide the irq install/uninstall/etc functions
and treat the MDP4 block's irq as "the" irq.  Even though the connectors
may have their own irqs which they install themselves.  For this reason
the display controller is the "master" device.

Each connector probably ends up being a separate device, just for the
logistics of finding/mapping io region, irq, etc.  Idealy we would
have a better way than just stashing the platform device in a global
(ie. like DT super-node.. but I don't have any snapdragon hw yet that
is using DT).

Note that so far I've not been able to get any docs on the hw, and it
seems that access to such docs would prevent me from working on the
freedreno gallium driver.  So there may be some mistakes in register
names (I had to invent a few, since no sufficient hint was given in
the downstream android fbdev driver), bitfield sizes, etc.  My current
state of understanding the registers is given in the envytools rnndb
files at:


These files are used both for a parser tool (in the same tree) to
parse logged register reads/writes (both from downstream android fbdev
driver, and this driver with register logging enabled), as well as to
generate the register level headers.

Rob Clark (4):
  drm/msm: add register definitions
  drm/msm: basic KMS driver for snapdragon
  drm/msm: add register definitions for gpu
  drm/msm: add a3xx gpu support

 drivers/gpu/drm/Kconfig                        |    2 +
 drivers/gpu/drm/Makefile                       |    1 +
 drivers/gpu/drm/msm/Kconfig                    |   34 +
 drivers/gpu/drm/msm/Makefile                   |   30 +
 drivers/gpu/drm/msm/NOTES                      |   69 +
 drivers/gpu/drm/msm/adreno/a2xx.xml.h          | 1438 ++++++++++++++++
 drivers/gpu/drm/msm/adreno/a3xx.xml.h          | 2193 ++++++++++++++++++++++++
 drivers/gpu/drm/msm/adreno/a3xx_gpu.c          |  501 ++++++
 drivers/gpu/drm/msm/adreno/a3xx_gpu.h          |   30 +
 drivers/gpu/drm/msm/adreno/adreno_common.xml.h |  432 +++++
 drivers/gpu/drm/msm/adreno/adreno_gpu.c        |  350 ++++
 drivers/gpu/drm/msm/adreno/adreno_gpu.h        |  142 ++
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h    |  254 +++
 drivers/gpu/drm/msm/dsi/dsi.xml.h              |  502 ++++++
 drivers/gpu/drm/msm/dsi/mmss_cc.xml.h          |  114 ++
 drivers/gpu/drm/msm/dsi/sfpb.xml.h             |   48 +
 drivers/gpu/drm/msm/hdmi/hdmi.c                |  235 +++
 drivers/gpu/drm/msm/hdmi/hdmi.h                |  112 ++
 drivers/gpu/drm/msm/hdmi/hdmi.xml.h            |  508 ++++++
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c      |  461 +++++
 drivers/gpu/drm/msm/hdmi/hdmi_i2c.c            |  281 +++
 drivers/gpu/drm/msm/hdmi/hdmi_phy_8960.c       |  141 ++
 drivers/gpu/drm/msm/hdmi/hdmi_phy_8x60.c       |  214 +++
 drivers/gpu/drm/msm/hdmi/qfprom.xml.h          |   50 +
 drivers/gpu/drm/msm/mdp4/mdp4.xml.h            | 1061 ++++++++++++
 drivers/gpu/drm/msm/mdp4/mdp4_crtc.c           |  684 ++++++++
 drivers/gpu/drm/msm/mdp4/mdp4_dtv_encoder.c    |  317 ++++
 drivers/gpu/drm/msm/mdp4/mdp4_format.c         |   56 +
 drivers/gpu/drm/msm/mdp4/mdp4_irq.c            |  203 +++
 drivers/gpu/drm/msm/mdp4/mdp4_kms.c            |  368 ++++
 drivers/gpu/drm/msm/mdp4/mdp4_kms.h            |  194 +++
 drivers/gpu/drm/msm/mdp4/mdp4_plane.c          |  243 +++
 drivers/gpu/drm/msm/msm_connector.c            |   34 +
 drivers/gpu/drm/msm/msm_connector.h            |   68 +
 drivers/gpu/drm/msm/msm_drv.c                  |  777 +++++++++
 drivers/gpu/drm/msm/msm_drv.h                  |  211 +++
 drivers/gpu/drm/msm/msm_fb.c                   |  202 +++
 drivers/gpu/drm/msm/msm_fbdev.c                |  258 +++
 drivers/gpu/drm/msm/msm_gem.c                  |  597 +++++++
 drivers/gpu/drm/msm/msm_gem.h                  |   99 ++
 drivers/gpu/drm/msm/msm_gem_submit.c           |  412 +++++
 drivers/gpu/drm/msm/msm_gpu.c                  |  411 +++++
 drivers/gpu/drm/msm/msm_gpu.h                  |  114 ++
 drivers/gpu/drm/msm/msm_ringbuffer.c           |   61 +
 drivers/gpu/drm/msm/msm_ringbuffer.h           |   43 +
 include/uapi/drm/Kbuild                        |    1 +
 include/uapi/drm/msm_drm.h                     |  207 +++
 47 files changed, 14763 insertions(+)
 create mode 100644 drivers/gpu/drm/msm/Kconfig
 create mode 100644 drivers/gpu/drm/msm/Makefile
 create mode 100644 drivers/gpu/drm/msm/NOTES
 create mode 100644 drivers/gpu/drm/msm/adreno/a2xx.xml.h
 create mode 100644 drivers/gpu/drm/msm/adreno/a3xx.xml.h
 create mode 100644 drivers/gpu/drm/msm/adreno/a3xx_gpu.c
 create mode 100644 drivers/gpu/drm/msm/adreno/a3xx_gpu.h
 create mode 100644 drivers/gpu/drm/msm/adreno/adreno_common.xml.h
 create mode 100644 drivers/gpu/drm/msm/adreno/adreno_gpu.c
 create mode 100644 drivers/gpu/drm/msm/adreno/adreno_gpu.h
 create mode 100644 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h
 create mode 100644 drivers/gpu/drm/msm/dsi/dsi.xml.h
 create mode 100644 drivers/gpu/drm/msm/dsi/mmss_cc.xml.h
 create mode 100644 drivers/gpu/drm/msm/dsi/sfpb.xml.h
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi.c
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi.h
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi.xml.h
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi_connector.c
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi_phy_8960.c
 create mode 100644 drivers/gpu/drm/msm/hdmi/hdmi_phy_8x60.c
 create mode 100644 drivers/gpu/drm/msm/hdmi/qfprom.xml.h
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4.xml.h
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_crtc.c
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_dtv_encoder.c
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_format.c
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_irq.c
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_kms.c
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_kms.h
 create mode 100644 drivers/gpu/drm/msm/mdp4/mdp4_plane.c
 create mode 100644 drivers/gpu/drm/msm/msm_connector.c
 create mode 100644 drivers/gpu/drm/msm/msm_connector.h
 create mode 100644 drivers/gpu/drm/msm/msm_drv.c
 create mode 100644 drivers/gpu/drm/msm/msm_drv.h
 create mode 100644 drivers/gpu/drm/msm/msm_fb.c
 create mode 100644 drivers/gpu/drm/msm/msm_fbdev.c
 create mode 100644 drivers/gpu/drm/msm/msm_gem.c
 create mode 100644 drivers/gpu/drm/msm/msm_gem.h
 create mode 100644 drivers/gpu/drm/msm/msm_gem_submit.c
 create mode 100644 drivers/gpu/drm/msm/msm_gpu.c
 create mode 100644 drivers/gpu/drm/msm/msm_gpu.h
 create mode 100644 drivers/gpu/drm/msm/msm_ringbuffer.c
 create mode 100644 drivers/gpu/drm/msm/msm_ringbuffer.h
 create mode 100644 include/uapi/drm/msm_drm.h


More information about the dri-devel mailing list