drm_crtc.h 41 KB

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