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