2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef __DRM_CRTC_H__
26 #define __DRM_CRTC_H__
28 #include <linux/i2c.h>
29 #include <linux/spinlock.h>
30 #include <linux/types.h>
31 #include <linux/idr.h>
33 #include <linux/hdmi.h>
34 #include <uapi/drm/drm_mode.h>
35 #include <uapi/drm/drm_fourcc.h>
36 #include <drm/drm_modeset_lock.h>
40 struct drm_framebuffer
;
41 struct drm_object_properties
;
47 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
48 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
49 #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
50 #define DRM_MODE_OBJECT_MODE 0xdededede
51 #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
52 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
53 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
54 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
55 #define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd
56 #define DRM_MODE_OBJECT_ANY 0
58 struct drm_mode_object
{
61 struct drm_object_properties
*properties
;
64 #define DRM_OBJECT_MAX_PROPERTY 24
65 struct drm_object_properties
{
67 /* NOTE: if we ever start dynamically destroying properties (ie.
68 * not at drm_mode_config_cleanup() time), then we'd have to do
69 * a better job of detaching property from mode objects to avoid
70 * dangling property pointers:
72 struct drm_property
*properties
[DRM_OBJECT_MAX_PROPERTY
];
73 /* do not read/write values directly, but use drm_object_property_get_value()
74 * and drm_object_property_set_value():
76 uint64_t values
[DRM_OBJECT_MAX_PROPERTY
];
79 static inline int64_t U642I64(uint64_t val
)
81 return (int64_t)*((int64_t *)&val
);
83 static inline uint64_t I642U64(int64_t val
)
85 return (uint64_t)*((uint64_t *)&val
);
88 /* rotation property bits */
89 #define DRM_ROTATE_0 0
90 #define DRM_ROTATE_90 1
91 #define DRM_ROTATE_180 2
92 #define DRM_ROTATE_270 3
93 #define DRM_REFLECT_X 4
94 #define DRM_REFLECT_Y 5
96 enum drm_connector_force
{
97 DRM_FORCE_UNSPECIFIED
,
99 DRM_FORCE_ON
, /* force on analog part normally */
100 DRM_FORCE_ON_DIGITAL
, /* for DVI-I use digital connector */
103 #include <drm/drm_modes.h>
105 enum drm_connector_status
{
106 connector_status_connected
= 1,
107 connector_status_disconnected
= 2,
108 connector_status_unknown
= 3,
111 enum subpixel_order
{
113 SubPixelHorizontalRGB
,
114 SubPixelHorizontalBGR
,
120 #define DRM_COLOR_FORMAT_RGB444 (1<<0)
121 #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
122 #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
124 * Describes a given display (e.g. CRT or flat panel) and its limitations.
126 struct drm_display_info
{
127 char name
[DRM_DISPLAY_INFO_LEN
];
130 unsigned int width_mm
;
131 unsigned int height_mm
;
133 /* Clock limits FIXME: storage format */
134 unsigned int min_vfreq
, max_vfreq
;
135 unsigned int min_hfreq
, max_hfreq
;
136 unsigned int pixel_clock
;
139 enum subpixel_order subpixel_order
;
142 /* Mask of supported hdmi deep color modes */
143 u8 edid_hdmi_dc_modes
;
148 /* data corresponds to displayid vend/prod/serial */
149 struct drm_tile_group
{
150 struct kref refcount
;
151 struct drm_device
*dev
;
156 struct drm_framebuffer_funcs
{
157 /* note: use drm_framebuffer_remove() */
158 void (*destroy
)(struct drm_framebuffer
*framebuffer
);
159 int (*create_handle
)(struct drm_framebuffer
*fb
,
160 struct drm_file
*file_priv
,
161 unsigned int *handle
);
163 * Optional callback for the dirty fb ioctl.
165 * Userspace can notify the driver via this callback
166 * that a area of the framebuffer has changed and should
167 * be flushed to the display hardware.
169 * See documentation in drm_mode.h for the struct
170 * drm_mode_fb_dirty_cmd for more information as all
171 * the semantics and arguments have a one to one mapping
174 int (*dirty
)(struct drm_framebuffer
*framebuffer
,
175 struct drm_file
*file_priv
, unsigned flags
,
176 unsigned color
, struct drm_clip_rect
*clips
,
180 struct drm_framebuffer
{
181 struct drm_device
*dev
;
183 * Note that the fb is refcounted for the benefit of driver internals,
184 * for example some hw, disabling a CRTC/plane is asynchronous, and
185 * scanout does not actually complete until the next vblank. So some
186 * cleanup (like releasing the reference(s) on the backing GEM bo(s))
187 * should be deferred. In cases like this, the driver would like to
188 * hold a ref to the fb even though it has already been removed from
189 * userspace perspective.
191 struct kref refcount
;
193 * Place on the dev->mode_config.fb_list, access protected by
194 * dev->mode_config.fb_lock.
196 struct list_head head
;
197 struct drm_mode_object base
;
198 const struct drm_framebuffer_funcs
*funcs
;
199 unsigned int pitches
[4];
200 unsigned int offsets
[4];
203 /* depth can be 15 or 16 */
207 uint32_t pixel_format
; /* fourcc format */
208 struct list_head filp_head
;
209 /* if you are using the helper */
210 void *helper_private
;
213 struct drm_property_blob
{
214 struct drm_mode_object base
;
215 struct list_head head
;
217 unsigned char data
[];
220 struct drm_property_enum
{
222 struct list_head head
;
223 char name
[DRM_PROP_NAME_LEN
];
226 struct drm_property
{
227 struct list_head head
;
228 struct drm_mode_object base
;
230 char name
[DRM_PROP_NAME_LEN
];
233 struct drm_device
*dev
;
235 struct list_head enum_list
;
239 struct drm_connector
;
241 struct drm_pending_vblank_event
;
244 struct drm_atomic_state
;
247 * struct drm_crtc_state - mutable CRTC state
248 * @crtc: backpointer to the CRTC
249 * @enable: whether the CRTC should be enabled, gates all other state
250 * @active: whether the CRTC is actively displaying (used for DPMS)
251 * @mode_changed: for use by helpers and drivers when computing state updates
252 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
253 * @last_vblank_count: for helpers and drivers to capture the vblank of the
254 * update to ensure framebuffer cleanup isn't done too early
255 * @planes_changed: for use by helpers and drivers when computing state updates
256 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
257 * @mode: current mode timings
258 * @event: optional pointer to a DRM event to signal upon completion of the
260 * @state: backpointer to global drm_atomic_state
262 * Note that the distinction between @enable and @active is rather subtile:
263 * Flipping @active while @enable is set without changing anything else may
264 * never return in a failure from the ->atomic_check callback. Userspace assumes
265 * that a DPMS On will always succeed. In other words: @enable controls resource
266 * assignment, @active controls the actual hardware state.
268 struct drm_crtc_state
{
269 struct drm_crtc
*crtc
;
274 /* computed state bits used by helpers and drivers */
275 bool planes_changed
: 1;
276 bool mode_changed
: 1;
278 /* attached planes bitmask:
279 * WARNING: transitional helpers do not maintain plane_mask so
280 * drivers not converted over to atomic helpers should not rely
281 * on plane_mask being accurate!
285 /* last_vblank_count: for vblank waits before cleanup */
286 u32 last_vblank_count
;
288 /* adjusted_mode: for use by helpers and drivers */
289 struct drm_display_mode adjusted_mode
;
291 struct drm_display_mode mode
;
293 struct drm_pending_vblank_event
*event
;
295 struct drm_atomic_state
*state
;
299 * struct drm_crtc_funcs - control CRTCs for a given device
300 * @save: save CRTC state
301 * @restore: restore CRTC state
302 * @reset: reset CRTC after state has been invalidated (e.g. resume)
303 * @cursor_set: setup the cursor
304 * @cursor_set2: setup the cursor with hotspot, superseeds @cursor_set if set
305 * @cursor_move: move the cursor
306 * @gamma_set: specify color ramp for CRTC
307 * @destroy: deinit and free object
308 * @set_property: called when a property is changed
309 * @set_config: apply a new CRTC configuration
310 * @page_flip: initiate a page flip
311 * @atomic_duplicate_state: duplicate the atomic state for this CRTC
312 * @atomic_destroy_state: destroy an atomic state for this CRTC
313 * @atomic_set_property: set a property on an atomic state for this CRTC
315 * The drm_crtc_funcs structure is the central CRTC management structure
316 * in the DRM. Each CRTC controls one or more connectors (note that the name
317 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
318 * connectors, not just CRTs).
320 * Each driver is responsible for filling out this structure at startup time,
321 * in addition to providing other modesetting features, like i2c and DDC
324 struct drm_crtc_funcs
{
325 /* Save CRTC state */
326 void (*save
)(struct drm_crtc
*crtc
); /* suspend? */
327 /* Restore CRTC state */
328 void (*restore
)(struct drm_crtc
*crtc
); /* resume? */
329 /* Reset CRTC state */
330 void (*reset
)(struct drm_crtc
*crtc
);
332 /* cursor controls */
333 int (*cursor_set
)(struct drm_crtc
*crtc
, struct drm_file
*file_priv
,
334 uint32_t handle
, uint32_t width
, uint32_t height
);
335 int (*cursor_set2
)(struct drm_crtc
*crtc
, struct drm_file
*file_priv
,
336 uint32_t handle
, uint32_t width
, uint32_t height
,
337 int32_t hot_x
, int32_t hot_y
);
338 int (*cursor_move
)(struct drm_crtc
*crtc
, int x
, int y
);
340 /* Set gamma on the CRTC */
341 void (*gamma_set
)(struct drm_crtc
*crtc
, u16
*r
, u16
*g
, u16
*b
,
342 uint32_t start
, uint32_t size
);
343 /* Object destroy routine */
344 void (*destroy
)(struct drm_crtc
*crtc
);
346 int (*set_config
)(struct drm_mode_set
*set
);
349 * Flip to the given framebuffer. This implements the page
350 * flip ioctl described in drm_mode.h, specifically, the
351 * implementation must return immediately and block all
352 * rendering to the current fb until the flip has completed.
353 * If userspace set the event flag in the ioctl, the event
354 * argument will point to an event to send back when the flip
355 * completes, otherwise it will be NULL.
357 int (*page_flip
)(struct drm_crtc
*crtc
,
358 struct drm_framebuffer
*fb
,
359 struct drm_pending_vblank_event
*event
,
362 int (*set_property
)(struct drm_crtc
*crtc
,
363 struct drm_property
*property
, uint64_t val
);
365 /* atomic update handling */
366 struct drm_crtc_state
*(*atomic_duplicate_state
)(struct drm_crtc
*crtc
);
367 void (*atomic_destroy_state
)(struct drm_crtc
*crtc
,
368 struct drm_crtc_state
*state
);
369 int (*atomic_set_property
)(struct drm_crtc
*crtc
,
370 struct drm_crtc_state
*state
,
371 struct drm_property
*property
,
376 * struct drm_crtc - central CRTC control structure
377 * @dev: parent DRM device
378 * @port: OF node used by drm_of_find_possible_crtcs()
379 * @head: list management
380 * @mutex: per-CRTC locking
381 * @base: base KMS object for ID tracking etc.
382 * @primary: primary plane for this CRTC
383 * @cursor: cursor plane for this CRTC
384 * @cursor_x: current x position of the cursor, used for universal cursor planes
385 * @cursor_y: current y position of the cursor, used for universal cursor planes
386 * @enabled: is this CRTC enabled?
387 * @mode: current mode timings
388 * @hwmode: mode timings as programmed to hw regs
389 * @invert_dimensions: for purposes of error checking crtc vs fb sizes,
390 * invert the width/height of the crtc. This is used if the driver
391 * is performing 90 or 270 degree rotated scanout
392 * @x: x position on screen
393 * @y: y position on screen
394 * @funcs: CRTC control functions
395 * @gamma_size: size of gamma ramp
396 * @gamma_store: gamma ramp values
397 * @framedur_ns: precise frame timing
398 * @linedur_ns: precise line timing
399 * @pixeldur_ns: precise pixel timing
400 * @helper_private: mid-layer private data
401 * @properties: property tracking for this CRTC
402 * @state: current atomic state for this CRTC
403 * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
406 * Each CRTC may have one or more connectors associated with it. This structure
407 * allows the CRTC to be controlled.
410 struct drm_device
*dev
;
411 struct device_node
*port
;
412 struct list_head head
;
417 * This provides a read lock for the overall crtc state (mode, dpms
418 * state, ...) and a write lock for everything which can be update
419 * without a full modeset (fb, cursor data, ...)
421 struct drm_modeset_lock mutex
;
423 struct drm_mode_object base
;
425 /* primary and cursor planes for CRTC */
426 struct drm_plane
*primary
;
427 struct drm_plane
*cursor
;
429 /* position of cursor plane on crtc */
435 /* Requested mode from modesetting. */
436 struct drm_display_mode mode
;
438 /* Programmed mode in hw, after adjustments for encoders,
439 * crtc, panel scaling etc. Needed for timestamping etc.
441 struct drm_display_mode hwmode
;
443 bool invert_dimensions
;
446 const struct drm_crtc_funcs
*funcs
;
448 /* CRTC gamma size for reporting to userspace */
450 uint16_t *gamma_store
;
452 /* Constants needed for precise vblank and swap timestamping. */
453 int framedur_ns
, linedur_ns
, pixeldur_ns
;
455 /* if you are using the helper */
456 void *helper_private
;
458 struct drm_object_properties properties
;
460 struct drm_crtc_state
*state
;
463 * For legacy crtc ioctls so that atomic drivers can get at the locking
466 struct drm_modeset_acquire_ctx
*acquire_ctx
;
470 * struct drm_connector_state - mutable connector state
471 * @connector: backpointer to the connector
472 * @crtc: CRTC to connect connector to, NULL if disabled
473 * @best_encoder: can be used by helpers and drivers to select the encoder
474 * @state: backpointer to global drm_atomic_state
476 struct drm_connector_state
{
477 struct drm_connector
*connector
;
479 struct drm_crtc
*crtc
; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
481 struct drm_encoder
*best_encoder
;
483 struct drm_atomic_state
*state
;
487 * struct drm_connector_funcs - control connectors on a given device
488 * @dpms: set power state (see drm_crtc_funcs above)
489 * @save: save connector state
490 * @restore: restore connector state
491 * @reset: reset connector after state has been invalidated (e.g. resume)
492 * @detect: is this connector active?
493 * @fill_modes: fill mode list for this connector
494 * @set_property: property for this connector may need an update
495 * @destroy: make object go away
496 * @force: notify the driver that the connector is forced on
497 * @atomic_duplicate_state: duplicate the atomic state for this connector
498 * @atomic_destroy_state: destroy an atomic state for this connector
499 * @atomic_set_property: set a property on an atomic state for this connector
501 * Each CRTC may have one or more connectors attached to it. The functions
502 * below allow the core DRM code to control connectors, enumerate available modes,
505 struct drm_connector_funcs
{
506 void (*dpms
)(struct drm_connector
*connector
, int mode
);
507 void (*save
)(struct drm_connector
*connector
);
508 void (*restore
)(struct drm_connector
*connector
);
509 void (*reset
)(struct drm_connector
*connector
);
511 /* Check to see if anything is attached to the connector.
512 * @force is set to false whilst polling, true when checking the
513 * connector due to user request. @force can be used by the driver
514 * to avoid expensive, destructive operations during automated
517 enum drm_connector_status (*detect
)(struct drm_connector
*connector
,
519 int (*fill_modes
)(struct drm_connector
*connector
, uint32_t max_width
, uint32_t max_height
);
520 int (*set_property
)(struct drm_connector
*connector
, struct drm_property
*property
,
522 void (*destroy
)(struct drm_connector
*connector
);
523 void (*force
)(struct drm_connector
*connector
);
525 /* atomic update handling */
526 struct drm_connector_state
*(*atomic_duplicate_state
)(struct drm_connector
*connector
);
527 void (*atomic_destroy_state
)(struct drm_connector
*connector
,
528 struct drm_connector_state
*state
);
529 int (*atomic_set_property
)(struct drm_connector
*connector
,
530 struct drm_connector_state
*state
,
531 struct drm_property
*property
,
536 * struct drm_encoder_funcs - encoder controls
537 * @reset: reset state (e.g. at init or resume time)
538 * @destroy: cleanup and free associated data
540 * Encoders sit between CRTCs and connectors.
542 struct drm_encoder_funcs
{
543 void (*reset
)(struct drm_encoder
*encoder
);
544 void (*destroy
)(struct drm_encoder
*encoder
);
547 #define DRM_CONNECTOR_MAX_ENCODER 3
550 * struct drm_encoder - central DRM encoder structure
551 * @dev: parent DRM device
552 * @head: list management
553 * @base: base KMS object
554 * @name: encoder name
555 * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
556 * @possible_crtcs: bitmask of potential CRTC bindings
557 * @possible_clones: bitmask of potential sibling encoders for cloning
558 * @crtc: currently bound CRTC
559 * @bridge: bridge associated to the encoder
560 * @funcs: control functions
561 * @helper_private: mid-layer private data
563 * CRTCs drive pixels to encoders, which convert them into signals
564 * appropriate for a given connector or set of connectors.
567 struct drm_device
*dev
;
568 struct list_head head
;
570 struct drm_mode_object base
;
573 uint32_t possible_crtcs
;
574 uint32_t possible_clones
;
576 struct drm_crtc
*crtc
;
577 struct drm_bridge
*bridge
;
578 const struct drm_encoder_funcs
*funcs
;
579 void *helper_private
;
582 /* should we poll this connector for connects and disconnects */
583 /* hot plug detectable */
584 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
585 /* poll for connections */
586 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
587 /* can cleanly poll for disconnections without flickering the screen */
588 /* DACs should rarely do this without a lot of testing */
589 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
591 #define MAX_ELD_BYTES 128
594 * struct drm_connector - central DRM connector control structure
595 * @dev: parent DRM device
596 * @kdev: kernel device for sysfs attributes
597 * @attr: sysfs attributes
598 * @head: list management
599 * @base: base KMS object
600 * @name: connector name
601 * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
602 * @connector_type_id: index into connector type enum
603 * @interlace_allowed: can this connector handle interlaced modes?
604 * @doublescan_allowed: can this connector handle doublescan?
605 * @stereo_allowed: can this connector handle stereo modes?
606 * @modes: modes available on this connector (from fill_modes() + user)
607 * @status: one of the drm_connector_status enums (connected, not, or unknown)
608 * @probed_modes: list of modes derived directly from the display
609 * @display_info: information about attached display (e.g. from EDID)
610 * @funcs: connector control functions
611 * @edid_blob_ptr: DRM property containing EDID if present
612 * @properties: property tracking for this connector
613 * @path_blob_ptr: DRM blob property data for the DP MST path property
614 * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
615 * @dpms: current dpms state
616 * @helper_private: mid-layer private data
617 * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
618 * @force: a %DRM_FORCE_<foo> state for forced mode sets
619 * @override_edid: has the EDID been overwritten through debugfs for testing?
620 * @encoder_ids: valid encoders for this connector
621 * @encoder: encoder driving this connector, if any
622 * @eld: EDID-like data, if present
623 * @dvi_dual: dual link DVI, if found
624 * @max_tmds_clock: max clock rate, if found
625 * @latency_present: AV delay info from ELD, if found
626 * @video_latency: video latency info from ELD, if found
627 * @audio_latency: audio latency info from ELD, if found
628 * @null_edid_counter: track sinks that give us all zeros for the EDID
629 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
630 * @debugfs_entry: debugfs directory for this connector
631 * @state: current atomic state for this connector
632 * @has_tile: is this connector connected to a tiled monitor
633 * @tile_group: tile group for the connected monitor
634 * @tile_is_single_monitor: whether the tile is one monitor housing
635 * @num_h_tile: number of horizontal tiles in the tile group
636 * @num_v_tile: number of vertical tiles in the tile group
637 * @tile_h_loc: horizontal location of this tile
638 * @tile_v_loc: vertical location of this tile
639 * @tile_h_size: horizontal size of this tile.
640 * @tile_v_size: vertical size of this tile.
642 * Each connector may be connected to one or more CRTCs, or may be clonable by
643 * another connector if they can share a CRTC. Each connector also has a specific
644 * position in the broader display (referred to as a 'screen' though it could
645 * span multiple monitors).
647 struct drm_connector
{
648 struct drm_device
*dev
;
650 struct device_attribute
*attr
;
651 struct list_head head
;
653 struct drm_mode_object base
;
657 int connector_type_id
;
658 bool interlace_allowed
;
659 bool doublescan_allowed
;
661 struct list_head modes
; /* list of modes on this connector */
663 enum drm_connector_status status
;
665 /* these are modes added by probing with DDC or the BIOS */
666 struct list_head probed_modes
;
668 struct drm_display_info display_info
;
669 const struct drm_connector_funcs
*funcs
;
671 struct drm_property_blob
*edid_blob_ptr
;
672 struct drm_object_properties properties
;
674 struct drm_property_blob
*path_blob_ptr
;
676 struct drm_property_blob
*tile_blob_ptr
;
678 uint8_t polled
; /* DRM_CONNECTOR_POLL_* */
680 /* requested DPMS state */
683 void *helper_private
;
685 /* forced on connector */
686 struct drm_cmdline_mode cmdline_mode
;
687 enum drm_connector_force force
;
689 uint32_t encoder_ids
[DRM_CONNECTOR_MAX_ENCODER
];
690 struct drm_encoder
*encoder
; /* currently active encoder */
693 uint8_t eld
[MAX_ELD_BYTES
];
695 int max_tmds_clock
; /* in MHz */
696 bool latency_present
[2];
697 int video_latency
[2]; /* [0]: progressive, [1]: interlaced */
698 int audio_latency
[2];
699 int null_edid_counter
; /* needed to workaround some HW bugs where we get all 0s */
700 unsigned bad_edid_counter
;
702 struct dentry
*debugfs_entry
;
704 struct drm_connector_state
*state
;
708 struct drm_tile_group
*tile_group
;
709 bool tile_is_single_monitor
;
711 uint8_t num_h_tile
, num_v_tile
;
712 uint8_t tile_h_loc
, tile_v_loc
;
713 uint16_t tile_h_size
, tile_v_size
;
717 * struct drm_plane_state - mutable plane state
718 * @plane: backpointer to the plane
719 * @crtc: currently bound CRTC, NULL if disabled
720 * @fb: currently bound framebuffer
721 * @fence: optional fence to wait for before scanning out @fb
722 * @crtc_x: left position of visible portion of plane on crtc
723 * @crtc_y: upper position of visible portion of plane on crtc
724 * @crtc_w: width of visible portion of plane on crtc
725 * @crtc_h: height of visible portion of plane on crtc
726 * @src_x: left position of visible portion of plane within
728 * @src_y: upper position of visible portion of plane within
730 * @src_w: width of visible portion of plane (in 16.16)
731 * @src_h: height of visible portion of plane (in 16.16)
732 * @state: backpointer to global drm_atomic_state
734 struct drm_plane_state
{
735 struct drm_plane
*plane
;
737 struct drm_crtc
*crtc
; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
738 struct drm_framebuffer
*fb
; /* do not write directly, use drm_atomic_set_fb_for_plane() */
741 /* Signed dest location allows it to be partially off screen */
742 int32_t crtc_x
, crtc_y
;
743 uint32_t crtc_w
, crtc_h
;
745 /* Source values are 16.16 fixed point */
746 uint32_t src_x
, src_y
;
747 uint32_t src_h
, src_w
;
749 struct drm_atomic_state
*state
;
754 * struct drm_plane_funcs - driver plane control functions
755 * @update_plane: update the plane configuration
756 * @disable_plane: shut down the plane
757 * @destroy: clean up plane resources
758 * @reset: reset plane after state has been invalidated (e.g. resume)
759 * @set_property: called when a property is changed
760 * @atomic_duplicate_state: duplicate the atomic state for this plane
761 * @atomic_destroy_state: destroy an atomic state for this plane
762 * @atomic_set_property: set a property on an atomic state for this plane
764 struct drm_plane_funcs
{
765 int (*update_plane
)(struct drm_plane
*plane
,
766 struct drm_crtc
*crtc
, struct drm_framebuffer
*fb
,
767 int crtc_x
, int crtc_y
,
768 unsigned int crtc_w
, unsigned int crtc_h
,
769 uint32_t src_x
, uint32_t src_y
,
770 uint32_t src_w
, uint32_t src_h
);
771 int (*disable_plane
)(struct drm_plane
*plane
);
772 void (*destroy
)(struct drm_plane
*plane
);
773 void (*reset
)(struct drm_plane
*plane
);
775 int (*set_property
)(struct drm_plane
*plane
,
776 struct drm_property
*property
, uint64_t val
);
778 /* atomic update handling */
779 struct drm_plane_state
*(*atomic_duplicate_state
)(struct drm_plane
*plane
);
780 void (*atomic_destroy_state
)(struct drm_plane
*plane
,
781 struct drm_plane_state
*state
);
782 int (*atomic_set_property
)(struct drm_plane
*plane
,
783 struct drm_plane_state
*state
,
784 struct drm_property
*property
,
788 enum drm_plane_type
{
789 DRM_PLANE_TYPE_OVERLAY
,
790 DRM_PLANE_TYPE_PRIMARY
,
791 DRM_PLANE_TYPE_CURSOR
,
795 * struct drm_plane - central DRM plane control structure
796 * @dev: DRM device this plane belongs to
797 * @head: for list management
798 * @base: base mode object
799 * @possible_crtcs: pipes this plane can be bound to
800 * @format_types: array of formats supported by this plane
801 * @format_count: number of formats supported
802 * @crtc: currently bound CRTC
803 * @fb: currently bound fb
804 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
805 * drm_mode_set_config_internal() to implement correct refcounting.
806 * @funcs: helper functions
807 * @properties: property tracking for this plane
808 * @type: type of plane (overlay, primary, cursor)
809 * @state: current atomic state for this plane
812 struct drm_device
*dev
;
813 struct list_head head
;
815 struct drm_modeset_lock mutex
;
817 struct drm_mode_object base
;
819 uint32_t possible_crtcs
;
820 uint32_t *format_types
;
821 uint32_t format_count
;
823 struct drm_crtc
*crtc
;
824 struct drm_framebuffer
*fb
;
826 struct drm_framebuffer
*old_fb
;
828 const struct drm_plane_funcs
*funcs
;
830 struct drm_object_properties properties
;
832 enum drm_plane_type type
;
834 void *helper_private
;
836 struct drm_plane_state
*state
;
840 * struct drm_bridge_funcs - drm_bridge control functions
841 * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge
842 * @disable: Called right before encoder prepare, disables the bridge
843 * @post_disable: Called right after encoder prepare, for lockstepped disable
844 * @mode_set: Set this mode to the bridge
845 * @pre_enable: Called right before encoder commit, for lockstepped commit
846 * @enable: Called right after encoder commit, enables the bridge
847 * @destroy: make object go away
849 struct drm_bridge_funcs
{
850 bool (*mode_fixup
)(struct drm_bridge
*bridge
,
851 const struct drm_display_mode
*mode
,
852 struct drm_display_mode
*adjusted_mode
);
853 void (*disable
)(struct drm_bridge
*bridge
);
854 void (*post_disable
)(struct drm_bridge
*bridge
);
855 void (*mode_set
)(struct drm_bridge
*bridge
,
856 struct drm_display_mode
*mode
,
857 struct drm_display_mode
*adjusted_mode
);
858 void (*pre_enable
)(struct drm_bridge
*bridge
);
859 void (*enable
)(struct drm_bridge
*bridge
);
860 void (*destroy
)(struct drm_bridge
*bridge
);
864 * struct drm_bridge - central DRM bridge control structure
865 * @dev: DRM device this bridge belongs to
866 * @head: list management
867 * @base: base mode object
868 * @funcs: control functions
869 * @driver_private: pointer to the bridge driver's internal context
872 struct drm_device
*dev
;
873 struct list_head head
;
875 struct drm_mode_object base
;
877 const struct drm_bridge_funcs
*funcs
;
878 void *driver_private
;
882 * struct struct drm_atomic_state - the global state object for atomic updates
883 * @dev: parent DRM device
884 * @flags: state flags like async update
885 * @planes: pointer to array of plane pointers
886 * @plane_states: pointer to array of plane states pointers
887 * @crtcs: pointer to array of CRTC pointers
888 * @crtc_states: pointer to array of CRTC states pointers
889 * @num_connector: size of the @connectors and @connector_states arrays
890 * @connectors: pointer to array of connector pointers
891 * @connector_states: pointer to array of connector states pointers
892 * @acquire_ctx: acquire context for this atomic modeset state update
894 struct drm_atomic_state
{
895 struct drm_device
*dev
;
897 struct drm_plane
**planes
;
898 struct drm_plane_state
**plane_states
;
899 struct drm_crtc
**crtcs
;
900 struct drm_crtc_state
**crtc_states
;
902 struct drm_connector
**connectors
;
903 struct drm_connector_state
**connector_states
;
905 struct drm_modeset_acquire_ctx
*acquire_ctx
;
910 * struct drm_mode_set - new values for a CRTC config change
911 * @fb: framebuffer to use for new config
912 * @crtc: CRTC whose configuration we're about to change
913 * @mode: mode timings to use
914 * @x: position of this CRTC relative to @fb
915 * @y: position of this CRTC relative to @fb
916 * @connectors: array of connectors to drive with this CRTC if possible
917 * @num_connectors: size of @connectors array
919 * Represents a single crtc the connectors that it drives with what mode
920 * and from which framebuffer it scans out from.
922 * This is used to set modes.
924 struct drm_mode_set
{
925 struct drm_framebuffer
*fb
;
926 struct drm_crtc
*crtc
;
927 struct drm_display_mode
*mode
;
932 struct drm_connector
**connectors
;
933 size_t num_connectors
;
937 * struct drm_mode_config_funcs - basic driver provided mode setting functions
938 * @fb_create: create a new framebuffer object
939 * @output_poll_changed: function to handle output configuration changes
940 * @atomic_check: check whether a give atomic state update is possible
941 * @atomic_commit: commit an atomic state update previously verified with
944 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
947 struct drm_mode_config_funcs
{
948 struct drm_framebuffer
*(*fb_create
)(struct drm_device
*dev
,
949 struct drm_file
*file_priv
,
950 struct drm_mode_fb_cmd2
*mode_cmd
);
951 void (*output_poll_changed
)(struct drm_device
*dev
);
953 int (*atomic_check
)(struct drm_device
*dev
,
954 struct drm_atomic_state
*a
);
955 int (*atomic_commit
)(struct drm_device
*dev
,
956 struct drm_atomic_state
*a
,
961 * struct drm_mode_group - group of mode setting resources for potential sub-grouping
962 * @num_crtcs: CRTC count
963 * @num_encoders: encoder count
964 * @num_connectors: connector count
965 * @num_bridges: bridge count
966 * @id_list: list of KMS object IDs in this group
968 * Currently this simply tracks the global mode setting state. But in the
969 * future it could allow groups of objects to be set aside into independent
970 * control groups for use by different user level processes (e.g. two X servers
971 * running simultaneously on different heads, each with their own mode
972 * configuration and freedom of mode setting).
974 struct drm_mode_group
{
976 uint32_t num_encoders
;
977 uint32_t num_connectors
;
978 uint32_t num_bridges
;
980 /* list of object IDs for this group */
985 * struct drm_mode_config - Mode configuration control structure
986 * @mutex: mutex protecting KMS related lists and structures
987 * @connection_mutex: ww mutex protecting connector state and routing
988 * @acquire_ctx: global implicit acquire context used by atomic drivers for
990 * @idr_mutex: mutex for KMS ID allocation and management
991 * @crtc_idr: main KMS ID tracking object
992 * @fb_lock: mutex to protect fb state and lists
993 * @num_fb: number of fbs available
994 * @fb_list: list of framebuffers available
995 * @num_connector: number of connectors on this device
996 * @connector_list: list of connector objects
997 * @num_bridge: number of bridges on this device
998 * @bridge_list: list of bridge objects
999 * @num_encoder: number of encoders on this device
1000 * @encoder_list: list of encoder objects
1001 * @num_overlay_plane: number of overlay planes on this device
1002 * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device
1003 * @plane_list: list of plane objects
1004 * @num_crtc: number of CRTCs on this device
1005 * @crtc_list: list of CRTC objects
1006 * @property_list: list of property objects
1007 * @min_width: minimum pixel width on this device
1008 * @min_height: minimum pixel height on this device
1009 * @max_width: maximum pixel width on this device
1010 * @max_height: maximum pixel height on this device
1011 * @funcs: core driver provided mode setting functions
1012 * @fb_base: base address of the framebuffer
1013 * @poll_enabled: track polling support for this device
1014 * @poll_running: track polling status for this device
1015 * @output_poll_work: delayed work for polling in process context
1016 * @property_blob_list: list of all the blob property objects
1017 * @*_property: core property tracking
1018 * @preferred_depth: preferred RBG pixel depth, used by fb helpers
1019 * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
1020 * @async_page_flip: does this device support async flips on the primary plane?
1021 * @cursor_width: hint to userspace for max cursor width
1022 * @cursor_height: hint to userspace for max cursor height
1024 * Core mode resource tracking structure. All CRTC, encoders, and connectors
1025 * enumerated by the driver are added here, as are global properties. Some
1026 * global restrictions are also here, e.g. dimension restrictions.
1028 struct drm_mode_config
{
1029 struct mutex mutex
; /* protects configuration (mode lists etc.) */
1030 struct drm_modeset_lock connection_mutex
; /* protects connector->encoder and encoder->crtc links */
1031 struct drm_modeset_acquire_ctx
*acquire_ctx
; /* for legacy _lock_all() / _unlock_all() */
1032 struct mutex idr_mutex
; /* for IDR management */
1033 struct idr crtc_idr
; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
1034 struct idr tile_idr
; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
1035 /* this is limited to one for now */
1037 struct mutex fb_lock
; /* proctects global and per-file fb lists */
1039 struct list_head fb_list
;
1042 struct list_head connector_list
;
1044 struct list_head bridge_list
;
1046 struct list_head encoder_list
;
1049 * Track # of overlay planes separately from # of total planes. By
1050 * default we only advertise overlay planes to userspace; if userspace
1051 * sets the "universal plane" capability bit, we'll go ahead and
1052 * expose all planes.
1054 int num_overlay_plane
;
1055 int num_total_plane
;
1056 struct list_head plane_list
;
1059 struct list_head crtc_list
;
1061 struct list_head property_list
;
1063 int min_width
, min_height
;
1064 int max_width
, max_height
;
1065 const struct drm_mode_config_funcs
*funcs
;
1066 resource_size_t fb_base
;
1068 /* output poll support */
1071 struct delayed_work output_poll_work
;
1073 /* pointers to standard properties */
1074 struct list_head property_blob_list
;
1075 struct drm_property
*edid_property
;
1076 struct drm_property
*dpms_property
;
1077 struct drm_property
*path_property
;
1078 struct drm_property
*tile_property
;
1079 struct drm_property
*plane_type_property
;
1080 struct drm_property
*rotation_property
;
1082 /* DVI-I properties */
1083 struct drm_property
*dvi_i_subconnector_property
;
1084 struct drm_property
*dvi_i_select_subconnector_property
;
1087 struct drm_property
*tv_subconnector_property
;
1088 struct drm_property
*tv_select_subconnector_property
;
1089 struct drm_property
*tv_mode_property
;
1090 struct drm_property
*tv_left_margin_property
;
1091 struct drm_property
*tv_right_margin_property
;
1092 struct drm_property
*tv_top_margin_property
;
1093 struct drm_property
*tv_bottom_margin_property
;
1094 struct drm_property
*tv_brightness_property
;
1095 struct drm_property
*tv_contrast_property
;
1096 struct drm_property
*tv_flicker_reduction_property
;
1097 struct drm_property
*tv_overscan_property
;
1098 struct drm_property
*tv_saturation_property
;
1099 struct drm_property
*tv_hue_property
;
1101 /* Optional properties */
1102 struct drm_property
*scaling_mode_property
;
1103 struct drm_property
*aspect_ratio_property
;
1104 struct drm_property
*dirty_info_property
;
1106 /* properties for virtual machine layout */
1107 struct drm_property
*suggested_x_property
;
1108 struct drm_property
*suggested_y_property
;
1110 /* dumb ioctl parameters */
1111 uint32_t preferred_depth
, prefer_shadow
;
1113 /* whether async page flip is supported or not */
1114 bool async_page_flip
;
1117 uint32_t cursor_width
, cursor_height
;
1121 * drm_for_each_plane_mask - iterate over planes specified by bitmask
1122 * @plane: the loop cursor
1123 * @dev: the DRM device
1124 * @plane_mask: bitmask of plane indices
1126 * Iterate over all planes specified by bitmask.
1128 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
1129 list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
1130 if ((plane_mask) & (1 << drm_plane_index(plane)))
1133 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
1134 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
1135 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
1136 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
1137 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
1138 #define obj_to_property(x) container_of(x, struct drm_property, base)
1139 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
1140 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
1142 struct drm_prop_enum_list
{
1147 extern int drm_crtc_init_with_planes(struct drm_device
*dev
,
1148 struct drm_crtc
*crtc
,
1149 struct drm_plane
*primary
,
1150 struct drm_plane
*cursor
,
1151 const struct drm_crtc_funcs
*funcs
);
1152 extern void drm_crtc_cleanup(struct drm_crtc
*crtc
);
1153 extern unsigned int drm_crtc_index(struct drm_crtc
*crtc
);
1156 * drm_crtc_mask - find the mask of a registered CRTC
1157 * @crtc: CRTC to find mask for
1159 * Given a registered CRTC, return the mask bit of that CRTC for an
1160 * encoder's possible_crtcs field.
1162 static inline uint32_t drm_crtc_mask(struct drm_crtc
*crtc
)
1164 return 1 << drm_crtc_index(crtc
);
1167 extern void drm_connector_ida_init(void);
1168 extern void drm_connector_ida_destroy(void);
1169 extern int drm_connector_init(struct drm_device
*dev
,
1170 struct drm_connector
*connector
,
1171 const struct drm_connector_funcs
*funcs
,
1172 int connector_type
);
1173 int drm_connector_register(struct drm_connector
*connector
);
1174 void drm_connector_unregister(struct drm_connector
*connector
);
1176 extern void drm_connector_cleanup(struct drm_connector
*connector
);
1177 extern unsigned int drm_connector_index(struct drm_connector
*connector
);
1178 /* helper to unplug all connectors from sysfs for device */
1179 extern void drm_connector_unplug_all(struct drm_device
*dev
);
1181 extern int drm_bridge_init(struct drm_device
*dev
, struct drm_bridge
*bridge
,
1182 const struct drm_bridge_funcs
*funcs
);
1183 extern void drm_bridge_cleanup(struct drm_bridge
*bridge
);
1185 extern int drm_encoder_init(struct drm_device
*dev
,
1186 struct drm_encoder
*encoder
,
1187 const struct drm_encoder_funcs
*funcs
,
1191 * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
1192 * @encoder: encoder to test
1193 * @crtc: crtc to test
1195 * Return false if @encoder can't be driven by @crtc, true otherwise.
1197 static inline bool drm_encoder_crtc_ok(struct drm_encoder
*encoder
,
1198 struct drm_crtc
*crtc
)
1200 return !!(encoder
->possible_crtcs
& drm_crtc_mask(crtc
));
1203 extern int drm_universal_plane_init(struct drm_device
*dev
,
1204 struct drm_plane
*plane
,
1205 unsigned long possible_crtcs
,
1206 const struct drm_plane_funcs
*funcs
,
1207 const uint32_t *formats
,
1208 uint32_t format_count
,
1209 enum drm_plane_type type
);
1210 extern int drm_plane_init(struct drm_device
*dev
,
1211 struct drm_plane
*plane
,
1212 unsigned long possible_crtcs
,
1213 const struct drm_plane_funcs
*funcs
,
1214 const uint32_t *formats
, uint32_t format_count
,
1216 extern void drm_plane_cleanup(struct drm_plane
*plane
);
1217 extern unsigned int drm_plane_index(struct drm_plane
*plane
);
1218 extern void drm_plane_force_disable(struct drm_plane
*plane
);
1219 extern int drm_crtc_check_viewport(const struct drm_crtc
*crtc
,
1221 const struct drm_display_mode
*mode
,
1222 const struct drm_framebuffer
*fb
);
1224 extern void drm_encoder_cleanup(struct drm_encoder
*encoder
);
1226 extern const char *drm_get_connector_status_name(enum drm_connector_status status
);
1227 extern const char *drm_get_subpixel_order_name(enum subpixel_order order
);
1228 extern const char *drm_get_dpms_name(int val
);
1229 extern const char *drm_get_dvi_i_subconnector_name(int val
);
1230 extern const char *drm_get_dvi_i_select_name(int val
);
1231 extern const char *drm_get_tv_subconnector_name(int val
);
1232 extern const char *drm_get_tv_select_name(int val
);
1233 extern void drm_fb_release(struct drm_file
*file_priv
);
1234 extern int drm_mode_group_init_legacy_group(struct drm_device
*dev
, struct drm_mode_group
*group
);
1235 extern void drm_mode_group_destroy(struct drm_mode_group
*group
);
1236 extern void drm_reinit_primary_mode_group(struct drm_device
*dev
);
1237 extern bool drm_probe_ddc(struct i2c_adapter
*adapter
);
1238 extern struct edid
*drm_get_edid(struct drm_connector
*connector
,
1239 struct i2c_adapter
*adapter
);
1240 extern struct edid
*drm_edid_duplicate(const struct edid
*edid
);
1241 extern int drm_add_edid_modes(struct drm_connector
*connector
, struct edid
*edid
);
1242 extern void drm_mode_config_init(struct drm_device
*dev
);
1243 extern void drm_mode_config_reset(struct drm_device
*dev
);
1244 extern void drm_mode_config_cleanup(struct drm_device
*dev
);
1246 extern int drm_mode_connector_set_path_property(struct drm_connector
*connector
,
1248 int drm_mode_connector_set_tile_property(struct drm_connector
*connector
);
1249 extern int drm_mode_connector_update_edid_property(struct drm_connector
*connector
,
1250 const struct edid
*edid
);
1252 static inline bool drm_property_type_is(struct drm_property
*property
,
1255 /* instanceof for props.. handles extended type vs original types: */
1256 if (property
->flags
& DRM_MODE_PROP_EXTENDED_TYPE
)
1257 return (property
->flags
& DRM_MODE_PROP_EXTENDED_TYPE
) == type
;
1258 return property
->flags
& type
;
1261 static inline bool drm_property_type_valid(struct drm_property
*property
)
1263 if (property
->flags
& DRM_MODE_PROP_EXTENDED_TYPE
)
1264 return !(property
->flags
& DRM_MODE_PROP_LEGACY_TYPE
);
1265 return !!(property
->flags
& DRM_MODE_PROP_LEGACY_TYPE
);
1268 extern int drm_object_property_set_value(struct drm_mode_object
*obj
,
1269 struct drm_property
*property
,
1271 extern int drm_object_property_get_value(struct drm_mode_object
*obj
,
1272 struct drm_property
*property
,
1274 extern int drm_framebuffer_init(struct drm_device
*dev
,
1275 struct drm_framebuffer
*fb
,
1276 const struct drm_framebuffer_funcs
*funcs
);
1277 extern struct drm_framebuffer
*drm_framebuffer_lookup(struct drm_device
*dev
,
1279 extern void drm_framebuffer_unreference(struct drm_framebuffer
*fb
);
1280 extern void drm_framebuffer_reference(struct drm_framebuffer
*fb
);
1281 extern void drm_framebuffer_remove(struct drm_framebuffer
*fb
);
1282 extern void drm_framebuffer_cleanup(struct drm_framebuffer
*fb
);
1283 extern void drm_framebuffer_unregister_private(struct drm_framebuffer
*fb
);
1285 extern void drm_object_attach_property(struct drm_mode_object
*obj
,
1286 struct drm_property
*property
,
1288 extern struct drm_property
*drm_property_create(struct drm_device
*dev
, int flags
,
1289 const char *name
, int num_values
);
1290 extern struct drm_property
*drm_property_create_enum(struct drm_device
*dev
, int flags
,
1292 const struct drm_prop_enum_list
*props
,
1294 struct drm_property
*drm_property_create_bitmask(struct drm_device
*dev
,
1295 int flags
, const char *name
,
1296 const struct drm_prop_enum_list
*props
,
1298 uint64_t supported_bits
);
1299 struct drm_property
*drm_property_create_range(struct drm_device
*dev
, int flags
,
1301 uint64_t min
, uint64_t max
);
1302 struct drm_property
*drm_property_create_signed_range(struct drm_device
*dev
,
1303 int flags
, const char *name
,
1304 int64_t min
, int64_t max
);
1305 struct drm_property
*drm_property_create_object(struct drm_device
*dev
,
1306 int flags
, const char *name
, uint32_t type
);
1307 extern void drm_property_destroy(struct drm_device
*dev
, struct drm_property
*property
);
1308 extern int drm_property_add_enum(struct drm_property
*property
, int index
,
1309 uint64_t value
, const char *name
);
1310 extern int drm_mode_create_dvi_i_properties(struct drm_device
*dev
);
1311 extern int drm_mode_create_tv_properties(struct drm_device
*dev
,
1312 unsigned int num_modes
,
1314 extern int drm_mode_create_scaling_mode_property(struct drm_device
*dev
);
1315 extern int drm_mode_create_aspect_ratio_property(struct drm_device
*dev
);
1316 extern int drm_mode_create_dirty_info_property(struct drm_device
*dev
);
1317 extern int drm_mode_create_suggested_offset_properties(struct drm_device
*dev
);
1319 extern int drm_mode_connector_attach_encoder(struct drm_connector
*connector
,
1320 struct drm_encoder
*encoder
);
1321 extern int drm_mode_crtc_set_gamma_size(struct drm_crtc
*crtc
,
1323 extern struct drm_mode_object
*drm_mode_object_find(struct drm_device
*dev
,
1324 uint32_t id
, uint32_t type
);
1327 extern int drm_mode_getresources(struct drm_device
*dev
,
1328 void *data
, struct drm_file
*file_priv
);
1329 extern int drm_mode_getplane_res(struct drm_device
*dev
, void *data
,
1330 struct drm_file
*file_priv
);
1331 extern int drm_mode_getcrtc(struct drm_device
*dev
,
1332 void *data
, struct drm_file
*file_priv
);
1333 extern int drm_mode_getconnector(struct drm_device
*dev
,
1334 void *data
, struct drm_file
*file_priv
);
1335 extern int drm_mode_set_config_internal(struct drm_mode_set
*set
);
1336 extern int drm_mode_setcrtc(struct drm_device
*dev
,
1337 void *data
, struct drm_file
*file_priv
);
1338 extern int drm_mode_getplane(struct drm_device
*dev
,
1339 void *data
, struct drm_file
*file_priv
);
1340 extern int drm_mode_setplane(struct drm_device
*dev
,
1341 void *data
, struct drm_file
*file_priv
);
1342 extern int drm_mode_cursor_ioctl(struct drm_device
*dev
,
1343 void *data
, struct drm_file
*file_priv
);
1344 extern int drm_mode_cursor2_ioctl(struct drm_device
*dev
,
1345 void *data
, struct drm_file
*file_priv
);
1346 extern int drm_mode_addfb(struct drm_device
*dev
,
1347 void *data
, struct drm_file
*file_priv
);
1348 extern int drm_mode_addfb2(struct drm_device
*dev
,
1349 void *data
, struct drm_file
*file_priv
);
1350 extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp
, uint32_t depth
);
1351 extern int drm_mode_rmfb(struct drm_device
*dev
,
1352 void *data
, struct drm_file
*file_priv
);
1353 extern int drm_mode_getfb(struct drm_device
*dev
,
1354 void *data
, struct drm_file
*file_priv
);
1355 extern int drm_mode_dirtyfb_ioctl(struct drm_device
*dev
,
1356 void *data
, struct drm_file
*file_priv
);
1358 extern int drm_mode_getproperty_ioctl(struct drm_device
*dev
,
1359 void *data
, struct drm_file
*file_priv
);
1360 extern int drm_mode_getblob_ioctl(struct drm_device
*dev
,
1361 void *data
, struct drm_file
*file_priv
);
1362 extern int drm_mode_connector_property_set_ioctl(struct drm_device
*dev
,
1363 void *data
, struct drm_file
*file_priv
);
1364 extern int drm_mode_getencoder(struct drm_device
*dev
,
1365 void *data
, struct drm_file
*file_priv
);
1366 extern int drm_mode_gamma_get_ioctl(struct drm_device
*dev
,
1367 void *data
, struct drm_file
*file_priv
);
1368 extern int drm_mode_gamma_set_ioctl(struct drm_device
*dev
,
1369 void *data
, struct drm_file
*file_priv
);
1370 extern u8
drm_match_cea_mode(const struct drm_display_mode
*to_match
);
1371 extern enum hdmi_picture_aspect
drm_get_cea_aspect_ratio(const u8 video_code
);
1372 extern bool drm_detect_hdmi_monitor(struct edid
*edid
);
1373 extern bool drm_detect_monitor_audio(struct edid
*edid
);
1374 extern bool drm_rgb_quant_range_selectable(struct edid
*edid
);
1375 extern int drm_mode_page_flip_ioctl(struct drm_device
*dev
,
1376 void *data
, struct drm_file
*file_priv
);
1377 extern int drm_add_modes_noedid(struct drm_connector
*connector
,
1378 int hdisplay
, int vdisplay
);
1379 extern void drm_set_preferred_mode(struct drm_connector
*connector
,
1380 int hpref
, int vpref
);
1382 extern int drm_edid_header_is_valid(const u8
*raw_edid
);
1383 extern bool drm_edid_block_valid(u8
*raw_edid
, int block
, bool print_bad_edid
);
1384 extern bool drm_edid_is_valid(struct edid
*edid
);
1386 extern struct drm_tile_group
*drm_mode_create_tile_group(struct drm_device
*dev
,
1388 extern struct drm_tile_group
*drm_mode_get_tile_group(struct drm_device
*dev
,
1390 extern void drm_mode_put_tile_group(struct drm_device
*dev
,
1391 struct drm_tile_group
*tg
);
1392 struct drm_display_mode
*drm_mode_find_dmt(struct drm_device
*dev
,
1393 int hsize
, int vsize
, int fresh
,
1396 extern int drm_mode_create_dumb_ioctl(struct drm_device
*dev
,
1397 void *data
, struct drm_file
*file_priv
);
1398 extern int drm_mode_mmap_dumb_ioctl(struct drm_device
*dev
,
1399 void *data
, struct drm_file
*file_priv
);
1400 extern int drm_mode_destroy_dumb_ioctl(struct drm_device
*dev
,
1401 void *data
, struct drm_file
*file_priv
);
1402 extern int drm_mode_obj_get_properties_ioctl(struct drm_device
*dev
, void *data
,
1403 struct drm_file
*file_priv
);
1404 extern int drm_mode_obj_set_property_ioctl(struct drm_device
*dev
, void *data
,
1405 struct drm_file
*file_priv
);
1406 extern int drm_mode_plane_set_obj_prop(struct drm_plane
*plane
,
1407 struct drm_property
*property
,
1410 extern void drm_fb_get_bpp_depth(uint32_t format
, unsigned int *depth
,
1412 extern int drm_format_num_planes(uint32_t format
);
1413 extern int drm_format_plane_cpp(uint32_t format
, int plane
);
1414 extern int drm_format_horz_chroma_subsampling(uint32_t format
);
1415 extern int drm_format_vert_chroma_subsampling(uint32_t format
);
1416 extern const char *drm_get_format_name(uint32_t format
);
1417 extern struct drm_property
*drm_mode_create_rotation_property(struct drm_device
*dev
,
1418 unsigned int supported_rotations
);
1419 extern unsigned int drm_rotation_simplify(unsigned int rotation
,
1420 unsigned int supported_rotations
);
1424 static inline struct drm_plane
*drm_plane_find(struct drm_device
*dev
,
1427 struct drm_mode_object
*mo
;
1428 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_PLANE
);
1429 return mo
? obj_to_plane(mo
) : NULL
;
1432 static inline struct drm_crtc
*drm_crtc_find(struct drm_device
*dev
,
1435 struct drm_mode_object
*mo
;
1436 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_CRTC
);
1437 return mo
? obj_to_crtc(mo
) : NULL
;
1440 static inline struct drm_encoder
*drm_encoder_find(struct drm_device
*dev
,
1443 struct drm_mode_object
*mo
;
1444 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_ENCODER
);
1445 return mo
? obj_to_encoder(mo
) : NULL
;
1448 static inline struct drm_connector
*drm_connector_find(struct drm_device
*dev
,
1451 struct drm_mode_object
*mo
;
1452 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_CONNECTOR
);
1453 return mo
? obj_to_connector(mo
) : NULL
;
1456 static inline struct drm_property
*drm_property_find(struct drm_device
*dev
,
1459 struct drm_mode_object
*mo
;
1460 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_PROPERTY
);
1461 return mo
? obj_to_property(mo
) : NULL
;
1464 static inline struct drm_property_blob
*
1465 drm_property_blob_find(struct drm_device
*dev
, uint32_t id
)
1467 struct drm_mode_object
*mo
;
1468 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_BLOB
);
1469 return mo
? obj_to_blob(mo
) : NULL
;
1472 /* Plane list iterator for legacy (overlay only) planes. */
1473 #define drm_for_each_legacy_plane(plane, planelist) \
1474 list_for_each_entry(plane, planelist, head) \
1475 if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1477 #endif /* __DRM_CRTC_H__ */