drm_mode.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
  3. * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com>
  4. * Copyright (c) 2008 Red Hat Inc.
  5. * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
  6. * Copyright (c) 2007-2008 Intel Corporation
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  24. * IN THE SOFTWARE.
  25. */
  26. #ifndef _DRM_MODE_H
  27. #define _DRM_MODE_H
  28. #include <linux/types.h>
  29. #define DRM_DISPLAY_INFO_LEN 32
  30. #define DRM_CONNECTOR_NAME_LEN 32
  31. #define DRM_DISPLAY_MODE_LEN 32
  32. #define DRM_PROP_NAME_LEN 32
  33. #define DRM_MODE_TYPE_BUILTIN (1<<0)
  34. #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
  35. #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
  36. #define DRM_MODE_TYPE_PREFERRED (1<<3)
  37. #define DRM_MODE_TYPE_DEFAULT (1<<4)
  38. #define DRM_MODE_TYPE_USERDEF (1<<5)
  39. #define DRM_MODE_TYPE_DRIVER (1<<6)
  40. /* Video mode flags */
  41. /* bit compatible with the xorg definitions. */
  42. #define DRM_MODE_FLAG_PHSYNC (1<<0)
  43. #define DRM_MODE_FLAG_NHSYNC (1<<1)
  44. #define DRM_MODE_FLAG_PVSYNC (1<<2)
  45. #define DRM_MODE_FLAG_NVSYNC (1<<3)
  46. #define DRM_MODE_FLAG_INTERLACE (1<<4)
  47. #define DRM_MODE_FLAG_DBLSCAN (1<<5)
  48. #define DRM_MODE_FLAG_CSYNC (1<<6)
  49. #define DRM_MODE_FLAG_PCSYNC (1<<7)
  50. #define DRM_MODE_FLAG_NCSYNC (1<<8)
  51. #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
  52. #define DRM_MODE_FLAG_BCAST (1<<10)
  53. #define DRM_MODE_FLAG_PIXMUX (1<<11)
  54. #define DRM_MODE_FLAG_DBLCLK (1<<12)
  55. #define DRM_MODE_FLAG_CLKDIV2 (1<<13)
  56. #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
  57. #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (1<<15)
  58. #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (1<<16)
  59. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (1<<17)
  60. #define DRM_MODE_FLAG_3D_L_DEPTH (1<<18)
  61. #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (1<<19)
  62. #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (1<<20)
  63. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (1<<21)
  64. /* DPMS flags */
  65. /* bit compatible with the xorg definitions. */
  66. #define DRM_MODE_DPMS_ON 0
  67. #define DRM_MODE_DPMS_STANDBY 1
  68. #define DRM_MODE_DPMS_SUSPEND 2
  69. #define DRM_MODE_DPMS_OFF 3
  70. /* Scaling mode options */
  71. #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or
  72. software can still scale) */
  73. #define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */
  74. #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
  75. #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
  76. /* Dithering mode options */
  77. #define DRM_MODE_DITHERING_OFF 0
  78. #define DRM_MODE_DITHERING_ON 1
  79. #define DRM_MODE_DITHERING_AUTO 2
  80. /* Dirty info options */
  81. #define DRM_MODE_DIRTY_OFF 0
  82. #define DRM_MODE_DIRTY_ON 1
  83. #define DRM_MODE_DIRTY_ANNOTATE 2
  84. struct drm_mode_modeinfo {
  85. __u32 clock;
  86. __u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
  87. __u16 vdisplay, vsync_start, vsync_end, vtotal, vscan;
  88. __u32 vrefresh;
  89. __u32 flags;
  90. __u32 type;
  91. char name[DRM_DISPLAY_MODE_LEN];
  92. };
  93. struct drm_mode_card_res {
  94. __u64 fb_id_ptr;
  95. __u64 crtc_id_ptr;
  96. __u64 connector_id_ptr;
  97. __u64 encoder_id_ptr;
  98. __u32 count_fbs;
  99. __u32 count_crtcs;
  100. __u32 count_connectors;
  101. __u32 count_encoders;
  102. __u32 min_width, max_width;
  103. __u32 min_height, max_height;
  104. };
  105. struct drm_mode_crtc {
  106. __u64 set_connectors_ptr;
  107. __u32 count_connectors;
  108. __u32 crtc_id; /**< Id */
  109. __u32 fb_id; /**< Id of framebuffer */
  110. __u32 x, y; /**< Position on the frameuffer */
  111. __u32 gamma_size;
  112. __u32 mode_valid;
  113. struct drm_mode_modeinfo mode;
  114. };
  115. #define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
  116. #define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
  117. /* Planes blend with or override other bits on the CRTC */
  118. struct drm_mode_set_plane {
  119. __u32 plane_id;
  120. __u32 crtc_id;
  121. __u32 fb_id; /* fb object contains surface format type */
  122. __u32 flags; /* see above flags */
  123. /* Signed dest location allows it to be partially off screen */
  124. __s32 crtc_x, crtc_y;
  125. __u32 crtc_w, crtc_h;
  126. /* Source values are 16.16 fixed point */
  127. __u32 src_x, src_y;
  128. __u32 src_h, src_w;
  129. };
  130. struct drm_mode_get_plane {
  131. __u32 plane_id;
  132. __u32 crtc_id;
  133. __u32 fb_id;
  134. __u32 possible_crtcs;
  135. __u32 gamma_size;
  136. __u32 count_format_types;
  137. __u64 format_type_ptr;
  138. };
  139. struct drm_mode_get_plane_res {
  140. __u64 plane_id_ptr;
  141. __u32 count_planes;
  142. };
  143. #define DRM_MODE_ENCODER_NONE 0
  144. #define DRM_MODE_ENCODER_DAC 1
  145. #define DRM_MODE_ENCODER_TMDS 2
  146. #define DRM_MODE_ENCODER_LVDS 3
  147. #define DRM_MODE_ENCODER_TVDAC 4
  148. #define DRM_MODE_ENCODER_VIRTUAL 5
  149. #define DRM_MODE_ENCODER_DSI 6
  150. struct drm_mode_get_encoder {
  151. __u32 encoder_id;
  152. __u32 encoder_type;
  153. __u32 crtc_id; /**< Id of crtc */
  154. __u32 possible_crtcs;
  155. __u32 possible_clones;
  156. };
  157. /* This is for connectors with multiple signal types. */
  158. /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
  159. #define DRM_MODE_SUBCONNECTOR_Automatic 0
  160. #define DRM_MODE_SUBCONNECTOR_Unknown 0
  161. #define DRM_MODE_SUBCONNECTOR_DVID 3
  162. #define DRM_MODE_SUBCONNECTOR_DVIA 4
  163. #define DRM_MODE_SUBCONNECTOR_Composite 5
  164. #define DRM_MODE_SUBCONNECTOR_SVIDEO 6
  165. #define DRM_MODE_SUBCONNECTOR_Component 8
  166. #define DRM_MODE_SUBCONNECTOR_SCART 9
  167. #define DRM_MODE_CONNECTOR_Unknown 0
  168. #define DRM_MODE_CONNECTOR_VGA 1
  169. #define DRM_MODE_CONNECTOR_DVII 2
  170. #define DRM_MODE_CONNECTOR_DVID 3
  171. #define DRM_MODE_CONNECTOR_DVIA 4
  172. #define DRM_MODE_CONNECTOR_Composite 5
  173. #define DRM_MODE_CONNECTOR_SVIDEO 6
  174. #define DRM_MODE_CONNECTOR_LVDS 7
  175. #define DRM_MODE_CONNECTOR_Component 8
  176. #define DRM_MODE_CONNECTOR_9PinDIN 9
  177. #define DRM_MODE_CONNECTOR_DisplayPort 10
  178. #define DRM_MODE_CONNECTOR_HDMIA 11
  179. #define DRM_MODE_CONNECTOR_HDMIB 12
  180. #define DRM_MODE_CONNECTOR_TV 13
  181. #define DRM_MODE_CONNECTOR_eDP 14
  182. #define DRM_MODE_CONNECTOR_VIRTUAL 15
  183. #define DRM_MODE_CONNECTOR_DSI 16
  184. struct drm_mode_get_connector {
  185. __u64 encoders_ptr;
  186. __u64 modes_ptr;
  187. __u64 props_ptr;
  188. __u64 prop_values_ptr;
  189. __u32 count_modes;
  190. __u32 count_props;
  191. __u32 count_encoders;
  192. __u32 encoder_id; /**< Current Encoder */
  193. __u32 connector_id; /**< Id */
  194. __u32 connector_type;
  195. __u32 connector_type_id;
  196. __u32 connection;
  197. __u32 mm_width, mm_height; /**< HxW in millimeters */
  198. __u32 subpixel;
  199. };
  200. #define DRM_MODE_PROP_PENDING (1<<0)
  201. #define DRM_MODE_PROP_RANGE (1<<1)
  202. #define DRM_MODE_PROP_IMMUTABLE (1<<2)
  203. #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
  204. #define DRM_MODE_PROP_BLOB (1<<4)
  205. #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
  206. struct drm_mode_property_enum {
  207. __u64 value;
  208. char name[DRM_PROP_NAME_LEN];
  209. };
  210. struct drm_mode_get_property {
  211. __u64 values_ptr; /* values and blob lengths */
  212. __u64 enum_blob_ptr; /* enum and blob id ptrs */
  213. __u32 prop_id;
  214. __u32 flags;
  215. char name[DRM_PROP_NAME_LEN];
  216. __u32 count_values;
  217. __u32 count_enum_blobs;
  218. };
  219. struct drm_mode_connector_set_property {
  220. __u64 value;
  221. __u32 prop_id;
  222. __u32 connector_id;
  223. };
  224. struct drm_mode_obj_get_properties {
  225. __u64 props_ptr;
  226. __u64 prop_values_ptr;
  227. __u32 count_props;
  228. __u32 obj_id;
  229. __u32 obj_type;
  230. };
  231. struct drm_mode_obj_set_property {
  232. __u64 value;
  233. __u32 prop_id;
  234. __u32 obj_id;
  235. __u32 obj_type;
  236. };
  237. struct drm_mode_get_blob {
  238. __u32 blob_id;
  239. __u32 length;
  240. __u64 data;
  241. };
  242. struct drm_mode_fb_cmd {
  243. __u32 fb_id;
  244. __u32 width, height;
  245. __u32 pitch;
  246. __u32 bpp;
  247. __u32 depth;
  248. /* driver specific handle */
  249. __u32 handle;
  250. };
  251. #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
  252. struct drm_mode_fb_cmd2 {
  253. __u32 fb_id;
  254. __u32 width, height;
  255. __u32 pixel_format; /* fourcc code from drm_fourcc.h */
  256. __u32 flags; /* see above flags */
  257. /*
  258. * In case of planar formats, this ioctl allows up to 4
  259. * buffer objects with offets and pitches per plane.
  260. * The pitch and offset order is dictated by the fourcc,
  261. * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
  262. *
  263. * YUV 4:2:0 image with a plane of 8 bit Y samples
  264. * followed by an interleaved U/V plane containing
  265. * 8 bit 2x2 subsampled colour difference samples.
  266. *
  267. * So it would consist of Y as offset[0] and UV as
  268. * offeset[1]. Note that offset[0] will generally
  269. * be 0.
  270. */
  271. __u32 handles[4];
  272. __u32 pitches[4]; /* pitch for each plane */
  273. __u32 offsets[4]; /* offset of each plane */
  274. };
  275. #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
  276. #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
  277. #define DRM_MODE_FB_DIRTY_FLAGS 0x03
  278. #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
  279. /*
  280. * Mark a region of a framebuffer as dirty.
  281. *
  282. * Some hardware does not automatically update display contents
  283. * as a hardware or software draw to a framebuffer. This ioctl
  284. * allows userspace to tell the kernel and the hardware what
  285. * regions of the framebuffer have changed.
  286. *
  287. * The kernel or hardware is free to update more then just the
  288. * region specified by the clip rects. The kernel or hardware
  289. * may also delay and/or coalesce several calls to dirty into a
  290. * single update.
  291. *
  292. * Userspace may annotate the updates, the annotates are a
  293. * promise made by the caller that the change is either a copy
  294. * of pixels or a fill of a single color in the region specified.
  295. *
  296. * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
  297. * the number of updated regions are half of num_clips given,
  298. * where the clip rects are paired in src and dst. The width and
  299. * height of each one of the pairs must match.
  300. *
  301. * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
  302. * promises that the region specified of the clip rects is filled
  303. * completely with a single color as given in the color argument.
  304. */
  305. struct drm_mode_fb_dirty_cmd {
  306. __u32 fb_id;
  307. __u32 flags;
  308. __u32 color;
  309. __u32 num_clips;
  310. __u64 clips_ptr;
  311. };
  312. struct drm_mode_mode_cmd {
  313. __u32 connector_id;
  314. struct drm_mode_modeinfo mode;
  315. };
  316. #define DRM_MODE_CURSOR_BO 0x01
  317. #define DRM_MODE_CURSOR_MOVE 0x02
  318. #define DRM_MODE_CURSOR_FLAGS 0x03
  319. /*
  320. * depending on the value in flags different members are used.
  321. *
  322. * CURSOR_BO uses
  323. * crtc_id
  324. * width
  325. * height
  326. * handle - if 0 turns the cursor off
  327. *
  328. * CURSOR_MOVE uses
  329. * crtc_id
  330. * x
  331. * y
  332. */
  333. struct drm_mode_cursor {
  334. __u32 flags;
  335. __u32 crtc_id;
  336. __s32 x;
  337. __s32 y;
  338. __u32 width;
  339. __u32 height;
  340. /* driver specific handle */
  341. __u32 handle;
  342. };
  343. struct drm_mode_cursor2 {
  344. __u32 flags;
  345. __u32 crtc_id;
  346. __s32 x;
  347. __s32 y;
  348. __u32 width;
  349. __u32 height;
  350. /* driver specific handle */
  351. __u32 handle;
  352. __s32 hot_x;
  353. __s32 hot_y;
  354. };
  355. struct drm_mode_crtc_lut {
  356. __u32 crtc_id;
  357. __u32 gamma_size;
  358. /* pointers to arrays */
  359. __u64 red;
  360. __u64 green;
  361. __u64 blue;
  362. };
  363. #define DRM_MODE_PAGE_FLIP_EVENT 0x01
  364. #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
  365. #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC)
  366. /*
  367. * Request a page flip on the specified crtc.
  368. *
  369. * This ioctl will ask KMS to schedule a page flip for the specified
  370. * crtc. Once any pending rendering targeting the specified fb (as of
  371. * ioctl time) has completed, the crtc will be reprogrammed to display
  372. * that fb after the next vertical refresh. The ioctl returns
  373. * immediately, but subsequent rendering to the current fb will block
  374. * in the execbuffer ioctl until the page flip happens. If a page
  375. * flip is already pending as the ioctl is called, EBUSY will be
  376. * returned.
  377. *
  378. * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
  379. * event (see drm.h: struct drm_event_vblank) when the page flip is
  380. * done. The user_data field passed in with this ioctl will be
  381. * returned as the user_data field in the vblank event struct.
  382. *
  383. * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
  384. * 'as soon as possible', meaning that it not delay waiting for vblank.
  385. * This may cause tearing on the screen.
  386. *
  387. * The reserved field must be zero until we figure out something
  388. * clever to use it for.
  389. */
  390. struct drm_mode_crtc_page_flip {
  391. __u32 crtc_id;
  392. __u32 fb_id;
  393. __u32 flags;
  394. __u32 reserved;
  395. __u64 user_data;
  396. };
  397. /* create a dumb scanout buffer */
  398. struct drm_mode_create_dumb {
  399. uint32_t height;
  400. uint32_t width;
  401. uint32_t bpp;
  402. uint32_t flags;
  403. /* handle, pitch, size will be returned */
  404. uint32_t handle;
  405. uint32_t pitch;
  406. uint64_t size;
  407. };
  408. /* set up for mmap of a dumb scanout buffer */
  409. struct drm_mode_map_dumb {
  410. /** Handle for the object being mapped. */
  411. __u32 handle;
  412. __u32 pad;
  413. /**
  414. * Fake offset to use for subsequent mmap call
  415. *
  416. * This is a fixed-size type for 32/64 compatibility.
  417. */
  418. __u64 offset;
  419. };
  420. struct drm_mode_destroy_dumb {
  421. uint32_t handle;
  422. };
  423. #endif