2 * Copyright (C) 2016 Noralf Trønnes
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
10 #ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H
11 #define __LINUX_DRM_SIMPLE_KMS_HELPER_H
13 #include <drm/drm_crtc.h>
14 #include <drm/drm_encoder.h>
15 #include <drm/drm_plane.h>
17 struct drm_simple_display_pipe;
20 * struct drm_simple_display_pipe_funcs - helper operations for a simple
23 struct drm_simple_display_pipe_funcs {
27 * This function is called to filter out valid modes from the
28 * suggestions suggested by the bridge or display. This optional
29 * hook is passed in when initializing the pipeline.
33 * drm_mode_status Enum
35 enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
36 const struct drm_display_mode *mode);
41 * This function should be used to enable the pipeline.
42 * It is called when the underlying crtc is enabled.
43 * This hook is optional.
45 void (*enable)(struct drm_simple_display_pipe *pipe,
46 struct drm_crtc_state *crtc_state);
50 * This function should be used to disable the pipeline.
51 * It is called when the underlying crtc is disabled.
52 * This hook is optional.
54 void (*disable)(struct drm_simple_display_pipe *pipe);
59 * This function is called in the check phase of an atomic update,
60 * specifically when the underlying plane is checked.
61 * The simple display pipeline helpers already check that the plane is
62 * not scaled, fills the entire visible area and is always enabled
63 * when the crtc is also enabled.
64 * This hook is optional.
68 * 0 on success, -EINVAL if the state or the transition can't be
69 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
70 * attempt to obtain another state object ran into a &drm_modeset_lock
73 int (*check)(struct drm_simple_display_pipe *pipe,
74 struct drm_plane_state *plane_state,
75 struct drm_crtc_state *crtc_state);
79 * This function is called when the underlying plane state is updated.
80 * This hook is optional.
82 * This is the function drivers should submit the
83 * &drm_pending_vblank_event from. Using either
84 * drm_crtc_arm_vblank_event(), when the driver supports vblank
85 * interrupt handling, or drm_crtc_send_vblank_event() directly in case
86 * the hardware lacks vblank support entirely.
88 void (*update)(struct drm_simple_display_pipe *pipe,
89 struct drm_plane_state *old_plane_state);
94 * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read
95 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
98 int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
99 struct drm_plane_state *plane_state);
104 * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read
105 * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
108 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
109 struct drm_plane_state *plane_state);
113 * struct drm_simple_display_pipe - simple display pipeline
114 * @crtc: CRTC control structure
115 * @plane: Plane control structure
116 * @encoder: Encoder control structure
117 * @connector: Connector control structure
118 * @funcs: Pipeline control functions (optional)
120 * Simple display pipeline with plane, crtc and encoder collapsed into one
121 * entity. It should be initialized by calling drm_simple_display_pipe_init().
123 struct drm_simple_display_pipe {
124 struct drm_crtc crtc;
125 struct drm_plane plane;
126 struct drm_encoder encoder;
127 struct drm_connector *connector;
129 const struct drm_simple_display_pipe_funcs *funcs;
132 int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
133 struct drm_bridge *bridge);
135 int drm_simple_display_pipe_init(struct drm_device *dev,
136 struct drm_simple_display_pipe *pipe,
137 const struct drm_simple_display_pipe_funcs *funcs,
138 const uint32_t *formats, unsigned int format_count,
139 const uint64_t *format_modifiers,
140 struct drm_connector *connector);
142 #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */