]>
Commit | Line | Data |
---|---|---|
52217195 DV |
1 | /* |
2 | * Copyright (c) 2016 Intel Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, distribute, and sell this software and its | |
5 | * documentation for any purpose is hereby granted without fee, provided that | |
6 | * the above copyright notice appear in all copies and that both that copyright | |
7 | * notice and this permission notice appear in supporting documentation, and | |
8 | * that the name of the copyright holders not be used in advertising or | |
9 | * publicity pertaining to distribution of the software without specific, | |
10 | * written prior permission. The copyright holders make no representations | |
11 | * about the suitability of this software for any purpose. It is provided "as | |
12 | * is" without express or implied warranty. | |
13 | * | |
14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
20 | * OF THIS SOFTWARE. | |
21 | */ | |
22 | ||
23 | #ifndef __DRM_CONNECTOR_H__ | |
24 | #define __DRM_CONNECTOR_H__ | |
25 | ||
26 | #include <linux/list.h> | |
ea497bb9 | 27 | #include <linux/llist.h> |
52217195 | 28 | #include <linux/ctype.h> |
0e9f25d0 | 29 | #include <linux/hdmi.h> |
949619f3 | 30 | #include <drm/drm_mode_object.h> |
d78aa650 | 31 | #include <drm/drm_util.h> |
52217195 | 32 | |
199e4e96 DV |
33 | #include <uapi/drm/drm_mode.h> |
34 | ||
52217195 | 35 | struct drm_connector_helper_funcs; |
6c5ed5ae | 36 | struct drm_modeset_acquire_ctx; |
52217195 DV |
37 | struct drm_device; |
38 | struct drm_crtc; | |
39 | struct drm_encoder; | |
40 | struct drm_property; | |
41 | struct drm_property_blob; | |
fceffb32 | 42 | struct drm_printer; |
52217195 DV |
43 | struct edid; |
44 | ||
45 | enum drm_connector_force { | |
46 | DRM_FORCE_UNSPECIFIED, | |
47 | DRM_FORCE_OFF, | |
48 | DRM_FORCE_ON, /* force on analog part normally */ | |
49 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ | |
50 | }; | |
51 | ||
ae2a6da8 DV |
52 | /** |
53 | * enum drm_connector_status - status for a &drm_connector | |
54 | * | |
55 | * This enum is used to track the connector status. There are no separate | |
56 | * #defines for the uapi! | |
57 | */ | |
52217195 | 58 | enum drm_connector_status { |
ae2a6da8 DV |
59 | /** |
60 | * @connector_status_connected: The connector is definitely connected to | |
61 | * a sink device, and can be enabled. | |
62 | */ | |
52217195 | 63 | connector_status_connected = 1, |
ae2a6da8 DV |
64 | /** |
65 | * @connector_status_disconnected: The connector isn't connected to a | |
66 | * sink device which can be autodetect. For digital outputs like DP or | |
67 | * HDMI (which can be realiable probed) this means there's really | |
68 | * nothing there. It is driver-dependent whether a connector with this | |
69 | * status can be lit up or not. | |
70 | */ | |
52217195 | 71 | connector_status_disconnected = 2, |
ae2a6da8 DV |
72 | /** |
73 | * @connector_status_unknown: The connector's status could not be | |
74 | * reliably detected. This happens when probing would either cause | |
75 | * flicker (like load-detection when the connector is in use), or when a | |
76 | * hardware resource isn't available (like when load-detection needs a | |
77 | * free CRTC). It should be possible to light up the connector with one | |
78 | * of the listed fallback modes. For default configuration userspace | |
79 | * should only try to light up connectors with unknown status when | |
80 | * there's not connector with @connector_status_connected. | |
81 | */ | |
52217195 DV |
82 | connector_status_unknown = 3, |
83 | }; | |
84 | ||
85 | enum subpixel_order { | |
86 | SubPixelUnknown = 0, | |
87 | SubPixelHorizontalRGB, | |
88 | SubPixelHorizontalBGR, | |
89 | SubPixelVerticalRGB, | |
90 | SubPixelVerticalBGR, | |
91 | SubPixelNone, | |
afa1c763 SS |
92 | |
93 | }; | |
94 | ||
62c58af3 SS |
95 | /** |
96 | * struct drm_scrambling: sink's scrambling support. | |
97 | */ | |
98 | struct drm_scrambling { | |
99 | /** | |
100 | * @supported: scrambling supported for rates > 340 Mhz. | |
101 | */ | |
102 | bool supported; | |
103 | /** | |
104 | * @low_rates: scrambling supported for rates <= 340 Mhz. | |
105 | */ | |
106 | bool low_rates; | |
107 | }; | |
108 | ||
afa1c763 SS |
109 | /* |
110 | * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink | |
111 | * | |
112 | * Provides SCDC register support and capabilities related information on a | |
113 | * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0. | |
114 | */ | |
115 | struct drm_scdc { | |
116 | /** | |
117 | * @supported: status control & data channel present. | |
118 | */ | |
119 | bool supported; | |
120 | /** | |
121 | * @read_request: sink is capable of generating scdc read request. | |
122 | */ | |
123 | bool read_request; | |
62c58af3 SS |
124 | /** |
125 | * @scrambling: sink's scrambling capabilities | |
126 | */ | |
127 | struct drm_scrambling scrambling; | |
afa1c763 SS |
128 | }; |
129 | ||
62c58af3 | 130 | |
afa1c763 SS |
131 | /** |
132 | * struct drm_hdmi_info - runtime information about the connected HDMI sink | |
133 | * | |
134 | * Describes if a given display supports advanced HDMI 2.0 features. | |
135 | * This information is available in CEA-861-F extension blocks (like HF-VSDB). | |
136 | */ | |
137 | struct drm_hdmi_info { | |
86cc921c | 138 | /** @scdc: sink's scdc support and capabilities */ |
afa1c763 | 139 | struct drm_scdc scdc; |
d8523153 SS |
140 | |
141 | /** | |
142 | * @y420_vdb_modes: bitmap of modes which can support ycbcr420 | |
143 | * output only (not normal RGB/YCBCR444/422 outputs). There are total | |
144 | * 107 VICs defined by CEA-861-F spec, so the size is 128 bits to map | |
145 | * upto 128 VICs; | |
146 | */ | |
147 | unsigned long y420_vdb_modes[BITS_TO_LONGS(128)]; | |
832d4f2f SS |
148 | |
149 | /** | |
150 | * @y420_cmdb_modes: bitmap of modes which can support ycbcr420 | |
151 | * output also, along with normal HDMI outputs. There are total 107 | |
152 | * VICs defined by CEA-861-F spec, so the size is 128 bits to map upto | |
153 | * 128 VICs; | |
154 | */ | |
155 | unsigned long y420_cmdb_modes[BITS_TO_LONGS(128)]; | |
156 | ||
157 | /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */ | |
158 | u64 y420_cmdb_map; | |
e6a9a2c3 SS |
159 | |
160 | /** @y420_dc_modes: bitmap of deep color support index */ | |
161 | u8 y420_dc_modes; | |
52217195 DV |
162 | }; |
163 | ||
40ee6fbe MN |
164 | /** |
165 | * enum drm_link_status - connector's link_status property value | |
166 | * | |
167 | * This enum is used as the connector's link status property value. | |
168 | * It is set to the values defined in uapi. | |
41232c1b MN |
169 | * |
170 | * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful | |
171 | * link training | |
172 | * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training | |
173 | * failure | |
40ee6fbe MN |
174 | */ |
175 | enum drm_link_status { | |
176 | DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD, | |
177 | DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD, | |
178 | }; | |
179 | ||
8d70f395 HG |
180 | /** |
181 | * enum drm_panel_orientation - panel_orientation info for &drm_display_info | |
182 | * | |
183 | * This enum is used to track the (LCD) panel orientation. There are no | |
184 | * separate #defines for the uapi! | |
185 | * | |
186 | * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any | |
187 | * panel orientation information (normal | |
188 | * for non panels) in this case the "panel | |
189 | * orientation" connector prop will not be | |
190 | * attached. | |
191 | * @DRM_MODE_PANEL_ORIENTATION_NORMAL: The top side of the panel matches the | |
192 | * top side of the device's casing. | |
193 | * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the | |
194 | * bottom side of the device's casing, iow | |
195 | * the panel is mounted upside-down. | |
196 | * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP: The left side of the panel matches the | |
197 | * top side of the device's casing. | |
198 | * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the | |
199 | * top side of the device's casing. | |
200 | */ | |
201 | enum drm_panel_orientation { | |
202 | DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1, | |
203 | DRM_MODE_PANEL_ORIENTATION_NORMAL = 0, | |
204 | DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP, | |
205 | DRM_MODE_PANEL_ORIENTATION_LEFT_UP, | |
206 | DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, | |
207 | }; | |
208 | ||
b3c6c8bf DV |
209 | /** |
210 | * struct drm_display_info - runtime data about the connected sink | |
211 | * | |
212 | * Describes a given display (e.g. CRT or flat panel) and its limitations. For | |
213 | * fixed display sinks like built-in panels there's not much difference between | |
ea0dd85a | 214 | * this and &struct drm_connector. But for sinks with a real cable this |
b3c6c8bf DV |
215 | * structure is meant to describe all the things at the other end of the cable. |
216 | * | |
217 | * For sinks which provide an EDID this can be filled out by calling | |
218 | * drm_add_edid_modes(). | |
52217195 DV |
219 | */ |
220 | struct drm_display_info { | |
b3c6c8bf DV |
221 | /** |
222 | * @name: Name of the display. | |
223 | */ | |
52217195 DV |
224 | char name[DRM_DISPLAY_INFO_LEN]; |
225 | ||
b3c6c8bf DV |
226 | /** |
227 | * @width_mm: Physical width in mm. | |
228 | */ | |
52217195 | 229 | unsigned int width_mm; |
b3c6c8bf DV |
230 | /** |
231 | * @height_mm: Physical height in mm. | |
232 | */ | |
52217195 DV |
233 | unsigned int height_mm; |
234 | ||
b3c6c8bf DV |
235 | /** |
236 | * @pixel_clock: Maximum pixel clock supported by the sink, in units of | |
188f7882 | 237 | * 100Hz. This mismatches the clock in &drm_display_mode (which is in |
b3c6c8bf DV |
238 | * kHZ), because that's what the EDID uses as base unit. |
239 | */ | |
52217195 | 240 | unsigned int pixel_clock; |
b3c6c8bf DV |
241 | /** |
242 | * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. | |
243 | */ | |
52217195 DV |
244 | unsigned int bpc; |
245 | ||
b3c6c8bf DV |
246 | /** |
247 | * @subpixel_order: Subpixel order of LCD panels. | |
248 | */ | |
52217195 DV |
249 | enum subpixel_order subpixel_order; |
250 | ||
251 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) | |
252 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) | |
253 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) | |
832d4f2f | 254 | #define DRM_COLOR_FORMAT_YCRCB420 (1<<3) |
52217195 | 255 | |
8d70f395 HG |
256 | /** |
257 | * @panel_orientation: Read only connector property for built-in panels, | |
258 | * indicating the orientation of the panel vs the device's casing. | |
259 | * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN. | |
260 | * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the | |
261 | * fb to compensate and gets exported as prop to userspace. | |
262 | */ | |
263 | int panel_orientation; | |
264 | ||
b3c6c8bf DV |
265 | /** |
266 | * @color_formats: HDMI Color formats, selects between RGB and YCrCb | |
267 | * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones | |
268 | * as used to describe the pixel format in framebuffers, and also don't | |
269 | * match the formats in @bus_formats which are shared with v4l. | |
270 | */ | |
52217195 DV |
271 | u32 color_formats; |
272 | ||
b3c6c8bf DV |
273 | /** |
274 | * @bus_formats: Pixel data format on the wire, somewhat redundant with | |
275 | * @color_formats. Array of size @num_bus_formats encoded using | |
276 | * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers. | |
277 | */ | |
52217195 | 278 | const u32 *bus_formats; |
b3c6c8bf DV |
279 | /** |
280 | * @num_bus_formats: Size of @bus_formats array. | |
281 | */ | |
52217195 DV |
282 | unsigned int num_bus_formats; |
283 | ||
284 | #define DRM_BUS_FLAG_DE_LOW (1<<0) | |
285 | #define DRM_BUS_FLAG_DE_HIGH (1<<1) | |
286 | /* drive data on pos. edge */ | |
287 | #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) | |
288 | /* drive data on neg. edge */ | |
289 | #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) | |
5ec1a960 LP |
290 | /* data is transmitted MSB to LSB on the bus */ |
291 | #define DRM_BUS_FLAG_DATA_MSB_TO_LSB (1<<4) | |
292 | /* data is transmitted LSB to MSB on the bus */ | |
293 | #define DRM_BUS_FLAG_DATA_LSB_TO_MSB (1<<5) | |
955f60db PU |
294 | /* drive sync on pos. edge */ |
295 | #define DRM_BUS_FLAG_SYNC_POSEDGE (1<<6) | |
296 | /* drive sync on neg. edge */ | |
297 | #define DRM_BUS_FLAG_SYNC_NEGEDGE (1<<7) | |
52217195 | 298 | |
b3c6c8bf DV |
299 | /** |
300 | * @bus_flags: Additional information (like pixel signal polarity) for | |
301 | * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines. | |
302 | */ | |
52217195 DV |
303 | u32 bus_flags; |
304 | ||
2a272ca9 VS |
305 | /** |
306 | * @max_tmds_clock: Maximum TMDS clock rate supported by the | |
307 | * sink in kHz. 0 means undefined. | |
308 | */ | |
309 | int max_tmds_clock; | |
310 | ||
311 | /** | |
312 | * @dvi_dual: Dual-link DVI sink? | |
313 | */ | |
314 | bool dvi_dual; | |
315 | ||
f1781e9b VS |
316 | /** |
317 | * @has_hdmi_infoframe: Does the sink support the HDMI infoframe? | |
318 | */ | |
319 | bool has_hdmi_infoframe; | |
320 | ||
b3c6c8bf DV |
321 | /** |
322 | * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even | |
323 | * more stuff redundant with @bus_formats. | |
324 | */ | |
52217195 DV |
325 | u8 edid_hdmi_dc_modes; |
326 | ||
b3c6c8bf DV |
327 | /** |
328 | * @cea_rev: CEA revision of the HDMI sink. | |
329 | */ | |
52217195 | 330 | u8 cea_rev; |
afa1c763 SS |
331 | |
332 | /** | |
333 | * @hdmi: advance features of a HDMI sink. | |
334 | */ | |
335 | struct drm_hdmi_info hdmi; | |
66660d4c DA |
336 | |
337 | /** | |
338 | * @non_desktop: Non desktop display (HMD). | |
339 | */ | |
340 | bool non_desktop; | |
52217195 DV |
341 | }; |
342 | ||
b3c6c8bf DV |
343 | int drm_display_info_set_bus_formats(struct drm_display_info *info, |
344 | const u32 *formats, | |
345 | unsigned int num_formats); | |
346 | ||
299a16b1 BB |
347 | /** |
348 | * struct drm_tv_connector_state - TV connector related states | |
349 | * @subconnector: selected subconnector | |
07d85290 JN |
350 | * @margins: margins |
351 | * @margins.left: left margin | |
352 | * @margins.right: right margin | |
353 | * @margins.top: top margin | |
354 | * @margins.bottom: bottom margin | |
299a16b1 BB |
355 | * @mode: TV mode |
356 | * @brightness: brightness in percent | |
357 | * @contrast: contrast in percent | |
358 | * @flicker_reduction: flicker reduction in percent | |
359 | * @overscan: overscan in percent | |
360 | * @saturation: saturation in percent | |
361 | * @hue: hue in percent | |
362 | */ | |
363 | struct drm_tv_connector_state { | |
364 | enum drm_mode_subconnector subconnector; | |
365 | struct { | |
366 | unsigned int left; | |
367 | unsigned int right; | |
368 | unsigned int top; | |
369 | unsigned int bottom; | |
370 | } margins; | |
371 | unsigned int mode; | |
372 | unsigned int brightness; | |
373 | unsigned int contrast; | |
374 | unsigned int flicker_reduction; | |
375 | unsigned int overscan; | |
376 | unsigned int saturation; | |
377 | unsigned int hue; | |
378 | }; | |
379 | ||
52217195 DV |
380 | /** |
381 | * struct drm_connector_state - mutable connector state | |
52217195 DV |
382 | */ |
383 | struct drm_connector_state { | |
aab999a6 | 384 | /** @connector: backpointer to the connector */ |
52217195 DV |
385 | struct drm_connector *connector; |
386 | ||
afb21ea6 DV |
387 | /** |
388 | * @crtc: CRTC to connect connector to, NULL if disabled. | |
389 | * | |
390 | * Do not change this directly, use drm_atomic_set_crtc_for_connector() | |
391 | * instead. | |
392 | */ | |
393 | struct drm_crtc *crtc; | |
52217195 | 394 | |
aab999a6 DV |
395 | /** |
396 | * @best_encoder: | |
397 | * | |
398 | * Used by the atomic helpers to select the encoder, through the | |
399 | * &drm_connector_helper_funcs.atomic_best_encoder or | |
400 | * &drm_connector_helper_funcs.best_encoder callbacks. | |
401 | */ | |
52217195 DV |
402 | struct drm_encoder *best_encoder; |
403 | ||
40ee6fbe MN |
404 | /** |
405 | * @link_status: Connector link_status to keep track of whether link is | |
406 | * GOOD or BAD to notify userspace if retraining is necessary. | |
407 | */ | |
408 | enum drm_link_status link_status; | |
409 | ||
aab999a6 | 410 | /** @state: backpointer to global drm_atomic_state */ |
52217195 | 411 | struct drm_atomic_state *state; |
299a16b1 | 412 | |
21a01abb ML |
413 | /** |
414 | * @commit: Tracks the pending commit to prevent use-after-free conditions. | |
415 | * | |
416 | * Is only set when @crtc is NULL. | |
417 | */ | |
418 | struct drm_crtc_commit *commit; | |
419 | ||
aab999a6 | 420 | /** @tv: TV connector state */ |
299a16b1 | 421 | struct drm_tv_connector_state tv; |
0e9f25d0 ML |
422 | |
423 | /** | |
424 | * @picture_aspect_ratio: Connector property to control the | |
425 | * HDMI infoframe aspect ratio setting. | |
426 | * | |
8f6e1e22 | 427 | * The %DRM_MODE_PICTURE_ASPECT_\* values much match the |
0e9f25d0 ML |
428 | * values for &enum hdmi_picture_aspect |
429 | */ | |
430 | enum hdmi_picture_aspect picture_aspect_ratio; | |
8f6e1e22 | 431 | |
50525c33 SL |
432 | /** |
433 | * @content_type: Connector property to control the | |
434 | * HDMI infoframe content type setting. | |
435 | * The %DRM_MODE_CONTENT_TYPE_\* values much | |
436 | * match the values. | |
437 | */ | |
438 | unsigned int content_type; | |
439 | ||
8f6e1e22 ML |
440 | /** |
441 | * @scaling_mode: Connector property to control the | |
442 | * upscaling, mostly used for built-in panels. | |
443 | */ | |
444 | unsigned int scaling_mode; | |
24557865 SP |
445 | |
446 | /** | |
447 | * @content_protection: Connector property to request content | |
448 | * protection. This is most commonly used for HDCP. | |
449 | */ | |
450 | unsigned int content_protection; | |
935774cd BS |
451 | |
452 | /** | |
453 | * @writeback_job: Writeback job for writeback connectors | |
454 | * | |
b13cc8dd BS |
455 | * Holds the framebuffer and out-fence for a writeback connector. As |
456 | * the writeback completion may be asynchronous to the normal commit | |
457 | * cycle, the writeback job lifetime is managed separately from the | |
458 | * normal atomic state by this object. | |
935774cd BS |
459 | * |
460 | * See also: drm_writeback_queue_job() and | |
461 | * drm_writeback_signal_completion() | |
462 | */ | |
463 | struct drm_writeback_job *writeback_job; | |
52217195 DV |
464 | }; |
465 | ||
466 | /** | |
467 | * struct drm_connector_funcs - control connectors on a given device | |
468 | * | |
469 | * Each CRTC may have one or more connectors attached to it. The functions | |
470 | * below allow the core DRM code to control connectors, enumerate available modes, | |
471 | * etc. | |
472 | */ | |
473 | struct drm_connector_funcs { | |
474 | /** | |
475 | * @dpms: | |
476 | * | |
477 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS | |
478 | * is exposed as a standard property on the connector, but diverted to | |
479 | * this callback in the drm core. Note that atomic drivers don't | |
480 | * implement the 4 level DPMS support on the connector any more, but | |
481 | * instead only have an on/off "ACTIVE" property on the CRTC object. | |
482 | * | |
144a7999 DV |
483 | * This hook is not used by atomic drivers, remapping of the legacy DPMS |
484 | * property is entirely handled in the DRM core. | |
52217195 DV |
485 | * |
486 | * RETURNS: | |
487 | * | |
488 | * 0 on success or a negative error code on failure. | |
489 | */ | |
490 | int (*dpms)(struct drm_connector *connector, int mode); | |
491 | ||
492 | /** | |
493 | * @reset: | |
494 | * | |
495 | * Reset connector hardware and software state to off. This function isn't | |
496 | * called by the core directly, only through drm_mode_config_reset(). | |
497 | * It's not a helper hook only for historical reasons. | |
498 | * | |
499 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset | |
500 | * atomic state using this hook. | |
501 | */ | |
502 | void (*reset)(struct drm_connector *connector); | |
503 | ||
504 | /** | |
505 | * @detect: | |
506 | * | |
507 | * Check to see if anything is attached to the connector. The parameter | |
508 | * force is set to false whilst polling, true when checking the | |
509 | * connector due to a user request. force can be used by the driver to | |
510 | * avoid expensive, destructive operations during automated probing. | |
511 | * | |
949f0886 LP |
512 | * This callback is optional, if not implemented the connector will be |
513 | * considered as always being attached. | |
514 | * | |
52217195 DV |
515 | * FIXME: |
516 | * | |
517 | * Note that this hook is only called by the probe helper. It's not in | |
518 | * the helper library vtable purely for historical reasons. The only DRM | |
519 | * core entry point to probe connector state is @fill_modes. | |
520 | * | |
6c5ed5ae ML |
521 | * Note that the helper library will already hold |
522 | * &drm_mode_config.connection_mutex. Drivers which need to grab additional | |
523 | * locks to avoid races with concurrent modeset changes need to use | |
524 | * &drm_connector_helper_funcs.detect_ctx instead. | |
525 | * | |
52217195 DV |
526 | * RETURNS: |
527 | * | |
528 | * drm_connector_status indicating the connector's status. | |
529 | */ | |
530 | enum drm_connector_status (*detect)(struct drm_connector *connector, | |
531 | bool force); | |
532 | ||
533 | /** | |
534 | * @force: | |
535 | * | |
536 | * This function is called to update internal encoder state when the | |
537 | * connector is forced to a certain state by userspace, either through | |
538 | * the sysfs interfaces or on the kernel cmdline. In that case the | |
539 | * @detect callback isn't called. | |
540 | * | |
541 | * FIXME: | |
542 | * | |
543 | * Note that this hook is only called by the probe helper. It's not in | |
544 | * the helper library vtable purely for historical reasons. The only DRM | |
545 | * core entry point to probe connector state is @fill_modes. | |
546 | */ | |
547 | void (*force)(struct drm_connector *connector); | |
548 | ||
549 | /** | |
550 | * @fill_modes: | |
551 | * | |
552 | * Entry point for output detection and basic mode validation. The | |
553 | * driver should reprobe the output if needed (e.g. when hotplug | |
d574528a | 554 | * handling is unreliable), add all detected modes to &drm_connector.modes |
52217195 DV |
555 | * and filter out any the device can't support in any configuration. It |
556 | * also needs to filter out any modes wider or higher than the | |
557 | * parameters max_width and max_height indicate. | |
558 | * | |
559 | * The drivers must also prune any modes no longer valid from | |
d574528a DV |
560 | * &drm_connector.modes. Furthermore it must update |
561 | * &drm_connector.status and &drm_connector.edid. If no EDID has been | |
562 | * received for this output connector->edid must be NULL. | |
52217195 DV |
563 | * |
564 | * Drivers using the probe helpers should use | |
92e1d263 | 565 | * drm_helper_probe_single_connector_modes() to implement this |
52217195 DV |
566 | * function. |
567 | * | |
568 | * RETURNS: | |
569 | * | |
d574528a | 570 | * The number of modes detected and filled into &drm_connector.modes. |
52217195 DV |
571 | */ |
572 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); | |
573 | ||
574 | /** | |
575 | * @set_property: | |
576 | * | |
577 | * This is the legacy entry point to update a property attached to the | |
578 | * connector. | |
579 | * | |
52217195 | 580 | * This callback is optional if the driver does not support any legacy |
144a7999 DV |
581 | * driver-private properties. For atomic drivers it is not used because |
582 | * property handling is done entirely in the DRM core. | |
52217195 DV |
583 | * |
584 | * RETURNS: | |
585 | * | |
586 | * 0 on success or a negative error code on failure. | |
587 | */ | |
588 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, | |
589 | uint64_t val); | |
590 | ||
591 | /** | |
592 | * @late_register: | |
593 | * | |
594 | * This optional hook can be used to register additional userspace | |
595 | * interfaces attached to the connector, light backlight control, i2c, | |
596 | * DP aux or similar interfaces. It is called late in the driver load | |
597 | * sequence from drm_connector_register() when registering all the | |
598 | * core drm connector interfaces. Everything added from this callback | |
599 | * should be unregistered in the early_unregister callback. | |
600 | * | |
d574528a | 601 | * This is called while holding &drm_connector.mutex. |
e73ab00e | 602 | * |
52217195 DV |
603 | * Returns: |
604 | * | |
605 | * 0 on success, or a negative error code on failure. | |
606 | */ | |
607 | int (*late_register)(struct drm_connector *connector); | |
608 | ||
609 | /** | |
610 | * @early_unregister: | |
611 | * | |
612 | * This optional hook should be used to unregister the additional | |
613 | * userspace interfaces attached to the connector from | |
621a9993 | 614 | * late_register(). It is called from drm_connector_unregister(), |
52217195 DV |
615 | * early in the driver unload sequence to disable userspace access |
616 | * before data structures are torndown. | |
e73ab00e | 617 | * |
d574528a | 618 | * This is called while holding &drm_connector.mutex. |
52217195 DV |
619 | */ |
620 | void (*early_unregister)(struct drm_connector *connector); | |
621 | ||
622 | /** | |
623 | * @destroy: | |
624 | * | |
625 | * Clean up connector resources. This is called at driver unload time | |
626 | * through drm_mode_config_cleanup(). It can also be called at runtime | |
627 | * when a connector is being hot-unplugged for drivers that support | |
628 | * connector hotplugging (e.g. DisplayPort MST). | |
629 | */ | |
630 | void (*destroy)(struct drm_connector *connector); | |
631 | ||
632 | /** | |
633 | * @atomic_duplicate_state: | |
634 | * | |
635 | * Duplicate the current atomic state for this connector and return it. | |
621a9993 | 636 | * The core and helpers guarantee that any atomic state duplicated with |
52217195 | 637 | * this hook and still owned by the caller (i.e. not transferred to the |
d574528a DV |
638 | * driver by calling &drm_mode_config_funcs.atomic_commit) will be |
639 | * cleaned up by calling the @atomic_destroy_state hook in this | |
640 | * structure. | |
52217195 | 641 | * |
ba1f665f HM |
642 | * This callback is mandatory for atomic drivers. |
643 | * | |
ea0dd85a | 644 | * Atomic drivers which don't subclass &struct drm_connector_state should use |
52217195 DV |
645 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the |
646 | * state structure to extend it with driver-private state should use | |
647 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is | |
648 | * duplicated in a consistent fashion across drivers. | |
649 | * | |
d574528a | 650 | * It is an error to call this hook before &drm_connector.state has been |
52217195 DV |
651 | * initialized correctly. |
652 | * | |
653 | * NOTE: | |
654 | * | |
655 | * If the duplicate state references refcounted resources this hook must | |
656 | * acquire a reference for each of them. The driver must release these | |
657 | * references again in @atomic_destroy_state. | |
658 | * | |
659 | * RETURNS: | |
660 | * | |
661 | * Duplicated atomic state or NULL when the allocation failed. | |
662 | */ | |
663 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); | |
664 | ||
665 | /** | |
666 | * @atomic_destroy_state: | |
667 | * | |
668 | * Destroy a state duplicated with @atomic_duplicate_state and release | |
669 | * or unreference all resources it references | |
ba1f665f HM |
670 | * |
671 | * This callback is mandatory for atomic drivers. | |
52217195 DV |
672 | */ |
673 | void (*atomic_destroy_state)(struct drm_connector *connector, | |
674 | struct drm_connector_state *state); | |
675 | ||
676 | /** | |
677 | * @atomic_set_property: | |
678 | * | |
679 | * Decode a driver-private property value and store the decoded value | |
680 | * into the passed-in state structure. Since the atomic core decodes all | |
681 | * standardized properties (even for extensions beyond the core set of | |
682 | * properties which might not be implemented by all drivers) this | |
683 | * requires drivers to subclass the state structure. | |
684 | * | |
685 | * Such driver-private properties should really only be implemented for | |
686 | * truly hardware/vendor specific state. Instead it is preferred to | |
687 | * standardize atomic extension and decode the properties used to expose | |
688 | * such an extension in the core. | |
689 | * | |
690 | * Do not call this function directly, use | |
691 | * drm_atomic_connector_set_property() instead. | |
692 | * | |
693 | * This callback is optional if the driver does not support any | |
694 | * driver-private atomic properties. | |
695 | * | |
696 | * NOTE: | |
697 | * | |
698 | * This function is called in the state assembly phase of atomic | |
699 | * modesets, which can be aborted for any reason (including on | |
700 | * userspace's request to just check whether a configuration would be | |
701 | * possible). Drivers MUST NOT touch any persistent state (hardware or | |
702 | * software) or data structures except the passed in @state parameter. | |
703 | * | |
704 | * Also since userspace controls in which order properties are set this | |
705 | * function must not do any input validation (since the state update is | |
706 | * incomplete and hence likely inconsistent). Instead any such input | |
707 | * validation must be done in the various atomic_check callbacks. | |
708 | * | |
709 | * RETURNS: | |
710 | * | |
711 | * 0 if the property has been found, -EINVAL if the property isn't | |
712 | * implemented by the driver (which shouldn't ever happen, the core only | |
713 | * asks for properties attached to this connector). No other validation | |
714 | * is allowed by the driver. The core already checks that the property | |
715 | * value is within the range (integer, valid enum value, ...) the driver | |
716 | * set when registering the property. | |
717 | */ | |
718 | int (*atomic_set_property)(struct drm_connector *connector, | |
719 | struct drm_connector_state *state, | |
720 | struct drm_property *property, | |
721 | uint64_t val); | |
722 | ||
723 | /** | |
724 | * @atomic_get_property: | |
725 | * | |
726 | * Reads out the decoded driver-private property. This is used to | |
727 | * implement the GETCONNECTOR IOCTL. | |
728 | * | |
729 | * Do not call this function directly, use | |
730 | * drm_atomic_connector_get_property() instead. | |
731 | * | |
732 | * This callback is optional if the driver does not support any | |
733 | * driver-private atomic properties. | |
734 | * | |
735 | * RETURNS: | |
736 | * | |
737 | * 0 on success, -EINVAL if the property isn't implemented by the | |
738 | * driver (which shouldn't ever happen, the core only asks for | |
739 | * properties attached to this connector). | |
740 | */ | |
741 | int (*atomic_get_property)(struct drm_connector *connector, | |
742 | const struct drm_connector_state *state, | |
743 | struct drm_property *property, | |
744 | uint64_t *val); | |
fceffb32 RC |
745 | |
746 | /** | |
747 | * @atomic_print_state: | |
748 | * | |
ea0dd85a | 749 | * If driver subclasses &struct drm_connector_state, it should implement |
fceffb32 RC |
750 | * this optional hook for printing additional driver specific state. |
751 | * | |
752 | * Do not call this directly, use drm_atomic_connector_print_state() | |
753 | * instead. | |
754 | */ | |
755 | void (*atomic_print_state)(struct drm_printer *p, | |
756 | const struct drm_connector_state *state); | |
52217195 DV |
757 | }; |
758 | ||
759 | /* mode specified on the command line */ | |
760 | struct drm_cmdline_mode { | |
761 | bool specified; | |
762 | bool refresh_specified; | |
763 | bool bpp_specified; | |
764 | int xres, yres; | |
765 | int bpp; | |
766 | int refresh; | |
767 | bool rb; | |
768 | bool interlace; | |
769 | bool cvt; | |
770 | bool margins; | |
771 | enum drm_connector_force force; | |
772 | }; | |
773 | ||
774 | /** | |
775 | * struct drm_connector - central DRM connector control structure | |
52217195 DV |
776 | * |
777 | * Each connector may be connected to one or more CRTCs, or may be clonable by | |
778 | * another connector if they can share a CRTC. Each connector also has a specific | |
779 | * position in the broader display (referred to as a 'screen' though it could | |
780 | * span multiple monitors). | |
781 | */ | |
782 | struct drm_connector { | |
92e1d263 | 783 | /** @dev: parent DRM device */ |
52217195 | 784 | struct drm_device *dev; |
92e1d263 | 785 | /** @kdev: kernel device for sysfs attributes */ |
52217195 | 786 | struct device *kdev; |
92e1d263 | 787 | /** @attr: sysfs attributes */ |
52217195 | 788 | struct device_attribute *attr; |
92e1d263 DV |
789 | |
790 | /** | |
791 | * @head: | |
792 | * | |
793 | * List of all connectors on a @dev, linked from | |
794 | * &drm_mode_config.connector_list. Protected by | |
795 | * &drm_mode_config.connector_list_lock, but please only use | |
796 | * &drm_connector_list_iter to walk this list. | |
797 | */ | |
52217195 DV |
798 | struct list_head head; |
799 | ||
92e1d263 | 800 | /** @base: base KMS object */ |
52217195 DV |
801 | struct drm_mode_object base; |
802 | ||
92e1d263 | 803 | /** @name: human readable name, can be overwritten by the driver */ |
52217195 DV |
804 | char *name; |
805 | ||
e73ab00e DV |
806 | /** |
807 | * @mutex: Lock for general connector state, but currently only protects | |
d574528a DV |
808 | * @registered. Most of the connector state is still protected by |
809 | * &drm_mode_config.mutex. | |
e73ab00e DV |
810 | */ |
811 | struct mutex mutex; | |
812 | ||
52217195 DV |
813 | /** |
814 | * @index: Compacted connector index, which matches the position inside | |
815 | * the mode_config.list for drivers not supporting hot-add/removing. Can | |
816 | * be used as an array index. It is invariant over the lifetime of the | |
817 | * connector. | |
818 | */ | |
819 | unsigned index; | |
820 | ||
92e1d263 DV |
821 | /** |
822 | * @connector_type: | |
823 | * one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h | |
824 | */ | |
52217195 | 825 | int connector_type; |
92e1d263 | 826 | /** @connector_type_id: index into connector type enum */ |
52217195 | 827 | int connector_type_id; |
92e1d263 DV |
828 | /** |
829 | * @interlace_allowed: | |
830 | * Can this connector handle interlaced modes? Only used by | |
831 | * drm_helper_probe_single_connector_modes() for mode filtering. | |
832 | */ | |
52217195 | 833 | bool interlace_allowed; |
92e1d263 DV |
834 | /** |
835 | * @doublescan_allowed: | |
836 | * Can this connector handle doublescan? Only used by | |
837 | * drm_helper_probe_single_connector_modes() for mode filtering. | |
838 | */ | |
52217195 | 839 | bool doublescan_allowed; |
92e1d263 DV |
840 | /** |
841 | * @stereo_allowed: | |
842 | * Can this connector handle stereo modes? Only used by | |
843 | * drm_helper_probe_single_connector_modes() for mode filtering. | |
844 | */ | |
52217195 | 845 | bool stereo_allowed; |
d8523153 SS |
846 | |
847 | /** | |
848 | * @ycbcr_420_allowed : This bool indicates if this connector is | |
849 | * capable of handling YCBCR 420 output. While parsing the EDID | |
850 | * blocks, its very helpful to know, if the source is capable of | |
851 | * handling YCBCR 420 outputs. | |
852 | */ | |
853 | bool ycbcr_420_allowed; | |
854 | ||
e73ab00e DV |
855 | /** |
856 | * @registered: Is this connector exposed (registered) with userspace? | |
857 | * Protected by @mutex. | |
858 | */ | |
52217195 | 859 | bool registered; |
91eefc05 DV |
860 | |
861 | /** | |
862 | * @modes: | |
863 | * Modes available on this connector (from fill_modes() + user). | |
d574528a | 864 | * Protected by &drm_mode_config.mutex. |
91eefc05 | 865 | */ |
d574528a | 866 | struct list_head modes; |
52217195 | 867 | |
91eefc05 DV |
868 | /** |
869 | * @status: | |
870 | * One of the drm_connector_status enums (connected, not, or unknown). | |
d574528a | 871 | * Protected by &drm_mode_config.mutex. |
91eefc05 | 872 | */ |
52217195 DV |
873 | enum drm_connector_status status; |
874 | ||
91eefc05 DV |
875 | /** |
876 | * @probed_modes: | |
877 | * These are modes added by probing with DDC or the BIOS, before | |
d574528a DV |
878 | * filtering is applied. Used by the probe helpers. Protected by |
879 | * &drm_mode_config.mutex. | |
91eefc05 | 880 | */ |
52217195 DV |
881 | struct list_head probed_modes; |
882 | ||
ae2a6da8 DV |
883 | /** |
884 | * @display_info: Display information is filled from EDID information | |
885 | * when a display is detected. For non hot-pluggable displays such as | |
886 | * flat panels in embedded systems, the driver should initialize the | |
d574528a DV |
887 | * &drm_display_info.width_mm and &drm_display_info.height_mm fields |
888 | * with the physical size of the display. | |
91eefc05 | 889 | * |
d574528a | 890 | * Protected by &drm_mode_config.mutex. |
ae2a6da8 | 891 | */ |
52217195 | 892 | struct drm_display_info display_info; |
92e1d263 DV |
893 | |
894 | /** @funcs: connector control functions */ | |
52217195 DV |
895 | const struct drm_connector_funcs *funcs; |
896 | ||
92e1d263 DV |
897 | /** |
898 | * @edid_blob_ptr: DRM property containing EDID if present. Protected by | |
899 | * &drm_mode_config.mutex. This should be updated only by calling | |
c555f023 | 900 | * drm_connector_update_edid_property(). |
92e1d263 | 901 | */ |
52217195 | 902 | struct drm_property_blob *edid_blob_ptr; |
92e1d263 DV |
903 | |
904 | /** @properties: property tracking for this connector */ | |
52217195 DV |
905 | struct drm_object_properties properties; |
906 | ||
92e1d263 DV |
907 | /** |
908 | * @scaling_mode_property: Optional atomic property to control the | |
909 | * upscaling. See drm_connector_attach_content_protection_property(). | |
910 | */ | |
8f6e1e22 ML |
911 | struct drm_property *scaling_mode_property; |
912 | ||
24557865 SP |
913 | /** |
914 | * @content_protection_property: DRM ENUM property for content | |
92e1d263 | 915 | * protection. See drm_connector_attach_content_protection_property(). |
24557865 SP |
916 | */ |
917 | struct drm_property *content_protection_property; | |
918 | ||
52217195 DV |
919 | /** |
920 | * @path_blob_ptr: | |
921 | * | |
92e1d263 | 922 | * DRM blob property data for the DP MST path property. This should only |
97e14fbe | 923 | * be updated by calling drm_connector_set_path_property(). |
52217195 DV |
924 | */ |
925 | struct drm_property_blob *path_blob_ptr; | |
926 | ||
52217195 | 927 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) |
52217195 | 928 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) |
52217195 DV |
929 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) |
930 | ||
ae2a6da8 DV |
931 | /** |
932 | * @polled: | |
933 | * | |
934 | * Connector polling mode, a combination of | |
935 | * | |
936 | * DRM_CONNECTOR_POLL_HPD | |
937 | * The connector generates hotplug events and doesn't need to be | |
938 | * periodically polled. The CONNECT and DISCONNECT flags must not | |
939 | * be set together with the HPD flag. | |
940 | * | |
941 | * DRM_CONNECTOR_POLL_CONNECT | |
942 | * Periodically poll the connector for connection. | |
943 | * | |
944 | * DRM_CONNECTOR_POLL_DISCONNECT | |
92e1d263 DV |
945 | * Periodically poll the connector for disconnection, without |
946 | * causing flickering even when the connector is in use. DACs should | |
947 | * rarely do this without a lot of testing. | |
ae2a6da8 DV |
948 | * |
949 | * Set to 0 for connectors that don't support connection status | |
950 | * discovery. | |
951 | */ | |
952 | uint8_t polled; | |
52217195 | 953 | |
92e1d263 DV |
954 | /** |
955 | * @dpms: Current dpms state. For legacy drivers the | |
956 | * &drm_connector_funcs.dpms callback must update this. For atomic | |
957 | * drivers, this is handled by the core atomic code, and drivers must | |
958 | * only take &drm_crtc_state.active into account. | |
959 | */ | |
52217195 DV |
960 | int dpms; |
961 | ||
92e1d263 | 962 | /** @helper_private: mid-layer private data */ |
52217195 DV |
963 | const struct drm_connector_helper_funcs *helper_private; |
964 | ||
92e1d263 | 965 | /** @cmdline_mode: mode line parsed from the kernel cmdline for this connector */ |
52217195 | 966 | struct drm_cmdline_mode cmdline_mode; |
92e1d263 | 967 | /** @force: a DRM_FORCE_<foo> state for forced mode sets */ |
52217195 | 968 | enum drm_connector_force force; |
92e1d263 | 969 | /** @override_edid: has the EDID been overwritten through debugfs for testing? */ |
52217195 DV |
970 | bool override_edid; |
971 | ||
972 | #define DRM_CONNECTOR_MAX_ENCODER 3 | |
92e1d263 DV |
973 | /** |
974 | * @encoder_ids: Valid encoders for this connector. Please only use | |
975 | * drm_connector_for_each_possible_encoder() to enumerate these. | |
976 | */ | |
52217195 | 977 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
92e1d263 | 978 | |
2e2b96ef DV |
979 | /** |
980 | * @encoder: Currently bound encoder driving this connector, if any. | |
981 | * Only really meaningful for non-atomic drivers. Atomic drivers should | |
982 | * instead look at &drm_connector_state.best_encoder, and in case they | |
983 | * need the CRTC driving this output, &drm_connector_state.crtc. | |
984 | */ | |
985 | struct drm_encoder *encoder; | |
52217195 DV |
986 | |
987 | #define MAX_ELD_BYTES 128 | |
92e1d263 | 988 | /** @eld: EDID-like data, if present */ |
52217195 | 989 | uint8_t eld[MAX_ELD_BYTES]; |
92e1d263 | 990 | /** @latency_present: AV delay info from ELD, if found */ |
52217195 | 991 | bool latency_present[2]; |
92e1d263 DV |
992 | /** |
993 | * @video_latency: Video latency info from ELD, if found. | |
994 | * [0]: progressive, [1]: interlaced | |
995 | */ | |
996 | int video_latency[2]; | |
997 | /** | |
998 | * @audio_latency: audio latency info from ELD, if found | |
999 | * [0]: progressive, [1]: interlaced | |
1000 | */ | |
52217195 | 1001 | int audio_latency[2]; |
92e1d263 DV |
1002 | /** |
1003 | * @null_edid_counter: track sinks that give us all zeros for the EDID. | |
1004 | * Needed to workaround some HW bugs where we get all 0s | |
1005 | */ | |
1006 | int null_edid_counter; | |
1007 | ||
1008 | /** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */ | |
52217195 DV |
1009 | unsigned bad_edid_counter; |
1010 | ||
92e1d263 DV |
1011 | /** |
1012 | * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used | |
1013 | * in Displayport compliance testing - Displayport Link CTS Core 1.2 | |
1014 | * rev1.1 4.2.2.6 | |
52217195 DV |
1015 | */ |
1016 | bool edid_corrupt; | |
1017 | ||
92e1d263 | 1018 | /** @debugfs_entry: debugfs directory for this connector */ |
52217195 DV |
1019 | struct dentry *debugfs_entry; |
1020 | ||
c9e42b72 DV |
1021 | /** |
1022 | * @state: | |
1023 | * | |
1024 | * Current atomic state for this connector. | |
1025 | * | |
92e1d263 | 1026 | * This is protected by &drm_mode_config.connection_mutex. Note that |
c9e42b72 DV |
1027 | * nonblocking atomic commits access the current connector state without |
1028 | * taking locks. Either by going through the &struct drm_atomic_state | |
77ac3b00 | 1029 | * pointers, see for_each_oldnew_connector_in_state(), |
c9e42b72 DV |
1030 | * for_each_old_connector_in_state() and |
1031 | * for_each_new_connector_in_state(). Or through careful ordering of | |
1032 | * atomic commit operations as implemented in the atomic helpers, see | |
1033 | * &struct drm_crtc_commit. | |
1034 | */ | |
52217195 DV |
1035 | struct drm_connector_state *state; |
1036 | ||
92e1d263 DV |
1037 | /* DisplayID bits. FIXME: Extract into a substruct? */ |
1038 | ||
1039 | /** | |
1040 | * @tile_blob_ptr: | |
1041 | * | |
1042 | * DRM blob property data for the tile property (used mostly by DP MST). | |
1043 | * This is meant for screens which are driven through separate display | |
1044 | * pipelines represented by &drm_crtc, which might not be running with | |
1045 | * genlocked clocks. For tiled panels which are genlocked, like | |
1046 | * dual-link LVDS or dual-link DSI, the driver should try to not expose | |
1047 | * the tiling and virtualize both &drm_crtc and &drm_plane if needed. | |
1048 | * | |
1049 | * This should only be updated by calling | |
97e14fbe | 1050 | * drm_connector_set_tile_property(). |
92e1d263 DV |
1051 | */ |
1052 | struct drm_property_blob *tile_blob_ptr; | |
1053 | ||
1054 | /** @has_tile: is this connector connected to a tiled monitor */ | |
52217195 | 1055 | bool has_tile; |
92e1d263 | 1056 | /** @tile_group: tile group for the connected monitor */ |
52217195 | 1057 | struct drm_tile_group *tile_group; |
92e1d263 | 1058 | /** @tile_is_single_monitor: whether the tile is one monitor housing */ |
52217195 DV |
1059 | bool tile_is_single_monitor; |
1060 | ||
92e1d263 DV |
1061 | /** @num_h_tile: number of horizontal tiles in the tile group */ |
1062 | /** @num_v_tile: number of vertical tiles in the tile group */ | |
52217195 | 1063 | uint8_t num_h_tile, num_v_tile; |
92e1d263 DV |
1064 | /** @tile_h_loc: horizontal location of this tile */ |
1065 | /** @tile_v_loc: vertical location of this tile */ | |
52217195 | 1066 | uint8_t tile_h_loc, tile_v_loc; |
92e1d263 DV |
1067 | /** @tile_h_size: horizontal size of this tile. */ |
1068 | /** @tile_v_size: vertical size of this tile. */ | |
52217195 | 1069 | uint16_t tile_h_size, tile_v_size; |
a703c550 DV |
1070 | |
1071 | /** | |
ea497bb9 | 1072 | * @free_node: |
a703c550 | 1073 | * |
92e1d263 | 1074 | * List used only by &drm_connector_list_iter to be able to clean up a |
ea497bb9 DV |
1075 | * connector from any context, in conjunction with |
1076 | * &drm_mode_config.connector_free_work. | |
a703c550 | 1077 | */ |
ea497bb9 | 1078 | struct llist_node free_node; |
52217195 DV |
1079 | }; |
1080 | ||
1081 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) | |
1082 | ||
1083 | int drm_connector_init(struct drm_device *dev, | |
1084 | struct drm_connector *connector, | |
1085 | const struct drm_connector_funcs *funcs, | |
1086 | int connector_type); | |
1087 | int drm_connector_register(struct drm_connector *connector); | |
1088 | void drm_connector_unregister(struct drm_connector *connector); | |
cde4c44d | 1089 | int drm_connector_attach_encoder(struct drm_connector *connector, |
52217195 DV |
1090 | struct drm_encoder *encoder); |
1091 | ||
1092 | void drm_connector_cleanup(struct drm_connector *connector); | |
73705732 VS |
1093 | |
1094 | static inline unsigned int drm_connector_index(const struct drm_connector *connector) | |
52217195 DV |
1095 | { |
1096 | return connector->index; | |
1097 | } | |
1098 | ||
73705732 VS |
1099 | static inline u32 drm_connector_mask(const struct drm_connector *connector) |
1100 | { | |
1101 | return 1 << connector->index; | |
1102 | } | |
1103 | ||
52217195 DV |
1104 | /** |
1105 | * drm_connector_lookup - lookup connector object | |
1106 | * @dev: DRM device | |
e7e62c7e | 1107 | * @file_priv: drm file to check for lease against. |
52217195 DV |
1108 | * @id: connector object id |
1109 | * | |
1110 | * This function looks up the connector object specified by id | |
1111 | * add takes a reference to it. | |
1112 | */ | |
1113 | static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, | |
418da172 | 1114 | struct drm_file *file_priv, |
52217195 DV |
1115 | uint32_t id) |
1116 | { | |
1117 | struct drm_mode_object *mo; | |
418da172 | 1118 | mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR); |
52217195 DV |
1119 | return mo ? obj_to_connector(mo) : NULL; |
1120 | } | |
1121 | ||
1122 | /** | |
ad093607 TR |
1123 | * drm_connector_get - acquire a connector reference |
1124 | * @connector: DRM connector | |
52217195 DV |
1125 | * |
1126 | * This function increments the connector's refcount. | |
1127 | */ | |
ad093607 TR |
1128 | static inline void drm_connector_get(struct drm_connector *connector) |
1129 | { | |
1130 | drm_mode_object_get(&connector->base); | |
1131 | } | |
1132 | ||
1133 | /** | |
1134 | * drm_connector_put - release a connector reference | |
1135 | * @connector: DRM connector | |
1136 | * | |
1137 | * This function decrements the connector's reference count and frees the | |
1138 | * object if the reference count drops to zero. | |
1139 | */ | |
1140 | static inline void drm_connector_put(struct drm_connector *connector) | |
1141 | { | |
1142 | drm_mode_object_put(&connector->base); | |
1143 | } | |
1144 | ||
1145 | /** | |
1146 | * drm_connector_reference - acquire a connector reference | |
1147 | * @connector: DRM connector | |
1148 | * | |
1149 | * This is a compatibility alias for drm_connector_get() and should not be | |
1150 | * used by new code. | |
1151 | */ | |
52217195 DV |
1152 | static inline void drm_connector_reference(struct drm_connector *connector) |
1153 | { | |
ad093607 | 1154 | drm_connector_get(connector); |
52217195 DV |
1155 | } |
1156 | ||
1157 | /** | |
ad093607 TR |
1158 | * drm_connector_unreference - release a connector reference |
1159 | * @connector: DRM connector | |
52217195 | 1160 | * |
ad093607 TR |
1161 | * This is a compatibility alias for drm_connector_put() and should not be |
1162 | * used by new code. | |
52217195 DV |
1163 | */ |
1164 | static inline void drm_connector_unreference(struct drm_connector *connector) | |
1165 | { | |
ad093607 | 1166 | drm_connector_put(connector); |
52217195 DV |
1167 | } |
1168 | ||
1169 | const char *drm_get_connector_status_name(enum drm_connector_status status); | |
1170 | const char *drm_get_subpixel_order_name(enum subpixel_order order); | |
1171 | const char *drm_get_dpms_name(int val); | |
1172 | const char *drm_get_dvi_i_subconnector_name(int val); | |
1173 | const char *drm_get_dvi_i_select_name(int val); | |
1174 | const char *drm_get_tv_subconnector_name(int val); | |
1175 | const char *drm_get_tv_select_name(int val); | |
24557865 | 1176 | const char *drm_get_content_protection_name(int val); |
52217195 DV |
1177 | |
1178 | int drm_mode_create_dvi_i_properties(struct drm_device *dev); | |
1179 | int drm_mode_create_tv_properties(struct drm_device *dev, | |
1180 | unsigned int num_modes, | |
1181 | const char * const modes[]); | |
1182 | int drm_mode_create_scaling_mode_property(struct drm_device *dev); | |
50525c33 | 1183 | int drm_connector_attach_content_type_property(struct drm_connector *dev); |
8f6e1e22 ML |
1184 | int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, |
1185 | u32 scaling_mode_mask); | |
24557865 SP |
1186 | int drm_connector_attach_content_protection_property( |
1187 | struct drm_connector *connector); | |
52217195 | 1188 | int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
50525c33 SL |
1189 | int drm_mode_create_content_type_property(struct drm_device *dev); |
1190 | void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame, | |
1191 | const struct drm_connector_state *conn_state); | |
1192 | ||
52217195 DV |
1193 | int drm_mode_create_suggested_offset_properties(struct drm_device *dev); |
1194 | ||
97e14fbe DV |
1195 | int drm_connector_set_path_property(struct drm_connector *connector, |
1196 | const char *path); | |
1197 | int drm_connector_set_tile_property(struct drm_connector *connector); | |
c555f023 DV |
1198 | int drm_connector_update_edid_property(struct drm_connector *connector, |
1199 | const struct edid *edid); | |
97e14fbe DV |
1200 | void drm_connector_set_link_status_property(struct drm_connector *connector, |
1201 | uint64_t link_status); | |
8d70f395 HG |
1202 | int drm_connector_init_panel_orientation_property( |
1203 | struct drm_connector *connector, int width, int height); | |
afb21ea6 | 1204 | |
9498c19b DV |
1205 | /** |
1206 | * struct drm_tile_group - Tile group metadata | |
1207 | * @refcount: reference count | |
1208 | * @dev: DRM device | |
1209 | * @id: tile group id exposed to userspace | |
1210 | * @group_data: Sink-private data identifying this group | |
1211 | * | |
1212 | * @group_data corresponds to displayid vend/prod/serial for external screens | |
1213 | * with an EDID. | |
1214 | */ | |
1215 | struct drm_tile_group { | |
1216 | struct kref refcount; | |
1217 | struct drm_device *dev; | |
1218 | int id; | |
1219 | u8 group_data[8]; | |
1220 | }; | |
1221 | ||
1222 | struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, | |
1223 | char topology[8]); | |
1224 | struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, | |
1225 | char topology[8]); | |
1226 | void drm_mode_put_tile_group(struct drm_device *dev, | |
1227 | struct drm_tile_group *tg); | |
1228 | ||
613051da DV |
1229 | /** |
1230 | * struct drm_connector_list_iter - connector_list iterator | |
1231 | * | |
1232 | * This iterator tracks state needed to be able to walk the connector_list | |
1233 | * within struct drm_mode_config. Only use together with | |
b982dab1 | 1234 | * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and |
613051da DV |
1235 | * drm_connector_list_iter_next() respectively the convenience macro |
1236 | * drm_for_each_connector_iter(). | |
1237 | */ | |
1238 | struct drm_connector_list_iter { | |
1239 | /* private: */ | |
1240 | struct drm_device *dev; | |
1241 | struct drm_connector *conn; | |
1242 | }; | |
1243 | ||
b982dab1 TR |
1244 | void drm_connector_list_iter_begin(struct drm_device *dev, |
1245 | struct drm_connector_list_iter *iter); | |
613051da DV |
1246 | struct drm_connector * |
1247 | drm_connector_list_iter_next(struct drm_connector_list_iter *iter); | |
b982dab1 | 1248 | void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); |
613051da | 1249 | |
38cb8d96 VS |
1250 | bool drm_connector_has_possible_encoder(struct drm_connector *connector, |
1251 | struct drm_encoder *encoder); | |
1252 | ||
613051da DV |
1253 | /** |
1254 | * drm_for_each_connector_iter - connector_list iterator macro | |
ea0dd85a DV |
1255 | * @connector: &struct drm_connector pointer used as cursor |
1256 | * @iter: &struct drm_connector_list_iter | |
613051da DV |
1257 | * |
1258 | * Note that @connector is only valid within the list body, if you want to use | |
b982dab1 | 1259 | * @connector after calling drm_connector_list_iter_end() then you need to grab |
5e851c9d | 1260 | * your own reference first using drm_connector_get(). |
613051da DV |
1261 | */ |
1262 | #define drm_for_each_connector_iter(connector, iter) \ | |
1263 | while ((connector = drm_connector_list_iter_next(iter))) | |
1264 | ||
83aefbb8 VS |
1265 | /** |
1266 | * drm_connector_for_each_possible_encoder - iterate connector's possible encoders | |
1267 | * @connector: &struct drm_connector pointer | |
1268 | * @encoder: &struct drm_encoder pointer used as cursor | |
1269 | * @__i: int iteration cursor, for macro-internal use | |
1270 | */ | |
1271 | #define drm_connector_for_each_possible_encoder(connector, encoder, __i) \ | |
1272 | for ((__i) = 0; (__i) < ARRAY_SIZE((connector)->encoder_ids) && \ | |
1273 | (connector)->encoder_ids[(__i)] != 0; (__i)++) \ | |
1274 | for_each_if((encoder) = \ | |
1275 | drm_encoder_find((connector)->dev, NULL, \ | |
1276 | (connector)->encoder_ids[(__i)])) \ | |
1277 | ||
52217195 | 1278 | #endif |