Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panel: add .prepare() and .unprepare() functions

Panels often require an initialization sequence that consists of three
steps: a) powering up the panel, b) starting transmission of video data
and c) enabling the panel (e.g. turn on backlight). This is usually
necessary to avoid visual glitches at the beginning of video data
transmission.

Similarly, the shutdown sequence is typically done in three steps as
well: a) disable the panel (e.g. turn off backlight), b) cease video
data transmission and c) power down the panel.

Currently drivers can only implement .enable() and .disable() functions,
which is not enough to implement the above sequences. This commit adds a
second pair of functions, .prepare() and .unprepare() to allow more
fine-grained control over when the above steps are performed.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
[treding: rewrite changelog, add kerneldoc]
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Ajay Kumar and committed by
Thierry Reding
45527d43 81cf32b2

+50
+50
include/drm/drm_panel.h
··· 30 30 struct drm_device; 31 31 struct drm_panel; 32 32 33 + /** 34 + * struct drm_panel_funcs - perform operations on a given panel 35 + * @disable: disable panel (turn off back light, etc.) 36 + * @unprepare: turn off panel 37 + * @prepare: turn on panel and perform set up 38 + * @enable: enable panel (turn on back light, etc.) 39 + * @get_modes: add modes to the connector that the panel is attached to and 40 + * return the number of modes added 41 + * 42 + * The .prepare() function is typically called before the display controller 43 + * starts to transmit video data. Panel drivers can use this to turn the panel 44 + * on and wait for it to become ready. If additional configuration is required 45 + * (via a control bus such as I2C, SPI or DSI for example) this is a good time 46 + * to do that. 47 + * 48 + * After the display controller has started transmitting video data, it's safe 49 + * to call the .enable() function. This will typically enable the backlight to 50 + * make the image on screen visible. Some panels require a certain amount of 51 + * time or frames before the image is displayed. This function is responsible 52 + * for taking this into account before enabling the backlight to avoid visual 53 + * glitches. 54 + * 55 + * Before stopping video transmission from the display controller it can be 56 + * necessary to turn off the panel to avoid visual glitches. This is done in 57 + * the .disable() function. Analogously to .enable() this typically involves 58 + * turning off the backlight and waiting for some time to make sure no image 59 + * is visible on the panel. It is then safe for the display controller to 60 + * cease transmission of video data. 61 + * 62 + * To save power when no video data is transmitted, a driver can power down 63 + * the panel. This is the job of the .unprepare() function. 64 + */ 33 65 struct drm_panel_funcs { 34 66 int (*disable)(struct drm_panel *panel); 67 + int (*unprepare)(struct drm_panel *panel); 68 + int (*prepare)(struct drm_panel *panel); 35 69 int (*enable)(struct drm_panel *panel); 36 70 int (*get_modes)(struct drm_panel *panel); 37 71 }; ··· 80 46 struct list_head list; 81 47 }; 82 48 49 + static inline int drm_panel_unprepare(struct drm_panel *panel) 50 + { 51 + if (panel && panel->funcs && panel->funcs->unprepare) 52 + return panel->funcs->unprepare(panel); 53 + 54 + return panel ? -ENOSYS : -EINVAL; 55 + } 56 + 83 57 static inline int drm_panel_disable(struct drm_panel *panel) 84 58 { 85 59 if (panel && panel->funcs && panel->funcs->disable) 86 60 return panel->funcs->disable(panel); 61 + 62 + return panel ? -ENOSYS : -EINVAL; 63 + } 64 + 65 + static inline int drm_panel_prepare(struct drm_panel *panel) 66 + { 67 + if (panel && panel->funcs && panel->funcs->prepare) 68 + return panel->funcs->prepare(panel); 87 69 88 70 return panel ? -ENOSYS : -EINVAL; 89 71 }