drm_mode.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. #define DRM_DISPLAY_INFO_LEN 32
  29. #define DRM_CONNECTOR_NAME_LEN 32
  30. #define DRM_DISPLAY_MODE_LEN 32
  31. #define DRM_PROP_NAME_LEN 32
  32. #define DRM_MODE_TYPE_BUILTIN (1<<0)
  33. #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
  34. #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
  35. #define DRM_MODE_TYPE_PREFERRED (1<<3)
  36. #define DRM_MODE_TYPE_DEFAULT (1<<4)
  37. #define DRM_MODE_TYPE_USERDEF (1<<5)
  38. #define DRM_MODE_TYPE_DRIVER (1<<6)
  39. /* Video mode flags */
  40. /* bit compatible with the xorg definitions. */
  41. #define DRM_MODE_FLAG_PHSYNC (1<<0)
  42. #define DRM_MODE_FLAG_NHSYNC (1<<1)
  43. #define DRM_MODE_FLAG_PVSYNC (1<<2)
  44. #define DRM_MODE_FLAG_NVSYNC (1<<3)
  45. #define DRM_MODE_FLAG_INTERLACE (1<<4)
  46. #define DRM_MODE_FLAG_DBLSCAN (1<<5)
  47. #define DRM_MODE_FLAG_CSYNC (1<<6)
  48. #define DRM_MODE_FLAG_PCSYNC (1<<7)
  49. #define DRM_MODE_FLAG_NCSYNC (1<<8)
  50. #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
  51. #define DRM_MODE_FLAG_BCAST (1<<10)
  52. #define DRM_MODE_FLAG_PIXMUX (1<<11)
  53. #define DRM_MODE_FLAG_DBLCLK (1<<12)
  54. #define DRM_MODE_FLAG_CLKDIV2 (1<<13)
  55. /* DPMS flags */
  56. /* bit compatible with the xorg definitions. */
  57. #define DRM_MODE_DPMS_ON 0
  58. #define DRM_MODE_DPMS_STANDBY 1
  59. #define DRM_MODE_DPMS_SUSPEND 2
  60. #define DRM_MODE_DPMS_OFF 3
  61. /* Scaling mode options */
  62. #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or
  63. software can still scale) */
  64. #define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */
  65. #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
  66. #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
  67. /* Dithering mode options */
  68. #define DRM_MODE_DITHERING_OFF 0
  69. #define DRM_MODE_DITHERING_ON 1
  70. #define DRM_MODE_DITHERING_AUTO 2
  71. /* Dirty info options */
  72. #define DRM_MODE_DIRTY_OFF 0
  73. #define DRM_MODE_DIRTY_ON 1
  74. #define DRM_MODE_DIRTY_ANNOTATE 2
  75. struct drm_mode_modeinfo {
  76. __u32 clock;
  77. __u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
  78. __u16 vdisplay, vsync_start, vsync_end, vtotal, vscan;
  79. __u32 vrefresh;
  80. __u32 flags;
  81. __u32 type;
  82. char name[DRM_DISPLAY_MODE_LEN];
  83. };
  84. struct drm_mode_card_res {
  85. __u64 fb_id_ptr;
  86. __u64 crtc_id_ptr;
  87. __u64 connector_id_ptr;
  88. __u64 encoder_id_ptr;
  89. __u32 count_fbs;
  90. __u32 count_crtcs;
  91. __u32 count_connectors;
  92. __u32 count_encoders;
  93. __u32 min_width, max_width;
  94. __u32 min_height, max_height;
  95. };
  96. struct drm_mode_crtc {
  97. __u64 set_connectors_ptr;
  98. __u32 count_connectors;
  99. __u32 crtc_id; /**< Id */
  100. __u32 fb_id; /**< Id of framebuffer */
  101. __u32 x, y; /**< Position on the frameuffer */
  102. __u32 gamma_size;
  103. __u32 mode_valid;
  104. struct drm_mode_modeinfo mode;
  105. };
  106. #define DRM_MODE_ENCODER_NONE 0
  107. #define DRM_MODE_ENCODER_DAC 1
  108. #define DRM_MODE_ENCODER_TMDS 2
  109. #define DRM_MODE_ENCODER_LVDS 3
  110. #define DRM_MODE_ENCODER_TVDAC 4
  111. struct drm_mode_get_encoder {
  112. __u32 encoder_id;
  113. __u32 encoder_type;
  114. __u32 crtc_id; /**< Id of crtc */
  115. __u32 possible_crtcs;
  116. __u32 possible_clones;
  117. };
  118. /* This is for connectors with multiple signal types. */
  119. /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
  120. #define DRM_MODE_SUBCONNECTOR_Automatic 0
  121. #define DRM_MODE_SUBCONNECTOR_Unknown 0
  122. #define DRM_MODE_SUBCONNECTOR_DVID 3
  123. #define DRM_MODE_SUBCONNECTOR_DVIA 4
  124. #define DRM_MODE_SUBCONNECTOR_Composite 5
  125. #define DRM_MODE_SUBCONNECTOR_SVIDEO 6
  126. #define DRM_MODE_SUBCONNECTOR_Component 8
  127. #define DRM_MODE_SUBCONNECTOR_SCART 9
  128. #define DRM_MODE_CONNECTOR_Unknown 0
  129. #define DRM_MODE_CONNECTOR_VGA 1
  130. #define DRM_MODE_CONNECTOR_DVII 2
  131. #define DRM_MODE_CONNECTOR_DVID 3
  132. #define DRM_MODE_CONNECTOR_DVIA 4
  133. #define DRM_MODE_CONNECTOR_Composite 5
  134. #define DRM_MODE_CONNECTOR_SVIDEO 6
  135. #define DRM_MODE_CONNECTOR_LVDS 7
  136. #define DRM_MODE_CONNECTOR_Component 8
  137. #define DRM_MODE_CONNECTOR_9PinDIN 9
  138. #define DRM_MODE_CONNECTOR_DisplayPort 10
  139. #define DRM_MODE_CONNECTOR_HDMIA 11
  140. #define DRM_MODE_CONNECTOR_HDMIB 12
  141. #define DRM_MODE_CONNECTOR_TV 13
  142. #define DRM_MODE_CONNECTOR_eDP 14
  143. struct drm_mode_get_connector {
  144. __u64 encoders_ptr;
  145. __u64 modes_ptr;
  146. __u64 props_ptr;
  147. __u64 prop_values_ptr;
  148. __u32 count_modes;
  149. __u32 count_props;
  150. __u32 count_encoders;
  151. __u32 encoder_id; /**< Current Encoder */
  152. __u32 connector_id; /**< Id */
  153. __u32 connector_type;
  154. __u32 connector_type_id;
  155. __u32 connection;
  156. __u32 mm_width, mm_height; /**< HxW in millimeters */
  157. __u32 subpixel;
  158. };
  159. #define DRM_MODE_PROP_PENDING (1<<0)
  160. #define DRM_MODE_PROP_RANGE (1<<1)
  161. #define DRM_MODE_PROP_IMMUTABLE (1<<2)
  162. #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
  163. #define DRM_MODE_PROP_BLOB (1<<4)
  164. struct drm_mode_property_enum {
  165. __u64 value;
  166. char name[DRM_PROP_NAME_LEN];
  167. };
  168. struct drm_mode_get_property {
  169. __u64 values_ptr; /* values and blob lengths */
  170. __u64 enum_blob_ptr; /* enum and blob id ptrs */
  171. __u32 prop_id;
  172. __u32 flags;
  173. char name[DRM_PROP_NAME_LEN];
  174. __u32 count_values;
  175. __u32 count_enum_blobs;
  176. };
  177. struct drm_mode_connector_set_property {
  178. __u64 value;
  179. __u32 prop_id;
  180. __u32 connector_id;
  181. };
  182. struct drm_mode_get_blob {
  183. __u32 blob_id;
  184. __u32 length;
  185. __u64 data;
  186. };
  187. struct drm_mode_fb_cmd {
  188. __u32 fb_id;
  189. __u32 width, height;
  190. __u32 pitch;
  191. __u32 bpp;
  192. __u32 depth;
  193. /* driver specific handle */
  194. __u32 handle;
  195. };
  196. #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
  197. #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
  198. #define DRM_MODE_FB_DIRTY_FLAGS 0x03
  199. #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
  200. /*
  201. * Mark a region of a framebuffer as dirty.
  202. *
  203. * Some hardware does not automatically update display contents
  204. * as a hardware or software draw to a framebuffer. This ioctl
  205. * allows userspace to tell the kernel and the hardware what
  206. * regions of the framebuffer have changed.
  207. *
  208. * The kernel or hardware is free to update more then just the
  209. * region specified by the clip rects. The kernel or hardware
  210. * may also delay and/or coalesce several calls to dirty into a
  211. * single update.
  212. *
  213. * Userspace may annotate the updates, the annotates are a
  214. * promise made by the caller that the change is either a copy
  215. * of pixels or a fill of a single color in the region specified.
  216. *
  217. * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
  218. * the number of updated regions are half of num_clips given,
  219. * where the clip rects are paired in src and dst. The width and
  220. * height of each one of the pairs must match.
  221. *
  222. * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
  223. * promises that the region specified of the clip rects is filled
  224. * completely with a single color as given in the color argument.
  225. */
  226. struct drm_mode_fb_dirty_cmd {
  227. __u32 fb_id;
  228. __u32 flags;
  229. __u32 color;
  230. __u32 num_clips;
  231. __u64 clips_ptr;
  232. };
  233. struct drm_mode_mode_cmd {
  234. __u32 connector_id;
  235. struct drm_mode_modeinfo mode;
  236. };
  237. #define DRM_MODE_CURSOR_BO (1<<0)
  238. #define DRM_MODE_CURSOR_MOVE (1<<1)
  239. /*
  240. * depending on the value in flags different members are used.
  241. *
  242. * CURSOR_BO uses
  243. * crtc
  244. * width
  245. * height
  246. * handle - if 0 turns the cursor of
  247. *
  248. * CURSOR_MOVE uses
  249. * crtc
  250. * x
  251. * y
  252. */
  253. struct drm_mode_cursor {
  254. __u32 flags;
  255. __u32 crtc_id;
  256. __s32 x;
  257. __s32 y;
  258. __u32 width;
  259. __u32 height;
  260. /* driver specific handle */
  261. __u32 handle;
  262. };
  263. struct drm_mode_crtc_lut {
  264. __u32 crtc_id;
  265. __u32 gamma_size;
  266. /* pointers to arrays */
  267. __u64 red;
  268. __u64 green;
  269. __u64 blue;
  270. };
  271. #define DRM_MODE_PAGE_FLIP_EVENT 0x01
  272. #define DRM_MODE_PAGE_FLIP_FLAGS DRM_MODE_PAGE_FLIP_EVENT
  273. /*
  274. * Request a page flip on the specified crtc.
  275. *
  276. * This ioctl will ask KMS to schedule a page flip for the specified
  277. * crtc. Once any pending rendering targeting the specified fb (as of
  278. * ioctl time) has completed, the crtc will be reprogrammed to display
  279. * that fb after the next vertical refresh. The ioctl returns
  280. * immediately, but subsequent rendering to the current fb will block
  281. * in the execbuffer ioctl until the page flip happens. If a page
  282. * flip is already pending as the ioctl is called, EBUSY will be
  283. * returned.
  284. *
  285. * The ioctl supports one flag, DRM_MODE_PAGE_FLIP_EVENT, which will
  286. * request that drm sends back a vblank event (see drm.h: struct
  287. * drm_event_vblank) when the page flip is done. The user_data field
  288. * passed in with this ioctl will be returned as the user_data field
  289. * in the vblank event struct.
  290. *
  291. * The reserved field must be zero until we figure out something
  292. * clever to use it for.
  293. */
  294. struct drm_mode_crtc_page_flip {
  295. __u32 crtc_id;
  296. __u32 fb_id;
  297. __u32 flags;
  298. __u32 reserved;
  299. __u64 user_data;
  300. };
  301. /* create a dumb scanout buffer */
  302. struct drm_mode_create_dumb {
  303. uint32_t height;
  304. uint32_t width;
  305. uint32_t bpp;
  306. uint32_t flags;
  307. /* handle, pitch, size will be returned */
  308. uint32_t handle;
  309. uint32_t pitch;
  310. uint64_t size;
  311. };
  312. /* set up for mmap of a dumb scanout buffer */
  313. struct drm_mode_map_dumb {
  314. /** Handle for the object being mapped. */
  315. __u32 handle;
  316. __u32 pad;
  317. /**
  318. * Fake offset to use for subsequent mmap call
  319. *
  320. * This is a fixed-size type for 32/64 compatibility.
  321. */
  322. __u64 offset;
  323. };
  324. struct drm_mode_destroy_dumb {
  325. uint32_t handle;
  326. };
  327. #endif