drm_crtc.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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 maching 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;
  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;
  149. float hsync;
  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. /*
  165. * Describes a given display (e.g. CRT or flat panel) and its limitations.
  166. */
  167. struct drm_display_info {
  168. char name[DRM_DISPLAY_INFO_LEN];
  169. /* Input info */
  170. bool serration_vsync;
  171. bool sync_on_green;
  172. bool composite_sync;
  173. bool separate_syncs;
  174. bool blank_to_black;
  175. unsigned char video_level;
  176. bool digital;
  177. /* Physical size */
  178. unsigned int width_mm;
  179. unsigned int height_mm;
  180. /* Display parameters */
  181. unsigned char gamma; /* FIXME: storage format */
  182. bool gtf_supported;
  183. bool standard_color;
  184. enum {
  185. monochrome = 0,
  186. rgb,
  187. other,
  188. unknown,
  189. } display_type;
  190. bool active_off_supported;
  191. bool suspend_supported;
  192. bool standby_supported;
  193. /* Color info FIXME: storage format */
  194. unsigned short redx, redy;
  195. unsigned short greenx, greeny;
  196. unsigned short bluex, bluey;
  197. unsigned short whitex, whitey;
  198. /* Clock limits FIXME: storage format */
  199. unsigned int min_vfreq, max_vfreq;
  200. unsigned int min_hfreq, max_hfreq;
  201. unsigned int pixel_clock;
  202. /* White point indices FIXME: storage format */
  203. unsigned int wpx1, wpy1;
  204. unsigned int wpgamma1;
  205. unsigned int wpx2, wpy2;
  206. unsigned int wpgamma2;
  207. enum subpixel_order subpixel_order;
  208. char *raw_edid; /* if any */
  209. };
  210. struct drm_framebuffer_funcs {
  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. struct drm_framebuffer {
  217. struct drm_device *dev;
  218. struct list_head head;
  219. struct drm_mode_object base;
  220. const struct drm_framebuffer_funcs *funcs;
  221. unsigned int pitch;
  222. unsigned int width;
  223. unsigned int height;
  224. /* depth can be 15 or 16 */
  225. unsigned int depth;
  226. int bits_per_pixel;
  227. int flags;
  228. void *fbdev;
  229. u32 pseudo_palette[17];
  230. struct list_head filp_head;
  231. };
  232. struct drm_property_blob {
  233. struct drm_mode_object base;
  234. struct list_head head;
  235. unsigned int length;
  236. void *data;
  237. };
  238. struct drm_property_enum {
  239. uint64_t value;
  240. struct list_head head;
  241. char name[DRM_PROP_NAME_LEN];
  242. };
  243. struct drm_property {
  244. struct list_head head;
  245. struct drm_mode_object base;
  246. uint32_t flags;
  247. char name[DRM_PROP_NAME_LEN];
  248. uint32_t num_values;
  249. uint64_t *values;
  250. struct list_head enum_blob_list;
  251. };
  252. struct drm_crtc;
  253. struct drm_connector;
  254. struct drm_encoder;
  255. /**
  256. * drm_crtc_funcs - control CRTCs for a given device
  257. * @dpms: control display power levels
  258. * @save: save CRTC state
  259. * @resore: restore CRTC state
  260. * @lock: lock the CRTC
  261. * @unlock: unlock the CRTC
  262. * @shadow_allocate: allocate shadow pixmap
  263. * @shadow_create: create shadow pixmap for rotation support
  264. * @shadow_destroy: free shadow pixmap
  265. * @mode_fixup: fixup proposed mode
  266. * @mode_set: set the desired mode on the CRTC
  267. * @gamma_set: specify color ramp for CRTC
  268. * @destroy: deinit and free object.
  269. *
  270. * The drm_crtc_funcs structure is the central CRTC management structure
  271. * in the DRM. Each CRTC controls one or more connectors (note that the name
  272. * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
  273. * connectors, not just CRTs).
  274. *
  275. * Each driver is responsible for filling out this structure at startup time,
  276. * in addition to providing other modesetting features, like i2c and DDC
  277. * bus accessors.
  278. */
  279. struct drm_crtc_funcs {
  280. /* Save CRTC state */
  281. void (*save)(struct drm_crtc *crtc); /* suspend? */
  282. /* Restore CRTC state */
  283. void (*restore)(struct drm_crtc *crtc); /* resume? */
  284. /* cursor controls */
  285. int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
  286. uint32_t handle, uint32_t width, uint32_t height);
  287. int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
  288. /* Set gamma on the CRTC */
  289. void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
  290. uint32_t size);
  291. /* Object destroy routine */
  292. void (*destroy)(struct drm_crtc *crtc);
  293. int (*set_config)(struct drm_mode_set *set);
  294. };
  295. /**
  296. * drm_crtc - central CRTC control structure
  297. * @enabled: is this CRTC enabled?
  298. * @x: x position on screen
  299. * @y: y position on screen
  300. * @desired_mode: new desired mode
  301. * @desired_x: desired x for desired_mode
  302. * @desired_y: desired y for desired_mode
  303. * @funcs: CRTC control functions
  304. *
  305. * Each CRTC may have one or more connectors associated with it. This structure
  306. * allows the CRTC to be controlled.
  307. */
  308. struct drm_crtc {
  309. struct drm_device *dev;
  310. struct list_head head;
  311. struct drm_mode_object base;
  312. /* framebuffer the connector is currently bound to */
  313. struct drm_framebuffer *fb;
  314. bool enabled;
  315. struct drm_display_mode mode;
  316. int x, y;
  317. struct drm_display_mode *desired_mode;
  318. int desired_x, desired_y;
  319. const struct drm_crtc_funcs *funcs;
  320. /* CRTC gamma size for reporting to userspace */
  321. uint32_t gamma_size;
  322. uint16_t *gamma_store;
  323. /* if you are using the helper */
  324. void *helper_private;
  325. };
  326. /**
  327. * drm_connector_funcs - control connectors on a given device
  328. * @dpms: set power state (see drm_crtc_funcs above)
  329. * @save: save connector state
  330. * @restore: restore connector state
  331. * @mode_valid: is this mode valid on the given connector?
  332. * @mode_fixup: try to fixup proposed mode for this connector
  333. * @mode_set: set this mode
  334. * @detect: is this connector active?
  335. * @get_modes: get mode list for this connector
  336. * @set_property: property for this connector may need update
  337. * @destroy: make object go away
  338. *
  339. * Each CRTC may have one or more connectors attached to it. The functions
  340. * below allow the core DRM code to control connectors, enumerate available modes,
  341. * etc.
  342. */
  343. struct drm_connector_funcs {
  344. void (*dpms)(struct drm_connector *connector, int mode);
  345. void (*save)(struct drm_connector *connector);
  346. void (*restore)(struct drm_connector *connector);
  347. enum drm_connector_status (*detect)(struct drm_connector *connector);
  348. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  349. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  350. uint64_t val);
  351. void (*destroy)(struct drm_connector *connector);
  352. };
  353. struct drm_encoder_funcs {
  354. void (*destroy)(struct drm_encoder *encoder);
  355. };
  356. #define DRM_CONNECTOR_MAX_UMODES 16
  357. #define DRM_CONNECTOR_MAX_PROPERTY 16
  358. #define DRM_CONNECTOR_LEN 32
  359. #define DRM_CONNECTOR_MAX_ENCODER 2
  360. /**
  361. * drm_encoder - central DRM encoder structure
  362. */
  363. struct drm_encoder {
  364. struct drm_device *dev;
  365. struct list_head head;
  366. struct drm_mode_object base;
  367. int encoder_type;
  368. uint32_t possible_crtcs;
  369. uint32_t possible_clones;
  370. struct drm_crtc *crtc;
  371. const struct drm_encoder_funcs *funcs;
  372. void *helper_private;
  373. };
  374. /**
  375. * drm_connector - central DRM connector control structure
  376. * @crtc: CRTC this connector is currently connected to, NULL if none
  377. * @interlace_allowed: can this connector handle interlaced modes?
  378. * @doublescan_allowed: can this connector handle doublescan?
  379. * @available_modes: modes available on this connector (from get_modes() + user)
  380. * @initial_x: initial x position for this connector
  381. * @initial_y: initial y position for this connector
  382. * @status: connector connected?
  383. * @funcs: connector control functions
  384. *
  385. * Each connector may be connected to one or more CRTCs, or may be clonable by
  386. * another connector if they can share a CRTC. Each connector also has a specific
  387. * position in the broader display (referred to as a 'screen' though it could
  388. * span multiple monitors).
  389. */
  390. struct drm_connector {
  391. struct drm_device *dev;
  392. struct device kdev;
  393. struct device_attribute *attr;
  394. struct list_head head;
  395. struct drm_mode_object base;
  396. int connector_type;
  397. int connector_type_id;
  398. bool interlace_allowed;
  399. bool doublescan_allowed;
  400. struct list_head modes; /* list of modes on this connector */
  401. int initial_x, initial_y;
  402. enum drm_connector_status status;
  403. /* these are modes added by probing with DDC or the BIOS */
  404. struct list_head probed_modes;
  405. struct drm_display_info display_info;
  406. const struct drm_connector_funcs *funcs;
  407. struct list_head user_modes;
  408. struct drm_property_blob *edid_blob_ptr;
  409. u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
  410. uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
  411. /* requested DPMS state */
  412. int dpms;
  413. void *helper_private;
  414. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  415. uint32_t force_encoder_id;
  416. struct drm_encoder *encoder; /* currently active encoder */
  417. };
  418. /**
  419. * struct drm_mode_set
  420. *
  421. * Represents a single crtc the connectors that it drives with what mode
  422. * and from which framebuffer it scans out from.
  423. *
  424. * This is used to set modes.
  425. */
  426. struct drm_mode_set {
  427. struct list_head head;
  428. struct drm_framebuffer *fb;
  429. struct drm_crtc *crtc;
  430. struct drm_display_mode *mode;
  431. uint32_t x;
  432. uint32_t y;
  433. struct drm_connector **connectors;
  434. size_t num_connectors;
  435. };
  436. /**
  437. * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
  438. * @resize: adjust CRTCs as necessary for the proposed layout
  439. *
  440. * Currently only a resize hook is available. DRM will call back into the
  441. * driver with a new screen width and height. If the driver can't support
  442. * the proposed size, it can return false. Otherwise it should adjust
  443. * the CRTC<->connector mappings as needed and update its view of the screen.
  444. */
  445. struct drm_mode_config_funcs {
  446. struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
  447. int (*fb_changed)(struct drm_device *dev);
  448. };
  449. struct drm_mode_group {
  450. uint32_t num_crtcs;
  451. uint32_t num_encoders;
  452. uint32_t num_connectors;
  453. /* list of object IDs for this group */
  454. uint32_t *id_list;
  455. };
  456. /**
  457. * drm_mode_config - Mode configuration control structure
  458. *
  459. */
  460. struct drm_mode_config {
  461. struct mutex mutex; /* protects configuration (mode lists etc.) */
  462. struct mutex idr_mutex; /* for IDR management */
  463. struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
  464. /* this is limited to one for now */
  465. int num_fb;
  466. struct list_head fb_list;
  467. int num_connector;
  468. struct list_head connector_list;
  469. int num_encoder;
  470. struct list_head encoder_list;
  471. int num_crtc;
  472. struct list_head crtc_list;
  473. struct list_head property_list;
  474. /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
  475. struct list_head fb_kernel_list;
  476. int min_width, min_height;
  477. int max_width, max_height;
  478. struct drm_mode_config_funcs *funcs;
  479. resource_size_t fb_base;
  480. /* pointers to standard properties */
  481. struct list_head property_blob_list;
  482. struct drm_property *edid_property;
  483. struct drm_property *dpms_property;
  484. /* DVI-I properties */
  485. struct drm_property *dvi_i_subconnector_property;
  486. struct drm_property *dvi_i_select_subconnector_property;
  487. /* TV properties */
  488. struct drm_property *tv_subconnector_property;
  489. struct drm_property *tv_select_subconnector_property;
  490. struct drm_property *tv_mode_property;
  491. struct drm_property *tv_left_margin_property;
  492. struct drm_property *tv_right_margin_property;
  493. struct drm_property *tv_top_margin_property;
  494. struct drm_property *tv_bottom_margin_property;
  495. /* Optional properties */
  496. struct drm_property *scaling_mode_property;
  497. struct drm_property *dithering_mode_property;
  498. };
  499. #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
  500. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  501. #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
  502. #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
  503. #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
  504. #define obj_to_property(x) container_of(x, struct drm_property, base)
  505. #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
  506. extern void drm_crtc_init(struct drm_device *dev,
  507. struct drm_crtc *crtc,
  508. const struct drm_crtc_funcs *funcs);
  509. extern void drm_crtc_cleanup(struct drm_crtc *crtc);
  510. extern void drm_connector_init(struct drm_device *dev,
  511. struct drm_connector *connector,
  512. const struct drm_connector_funcs *funcs,
  513. int connector_type);
  514. extern void drm_connector_cleanup(struct drm_connector *connector);
  515. extern void drm_encoder_init(struct drm_device *dev,
  516. struct drm_encoder *encoder,
  517. const struct drm_encoder_funcs *funcs,
  518. int encoder_type);
  519. extern void drm_encoder_cleanup(struct drm_encoder *encoder);
  520. extern char *drm_get_connector_name(struct drm_connector *connector);
  521. extern char *drm_get_dpms_name(int val);
  522. extern char *drm_get_dvi_i_subconnector_name(int val);
  523. extern char *drm_get_dvi_i_select_name(int val);
  524. extern char *drm_get_tv_subconnector_name(int val);
  525. extern char *drm_get_tv_select_name(int val);
  526. extern void drm_fb_release(struct drm_file *file_priv);
  527. extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
  528. extern struct edid *drm_get_edid(struct drm_connector *connector,
  529. struct i2c_adapter *adapter);
  530. extern int drm_do_probe_ddc_edid(struct i2c_adapter *adapter,
  531. unsigned char *buf, int len);
  532. extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
  533. extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
  534. extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
  535. extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
  536. struct drm_display_mode *mode);
  537. extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
  538. extern void drm_mode_config_init(struct drm_device *dev);
  539. extern void drm_mode_config_cleanup(struct drm_device *dev);
  540. extern void drm_mode_set_name(struct drm_display_mode *mode);
  541. extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
  542. extern int drm_mode_width(struct drm_display_mode *mode);
  543. extern int drm_mode_height(struct drm_display_mode *mode);
  544. /* for us by fb module */
  545. extern int drm_mode_attachmode_crtc(struct drm_device *dev,
  546. struct drm_crtc *crtc,
  547. struct drm_display_mode *mode);
  548. extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
  549. extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
  550. extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
  551. extern void drm_mode_list_concat(struct list_head *head,
  552. struct list_head *new);
  553. extern void drm_mode_validate_size(struct drm_device *dev,
  554. struct list_head *mode_list,
  555. int maxX, int maxY, int maxPitch);
  556. extern void drm_mode_prune_invalid(struct drm_device *dev,
  557. struct list_head *mode_list, bool verbose);
  558. extern void drm_mode_sort(struct list_head *mode_list);
  559. extern int drm_mode_vrefresh(struct drm_display_mode *mode);
  560. extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
  561. int adjust_flags);
  562. extern void drm_mode_connector_list_update(struct drm_connector *connector);
  563. extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
  564. struct edid *edid);
  565. extern int drm_connector_property_set_value(struct drm_connector *connector,
  566. struct drm_property *property,
  567. uint64_t value);
  568. extern int drm_connector_property_get_value(struct drm_connector *connector,
  569. struct drm_property *property,
  570. uint64_t *value);
  571. extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
  572. extern void drm_framebuffer_set_object(struct drm_device *dev,
  573. unsigned long handle);
  574. extern int drm_framebuffer_init(struct drm_device *dev,
  575. struct drm_framebuffer *fb,
  576. const struct drm_framebuffer_funcs *funcs);
  577. extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
  578. extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
  579. extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
  580. extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
  581. extern bool drm_crtc_in_use(struct drm_crtc *crtc);
  582. extern int drm_connector_attach_property(struct drm_connector *connector,
  583. struct drm_property *property, uint64_t init_val);
  584. extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
  585. const char *name, int num_values);
  586. extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
  587. extern int drm_property_add_enum(struct drm_property *property, int index,
  588. uint64_t value, const char *name);
  589. extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  590. extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
  591. char *formats[]);
  592. extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  593. extern int drm_mode_create_dithering_property(struct drm_device *dev);
  594. extern char *drm_get_encoder_name(struct drm_encoder *encoder);
  595. extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
  596. struct drm_encoder *encoder);
  597. extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
  598. struct drm_encoder *encoder);
  599. extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
  600. int gamma_size);
  601. extern void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type);
  602. /* IOCTLs */
  603. extern int drm_mode_getresources(struct drm_device *dev,
  604. void *data, struct drm_file *file_priv);
  605. extern int drm_mode_getcrtc(struct drm_device *dev,
  606. void *data, struct drm_file *file_priv);
  607. extern int drm_mode_getconnector(struct drm_device *dev,
  608. void *data, struct drm_file *file_priv);
  609. extern int drm_mode_setcrtc(struct drm_device *dev,
  610. void *data, struct drm_file *file_priv);
  611. extern int drm_mode_cursor_ioctl(struct drm_device *dev,
  612. void *data, struct drm_file *file_priv);
  613. extern int drm_mode_addfb(struct drm_device *dev,
  614. void *data, struct drm_file *file_priv);
  615. extern int drm_mode_rmfb(struct drm_device *dev,
  616. void *data, struct drm_file *file_priv);
  617. extern int drm_mode_getfb(struct drm_device *dev,
  618. void *data, struct drm_file *file_priv);
  619. extern int drm_mode_addmode_ioctl(struct drm_device *dev,
  620. void *data, struct drm_file *file_priv);
  621. extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
  622. void *data, struct drm_file *file_priv);
  623. extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
  624. void *data, struct drm_file *file_priv);
  625. extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
  626. void *data, struct drm_file *file_priv);
  627. extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
  628. void *data, struct drm_file *file_priv);
  629. extern int drm_mode_getblob_ioctl(struct drm_device *dev,
  630. void *data, struct drm_file *file_priv);
  631. extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
  632. void *data, struct drm_file *file_priv);
  633. extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
  634. void *data, struct drm_file *file_priv);
  635. extern int drm_mode_replacefb(struct drm_device *dev,
  636. void *data, struct drm_file *file_priv);
  637. extern int drm_mode_getencoder(struct drm_device *dev,
  638. void *data, struct drm_file *file_priv);
  639. extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
  640. void *data, struct drm_file *file_priv);
  641. extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
  642. void *data, struct drm_file *file_priv);
  643. extern bool drm_detect_hdmi_monitor(struct edid *edid);
  644. #endif /* __DRM_CRTC_H__ */