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