xref: /linux/include/drm/drm_simple_kms_helper.h (revision 6806cdf9aa1c822afd89881e48908315aed18451)
15b809074SNoralf Trønnes /*
25b809074SNoralf Trønnes  * Copyright (C) 2016 Noralf Trønnes
35b809074SNoralf Trønnes  *
45b809074SNoralf Trønnes  * This program is free software; you can redistribute it and/or modify
55b809074SNoralf Trønnes  * it under the terms of the GNU General Public License as published by
65b809074SNoralf Trønnes  * the Free Software Foundation; either version 2 of the License, or
75b809074SNoralf Trønnes  * (at your option) any later version.
85b809074SNoralf Trønnes  */
95b809074SNoralf Trønnes 
105b809074SNoralf Trønnes #ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H
115b809074SNoralf Trønnes #define __LINUX_DRM_SIMPLE_KMS_HELPER_H
125b809074SNoralf Trønnes 
13a6a9534cSNoralf Trønnes #include <drm/drm_crtc.h>
14a6a9534cSNoralf Trønnes #include <drm/drm_encoder.h>
15a6a9534cSNoralf Trønnes #include <drm/drm_plane.h>
16a6a9534cSNoralf Trønnes 
175b809074SNoralf Trønnes struct drm_simple_display_pipe;
185b809074SNoralf Trønnes 
195b809074SNoralf Trønnes /**
205b809074SNoralf Trønnes  * struct drm_simple_display_pipe_funcs - helper operations for a simple
215b809074SNoralf Trønnes  *                                        display pipeline
225b809074SNoralf Trønnes  */
235b809074SNoralf Trønnes struct drm_simple_display_pipe_funcs {
245b809074SNoralf Trønnes 	/**
255b809074SNoralf Trønnes 	 * @enable:
265b809074SNoralf Trønnes 	 *
275b809074SNoralf Trønnes 	 * This function should be used to enable the pipeline.
285b809074SNoralf Trønnes 	 * It is called when the underlying crtc is enabled.
295b809074SNoralf Trønnes 	 * This hook is optional.
305b809074SNoralf Trønnes 	 */
315b809074SNoralf Trønnes 	void (*enable)(struct drm_simple_display_pipe *pipe,
325b809074SNoralf Trønnes 		       struct drm_crtc_state *crtc_state);
335b809074SNoralf Trønnes 	/**
345b809074SNoralf Trønnes 	 * @disable:
355b809074SNoralf Trønnes 	 *
365b809074SNoralf Trønnes 	 * This function should be used to disable the pipeline.
375b809074SNoralf Trønnes 	 * It is called when the underlying crtc is disabled.
385b809074SNoralf Trønnes 	 * This hook is optional.
395b809074SNoralf Trønnes 	 */
405b809074SNoralf Trønnes 	void (*disable)(struct drm_simple_display_pipe *pipe);
415b809074SNoralf Trønnes 
425b809074SNoralf Trønnes 	/**
435b809074SNoralf Trønnes 	 * @check:
445b809074SNoralf Trønnes 	 *
455b809074SNoralf Trønnes 	 * This function is called in the check phase of an atomic update,
465b809074SNoralf Trønnes 	 * specifically when the underlying plane is checked.
475b809074SNoralf Trønnes 	 * The simple display pipeline helpers already check that the plane is
485b809074SNoralf Trønnes 	 * not scaled, fills the entire visible area and is always enabled
495b809074SNoralf Trønnes 	 * when the crtc is also enabled.
505b809074SNoralf Trønnes 	 * This hook is optional.
515b809074SNoralf Trønnes 	 *
525b809074SNoralf Trønnes 	 * RETURNS:
535b809074SNoralf Trønnes 	 *
545b809074SNoralf Trønnes 	 * 0 on success, -EINVAL if the state or the transition can't be
555b809074SNoralf Trønnes 	 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
565b809074SNoralf Trønnes 	 * attempt to obtain another state object ran into a &drm_modeset_lock
575b809074SNoralf Trønnes 	 * deadlock.
585b809074SNoralf Trønnes 	 */
595b809074SNoralf Trønnes 	int (*check)(struct drm_simple_display_pipe *pipe,
605b809074SNoralf Trønnes 		     struct drm_plane_state *plane_state,
615b809074SNoralf Trønnes 		     struct drm_crtc_state *crtc_state);
625b809074SNoralf Trønnes 	/**
635b809074SNoralf Trønnes 	 * @update:
645b809074SNoralf Trønnes 	 *
655b809074SNoralf Trønnes 	 * This function is called when the underlying plane state is updated.
665b809074SNoralf Trønnes 	 * This hook is optional.
676dcf0de7SDaniel Vetter 	 *
686dcf0de7SDaniel Vetter 	 * This is the function drivers should submit the
696dcf0de7SDaniel Vetter 	 * &drm_pending_vblank_event from. Using either
706dcf0de7SDaniel Vetter 	 * drm_crtc_arm_vblank_event(), when the driver supports vblank
716dcf0de7SDaniel Vetter 	 * interrupt handling, or drm_crtc_send_vblank_event() directly in case
726dcf0de7SDaniel Vetter 	 * the hardware lacks vblank support entirely.
735b809074SNoralf Trønnes 	 */
745b809074SNoralf Trønnes 	void (*update)(struct drm_simple_display_pipe *pipe,
755b809074SNoralf Trønnes 		       struct drm_plane_state *plane_state);
767d83a155SMarek Vasut 
777d83a155SMarek Vasut 	/**
787d83a155SMarek Vasut 	 * @prepare_fb:
797d83a155SMarek Vasut 	 *
80*6806cdf9SDaniel Vetter 	 * Optional, called by &drm_plane_helper_funcs.prepare_fb.  Please read
81*6806cdf9SDaniel Vetter 	 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
82*6806cdf9SDaniel Vetter 	 * more details.
837d83a155SMarek Vasut 	 */
847d83a155SMarek Vasut 	int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
857d83a155SMarek Vasut 			  struct drm_plane_state *plane_state);
867d83a155SMarek Vasut 
877d83a155SMarek Vasut 	/**
887d83a155SMarek Vasut 	 * @cleanup_fb:
897d83a155SMarek Vasut 	 *
90*6806cdf9SDaniel Vetter 	 * Optional, called by &drm_plane_helper_funcs.cleanup_fb.  Please read
91*6806cdf9SDaniel Vetter 	 * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
92*6806cdf9SDaniel Vetter 	 * more details.
937d83a155SMarek Vasut 	 */
947d83a155SMarek Vasut 	void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
957d83a155SMarek Vasut 			   struct drm_plane_state *plane_state);
965b809074SNoralf Trønnes };
975b809074SNoralf Trønnes 
985b809074SNoralf Trønnes /**
995b809074SNoralf Trønnes  * struct drm_simple_display_pipe - simple display pipeline
1005b809074SNoralf Trønnes  * @crtc: CRTC control structure
1015b809074SNoralf Trønnes  * @plane: Plane control structure
1025b809074SNoralf Trønnes  * @encoder: Encoder control structure
1035b809074SNoralf Trønnes  * @connector: Connector control structure
1045b809074SNoralf Trønnes  * @funcs: Pipeline control functions (optional)
1055b809074SNoralf Trønnes  *
1065b809074SNoralf Trønnes  * Simple display pipeline with plane, crtc and encoder collapsed into one
1075b809074SNoralf Trønnes  * entity. It should be initialized by calling drm_simple_display_pipe_init().
1085b809074SNoralf Trønnes  */
1095b809074SNoralf Trønnes struct drm_simple_display_pipe {
1105b809074SNoralf Trønnes 	struct drm_crtc crtc;
1115b809074SNoralf Trønnes 	struct drm_plane plane;
1125b809074SNoralf Trønnes 	struct drm_encoder encoder;
1135b809074SNoralf Trønnes 	struct drm_connector *connector;
1145b809074SNoralf Trønnes 
1155b809074SNoralf Trønnes 	const struct drm_simple_display_pipe_funcs *funcs;
1165b809074SNoralf Trønnes };
1175b809074SNoralf Trønnes 
118315486c6SAndrea Merello int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
119315486c6SAndrea Merello 					  struct drm_bridge *bridge);
120315486c6SAndrea Merello 
1215b809074SNoralf Trønnes int drm_simple_display_pipe_init(struct drm_device *dev,
1225b809074SNoralf Trønnes 			struct drm_simple_display_pipe *pipe,
1235b809074SNoralf Trønnes 			const struct drm_simple_display_pipe_funcs *funcs,
1245b809074SNoralf Trønnes 			const uint32_t *formats, unsigned int format_count,
1255b809074SNoralf Trønnes 			struct drm_connector *connector);
1265b809074SNoralf Trønnes 
1275b809074SNoralf Trønnes #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */
128