]>
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> | |
27 | #include <linux/ctype.h> | |
949619f3 | 28 | #include <drm/drm_mode_object.h> |
52217195 | 29 | |
199e4e96 DV |
30 | #include <uapi/drm/drm_mode.h> |
31 | ||
32 | struct drm_device; | |
33 | ||
52217195 | 34 | struct drm_connector_helper_funcs; |
6c5ed5ae | 35 | struct drm_modeset_acquire_ctx; |
52217195 DV |
36 | struct drm_device; |
37 | struct drm_crtc; | |
38 | struct drm_encoder; | |
39 | struct drm_property; | |
40 | struct drm_property_blob; | |
fceffb32 | 41 | struct drm_printer; |
52217195 DV |
42 | struct edid; |
43 | ||
44 | enum drm_connector_force { | |
45 | DRM_FORCE_UNSPECIFIED, | |
46 | DRM_FORCE_OFF, | |
47 | DRM_FORCE_ON, /* force on analog part normally */ | |
48 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ | |
49 | }; | |
50 | ||
ae2a6da8 DV |
51 | /** |
52 | * enum drm_connector_status - status for a &drm_connector | |
53 | * | |
54 | * This enum is used to track the connector status. There are no separate | |
55 | * #defines for the uapi! | |
56 | */ | |
52217195 | 57 | enum drm_connector_status { |
ae2a6da8 DV |
58 | /** |
59 | * @connector_status_connected: The connector is definitely connected to | |
60 | * a sink device, and can be enabled. | |
61 | */ | |
52217195 | 62 | connector_status_connected = 1, |
ae2a6da8 DV |
63 | /** |
64 | * @connector_status_disconnected: The connector isn't connected to a | |
65 | * sink device which can be autodetect. For digital outputs like DP or | |
66 | * HDMI (which can be realiable probed) this means there's really | |
67 | * nothing there. It is driver-dependent whether a connector with this | |
68 | * status can be lit up or not. | |
69 | */ | |
52217195 | 70 | connector_status_disconnected = 2, |
ae2a6da8 DV |
71 | /** |
72 | * @connector_status_unknown: The connector's status could not be | |
73 | * reliably detected. This happens when probing would either cause | |
74 | * flicker (like load-detection when the connector is in use), or when a | |
75 | * hardware resource isn't available (like when load-detection needs a | |
76 | * free CRTC). It should be possible to light up the connector with one | |
77 | * of the listed fallback modes. For default configuration userspace | |
78 | * should only try to light up connectors with unknown status when | |
79 | * there's not connector with @connector_status_connected. | |
80 | */ | |
52217195 DV |
81 | connector_status_unknown = 3, |
82 | }; | |
83 | ||
84 | enum subpixel_order { | |
85 | SubPixelUnknown = 0, | |
86 | SubPixelHorizontalRGB, | |
87 | SubPixelHorizontalBGR, | |
88 | SubPixelVerticalRGB, | |
89 | SubPixelVerticalBGR, | |
90 | SubPixelNone, | |
afa1c763 SS |
91 | |
92 | }; | |
93 | ||
62c58af3 SS |
94 | /** |
95 | * struct drm_scrambling: sink's scrambling support. | |
96 | */ | |
97 | struct drm_scrambling { | |
98 | /** | |
99 | * @supported: scrambling supported for rates > 340 Mhz. | |
100 | */ | |
101 | bool supported; | |
102 | /** | |
103 | * @low_rates: scrambling supported for rates <= 340 Mhz. | |
104 | */ | |
105 | bool low_rates; | |
106 | }; | |
107 | ||
afa1c763 SS |
108 | /* |
109 | * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink | |
110 | * | |
111 | * Provides SCDC register support and capabilities related information on a | |
112 | * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0. | |
113 | */ | |
114 | struct drm_scdc { | |
115 | /** | |
116 | * @supported: status control & data channel present. | |
117 | */ | |
118 | bool supported; | |
119 | /** | |
120 | * @read_request: sink is capable of generating scdc read request. | |
121 | */ | |
122 | bool read_request; | |
62c58af3 SS |
123 | /** |
124 | * @scrambling: sink's scrambling capabilities | |
125 | */ | |
126 | struct drm_scrambling scrambling; | |
afa1c763 SS |
127 | }; |
128 | ||
62c58af3 | 129 | |
afa1c763 SS |
130 | /** |
131 | * struct drm_hdmi_info - runtime information about the connected HDMI sink | |
132 | * | |
133 | * Describes if a given display supports advanced HDMI 2.0 features. | |
134 | * This information is available in CEA-861-F extension blocks (like HF-VSDB). | |
135 | */ | |
136 | struct drm_hdmi_info { | |
86cc921c | 137 | /** @scdc: sink's scdc support and capabilities */ |
afa1c763 | 138 | struct drm_scdc scdc; |
52217195 DV |
139 | }; |
140 | ||
40ee6fbe MN |
141 | /** |
142 | * enum drm_link_status - connector's link_status property value | |
143 | * | |
144 | * This enum is used as the connector's link status property value. | |
145 | * It is set to the values defined in uapi. | |
41232c1b MN |
146 | * |
147 | * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful | |
148 | * link training | |
149 | * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training | |
150 | * failure | |
40ee6fbe MN |
151 | */ |
152 | enum drm_link_status { | |
153 | DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD, | |
154 | DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD, | |
155 | }; | |
156 | ||
b3c6c8bf DV |
157 | /** |
158 | * struct drm_display_info - runtime data about the connected sink | |
159 | * | |
160 | * Describes a given display (e.g. CRT or flat panel) and its limitations. For | |
161 | * fixed display sinks like built-in panels there's not much difference between | |
ea0dd85a | 162 | * this and &struct drm_connector. But for sinks with a real cable this |
b3c6c8bf DV |
163 | * structure is meant to describe all the things at the other end of the cable. |
164 | * | |
165 | * For sinks which provide an EDID this can be filled out by calling | |
166 | * drm_add_edid_modes(). | |
52217195 DV |
167 | */ |
168 | struct drm_display_info { | |
b3c6c8bf DV |
169 | /** |
170 | * @name: Name of the display. | |
171 | */ | |
52217195 DV |
172 | char name[DRM_DISPLAY_INFO_LEN]; |
173 | ||
b3c6c8bf DV |
174 | /** |
175 | * @width_mm: Physical width in mm. | |
176 | */ | |
52217195 | 177 | unsigned int width_mm; |
b3c6c8bf DV |
178 | /** |
179 | * @height_mm: Physical height in mm. | |
180 | */ | |
52217195 DV |
181 | unsigned int height_mm; |
182 | ||
b3c6c8bf DV |
183 | /** |
184 | * @pixel_clock: Maximum pixel clock supported by the sink, in units of | |
188f7882 | 185 | * 100Hz. This mismatches the clock in &drm_display_mode (which is in |
b3c6c8bf DV |
186 | * kHZ), because that's what the EDID uses as base unit. |
187 | */ | |
52217195 | 188 | unsigned int pixel_clock; |
b3c6c8bf DV |
189 | /** |
190 | * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. | |
191 | */ | |
52217195 DV |
192 | unsigned int bpc; |
193 | ||
b3c6c8bf DV |
194 | /** |
195 | * @subpixel_order: Subpixel order of LCD panels. | |
196 | */ | |
52217195 DV |
197 | enum subpixel_order subpixel_order; |
198 | ||
199 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) | |
200 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) | |
201 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) | |
202 | ||
b3c6c8bf DV |
203 | /** |
204 | * @color_formats: HDMI Color formats, selects between RGB and YCrCb | |
205 | * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones | |
206 | * as used to describe the pixel format in framebuffers, and also don't | |
207 | * match the formats in @bus_formats which are shared with v4l. | |
208 | */ | |
52217195 DV |
209 | u32 color_formats; |
210 | ||
b3c6c8bf DV |
211 | /** |
212 | * @bus_formats: Pixel data format on the wire, somewhat redundant with | |
213 | * @color_formats. Array of size @num_bus_formats encoded using | |
214 | * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers. | |
215 | */ | |
52217195 | 216 | const u32 *bus_formats; |
b3c6c8bf DV |
217 | /** |
218 | * @num_bus_formats: Size of @bus_formats array. | |
219 | */ | |
52217195 DV |
220 | unsigned int num_bus_formats; |
221 | ||
222 | #define DRM_BUS_FLAG_DE_LOW (1<<0) | |
223 | #define DRM_BUS_FLAG_DE_HIGH (1<<1) | |
224 | /* drive data on pos. edge */ | |
225 | #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) | |
226 | /* drive data on neg. edge */ | |
227 | #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) | |
228 | ||
b3c6c8bf DV |
229 | /** |
230 | * @bus_flags: Additional information (like pixel signal polarity) for | |
231 | * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines. | |
232 | */ | |
52217195 DV |
233 | u32 bus_flags; |
234 | ||
2a272ca9 VS |
235 | /** |
236 | * @max_tmds_clock: Maximum TMDS clock rate supported by the | |
237 | * sink in kHz. 0 means undefined. | |
238 | */ | |
239 | int max_tmds_clock; | |
240 | ||
241 | /** | |
242 | * @dvi_dual: Dual-link DVI sink? | |
243 | */ | |
244 | bool dvi_dual; | |
245 | ||
b3c6c8bf DV |
246 | /** |
247 | * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even | |
248 | * more stuff redundant with @bus_formats. | |
249 | */ | |
52217195 DV |
250 | u8 edid_hdmi_dc_modes; |
251 | ||
b3c6c8bf DV |
252 | /** |
253 | * @cea_rev: CEA revision of the HDMI sink. | |
254 | */ | |
52217195 | 255 | u8 cea_rev; |
afa1c763 SS |
256 | |
257 | /** | |
258 | * @hdmi: advance features of a HDMI sink. | |
259 | */ | |
260 | struct drm_hdmi_info hdmi; | |
52217195 DV |
261 | }; |
262 | ||
b3c6c8bf DV |
263 | int drm_display_info_set_bus_formats(struct drm_display_info *info, |
264 | const u32 *formats, | |
265 | unsigned int num_formats); | |
266 | ||
299a16b1 BB |
267 | /** |
268 | * struct drm_tv_connector_state - TV connector related states | |
269 | * @subconnector: selected subconnector | |
270 | * @margins: left/right/top/bottom margins | |
271 | * @mode: TV mode | |
272 | * @brightness: brightness in percent | |
273 | * @contrast: contrast in percent | |
274 | * @flicker_reduction: flicker reduction in percent | |
275 | * @overscan: overscan in percent | |
276 | * @saturation: saturation in percent | |
277 | * @hue: hue in percent | |
278 | */ | |
279 | struct drm_tv_connector_state { | |
280 | enum drm_mode_subconnector subconnector; | |
281 | struct { | |
282 | unsigned int left; | |
283 | unsigned int right; | |
284 | unsigned int top; | |
285 | unsigned int bottom; | |
286 | } margins; | |
287 | unsigned int mode; | |
288 | unsigned int brightness; | |
289 | unsigned int contrast; | |
290 | unsigned int flicker_reduction; | |
291 | unsigned int overscan; | |
292 | unsigned int saturation; | |
293 | unsigned int hue; | |
294 | }; | |
295 | ||
52217195 DV |
296 | /** |
297 | * struct drm_connector_state - mutable connector state | |
298 | * @connector: backpointer to the connector | |
52217195 DV |
299 | * @best_encoder: can be used by helpers and drivers to select the encoder |
300 | * @state: backpointer to global drm_atomic_state | |
299a16b1 | 301 | * @tv: TV connector state |
52217195 DV |
302 | */ |
303 | struct drm_connector_state { | |
304 | struct drm_connector *connector; | |
305 | ||
afb21ea6 DV |
306 | /** |
307 | * @crtc: CRTC to connect connector to, NULL if disabled. | |
308 | * | |
309 | * Do not change this directly, use drm_atomic_set_crtc_for_connector() | |
310 | * instead. | |
311 | */ | |
312 | struct drm_crtc *crtc; | |
52217195 DV |
313 | |
314 | struct drm_encoder *best_encoder; | |
315 | ||
40ee6fbe MN |
316 | /** |
317 | * @link_status: Connector link_status to keep track of whether link is | |
318 | * GOOD or BAD to notify userspace if retraining is necessary. | |
319 | */ | |
320 | enum drm_link_status link_status; | |
321 | ||
52217195 | 322 | struct drm_atomic_state *state; |
299a16b1 BB |
323 | |
324 | struct drm_tv_connector_state tv; | |
52217195 DV |
325 | }; |
326 | ||
327 | /** | |
328 | * struct drm_connector_funcs - control connectors on a given device | |
329 | * | |
330 | * Each CRTC may have one or more connectors attached to it. The functions | |
331 | * below allow the core DRM code to control connectors, enumerate available modes, | |
332 | * etc. | |
333 | */ | |
334 | struct drm_connector_funcs { | |
335 | /** | |
336 | * @dpms: | |
337 | * | |
338 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS | |
339 | * is exposed as a standard property on the connector, but diverted to | |
340 | * this callback in the drm core. Note that atomic drivers don't | |
341 | * implement the 4 level DPMS support on the connector any more, but | |
342 | * instead only have an on/off "ACTIVE" property on the CRTC object. | |
343 | * | |
344 | * Drivers implementing atomic modeset should use | |
345 | * drm_atomic_helper_connector_dpms() to implement this hook. | |
346 | * | |
347 | * RETURNS: | |
348 | * | |
349 | * 0 on success or a negative error code on failure. | |
350 | */ | |
351 | int (*dpms)(struct drm_connector *connector, int mode); | |
352 | ||
353 | /** | |
354 | * @reset: | |
355 | * | |
356 | * Reset connector hardware and software state to off. This function isn't | |
357 | * called by the core directly, only through drm_mode_config_reset(). | |
358 | * It's not a helper hook only for historical reasons. | |
359 | * | |
360 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset | |
361 | * atomic state using this hook. | |
362 | */ | |
363 | void (*reset)(struct drm_connector *connector); | |
364 | ||
365 | /** | |
366 | * @detect: | |
367 | * | |
368 | * Check to see if anything is attached to the connector. The parameter | |
369 | * force is set to false whilst polling, true when checking the | |
370 | * connector due to a user request. force can be used by the driver to | |
371 | * avoid expensive, destructive operations during automated probing. | |
372 | * | |
949f0886 LP |
373 | * This callback is optional, if not implemented the connector will be |
374 | * considered as always being attached. | |
375 | * | |
52217195 DV |
376 | * FIXME: |
377 | * | |
378 | * Note that this hook is only called by the probe helper. It's not in | |
379 | * the helper library vtable purely for historical reasons. The only DRM | |
380 | * core entry point to probe connector state is @fill_modes. | |
381 | * | |
6c5ed5ae ML |
382 | * Note that the helper library will already hold |
383 | * &drm_mode_config.connection_mutex. Drivers which need to grab additional | |
384 | * locks to avoid races with concurrent modeset changes need to use | |
385 | * &drm_connector_helper_funcs.detect_ctx instead. | |
386 | * | |
52217195 DV |
387 | * RETURNS: |
388 | * | |
389 | * drm_connector_status indicating the connector's status. | |
390 | */ | |
391 | enum drm_connector_status (*detect)(struct drm_connector *connector, | |
392 | bool force); | |
393 | ||
394 | /** | |
395 | * @force: | |
396 | * | |
397 | * This function is called to update internal encoder state when the | |
398 | * connector is forced to a certain state by userspace, either through | |
399 | * the sysfs interfaces or on the kernel cmdline. In that case the | |
400 | * @detect callback isn't called. | |
401 | * | |
402 | * FIXME: | |
403 | * | |
404 | * Note that this hook is only called by the probe helper. It's not in | |
405 | * the helper library vtable purely for historical reasons. The only DRM | |
406 | * core entry point to probe connector state is @fill_modes. | |
407 | */ | |
408 | void (*force)(struct drm_connector *connector); | |
409 | ||
410 | /** | |
411 | * @fill_modes: | |
412 | * | |
413 | * Entry point for output detection and basic mode validation. The | |
414 | * driver should reprobe the output if needed (e.g. when hotplug | |
d574528a | 415 | * handling is unreliable), add all detected modes to &drm_connector.modes |
52217195 DV |
416 | * and filter out any the device can't support in any configuration. It |
417 | * also needs to filter out any modes wider or higher than the | |
418 | * parameters max_width and max_height indicate. | |
419 | * | |
420 | * The drivers must also prune any modes no longer valid from | |
d574528a DV |
421 | * &drm_connector.modes. Furthermore it must update |
422 | * &drm_connector.status and &drm_connector.edid. If no EDID has been | |
423 | * received for this output connector->edid must be NULL. | |
52217195 DV |
424 | * |
425 | * Drivers using the probe helpers should use | |
426 | * drm_helper_probe_single_connector_modes() or | |
427 | * drm_helper_probe_single_connector_modes_nomerge() to implement this | |
428 | * function. | |
429 | * | |
430 | * RETURNS: | |
431 | * | |
d574528a | 432 | * The number of modes detected and filled into &drm_connector.modes. |
52217195 DV |
433 | */ |
434 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); | |
435 | ||
436 | /** | |
437 | * @set_property: | |
438 | * | |
439 | * This is the legacy entry point to update a property attached to the | |
440 | * connector. | |
441 | * | |
442 | * Drivers implementing atomic modeset should use | |
443 | * drm_atomic_helper_connector_set_property() to implement this hook. | |
444 | * | |
445 | * This callback is optional if the driver does not support any legacy | |
446 | * driver-private properties. | |
447 | * | |
448 | * RETURNS: | |
449 | * | |
450 | * 0 on success or a negative error code on failure. | |
451 | */ | |
452 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, | |
453 | uint64_t val); | |
454 | ||
455 | /** | |
456 | * @late_register: | |
457 | * | |
458 | * This optional hook can be used to register additional userspace | |
459 | * interfaces attached to the connector, light backlight control, i2c, | |
460 | * DP aux or similar interfaces. It is called late in the driver load | |
461 | * sequence from drm_connector_register() when registering all the | |
462 | * core drm connector interfaces. Everything added from this callback | |
463 | * should be unregistered in the early_unregister callback. | |
464 | * | |
d574528a | 465 | * This is called while holding &drm_connector.mutex. |
e73ab00e | 466 | * |
52217195 DV |
467 | * Returns: |
468 | * | |
469 | * 0 on success, or a negative error code on failure. | |
470 | */ | |
471 | int (*late_register)(struct drm_connector *connector); | |
472 | ||
473 | /** | |
474 | * @early_unregister: | |
475 | * | |
476 | * This optional hook should be used to unregister the additional | |
477 | * userspace interfaces attached to the connector from | |
621a9993 | 478 | * late_register(). It is called from drm_connector_unregister(), |
52217195 DV |
479 | * early in the driver unload sequence to disable userspace access |
480 | * before data structures are torndown. | |
e73ab00e | 481 | * |
d574528a | 482 | * This is called while holding &drm_connector.mutex. |
52217195 DV |
483 | */ |
484 | void (*early_unregister)(struct drm_connector *connector); | |
485 | ||
486 | /** | |
487 | * @destroy: | |
488 | * | |
489 | * Clean up connector resources. This is called at driver unload time | |
490 | * through drm_mode_config_cleanup(). It can also be called at runtime | |
491 | * when a connector is being hot-unplugged for drivers that support | |
492 | * connector hotplugging (e.g. DisplayPort MST). | |
493 | */ | |
494 | void (*destroy)(struct drm_connector *connector); | |
495 | ||
496 | /** | |
497 | * @atomic_duplicate_state: | |
498 | * | |
499 | * Duplicate the current atomic state for this connector and return it. | |
621a9993 | 500 | * The core and helpers guarantee that any atomic state duplicated with |
52217195 | 501 | * this hook and still owned by the caller (i.e. not transferred to the |
d574528a DV |
502 | * driver by calling &drm_mode_config_funcs.atomic_commit) will be |
503 | * cleaned up by calling the @atomic_destroy_state hook in this | |
504 | * structure. | |
52217195 | 505 | * |
ea0dd85a | 506 | * Atomic drivers which don't subclass &struct drm_connector_state should use |
52217195 DV |
507 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the |
508 | * state structure to extend it with driver-private state should use | |
509 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is | |
510 | * duplicated in a consistent fashion across drivers. | |
511 | * | |
d574528a | 512 | * It is an error to call this hook before &drm_connector.state has been |
52217195 DV |
513 | * initialized correctly. |
514 | * | |
515 | * NOTE: | |
516 | * | |
517 | * If the duplicate state references refcounted resources this hook must | |
518 | * acquire a reference for each of them. The driver must release these | |
519 | * references again in @atomic_destroy_state. | |
520 | * | |
521 | * RETURNS: | |
522 | * | |
523 | * Duplicated atomic state or NULL when the allocation failed. | |
524 | */ | |
525 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); | |
526 | ||
527 | /** | |
528 | * @atomic_destroy_state: | |
529 | * | |
530 | * Destroy a state duplicated with @atomic_duplicate_state and release | |
531 | * or unreference all resources it references | |
532 | */ | |
533 | void (*atomic_destroy_state)(struct drm_connector *connector, | |
534 | struct drm_connector_state *state); | |
535 | ||
536 | /** | |
537 | * @atomic_set_property: | |
538 | * | |
539 | * Decode a driver-private property value and store the decoded value | |
540 | * into the passed-in state structure. Since the atomic core decodes all | |
541 | * standardized properties (even for extensions beyond the core set of | |
542 | * properties which might not be implemented by all drivers) this | |
543 | * requires drivers to subclass the state structure. | |
544 | * | |
545 | * Such driver-private properties should really only be implemented for | |
546 | * truly hardware/vendor specific state. Instead it is preferred to | |
547 | * standardize atomic extension and decode the properties used to expose | |
548 | * such an extension in the core. | |
549 | * | |
550 | * Do not call this function directly, use | |
551 | * drm_atomic_connector_set_property() instead. | |
552 | * | |
553 | * This callback is optional if the driver does not support any | |
554 | * driver-private atomic properties. | |
555 | * | |
556 | * NOTE: | |
557 | * | |
558 | * This function is called in the state assembly phase of atomic | |
559 | * modesets, which can be aborted for any reason (including on | |
560 | * userspace's request to just check whether a configuration would be | |
561 | * possible). Drivers MUST NOT touch any persistent state (hardware or | |
562 | * software) or data structures except the passed in @state parameter. | |
563 | * | |
564 | * Also since userspace controls in which order properties are set this | |
565 | * function must not do any input validation (since the state update is | |
566 | * incomplete and hence likely inconsistent). Instead any such input | |
567 | * validation must be done in the various atomic_check callbacks. | |
568 | * | |
569 | * RETURNS: | |
570 | * | |
571 | * 0 if the property has been found, -EINVAL if the property isn't | |
572 | * implemented by the driver (which shouldn't ever happen, the core only | |
573 | * asks for properties attached to this connector). No other validation | |
574 | * is allowed by the driver. The core already checks that the property | |
575 | * value is within the range (integer, valid enum value, ...) the driver | |
576 | * set when registering the property. | |
577 | */ | |
578 | int (*atomic_set_property)(struct drm_connector *connector, | |
579 | struct drm_connector_state *state, | |
580 | struct drm_property *property, | |
581 | uint64_t val); | |
582 | ||
583 | /** | |
584 | * @atomic_get_property: | |
585 | * | |
586 | * Reads out the decoded driver-private property. This is used to | |
587 | * implement the GETCONNECTOR IOCTL. | |
588 | * | |
589 | * Do not call this function directly, use | |
590 | * drm_atomic_connector_get_property() instead. | |
591 | * | |
592 | * This callback is optional if the driver does not support any | |
593 | * driver-private atomic properties. | |
594 | * | |
595 | * RETURNS: | |
596 | * | |
597 | * 0 on success, -EINVAL if the property isn't implemented by the | |
598 | * driver (which shouldn't ever happen, the core only asks for | |
599 | * properties attached to this connector). | |
600 | */ | |
601 | int (*atomic_get_property)(struct drm_connector *connector, | |
602 | const struct drm_connector_state *state, | |
603 | struct drm_property *property, | |
604 | uint64_t *val); | |
fceffb32 RC |
605 | |
606 | /** | |
607 | * @atomic_print_state: | |
608 | * | |
ea0dd85a | 609 | * If driver subclasses &struct drm_connector_state, it should implement |
fceffb32 RC |
610 | * this optional hook for printing additional driver specific state. |
611 | * | |
612 | * Do not call this directly, use drm_atomic_connector_print_state() | |
613 | * instead. | |
614 | */ | |
615 | void (*atomic_print_state)(struct drm_printer *p, | |
616 | const struct drm_connector_state *state); | |
52217195 DV |
617 | }; |
618 | ||
619 | /* mode specified on the command line */ | |
620 | struct drm_cmdline_mode { | |
621 | bool specified; | |
622 | bool refresh_specified; | |
623 | bool bpp_specified; | |
624 | int xres, yres; | |
625 | int bpp; | |
626 | int refresh; | |
627 | bool rb; | |
628 | bool interlace; | |
629 | bool cvt; | |
630 | bool margins; | |
631 | enum drm_connector_force force; | |
632 | }; | |
633 | ||
634 | /** | |
635 | * struct drm_connector - central DRM connector control structure | |
636 | * @dev: parent DRM device | |
637 | * @kdev: kernel device for sysfs attributes | |
638 | * @attr: sysfs attributes | |
639 | * @head: list management | |
640 | * @base: base KMS object | |
641 | * @name: human readable name, can be overwritten by the driver | |
642 | * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h | |
643 | * @connector_type_id: index into connector type enum | |
644 | * @interlace_allowed: can this connector handle interlaced modes? | |
645 | * @doublescan_allowed: can this connector handle doublescan? | |
646 | * @stereo_allowed: can this connector handle stereo modes? | |
52217195 DV |
647 | * @funcs: connector control functions |
648 | * @edid_blob_ptr: DRM property containing EDID if present | |
649 | * @properties: property tracking for this connector | |
52217195 DV |
650 | * @dpms: current dpms state |
651 | * @helper_private: mid-layer private data | |
652 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector | |
653 | * @force: a DRM_FORCE_<foo> state for forced mode sets | |
654 | * @override_edid: has the EDID been overwritten through debugfs for testing? | |
655 | * @encoder_ids: valid encoders for this connector | |
656 | * @encoder: encoder driving this connector, if any | |
657 | * @eld: EDID-like data, if present | |
52217195 DV |
658 | * @latency_present: AV delay info from ELD, if found |
659 | * @video_latency: video latency info from ELD, if found | |
660 | * @audio_latency: audio latency info from ELD, if found | |
661 | * @null_edid_counter: track sinks that give us all zeros for the EDID | |
662 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum | |
663 | * @edid_corrupt: indicates whether the last read EDID was corrupt | |
664 | * @debugfs_entry: debugfs directory for this connector | |
52217195 DV |
665 | * @has_tile: is this connector connected to a tiled monitor |
666 | * @tile_group: tile group for the connected monitor | |
667 | * @tile_is_single_monitor: whether the tile is one monitor housing | |
668 | * @num_h_tile: number of horizontal tiles in the tile group | |
669 | * @num_v_tile: number of vertical tiles in the tile group | |
670 | * @tile_h_loc: horizontal location of this tile | |
671 | * @tile_v_loc: vertical location of this tile | |
672 | * @tile_h_size: horizontal size of this tile. | |
673 | * @tile_v_size: vertical size of this tile. | |
674 | * | |
675 | * Each connector may be connected to one or more CRTCs, or may be clonable by | |
676 | * another connector if they can share a CRTC. Each connector also has a specific | |
677 | * position in the broader display (referred to as a 'screen' though it could | |
678 | * span multiple monitors). | |
679 | */ | |
680 | struct drm_connector { | |
681 | struct drm_device *dev; | |
682 | struct device *kdev; | |
683 | struct device_attribute *attr; | |
684 | struct list_head head; | |
685 | ||
686 | struct drm_mode_object base; | |
687 | ||
688 | char *name; | |
689 | ||
e73ab00e DV |
690 | /** |
691 | * @mutex: Lock for general connector state, but currently only protects | |
d574528a DV |
692 | * @registered. Most of the connector state is still protected by |
693 | * &drm_mode_config.mutex. | |
e73ab00e DV |
694 | */ |
695 | struct mutex mutex; | |
696 | ||
52217195 DV |
697 | /** |
698 | * @index: Compacted connector index, which matches the position inside | |
699 | * the mode_config.list for drivers not supporting hot-add/removing. Can | |
700 | * be used as an array index. It is invariant over the lifetime of the | |
701 | * connector. | |
702 | */ | |
703 | unsigned index; | |
704 | ||
705 | int connector_type; | |
706 | int connector_type_id; | |
707 | bool interlace_allowed; | |
708 | bool doublescan_allowed; | |
709 | bool stereo_allowed; | |
e73ab00e DV |
710 | /** |
711 | * @registered: Is this connector exposed (registered) with userspace? | |
712 | * Protected by @mutex. | |
713 | */ | |
52217195 | 714 | bool registered; |
91eefc05 DV |
715 | |
716 | /** | |
717 | * @modes: | |
718 | * Modes available on this connector (from fill_modes() + user). | |
d574528a | 719 | * Protected by &drm_mode_config.mutex. |
91eefc05 | 720 | */ |
d574528a | 721 | struct list_head modes; |
52217195 | 722 | |
91eefc05 DV |
723 | /** |
724 | * @status: | |
725 | * One of the drm_connector_status enums (connected, not, or unknown). | |
d574528a | 726 | * Protected by &drm_mode_config.mutex. |
91eefc05 | 727 | */ |
52217195 DV |
728 | enum drm_connector_status status; |
729 | ||
91eefc05 DV |
730 | /** |
731 | * @probed_modes: | |
732 | * These are modes added by probing with DDC or the BIOS, before | |
d574528a DV |
733 | * filtering is applied. Used by the probe helpers. Protected by |
734 | * &drm_mode_config.mutex. | |
91eefc05 | 735 | */ |
52217195 DV |
736 | struct list_head probed_modes; |
737 | ||
ae2a6da8 DV |
738 | /** |
739 | * @display_info: Display information is filled from EDID information | |
740 | * when a display is detected. For non hot-pluggable displays such as | |
741 | * flat panels in embedded systems, the driver should initialize the | |
d574528a DV |
742 | * &drm_display_info.width_mm and &drm_display_info.height_mm fields |
743 | * with the physical size of the display. | |
91eefc05 | 744 | * |
d574528a | 745 | * Protected by &drm_mode_config.mutex. |
ae2a6da8 | 746 | */ |
52217195 DV |
747 | struct drm_display_info display_info; |
748 | const struct drm_connector_funcs *funcs; | |
749 | ||
750 | struct drm_property_blob *edid_blob_ptr; | |
751 | struct drm_object_properties properties; | |
752 | ||
753 | /** | |
754 | * @path_blob_ptr: | |
755 | * | |
756 | * DRM blob property data for the DP MST path property. | |
757 | */ | |
758 | struct drm_property_blob *path_blob_ptr; | |
759 | ||
760 | /** | |
761 | * @tile_blob_ptr: | |
762 | * | |
763 | * DRM blob property data for the tile property (used mostly by DP MST). | |
764 | * This is meant for screens which are driven through separate display | |
765 | * pipelines represented by &drm_crtc, which might not be running with | |
766 | * genlocked clocks. For tiled panels which are genlocked, like | |
767 | * dual-link LVDS or dual-link DSI, the driver should try to not expose | |
768 | * the tiling and virtualize both &drm_crtc and &drm_plane if needed. | |
769 | */ | |
770 | struct drm_property_blob *tile_blob_ptr; | |
771 | ||
772 | /* should we poll this connector for connects and disconnects */ | |
773 | /* hot plug detectable */ | |
774 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) | |
775 | /* poll for connections */ | |
776 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) | |
777 | /* can cleanly poll for disconnections without flickering the screen */ | |
778 | /* DACs should rarely do this without a lot of testing */ | |
779 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) | |
780 | ||
ae2a6da8 DV |
781 | /** |
782 | * @polled: | |
783 | * | |
784 | * Connector polling mode, a combination of | |
785 | * | |
786 | * DRM_CONNECTOR_POLL_HPD | |
787 | * The connector generates hotplug events and doesn't need to be | |
788 | * periodically polled. The CONNECT and DISCONNECT flags must not | |
789 | * be set together with the HPD flag. | |
790 | * | |
791 | * DRM_CONNECTOR_POLL_CONNECT | |
792 | * Periodically poll the connector for connection. | |
793 | * | |
794 | * DRM_CONNECTOR_POLL_DISCONNECT | |
795 | * Periodically poll the connector for disconnection. | |
796 | * | |
797 | * Set to 0 for connectors that don't support connection status | |
798 | * discovery. | |
799 | */ | |
800 | uint8_t polled; | |
52217195 DV |
801 | |
802 | /* requested DPMS state */ | |
803 | int dpms; | |
804 | ||
805 | const struct drm_connector_helper_funcs *helper_private; | |
806 | ||
807 | /* forced on connector */ | |
808 | struct drm_cmdline_mode cmdline_mode; | |
809 | enum drm_connector_force force; | |
810 | bool override_edid; | |
811 | ||
812 | #define DRM_CONNECTOR_MAX_ENCODER 3 | |
813 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; | |
814 | struct drm_encoder *encoder; /* currently active encoder */ | |
815 | ||
816 | #define MAX_ELD_BYTES 128 | |
817 | /* EDID bits */ | |
818 | uint8_t eld[MAX_ELD_BYTES]; | |
52217195 DV |
819 | bool latency_present[2]; |
820 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ | |
821 | int audio_latency[2]; | |
822 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ | |
823 | unsigned bad_edid_counter; | |
824 | ||
825 | /* Flag for raw EDID header corruption - used in Displayport | |
826 | * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 | |
827 | */ | |
828 | bool edid_corrupt; | |
829 | ||
830 | struct dentry *debugfs_entry; | |
831 | ||
c9e42b72 DV |
832 | /** |
833 | * @state: | |
834 | * | |
835 | * Current atomic state for this connector. | |
836 | * | |
837 | * This is protected by @drm_mode_config.connection_mutex. Note that | |
838 | * nonblocking atomic commits access the current connector state without | |
839 | * taking locks. Either by going through the &struct drm_atomic_state | |
840 | * pointers, see for_each_connector_in_state(), | |
841 | * for_each_oldnew_connector_in_state(), | |
842 | * for_each_old_connector_in_state() and | |
843 | * for_each_new_connector_in_state(). Or through careful ordering of | |
844 | * atomic commit operations as implemented in the atomic helpers, see | |
845 | * &struct drm_crtc_commit. | |
846 | */ | |
52217195 DV |
847 | struct drm_connector_state *state; |
848 | ||
849 | /* DisplayID bits */ | |
850 | bool has_tile; | |
851 | struct drm_tile_group *tile_group; | |
852 | bool tile_is_single_monitor; | |
853 | ||
854 | uint8_t num_h_tile, num_v_tile; | |
855 | uint8_t tile_h_loc, tile_v_loc; | |
856 | uint16_t tile_h_size, tile_v_size; | |
857 | }; | |
858 | ||
859 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) | |
860 | ||
861 | int drm_connector_init(struct drm_device *dev, | |
862 | struct drm_connector *connector, | |
863 | const struct drm_connector_funcs *funcs, | |
864 | int connector_type); | |
865 | int drm_connector_register(struct drm_connector *connector); | |
866 | void drm_connector_unregister(struct drm_connector *connector); | |
867 | int drm_mode_connector_attach_encoder(struct drm_connector *connector, | |
868 | struct drm_encoder *encoder); | |
869 | ||
870 | void drm_connector_cleanup(struct drm_connector *connector); | |
871 | static inline unsigned drm_connector_index(struct drm_connector *connector) | |
872 | { | |
873 | return connector->index; | |
874 | } | |
875 | ||
876 | /** | |
877 | * drm_connector_lookup - lookup connector object | |
878 | * @dev: DRM device | |
879 | * @id: connector object id | |
880 | * | |
881 | * This function looks up the connector object specified by id | |
882 | * add takes a reference to it. | |
883 | */ | |
884 | static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, | |
885 | uint32_t id) | |
886 | { | |
887 | struct drm_mode_object *mo; | |
888 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); | |
889 | return mo ? obj_to_connector(mo) : NULL; | |
890 | } | |
891 | ||
892 | /** | |
ad093607 TR |
893 | * drm_connector_get - acquire a connector reference |
894 | * @connector: DRM connector | |
52217195 DV |
895 | * |
896 | * This function increments the connector's refcount. | |
897 | */ | |
ad093607 TR |
898 | static inline void drm_connector_get(struct drm_connector *connector) |
899 | { | |
900 | drm_mode_object_get(&connector->base); | |
901 | } | |
902 | ||
903 | /** | |
904 | * drm_connector_put - release a connector reference | |
905 | * @connector: DRM connector | |
906 | * | |
907 | * This function decrements the connector's reference count and frees the | |
908 | * object if the reference count drops to zero. | |
909 | */ | |
910 | static inline void drm_connector_put(struct drm_connector *connector) | |
911 | { | |
912 | drm_mode_object_put(&connector->base); | |
913 | } | |
914 | ||
915 | /** | |
916 | * drm_connector_reference - acquire a connector reference | |
917 | * @connector: DRM connector | |
918 | * | |
919 | * This is a compatibility alias for drm_connector_get() and should not be | |
920 | * used by new code. | |
921 | */ | |
52217195 DV |
922 | static inline void drm_connector_reference(struct drm_connector *connector) |
923 | { | |
ad093607 | 924 | drm_connector_get(connector); |
52217195 DV |
925 | } |
926 | ||
927 | /** | |
ad093607 TR |
928 | * drm_connector_unreference - release a connector reference |
929 | * @connector: DRM connector | |
52217195 | 930 | * |
ad093607 TR |
931 | * This is a compatibility alias for drm_connector_put() and should not be |
932 | * used by new code. | |
52217195 DV |
933 | */ |
934 | static inline void drm_connector_unreference(struct drm_connector *connector) | |
935 | { | |
ad093607 | 936 | drm_connector_put(connector); |
52217195 DV |
937 | } |
938 | ||
939 | const char *drm_get_connector_status_name(enum drm_connector_status status); | |
940 | const char *drm_get_subpixel_order_name(enum subpixel_order order); | |
941 | const char *drm_get_dpms_name(int val); | |
942 | const char *drm_get_dvi_i_subconnector_name(int val); | |
943 | const char *drm_get_dvi_i_select_name(int val); | |
944 | const char *drm_get_tv_subconnector_name(int val); | |
945 | const char *drm_get_tv_select_name(int val); | |
946 | ||
947 | int drm_mode_create_dvi_i_properties(struct drm_device *dev); | |
948 | int drm_mode_create_tv_properties(struct drm_device *dev, | |
949 | unsigned int num_modes, | |
950 | const char * const modes[]); | |
951 | int drm_mode_create_scaling_mode_property(struct drm_device *dev); | |
952 | int drm_mode_create_aspect_ratio_property(struct drm_device *dev); | |
953 | int drm_mode_create_suggested_offset_properties(struct drm_device *dev); | |
954 | ||
955 | int drm_mode_connector_set_path_property(struct drm_connector *connector, | |
956 | const char *path); | |
957 | int drm_mode_connector_set_tile_property(struct drm_connector *connector); | |
958 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, | |
959 | const struct edid *edid); | |
40ee6fbe MN |
960 | void drm_mode_connector_set_link_status_property(struct drm_connector *connector, |
961 | uint64_t link_status); | |
afb21ea6 | 962 | |
9498c19b DV |
963 | /** |
964 | * struct drm_tile_group - Tile group metadata | |
965 | * @refcount: reference count | |
966 | * @dev: DRM device | |
967 | * @id: tile group id exposed to userspace | |
968 | * @group_data: Sink-private data identifying this group | |
969 | * | |
970 | * @group_data corresponds to displayid vend/prod/serial for external screens | |
971 | * with an EDID. | |
972 | */ | |
973 | struct drm_tile_group { | |
974 | struct kref refcount; | |
975 | struct drm_device *dev; | |
976 | int id; | |
977 | u8 group_data[8]; | |
978 | }; | |
979 | ||
980 | struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, | |
981 | char topology[8]); | |
982 | struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, | |
983 | char topology[8]); | |
984 | void drm_mode_put_tile_group(struct drm_device *dev, | |
985 | struct drm_tile_group *tg); | |
986 | ||
afb21ea6 DV |
987 | /** |
988 | * drm_for_each_connector - iterate over all connectors | |
989 | * @connector: the loop cursor | |
990 | * @dev: the DRM device | |
991 | * | |
992 | * Iterate over all connectors of @dev. | |
613051da DV |
993 | * |
994 | * WARNING: | |
995 | * | |
996 | * This iterator is not safe against hotadd/removal of connectors and is | |
997 | * deprecated. Use drm_for_each_connector_iter() instead. | |
afb21ea6 DV |
998 | */ |
999 | #define drm_for_each_connector(connector, dev) \ | |
347e8903 | 1000 | list_for_each_entry(connector, &(dev)->mode_config.connector_list, head) |
afb21ea6 | 1001 | |
613051da DV |
1002 | /** |
1003 | * struct drm_connector_list_iter - connector_list iterator | |
1004 | * | |
1005 | * This iterator tracks state needed to be able to walk the connector_list | |
1006 | * within struct drm_mode_config. Only use together with | |
b982dab1 | 1007 | * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and |
613051da DV |
1008 | * drm_connector_list_iter_next() respectively the convenience macro |
1009 | * drm_for_each_connector_iter(). | |
1010 | */ | |
1011 | struct drm_connector_list_iter { | |
1012 | /* private: */ | |
1013 | struct drm_device *dev; | |
1014 | struct drm_connector *conn; | |
1015 | }; | |
1016 | ||
b982dab1 TR |
1017 | void drm_connector_list_iter_begin(struct drm_device *dev, |
1018 | struct drm_connector_list_iter *iter); | |
613051da DV |
1019 | struct drm_connector * |
1020 | drm_connector_list_iter_next(struct drm_connector_list_iter *iter); | |
b982dab1 | 1021 | void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); |
613051da DV |
1022 | |
1023 | /** | |
1024 | * drm_for_each_connector_iter - connector_list iterator macro | |
ea0dd85a DV |
1025 | * @connector: &struct drm_connector pointer used as cursor |
1026 | * @iter: &struct drm_connector_list_iter | |
613051da DV |
1027 | * |
1028 | * Note that @connector is only valid within the list body, if you want to use | |
b982dab1 TR |
1029 | * @connector after calling drm_connector_list_iter_end() then you need to grab |
1030 | * your own reference first using drm_connector_begin(). | |
613051da DV |
1031 | */ |
1032 | #define drm_for_each_connector_iter(connector, iter) \ | |
1033 | while ((connector = drm_connector_list_iter_next(iter))) | |
1034 | ||
52217195 | 1035 | #endif |