drm_mode.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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 "drm.h"
  29. #if defined(__cplusplus)
  30. extern "C" {
  31. #endif
  32. #define DRM_DISPLAY_INFO_LEN 32
  33. #define DRM_CONNECTOR_NAME_LEN 32
  34. #define DRM_DISPLAY_MODE_LEN 32
  35. #define DRM_PROP_NAME_LEN 32
  36. #define DRM_MODE_TYPE_BUILTIN (1<<0) /* deprecated */
  37. #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
  38. #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
  39. #define DRM_MODE_TYPE_PREFERRED (1<<3)
  40. #define DRM_MODE_TYPE_DEFAULT (1<<4) /* deprecated */
  41. #define DRM_MODE_TYPE_USERDEF (1<<5)
  42. #define DRM_MODE_TYPE_DRIVER (1<<6)
  43. #define DRM_MODE_TYPE_ALL (DRM_MODE_TYPE_PREFERRED | \
  44. DRM_MODE_TYPE_USERDEF | \
  45. DRM_MODE_TYPE_DRIVER)
  46. /* Video mode flags */
  47. /* bit compatible with the xrandr RR_ definitions (bits 0-13)
  48. *
  49. * ABI warning: Existing userspace really expects
  50. * the mode flags to match the xrandr definitions. Any
  51. * changes that don't match the xrandr definitions will
  52. * likely need a new client cap or some other mechanism
  53. * to avoid breaking existing userspace. This includes
  54. * allocating new flags in the previously unused bits!
  55. */
  56. #define DRM_MODE_FLAG_PHSYNC (1<<0)
  57. #define DRM_MODE_FLAG_NHSYNC (1<<1)
  58. #define DRM_MODE_FLAG_PVSYNC (1<<2)
  59. #define DRM_MODE_FLAG_NVSYNC (1<<3)
  60. #define DRM_MODE_FLAG_INTERLACE (1<<4)
  61. #define DRM_MODE_FLAG_DBLSCAN (1<<5)
  62. #define DRM_MODE_FLAG_CSYNC (1<<6)
  63. #define DRM_MODE_FLAG_PCSYNC (1<<7)
  64. #define DRM_MODE_FLAG_NCSYNC (1<<8)
  65. #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
  66. #define DRM_MODE_FLAG_BCAST (1<<10) /* deprecated */
  67. #define DRM_MODE_FLAG_PIXMUX (1<<11) /* deprecated */
  68. #define DRM_MODE_FLAG_DBLCLK (1<<12)
  69. #define DRM_MODE_FLAG_CLKDIV2 (1<<13)
  70. /*
  71. * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
  72. * (define not exposed to user space).
  73. */
  74. #define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
  75. #define DRM_MODE_FLAG_3D_NONE (0<<14)
  76. #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
  77. #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14)
  78. #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14)
  79. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14)
  80. #define DRM_MODE_FLAG_3D_L_DEPTH (5<<14)
  81. #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14)
  82. #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14)
  83. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14)
  84. /* Picture aspect ratio options */
  85. #define DRM_MODE_PICTURE_ASPECT_NONE 0
  86. #define DRM_MODE_PICTURE_ASPECT_4_3 1
  87. #define DRM_MODE_PICTURE_ASPECT_16_9 2
  88. #define DRM_MODE_PICTURE_ASPECT_64_27 3
  89. #define DRM_MODE_PICTURE_ASPECT_256_135 4
  90. /* Content type options */
  91. #define DRM_MODE_CONTENT_TYPE_NO_DATA 0
  92. #define DRM_MODE_CONTENT_TYPE_GRAPHICS 1
  93. #define DRM_MODE_CONTENT_TYPE_PHOTO 2
  94. #define DRM_MODE_CONTENT_TYPE_CINEMA 3
  95. #define DRM_MODE_CONTENT_TYPE_GAME 4
  96. /* Aspect ratio flag bitmask (4 bits 22:19) */
  97. #define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
  98. #define DRM_MODE_FLAG_PIC_AR_NONE \
  99. (DRM_MODE_PICTURE_ASPECT_NONE<<19)
  100. #define DRM_MODE_FLAG_PIC_AR_4_3 \
  101. (DRM_MODE_PICTURE_ASPECT_4_3<<19)
  102. #define DRM_MODE_FLAG_PIC_AR_16_9 \
  103. (DRM_MODE_PICTURE_ASPECT_16_9<<19)
  104. #define DRM_MODE_FLAG_PIC_AR_64_27 \
  105. (DRM_MODE_PICTURE_ASPECT_64_27<<19)
  106. #define DRM_MODE_FLAG_PIC_AR_256_135 \
  107. (DRM_MODE_PICTURE_ASPECT_256_135<<19)
  108. #define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \
  109. DRM_MODE_FLAG_NHSYNC | \
  110. DRM_MODE_FLAG_PVSYNC | \
  111. DRM_MODE_FLAG_NVSYNC | \
  112. DRM_MODE_FLAG_INTERLACE | \
  113. DRM_MODE_FLAG_DBLSCAN | \
  114. DRM_MODE_FLAG_CSYNC | \
  115. DRM_MODE_FLAG_PCSYNC | \
  116. DRM_MODE_FLAG_NCSYNC | \
  117. DRM_MODE_FLAG_HSKEW | \
  118. DRM_MODE_FLAG_DBLCLK | \
  119. DRM_MODE_FLAG_CLKDIV2 | \
  120. DRM_MODE_FLAG_3D_MASK)
  121. /* DPMS flags */
  122. /* bit compatible with the xorg definitions. */
  123. #define DRM_MODE_DPMS_ON 0
  124. #define DRM_MODE_DPMS_STANDBY 1
  125. #define DRM_MODE_DPMS_SUSPEND 2
  126. #define DRM_MODE_DPMS_OFF 3
  127. /* Scaling mode options */
  128. #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or
  129. software can still scale) */
  130. #define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */
  131. #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
  132. #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
  133. /* Dithering mode options */
  134. #define DRM_MODE_DITHERING_OFF 0
  135. #define DRM_MODE_DITHERING_ON 1
  136. #define DRM_MODE_DITHERING_AUTO 2
  137. /* Dirty info options */
  138. #define DRM_MODE_DIRTY_OFF 0
  139. #define DRM_MODE_DIRTY_ON 1
  140. #define DRM_MODE_DIRTY_ANNOTATE 2
  141. /* Link Status options */
  142. #define DRM_MODE_LINK_STATUS_GOOD 0
  143. #define DRM_MODE_LINK_STATUS_BAD 1
  144. /*
  145. * DRM_MODE_ROTATE_<degrees>
  146. *
  147. * Signals that a drm plane is been rotated <degrees> degrees in counter
  148. * clockwise direction.
  149. *
  150. * This define is provided as a convenience, looking up the property id
  151. * using the name->prop id lookup is the preferred method.
  152. */
  153. #define DRM_MODE_ROTATE_0 (1<<0)
  154. #define DRM_MODE_ROTATE_90 (1<<1)
  155. #define DRM_MODE_ROTATE_180 (1<<2)
  156. #define DRM_MODE_ROTATE_270 (1<<3)
  157. /*
  158. * DRM_MODE_ROTATE_MASK
  159. *
  160. * Bitmask used to look for drm plane rotations.
  161. */
  162. #define DRM_MODE_ROTATE_MASK (\
  163. DRM_MODE_ROTATE_0 | \
  164. DRM_MODE_ROTATE_90 | \
  165. DRM_MODE_ROTATE_180 | \
  166. DRM_MODE_ROTATE_270)
  167. /*
  168. * DRM_MODE_REFLECT_<axis>
  169. *
  170. * Signals that the contents of a drm plane is reflected along the <axis> axis,
  171. * in the same way as mirroring.
  172. * See kerneldoc chapter "Plane Composition Properties" for more details.
  173. *
  174. * This define is provided as a convenience, looking up the property id
  175. * using the name->prop id lookup is the preferred method.
  176. */
  177. #define DRM_MODE_REFLECT_X (1<<4)
  178. #define DRM_MODE_REFLECT_Y (1<<5)
  179. /*
  180. * DRM_MODE_REFLECT_MASK
  181. *
  182. * Bitmask used to look for drm plane reflections.
  183. */
  184. #define DRM_MODE_REFLECT_MASK (\
  185. DRM_MODE_REFLECT_X | \
  186. DRM_MODE_REFLECT_Y)
  187. /* Content Protection Flags */
  188. #define DRM_MODE_CONTENT_PROTECTION_UNDESIRED 0
  189. #define DRM_MODE_CONTENT_PROTECTION_DESIRED 1
  190. #define DRM_MODE_CONTENT_PROTECTION_ENABLED 2
  191. struct drm_mode_modeinfo {
  192. __u32 clock;
  193. __u16 hdisplay;
  194. __u16 hsync_start;
  195. __u16 hsync_end;
  196. __u16 htotal;
  197. __u16 hskew;
  198. __u16 vdisplay;
  199. __u16 vsync_start;
  200. __u16 vsync_end;
  201. __u16 vtotal;
  202. __u16 vscan;
  203. __u32 vrefresh;
  204. __u32 flags;
  205. __u32 type;
  206. char name[DRM_DISPLAY_MODE_LEN];
  207. };
  208. struct drm_mode_card_res {
  209. __u64 fb_id_ptr;
  210. __u64 crtc_id_ptr;
  211. __u64 connector_id_ptr;
  212. __u64 encoder_id_ptr;
  213. __u32 count_fbs;
  214. __u32 count_crtcs;
  215. __u32 count_connectors;
  216. __u32 count_encoders;
  217. __u32 min_width;
  218. __u32 max_width;
  219. __u32 min_height;
  220. __u32 max_height;
  221. };
  222. struct drm_mode_crtc {
  223. __u64 set_connectors_ptr;
  224. __u32 count_connectors;
  225. __u32 crtc_id; /**< Id */
  226. __u32 fb_id; /**< Id of framebuffer */
  227. __u32 x; /**< x Position on the framebuffer */
  228. __u32 y; /**< y Position on the framebuffer */
  229. __u32 gamma_size;
  230. __u32 mode_valid;
  231. struct drm_mode_modeinfo mode;
  232. };
  233. #define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
  234. #define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
  235. /* Planes blend with or override other bits on the CRTC */
  236. struct drm_mode_set_plane {
  237. __u32 plane_id;
  238. __u32 crtc_id;
  239. __u32 fb_id; /* fb object contains surface format type */
  240. __u32 flags; /* see above flags */
  241. /* Signed dest location allows it to be partially off screen */
  242. __s32 crtc_x;
  243. __s32 crtc_y;
  244. __u32 crtc_w;
  245. __u32 crtc_h;
  246. /* Source values are 16.16 fixed point */
  247. __u32 src_x;
  248. __u32 src_y;
  249. __u32 src_h;
  250. __u32 src_w;
  251. };
  252. struct drm_mode_get_plane {
  253. __u32 plane_id;
  254. __u32 crtc_id;
  255. __u32 fb_id;
  256. __u32 possible_crtcs;
  257. __u32 gamma_size;
  258. __u32 count_format_types;
  259. __u64 format_type_ptr;
  260. };
  261. struct drm_mode_get_plane_res {
  262. __u64 plane_id_ptr;
  263. __u32 count_planes;
  264. };
  265. #define DRM_MODE_ENCODER_NONE 0
  266. #define DRM_MODE_ENCODER_DAC 1
  267. #define DRM_MODE_ENCODER_TMDS 2
  268. #define DRM_MODE_ENCODER_LVDS 3
  269. #define DRM_MODE_ENCODER_TVDAC 4
  270. #define DRM_MODE_ENCODER_VIRTUAL 5
  271. #define DRM_MODE_ENCODER_DSI 6
  272. #define DRM_MODE_ENCODER_DPMST 7
  273. #define DRM_MODE_ENCODER_DPI 8
  274. struct drm_mode_get_encoder {
  275. __u32 encoder_id;
  276. __u32 encoder_type;
  277. __u32 crtc_id; /**< Id of crtc */
  278. __u32 possible_crtcs;
  279. __u32 possible_clones;
  280. };
  281. /* This is for connectors with multiple signal types. */
  282. /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
  283. enum drm_mode_subconnector {
  284. DRM_MODE_SUBCONNECTOR_Automatic = 0,
  285. DRM_MODE_SUBCONNECTOR_Unknown = 0,
  286. DRM_MODE_SUBCONNECTOR_DVID = 3,
  287. DRM_MODE_SUBCONNECTOR_DVIA = 4,
  288. DRM_MODE_SUBCONNECTOR_Composite = 5,
  289. DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
  290. DRM_MODE_SUBCONNECTOR_Component = 8,
  291. DRM_MODE_SUBCONNECTOR_SCART = 9,
  292. };
  293. #define DRM_MODE_CONNECTOR_Unknown 0
  294. #define DRM_MODE_CONNECTOR_VGA 1
  295. #define DRM_MODE_CONNECTOR_DVII 2
  296. #define DRM_MODE_CONNECTOR_DVID 3
  297. #define DRM_MODE_CONNECTOR_DVIA 4
  298. #define DRM_MODE_CONNECTOR_Composite 5
  299. #define DRM_MODE_CONNECTOR_SVIDEO 6
  300. #define DRM_MODE_CONNECTOR_LVDS 7
  301. #define DRM_MODE_CONNECTOR_Component 8
  302. #define DRM_MODE_CONNECTOR_9PinDIN 9
  303. #define DRM_MODE_CONNECTOR_DisplayPort 10
  304. #define DRM_MODE_CONNECTOR_HDMIA 11
  305. #define DRM_MODE_CONNECTOR_HDMIB 12
  306. #define DRM_MODE_CONNECTOR_TV 13
  307. #define DRM_MODE_CONNECTOR_eDP 14
  308. #define DRM_MODE_CONNECTOR_VIRTUAL 15
  309. #define DRM_MODE_CONNECTOR_DSI 16
  310. #define DRM_MODE_CONNECTOR_DPI 17
  311. #define DRM_MODE_CONNECTOR_WRITEBACK 18
  312. struct drm_mode_get_connector {
  313. __u64 encoders_ptr;
  314. __u64 modes_ptr;
  315. __u64 props_ptr;
  316. __u64 prop_values_ptr;
  317. __u32 count_modes;
  318. __u32 count_props;
  319. __u32 count_encoders;
  320. __u32 encoder_id; /**< Current Encoder */
  321. __u32 connector_id; /**< Id */
  322. __u32 connector_type;
  323. __u32 connector_type_id;
  324. __u32 connection;
  325. __u32 mm_width; /**< width in millimeters */
  326. __u32 mm_height; /**< height in millimeters */
  327. __u32 subpixel;
  328. __u32 pad;
  329. };
  330. #define DRM_MODE_PROP_PENDING (1<<0) /* deprecated, do not use */
  331. #define DRM_MODE_PROP_RANGE (1<<1)
  332. #define DRM_MODE_PROP_IMMUTABLE (1<<2)
  333. #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
  334. #define DRM_MODE_PROP_BLOB (1<<4)
  335. #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
  336. /* non-extended types: legacy bitmask, one bit per type: */
  337. #define DRM_MODE_PROP_LEGACY_TYPE ( \
  338. DRM_MODE_PROP_RANGE | \
  339. DRM_MODE_PROP_ENUM | \
  340. DRM_MODE_PROP_BLOB | \
  341. DRM_MODE_PROP_BITMASK)
  342. /* extended-types: rather than continue to consume a bit per type,
  343. * grab a chunk of the bits to use as integer type id.
  344. */
  345. #define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0
  346. #define DRM_MODE_PROP_TYPE(n) ((n) << 6)
  347. #define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
  348. #define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
  349. /* the PROP_ATOMIC flag is used to hide properties from userspace that
  350. * is not aware of atomic properties. This is mostly to work around
  351. * older userspace (DDX drivers) that read/write each prop they find,
  352. * witout being aware that this could be triggering a lengthy modeset.
  353. */
  354. #define DRM_MODE_PROP_ATOMIC 0x80000000
  355. struct drm_mode_property_enum {
  356. __u64 value;
  357. char name[DRM_PROP_NAME_LEN];
  358. };
  359. struct drm_mode_get_property {
  360. __u64 values_ptr; /* values and blob lengths */
  361. __u64 enum_blob_ptr; /* enum and blob id ptrs */
  362. __u32 prop_id;
  363. __u32 flags;
  364. char name[DRM_PROP_NAME_LEN];
  365. __u32 count_values;
  366. /* This is only used to count enum values, not blobs. The _blobs is
  367. * simply because of a historical reason, i.e. backwards compat. */
  368. __u32 count_enum_blobs;
  369. };
  370. struct drm_mode_connector_set_property {
  371. __u64 value;
  372. __u32 prop_id;
  373. __u32 connector_id;
  374. };
  375. #define DRM_MODE_OBJECT_CRTC 0xcccccccc
  376. #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
  377. #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
  378. #define DRM_MODE_OBJECT_MODE 0xdededede
  379. #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  380. #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  381. #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
  382. #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
  383. #define DRM_MODE_OBJECT_ANY 0
  384. struct drm_mode_obj_get_properties {
  385. __u64 props_ptr;
  386. __u64 prop_values_ptr;
  387. __u32 count_props;
  388. __u32 obj_id;
  389. __u32 obj_type;
  390. };
  391. struct drm_mode_obj_set_property {
  392. __u64 value;
  393. __u32 prop_id;
  394. __u32 obj_id;
  395. __u32 obj_type;
  396. };
  397. struct drm_mode_get_blob {
  398. __u32 blob_id;
  399. __u32 length;
  400. __u64 data;
  401. };
  402. struct drm_mode_fb_cmd {
  403. __u32 fb_id;
  404. __u32 width;
  405. __u32 height;
  406. __u32 pitch;
  407. __u32 bpp;
  408. __u32 depth;
  409. /* driver specific handle */
  410. __u32 handle;
  411. };
  412. #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
  413. #define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */
  414. struct drm_mode_fb_cmd2 {
  415. __u32 fb_id;
  416. __u32 width;
  417. __u32 height;
  418. __u32 pixel_format; /* fourcc code from drm_fourcc.h */
  419. __u32 flags; /* see above flags */
  420. /*
  421. * In case of planar formats, this ioctl allows up to 4
  422. * buffer objects with offsets and pitches per plane.
  423. * The pitch and offset order is dictated by the fourcc,
  424. * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
  425. *
  426. * YUV 4:2:0 image with a plane of 8 bit Y samples
  427. * followed by an interleaved U/V plane containing
  428. * 8 bit 2x2 subsampled colour difference samples.
  429. *
  430. * So it would consist of Y as offsets[0] and UV as
  431. * offsets[1]. Note that offsets[0] will generally
  432. * be 0 (but this is not required).
  433. *
  434. * To accommodate tiled, compressed, etc formats, a
  435. * modifier can be specified. The default value of zero
  436. * indicates "native" format as specified by the fourcc.
  437. * Vendor specific modifier token. Note that even though
  438. * it looks like we have a modifier per-plane, we in fact
  439. * do not. The modifier for each plane must be identical.
  440. * Thus all combinations of different data layouts for
  441. * multi plane formats must be enumerated as separate
  442. * modifiers.
  443. */
  444. __u32 handles[4];
  445. __u32 pitches[4]; /* pitch for each plane */
  446. __u32 offsets[4]; /* offset of each plane */
  447. __u64 modifier[4]; /* ie, tiling, compress */
  448. };
  449. #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
  450. #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
  451. #define DRM_MODE_FB_DIRTY_FLAGS 0x03
  452. #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
  453. /*
  454. * Mark a region of a framebuffer as dirty.
  455. *
  456. * Some hardware does not automatically update display contents
  457. * as a hardware or software draw to a framebuffer. This ioctl
  458. * allows userspace to tell the kernel and the hardware what
  459. * regions of the framebuffer have changed.
  460. *
  461. * The kernel or hardware is free to update more then just the
  462. * region specified by the clip rects. The kernel or hardware
  463. * may also delay and/or coalesce several calls to dirty into a
  464. * single update.
  465. *
  466. * Userspace may annotate the updates, the annotates are a
  467. * promise made by the caller that the change is either a copy
  468. * of pixels or a fill of a single color in the region specified.
  469. *
  470. * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
  471. * the number of updated regions are half of num_clips given,
  472. * where the clip rects are paired in src and dst. The width and
  473. * height of each one of the pairs must match.
  474. *
  475. * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
  476. * promises that the region specified of the clip rects is filled
  477. * completely with a single color as given in the color argument.
  478. */
  479. struct drm_mode_fb_dirty_cmd {
  480. __u32 fb_id;
  481. __u32 flags;
  482. __u32 color;
  483. __u32 num_clips;
  484. __u64 clips_ptr;
  485. };
  486. struct drm_mode_mode_cmd {
  487. __u32 connector_id;
  488. struct drm_mode_modeinfo mode;
  489. };
  490. #define DRM_MODE_CURSOR_BO 0x01
  491. #define DRM_MODE_CURSOR_MOVE 0x02
  492. #define DRM_MODE_CURSOR_FLAGS 0x03
  493. /*
  494. * depending on the value in flags different members are used.
  495. *
  496. * CURSOR_BO uses
  497. * crtc_id
  498. * width
  499. * height
  500. * handle - if 0 turns the cursor off
  501. *
  502. * CURSOR_MOVE uses
  503. * crtc_id
  504. * x
  505. * y
  506. */
  507. struct drm_mode_cursor {
  508. __u32 flags;
  509. __u32 crtc_id;
  510. __s32 x;
  511. __s32 y;
  512. __u32 width;
  513. __u32 height;
  514. /* driver specific handle */
  515. __u32 handle;
  516. };
  517. struct drm_mode_cursor2 {
  518. __u32 flags;
  519. __u32 crtc_id;
  520. __s32 x;
  521. __s32 y;
  522. __u32 width;
  523. __u32 height;
  524. /* driver specific handle */
  525. __u32 handle;
  526. __s32 hot_x;
  527. __s32 hot_y;
  528. };
  529. struct drm_mode_crtc_lut {
  530. __u32 crtc_id;
  531. __u32 gamma_size;
  532. /* pointers to arrays */
  533. __u64 red;
  534. __u64 green;
  535. __u64 blue;
  536. };
  537. struct drm_color_ctm {
  538. /*
  539. * Conversion matrix in S31.32 sign-magnitude
  540. * (not two's complement!) format.
  541. */
  542. __u64 matrix[9];
  543. };
  544. struct drm_color_lut {
  545. /*
  546. * Data is U0.16 fixed point format.
  547. */
  548. __u16 red;
  549. __u16 green;
  550. __u16 blue;
  551. __u16 reserved;
  552. };
  553. #define DRM_MODE_PAGE_FLIP_EVENT 0x01
  554. #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
  555. #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
  556. #define DRM_MODE_PAGE_FLIP_TARGET_RELATIVE 0x8
  557. #define DRM_MODE_PAGE_FLIP_TARGET (DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE | \
  558. DRM_MODE_PAGE_FLIP_TARGET_RELATIVE)
  559. #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | \
  560. DRM_MODE_PAGE_FLIP_ASYNC | \
  561. DRM_MODE_PAGE_FLIP_TARGET)
  562. /*
  563. * Request a page flip on the specified crtc.
  564. *
  565. * This ioctl will ask KMS to schedule a page flip for the specified
  566. * crtc. Once any pending rendering targeting the specified fb (as of
  567. * ioctl time) has completed, the crtc will be reprogrammed to display
  568. * that fb after the next vertical refresh. The ioctl returns
  569. * immediately, but subsequent rendering to the current fb will block
  570. * in the execbuffer ioctl until the page flip happens. If a page
  571. * flip is already pending as the ioctl is called, EBUSY will be
  572. * returned.
  573. *
  574. * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
  575. * event (see drm.h: struct drm_event_vblank) when the page flip is
  576. * done. The user_data field passed in with this ioctl will be
  577. * returned as the user_data field in the vblank event struct.
  578. *
  579. * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
  580. * 'as soon as possible', meaning that it not delay waiting for vblank.
  581. * This may cause tearing on the screen.
  582. *
  583. * The reserved field must be zero.
  584. */
  585. struct drm_mode_crtc_page_flip {
  586. __u32 crtc_id;
  587. __u32 fb_id;
  588. __u32 flags;
  589. __u32 reserved;
  590. __u64 user_data;
  591. };
  592. /*
  593. * Request a page flip on the specified crtc.
  594. *
  595. * Same as struct drm_mode_crtc_page_flip, but supports new flags and
  596. * re-purposes the reserved field:
  597. *
  598. * The sequence field must be zero unless either of the
  599. * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is specified. When
  600. * the ABSOLUTE flag is specified, the sequence field denotes the absolute
  601. * vblank sequence when the flip should take effect. When the RELATIVE
  602. * flag is specified, the sequence field denotes the relative (to the
  603. * current one when the ioctl is called) vblank sequence when the flip
  604. * should take effect. NOTE: DRM_IOCTL_WAIT_VBLANK must still be used to
  605. * make sure the vblank sequence before the target one has passed before
  606. * calling this ioctl. The purpose of the
  607. * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is merely to clarify
  608. * the target for when code dealing with a page flip runs during a
  609. * vertical blank period.
  610. */
  611. struct drm_mode_crtc_page_flip_target {
  612. __u32 crtc_id;
  613. __u32 fb_id;
  614. __u32 flags;
  615. __u32 sequence;
  616. __u64 user_data;
  617. };
  618. /* create a dumb scanout buffer */
  619. struct drm_mode_create_dumb {
  620. __u32 height;
  621. __u32 width;
  622. __u32 bpp;
  623. __u32 flags;
  624. /* handle, pitch, size will be returned */
  625. __u32 handle;
  626. __u32 pitch;
  627. __u64 size;
  628. };
  629. /* set up for mmap of a dumb scanout buffer */
  630. struct drm_mode_map_dumb {
  631. /** Handle for the object being mapped. */
  632. __u32 handle;
  633. __u32 pad;
  634. /**
  635. * Fake offset to use for subsequent mmap call
  636. *
  637. * This is a fixed-size type for 32/64 compatibility.
  638. */
  639. __u64 offset;
  640. };
  641. struct drm_mode_destroy_dumb {
  642. __u32 handle;
  643. };
  644. /* page-flip flags are valid, plus: */
  645. #define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
  646. #define DRM_MODE_ATOMIC_NONBLOCK 0x0200
  647. #define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
  648. #define DRM_MODE_ATOMIC_FLAGS (\
  649. DRM_MODE_PAGE_FLIP_EVENT |\
  650. DRM_MODE_PAGE_FLIP_ASYNC |\
  651. DRM_MODE_ATOMIC_TEST_ONLY |\
  652. DRM_MODE_ATOMIC_NONBLOCK |\
  653. DRM_MODE_ATOMIC_ALLOW_MODESET)
  654. struct drm_mode_atomic {
  655. __u32 flags;
  656. __u32 count_objs;
  657. __u64 objs_ptr;
  658. __u64 count_props_ptr;
  659. __u64 props_ptr;
  660. __u64 prop_values_ptr;
  661. __u64 reserved;
  662. __u64 user_data;
  663. };
  664. struct drm_format_modifier_blob {
  665. #define FORMAT_BLOB_CURRENT 1
  666. /* Version of this blob format */
  667. __u32 version;
  668. /* Flags */
  669. __u32 flags;
  670. /* Number of fourcc formats supported */
  671. __u32 count_formats;
  672. /* Where in this blob the formats exist (in bytes) */
  673. __u32 formats_offset;
  674. /* Number of drm_format_modifiers */
  675. __u32 count_modifiers;
  676. /* Where in this blob the modifiers exist (in bytes) */
  677. __u32 modifiers_offset;
  678. /* __u32 formats[] */
  679. /* struct drm_format_modifier modifiers[] */
  680. };
  681. struct drm_format_modifier {
  682. /* Bitmask of formats in get_plane format list this info applies to. The
  683. * offset allows a sliding window of which 64 formats (bits).
  684. *
  685. * Some examples:
  686. * In today's world with < 65 formats, and formats 0, and 2 are
  687. * supported
  688. * 0x0000000000000005
  689. * ^-offset = 0, formats = 5
  690. *
  691. * If the number formats grew to 128, and formats 98-102 are
  692. * supported with the modifier:
  693. *
  694. * 0x0000007c00000000 0000000000000000
  695. * ^
  696. * |__offset = 64, formats = 0x7c00000000
  697. *
  698. */
  699. __u64 formats;
  700. __u32 offset;
  701. __u32 pad;
  702. /* The modifier that applies to the >get_plane format list bitmask. */
  703. __u64 modifier;
  704. };
  705. /**
  706. * Create a new 'blob' data property, copying length bytes from data pointer,
  707. * and returning new blob ID.
  708. */
  709. struct drm_mode_create_blob {
  710. /** Pointer to data to copy. */
  711. __u64 data;
  712. /** Length of data to copy. */
  713. __u32 length;
  714. /** Return: new property ID. */
  715. __u32 blob_id;
  716. };
  717. /**
  718. * Destroy a user-created blob property.
  719. */
  720. struct drm_mode_destroy_blob {
  721. __u32 blob_id;
  722. };
  723. /**
  724. * Lease mode resources, creating another drm_master.
  725. */
  726. struct drm_mode_create_lease {
  727. /** Pointer to array of object ids (__u32) */
  728. __u64 object_ids;
  729. /** Number of object ids */
  730. __u32 object_count;
  731. /** flags for new FD (O_CLOEXEC, etc) */
  732. __u32 flags;
  733. /** Return: unique identifier for lessee. */
  734. __u32 lessee_id;
  735. /** Return: file descriptor to new drm_master file */
  736. __u32 fd;
  737. };
  738. /**
  739. * List lesses from a drm_master
  740. */
  741. struct drm_mode_list_lessees {
  742. /** Number of lessees.
  743. * On input, provides length of the array.
  744. * On output, provides total number. No
  745. * more than the input number will be written
  746. * back, so two calls can be used to get
  747. * the size and then the data.
  748. */
  749. __u32 count_lessees;
  750. __u32 pad;
  751. /** Pointer to lessees.
  752. * pointer to __u64 array of lessee ids
  753. */
  754. __u64 lessees_ptr;
  755. };
  756. /**
  757. * Get leased objects
  758. */
  759. struct drm_mode_get_lease {
  760. /** Number of leased objects.
  761. * On input, provides length of the array.
  762. * On output, provides total number. No
  763. * more than the input number will be written
  764. * back, so two calls can be used to get
  765. * the size and then the data.
  766. */
  767. __u32 count_objects;
  768. __u32 pad;
  769. /** Pointer to objects.
  770. * pointer to __u32 array of object ids
  771. */
  772. __u64 objects_ptr;
  773. };
  774. /**
  775. * Revoke lease
  776. */
  777. struct drm_mode_revoke_lease {
  778. /** Unique ID of lessee
  779. */
  780. __u32 lessee_id;
  781. };
  782. #if defined(__cplusplus)
  783. }
  784. #endif
  785. #endif