drm_crtc.h 40 KB

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