Home | History | Annotate | Line # | Download | only in drm
drm_crtc.h revision 1.7
      1 /*	$NetBSD: drm_crtc.h,v 1.7 2018/08/27 06:46:02 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright  2006 Keith Packard
      5  * Copyright  2007-2008 Dave Airlie
      6  * Copyright  2007-2008 Intel Corporation
      7  *   Jesse Barnes <jesse.barnes (at) intel.com>
      8  *
      9  * Permission is hereby granted, free of charge, to any person obtaining a
     10  * copy of this software and associated documentation files (the "Software"),
     11  * to deal in the Software without restriction, including without limitation
     12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     13  * and/or sell copies of the Software, and to permit persons to whom the
     14  * Software is furnished to do so, subject to the following conditions:
     15  *
     16  * The above copyright notice and this permission notice shall be included in
     17  * all copies or substantial portions of the Software.
     18  *
     19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     22  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     25  * OTHER DEALINGS IN THE SOFTWARE.
     26  */
     27 #ifndef __DRM_CRTC_H__
     28 #define __DRM_CRTC_H__
     29 
     30 #include <linux/i2c.h>
     31 #include <linux/spinlock.h>
     32 #include <linux/types.h>
     33 #include <linux/idr.h>
     34 #include <linux/fb.h>
     35 #include <linux/hdmi.h>
     36 #include <linux/media-bus-format.h>
     37 #include <linux/kref.h>
     38 #include <linux/mutex.h>
     39 #include <linux/workqueue.h>
     40 #include <uapi/drm/drm_mode.h>
     41 #include <uapi/drm/drm_fourcc.h>
     42 #include <drm/drm_modeset_lock.h>
     43 
     44 struct drm_device;
     45 struct drm_mode_set;
     46 struct drm_framebuffer;
     47 struct drm_object_properties;
     48 struct drm_file;
     49 struct drm_clip_rect;
     50 struct device_node;
     51 struct fence;
     52 
     53 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
     54 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
     55 #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
     56 #define DRM_MODE_OBJECT_MODE 0xdededede
     57 #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
     58 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
     59 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
     60 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
     61 #define DRM_MODE_OBJECT_ANY 0
     62 
     63 struct drm_mode_object {
     64 	uint32_t id;
     65 	uint32_t type;
     66 	struct drm_object_properties *properties;
     67 };
     68 
     69 #define DRM_OBJECT_MAX_PROPERTY 24
     70 struct drm_object_properties {
     71 	int count, atomic_count;
     72 	/* NOTE: if we ever start dynamically destroying properties (ie.
     73 	 * not at drm_mode_config_cleanup() time), then we'd have to do
     74 	 * a better job of detaching property from mode objects to avoid
     75 	 * dangling property pointers:
     76 	 */
     77 	struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
     78 	/* do not read/write values directly, but use drm_object_property_get_value()
     79 	 * and drm_object_property_set_value():
     80 	 */
     81 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
     82 };
     83 
     84 static inline int64_t U642I64(uint64_t val)
     85 {
     86 	return (int64_t)*((int64_t *)&val);
     87 }
     88 static inline uint64_t I642U64(int64_t val)
     89 {
     90 	return (uint64_t)*((uint64_t *)&val);
     91 }
     92 
     93 /* rotation property bits */
     94 #define DRM_ROTATE_MASK 0x0f
     95 #define DRM_ROTATE_0	0
     96 #define DRM_ROTATE_90	1
     97 #define DRM_ROTATE_180	2
     98 #define DRM_ROTATE_270	3
     99 #define DRM_REFLECT_MASK (~DRM_ROTATE_MASK)
    100 #define DRM_REFLECT_X	4
    101 #define DRM_REFLECT_Y	5
    102 
    103 enum drm_connector_force {
    104 	DRM_FORCE_UNSPECIFIED,
    105 	DRM_FORCE_OFF,
    106 	DRM_FORCE_ON,         /* force on analog part normally */
    107 	DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
    108 };
    109 
    110 #include <drm/drm_modes.h>
    111 
    112 enum drm_connector_status {
    113 	connector_status_connected = 1,
    114 	connector_status_disconnected = 2,
    115 	connector_status_unknown = 3,
    116 };
    117 
    118 enum subpixel_order {
    119 	SubPixelUnknown = 0,
    120 	SubPixelHorizontalRGB,
    121 	SubPixelHorizontalBGR,
    122 	SubPixelVerticalRGB,
    123 	SubPixelVerticalBGR,
    124 	SubPixelNone,
    125 };
    126 
    127 #define DRM_COLOR_FORMAT_RGB444		(1<<0)
    128 #define DRM_COLOR_FORMAT_YCRCB444	(1<<1)
    129 #define DRM_COLOR_FORMAT_YCRCB422	(1<<2)
    130 /*
    131  * Describes a given display (e.g. CRT or flat panel) and its limitations.
    132  */
    133 struct drm_display_info {
    134 	char name[DRM_DISPLAY_INFO_LEN];
    135 
    136 	/* Physical size */
    137         unsigned int width_mm;
    138 	unsigned int height_mm;
    139 
    140 	/* Clock limits FIXME: storage format */
    141 	unsigned int min_vfreq, max_vfreq;
    142 	unsigned int min_hfreq, max_hfreq;
    143 	unsigned int pixel_clock;
    144 	unsigned int bpc;
    145 
    146 	enum subpixel_order subpixel_order;
    147 	u32 color_formats;
    148 
    149 	u32 *bus_formats;
    150 	unsigned int num_bus_formats;
    151 
    152 	/* Mask of supported hdmi deep color modes */
    153 	u8 edid_hdmi_dc_modes;
    154 
    155 	u8 cea_rev;
    156 };
    157 
    158 /* data corresponds to displayid vend/prod/serial */
    159 struct drm_tile_group {
    160 	struct kref refcount;
    161 	struct drm_device *dev;
    162 	int id;
    163 	u8 group_data[8];
    164 };
    165 
    166 struct drm_framebuffer_funcs {
    167 	/* note: use drm_framebuffer_remove() */
    168 	void (*destroy)(struct drm_framebuffer *framebuffer);
    169 	int (*create_handle)(struct drm_framebuffer *fb,
    170 			     struct drm_file *file_priv,
    171 			     unsigned int *handle);
    172 	/*
    173 	 * Optional callback for the dirty fb ioctl.
    174 	 *
    175 	 * Userspace can notify the driver via this callback
    176 	 * that a area of the framebuffer has changed and should
    177 	 * be flushed to the display hardware.
    178 	 *
    179 	 * See documentation in drm_mode.h for the struct
    180 	 * drm_mode_fb_dirty_cmd for more information as all
    181 	 * the semantics and arguments have a one to one mapping
    182 	 * on this function.
    183 	 */
    184 	int (*dirty)(struct drm_framebuffer *framebuffer,
    185 		     struct drm_file *file_priv, unsigned flags,
    186 		     unsigned color, struct drm_clip_rect *clips,
    187 		     unsigned num_clips);
    188 };
    189 
    190 struct drm_framebuffer {
    191 	struct drm_device *dev;
    192 	/*
    193 	 * Note that the fb is refcounted for the benefit of driver internals,
    194 	 * for example some hw, disabling a CRTC/plane is asynchronous, and
    195 	 * scanout does not actually complete until the next vblank.  So some
    196 	 * cleanup (like releasing the reference(s) on the backing GEM bo(s))
    197 	 * should be deferred.  In cases like this, the driver would like to
    198 	 * hold a ref to the fb even though it has already been removed from
    199 	 * userspace perspective.
    200 	 */
    201 	struct kref refcount;
    202 	/*
    203 	 * Place on the dev->mode_config.fb_list, access protected by
    204 	 * dev->mode_config.fb_lock.
    205 	 */
    206 	struct list_head head;
    207 	struct drm_mode_object base;
    208 	const struct drm_framebuffer_funcs *funcs;
    209 	unsigned int pitches[4];
    210 	unsigned int offsets[4];
    211 	uint64_t modifier[4];
    212 	unsigned int width;
    213 	unsigned int height;
    214 	/* depth can be 15 or 16 */
    215 	unsigned int depth;
    216 	int bits_per_pixel;
    217 	int flags;
    218 	uint32_t pixel_format; /* fourcc format */
    219 	struct list_head filp_head;
    220 };
    221 
    222 struct drm_property_blob {
    223 	struct drm_mode_object base;
    224 	struct drm_device *dev;
    225 	struct kref refcount;
    226 	struct list_head head_global;
    227 	struct list_head head_file;
    228 	size_t length;
    229 	unsigned char data[];
    230 };
    231 
    232 struct drm_property_enum {
    233 	uint64_t value;
    234 	struct list_head head;
    235 	char name[DRM_PROP_NAME_LEN];
    236 };
    237 
    238 struct drm_property {
    239 	struct list_head head;
    240 	struct drm_mode_object base;
    241 	uint32_t flags;
    242 	char name[DRM_PROP_NAME_LEN];
    243 	uint32_t num_values;
    244 	uint64_t *values;
    245 	struct drm_device *dev;
    246 
    247 	struct list_head enum_list;
    248 };
    249 
    250 struct drm_crtc;
    251 struct drm_connector;
    252 struct drm_encoder;
    253 struct drm_pending_vblank_event;
    254 struct drm_plane;
    255 struct drm_bridge;
    256 struct drm_atomic_state;
    257 
    258 /**
    259  * struct drm_crtc_state - mutable CRTC state
    260  * @crtc: backpointer to the CRTC
    261  * @enable: whether the CRTC should be enabled, gates all other state
    262  * @active: whether the CRTC is actively displaying (used for DPMS)
    263  * @planes_changed: planes on this crtc are updated
    264  * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
    265  * @active_changed: crtc_state->active has been toggled.
    266  * @connectors_changed: connectors to this crtc have been updated
    267  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
    268  * @last_vblank_count: for helpers and drivers to capture the vblank of the
    269  * 	update to ensure framebuffer cleanup isn't done too early
    270  * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
    271  * @mode: current mode timings
    272  * @event: optional pointer to a DRM event to signal upon completion of the
    273  * 	state update
    274  * @state: backpointer to global drm_atomic_state
    275  *
    276  * Note that the distinction between @enable and @active is rather subtile:
    277  * Flipping @active while @enable is set without changing anything else may
    278  * never return in a failure from the ->atomic_check callback. Userspace assumes
    279  * that a DPMS On will always succeed. In other words: @enable controls resource
    280  * assignment, @active controls the actual hardware state.
    281  */
    282 struct drm_crtc_state {
    283 	struct drm_crtc *crtc;
    284 
    285 	bool enable;
    286 	bool active;
    287 
    288 	/* computed state bits used by helpers and drivers */
    289 	bool planes_changed : 1;
    290 	bool mode_changed : 1;
    291 	bool active_changed : 1;
    292 	bool connectors_changed : 1;
    293 
    294 	/* attached planes bitmask:
    295 	 * WARNING: transitional helpers do not maintain plane_mask so
    296 	 * drivers not converted over to atomic helpers should not rely
    297 	 * on plane_mask being accurate!
    298 	 */
    299 	u32 plane_mask;
    300 
    301 	/* last_vblank_count: for vblank waits before cleanup */
    302 	u32 last_vblank_count;
    303 
    304 	/* adjusted_mode: for use by helpers and drivers */
    305 	struct drm_display_mode adjusted_mode;
    306 
    307 	struct drm_display_mode mode;
    308 
    309 	/* blob property to expose current mode to atomic userspace */
    310 	struct drm_property_blob *mode_blob;
    311 
    312 	struct drm_pending_vblank_event *event;
    313 
    314 	struct drm_atomic_state *state;
    315 };
    316 
    317 /**
    318  * struct drm_crtc_funcs - control CRTCs for a given device
    319  * @save: save CRTC state
    320  * @restore: restore CRTC state
    321  * @reset: reset CRTC after state has been invalidated (e.g. resume)
    322  * @cursor_set: setup the cursor
    323  * @cursor_set2: setup the cursor with hotspot, superseeds @cursor_set if set
    324  * @cursor_move: move the cursor
    325  * @gamma_set: specify color ramp for CRTC
    326  * @destroy: deinit and free object
    327  * @set_property: called when a property is changed
    328  * @set_config: apply a new CRTC configuration
    329  * @page_flip: initiate a page flip
    330  * @atomic_duplicate_state: duplicate the atomic state for this CRTC
    331  * @atomic_destroy_state: destroy an atomic state for this CRTC
    332  * @atomic_set_property: set a property on an atomic state for this CRTC
    333  *    (do not call directly, use drm_atomic_crtc_set_property())
    334  * @atomic_get_property: get a property on an atomic state for this CRTC
    335  *    (do not call directly, use drm_atomic_crtc_get_property())
    336  *
    337  * The drm_crtc_funcs structure is the central CRTC management structure
    338  * in the DRM.  Each CRTC controls one or more connectors (note that the name
    339  * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
    340  * connectors, not just CRTs).
    341  *
    342  * Each driver is responsible for filling out this structure at startup time,
    343  * in addition to providing other modesetting features, like i2c and DDC
    344  * bus accessors.
    345  */
    346 struct drm_crtc_funcs {
    347 	/* Save CRTC state */
    348 	void (*save)(struct drm_crtc *crtc); /* suspend? */
    349 	/* Restore CRTC state */
    350 	void (*restore)(struct drm_crtc *crtc); /* resume? */
    351 	/* Reset CRTC state */
    352 	void (*reset)(struct drm_crtc *crtc);
    353 
    354 	/* cursor controls */
    355 	int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
    356 			  uint32_t handle, uint32_t width, uint32_t height);
    357 	int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
    358 			   uint32_t handle, uint32_t width, uint32_t height,
    359 			   int32_t hot_x, int32_t hot_y);
    360 	int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
    361 
    362 	/* Set gamma on the CRTC */
    363 	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
    364 			  uint32_t start, uint32_t size);
    365 	/* Object destroy routine */
    366 	void (*destroy)(struct drm_crtc *crtc);
    367 
    368 	int (*set_config)(struct drm_mode_set *set);
    369 
    370 	/*
    371 	 * Flip to the given framebuffer.  This implements the page
    372 	 * flip ioctl described in drm_mode.h, specifically, the
    373 	 * implementation must return immediately and block all
    374 	 * rendering to the current fb until the flip has completed.
    375 	 * If userspace set the event flag in the ioctl, the event
    376 	 * argument will point to an event to send back when the flip
    377 	 * completes, otherwise it will be NULL.
    378 	 */
    379 	int (*page_flip)(struct drm_crtc *crtc,
    380 			 struct drm_framebuffer *fb,
    381 			 struct drm_pending_vblank_event *event,
    382 			 uint32_t flags);
    383 
    384 	int (*set_property)(struct drm_crtc *crtc,
    385 			    struct drm_property *property, uint64_t val);
    386 
    387 	/* atomic update handling */
    388 	struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc);
    389 	void (*atomic_destroy_state)(struct drm_crtc *crtc,
    390 				     struct drm_crtc_state *state);
    391 	int (*atomic_set_property)(struct drm_crtc *crtc,
    392 				   struct drm_crtc_state *state,
    393 				   struct drm_property *property,
    394 				   uint64_t val);
    395 	int (*atomic_get_property)(struct drm_crtc *crtc,
    396 				   const struct drm_crtc_state *state,
    397 				   struct drm_property *property,
    398 				   uint64_t *val);
    399 };
    400 
    401 /**
    402  * struct drm_crtc - central CRTC control structure
    403  * @dev: parent DRM device
    404  * @port: OF node used by drm_of_find_possible_crtcs()
    405  * @head: list management
    406  * @mutex: per-CRTC locking
    407  * @base: base KMS object for ID tracking etc.
    408  * @primary: primary plane for this CRTC
    409  * @cursor: cursor plane for this CRTC
    410  * @cursor_x: current x position of the cursor, used for universal cursor planes
    411  * @cursor_y: current y position of the cursor, used for universal cursor planes
    412  * @enabled: is this CRTC enabled?
    413  * @mode: current mode timings
    414  * @hwmode: mode timings as programmed to hw regs
    415  * @x: x position on screen
    416  * @y: y position on screen
    417  * @funcs: CRTC control functions
    418  * @gamma_size: size of gamma ramp
    419  * @gamma_store: gamma ramp values
    420  * @helper_private: mid-layer private data
    421  * @properties: property tracking for this CRTC
    422  * @state: current atomic state for this CRTC
    423  * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
    424  * 	legacy ioctls
    425  *
    426  * Each CRTC may have one or more connectors associated with it.  This structure
    427  * allows the CRTC to be controlled.
    428  */
    429 struct drm_crtc {
    430 	struct drm_device *dev;
    431 	struct device_node *port;
    432 	struct list_head head;
    433 
    434 	/*
    435 	 * crtc mutex
    436 	 *
    437 	 * This provides a read lock for the overall crtc state (mode, dpms
    438 	 * state, ...) and a write lock for everything which can be update
    439 	 * without a full modeset (fb, cursor data, ...)
    440 	 */
    441 	struct drm_modeset_lock mutex;
    442 
    443 	struct drm_mode_object base;
    444 
    445 	/* primary and cursor planes for CRTC */
    446 	struct drm_plane *primary;
    447 	struct drm_plane *cursor;
    448 
    449 	/* position of cursor plane on crtc */
    450 	int cursor_x;
    451 	int cursor_y;
    452 
    453 	bool enabled;
    454 
    455 	/* Requested mode from modesetting. */
    456 	struct drm_display_mode mode;
    457 
    458 	/* Programmed mode in hw, after adjustments for encoders,
    459 	 * crtc, panel scaling etc. Needed for timestamping etc.
    460 	 */
    461 	struct drm_display_mode hwmode;
    462 
    463 	int x, y;
    464 	const struct drm_crtc_funcs *funcs;
    465 
    466 	/* CRTC gamma size for reporting to userspace */
    467 	uint32_t gamma_size;
    468 	uint16_t *gamma_store;
    469 
    470 	/* if you are using the helper */
    471 	const void *helper_private;
    472 
    473 	struct drm_object_properties properties;
    474 
    475 	struct drm_crtc_state *state;
    476 
    477 	/*
    478 	 * For legacy crtc ioctls so that atomic drivers can get at the locking
    479 	 * acquire context.
    480 	 */
    481 	struct drm_modeset_acquire_ctx *acquire_ctx;
    482 };
    483 
    484 /**
    485  * struct drm_connector_state - mutable connector state
    486  * @connector: backpointer to the connector
    487  * @crtc: CRTC to connect connector to, NULL if disabled
    488  * @best_encoder: can be used by helpers and drivers to select the encoder
    489  * @state: backpointer to global drm_atomic_state
    490  */
    491 struct drm_connector_state {
    492 	struct drm_connector *connector;
    493 
    494 	struct drm_crtc *crtc;  /* do not write directly, use drm_atomic_set_crtc_for_connector() */
    495 
    496 	struct drm_encoder *best_encoder;
    497 
    498 	struct drm_atomic_state *state;
    499 };
    500 
    501 /**
    502  * struct drm_connector_funcs - control connectors on a given device
    503  * @dpms: set power state
    504  * @save: save connector state
    505  * @restore: restore connector state
    506  * @reset: reset connector after state has been invalidated (e.g. resume)
    507  * @detect: is this connector active?
    508  * @fill_modes: fill mode list for this connector
    509  * @set_property: property for this connector may need an update
    510  * @destroy: make object go away
    511  * @force: notify the driver that the connector is forced on
    512  * @atomic_duplicate_state: duplicate the atomic state for this connector
    513  * @atomic_destroy_state: destroy an atomic state for this connector
    514  * @atomic_set_property: set a property on an atomic state for this connector
    515  *    (do not call directly, use drm_atomic_connector_set_property())
    516  * @atomic_get_property: get a property on an atomic state for this connector
    517  *    (do not call directly, use drm_atomic_connector_get_property())
    518  *
    519  * Each CRTC may have one or more connectors attached to it.  The functions
    520  * below allow the core DRM code to control connectors, enumerate available modes,
    521  * etc.
    522  */
    523 struct drm_connector_funcs {
    524 	int (*dpms)(struct drm_connector *connector, int mode);
    525 	void (*save)(struct drm_connector *connector);
    526 	void (*restore)(struct drm_connector *connector);
    527 	void (*reset)(struct drm_connector *connector);
    528 
    529 	/* Check to see if anything is attached to the connector.
    530 	 * @force is set to false whilst polling, true when checking the
    531 	 * connector due to user request. @force can be used by the driver
    532 	 * to avoid expensive, destructive operations during automated
    533 	 * probing.
    534 	 */
    535 	enum drm_connector_status (*detect)(struct drm_connector *connector,
    536 					    bool force);
    537 	int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
    538 	int (*set_property)(struct drm_connector *connector, struct drm_property *property,
    539 			     uint64_t val);
    540 	void (*destroy)(struct drm_connector *connector);
    541 	void (*force)(struct drm_connector *connector);
    542 
    543 	/* atomic update handling */
    544 	struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
    545 	void (*atomic_destroy_state)(struct drm_connector *connector,
    546 				     struct drm_connector_state *state);
    547 	int (*atomic_set_property)(struct drm_connector *connector,
    548 				   struct drm_connector_state *state,
    549 				   struct drm_property *property,
    550 				   uint64_t val);
    551 	int (*atomic_get_property)(struct drm_connector *connector,
    552 				   const struct drm_connector_state *state,
    553 				   struct drm_property *property,
    554 				   uint64_t *val);
    555 };
    556 
    557 /**
    558  * struct drm_encoder_funcs - encoder controls
    559  * @reset: reset state (e.g. at init or resume time)
    560  * @destroy: cleanup and free associated data
    561  *
    562  * Encoders sit between CRTCs and connectors.
    563  */
    564 struct drm_encoder_funcs {
    565 	void (*reset)(struct drm_encoder *encoder);
    566 	void (*destroy)(struct drm_encoder *encoder);
    567 };
    568 
    569 #define DRM_CONNECTOR_MAX_ENCODER 3
    570 
    571 /**
    572  * struct drm_encoder - central DRM encoder structure
    573  * @dev: parent DRM device
    574  * @head: list management
    575  * @base: base KMS object
    576  * @name: encoder name
    577  * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
    578  * @possible_crtcs: bitmask of potential CRTC bindings
    579  * @possible_clones: bitmask of potential sibling encoders for cloning
    580  * @crtc: currently bound CRTC
    581  * @bridge: bridge associated to the encoder
    582  * @funcs: control functions
    583  * @helper_private: mid-layer private data
    584  *
    585  * CRTCs drive pixels to encoders, which convert them into signals
    586  * appropriate for a given connector or set of connectors.
    587  */
    588 struct drm_encoder {
    589 	struct drm_device *dev;
    590 	struct list_head head;
    591 
    592 	struct drm_mode_object base;
    593 	char *name;
    594 	int encoder_type;
    595 	uint32_t possible_crtcs;
    596 	uint32_t possible_clones;
    597 
    598 	struct drm_crtc *crtc;
    599 	struct drm_bridge *bridge;
    600 	const struct drm_encoder_funcs *funcs;
    601 	const void *helper_private;
    602 };
    603 
    604 /* should we poll this connector for connects and disconnects */
    605 /* hot plug detectable */
    606 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
    607 /* poll for connections */
    608 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
    609 /* can cleanly poll for disconnections without flickering the screen */
    610 /* DACs should rarely do this without a lot of testing */
    611 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
    612 
    613 #define MAX_ELD_BYTES	128
    614 
    615 /**
    616  * struct drm_connector - central DRM connector control structure
    617  * @dev: parent DRM device
    618  * @kdev: kernel device for sysfs attributes
    619  * @attr: sysfs attributes
    620  * @head: list management
    621  * @base: base KMS object
    622  * @name: connector name
    623  * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
    624  * @connector_type_id: index into connector type enum
    625  * @interlace_allowed: can this connector handle interlaced modes?
    626  * @doublescan_allowed: can this connector handle doublescan?
    627  * @stereo_allowed: can this connector handle stereo modes?
    628  * @modes: modes available on this connector (from fill_modes() + user)
    629  * @status: one of the drm_connector_status enums (connected, not, or unknown)
    630  * @probed_modes: list of modes derived directly from the display
    631  * @display_info: information about attached display (e.g. from EDID)
    632  * @funcs: connector control functions
    633  * @edid_blob_ptr: DRM property containing EDID if present
    634  * @properties: property tracking for this connector
    635  * @path_blob_ptr: DRM blob property data for the DP MST path property
    636  * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
    637  * @dpms: current dpms state
    638  * @helper_private: mid-layer private data
    639  * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
    640  * @force: a %DRM_FORCE_<foo> state for forced mode sets
    641  * @override_edid: has the EDID been overwritten through debugfs for testing?
    642  * @encoder_ids: valid encoders for this connector
    643  * @encoder: encoder driving this connector, if any
    644  * @physical_address: HDMI physical address
    645  * @eld: EDID-like data, if present
    646  * @dvi_dual: dual link DVI, if found
    647  * @max_tmds_clock: max clock rate, if found
    648  * @latency_present: AV delay info from ELD, if found
    649  * @video_latency: video latency info from ELD, if found
    650  * @audio_latency: audio latency info from ELD, if found
    651  * @null_edid_counter: track sinks that give us all zeros for the EDID
    652  * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
    653  * @edid_corrupt: indicates whether the last read EDID was corrupt
    654  * @debugfs_entry: debugfs directory for this connector
    655  * @state: current atomic state for this connector
    656  * @has_tile: is this connector connected to a tiled monitor
    657  * @tile_group: tile group for the connected monitor
    658  * @tile_is_single_monitor: whether the tile is one monitor housing
    659  * @num_h_tile: number of horizontal tiles in the tile group
    660  * @num_v_tile: number of vertical tiles in the tile group
    661  * @tile_h_loc: horizontal location of this tile
    662  * @tile_v_loc: vertical location of this tile
    663  * @tile_h_size: horizontal size of this tile.
    664  * @tile_v_size: vertical size of this tile.
    665  *
    666  * Each connector may be connected to one or more CRTCs, or may be clonable by
    667  * another connector if they can share a CRTC.  Each connector also has a specific
    668  * position in the broader display (referred to as a 'screen' though it could
    669  * span multiple monitors).
    670  */
    671 struct drm_connector {
    672 	struct drm_device *dev;
    673 	struct device *kdev;
    674 	struct device_attribute *attr;
    675 	struct list_head head;
    676 
    677 	struct drm_mode_object base;
    678 
    679 	char *name;
    680 	int connector_type;
    681 	int connector_type_id;
    682 	bool interlace_allowed;
    683 	bool doublescan_allowed;
    684 	bool stereo_allowed;
    685 	struct list_head modes; /* list of modes on this connector */
    686 
    687 	enum drm_connector_status status;
    688 
    689 	/* these are modes added by probing with DDC or the BIOS */
    690 	struct list_head probed_modes;
    691 
    692 	struct drm_display_info display_info;
    693 	const struct drm_connector_funcs *funcs;
    694 
    695 	struct drm_property_blob *edid_blob_ptr;
    696 	struct drm_object_properties properties;
    697 
    698 	struct drm_property_blob *path_blob_ptr;
    699 
    700 	struct drm_property_blob *tile_blob_ptr;
    701 
    702 	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
    703 
    704 	/* requested DPMS state */
    705 	int dpms;
    706 
    707 	const void *helper_private;
    708 
    709 	/* forced on connector */
    710 	struct drm_cmdline_mode cmdline_mode;
    711 	enum drm_connector_force force;
    712 	bool override_edid;
    713 	uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
    714 	struct drm_encoder *encoder; /* currently active encoder */
    715 
    716 	/* EDID bits */
    717 	uint16_t physical_address;
    718 	uint8_t eld[MAX_ELD_BYTES];
    719 	bool dvi_dual;
    720 	int max_tmds_clock;	/* in MHz */
    721 	bool latency_present[2];
    722 	int video_latency[2];	/* [0]: progressive, [1]: interlaced */
    723 	int audio_latency[2];
    724 	int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
    725 	unsigned bad_edid_counter;
    726 
    727 	/* Flag for raw EDID header corruption - used in Displayport
    728 	 * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
    729 	 */
    730 	bool edid_corrupt;
    731 
    732 	struct dentry *debugfs_entry;
    733 
    734 	struct drm_connector_state *state;
    735 
    736 	/* DisplayID bits */
    737 	bool has_tile;
    738 	struct drm_tile_group *tile_group;
    739 	bool tile_is_single_monitor;
    740 
    741 	uint8_t num_h_tile, num_v_tile;
    742 	uint8_t tile_h_loc, tile_v_loc;
    743 	uint16_t tile_h_size, tile_v_size;
    744 };
    745 
    746 /**
    747  * struct drm_plane_state - mutable plane state
    748  * @plane: backpointer to the plane
    749  * @crtc: currently bound CRTC, NULL if disabled
    750  * @fb: currently bound framebuffer
    751  * @fence: optional fence to wait for before scanning out @fb
    752  * @crtc_x: left position of visible portion of plane on crtc
    753  * @crtc_y: upper position of visible portion of plane on crtc
    754  * @crtc_w: width of visible portion of plane on crtc
    755  * @crtc_h: height of visible portion of plane on crtc
    756  * @src_x: left position of visible portion of plane within
    757  *	plane (in 16.16)
    758  * @src_y: upper position of visible portion of plane within
    759  *	plane (in 16.16)
    760  * @src_w: width of visible portion of plane (in 16.16)
    761  * @src_h: height of visible portion of plane (in 16.16)
    762  * @state: backpointer to global drm_atomic_state
    763  */
    764 struct drm_plane_state {
    765 	struct drm_plane *plane;
    766 
    767 	struct drm_crtc *crtc;   /* do not write directly, use drm_atomic_set_crtc_for_plane() */
    768 	struct drm_framebuffer *fb;  /* do not write directly, use drm_atomic_set_fb_for_plane() */
    769 	struct fence *fence;
    770 
    771 	/* Signed dest location allows it to be partially off screen */
    772 	int32_t crtc_x, crtc_y;
    773 	uint32_t crtc_w, crtc_h;
    774 
    775 	/* Source values are 16.16 fixed point */
    776 	uint32_t src_x, src_y;
    777 	uint32_t src_h, src_w;
    778 
    779 	/* Plane rotation */
    780 	unsigned int rotation;
    781 
    782 	struct drm_atomic_state *state;
    783 };
    784 
    785 
    786 /**
    787  * struct drm_plane_funcs - driver plane control functions
    788  * @update_plane: update the plane configuration
    789  * @disable_plane: shut down the plane
    790  * @destroy: clean up plane resources
    791  * @reset: reset plane after state has been invalidated (e.g. resume)
    792  * @set_property: called when a property is changed
    793  * @atomic_duplicate_state: duplicate the atomic state for this plane
    794  * @atomic_destroy_state: destroy an atomic state for this plane
    795  * @atomic_set_property: set a property on an atomic state for this plane
    796  *    (do not call directly, use drm_atomic_plane_set_property())
    797  * @atomic_get_property: get a property on an atomic state for this plane
    798  *    (do not call directly, use drm_atomic_plane_get_property())
    799  */
    800 struct drm_plane_funcs {
    801 	int (*update_plane)(struct drm_plane *plane,
    802 			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
    803 			    int crtc_x, int crtc_y,
    804 			    unsigned int crtc_w, unsigned int crtc_h,
    805 			    uint32_t src_x, uint32_t src_y,
    806 			    uint32_t src_w, uint32_t src_h);
    807 	int (*disable_plane)(struct drm_plane *plane);
    808 	void (*destroy)(struct drm_plane *plane);
    809 	void (*reset)(struct drm_plane *plane);
    810 
    811 	int (*set_property)(struct drm_plane *plane,
    812 			    struct drm_property *property, uint64_t val);
    813 
    814 	/* atomic update handling */
    815 	struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
    816 	void (*atomic_destroy_state)(struct drm_plane *plane,
    817 				     struct drm_plane_state *state);
    818 	int (*atomic_set_property)(struct drm_plane *plane,
    819 				   struct drm_plane_state *state,
    820 				   struct drm_property *property,
    821 				   uint64_t val);
    822 	int (*atomic_get_property)(struct drm_plane *plane,
    823 				   const struct drm_plane_state *state,
    824 				   struct drm_property *property,
    825 				   uint64_t *val);
    826 };
    827 
    828 enum drm_plane_type {
    829 	DRM_PLANE_TYPE_OVERLAY,
    830 	DRM_PLANE_TYPE_PRIMARY,
    831 	DRM_PLANE_TYPE_CURSOR,
    832 };
    833 
    834 /**
    835  * struct drm_plane - central DRM plane control structure
    836  * @dev: DRM device this plane belongs to
    837  * @head: for list management
    838  * @base: base mode object
    839  * @possible_crtcs: pipes this plane can be bound to
    840  * @format_types: array of formats supported by this plane
    841  * @format_count: number of formats supported
    842  * @format_default: driver hasn't supplied supported formats for the plane
    843  * @crtc: currently bound CRTC
    844  * @fb: currently bound fb
    845  * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
    846  * 	drm_mode_set_config_internal() to implement correct refcounting.
    847  * @funcs: helper functions
    848  * @properties: property tracking for this plane
    849  * @type: type of plane (overlay, primary, cursor)
    850  * @state: current atomic state for this plane
    851  */
    852 struct drm_plane {
    853 	struct drm_device *dev;
    854 	struct list_head head;
    855 
    856 	struct drm_modeset_lock mutex;
    857 
    858 	struct drm_mode_object base;
    859 
    860 	uint32_t possible_crtcs;
    861 	uint32_t *format_types;
    862 	unsigned int format_count;
    863 	bool format_default;
    864 
    865 	struct drm_crtc *crtc;
    866 	struct drm_framebuffer *fb;
    867 
    868 	struct drm_framebuffer *old_fb;
    869 
    870 	const struct drm_plane_funcs *funcs;
    871 
    872 	struct drm_object_properties properties;
    873 
    874 	enum drm_plane_type type;
    875 
    876 	const void *helper_private;
    877 
    878 	struct drm_plane_state *state;
    879 };
    880 
    881 /**
    882  * struct drm_bridge_funcs - drm_bridge control functions
    883  * @attach: Called during drm_bridge_attach
    884  * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge
    885  * @disable: Called right before encoder prepare, disables the bridge
    886  * @post_disable: Called right after encoder prepare, for lockstepped disable
    887  * @mode_set: Set this mode to the bridge
    888  * @pre_enable: Called right before encoder commit, for lockstepped commit
    889  * @enable: Called right after encoder commit, enables the bridge
    890  */
    891 struct drm_bridge_funcs {
    892 	int (*attach)(struct drm_bridge *bridge);
    893 	bool (*mode_fixup)(struct drm_bridge *bridge,
    894 			   const struct drm_display_mode *mode,
    895 			   struct drm_display_mode *adjusted_mode);
    896 	void (*disable)(struct drm_bridge *bridge);
    897 	void (*post_disable)(struct drm_bridge *bridge);
    898 	void (*mode_set)(struct drm_bridge *bridge,
    899 			 struct drm_display_mode *mode,
    900 			 struct drm_display_mode *adjusted_mode);
    901 	void (*pre_enable)(struct drm_bridge *bridge);
    902 	void (*enable)(struct drm_bridge *bridge);
    903 };
    904 
    905 /**
    906  * struct drm_bridge - central DRM bridge control structure
    907  * @dev: DRM device this bridge belongs to
    908  * @encoder: encoder to which this bridge is connected
    909  * @next: the next bridge in the encoder chain
    910  * @of_node: device node pointer to the bridge
    911  * @list: to keep track of all added bridges
    912  * @funcs: control functions
    913  * @driver_private: pointer to the bridge driver's internal context
    914  */
    915 struct drm_bridge {
    916 	struct drm_device *dev;
    917 	struct drm_encoder *encoder;
    918 	struct drm_bridge *next;
    919 #ifdef CONFIG_OF
    920 	struct device_node *of_node;
    921 #endif
    922 	struct list_head list;
    923 
    924 	const struct drm_bridge_funcs *funcs;
    925 	void *driver_private;
    926 };
    927 
    928 /**
    929  * struct drm_atomic_state - the global state object for atomic updates
    930  * @dev: parent DRM device
    931  * @allow_modeset: allow full modeset
    932  * @legacy_cursor_update: hint to enforce legacy cursor ioctl semantics
    933  * @planes: pointer to array of plane pointers
    934  * @plane_states: pointer to array of plane states pointers
    935  * @crtcs: pointer to array of CRTC pointers
    936  * @crtc_states: pointer to array of CRTC states pointers
    937  * @num_connector: size of the @connectors and @connector_states arrays
    938  * @connectors: pointer to array of connector pointers
    939  * @connector_states: pointer to array of connector states pointers
    940  * @acquire_ctx: acquire context for this atomic modeset state update
    941  */
    942 struct drm_atomic_state {
    943 	struct drm_device *dev;
    944 	bool allow_modeset : 1;
    945 	bool legacy_cursor_update : 1;
    946 	struct drm_plane **planes;
    947 	struct drm_plane_state **plane_states;
    948 	struct drm_crtc **crtcs;
    949 	struct drm_crtc_state **crtc_states;
    950 	int num_connector;
    951 	struct drm_connector **connectors;
    952 	struct drm_connector_state **connector_states;
    953 
    954 	struct drm_modeset_acquire_ctx *acquire_ctx;
    955 };
    956 
    957 
    958 /**
    959  * struct drm_mode_set - new values for a CRTC config change
    960  * @fb: framebuffer to use for new config
    961  * @crtc: CRTC whose configuration we're about to change
    962  * @mode: mode timings to use
    963  * @x: position of this CRTC relative to @fb
    964  * @y: position of this CRTC relative to @fb
    965  * @connectors: array of connectors to drive with this CRTC if possible
    966  * @num_connectors: size of @connectors array
    967  *
    968  * Represents a single crtc the connectors that it drives with what mode
    969  * and from which framebuffer it scans out from.
    970  *
    971  * This is used to set modes.
    972  */
    973 struct drm_mode_set {
    974 	struct drm_framebuffer *fb;
    975 	struct drm_crtc *crtc;
    976 	struct drm_display_mode *mode;
    977 
    978 	uint32_t x;
    979 	uint32_t y;
    980 
    981 	struct drm_connector **connectors;
    982 	size_t num_connectors;
    983 };
    984 
    985 /**
    986  * struct drm_mode_config_funcs - basic driver provided mode setting functions
    987  * @fb_create: create a new framebuffer object
    988  * @output_poll_changed: function to handle output configuration changes
    989  * @atomic_check: check whether a given atomic state update is possible
    990  * @atomic_commit: commit an atomic state update previously verified with
    991  * 	atomic_check()
    992  * @atomic_state_alloc: allocate a new atomic state
    993  * @atomic_state_clear: clear the atomic state
    994  * @atomic_state_free: free the atomic state
    995  *
    996  * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
    997  * involve drivers.
    998  */
    999 struct drm_mode_config_funcs {
   1000 	struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
   1001 					     struct drm_file *file_priv,
   1002 					     struct drm_mode_fb_cmd2 *mode_cmd);
   1003 	void (*output_poll_changed)(struct drm_device *dev);
   1004 
   1005 	int (*atomic_check)(struct drm_device *dev,
   1006 			    struct drm_atomic_state *a);
   1007 	int (*atomic_commit)(struct drm_device *dev,
   1008 			     struct drm_atomic_state *a,
   1009 			     bool async);
   1010 	struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
   1011 	void (*atomic_state_clear)(struct drm_atomic_state *state);
   1012 	void (*atomic_state_free)(struct drm_atomic_state *state);
   1013 };
   1014 
   1015 /**
   1016  * struct drm_mode_config - Mode configuration control structure
   1017  * @mutex: mutex protecting KMS related lists and structures
   1018  * @connection_mutex: ww mutex protecting connector state and routing
   1019  * @acquire_ctx: global implicit acquire context used by atomic drivers for
   1020  * 	legacy ioctls
   1021  * @idr_mutex: mutex for KMS ID allocation and management
   1022  * @crtc_idr: main KMS ID tracking object
   1023  * @fb_lock: mutex to protect fb state and lists
   1024  * @num_fb: number of fbs available
   1025  * @fb_list: list of framebuffers available
   1026  * @num_connector: number of connectors on this device
   1027  * @connector_list: list of connector objects
   1028  * @num_encoder: number of encoders on this device
   1029  * @encoder_list: list of encoder objects
   1030  * @num_overlay_plane: number of overlay planes on this device
   1031  * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device
   1032  * @plane_list: list of plane objects
   1033  * @num_crtc: number of CRTCs on this device
   1034  * @crtc_list: list of CRTC objects
   1035  * @property_list: list of property objects
   1036  * @min_width: minimum pixel width on this device
   1037  * @min_height: minimum pixel height on this device
   1038  * @max_width: maximum pixel width on this device
   1039  * @max_height: maximum pixel height on this device
   1040  * @funcs: core driver provided mode setting functions
   1041  * @fb_base: base address of the framebuffer
   1042  * @poll_enabled: track polling support for this device
   1043  * @poll_running: track polling status for this device
   1044  * @output_poll_work: delayed work for polling in process context
   1045  * @property_blob_list: list of all the blob property objects
   1046  * @blob_lock: mutex for blob property allocation and management
   1047  * @*_property: core property tracking
   1048  * @preferred_depth: preferred RBG pixel depth, used by fb helpers
   1049  * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
   1050  * @async_page_flip: does this device support async flips on the primary plane?
   1051  * @cursor_width: hint to userspace for max cursor width
   1052  * @cursor_height: hint to userspace for max cursor height
   1053  *
   1054  * Core mode resource tracking structure.  All CRTC, encoders, and connectors
   1055  * enumerated by the driver are added here, as are global properties.  Some
   1056  * global restrictions are also here, e.g. dimension restrictions.
   1057  */
   1058 struct drm_mode_config {
   1059 	struct mutex mutex; /* protects configuration (mode lists etc.) */
   1060 	struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */
   1061 	struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */
   1062 	struct mutex idr_mutex; /* for IDR management */
   1063 	struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
   1064 	struct idr tile_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
   1065 	/* this is limited to one for now */
   1066 
   1067 	struct mutex fb_lock; /* proctects global and per-file fb lists */
   1068 	int num_fb;
   1069 	struct list_head fb_list;
   1070 
   1071 	int num_connector;
   1072 	struct list_head connector_list;
   1073 	int num_encoder;
   1074 	struct list_head encoder_list;
   1075 
   1076 	/*
   1077 	 * Track # of overlay planes separately from # of total planes.  By
   1078 	 * default we only advertise overlay planes to userspace; if userspace
   1079 	 * sets the "universal plane" capability bit, we'll go ahead and
   1080 	 * expose all planes.
   1081 	 */
   1082 	int num_overlay_plane;
   1083 	int num_total_plane;
   1084 	struct list_head plane_list;
   1085 
   1086 	int num_crtc;
   1087 	struct list_head crtc_list;
   1088 
   1089 	struct list_head property_list;
   1090 
   1091 	int min_width, min_height;
   1092 	int max_width, max_height;
   1093 	const struct drm_mode_config_funcs *funcs;
   1094 	resource_size_t fb_base;
   1095 
   1096 	/* output poll support */
   1097 	bool poll_enabled;
   1098 	bool poll_running;
   1099 	bool delayed_event;
   1100 	struct delayed_work output_poll_work;
   1101 
   1102 	struct mutex blob_lock;
   1103 
   1104 	/* pointers to standard properties */
   1105 	struct list_head property_blob_list;
   1106 	struct drm_property *edid_property;
   1107 	struct drm_property *dpms_property;
   1108 	struct drm_property *path_property;
   1109 	struct drm_property *tile_property;
   1110 	struct drm_property *plane_type_property;
   1111 	struct drm_property *rotation_property;
   1112 	struct drm_property *prop_src_x;
   1113 	struct drm_property *prop_src_y;
   1114 	struct drm_property *prop_src_w;
   1115 	struct drm_property *prop_src_h;
   1116 	struct drm_property *prop_crtc_x;
   1117 	struct drm_property *prop_crtc_y;
   1118 	struct drm_property *prop_crtc_w;
   1119 	struct drm_property *prop_crtc_h;
   1120 	struct drm_property *prop_fb_id;
   1121 	struct drm_property *prop_crtc_id;
   1122 	struct drm_property *prop_active;
   1123 	struct drm_property *prop_mode_id;
   1124 
   1125 	/* DVI-I properties */
   1126 	struct drm_property *dvi_i_subconnector_property;
   1127 	struct drm_property *dvi_i_select_subconnector_property;
   1128 
   1129 	/* TV properties */
   1130 	struct drm_property *tv_subconnector_property;
   1131 	struct drm_property *tv_select_subconnector_property;
   1132 	struct drm_property *tv_mode_property;
   1133 	struct drm_property *tv_left_margin_property;
   1134 	struct drm_property *tv_right_margin_property;
   1135 	struct drm_property *tv_top_margin_property;
   1136 	struct drm_property *tv_bottom_margin_property;
   1137 	struct drm_property *tv_brightness_property;
   1138 	struct drm_property *tv_contrast_property;
   1139 	struct drm_property *tv_flicker_reduction_property;
   1140 	struct drm_property *tv_overscan_property;
   1141 	struct drm_property *tv_saturation_property;
   1142 	struct drm_property *tv_hue_property;
   1143 
   1144 	/* Optional properties */
   1145 	struct drm_property *scaling_mode_property;
   1146 	struct drm_property *aspect_ratio_property;
   1147 	struct drm_property *dirty_info_property;
   1148 
   1149 	/* properties for virtual machine layout */
   1150 	struct drm_property *suggested_x_property;
   1151 	struct drm_property *suggested_y_property;
   1152 
   1153 	/* dumb ioctl parameters */
   1154 	uint32_t preferred_depth, prefer_shadow;
   1155 
   1156 	/* whether async page flip is supported or not */
   1157 	bool async_page_flip;
   1158 
   1159 	/* whether the driver supports fb modifiers */
   1160 	bool allow_fb_modifiers;
   1161 
   1162 	/* cursor size */
   1163 	uint32_t cursor_width, cursor_height;
   1164 };
   1165 
   1166 /**
   1167  * drm_for_each_plane_mask - iterate over planes specified by bitmask
   1168  * @plane: the loop cursor
   1169  * @dev: the DRM device
   1170  * @plane_mask: bitmask of plane indices
   1171  *
   1172  * Iterate over all planes specified by bitmask.
   1173  */
   1174 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
   1175 	list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
   1176 		if ((plane_mask) & (1 << drm_plane_index(plane)))
   1177 
   1178 
   1179 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
   1180 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
   1181 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
   1182 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
   1183 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
   1184 #define obj_to_property(x) container_of(x, struct drm_property, base)
   1185 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
   1186 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
   1187 
   1188 struct drm_prop_enum_list {
   1189 	int type;
   1190 	const char *name;
   1191 };
   1192 
   1193 extern int drm_crtc_init_with_planes(struct drm_device *dev,
   1194 				     struct drm_crtc *crtc,
   1195 				     struct drm_plane *primary,
   1196 				     struct drm_plane *cursor,
   1197 				     const struct drm_crtc_funcs *funcs);
   1198 extern void drm_crtc_cleanup(struct drm_crtc *crtc);
   1199 extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
   1200 
   1201 /**
   1202  * drm_crtc_mask - find the mask of a registered CRTC
   1203  * @crtc: CRTC to find mask for
   1204  *
   1205  * Given a registered CRTC, return the mask bit of that CRTC for an
   1206  * encoder's possible_crtcs field.
   1207  */
   1208 static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc)
   1209 {
   1210 	return 1 << drm_crtc_index(crtc);
   1211 }
   1212 
   1213 extern void drm_connector_ida_init(void);
   1214 extern void drm_connector_ida_destroy(void);
   1215 extern int drm_connector_init(struct drm_device *dev,
   1216 			      struct drm_connector *connector,
   1217 			      const struct drm_connector_funcs *funcs,
   1218 			      int connector_type);
   1219 int drm_connector_register(struct drm_connector *connector);
   1220 void drm_connector_unregister(struct drm_connector *connector);
   1221 
   1222 extern void drm_connector_cleanup(struct drm_connector *connector);
   1223 extern unsigned int drm_connector_index(struct drm_connector *connector);
   1224 /* helper to unplug all connectors from sysfs for device */
   1225 extern void drm_connector_unplug_all(struct drm_device *dev);
   1226 
   1227 extern int drm_bridge_add(struct drm_bridge *bridge);
   1228 extern void drm_bridge_remove(struct drm_bridge *bridge);
   1229 extern struct drm_bridge *of_drm_find_bridge(struct device_node *np);
   1230 extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
   1231 
   1232 bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
   1233 			const struct drm_display_mode *mode,
   1234 			struct drm_display_mode *adjusted_mode);
   1235 void drm_bridge_disable(struct drm_bridge *bridge);
   1236 void drm_bridge_post_disable(struct drm_bridge *bridge);
   1237 void drm_bridge_mode_set(struct drm_bridge *bridge,
   1238 			struct drm_display_mode *mode,
   1239 			struct drm_display_mode *adjusted_mode);
   1240 void drm_bridge_pre_enable(struct drm_bridge *bridge);
   1241 void drm_bridge_enable(struct drm_bridge *bridge);
   1242 
   1243 extern int drm_encoder_init(struct drm_device *dev,
   1244 			    struct drm_encoder *encoder,
   1245 			    const struct drm_encoder_funcs *funcs,
   1246 			    int encoder_type);
   1247 
   1248 /**
   1249  * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
   1250  * @encoder: encoder to test
   1251  * @crtc: crtc to test
   1252  *
   1253  * Return false if @encoder can't be driven by @crtc, true otherwise.
   1254  */
   1255 static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
   1256 				       struct drm_crtc *crtc)
   1257 {
   1258 	return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
   1259 }
   1260 
   1261 extern int drm_universal_plane_init(struct drm_device *dev,
   1262 				    struct drm_plane *plane,
   1263 				    unsigned long possible_crtcs,
   1264 				    const struct drm_plane_funcs *funcs,
   1265 				    const uint32_t *formats,
   1266 				    unsigned int format_count,
   1267 				    enum drm_plane_type type);
   1268 extern int drm_plane_init(struct drm_device *dev,
   1269 			  struct drm_plane *plane,
   1270 			  unsigned long possible_crtcs,
   1271 			  const struct drm_plane_funcs *funcs,
   1272 			  const uint32_t *formats, unsigned int format_count,
   1273 			  bool is_primary);
   1274 extern void drm_plane_cleanup(struct drm_plane *plane);
   1275 extern unsigned int drm_plane_index(struct drm_plane *plane);
   1276 extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
   1277 extern void drm_plane_force_disable(struct drm_plane *plane);
   1278 extern int drm_plane_check_pixel_format(const struct drm_plane *plane,
   1279 					u32 format);
   1280 extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
   1281 				   int *hdisplay, int *vdisplay);
   1282 extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
   1283 				   int x, int y,
   1284 				   const struct drm_display_mode *mode,
   1285 				   const struct drm_framebuffer *fb);
   1286 
   1287 extern void drm_encoder_cleanup(struct drm_encoder *encoder);
   1288 
   1289 extern const char *drm_get_connector_status_name(enum drm_connector_status status);
   1290 extern const char *drm_get_subpixel_order_name(enum subpixel_order order);
   1291 extern const char *drm_get_dpms_name(int val);
   1292 extern const char *drm_get_dvi_i_subconnector_name(int val);
   1293 extern const char *drm_get_dvi_i_select_name(int val);
   1294 extern const char *drm_get_tv_subconnector_name(int val);
   1295 extern const char *drm_get_tv_select_name(int val);
   1296 extern void drm_fb_release(struct drm_file *file_priv);
   1297 extern void drm_property_destroy_user_blobs(struct drm_device *dev,
   1298                                             struct drm_file *file_priv);
   1299 extern bool drm_probe_ddc(struct i2c_adapter *adapter);
   1300 extern struct edid *drm_get_edid(struct drm_connector *connector,
   1301 				 struct i2c_adapter *adapter);
   1302 extern struct edid *drm_edid_duplicate(const struct edid *edid);
   1303 extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
   1304 extern void drm_mode_config_init(struct drm_device *dev);
   1305 extern void drm_mode_config_reset(struct drm_device *dev);
   1306 extern void drm_mode_config_cleanup(struct drm_device *dev);
   1307 
   1308 extern int drm_mode_connector_set_path_property(struct drm_connector *connector,
   1309 						const char *path);
   1310 int drm_mode_connector_set_tile_property(struct drm_connector *connector);
   1311 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
   1312 						   const struct edid *edid);
   1313 
   1314 extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
   1315 					    const u32 *formats,
   1316 					    unsigned int num_formats);
   1317 
   1318 static inline bool drm_property_type_is(struct drm_property *property,
   1319 		uint32_t type)
   1320 {
   1321 	/* instanceof for props.. handles extended type vs original types: */
   1322 	if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
   1323 		return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
   1324 	return property->flags & type;
   1325 }
   1326 
   1327 static inline bool drm_property_type_valid(struct drm_property *property)
   1328 {
   1329 	if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
   1330 		return !(property->flags & DRM_MODE_PROP_LEGACY_TYPE);
   1331 	return !!(property->flags & DRM_MODE_PROP_LEGACY_TYPE);
   1332 }
   1333 
   1334 extern int drm_object_property_set_value(struct drm_mode_object *obj,
   1335 					 struct drm_property *property,
   1336 					 uint64_t val);
   1337 extern int drm_object_property_get_value(struct drm_mode_object *obj,
   1338 					 struct drm_property *property,
   1339 					 uint64_t *value);
   1340 extern int drm_framebuffer_init(struct drm_device *dev,
   1341 				struct drm_framebuffer *fb,
   1342 				const struct drm_framebuffer_funcs *funcs);
   1343 extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
   1344 						      uint32_t id);
   1345 extern void drm_framebuffer_unreference(struct drm_framebuffer *fb);
   1346 extern void drm_framebuffer_reference(struct drm_framebuffer *fb);
   1347 extern void drm_framebuffer_remove(struct drm_framebuffer *fb);
   1348 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
   1349 extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
   1350 
   1351 extern void drm_object_attach_property(struct drm_mode_object *obj,
   1352 				       struct drm_property *property,
   1353 				       uint64_t init_val);
   1354 extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
   1355 						const char *name, int num_values);
   1356 extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
   1357 					 const char *name,
   1358 					 const struct drm_prop_enum_list *props,
   1359 					 int num_values);
   1360 struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
   1361 					 int flags, const char *name,
   1362 					 const struct drm_prop_enum_list *props,
   1363 					 int num_props,
   1364 					 uint64_t supported_bits);
   1365 struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
   1366 					 const char *name,
   1367 					 uint64_t min, uint64_t max);
   1368 struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
   1369 					 int flags, const char *name,
   1370 					 int64_t min, int64_t max);
   1371 struct drm_property *drm_property_create_object(struct drm_device *dev,
   1372 					 int flags, const char *name, uint32_t type);
   1373 struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
   1374 					 const char *name);
   1375 struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
   1376                                                    size_t length,
   1377                                                    const void *data);
   1378 struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
   1379                                                    uint32_t id);
   1380 struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob);
   1381 void drm_property_unreference_blob(struct drm_property_blob *blob);
   1382 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
   1383 extern int drm_property_add_enum(struct drm_property *property, int index,
   1384 				 uint64_t value, const char *name);
   1385 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
   1386 extern int drm_mode_create_tv_properties(struct drm_device *dev,
   1387 					 unsigned int num_modes,
   1388 					 const char * const modes[]);
   1389 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
   1390 extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
   1391 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
   1392 extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
   1393 extern bool drm_property_change_valid_get(struct drm_property *property,
   1394 					 uint64_t value, struct drm_mode_object **ref);
   1395 extern void drm_property_change_valid_put(struct drm_property *property,
   1396 		struct drm_mode_object *ref);
   1397 
   1398 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
   1399 					     struct drm_encoder *encoder);
   1400 extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
   1401 					 int gamma_size);
   1402 extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
   1403 		uint32_t id, uint32_t type);
   1404 
   1405 /* IOCTLs */
   1406 extern int drm_mode_getresources(struct drm_device *dev,
   1407 				 void *data, struct drm_file *file_priv);
   1408 extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
   1409 				   struct drm_file *file_priv);
   1410 extern int drm_mode_getcrtc(struct drm_device *dev,
   1411 			    void *data, struct drm_file *file_priv);
   1412 extern int drm_mode_getconnector(struct drm_device *dev,
   1413 			      void *data, struct drm_file *file_priv);
   1414 extern int drm_mode_set_config_internal(struct drm_mode_set *set);
   1415 extern int drm_mode_setcrtc(struct drm_device *dev,
   1416 			    void *data, struct drm_file *file_priv);
   1417 extern int drm_mode_getplane(struct drm_device *dev,
   1418 			       void *data, struct drm_file *file_priv);
   1419 extern int drm_mode_setplane(struct drm_device *dev,
   1420 			       void *data, struct drm_file *file_priv);
   1421 extern int drm_mode_cursor_ioctl(struct drm_device *dev,
   1422 				void *data, struct drm_file *file_priv);
   1423 extern int drm_mode_cursor2_ioctl(struct drm_device *dev,
   1424 				void *data, struct drm_file *file_priv);
   1425 extern int drm_mode_addfb(struct drm_device *dev,
   1426 			  void *data, struct drm_file *file_priv);
   1427 extern int drm_mode_addfb2(struct drm_device *dev,
   1428 			   void *data, struct drm_file *file_priv);
   1429 extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
   1430 extern int drm_mode_rmfb(struct drm_device *dev,
   1431 			 void *data, struct drm_file *file_priv);
   1432 extern int drm_mode_getfb(struct drm_device *dev,
   1433 			  void *data, struct drm_file *file_priv);
   1434 extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
   1435 				  void *data, struct drm_file *file_priv);
   1436 
   1437 extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
   1438 				      void *data, struct drm_file *file_priv);
   1439 extern int drm_mode_getblob_ioctl(struct drm_device *dev,
   1440 				  void *data, struct drm_file *file_priv);
   1441 extern int drm_mode_createblob_ioctl(struct drm_device *dev,
   1442 				     void *data, struct drm_file *file_priv);
   1443 extern int drm_mode_destroyblob_ioctl(struct drm_device *dev,
   1444 				      void *data, struct drm_file *file_priv);
   1445 extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
   1446 					      void *data, struct drm_file *file_priv);
   1447 extern int drm_mode_getencoder(struct drm_device *dev,
   1448 			       void *data, struct drm_file *file_priv);
   1449 extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
   1450 				    void *data, struct drm_file *file_priv);
   1451 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
   1452 				    void *data, struct drm_file *file_priv);
   1453 extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
   1454 extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
   1455 extern bool drm_detect_hdmi_monitor(struct edid *edid);
   1456 extern bool drm_detect_monitor_audio(struct edid *edid);
   1457 extern bool drm_rgb_quant_range_selectable(struct edid *edid);
   1458 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
   1459 				    void *data, struct drm_file *file_priv);
   1460 extern int drm_add_modes_noedid(struct drm_connector *connector,
   1461 				int hdisplay, int vdisplay);
   1462 extern void drm_set_preferred_mode(struct drm_connector *connector,
   1463 				   int hpref, int vpref);
   1464 
   1465 extern int drm_edid_header_is_valid(const u8 *raw_edid);
   1466 extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
   1467 				 bool *edid_corrupt);
   1468 extern bool drm_edid_is_valid(struct edid *edid);
   1469 
   1470 extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
   1471 							 char topology[8]);
   1472 extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
   1473 					       char topology[8]);
   1474 extern void drm_mode_put_tile_group(struct drm_device *dev,
   1475 				   struct drm_tile_group *tg);
   1476 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
   1477 					   int hsize, int vsize, int fresh,
   1478 					   bool rb);
   1479 
   1480 extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
   1481 				      void *data, struct drm_file *file_priv);
   1482 extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
   1483 				    void *data, struct drm_file *file_priv);
   1484 extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
   1485 				      void *data, struct drm_file *file_priv);
   1486 extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
   1487 					     struct drm_file *file_priv);
   1488 extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
   1489 					   struct drm_file *file_priv);
   1490 extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
   1491 				       struct drm_property *property,
   1492 				       uint64_t value);
   1493 extern int drm_mode_atomic_ioctl(struct drm_device *dev,
   1494 				 void *data, struct drm_file *file_priv);
   1495 
   1496 extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
   1497 				 int *bpp);
   1498 extern int drm_format_num_planes(uint32_t format);
   1499 extern int drm_format_plane_cpp(uint32_t format, int plane);
   1500 extern int drm_format_horz_chroma_subsampling(uint32_t format);
   1501 extern int drm_format_vert_chroma_subsampling(uint32_t format);
   1502 extern const char *drm_get_format_name(uint32_t format);
   1503 extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
   1504 							      unsigned int supported_rotations);
   1505 extern unsigned int drm_rotation_simplify(unsigned int rotation,
   1506 					  unsigned int supported_rotations);
   1507 
   1508 /* Helpers */
   1509 
   1510 static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
   1511 		uint32_t id)
   1512 {
   1513 	struct drm_mode_object *mo;
   1514 	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
   1515 	return mo ? obj_to_plane(mo) : NULL;
   1516 }
   1517 
   1518 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
   1519 	uint32_t id)
   1520 {
   1521 	struct drm_mode_object *mo;
   1522 	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC);
   1523 	return mo ? obj_to_crtc(mo) : NULL;
   1524 }
   1525 
   1526 static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
   1527 	uint32_t id)
   1528 {
   1529 	struct drm_mode_object *mo;
   1530 	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
   1531 	return mo ? obj_to_encoder(mo) : NULL;
   1532 }
   1533 
   1534 static inline struct drm_connector *drm_connector_find(struct drm_device *dev,
   1535 		uint32_t id)
   1536 {
   1537 	struct drm_mode_object *mo;
   1538 	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
   1539 	return mo ? obj_to_connector(mo) : NULL;
   1540 }
   1541 
   1542 static inline struct drm_property *drm_property_find(struct drm_device *dev,
   1543 		uint32_t id)
   1544 {
   1545 	struct drm_mode_object *mo;
   1546 	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY);
   1547 	return mo ? obj_to_property(mo) : NULL;
   1548 }
   1549 
   1550 /* Plane list iterator for legacy (overlay only) planes. */
   1551 #define drm_for_each_legacy_plane(plane, dev) \
   1552 	list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
   1553 		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
   1554 
   1555 #define drm_for_each_plane(plane, dev) \
   1556 	list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
   1557 
   1558 #define drm_for_each_crtc(crtc, dev) \
   1559 	list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
   1560 
   1561 static inline void
   1562 assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config)
   1563 {
   1564 	/*
   1565 	 * The connector hotadd/remove code currently grabs both locks when
   1566 	 * updating lists. Hence readers need only hold either of them to be
   1567 	 * safe and the check amounts to
   1568 	 *
   1569 	 * WARN_ON(not_holding(A) && not_holding(B)).
   1570 	 */
   1571 	WARN_ON(!mutex_is_locked(&mode_config->mutex) &&
   1572 		!drm_modeset_is_locked(&mode_config->connection_mutex));
   1573 }
   1574 
   1575 #define drm_for_each_connector(connector, dev) \
   1576 	for (assert_drm_connector_list_read_locked(&(dev)->mode_config),	\
   1577 	     connector = list_first_entry(&(dev)->mode_config.connector_list,	\
   1578 					  struct drm_connector, head);		\
   1579 	     &connector->head != (&(dev)->mode_config.connector_list);		\
   1580 	     connector = list_next_entry(connector, head))
   1581 
   1582 #define drm_for_each_encoder(encoder, dev) \
   1583 	list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head)
   1584 
   1585 #define drm_for_each_fb(fb, dev) \
   1586 	for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)),		\
   1587 	     fb = list_first_entry(&(dev)->mode_config.fb_list,	\
   1588 					  struct drm_framebuffer, head);	\
   1589 	     &fb->head != (&(dev)->mode_config.fb_list);			\
   1590 	     fb = list_next_entry(fb, head))
   1591 
   1592 #endif /* __DRM_CRTC_H__ */
   1593