drm_mode.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. #if !defined(__KERNEL__) && !defined(_KERNEL)
  29. #include <stdint.h>
  30. #else
  31. #include <linux/kernel.h>
  32. #endif
  33. #define DRM_DISPLAY_INFO_LEN 32
  34. #define DRM_CONNECTOR_NAME_LEN 32
  35. #define DRM_DISPLAY_MODE_LEN 32
  36. #define DRM_PROP_NAME_LEN 32
  37. #define DRM_MODE_TYPE_BUILTIN (1<<0)
  38. #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
  39. #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
  40. #define DRM_MODE_TYPE_PREFERRED (1<<3)
  41. #define DRM_MODE_TYPE_DEFAULT (1<<4)
  42. #define DRM_MODE_TYPE_USERDEF (1<<5)
  43. #define DRM_MODE_TYPE_DRIVER (1<<6)
  44. /* Video mode flags */
  45. /* bit compatible with the xorg definitions. */
  46. #define DRM_MODE_FLAG_PHSYNC (1<<0)
  47. #define DRM_MODE_FLAG_NHSYNC (1<<1)
  48. #define DRM_MODE_FLAG_PVSYNC (1<<2)
  49. #define DRM_MODE_FLAG_NVSYNC (1<<3)
  50. #define DRM_MODE_FLAG_INTERLACE (1<<4)
  51. #define DRM_MODE_FLAG_DBLSCAN (1<<5)
  52. #define DRM_MODE_FLAG_CSYNC (1<<6)
  53. #define DRM_MODE_FLAG_PCSYNC (1<<7)
  54. #define DRM_MODE_FLAG_NCSYNC (1<<8)
  55. #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
  56. #define DRM_MODE_FLAG_BCAST (1<<10)
  57. #define DRM_MODE_FLAG_PIXMUX (1<<11)
  58. #define DRM_MODE_FLAG_DBLCLK (1<<12)
  59. #define DRM_MODE_FLAG_CLKDIV2 (1<<13)
  60. /* DPMS flags */
  61. /* bit compatible with the xorg definitions. */
  62. #define DRM_MODE_DPMS_ON 0
  63. #define DRM_MODE_DPMS_STANDBY 1
  64. #define DRM_MODE_DPMS_SUSPEND 2
  65. #define DRM_MODE_DPMS_OFF 3
  66. /* Scaling mode options */
  67. #define DRM_MODE_SCALE_NON_GPU 0
  68. #define DRM_MODE_SCALE_FULLSCREEN 1
  69. #define DRM_MODE_SCALE_NO_SCALE 2
  70. #define DRM_MODE_SCALE_ASPECT 3
  71. /* Dithering mode options */
  72. #define DRM_MODE_DITHERING_OFF 0
  73. #define DRM_MODE_DITHERING_ON 1
  74. struct drm_mode_modeinfo {
  75. uint32_t clock;
  76. uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
  77. uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
  78. uint32_t vrefresh; /* vertical refresh * 1000 */
  79. uint32_t flags;
  80. uint32_t type;
  81. char name[DRM_DISPLAY_MODE_LEN];
  82. };
  83. struct drm_mode_card_res {
  84. uint64_t fb_id_ptr;
  85. uint64_t crtc_id_ptr;
  86. uint64_t connector_id_ptr;
  87. uint64_t encoder_id_ptr;
  88. uint32_t count_fbs;
  89. uint32_t count_crtcs;
  90. uint32_t count_connectors;
  91. uint32_t count_encoders;
  92. uint32_t min_width, max_width;
  93. uint32_t min_height, max_height;
  94. };
  95. struct drm_mode_crtc {
  96. uint64_t set_connectors_ptr;
  97. uint32_t count_connectors;
  98. uint32_t crtc_id; /**< Id */
  99. uint32_t fb_id; /**< Id of framebuffer */
  100. uint32_t x, y; /**< Position on the frameuffer */
  101. uint32_t gamma_size;
  102. uint32_t mode_valid;
  103. struct drm_mode_modeinfo mode;
  104. };
  105. #define DRM_MODE_ENCODER_NONE 0
  106. #define DRM_MODE_ENCODER_DAC 1
  107. #define DRM_MODE_ENCODER_TMDS 2
  108. #define DRM_MODE_ENCODER_LVDS 3
  109. #define DRM_MODE_ENCODER_TVDAC 4
  110. struct drm_mode_get_encoder {
  111. uint32_t encoder_id;
  112. uint32_t encoder_type;
  113. uint32_t crtc_id; /**< Id of crtc */
  114. uint32_t possible_crtcs;
  115. uint32_t possible_clones;
  116. };
  117. /* This is for connectors with multiple signal types. */
  118. /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
  119. #define DRM_MODE_SUBCONNECTOR_Automatic 0
  120. #define DRM_MODE_SUBCONNECTOR_Unknown 0
  121. #define DRM_MODE_SUBCONNECTOR_DVID 3
  122. #define DRM_MODE_SUBCONNECTOR_DVIA 4
  123. #define DRM_MODE_SUBCONNECTOR_Composite 5
  124. #define DRM_MODE_SUBCONNECTOR_SVIDEO 6
  125. #define DRM_MODE_SUBCONNECTOR_Component 8
  126. #define DRM_MODE_CONNECTOR_Unknown 0
  127. #define DRM_MODE_CONNECTOR_VGA 1
  128. #define DRM_MODE_CONNECTOR_DVII 2
  129. #define DRM_MODE_CONNECTOR_DVID 3
  130. #define DRM_MODE_CONNECTOR_DVIA 4
  131. #define DRM_MODE_CONNECTOR_Composite 5
  132. #define DRM_MODE_CONNECTOR_SVIDEO 6
  133. #define DRM_MODE_CONNECTOR_LVDS 7
  134. #define DRM_MODE_CONNECTOR_Component 8
  135. #define DRM_MODE_CONNECTOR_9PinDIN 9
  136. #define DRM_MODE_CONNECTOR_DisplayPort 10
  137. #define DRM_MODE_CONNECTOR_HDMIA 11
  138. #define DRM_MODE_CONNECTOR_HDMIB 12
  139. struct drm_mode_get_connector {
  140. uint64_t encoders_ptr;
  141. uint64_t modes_ptr;
  142. uint64_t props_ptr;
  143. uint64_t prop_values_ptr;
  144. uint32_t count_modes;
  145. uint32_t count_props;
  146. uint32_t count_encoders;
  147. uint32_t encoder_id; /**< Current Encoder */
  148. uint32_t connector_id; /**< Id */
  149. uint32_t connector_type;
  150. uint32_t connector_type_id;
  151. uint32_t connection;
  152. uint32_t mm_width, mm_height; /**< HxW in millimeters */
  153. uint32_t subpixel;
  154. };
  155. #define DRM_MODE_PROP_PENDING (1<<0)
  156. #define DRM_MODE_PROP_RANGE (1<<1)
  157. #define DRM_MODE_PROP_IMMUTABLE (1<<2)
  158. #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
  159. #define DRM_MODE_PROP_BLOB (1<<4)
  160. struct drm_mode_property_enum {
  161. uint64_t value;
  162. char name[DRM_PROP_NAME_LEN];
  163. };
  164. struct drm_mode_get_property {
  165. uint64_t values_ptr; /* values and blob lengths */
  166. uint64_t enum_blob_ptr; /* enum and blob id ptrs */
  167. uint32_t prop_id;
  168. uint32_t flags;
  169. char name[DRM_PROP_NAME_LEN];
  170. uint32_t count_values;
  171. uint32_t count_enum_blobs;
  172. };
  173. struct drm_mode_connector_set_property {
  174. uint64_t value;
  175. uint32_t prop_id;
  176. uint32_t connector_id;
  177. };
  178. struct drm_mode_get_blob {
  179. uint32_t blob_id;
  180. uint32_t length;
  181. uint64_t data;
  182. };
  183. struct drm_mode_fb_cmd {
  184. uint32_t fb_id;
  185. uint32_t width, height;
  186. uint32_t pitch;
  187. uint32_t bpp;
  188. uint32_t depth;
  189. /* driver specific handle */
  190. uint32_t handle;
  191. };
  192. struct drm_mode_mode_cmd {
  193. uint32_t connector_id;
  194. struct drm_mode_modeinfo mode;
  195. };
  196. #define DRM_MODE_CURSOR_BO (1<<0)
  197. #define DRM_MODE_CURSOR_MOVE (1<<1)
  198. /*
  199. * depending on the value in flags diffrent members are used.
  200. *
  201. * CURSOR_BO uses
  202. * crtc
  203. * width
  204. * height
  205. * handle - if 0 turns the cursor of
  206. *
  207. * CURSOR_MOVE uses
  208. * crtc
  209. * x
  210. * y
  211. */
  212. struct drm_mode_cursor {
  213. uint32_t flags;
  214. uint32_t crtc_id;
  215. int32_t x;
  216. int32_t y;
  217. uint32_t width;
  218. uint32_t height;
  219. /* driver specific handle */
  220. uint32_t handle;
  221. };
  222. struct drm_mode_crtc_lut {
  223. uint32_t crtc_id;
  224. uint32_t gamma_size;
  225. /* pointers to arrays */
  226. uint64_t red;
  227. uint64_t green;
  228. uint64_t blue;
  229. };
  230. #endif