drm_crtc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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. struct drm_device;
  33. struct drm_mode_set;
  34. struct drm_framebuffer;
  35. #define DRM_MODE_OBJECT_CRTC 0xcccccccc
  36. #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
  37. #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
  38. #define DRM_MODE_OBJECT_MODE 0xdededede
  39. #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  40. #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  41. #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
  42. struct drm_mode_object {
  43. uint32_t id;
  44. uint32_t type;
  45. };
  46. /*
  47. * Note on terminology: here, for brevity and convenience, we refer to connector
  48. * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
  49. * DVI, etc. And 'screen' refers to the whole of the visible display, which
  50. * may span multiple monitors (and therefore multiple CRTC and connector
  51. * structures).
  52. */
  53. enum drm_mode_status {
  54. MODE_OK = 0, /* Mode OK */
  55. MODE_HSYNC, /* hsync out of range */
  56. MODE_VSYNC, /* vsync out of range */
  57. MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
  58. MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
  59. MODE_BAD_WIDTH, /* requires an unsupported linepitch */
  60. MODE_NOMODE, /* no mode with a matching name */
  61. MODE_NO_INTERLACE, /* interlaced mode not supported */
  62. MODE_NO_DBLESCAN, /* doublescan mode not supported */
  63. MODE_NO_VSCAN, /* multiscan mode not supported */
  64. MODE_MEM, /* insufficient video memory */
  65. MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
  66. MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
  67. MODE_MEM_VIRT, /* insufficient video memory given virtual size */
  68. MODE_NOCLOCK, /* no fixed clock available */
  69. MODE_CLOCK_HIGH, /* clock required is too high */
  70. MODE_CLOCK_LOW, /* clock required is too low */
  71. MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
  72. MODE_BAD_HVALUE, /* horizontal timing was out of range */
  73. MODE_BAD_VVALUE, /* vertical timing was out of range */
  74. MODE_BAD_VSCAN, /* VScan value out of range */
  75. MODE_HSYNC_NARROW, /* horizontal sync too narrow */
  76. MODE_HSYNC_WIDE, /* horizontal sync too wide */
  77. MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
  78. MODE_HBLANK_WIDE, /* horizontal blanking too wide */
  79. MODE_VSYNC_NARROW, /* vertical sync too narrow */
  80. MODE_VSYNC_WIDE, /* vertical sync too wide */
  81. MODE_VBLANK_NARROW, /* vertical blanking too narrow */
  82. MODE_VBLANK_WIDE, /* vertical blanking too wide */
  83. MODE_PANEL, /* exceeds panel dimensions */
  84. MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
  85. MODE_ONE_WIDTH, /* only one width is supported */
  86. MODE_ONE_HEIGHT, /* only one height is supported */
  87. MODE_ONE_SIZE, /* only one resolution is supported */
  88. MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
  89. MODE_UNVERIFIED = -3, /* mode needs to reverified */
  90. MODE_BAD = -2, /* unspecified reason */
  91. MODE_ERROR = -1 /* error condition */
  92. };
  93. #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
  94. DRM_MODE_TYPE_CRTC_C)
  95. #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
  96. .name = nm, .status = 0, .type = (t), .clock = (c), \
  97. .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
  98. .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
  99. .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
  100. .vscan = (vs), .flags = (f), .vrefresh = 0
  101. #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
  102. struct drm_display_mode {
  103. /* Header */
  104. struct list_head head;
  105. struct drm_mode_object base;
  106. char name[DRM_DISPLAY_MODE_LEN];
  107. int connector_count;
  108. enum drm_mode_status status;
  109. int type;
  110. /* Proposed mode values */
  111. int clock; /* in kHz */
  112. int hdisplay;
  113. int hsync_start;
  114. int hsync_end;
  115. int htotal;
  116. int hskew;
  117. int vdisplay;
  118. int vsync_start;
  119. int vsync_end;
  120. int vtotal;
  121. int vscan;
  122. unsigned int flags;
  123. /* Addressable image size (may be 0 for projectors, etc.) */
  124. int width_mm;
  125. int height_mm;
  126. /* Actual mode we give to hw */
  127. int clock_index;
  128. int synth_clock;
  129. int crtc_hdisplay;
  130. int crtc_hblank_start;
  131. int crtc_hblank_end;
  132. int crtc_hsync_start;
  133. int crtc_hsync_end;
  134. int crtc_htotal;
  135. int crtc_hskew;
  136. int crtc_vdisplay;
  137. int crtc_vblank_start;
  138. int crtc_vblank_end;
  139. int crtc_vsync_start;
  140. int crtc_vsync_end;
  141. int crtc_vtotal;
  142. int crtc_hadjusted;
  143. int crtc_vadjusted;
  144. /* Driver private mode info */
  145. int private_size;
  146. int *private;
  147. int private_flags;
  148. int vrefresh; /* in Hz */
  149. int hsync; /* in kHz */
  150. };
  151. enum drm_connector_status {
  152. connector_status_connected = 1,
  153. connector_status_disconnected = 2,
  154. connector_status_unknown = 3,
  155. };
  156. enum subpixel_order {
  157. SubPixelUnknown = 0,
  158. SubPixelHorizontalRGB,
  159. SubPixelHorizontalBGR,
  160. SubPixelVerticalRGB,
  161. SubPixelVerticalBGR,
  162. SubPixelNone,
  163. };
  164. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  165. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  166. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  167. /*
  168. * Describes a given display (e.g. CRT or flat panel) and its limitations.
  169. */
  170. struct drm_display_info {
  171. char name[DRM_DISPLAY_INFO_LEN];
  172. /* Physical size */
  173. unsigned int width_mm;
  174. unsigned int height_mm;
  175. /* Clock limits FIXME: storage format */
  176. unsigned int min_vfreq, max_vfreq;
  177. unsigned int min_hfreq, max_hfreq;
  178. unsigned int pixel_clock;
  179. unsigned int bpc;
  180. enum subpixel_order subpixel_order;
  181. u32 color_formats;
  182. u8 cea_rev;
  183. char *raw_edid; /* if any */
  184. };
  185. struct drm_framebuffer_funcs {
  186. void (*destroy)(struct drm_framebuffer *framebuffer);
  187. int (*create_handle)(struct drm_framebuffer *fb,
  188. struct drm_file *file_priv,
  189. unsigned int *handle);
  190. /**
  191. * Optinal callback for the dirty fb ioctl.
  192. *
  193. * Userspace can notify the driver via this callback
  194. * that a area of the framebuffer has changed and should
  195. * be flushed to the display hardware.
  196. *
  197. * See documentation in drm_mode.h for the struct
  198. * drm_mode_fb_dirty_cmd for more information as all
  199. * the semantics and arguments have a one to one mapping
  200. * on this function.
  201. */
  202. int (*dirty)(struct drm_framebuffer *framebuffer,
  203. struct drm_file *file_priv, unsigned flags,
  204. unsigned color, struct drm_clip_rect *clips,
  205. unsigned num_clips);
  206. };
  207. struct drm_framebuffer {
  208. struct drm_device *dev;
  209. struct list_head head;
  210. struct drm_mode_object base;
  211. const struct drm_framebuffer_funcs *funcs;
  212. unsigned int pitch;
  213. unsigned int width;
  214. unsigned int height;
  215. /* depth can be 15 or 16 */
  216. unsigned int depth;
  217. int bits_per_pixel;
  218. int flags;
  219. struct list_head filp_head;
  220. /* if you are using the helper */
  221. void *helper_private;
  222. };
  223. struct drm_property_blob {
  224. struct drm_mode_object base;
  225. struct list_head head;
  226. unsigned int length;
  227. void *data;
  228. };
  229. struct drm_property_enum {
  230. uint64_t value;
  231. struct list_head head;
  232. char name[DRM_PROP_NAME_LEN];
  233. };
  234. struct drm_property {
  235. struct list_head head;
  236. struct drm_mode_object base;
  237. uint32_t flags;
  238. char name[DRM_PROP_NAME_LEN];
  239. uint32_t num_values;
  240. uint64_t *values;
  241. struct list_head enum_blob_list;
  242. };
  243. struct drm_crtc;
  244. struct drm_connector;
  245. struct drm_encoder;
  246. struct drm_pending_vblank_event;
  247. /**
  248. * drm_crtc_funcs - control CRTCs for a given device
  249. * @reset: reset CRTC after state has been invalidate (e.g. resume)
  250. * @dpms: control display power levels
  251. * @save: save CRTC state
  252. * @resore: restore CRTC state
  253. * @lock: lock the CRTC
  254. * @unlock: unlock the CRTC
  255. * @shadow_allocate: allocate shadow pixmap
  256. * @shadow_create: create shadow pixmap for rotation support
  257. * @shadow_destroy: free shadow pixmap
  258. * @mode_fixup: fixup proposed mode
  259. * @mode_set: set the desired mode on the CRTC
  260. * @gamma_set: specify color ramp for CRTC
  261. * @destroy: deinit and free object.
  262. *
  263. * The drm_crtc_funcs structure is the central CRTC management structure
  264. * in the DRM. Each CRTC controls one or more connectors (note that the name
  265. * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
  266. * connectors, not just CRTs).
  267. *
  268. * Each driver is responsible for filling out this structure at startup time,
  269. * in addition to providing other modesetting features, like i2c and DDC
  270. * bus accessors.
  271. */
  272. struct drm_crtc_funcs {
  273. /* Save CRTC state */
  274. void (*save)(struct drm_crtc *crtc); /* suspend? */
  275. /* Restore CRTC state */
  276. void (*restore)(struct drm_crtc *crtc); /* resume? */
  277. /* Reset CRTC state */
  278. void (*reset)(struct drm_crtc *crtc);
  279. /* cursor controls */
  280. int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
  281. uint32_t handle, uint32_t width, uint32_t height);
  282. int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
  283. /* Set gamma on the CRTC */
  284. void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
  285. uint32_t start, uint32_t size);
  286. /* Object destroy routine */
  287. void (*destroy)(struct drm_crtc *crtc);
  288. int (*set_config)(struct drm_mode_set *set);
  289. /*
  290. * Flip to the given framebuffer. This implements the page
  291. * flip ioctl described in drm_mode.h, specifically, the
  292. * implementation must return immediately and block all
  293. * rendering to the current fb until the flip has completed.
  294. * If userspace set the event flag in the ioctl, the event
  295. * argument will point to an event to send back when the flip
  296. * completes, otherwise it will be NULL.
  297. */
  298. int (*page_flip)(struct drm_crtc *crtc,
  299. struct drm_framebuffer *fb,
  300. struct drm_pending_vblank_event *event);
  301. };
  302. /**
  303. * drm_crtc - central CRTC control structure
  304. * @enabled: is this CRTC enabled?
  305. * @x: x position on screen
  306. * @y: y position on screen
  307. * @funcs: CRTC control functions
  308. *
  309. * Each CRTC may have one or more connectors associated with it. This structure
  310. * allows the CRTC to be controlled.
  311. */
  312. struct drm_crtc {
  313. struct drm_device *dev;
  314. struct list_head head;
  315. struct drm_mode_object base;
  316. /* framebuffer the connector is currently bound to */
  317. struct drm_framebuffer *fb;
  318. bool enabled;
  319. /* Requested mode from modesetting. */
  320. struct drm_display_mode mode;
  321. /* Programmed mode in hw, after adjustments for encoders,
  322. * crtc, panel scaling etc. Needed for timestamping etc.
  323. */
  324. struct drm_display_mode hwmode;
  325. int x, y;
  326. const struct drm_crtc_funcs *funcs;
  327. /* CRTC gamma size for reporting to userspace */
  328. uint32_t gamma_size;
  329. uint16_t *gamma_store;
  330. /* Constants needed for precise vblank and swap timestamping. */
  331. s64 framedur_ns, linedur_ns, pixeldur_ns;
  332. /* if you are using the helper */
  333. void *helper_private;
  334. };
  335. /**
  336. * drm_connector_funcs - control connectors on a given device
  337. * @dpms: set power state (see drm_crtc_funcs above)
  338. * @save: save connector state
  339. * @restore: restore connector state
  340. * @reset: reset connector after state has been invalidate (e.g. resume)
  341. * @mode_valid: is this mode valid on the given connector?
  342. * @mode_fixup: try to fixup proposed mode for this connector
  343. * @mode_set: set this mode
  344. * @detect: is this connector active?
  345. * @get_modes: get mode list for this connector
  346. * @set_property: property for this connector may need update
  347. * @destroy: make object go away
  348. * @force: notify the driver the connector is forced on
  349. *
  350. * Each CRTC may have one or more connectors attached to it. The functions
  351. * below allow the core DRM code to control connectors, enumerate available modes,
  352. * etc.
  353. */
  354. struct drm_connector_funcs {
  355. void (*dpms)(struct drm_connector *connector, int mode);
  356. void (*save)(struct drm_connector *connector);
  357. void (*restore)(struct drm_connector *connector);
  358. void (*reset)(struct drm_connector *connector);
  359. /* Check to see if anything is attached to the connector.
  360. * @force is set to false whilst polling, true when checking the
  361. * connector due to user request. @force can be used by the driver
  362. * to avoid expensive, destructive operations during automated
  363. * probing.
  364. */
  365. enum drm_connector_status (*detect)(struct drm_connector *connector,
  366. bool force);
  367. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  368. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  369. uint64_t val);
  370. void (*destroy)(struct drm_connector *connector);
  371. void (*force)(struct drm_connector *connector);
  372. };
  373. struct drm_encoder_funcs {
  374. void (*reset)(struct drm_encoder *encoder);
  375. void (*destroy)(struct drm_encoder *encoder);
  376. };
  377. #define DRM_CONNECTOR_MAX_UMODES 16
  378. #define DRM_CONNECTOR_MAX_PROPERTY 16
  379. #define DRM_CONNECTOR_LEN 32
  380. #define DRM_CONNECTOR_MAX_ENCODER 2
  381. /**
  382. * drm_encoder - central DRM encoder structure
  383. */
  384. struct drm_encoder {
  385. struct drm_device *dev;
  386. struct list_head head;
  387. struct drm_mode_object base;
  388. int encoder_type;
  389. uint32_t possible_crtcs;
  390. uint32_t possible_clones;
  391. struct drm_crtc *crtc;
  392. const struct drm_encoder_funcs *funcs;
  393. void *helper_private;
  394. };
  395. enum drm_connector_force {
  396. DRM_FORCE_UNSPECIFIED,
  397. DRM_FORCE_OFF,
  398. DRM_FORCE_ON, /* force on analog part normally */
  399. DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
  400. };
  401. /* should we poll this connector for connects and disconnects */
  402. /* hot plug detectable */
  403. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  404. /* poll for connections */
  405. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  406. /* can cleanly poll for disconnections without flickering the screen */
  407. /* DACs should rarely do this without a lot of testing */
  408. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  409. /**
  410. * drm_connector - central DRM connector control structure
  411. * @crtc: CRTC this connector is currently connected to, NULL if none
  412. * @interlace_allowed: can this connector handle interlaced modes?
  413. * @doublescan_allowed: can this connector handle doublescan?
  414. * @available_modes: modes available on this connector (from get_modes() + user)
  415. * @initial_x: initial x position for this connector
  416. * @initial_y: initial y position for this connector
  417. * @status: connector connected?
  418. * @funcs: connector control functions
  419. *
  420. * Each connector may be connected to one or more CRTCs, or may be clonable by
  421. * another connector if they can share a CRTC. Each connector also has a specific
  422. * position in the broader display (referred to as a 'screen' though it could
  423. * span multiple monitors).
  424. */
  425. struct drm_connector {
  426. struct drm_device *dev;
  427. struct device kdev;
  428. struct device_attribute *attr;
  429. struct list_head head;
  430. struct drm_mode_object base;
  431. int connector_type;
  432. int connector_type_id;
  433. bool interlace_allowed;
  434. bool doublescan_allowed;
  435. struct list_head modes; /* list of modes on this connector */
  436. int initial_x, initial_y;
  437. enum drm_connector_status status;
  438. /* these are modes added by probing with DDC or the BIOS */
  439. struct list_head probed_modes;
  440. struct drm_display_info display_info;
  441. const struct drm_connector_funcs *funcs;
  442. struct list_head user_modes;
  443. struct drm_property_blob *edid_blob_ptr;
  444. u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
  445. uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
  446. uint8_t polled; /* DRM_CONNECTOR_POLL_* */
  447. /* requested DPMS state */
  448. int dpms;
  449. void *helper_private;
  450. /* forced on connector */
  451. enum drm_connector_force force;
  452. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  453. uint32_t force_encoder_id;
  454. struct drm_encoder *encoder; /* currently active encoder */
  455. int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
  456. };
  457. /**
  458. * struct drm_mode_set
  459. *
  460. * Represents a single crtc the connectors that it drives with what mode
  461. * and from which framebuffer it scans out from.
  462. *
  463. * This is used to set modes.
  464. */
  465. struct drm_mode_set {
  466. struct list_head head;
  467. struct drm_framebuffer *fb;
  468. struct drm_crtc *crtc;
  469. struct drm_display_mode *mode;
  470. uint32_t x;
  471. uint32_t y;
  472. struct drm_connector **connectors;
  473. size_t num_connectors;
  474. };
  475. /**
  476. * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
  477. */
  478. struct drm_mode_config_funcs {
  479. struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
  480. void (*output_poll_changed)(struct drm_device *dev);
  481. };
  482. struct drm_mode_group {
  483. uint32_t num_crtcs;
  484. uint32_t num_encoders;
  485. uint32_t num_connectors;
  486. /* list of object IDs for this group */
  487. uint32_t *id_list;
  488. };
  489. /**
  490. * drm_mode_config - Mode configuration control structure
  491. *
  492. */
  493. struct drm_mode_config {
  494. struct mutex mutex; /* protects configuration (mode lists etc.) */
  495. struct mutex idr_mutex; /* for IDR management */
  496. struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
  497. /* this is limited to one for now */
  498. int num_fb;
  499. struct list_head fb_list;
  500. int num_connector;
  501. struct list_head connector_list;
  502. int num_encoder;
  503. struct list_head encoder_list;
  504. int num_crtc;
  505. struct list_head crtc_list;
  506. struct list_head property_list;
  507. int min_width, min_height;
  508. int max_width, max_height;
  509. struct drm_mode_config_funcs *funcs;
  510. resource_size_t fb_base;
  511. /* output poll support */
  512. bool poll_enabled;
  513. struct delayed_work output_poll_work;
  514. /* pointers to standard properties */
  515. struct list_head property_blob_list;
  516. struct drm_property *edid_property;
  517. struct drm_property *dpms_property;
  518. /* DVI-I properties */
  519. struct drm_property *dvi_i_subconnector_property;
  520. struct drm_property *dvi_i_select_subconnector_property;
  521. /* TV properties */
  522. struct drm_property *tv_subconnector_property;
  523. struct drm_property *tv_select_subconnector_property;
  524. struct drm_property *tv_mode_property;
  525. struct drm_property *tv_left_margin_property;
  526. struct drm_property *tv_right_margin_property;
  527. struct drm_property *tv_top_margin_property;
  528. struct drm_property *tv_bottom_margin_property;
  529. struct drm_property *tv_brightness_property;
  530. struct drm_property *tv_contrast_property;
  531. struct drm_property *tv_flicker_reduction_property;
  532. struct drm_property *tv_overscan_property;
  533. struct drm_property *tv_saturation_property;
  534. struct drm_property *tv_hue_property;
  535. /* Optional properties */
  536. struct drm_property *scaling_mode_property;
  537. struct drm_property *dithering_mode_property;
  538. struct drm_property *dirty_info_property;
  539. };
  540. #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
  541. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  542. #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
  543. #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
  544. #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
  545. #define obj_to_property(x) container_of(x, struct drm_property, base)
  546. #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
  547. extern void drm_crtc_init(struct drm_device *dev,
  548. struct drm_crtc *crtc,
  549. const struct drm_crtc_funcs *funcs);
  550. extern void drm_crtc_cleanup(struct drm_crtc *crtc);
  551. extern void drm_connector_init(struct drm_device *dev,
  552. struct drm_connector *connector,
  553. const struct drm_connector_funcs *funcs,
  554. int connector_type);
  555. extern void drm_connector_cleanup(struct drm_connector *connector);
  556. extern void drm_encoder_init(struct drm_device *dev,
  557. struct drm_encoder *encoder,
  558. const struct drm_encoder_funcs *funcs,
  559. int encoder_type);
  560. extern void drm_encoder_cleanup(struct drm_encoder *encoder);
  561. extern char *drm_get_connector_name(struct drm_connector *connector);
  562. extern char *drm_get_dpms_name(int val);
  563. extern char *drm_get_dvi_i_subconnector_name(int val);
  564. extern char *drm_get_dvi_i_select_name(int val);
  565. extern char *drm_get_tv_subconnector_name(int val);
  566. extern char *drm_get_tv_select_name(int val);
  567. extern void drm_fb_release(struct drm_file *file_priv);
  568. extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
  569. extern struct edid *drm_get_edid(struct drm_connector *connector,
  570. struct i2c_adapter *adapter);
  571. extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
  572. extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
  573. extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
  574. extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
  575. const struct drm_display_mode *mode);
  576. extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
  577. extern void drm_mode_config_init(struct drm_device *dev);
  578. extern void drm_mode_config_reset(struct drm_device *dev);
  579. extern void drm_mode_config_cleanup(struct drm_device *dev);
  580. extern void drm_mode_set_name(struct drm_display_mode *mode);
  581. extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
  582. extern int drm_mode_width(struct drm_display_mode *mode);
  583. extern int drm_mode_height(struct drm_display_mode *mode);
  584. /* for us by fb module */
  585. extern int drm_mode_attachmode_crtc(struct drm_device *dev,
  586. struct drm_crtc *crtc,
  587. struct drm_display_mode *mode);
  588. extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
  589. extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
  590. extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
  591. extern void drm_mode_list_concat(struct list_head *head,
  592. struct list_head *new);
  593. extern void drm_mode_validate_size(struct drm_device *dev,
  594. struct list_head *mode_list,
  595. int maxX, int maxY, int maxPitch);
  596. extern void drm_mode_prune_invalid(struct drm_device *dev,
  597. struct list_head *mode_list, bool verbose);
  598. extern void drm_mode_sort(struct list_head *mode_list);
  599. extern int drm_mode_hsync(const struct drm_display_mode *mode);
  600. extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
  601. extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
  602. int adjust_flags);
  603. extern void drm_mode_connector_list_update(struct drm_connector *connector);
  604. extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
  605. struct edid *edid);
  606. extern int drm_connector_property_set_value(struct drm_connector *connector,
  607. struct drm_property *property,
  608. uint64_t value);
  609. extern int drm_connector_property_get_value(struct drm_connector *connector,
  610. struct drm_property *property,
  611. uint64_t *value);
  612. extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
  613. extern void drm_framebuffer_set_object(struct drm_device *dev,
  614. unsigned long handle);
  615. extern int drm_framebuffer_init(struct drm_device *dev,
  616. struct drm_framebuffer *fb,
  617. const struct drm_framebuffer_funcs *funcs);
  618. extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
  619. extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
  620. extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
  621. extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
  622. extern bool drm_crtc_in_use(struct drm_crtc *crtc);
  623. extern int drm_connector_attach_property(struct drm_connector *connector,
  624. struct drm_property *property, uint64_t init_val);
  625. extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
  626. const char *name, int num_values);
  627. extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
  628. extern int drm_property_add_enum(struct drm_property *property, int index,
  629. uint64_t value, const char *name);
  630. extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  631. extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
  632. char *formats[]);
  633. extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  634. extern int drm_mode_create_dithering_property(struct drm_device *dev);
  635. extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
  636. extern char *drm_get_encoder_name(struct drm_encoder *encoder);
  637. extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
  638. struct drm_encoder *encoder);
  639. extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
  640. struct drm_encoder *encoder);
  641. extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
  642. int gamma_size);
  643. extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
  644. uint32_t id, uint32_t type);
  645. /* IOCTLs */
  646. extern int drm_mode_getresources(struct drm_device *dev,
  647. void *data, struct drm_file *file_priv);
  648. extern int drm_mode_getcrtc(struct drm_device *dev,
  649. void *data, struct drm_file *file_priv);
  650. extern int drm_mode_getconnector(struct drm_device *dev,
  651. void *data, struct drm_file *file_priv);
  652. extern int drm_mode_setcrtc(struct drm_device *dev,
  653. void *data, struct drm_file *file_priv);
  654. extern int drm_mode_cursor_ioctl(struct drm_device *dev,
  655. void *data, struct drm_file *file_priv);
  656. extern int drm_mode_addfb(struct drm_device *dev,
  657. void *data, struct drm_file *file_priv);
  658. extern int drm_mode_rmfb(struct drm_device *dev,
  659. void *data, struct drm_file *file_priv);
  660. extern int drm_mode_getfb(struct drm_device *dev,
  661. void *data, struct drm_file *file_priv);
  662. extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
  663. void *data, struct drm_file *file_priv);
  664. extern int drm_mode_addmode_ioctl(struct drm_device *dev,
  665. void *data, struct drm_file *file_priv);
  666. extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
  667. void *data, struct drm_file *file_priv);
  668. extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
  669. void *data, struct drm_file *file_priv);
  670. extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
  671. void *data, struct drm_file *file_priv);
  672. extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
  673. void *data, struct drm_file *file_priv);
  674. extern int drm_mode_getblob_ioctl(struct drm_device *dev,
  675. void *data, struct drm_file *file_priv);
  676. extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
  677. void *data, struct drm_file *file_priv);
  678. extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
  679. void *data, struct drm_file *file_priv);
  680. extern int drm_mode_replacefb(struct drm_device *dev,
  681. void *data, struct drm_file *file_priv);
  682. extern int drm_mode_getencoder(struct drm_device *dev,
  683. void *data, struct drm_file *file_priv);
  684. extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
  685. void *data, struct drm_file *file_priv);
  686. extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
  687. void *data, struct drm_file *file_priv);
  688. extern u8 *drm_find_cea_extension(struct edid *edid);
  689. extern bool drm_detect_hdmi_monitor(struct edid *edid);
  690. extern bool drm_detect_monitor_audio(struct edid *edid);
  691. extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
  692. void *data, struct drm_file *file_priv);
  693. extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
  694. int hdisplay, int vdisplay, int vrefresh,
  695. bool reduced, bool interlaced, bool margins);
  696. extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
  697. int hdisplay, int vdisplay, int vrefresh,
  698. bool interlaced, int margins);
  699. extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
  700. int hdisplay, int vdisplay, int vrefresh,
  701. bool interlaced, int margins, int GTF_M,
  702. int GTF_2C, int GTF_K, int GTF_2J);
  703. extern int drm_add_modes_noedid(struct drm_connector *connector,
  704. int hdisplay, int vdisplay);
  705. extern int drm_edid_header_is_valid(const u8 *raw_edid);
  706. extern bool drm_edid_is_valid(struct edid *edid);
  707. struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
  708. int hsize, int vsize, int fresh);
  709. extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
  710. void *data, struct drm_file *file_priv);
  711. extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
  712. void *data, struct drm_file *file_priv);
  713. extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
  714. void *data, struct drm_file *file_priv);
  715. #endif /* __DRM_CRTC_H__ */