18c2ecf20Sopenharmony_ciNOTES about msm drm/kms driver:
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciIn the current snapdragon SoC's, we have (at least) 3 different
48c2ecf20Sopenharmony_cidisplay controller blocks at play:
58c2ecf20Sopenharmony_ci + MDP3 - ?? seems to be what is on geeksphone peak device
68c2ecf20Sopenharmony_ci + MDP4 - S3 (APQ8060, touchpad), S4-pro (APQ8064, nexus4 & ifc6410)
78c2ecf20Sopenharmony_ci + MDP5 - snapdragon 800
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci(I don't have a completely clear picture on which display controller
108c2ecf20Sopenharmony_cimaps to which part #)
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciPlus a handful of blocks around them for HDMI/DSI/etc output.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciAnd on gpu side of things:
158c2ecf20Sopenharmony_ci + zero, one, or two 2d cores (z180)
168c2ecf20Sopenharmony_ci + and either a2xx or a3xx 3d core.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciBut, HDMI/DSI/etc blocks seem like they can be shared across multiple
198c2ecf20Sopenharmony_cidisplay controller blocks.  And I for sure don't want to have to deal
208c2ecf20Sopenharmony_ciwith N different kms devices from xf86-video-freedreno.  Plus, it
218c2ecf20Sopenharmony_ciseems like we can do some clever tricks like use GPU to trigger
228c2ecf20Sopenharmony_cipageflip after rendering completes (ie. have the kms/crtc code build
238c2ecf20Sopenharmony_ciup gpu cmdstream to update scanout and write FLUSH register after).
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciSo, the approach is one drm driver, with some modularity.  Different
268c2ecf20Sopenharmony_ci'struct msm_kms' implementations, depending on display controller.
278c2ecf20Sopenharmony_ciAnd one or more 'struct msm_gpu' for the various different gpu sub-
288c2ecf20Sopenharmony_cimodules.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci(Second part is not implemented yet.  So far this is just basic KMS
318c2ecf20Sopenharmony_cidriver, and not exposing any custom ioctls to userspace for now.)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciThe kms module provides the plane, crtc, and encoder objects, and
348c2ecf20Sopenharmony_ciloads whatever connectors are appropriate.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciFor MDP4, the mapping is:
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci  plane   -> PIPE{RGBn,VGn}              \
398c2ecf20Sopenharmony_ci  crtc    -> OVLP{n} + DMA{P,S,E} (??)   |-> MDP "device"
408c2ecf20Sopenharmony_ci  encoder -> DTV/LCDC/DSI (within MDP4)  /
418c2ecf20Sopenharmony_ci  connector -> HDMI/DSI/etc              --> other device(s)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciSince the irq's that drm core mostly cares about are vblank/framedone,
448c2ecf20Sopenharmony_ciwe'll let msm_mdp4_kms provide the irq install/uninstall/etc functions
458c2ecf20Sopenharmony_ciand treat the MDP4 block's irq as "the" irq.  Even though the connectors
468c2ecf20Sopenharmony_cimay have their own irqs which they install themselves.  For this reason
478c2ecf20Sopenharmony_cithe display controller is the "master" device.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciFor MDP5, the mapping is:
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci  plane   -> PIPE{RGBn,VIGn}             \
528c2ecf20Sopenharmony_ci  crtc    -> LM (layer mixer)            |-> MDP "device"
538c2ecf20Sopenharmony_ci  encoder -> INTF                        /
548c2ecf20Sopenharmony_ci  connector -> HDMI/DSI/eDP/etc          --> other device(s)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciUnlike MDP4, it appears we can get by with a single encoder, rather
578c2ecf20Sopenharmony_cithan needing a different implementation for DTV, DSI, etc.  (Ie. the
588c2ecf20Sopenharmony_ciregister interface is same, just different bases.)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciAlso unlike MDP4, with MDP5 all the IRQs for other blocks (HDMI, DSI,
618c2ecf20Sopenharmony_cietc) are routed through MDP.
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciAnd finally, MDP5 has this "Shared Memory Pool" (called "SMP"), from
648c2ecf20Sopenharmony_ciwhich blocks need to be allocated to the active pipes based on fetch
658c2ecf20Sopenharmony_cistride.
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciEach connector probably ends up being a separate device, just for the
688c2ecf20Sopenharmony_cilogistics of finding/mapping io region, irq, etc.  Idealy we would
698c2ecf20Sopenharmony_cihave a better way than just stashing the platform device in a global
708c2ecf20Sopenharmony_ci(ie. like DT super-node.. but I don't have any snapdragon hw yet that
718c2ecf20Sopenharmony_ciis using DT).
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ciNote that so far I've not been able to get any docs on the hw, and it
748c2ecf20Sopenharmony_ciseems that access to such docs would prevent me from working on the
758c2ecf20Sopenharmony_cifreedreno gallium driver.  So there may be some mistakes in register
768c2ecf20Sopenharmony_cinames (I had to invent a few, since no sufficient hint was given in
778c2ecf20Sopenharmony_cithe downstream android fbdev driver), bitfield sizes, etc.  My current
788c2ecf20Sopenharmony_cistate of understanding the registers is given in the envytools rnndb
798c2ecf20Sopenharmony_cifiles at:
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci  https://github.com/freedreno/envytools/tree/master/rnndb
828c2ecf20Sopenharmony_ci  (the mdp4/hdmi/dsi directories)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciThese files are used both for a parser tool (in the same tree) to
858c2ecf20Sopenharmony_ciparse logged register reads/writes (both from downstream android fbdev
868c2ecf20Sopenharmony_cidriver, and this driver with register logging enabled), as well as to
878c2ecf20Sopenharmony_cigenerate the register level headers.
88