162306a36Sopenharmony_ciNOTES about msm drm/kms driver:
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciIn the current snapdragon SoC's, we have (at least) 3 different
462306a36Sopenharmony_cidisplay controller blocks at play:
562306a36Sopenharmony_ci + MDP3 - ?? seems to be what is on geeksphone peak device
662306a36Sopenharmony_ci + MDP4 - S3 (APQ8060, touchpad), S4-pro (APQ8064, nexus4 & ifc6410)
762306a36Sopenharmony_ci + MDP5 - snapdragon 800
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci(I don't have a completely clear picture on which display controller
1062306a36Sopenharmony_cimaps to which part #)
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciPlus a handful of blocks around them for HDMI/DSI/etc output.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciAnd on gpu side of things:
1562306a36Sopenharmony_ci + zero, one, or two 2d cores (z180)
1662306a36Sopenharmony_ci + and either a2xx or a3xx 3d core.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciBut, HDMI/DSI/etc blocks seem like they can be shared across multiple
1962306a36Sopenharmony_cidisplay controller blocks.  And I for sure don't want to have to deal
2062306a36Sopenharmony_ciwith N different kms devices from xf86-video-freedreno.  Plus, it
2162306a36Sopenharmony_ciseems like we can do some clever tricks like use GPU to trigger
2262306a36Sopenharmony_cipageflip after rendering completes (ie. have the kms/crtc code build
2362306a36Sopenharmony_ciup gpu cmdstream to update scanout and write FLUSH register after).
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciSo, the approach is one drm driver, with some modularity.  Different
2662306a36Sopenharmony_ci'struct msm_kms' implementations, depending on display controller.
2762306a36Sopenharmony_ciAnd one or more 'struct msm_gpu' for the various different gpu sub-
2862306a36Sopenharmony_cimodules.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci(Second part is not implemented yet.  So far this is just basic KMS
3162306a36Sopenharmony_cidriver, and not exposing any custom ioctls to userspace for now.)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciThe kms module provides the plane, crtc, and encoder objects, and
3462306a36Sopenharmony_ciloads whatever connectors are appropriate.
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciFor MDP4, the mapping is:
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci  plane   -> PIPE{RGBn,VGn}              \
3962306a36Sopenharmony_ci  crtc    -> OVLP{n} + DMA{P,S,E} (??)   |-> MDP "device"
4062306a36Sopenharmony_ci  encoder -> DTV/LCDC/DSI (within MDP4)  /
4162306a36Sopenharmony_ci  connector -> HDMI/DSI/etc              --> other device(s)
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciSince the irq's that drm core mostly cares about are vblank/framedone,
4462306a36Sopenharmony_ciwe'll let msm_mdp4_kms provide the irq install/uninstall/etc functions
4562306a36Sopenharmony_ciand treat the MDP4 block's irq as "the" irq.  Even though the connectors
4662306a36Sopenharmony_cimay have their own irqs which they install themselves.  For this reason
4762306a36Sopenharmony_cithe display controller is the "master" device.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciFor MDP5, the mapping is:
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci  plane   -> PIPE{RGBn,VIGn}             \
5262306a36Sopenharmony_ci  crtc    -> LM (layer mixer)            |-> MDP "device"
5362306a36Sopenharmony_ci  encoder -> INTF                        /
5462306a36Sopenharmony_ci  connector -> HDMI/DSI/eDP/etc          --> other device(s)
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciUnlike MDP4, it appears we can get by with a single encoder, rather
5762306a36Sopenharmony_cithan needing a different implementation for DTV, DSI, etc.  (Ie. the
5862306a36Sopenharmony_ciregister interface is same, just different bases.)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciAlso unlike MDP4, with MDP5 all the IRQs for other blocks (HDMI, DSI,
6162306a36Sopenharmony_cietc) are routed through MDP.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciAnd finally, MDP5 has this "Shared Memory Pool" (called "SMP"), from
6462306a36Sopenharmony_ciwhich blocks need to be allocated to the active pipes based on fetch
6562306a36Sopenharmony_cistride.
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ciEach connector probably ends up being a separate device, just for the
6862306a36Sopenharmony_cilogistics of finding/mapping io region, irq, etc.  Idealy we would
6962306a36Sopenharmony_cihave a better way than just stashing the platform device in a global
7062306a36Sopenharmony_ci(ie. like DT super-node.. but I don't have any snapdragon hw yet that
7162306a36Sopenharmony_ciis using DT).
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciNote that so far I've not been able to get any docs on the hw, and it
7462306a36Sopenharmony_ciseems that access to such docs would prevent me from working on the
7562306a36Sopenharmony_cifreedreno gallium driver.  So there may be some mistakes in register
7662306a36Sopenharmony_cinames (I had to invent a few, since no sufficient hint was given in
7762306a36Sopenharmony_cithe downstream android fbdev driver), bitfield sizes, etc.  My current
7862306a36Sopenharmony_cistate of understanding the registers is given in the envytools rnndb
7962306a36Sopenharmony_cifiles at:
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci  https://github.com/freedreno/envytools/tree/master/rnndb
8262306a36Sopenharmony_ci  (the mdp4/hdmi/dsi directories)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciThese files are used both for a parser tool (in the same tree) to
8562306a36Sopenharmony_ciparse logged register reads/writes (both from downstream android fbdev
8662306a36Sopenharmony_cidriver, and this driver with register logging enabled), as well as to
8762306a36Sopenharmony_cigenerate the register level headers.
88