drm_crtc.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. /*
  2. * Copyright © 2006 Keith Packard
  3. * Copyright © 2007-2008 Dave Airlie
  4. * Copyright © 2007-2008 Intel Corporation
  5. * Jesse Barnes <jesse.barnes@intel.com>
  6. *
  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:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  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.
  24. */
  25. #ifndef __DRM_CRTC_H__
  26. #define __DRM_CRTC_H__
  27. #include <linux/i2c.h>
  28. #include <linux/spinlock.h>
  29. #include <linux/types.h>
  30. #include <linux/idr.h>
  31. #include <linux/fb.h>
  32. #include <drm/drm_mode.h>
  33. #include <drm/drm_fourcc.h>
  34. struct drm_device;
  35. struct drm_mode_set;
  36. struct drm_framebuffer;
  37. struct drm_object_properties;
  38. struct drm_file;
  39. struct drm_clip_rect;
  40. #define DRM_MODE_OBJECT_CRTC 0xcccccccc
  41. #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
  42. #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
  43. #define DRM_MODE_OBJECT_MODE 0xdededede
  44. #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  45. #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  46. #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
  47. #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
  48. struct drm_mode_object {
  49. uint32_t id;
  50. uint32_t type;
  51. struct drm_object_properties *properties;
  52. };
  53. #define DRM_OBJECT_MAX_PROPERTY 24
  54. struct drm_object_properties {
  55. int count;
  56. uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
  57. uint64_t values[DRM_OBJECT_MAX_PROPERTY];
  58. };
  59. /*
  60. * Note on terminology: here, for brevity and convenience, we refer to connector
  61. * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
  62. * DVI, etc. And 'screen' refers to the whole of the visible display, which
  63. * may span multiple monitors (and therefore multiple CRTC and connector
  64. * structures).
  65. */
  66. enum drm_mode_status {
  67. MODE_OK = 0, /* Mode OK */
  68. MODE_HSYNC, /* hsync out of range */
  69. MODE_VSYNC, /* vsync out of range */
  70. MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
  71. MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
  72. MODE_BAD_WIDTH, /* requires an unsupported linepitch */
  73. MODE_NOMODE, /* no mode with a matching name */
  74. MODE_NO_INTERLACE, /* interlaced mode not supported */
  75. MODE_NO_DBLESCAN, /* doublescan mode not supported */
  76. MODE_NO_VSCAN, /* multiscan mode not supported */
  77. MODE_MEM, /* insufficient video memory */
  78. MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
  79. MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
  80. MODE_MEM_VIRT, /* insufficient video memory given virtual size */
  81. MODE_NOCLOCK, /* no fixed clock available */
  82. MODE_CLOCK_HIGH, /* clock required is too high */
  83. MODE_CLOCK_LOW, /* clock required is too low */
  84. MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
  85. MODE_BAD_HVALUE, /* horizontal timing was out of range */
  86. MODE_BAD_VVALUE, /* vertical timing was out of range */
  87. MODE_BAD_VSCAN, /* VScan value out of range */
  88. MODE_HSYNC_NARROW, /* horizontal sync too narrow */
  89. MODE_HSYNC_WIDE, /* horizontal sync too wide */
  90. MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
  91. MODE_HBLANK_WIDE, /* horizontal blanking too wide */
  92. MODE_VSYNC_NARROW, /* vertical sync too narrow */
  93. MODE_VSYNC_WIDE, /* vertical sync too wide */
  94. MODE_VBLANK_NARROW, /* vertical blanking too narrow */
  95. MODE_VBLANK_WIDE, /* vertical blanking too wide */
  96. MODE_PANEL, /* exceeds panel dimensions */
  97. MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
  98. MODE_ONE_WIDTH, /* only one width is supported */
  99. MODE_ONE_HEIGHT, /* only one height is supported */
  100. MODE_ONE_SIZE, /* only one resolution is supported */
  101. MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
  102. MODE_UNVERIFIED = -3, /* mode needs to reverified */
  103. MODE_BAD = -2, /* unspecified reason */
  104. MODE_ERROR = -1 /* error condition */
  105. };
  106. #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
  107. DRM_MODE_TYPE_CRTC_C)
  108. #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
  109. .name = nm, .status = 0, .type = (t), .clock = (c), \
  110. .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
  111. .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
  112. .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
  113. .vscan = (vs), .flags = (f), \
  114. .base.type = DRM_MODE_OBJECT_MODE
  115. #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
  116. struct drm_display_mode {
  117. /* Header */
  118. struct list_head head;
  119. struct drm_mode_object base;
  120. char name[DRM_DISPLAY_MODE_LEN];
  121. enum drm_mode_status status;
  122. unsigned int type;
  123. /* Proposed mode values */
  124. int clock; /* in kHz */
  125. int hdisplay;
  126. int hsync_start;
  127. int hsync_end;
  128. int htotal;
  129. int hskew;
  130. int vdisplay;
  131. int vsync_start;
  132. int vsync_end;
  133. int vtotal;
  134. int vscan;
  135. unsigned int flags;
  136. /* Addressable image size (may be 0 for projectors, etc.) */
  137. int width_mm;
  138. int height_mm;
  139. /* Actual mode we give to hw */
  140. int clock_index;
  141. int synth_clock;
  142. int crtc_hdisplay;
  143. int crtc_hblank_start;
  144. int crtc_hblank_end;
  145. int crtc_hsync_start;
  146. int crtc_hsync_end;
  147. int crtc_htotal;
  148. int crtc_hskew;
  149. int crtc_vdisplay;
  150. int crtc_vblank_start;
  151. int crtc_vblank_end;
  152. int crtc_vsync_start;
  153. int crtc_vsync_end;
  154. int crtc_vtotal;
  155. /* Driver private mode info */
  156. int private_size;
  157. int *private;
  158. int private_flags;
  159. int vrefresh; /* in Hz */
  160. int hsync; /* in kHz */
  161. };
  162. enum drm_connector_status {
  163. connector_status_connected = 1,
  164. connector_status_disconnected = 2,
  165. connector_status_unknown = 3,
  166. };
  167. enum subpixel_order {
  168. SubPixelUnknown = 0,
  169. SubPixelHorizontalRGB,
  170. SubPixelHorizontalBGR,
  171. SubPixelVerticalRGB,
  172. SubPixelVerticalBGR,
  173. SubPixelNone,
  174. };
  175. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  176. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  177. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  178. /*
  179. * Describes a given display (e.g. CRT or flat panel) and its limitations.
  180. */
  181. struct drm_display_info {
  182. char name[DRM_DISPLAY_INFO_LEN];
  183. /* Physical size */
  184. unsigned int width_mm;
  185. unsigned int height_mm;
  186. /* Clock limits FIXME: storage format */
  187. unsigned int min_vfreq, max_vfreq;
  188. unsigned int min_hfreq, max_hfreq;
  189. unsigned int pixel_clock;
  190. unsigned int bpc;
  191. enum subpixel_order subpixel_order;
  192. u32 color_formats;
  193. u8 cea_rev;
  194. };
  195. struct drm_framebuffer_funcs {
  196. /* note: use drm_framebuffer_remove() */
  197. void (*destroy)(struct drm_framebuffer *framebuffer);
  198. int (*create_handle)(struct drm_framebuffer *fb,
  199. struct drm_file *file_priv,
  200. unsigned int *handle);
  201. /**
  202. * Optinal callback for the dirty fb ioctl.
  203. *
  204. * Userspace can notify the driver via this callback
  205. * that a area of the framebuffer has changed and should
  206. * be flushed to the display hardware.
  207. *
  208. * See documentation in drm_mode.h for the struct
  209. * drm_mode_fb_dirty_cmd for more information as all
  210. * the semantics and arguments have a one to one mapping
  211. * on this function.
  212. */
  213. int (*dirty)(struct drm_framebuffer *framebuffer,
  214. struct drm_file *file_priv, unsigned flags,
  215. unsigned color, struct drm_clip_rect *clips,
  216. unsigned num_clips);
  217. };
  218. struct drm_framebuffer {
  219. struct drm_device *dev;
  220. /*
  221. * Note that the fb is refcounted for the benefit of driver internals,
  222. * for example some hw, disabling a CRTC/plane is asynchronous, and
  223. * scanout does not actually complete until the next vblank. So some
  224. * cleanup (like releasing the reference(s) on the backing GEM bo(s))
  225. * should be deferred. In cases like this, the driver would like to
  226. * hold a ref to the fb even though it has already been removed from
  227. * userspace perspective.
  228. */
  229. struct kref refcount;
  230. /*
  231. * Place on the dev->mode_config.fb_list, access protected by
  232. * dev->mode_config.fb_lock.
  233. */
  234. struct list_head head;
  235. struct drm_mode_object base;
  236. const struct drm_framebuffer_funcs *funcs;
  237. unsigned int pitches[4];
  238. unsigned int offsets[4];
  239. unsigned int width;
  240. unsigned int height;
  241. /* depth can be 15 or 16 */
  242. unsigned int depth;
  243. int bits_per_pixel;
  244. int flags;
  245. uint32_t pixel_format; /* fourcc format */
  246. struct list_head filp_head;
  247. /* if you are using the helper */
  248. void *helper_private;
  249. };
  250. struct drm_property_blob {
  251. struct drm_mode_object base;
  252. struct list_head head;
  253. unsigned int length;
  254. unsigned char data[];
  255. };
  256. struct drm_property_enum {
  257. uint64_t value;
  258. struct list_head head;
  259. char name[DRM_PROP_NAME_LEN];
  260. };
  261. struct drm_property {
  262. struct list_head head;
  263. struct drm_mode_object base;
  264. uint32_t flags;
  265. char name[DRM_PROP_NAME_LEN];
  266. uint32_t num_values;
  267. uint64_t *values;
  268. struct list_head enum_blob_list;
  269. };
  270. struct drm_crtc;
  271. struct drm_connector;
  272. struct drm_encoder;
  273. struct drm_pending_vblank_event;
  274. struct drm_plane;
  275. /**
  276. * drm_crtc_funcs - control CRTCs for a given device
  277. * @save: save CRTC state
  278. * @restore: restore CRTC state
  279. * @reset: reset CRTC after state has been invalidated (e.g. resume)
  280. * @cursor_set: setup the cursor
  281. * @cursor_move: move the cursor
  282. * @gamma_set: specify color ramp for CRTC
  283. * @destroy: deinit and free object
  284. * @set_property: called when a property is changed
  285. * @set_config: apply a new CRTC configuration
  286. * @page_flip: initiate a page flip
  287. *
  288. * The drm_crtc_funcs structure is the central CRTC management structure
  289. * in the DRM. Each CRTC controls one or more connectors (note that the name
  290. * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
  291. * connectors, not just CRTs).
  292. *
  293. * Each driver is responsible for filling out this structure at startup time,
  294. * in addition to providing other modesetting features, like i2c and DDC
  295. * bus accessors.
  296. */
  297. struct drm_crtc_funcs {
  298. /* Save CRTC state */
  299. void (*save)(struct drm_crtc *crtc); /* suspend? */
  300. /* Restore CRTC state */
  301. void (*restore)(struct drm_crtc *crtc); /* resume? */
  302. /* Reset CRTC state */
  303. void (*reset)(struct drm_crtc *crtc);
  304. /* cursor controls */
  305. int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
  306. uint32_t handle, uint32_t width, uint32_t height);
  307. int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
  308. uint32_t handle, uint32_t width, uint32_t height,
  309. int32_t hot_x, int32_t hot_y);
  310. int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
  311. /* Set gamma on the CRTC */
  312. void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
  313. uint32_t start, uint32_t size);
  314. /* Object destroy routine */
  315. void (*destroy)(struct drm_crtc *crtc);
  316. int (*set_config)(struct drm_mode_set *set);
  317. /*
  318. * Flip to the given framebuffer. This implements the page
  319. * flip ioctl described in drm_mode.h, specifically, the
  320. * implementation must return immediately and block all
  321. * rendering to the current fb until the flip has completed.
  322. * If userspace set the event flag in the ioctl, the event
  323. * argument will point to an event to send back when the flip
  324. * completes, otherwise it will be NULL.
  325. */
  326. int (*page_flip)(struct drm_crtc *crtc,
  327. struct drm_framebuffer *fb,
  328. struct drm_pending_vblank_event *event);
  329. int (*set_property)(struct drm_crtc *crtc,
  330. struct drm_property *property, uint64_t val);
  331. };
  332. /**
  333. * drm_crtc - central CRTC control structure
  334. * @dev: parent DRM device
  335. * @head: list management
  336. * @base: base KMS object for ID tracking etc.
  337. * @enabled: is this CRTC enabled?
  338. * @mode: current mode timings
  339. * @hwmode: mode timings as programmed to hw regs
  340. * @invert_dimensions: for purposes of error checking crtc vs fb sizes,
  341. * invert the width/height of the crtc. This is used if the driver
  342. * is performing 90 or 270 degree rotated scanout
  343. * @x: x position on screen
  344. * @y: y position on screen
  345. * @funcs: CRTC control functions
  346. * @gamma_size: size of gamma ramp
  347. * @gamma_store: gamma ramp values
  348. * @framedur_ns: precise frame timing
  349. * @framedur_ns: precise line timing
  350. * @pixeldur_ns: precise pixel timing
  351. * @helper_private: mid-layer private data
  352. * @properties: property tracking for this CRTC
  353. *
  354. * Each CRTC may have one or more connectors associated with it. This structure
  355. * allows the CRTC to be controlled.
  356. */
  357. struct drm_crtc {
  358. struct drm_device *dev;
  359. struct list_head head;
  360. /**
  361. * crtc mutex
  362. *
  363. * This provides a read lock for the overall crtc state (mode, dpms
  364. * state, ...) and a write lock for everything which can be update
  365. * without a full modeset (fb, cursor data, ...)
  366. */
  367. struct mutex mutex;
  368. struct drm_mode_object base;
  369. /* framebuffer the connector is currently bound to */
  370. struct drm_framebuffer *fb;
  371. /* Temporary tracking of the old fb while a modeset is ongoing. Used
  372. * by drm_mode_set_config_internal to implement correct refcounting. */
  373. struct drm_framebuffer *old_fb;
  374. bool enabled;
  375. /* Requested mode from modesetting. */
  376. struct drm_display_mode mode;
  377. /* Programmed mode in hw, after adjustments for encoders,
  378. * crtc, panel scaling etc. Needed for timestamping etc.
  379. */
  380. struct drm_display_mode hwmode;
  381. bool invert_dimensions;
  382. int x, y;
  383. const struct drm_crtc_funcs *funcs;
  384. /* CRTC gamma size for reporting to userspace */
  385. uint32_t gamma_size;
  386. uint16_t *gamma_store;
  387. /* Constants needed for precise vblank and swap timestamping. */
  388. s64 framedur_ns, linedur_ns, pixeldur_ns;
  389. /* if you are using the helper */
  390. void *helper_private;
  391. struct drm_object_properties properties;
  392. };
  393. /**
  394. * drm_connector_funcs - control connectors on a given device
  395. * @dpms: set power state (see drm_crtc_funcs above)
  396. * @save: save connector state
  397. * @restore: restore connector state
  398. * @reset: reset connector after state has been invalidated (e.g. resume)
  399. * @detect: is this connector active?
  400. * @fill_modes: fill mode list for this connector
  401. * @set_property: property for this connector may need an update
  402. * @destroy: make object go away
  403. * @force: notify the driver that the connector is forced on
  404. *
  405. * Each CRTC may have one or more connectors attached to it. The functions
  406. * below allow the core DRM code to control connectors, enumerate available modes,
  407. * etc.
  408. */
  409. struct drm_connector_funcs {
  410. void (*dpms)(struct drm_connector *connector, int mode);
  411. void (*save)(struct drm_connector *connector);
  412. void (*restore)(struct drm_connector *connector);
  413. void (*reset)(struct drm_connector *connector);
  414. /* Check to see if anything is attached to the connector.
  415. * @force is set to false whilst polling, true when checking the
  416. * connector due to user request. @force can be used by the driver
  417. * to avoid expensive, destructive operations during automated
  418. * probing.
  419. */
  420. enum drm_connector_status (*detect)(struct drm_connector *connector,
  421. bool force);
  422. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  423. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  424. uint64_t val);
  425. void (*destroy)(struct drm_connector *connector);
  426. void (*force)(struct drm_connector *connector);
  427. };
  428. /**
  429. * drm_encoder_funcs - encoder controls
  430. * @reset: reset state (e.g. at init or resume time)
  431. * @destroy: cleanup and free associated data
  432. *
  433. * Encoders sit between CRTCs and connectors.
  434. */
  435. struct drm_encoder_funcs {
  436. void (*reset)(struct drm_encoder *encoder);
  437. void (*destroy)(struct drm_encoder *encoder);
  438. };
  439. #define DRM_CONNECTOR_MAX_UMODES 16
  440. #define DRM_CONNECTOR_LEN 32
  441. #define DRM_CONNECTOR_MAX_ENCODER 3
  442. /**
  443. * drm_encoder - central DRM encoder structure
  444. * @dev: parent DRM device
  445. * @head: list management
  446. * @base: base KMS object
  447. * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
  448. * @possible_crtcs: bitmask of potential CRTC bindings
  449. * @possible_clones: bitmask of potential sibling encoders for cloning
  450. * @crtc: currently bound CRTC
  451. * @funcs: control functions
  452. * @helper_private: mid-layer private data
  453. *
  454. * CRTCs drive pixels to encoders, which convert them into signals
  455. * appropriate for a given connector or set of connectors.
  456. */
  457. struct drm_encoder {
  458. struct drm_device *dev;
  459. struct list_head head;
  460. struct drm_mode_object base;
  461. int encoder_type;
  462. uint32_t possible_crtcs;
  463. uint32_t possible_clones;
  464. struct drm_crtc *crtc;
  465. const struct drm_encoder_funcs *funcs;
  466. void *helper_private;
  467. };
  468. enum drm_connector_force {
  469. DRM_FORCE_UNSPECIFIED,
  470. DRM_FORCE_OFF,
  471. DRM_FORCE_ON, /* force on analog part normally */
  472. DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
  473. };
  474. /* should we poll this connector for connects and disconnects */
  475. /* hot plug detectable */
  476. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  477. /* poll for connections */
  478. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  479. /* can cleanly poll for disconnections without flickering the screen */
  480. /* DACs should rarely do this without a lot of testing */
  481. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  482. #define MAX_ELD_BYTES 128
  483. /**
  484. * drm_connector - central DRM connector control structure
  485. * @dev: parent DRM device
  486. * @kdev: kernel device for sysfs attributes
  487. * @attr: sysfs attributes
  488. * @head: list management
  489. * @base: base KMS object
  490. * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
  491. * @connector_type_id: index into connector type enum
  492. * @interlace_allowed: can this connector handle interlaced modes?
  493. * @doublescan_allowed: can this connector handle doublescan?
  494. * @modes: modes available on this connector (from fill_modes() + user)
  495. * @status: one of the drm_connector_status enums (connected, not, or unknown)
  496. * @probed_modes: list of modes derived directly from the display
  497. * @display_info: information about attached display (e.g. from EDID)
  498. * @funcs: connector control functions
  499. * @edid_blob_ptr: DRM property containing EDID if present
  500. * @properties: property tracking for this connector
  501. * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
  502. * @dpms: current dpms state
  503. * @helper_private: mid-layer private data
  504. * @force: a %DRM_FORCE_<foo> state for forced mode sets
  505. * @encoder_ids: valid encoders for this connector
  506. * @encoder: encoder driving this connector, if any
  507. * @eld: EDID-like data, if present
  508. * @dvi_dual: dual link DVI, if found
  509. * @max_tmds_clock: max clock rate, if found
  510. * @latency_present: AV delay info from ELD, if found
  511. * @video_latency: video latency info from ELD, if found
  512. * @audio_latency: audio latency info from ELD, if found
  513. * @null_edid_counter: track sinks that give us all zeros for the EDID
  514. *
  515. * Each connector may be connected to one or more CRTCs, or may be clonable by
  516. * another connector if they can share a CRTC. Each connector also has a specific
  517. * position in the broader display (referred to as a 'screen' though it could
  518. * span multiple monitors).
  519. */
  520. struct drm_connector {
  521. struct drm_device *dev;
  522. struct device kdev;
  523. struct device_attribute *attr;
  524. struct list_head head;
  525. struct drm_mode_object base;
  526. int connector_type;
  527. int connector_type_id;
  528. bool interlace_allowed;
  529. bool doublescan_allowed;
  530. struct list_head modes; /* list of modes on this connector */
  531. enum drm_connector_status status;
  532. /* these are modes added by probing with DDC or the BIOS */
  533. struct list_head probed_modes;
  534. struct drm_display_info display_info;
  535. const struct drm_connector_funcs *funcs;
  536. struct drm_property_blob *edid_blob_ptr;
  537. struct drm_object_properties properties;
  538. uint8_t polled; /* DRM_CONNECTOR_POLL_* */
  539. /* requested DPMS state */
  540. int dpms;
  541. void *helper_private;
  542. /* forced on connector */
  543. enum drm_connector_force force;
  544. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  545. struct drm_encoder *encoder; /* currently active encoder */
  546. /* EDID bits */
  547. uint8_t eld[MAX_ELD_BYTES];
  548. bool dvi_dual;
  549. int max_tmds_clock; /* in MHz */
  550. bool latency_present[2];
  551. int video_latency[2]; /* [0]: progressive, [1]: interlaced */
  552. int audio_latency[2];
  553. int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
  554. unsigned bad_edid_counter;
  555. };
  556. /**
  557. * drm_plane_funcs - driver plane control functions
  558. * @update_plane: update the plane configuration
  559. * @disable_plane: shut down the plane
  560. * @destroy: clean up plane resources
  561. * @set_property: called when a property is changed
  562. */
  563. struct drm_plane_funcs {
  564. int (*update_plane)(struct drm_plane *plane,
  565. struct drm_crtc *crtc, struct drm_framebuffer *fb,
  566. int crtc_x, int crtc_y,
  567. unsigned int crtc_w, unsigned int crtc_h,
  568. uint32_t src_x, uint32_t src_y,
  569. uint32_t src_w, uint32_t src_h);
  570. int (*disable_plane)(struct drm_plane *plane);
  571. void (*destroy)(struct drm_plane *plane);
  572. int (*set_property)(struct drm_plane *plane,
  573. struct drm_property *property, uint64_t val);
  574. };
  575. /**
  576. * drm_plane - central DRM plane control structure
  577. * @dev: DRM device this plane belongs to
  578. * @head: for list management
  579. * @base: base mode object
  580. * @possible_crtcs: pipes this plane can be bound to
  581. * @format_types: array of formats supported by this plane
  582. * @format_count: number of formats supported
  583. * @crtc: currently bound CRTC
  584. * @fb: currently bound fb
  585. * @funcs: helper functions
  586. * @properties: property tracking for this plane
  587. */
  588. struct drm_plane {
  589. struct drm_device *dev;
  590. struct list_head head;
  591. struct drm_mode_object base;
  592. uint32_t possible_crtcs;
  593. uint32_t *format_types;
  594. uint32_t format_count;
  595. struct drm_crtc *crtc;
  596. struct drm_framebuffer *fb;
  597. const struct drm_plane_funcs *funcs;
  598. struct drm_object_properties properties;
  599. };
  600. /**
  601. * drm_mode_set - new values for a CRTC config change
  602. * @head: list management
  603. * @fb: framebuffer to use for new config
  604. * @crtc: CRTC whose configuration we're about to change
  605. * @mode: mode timings to use
  606. * @x: position of this CRTC relative to @fb
  607. * @y: position of this CRTC relative to @fb
  608. * @connectors: array of connectors to drive with this CRTC if possible
  609. * @num_connectors: size of @connectors array
  610. *
  611. * Represents a single crtc the connectors that it drives with what mode
  612. * and from which framebuffer it scans out from.
  613. *
  614. * This is used to set modes.
  615. */
  616. struct drm_mode_set {
  617. struct drm_framebuffer *fb;
  618. struct drm_crtc *crtc;
  619. struct drm_display_mode *mode;
  620. uint32_t x;
  621. uint32_t y;
  622. struct drm_connector **connectors;
  623. size_t num_connectors;
  624. };
  625. /**
  626. * struct drm_mode_config_funcs - basic driver provided mode setting functions
  627. * @fb_create: create a new framebuffer object
  628. * @output_poll_changed: function to handle output configuration changes
  629. *
  630. * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
  631. * involve drivers.
  632. */
  633. struct drm_mode_config_funcs {
  634. struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
  635. struct drm_file *file_priv,
  636. struct drm_mode_fb_cmd2 *mode_cmd);
  637. void (*output_poll_changed)(struct drm_device *dev);
  638. };
  639. /**
  640. * drm_mode_group - group of mode setting resources for potential sub-grouping
  641. * @num_crtcs: CRTC count
  642. * @num_encoders: encoder count
  643. * @num_connectors: connector count
  644. * @id_list: list of KMS object IDs in this group
  645. *
  646. * Currently this simply tracks the global mode setting state. But in the
  647. * future it could allow groups of objects to be set aside into independent
  648. * control groups for use by different user level processes (e.g. two X servers
  649. * running simultaneously on different heads, each with their own mode
  650. * configuration and freedom of mode setting).
  651. */
  652. struct drm_mode_group {
  653. uint32_t num_crtcs;
  654. uint32_t num_encoders;
  655. uint32_t num_connectors;
  656. /* list of object IDs for this group */
  657. uint32_t *id_list;
  658. };
  659. /**
  660. * drm_mode_config - Mode configuration control structure
  661. * @mutex: mutex protecting KMS related lists and structures
  662. * @idr_mutex: mutex for KMS ID allocation and management
  663. * @crtc_idr: main KMS ID tracking object
  664. * @num_fb: number of fbs available
  665. * @fb_list: list of framebuffers available
  666. * @num_connector: number of connectors on this device
  667. * @connector_list: list of connector objects
  668. * @num_encoder: number of encoders on this device
  669. * @encoder_list: list of encoder objects
  670. * @num_crtc: number of CRTCs on this device
  671. * @crtc_list: list of CRTC objects
  672. * @min_width: minimum pixel width on this device
  673. * @min_height: minimum pixel height on this device
  674. * @max_width: maximum pixel width on this device
  675. * @max_height: maximum pixel height on this device
  676. * @funcs: core driver provided mode setting functions
  677. * @fb_base: base address of the framebuffer
  678. * @poll_enabled: track polling status for this device
  679. * @output_poll_work: delayed work for polling in process context
  680. * @*_property: core property tracking
  681. *
  682. * Core mode resource tracking structure. All CRTC, encoders, and connectors
  683. * enumerated by the driver are added here, as are global properties. Some
  684. * global restrictions are also here, e.g. dimension restrictions.
  685. */
  686. struct drm_mode_config {
  687. struct mutex mutex; /* protects configuration (mode lists etc.) */
  688. struct mutex idr_mutex; /* for IDR management */
  689. struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
  690. /* this is limited to one for now */
  691. /**
  692. * fb_lock - mutex to protect fb state
  693. *
  694. * Besides the global fb list his also protects the fbs list in the
  695. * file_priv
  696. */
  697. struct mutex fb_lock;
  698. int num_fb;
  699. struct list_head fb_list;
  700. int num_connector;
  701. struct list_head connector_list;
  702. int num_encoder;
  703. struct list_head encoder_list;
  704. int num_plane;
  705. struct list_head plane_list;
  706. int num_crtc;
  707. struct list_head crtc_list;
  708. struct list_head property_list;
  709. int min_width, min_height;
  710. int max_width, max_height;
  711. const struct drm_mode_config_funcs *funcs;
  712. resource_size_t fb_base;
  713. /* output poll support */
  714. bool poll_enabled;
  715. bool poll_running;
  716. struct delayed_work output_poll_work;
  717. /* pointers to standard properties */
  718. struct list_head property_blob_list;
  719. struct drm_property *edid_property;
  720. struct drm_property *dpms_property;
  721. /* DVI-I properties */
  722. struct drm_property *dvi_i_subconnector_property;
  723. struct drm_property *dvi_i_select_subconnector_property;
  724. /* TV properties */
  725. struct drm_property *tv_subconnector_property;
  726. struct drm_property *tv_select_subconnector_property;
  727. struct drm_property *tv_mode_property;
  728. struct drm_property *tv_left_margin_property;
  729. struct drm_property *tv_right_margin_property;
  730. struct drm_property *tv_top_margin_property;
  731. struct drm_property *tv_bottom_margin_property;
  732. struct drm_property *tv_brightness_property;
  733. struct drm_property *tv_contrast_property;
  734. struct drm_property *tv_flicker_reduction_property;
  735. struct drm_property *tv_overscan_property;
  736. struct drm_property *tv_saturation_property;
  737. struct drm_property *tv_hue_property;
  738. /* Optional properties */
  739. struct drm_property *scaling_mode_property;
  740. struct drm_property *dithering_mode_property;
  741. struct drm_property *dirty_info_property;
  742. /* dumb ioctl parameters */
  743. uint32_t preferred_depth, prefer_shadow;
  744. };
  745. #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
  746. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  747. #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
  748. #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
  749. #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
  750. #define obj_to_property(x) container_of(x, struct drm_property, base)
  751. #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
  752. #define obj_to_plane(x) container_of(x, struct drm_plane, base)
  753. struct drm_prop_enum_list {
  754. int type;
  755. char *name;
  756. };
  757. extern void drm_modeset_lock_all(struct drm_device *dev);
  758. extern void drm_modeset_unlock_all(struct drm_device *dev);
  759. extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
  760. extern int drm_crtc_init(struct drm_device *dev,
  761. struct drm_crtc *crtc,
  762. const struct drm_crtc_funcs *funcs);
  763. extern void drm_crtc_cleanup(struct drm_crtc *crtc);
  764. extern int drm_connector_init(struct drm_device *dev,
  765. struct drm_connector *connector,
  766. const struct drm_connector_funcs *funcs,
  767. int connector_type);
  768. extern void drm_connector_cleanup(struct drm_connector *connector);
  769. /* helper to unplug all connectors from sysfs for device */
  770. extern void drm_connector_unplug_all(struct drm_device *dev);
  771. extern int drm_encoder_init(struct drm_device *dev,
  772. struct drm_encoder *encoder,
  773. const struct drm_encoder_funcs *funcs,
  774. int encoder_type);
  775. extern int drm_plane_init(struct drm_device *dev,
  776. struct drm_plane *plane,
  777. unsigned long possible_crtcs,
  778. const struct drm_plane_funcs *funcs,
  779. const uint32_t *formats, uint32_t format_count,
  780. bool priv);
  781. extern void drm_plane_cleanup(struct drm_plane *plane);
  782. extern void drm_plane_force_disable(struct drm_plane *plane);
  783. extern void drm_encoder_cleanup(struct drm_encoder *encoder);
  784. extern const char *drm_get_connector_name(const struct drm_connector *connector);
  785. extern const char *drm_get_connector_status_name(enum drm_connector_status status);
  786. extern const char *drm_get_dpms_name(int val);
  787. extern const char *drm_get_dvi_i_subconnector_name(int val);
  788. extern const char *drm_get_dvi_i_select_name(int val);
  789. extern const char *drm_get_tv_subconnector_name(int val);
  790. extern const char *drm_get_tv_select_name(int val);
  791. extern void drm_fb_release(struct drm_file *file_priv);
  792. extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
  793. extern bool drm_probe_ddc(struct i2c_adapter *adapter);
  794. extern struct edid *drm_get_edid(struct drm_connector *connector,
  795. struct i2c_adapter *adapter);
  796. extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
  797. extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
  798. extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
  799. extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
  800. extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
  801. const struct drm_display_mode *mode);
  802. extern void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
  803. extern void drm_mode_config_init(struct drm_device *dev);
  804. extern void drm_mode_config_reset(struct drm_device *dev);
  805. extern void drm_mode_config_cleanup(struct drm_device *dev);
  806. extern void drm_mode_set_name(struct drm_display_mode *mode);
  807. extern bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
  808. extern bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
  809. extern int drm_mode_width(const struct drm_display_mode *mode);
  810. extern int drm_mode_height(const struct drm_display_mode *mode);
  811. /* for us by fb module */
  812. extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
  813. extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
  814. extern void drm_mode_list_concat(struct list_head *head,
  815. struct list_head *new);
  816. extern void drm_mode_validate_size(struct drm_device *dev,
  817. struct list_head *mode_list,
  818. int maxX, int maxY, int maxPitch);
  819. extern void drm_mode_validate_clocks(struct drm_device *dev,
  820. struct list_head *mode_list,
  821. int *min, int *max, int n_ranges);
  822. extern void drm_mode_prune_invalid(struct drm_device *dev,
  823. struct list_head *mode_list, bool verbose);
  824. extern void drm_mode_sort(struct list_head *mode_list);
  825. extern int drm_mode_hsync(const struct drm_display_mode *mode);
  826. extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
  827. extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
  828. int adjust_flags);
  829. extern void drm_mode_connector_list_update(struct drm_connector *connector);
  830. extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
  831. struct edid *edid);
  832. extern int drm_object_property_set_value(struct drm_mode_object *obj,
  833. struct drm_property *property,
  834. uint64_t val);
  835. extern int drm_object_property_get_value(struct drm_mode_object *obj,
  836. struct drm_property *property,
  837. uint64_t *value);
  838. extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
  839. extern void drm_framebuffer_set_object(struct drm_device *dev,
  840. unsigned long handle);
  841. extern int drm_framebuffer_init(struct drm_device *dev,
  842. struct drm_framebuffer *fb,
  843. const struct drm_framebuffer_funcs *funcs);
  844. extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
  845. uint32_t id);
  846. extern void drm_framebuffer_unreference(struct drm_framebuffer *fb);
  847. extern void drm_framebuffer_reference(struct drm_framebuffer *fb);
  848. extern void drm_framebuffer_remove(struct drm_framebuffer *fb);
  849. extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
  850. extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
  851. extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
  852. extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
  853. extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
  854. extern bool drm_crtc_in_use(struct drm_crtc *crtc);
  855. extern void drm_object_attach_property(struct drm_mode_object *obj,
  856. struct drm_property *property,
  857. uint64_t init_val);
  858. extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
  859. const char *name, int num_values);
  860. extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
  861. const char *name,
  862. const struct drm_prop_enum_list *props,
  863. int num_values);
  864. struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
  865. int flags, const char *name,
  866. const struct drm_prop_enum_list *props,
  867. int num_values);
  868. struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
  869. const char *name,
  870. uint64_t min, uint64_t max);
  871. extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
  872. extern int drm_property_add_enum(struct drm_property *property, int index,
  873. uint64_t value, const char *name);
  874. extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  875. extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
  876. char *formats[]);
  877. extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  878. extern int drm_mode_create_dithering_property(struct drm_device *dev);
  879. extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
  880. extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
  881. extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
  882. struct drm_encoder *encoder);
  883. extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
  884. struct drm_encoder *encoder);
  885. extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
  886. int gamma_size);
  887. extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
  888. uint32_t id, uint32_t type);
  889. /* IOCTLs */
  890. extern int drm_mode_getresources(struct drm_device *dev,
  891. void *data, struct drm_file *file_priv);
  892. extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
  893. struct drm_file *file_priv);
  894. extern int drm_mode_getcrtc(struct drm_device *dev,
  895. void *data, struct drm_file *file_priv);
  896. extern int drm_mode_getconnector(struct drm_device *dev,
  897. void *data, struct drm_file *file_priv);
  898. extern int drm_mode_set_config_internal(struct drm_mode_set *set);
  899. extern int drm_mode_setcrtc(struct drm_device *dev,
  900. void *data, struct drm_file *file_priv);
  901. extern int drm_mode_getplane(struct drm_device *dev,
  902. void *data, struct drm_file *file_priv);
  903. extern int drm_mode_setplane(struct drm_device *dev,
  904. void *data, struct drm_file *file_priv);
  905. extern int drm_mode_cursor_ioctl(struct drm_device *dev,
  906. void *data, struct drm_file *file_priv);
  907. extern int drm_mode_cursor2_ioctl(struct drm_device *dev,
  908. void *data, struct drm_file *file_priv);
  909. extern int drm_mode_addfb(struct drm_device *dev,
  910. void *data, struct drm_file *file_priv);
  911. extern int drm_mode_addfb2(struct drm_device *dev,
  912. void *data, struct drm_file *file_priv);
  913. extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
  914. extern int drm_mode_rmfb(struct drm_device *dev,
  915. void *data, struct drm_file *file_priv);
  916. extern int drm_mode_getfb(struct drm_device *dev,
  917. void *data, struct drm_file *file_priv);
  918. extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
  919. void *data, struct drm_file *file_priv);
  920. extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
  921. void *data, struct drm_file *file_priv);
  922. extern int drm_mode_getblob_ioctl(struct drm_device *dev,
  923. void *data, struct drm_file *file_priv);
  924. extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
  925. void *data, struct drm_file *file_priv);
  926. extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
  927. void *data, struct drm_file *file_priv);
  928. extern int drm_mode_replacefb(struct drm_device *dev,
  929. void *data, struct drm_file *file_priv);
  930. extern int drm_mode_getencoder(struct drm_device *dev,
  931. void *data, struct drm_file *file_priv);
  932. extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
  933. void *data, struct drm_file *file_priv);
  934. extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
  935. void *data, struct drm_file *file_priv);
  936. extern u8 *drm_find_cea_extension(struct edid *edid);
  937. extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
  938. extern bool drm_detect_hdmi_monitor(struct edid *edid);
  939. extern bool drm_detect_monitor_audio(struct edid *edid);
  940. extern bool drm_rgb_quant_range_selectable(struct edid *edid);
  941. extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
  942. void *data, struct drm_file *file_priv);
  943. extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
  944. int hdisplay, int vdisplay, int vrefresh,
  945. bool reduced, bool interlaced, bool margins);
  946. extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
  947. int hdisplay, int vdisplay, int vrefresh,
  948. bool interlaced, int margins);
  949. extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
  950. int hdisplay, int vdisplay, int vrefresh,
  951. bool interlaced, int margins, int GTF_M,
  952. int GTF_2C, int GTF_K, int GTF_2J);
  953. extern int drm_add_modes_noedid(struct drm_connector *connector,
  954. int hdisplay, int vdisplay);
  955. extern int drm_edid_header_is_valid(const u8 *raw_edid);
  956. extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid);
  957. extern bool drm_edid_is_valid(struct edid *edid);
  958. struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
  959. int hsize, int vsize, int fresh,
  960. bool rb);
  961. extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
  962. void *data, struct drm_file *file_priv);
  963. extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
  964. void *data, struct drm_file *file_priv);
  965. extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
  966. void *data, struct drm_file *file_priv);
  967. extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
  968. struct drm_file *file_priv);
  969. extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
  970. struct drm_file *file_priv);
  971. extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
  972. int *bpp);
  973. extern int drm_format_num_planes(uint32_t format);
  974. extern int drm_format_plane_cpp(uint32_t format, int plane);
  975. extern int drm_format_horz_chroma_subsampling(uint32_t format);
  976. extern int drm_format_vert_chroma_subsampling(uint32_t format);
  977. extern const char *drm_get_format_name(uint32_t format);
  978. #endif /* __DRM_CRTC_H__ */