drm_crtc.h 41 KB

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