drm_crtc.h 41 KB

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