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