drm_mode.h 28 KB

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