drm_mode.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  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_CONNECTOR_NAME_LEN 32
  33. #define DRM_DISPLAY_MODE_LEN 32
  34. #define DRM_PROP_NAME_LEN 32
  35. #define DRM_MODE_TYPE_BUILTIN (1<<0) /* deprecated */
  36. #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
  37. #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
  38. #define DRM_MODE_TYPE_PREFERRED (1<<3)
  39. #define DRM_MODE_TYPE_DEFAULT (1<<4) /* deprecated */
  40. #define DRM_MODE_TYPE_USERDEF (1<<5)
  41. #define DRM_MODE_TYPE_DRIVER (1<<6)
  42. #define DRM_MODE_TYPE_ALL (DRM_MODE_TYPE_PREFERRED | \
  43. DRM_MODE_TYPE_USERDEF | \
  44. DRM_MODE_TYPE_DRIVER)
  45. /* Video mode flags */
  46. /* bit compatible with the xrandr RR_ definitions (bits 0-13)
  47. *
  48. * ABI warning: Existing userspace really expects
  49. * the mode flags to match the xrandr definitions. Any
  50. * changes that don't match the xrandr definitions will
  51. * likely need a new client cap or some other mechanism
  52. * to avoid breaking existing userspace. This includes
  53. * allocating new flags in the previously unused bits!
  54. */
  55. #define DRM_MODE_FLAG_PHSYNC (1<<0)
  56. #define DRM_MODE_FLAG_NHSYNC (1<<1)
  57. #define DRM_MODE_FLAG_PVSYNC (1<<2)
  58. #define DRM_MODE_FLAG_NVSYNC (1<<3)
  59. #define DRM_MODE_FLAG_INTERLACE (1<<4)
  60. #define DRM_MODE_FLAG_DBLSCAN (1<<5)
  61. #define DRM_MODE_FLAG_CSYNC (1<<6)
  62. #define DRM_MODE_FLAG_PCSYNC (1<<7)
  63. #define DRM_MODE_FLAG_NCSYNC (1<<8)
  64. #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
  65. #define DRM_MODE_FLAG_BCAST (1<<10) /* deprecated */
  66. #define DRM_MODE_FLAG_PIXMUX (1<<11) /* deprecated */
  67. #define DRM_MODE_FLAG_DBLCLK (1<<12)
  68. #define DRM_MODE_FLAG_CLKDIV2 (1<<13)
  69. /*
  70. * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
  71. * (define not exposed to user space).
  72. */
  73. #define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
  74. #define DRM_MODE_FLAG_3D_NONE (0<<14)
  75. #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
  76. #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14)
  77. #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14)
  78. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14)
  79. #define DRM_MODE_FLAG_3D_L_DEPTH (5<<14)
  80. #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14)
  81. #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14)
  82. #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14)
  83. /* Picture aspect ratio options */
  84. #define DRM_MODE_PICTURE_ASPECT_NONE 0
  85. #define DRM_MODE_PICTURE_ASPECT_4_3 1
  86. #define DRM_MODE_PICTURE_ASPECT_16_9 2
  87. #define DRM_MODE_PICTURE_ASPECT_64_27 3
  88. #define DRM_MODE_PICTURE_ASPECT_256_135 4
  89. /* Content type options */
  90. #define DRM_MODE_CONTENT_TYPE_NO_DATA 0
  91. #define DRM_MODE_CONTENT_TYPE_GRAPHICS 1
  92. #define DRM_MODE_CONTENT_TYPE_PHOTO 2
  93. #define DRM_MODE_CONTENT_TYPE_CINEMA 3
  94. #define DRM_MODE_CONTENT_TYPE_GAME 4
  95. /* Aspect ratio flag bitmask (4 bits 22:19) */
  96. #define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
  97. #define DRM_MODE_FLAG_PIC_AR_NONE \
  98. (DRM_MODE_PICTURE_ASPECT_NONE<<19)
  99. #define DRM_MODE_FLAG_PIC_AR_4_3 \
  100. (DRM_MODE_PICTURE_ASPECT_4_3<<19)
  101. #define DRM_MODE_FLAG_PIC_AR_16_9 \
  102. (DRM_MODE_PICTURE_ASPECT_16_9<<19)
  103. #define DRM_MODE_FLAG_PIC_AR_64_27 \
  104. (DRM_MODE_PICTURE_ASPECT_64_27<<19)
  105. #define DRM_MODE_FLAG_PIC_AR_256_135 \
  106. (DRM_MODE_PICTURE_ASPECT_256_135<<19)
  107. #define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \
  108. DRM_MODE_FLAG_NHSYNC | \
  109. DRM_MODE_FLAG_PVSYNC | \
  110. DRM_MODE_FLAG_NVSYNC | \
  111. DRM_MODE_FLAG_INTERLACE | \
  112. DRM_MODE_FLAG_DBLSCAN | \
  113. DRM_MODE_FLAG_CSYNC | \
  114. DRM_MODE_FLAG_PCSYNC | \
  115. DRM_MODE_FLAG_NCSYNC | \
  116. DRM_MODE_FLAG_HSKEW | \
  117. DRM_MODE_FLAG_DBLCLK | \
  118. DRM_MODE_FLAG_CLKDIV2 | \
  119. DRM_MODE_FLAG_3D_MASK)
  120. /* DPMS flags */
  121. /* bit compatible with the xorg definitions. */
  122. #define DRM_MODE_DPMS_ON 0
  123. #define DRM_MODE_DPMS_STANDBY 1
  124. #define DRM_MODE_DPMS_SUSPEND 2
  125. #define DRM_MODE_DPMS_OFF 3
  126. /* Scaling mode options */
  127. #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or
  128. software can still scale) */
  129. #define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */
  130. #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
  131. #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
  132. /* Dithering mode options */
  133. #define DRM_MODE_DITHERING_OFF 0
  134. #define DRM_MODE_DITHERING_ON 1
  135. #define DRM_MODE_DITHERING_AUTO 2
  136. /* Dirty info options */
  137. #define DRM_MODE_DIRTY_OFF 0
  138. #define DRM_MODE_DIRTY_ON 1
  139. #define DRM_MODE_DIRTY_ANNOTATE 2
  140. /* Link Status options */
  141. #define DRM_MODE_LINK_STATUS_GOOD 0
  142. #define DRM_MODE_LINK_STATUS_BAD 1
  143. /*
  144. * DRM_MODE_ROTATE_<degrees>
  145. *
  146. * Signals that a drm plane is been rotated <degrees> degrees in counter
  147. * clockwise direction.
  148. *
  149. * This define is provided as a convenience, looking up the property id
  150. * using the name->prop id lookup is the preferred method.
  151. */
  152. #define DRM_MODE_ROTATE_0 (1<<0)
  153. #define DRM_MODE_ROTATE_90 (1<<1)
  154. #define DRM_MODE_ROTATE_180 (1<<2)
  155. #define DRM_MODE_ROTATE_270 (1<<3)
  156. /*
  157. * DRM_MODE_ROTATE_MASK
  158. *
  159. * Bitmask used to look for drm plane rotations.
  160. */
  161. #define DRM_MODE_ROTATE_MASK (\
  162. DRM_MODE_ROTATE_0 | \
  163. DRM_MODE_ROTATE_90 | \
  164. DRM_MODE_ROTATE_180 | \
  165. DRM_MODE_ROTATE_270)
  166. /*
  167. * DRM_MODE_REFLECT_<axis>
  168. *
  169. * Signals that the contents of a drm plane is reflected along the <axis> axis,
  170. * in the same way as mirroring.
  171. * See kerneldoc chapter "Plane Composition Properties" for more details.
  172. *
  173. * This define is provided as a convenience, looking up the property id
  174. * using the name->prop id lookup is the preferred method.
  175. */
  176. #define DRM_MODE_REFLECT_X (1<<4)
  177. #define DRM_MODE_REFLECT_Y (1<<5)
  178. /*
  179. * DRM_MODE_REFLECT_MASK
  180. *
  181. * Bitmask used to look for drm plane reflections.
  182. */
  183. #define DRM_MODE_REFLECT_MASK (\
  184. DRM_MODE_REFLECT_X | \
  185. DRM_MODE_REFLECT_Y)
  186. /* Content Protection Flags */
  187. #define DRM_MODE_CONTENT_PROTECTION_UNDESIRED 0
  188. #define DRM_MODE_CONTENT_PROTECTION_DESIRED 1
  189. #define DRM_MODE_CONTENT_PROTECTION_ENABLED 2
  190. struct drm_mode_modeinfo {
  191. __u32 clock;
  192. __u16 hdisplay;
  193. __u16 hsync_start;
  194. __u16 hsync_end;
  195. __u16 htotal;
  196. __u16 hskew;
  197. __u16 vdisplay;
  198. __u16 vsync_start;
  199. __u16 vsync_end;
  200. __u16 vtotal;
  201. __u16 vscan;
  202. __u32 vrefresh;
  203. __u32 flags;
  204. __u32 type;
  205. char name[DRM_DISPLAY_MODE_LEN];
  206. };
  207. struct drm_mode_card_res {
  208. __u64 fb_id_ptr;
  209. __u64 crtc_id_ptr;
  210. __u64 connector_id_ptr;
  211. __u64 encoder_id_ptr;
  212. __u32 count_fbs;
  213. __u32 count_crtcs;
  214. __u32 count_connectors;
  215. __u32 count_encoders;
  216. __u32 min_width;
  217. __u32 max_width;
  218. __u32 min_height;
  219. __u32 max_height;
  220. };
  221. struct drm_mode_crtc {
  222. __u64 set_connectors_ptr;
  223. __u32 count_connectors;
  224. __u32 crtc_id; /**< Id */
  225. __u32 fb_id; /**< Id of framebuffer */
  226. __u32 x; /**< x Position on the framebuffer */
  227. __u32 y; /**< y Position on the framebuffer */
  228. __u32 gamma_size;
  229. __u32 mode_valid;
  230. struct drm_mode_modeinfo mode;
  231. };
  232. #define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
  233. #define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
  234. /* Planes blend with or override other bits on the CRTC */
  235. struct drm_mode_set_plane {
  236. __u32 plane_id;
  237. __u32 crtc_id;
  238. __u32 fb_id; /* fb object contains surface format type */
  239. __u32 flags; /* see above flags */
  240. /* Signed dest location allows it to be partially off screen */
  241. __s32 crtc_x;
  242. __s32 crtc_y;
  243. __u32 crtc_w;
  244. __u32 crtc_h;
  245. /* Source values are 16.16 fixed point */
  246. __u32 src_x;
  247. __u32 src_y;
  248. __u32 src_h;
  249. __u32 src_w;
  250. };
  251. struct drm_mode_get_plane {
  252. __u32 plane_id;
  253. __u32 crtc_id;
  254. __u32 fb_id;
  255. __u32 possible_crtcs;
  256. __u32 gamma_size;
  257. __u32 count_format_types;
  258. __u64 format_type_ptr;
  259. };
  260. struct drm_mode_get_plane_res {
  261. __u64 plane_id_ptr;
  262. __u32 count_planes;
  263. };
  264. #define DRM_MODE_ENCODER_NONE 0
  265. #define DRM_MODE_ENCODER_DAC 1
  266. #define DRM_MODE_ENCODER_TMDS 2
  267. #define DRM_MODE_ENCODER_LVDS 3
  268. #define DRM_MODE_ENCODER_TVDAC 4
  269. #define DRM_MODE_ENCODER_VIRTUAL 5
  270. #define DRM_MODE_ENCODER_DSI 6
  271. #define DRM_MODE_ENCODER_DPMST 7
  272. #define DRM_MODE_ENCODER_DPI 8
  273. struct drm_mode_get_encoder {
  274. __u32 encoder_id;
  275. __u32 encoder_type;
  276. __u32 crtc_id; /**< Id of crtc */
  277. __u32 possible_crtcs;
  278. __u32 possible_clones;
  279. };
  280. /* This is for connectors with multiple signal types. */
  281. /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
  282. enum drm_mode_subconnector {
  283. DRM_MODE_SUBCONNECTOR_Automatic = 0,
  284. DRM_MODE_SUBCONNECTOR_Unknown = 0,
  285. DRM_MODE_SUBCONNECTOR_DVID = 3,
  286. DRM_MODE_SUBCONNECTOR_DVIA = 4,
  287. DRM_MODE_SUBCONNECTOR_Composite = 5,
  288. DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
  289. DRM_MODE_SUBCONNECTOR_Component = 8,
  290. DRM_MODE_SUBCONNECTOR_SCART = 9,
  291. };
  292. #define DRM_MODE_CONNECTOR_Unknown 0
  293. #define DRM_MODE_CONNECTOR_VGA 1
  294. #define DRM_MODE_CONNECTOR_DVII 2
  295. #define DRM_MODE_CONNECTOR_DVID 3
  296. #define DRM_MODE_CONNECTOR_DVIA 4
  297. #define DRM_MODE_CONNECTOR_Composite 5
  298. #define DRM_MODE_CONNECTOR_SVIDEO 6
  299. #define DRM_MODE_CONNECTOR_LVDS 7
  300. #define DRM_MODE_CONNECTOR_Component 8
  301. #define DRM_MODE_CONNECTOR_9PinDIN 9
  302. #define DRM_MODE_CONNECTOR_DisplayPort 10
  303. #define DRM_MODE_CONNECTOR_HDMIA 11
  304. #define DRM_MODE_CONNECTOR_HDMIB 12
  305. #define DRM_MODE_CONNECTOR_TV 13
  306. #define DRM_MODE_CONNECTOR_eDP 14
  307. #define DRM_MODE_CONNECTOR_VIRTUAL 15
  308. #define DRM_MODE_CONNECTOR_DSI 16
  309. #define DRM_MODE_CONNECTOR_DPI 17
  310. #define DRM_MODE_CONNECTOR_WRITEBACK 18
  311. struct drm_mode_get_connector {
  312. __u64 encoders_ptr;
  313. __u64 modes_ptr;
  314. __u64 props_ptr;
  315. __u64 prop_values_ptr;
  316. __u32 count_modes;
  317. __u32 count_props;
  318. __u32 count_encoders;
  319. __u32 encoder_id; /**< Current Encoder */
  320. __u32 connector_id; /**< Id */
  321. __u32 connector_type;
  322. __u32 connector_type_id;
  323. __u32 connection;
  324. __u32 mm_width; /**< width in millimeters */
  325. __u32 mm_height; /**< height in millimeters */
  326. __u32 subpixel;
  327. __u32 pad;
  328. };
  329. #define DRM_MODE_PROP_PENDING (1<<0) /* deprecated, do not use */
  330. #define DRM_MODE_PROP_RANGE (1<<1)
  331. #define DRM_MODE_PROP_IMMUTABLE (1<<2)
  332. #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
  333. #define DRM_MODE_PROP_BLOB (1<<4)
  334. #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
  335. /* non-extended types: legacy bitmask, one bit per type: */
  336. #define DRM_MODE_PROP_LEGACY_TYPE ( \
  337. DRM_MODE_PROP_RANGE | \
  338. DRM_MODE_PROP_ENUM | \
  339. DRM_MODE_PROP_BLOB | \
  340. DRM_MODE_PROP_BITMASK)
  341. /* extended-types: rather than continue to consume a bit per type,
  342. * grab a chunk of the bits to use as integer type id.
  343. */
  344. #define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0
  345. #define DRM_MODE_PROP_TYPE(n) ((n) << 6)
  346. #define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
  347. #define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
  348. /* the PROP_ATOMIC flag is used to hide properties from userspace that
  349. * is not aware of atomic properties. This is mostly to work around
  350. * older userspace (DDX drivers) that read/write each prop they find,
  351. * without being aware that this could be triggering a lengthy modeset.
  352. */
  353. #define DRM_MODE_PROP_ATOMIC 0x80000000
  354. struct drm_mode_property_enum {
  355. __u64 value;
  356. char name[DRM_PROP_NAME_LEN];
  357. };
  358. struct drm_mode_get_property {
  359. __u64 values_ptr; /* values and blob lengths */
  360. __u64 enum_blob_ptr; /* enum and blob id ptrs */
  361. __u32 prop_id;
  362. __u32 flags;
  363. char name[DRM_PROP_NAME_LEN];
  364. __u32 count_values;
  365. /* This is only used to count enum values, not blobs. The _blobs is
  366. * simply because of a historical reason, i.e. backwards compat. */
  367. __u32 count_enum_blobs;
  368. };
  369. struct drm_mode_connector_set_property {
  370. __u64 value;
  371. __u32 prop_id;
  372. __u32 connector_id;
  373. };
  374. #define DRM_MODE_OBJECT_CRTC 0xcccccccc
  375. #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
  376. #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
  377. #define DRM_MODE_OBJECT_MODE 0xdededede
  378. #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  379. #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  380. #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
  381. #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
  382. #define DRM_MODE_OBJECT_ANY 0
  383. struct drm_mode_obj_get_properties {
  384. __u64 props_ptr;
  385. __u64 prop_values_ptr;
  386. __u32 count_props;
  387. __u32 obj_id;
  388. __u32 obj_type;
  389. };
  390. struct drm_mode_obj_set_property {
  391. __u64 value;
  392. __u32 prop_id;
  393. __u32 obj_id;
  394. __u32 obj_type;
  395. };
  396. struct drm_mode_get_blob {
  397. __u32 blob_id;
  398. __u32 length;
  399. __u64 data;
  400. };
  401. struct drm_mode_fb_cmd {
  402. __u32 fb_id;
  403. __u32 width;
  404. __u32 height;
  405. __u32 pitch;
  406. __u32 bpp;
  407. __u32 depth;
  408. /* driver specific handle */
  409. __u32 handle;
  410. };
  411. #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
  412. #define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */
  413. struct drm_mode_fb_cmd2 {
  414. __u32 fb_id;
  415. __u32 width;
  416. __u32 height;
  417. __u32 pixel_format; /* fourcc code from drm_fourcc.h */
  418. __u32 flags; /* see above flags */
  419. /*
  420. * In case of planar formats, this ioctl allows up to 4
  421. * buffer objects with offsets and pitches per plane.
  422. * The pitch and offset order is dictated by the fourcc,
  423. * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
  424. *
  425. * YUV 4:2:0 image with a plane of 8 bit Y samples
  426. * followed by an interleaved U/V plane containing
  427. * 8 bit 2x2 subsampled colour difference samples.
  428. *
  429. * So it would consist of Y as offsets[0] and UV as
  430. * offsets[1]. Note that offsets[0] will generally
  431. * be 0 (but this is not required).
  432. *
  433. * To accommodate tiled, compressed, etc formats, a
  434. * modifier can be specified. The default value of zero
  435. * indicates "native" format as specified by the fourcc.
  436. * Vendor specific modifier token. Note that even though
  437. * it looks like we have a modifier per-plane, we in fact
  438. * do not. The modifier for each plane must be identical.
  439. * Thus all combinations of different data layouts for
  440. * multi plane formats must be enumerated as separate
  441. * modifiers.
  442. */
  443. __u32 handles[4];
  444. __u32 pitches[4]; /* pitch for each plane */
  445. __u32 offsets[4]; /* offset of each plane */
  446. __u64 modifier[4]; /* ie, tiling, compress */
  447. };
  448. #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
  449. #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
  450. #define DRM_MODE_FB_DIRTY_FLAGS 0x03
  451. #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
  452. /*
  453. * Mark a region of a framebuffer as dirty.
  454. *
  455. * Some hardware does not automatically update display contents
  456. * as a hardware or software draw to a framebuffer. This ioctl
  457. * allows userspace to tell the kernel and the hardware what
  458. * regions of the framebuffer have changed.
  459. *
  460. * The kernel or hardware is free to update more then just the
  461. * region specified by the clip rects. The kernel or hardware
  462. * may also delay and/or coalesce several calls to dirty into a
  463. * single update.
  464. *
  465. * Userspace may annotate the updates, the annotates are a
  466. * promise made by the caller that the change is either a copy
  467. * of pixels or a fill of a single color in the region specified.
  468. *
  469. * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
  470. * the number of updated regions are half of num_clips given,
  471. * where the clip rects are paired in src and dst. The width and
  472. * height of each one of the pairs must match.
  473. *
  474. * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
  475. * promises that the region specified of the clip rects is filled
  476. * completely with a single color as given in the color argument.
  477. */
  478. struct drm_mode_fb_dirty_cmd {
  479. __u32 fb_id;
  480. __u32 flags;
  481. __u32 color;
  482. __u32 num_clips;
  483. __u64 clips_ptr;
  484. };
  485. struct drm_mode_mode_cmd {
  486. __u32 connector_id;
  487. struct drm_mode_modeinfo mode;
  488. };
  489. #define DRM_MODE_CURSOR_BO 0x01
  490. #define DRM_MODE_CURSOR_MOVE 0x02
  491. #define DRM_MODE_CURSOR_FLAGS 0x03
  492. /*
  493. * depending on the value in flags different members are used.
  494. *
  495. * CURSOR_BO uses
  496. * crtc_id
  497. * width
  498. * height
  499. * handle - if 0 turns the cursor off
  500. *
  501. * CURSOR_MOVE uses
  502. * crtc_id
  503. * x
  504. * y
  505. */
  506. struct drm_mode_cursor {
  507. __u32 flags;
  508. __u32 crtc_id;
  509. __s32 x;
  510. __s32 y;
  511. __u32 width;
  512. __u32 height;
  513. /* driver specific handle */
  514. __u32 handle;
  515. };
  516. struct drm_mode_cursor2 {
  517. __u32 flags;
  518. __u32 crtc_id;
  519. __s32 x;
  520. __s32 y;
  521. __u32 width;
  522. __u32 height;
  523. /* driver specific handle */
  524. __u32 handle;
  525. __s32 hot_x;
  526. __s32 hot_y;
  527. };
  528. struct drm_mode_crtc_lut {
  529. __u32 crtc_id;
  530. __u32 gamma_size;
  531. /* pointers to arrays */
  532. __u64 red;
  533. __u64 green;
  534. __u64 blue;
  535. };
  536. struct drm_color_ctm {
  537. /*
  538. * Conversion matrix in S31.32 sign-magnitude
  539. * (not two's complement!) format.
  540. */
  541. __u64 matrix[9];
  542. };
  543. struct drm_color_lut {
  544. /*
  545. * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and
  546. * 0xffff == 1.0.
  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. /**
  783. * struct drm_mode_rect - Two dimensional rectangle.
  784. * @x1: Horizontal starting coordinate (inclusive).
  785. * @y1: Vertical starting coordinate (inclusive).
  786. * @x2: Horizontal ending coordinate (exclusive).
  787. * @y2: Vertical ending coordinate (exclusive).
  788. *
  789. * With drm subsystem using struct drm_rect to manage rectangular area this
  790. * export it to user-space.
  791. *
  792. * Currently used by drm_mode_atomic blob property FB_DAMAGE_CLIPS.
  793. */
  794. struct drm_mode_rect {
  795. __s32 x1;
  796. __s32 y1;
  797. __s32 x2;
  798. __s32 y2;
  799. };
  800. #if defined(__cplusplus)
  801. }
  802. #endif
  803. #endif