drm_crtc.h 41 KB

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