drm_crtc.h 41 KB

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