]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/drm/drm_simple_kms_helper.h
bridge: Elaborate a bit on dumb VGA bridges in Kconfig
[mirror_ubuntu-eoan-kernel.git] / include / drm / drm_simple_kms_helper.h
CommitLineData
5b809074
NT
1/*
2 * Copyright (C) 2016 Noralf Trønnes
3 *
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.
8 */
9
10#ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H
11#define __LINUX_DRM_SIMPLE_KMS_HELPER_H
12
a6a9534c
NT
13#include <drm/drm_crtc.h>
14#include <drm/drm_encoder.h>
15#include <drm/drm_plane.h>
16
5b809074
NT
17struct drm_simple_display_pipe;
18
19/**
20 * struct drm_simple_display_pipe_funcs - helper operations for a simple
21 * display pipeline
22 */
23struct drm_simple_display_pipe_funcs {
40275dc4
LW
24 /**
25 * @mode_valid:
26 *
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.
30 *
31 * RETURNS:
32 *
33 * drm_mode_status Enum
34 */
35 enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
36 const struct drm_display_mode *mode);
37
5b809074
NT
38 /**
39 * @enable:
40 *
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.
44 */
45 void (*enable)(struct drm_simple_display_pipe *pipe,
46 struct drm_crtc_state *crtc_state);
47 /**
48 * @disable:
49 *
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.
53 */
54 void (*disable)(struct drm_simple_display_pipe *pipe);
55
56 /**
57 * @check:
58 *
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.
65 *
66 * RETURNS:
67 *
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
71 * deadlock.
72 */
73 int (*check)(struct drm_simple_display_pipe *pipe,
74 struct drm_plane_state *plane_state,
75 struct drm_crtc_state *crtc_state);
76 /**
77 * @update:
78 *
79 * This function is called when the underlying plane state is updated.
80 * This hook is optional.
6dcf0de7
DV
81 *
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.
5b809074
NT
87 */
88 void (*update)(struct drm_simple_display_pipe *pipe,
bcd2ba02 89 struct drm_plane_state *old_plane_state);
7d83a155
MV
90
91 /**
92 * @prepare_fb:
93 *
6806cdf9
DV
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
96 * more details.
7d83a155
MV
97 */
98 int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
99 struct drm_plane_state *plane_state);
100
101 /**
102 * @cleanup_fb:
103 *
6806cdf9
DV
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
106 * more details.
7d83a155
MV
107 */
108 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
109 struct drm_plane_state *plane_state);
ac86cba9
OA
110
111 /**
112 * @enable_vblank:
113 *
114 * Optional, called by &drm_crtc_funcs.enable_vblank. Please read
115 * the documentation for the &drm_crtc_funcs.enable_vblank hook for
116 * more details.
117 */
118 int (*enable_vblank)(struct drm_simple_display_pipe *pipe);
119
120 /**
121 * @disable_vblank:
122 *
123 * Optional, called by &drm_crtc_funcs.disable_vblank. Please read
124 * the documentation for the &drm_crtc_funcs.disable_vblank hook for
125 * more details.
126 */
127 void (*disable_vblank)(struct drm_simple_display_pipe *pipe);
5b809074
NT
128};
129
130/**
131 * struct drm_simple_display_pipe - simple display pipeline
132 * @crtc: CRTC control structure
133 * @plane: Plane control structure
134 * @encoder: Encoder control structure
135 * @connector: Connector control structure
136 * @funcs: Pipeline control functions (optional)
137 *
138 * Simple display pipeline with plane, crtc and encoder collapsed into one
139 * entity. It should be initialized by calling drm_simple_display_pipe_init().
140 */
141struct drm_simple_display_pipe {
142 struct drm_crtc crtc;
143 struct drm_plane plane;
144 struct drm_encoder encoder;
145 struct drm_connector *connector;
146
147 const struct drm_simple_display_pipe_funcs *funcs;
148};
149
315486c6
AM
150int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
151 struct drm_bridge *bridge);
152
5b809074
NT
153int drm_simple_display_pipe_init(struct drm_device *dev,
154 struct drm_simple_display_pipe *pipe,
155 const struct drm_simple_display_pipe_funcs *funcs,
156 const uint32_t *formats, unsigned int format_count,
e6fc3b68 157 const uint64_t *format_modifiers,
5b809074
NT
158 struct drm_connector *connector);
159
160#endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */