adf.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * Copyright (C) 2013 Google, Inc.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #ifndef _UAPI_VIDEO_ADF_H_
  15. #define _UAPI_VIDEO_ADF_H_
  16. #include <linux/ioctl.h>
  17. #include <linux/types.h>
  18. #include <drm/drm_fourcc.h>
  19. #include <drm/drm_mode.h>
  20. #define ADF_NAME_LEN 32
  21. #define ADF_MAX_CUSTOM_DATA_SIZE 4096
  22. enum adf_interface_type {
  23. ADF_INTF_DSI = 0,
  24. ADF_INTF_eDP = 1,
  25. ADF_INTF_DPI = 2,
  26. ADF_INTF_VGA = 3,
  27. ADF_INTF_DVI = 4,
  28. ADF_INTF_HDMI = 5,
  29. ADF_INTF_MEMORY = 6,
  30. ADF_INTF_TYPE_DEVICE_CUSTOM = 128,
  31. ADF_INTF_TYPE_MAX = (~(__u32)0),
  32. };
  33. #define ADF_INTF_FLAG_PRIMARY (1 << 0)
  34. #define ADF_INTF_FLAG_EXTERNAL (1 << 1)
  35. enum adf_event_type {
  36. ADF_EVENT_VSYNC = 0,
  37. ADF_EVENT_HOTPLUG = 1,
  38. ADF_EVENT_DEVICE_CUSTOM = 128,
  39. ADF_EVENT_TYPE_MAX = 255,
  40. };
  41. /**
  42. * struct adf_set_event - start or stop subscribing to ADF events
  43. *
  44. * @type: the type of event to (un)subscribe
  45. * @enabled: subscribe or unsubscribe
  46. *
  47. * After subscribing to an event, userspace may poll() the ADF object's fd
  48. * to wait for events or read() to consume the event's data.
  49. *
  50. * ADF reserves event types 0 to %ADF_EVENT_DEVICE_CUSTOM-1 for its own events.
  51. * Devices may use event types %ADF_EVENT_DEVICE_CUSTOM to %ADF_EVENT_TYPE_MAX-1
  52. * for driver-private events.
  53. */
  54. struct adf_set_event {
  55. __u8 type;
  56. __u8 enabled;
  57. };
  58. /**
  59. * struct adf_event - common header for ADF event data
  60. *
  61. * @type: event type
  62. * @length: total size of event data, header inclusive
  63. */
  64. struct adf_event {
  65. __u8 type;
  66. __u32 length;
  67. };
  68. /**
  69. * struct adf_vsync_event - ADF vsync event
  70. *
  71. * @base: event header (see &struct adf_event)
  72. * @timestamp: time of vsync event, in nanoseconds
  73. */
  74. struct adf_vsync_event {
  75. struct adf_event base;
  76. __aligned_u64 timestamp;
  77. };
  78. /**
  79. * struct adf_vsync_event - ADF display hotplug event
  80. *
  81. * @base: event header (see &struct adf_event)
  82. * @connected: whether a display is now connected to the interface
  83. */
  84. struct adf_hotplug_event {
  85. struct adf_event base;
  86. __u8 connected;
  87. };
  88. #define ADF_MAX_PLANES 4
  89. /**
  90. * struct adf_buffer_config - description of buffer displayed by adf_post_config
  91. *
  92. * @overlay_engine: id of the target overlay engine
  93. * @w: width of display region in pixels
  94. * @h: height of display region in pixels
  95. * @format: DRM-style fourcc, see drm_fourcc.h for standard formats
  96. * @fd: dma_buf fd for each plane
  97. * @offset: location of first pixel to scan out, in bytes
  98. * @pitch: stride (i.e. length of a scanline including padding) in bytes
  99. * @n_planes: number of planes in buffer
  100. * @acquire_fence: sync_fence fd which will clear when the buffer is
  101. * ready for display, or <0 if the buffer is already ready
  102. */
  103. struct adf_buffer_config {
  104. __u32 overlay_engine;
  105. __u32 w;
  106. __u32 h;
  107. __u32 format;
  108. __s32 fd[ADF_MAX_PLANES];
  109. __u32 offset[ADF_MAX_PLANES];
  110. __u32 pitch[ADF_MAX_PLANES];
  111. __u8 n_planes;
  112. __s32 acquire_fence;
  113. };
  114. #define ADF_MAX_BUFFERS (4096 / sizeof(struct adf_buffer_config))
  115. /**
  116. * struct adf_post_config - request to flip to a new set of buffers
  117. *
  118. * @n_interfaces: number of interfaces targeted by the flip (input)
  119. * @interfaces: ids of interfaces targeted by the flip (input)
  120. * @n_bufs: number of buffers displayed (input)
  121. * @bufs: description of buffers displayed (input)
  122. * @custom_data_size: size of driver-private data (input)
  123. * @custom_data: driver-private data (input)
  124. * @complete_fence: sync_fence fd which will clear when this
  125. * configuration has left the screen (output)
  126. */
  127. struct adf_post_config {
  128. size_t n_interfaces;
  129. __u32 __user *interfaces;
  130. size_t n_bufs;
  131. struct adf_buffer_config __user *bufs;
  132. size_t custom_data_size;
  133. void __user *custom_data;
  134. __s32 complete_fence;
  135. };
  136. #define ADF_MAX_INTERFACES (4096 / sizeof(__u32))
  137. /**
  138. * struct adf_simple_buffer_allocate - request to allocate a "simple" buffer
  139. *
  140. * @w: width of buffer in pixels (input)
  141. * @h: height of buffer in pixels (input)
  142. * @format: DRM-style fourcc (input)
  143. *
  144. * @fd: dma_buf fd (output)
  145. * @offset: location of first pixel, in bytes (output)
  146. * @pitch: length of a scanline including padding, in bytes (output)
  147. *
  148. * Simple buffers are analogous to DRM's "dumb" buffers. They have a single
  149. * plane of linear RGB data which can be allocated and scanned out without
  150. * any driver-private ioctls or data.
  151. *
  152. * @format must be a standard RGB format defined in drm_fourcc.h.
  153. *
  154. * ADF clients must NOT assume that an interface can scan out a simple buffer
  155. * allocated by a different ADF interface, even if the two interfaces belong to
  156. * the same ADF device.
  157. */
  158. struct adf_simple_buffer_alloc {
  159. __u16 w;
  160. __u16 h;
  161. __u32 format;
  162. __s32 fd;
  163. __u32 offset;
  164. __u32 pitch;
  165. };
  166. /**
  167. * struct adf_simple_post_config - request to flip to a single buffer without
  168. * driver-private data
  169. *
  170. * @buf: description of buffer displayed (input)
  171. * @complete_fence: sync_fence fd which will clear when this buffer has left the
  172. * screen (output)
  173. */
  174. struct adf_simple_post_config {
  175. struct adf_buffer_config buf;
  176. __s32 complete_fence;
  177. };
  178. /**
  179. * struct adf_attachment_config - description of attachment between an overlay
  180. * engine and an interface
  181. *
  182. * @overlay_engine: id of the overlay engine
  183. * @interface: id of the interface
  184. */
  185. struct adf_attachment_config {
  186. __u32 overlay_engine;
  187. __u32 interface;
  188. };
  189. /**
  190. * struct adf_device_data - describes a display device
  191. *
  192. * @name: display device's name
  193. * @n_attachments: the number of current attachments
  194. * @attachments: list of current attachments
  195. * @n_allowed_attachments: the number of allowed attachments
  196. * @allowed_attachments: list of allowed attachments
  197. * @custom_data_size: size of driver-private data
  198. * @custom_data: driver-private data
  199. */
  200. struct adf_device_data {
  201. char name[ADF_NAME_LEN];
  202. size_t n_attachments;
  203. struct adf_attachment_config __user *attachments;
  204. size_t n_allowed_attachments;
  205. struct adf_attachment_config __user *allowed_attachments;
  206. size_t custom_data_size;
  207. void __user *custom_data;
  208. };
  209. #define ADF_MAX_ATTACHMENTS (4096 / sizeof(struct adf_attachment_config))
  210. /**
  211. * struct adf_device_data - describes a display interface
  212. *
  213. * @name: display interface's name
  214. * @type: interface type (see enum @adf_interface_type)
  215. * @id: which interface of type @type;
  216. * e.g. interface DSI.1 -> @type=@ADF_INTF_TYPE_DSI, @id=1
  217. * @flags: informational flags (bitmask of %ADF_INTF_FLAG_* values)
  218. * @dpms_state: DPMS state (one of @DRM_MODE_DPMS_* defined in drm_mode.h)
  219. * @hotplug_detect: whether a display is plugged in
  220. * @width_mm: screen width in millimeters, or 0 if unknown
  221. * @height_mm: screen height in millimeters, or 0 if unknown
  222. * @current_mode: current display mode
  223. * @n_available_modes: the number of hardware display modes
  224. * @available_modes: list of hardware display modes
  225. * @custom_data_size: size of driver-private data
  226. * @custom_data: driver-private data
  227. */
  228. struct adf_interface_data {
  229. char name[ADF_NAME_LEN];
  230. __u32 type;
  231. __u32 id;
  232. /* e.g. type=ADF_INTF_TYPE_DSI, id=1 => DSI.1 */
  233. __u32 flags;
  234. __u8 dpms_state;
  235. __u8 hotplug_detect;
  236. __u16 width_mm;
  237. __u16 height_mm;
  238. struct drm_mode_modeinfo current_mode;
  239. size_t n_available_modes;
  240. struct drm_mode_modeinfo __user *available_modes;
  241. size_t custom_data_size;
  242. void __user *custom_data;
  243. };
  244. #define ADF_MAX_MODES (4096 / sizeof(struct drm_mode_modeinfo))
  245. /**
  246. * struct adf_overlay_engine_data - describes an overlay engine
  247. *
  248. * @name: overlay engine's name
  249. * @n_supported_formats: number of supported formats
  250. * @supported_formats: list of supported formats
  251. * @custom_data_size: size of driver-private data
  252. * @custom_data: driver-private data
  253. */
  254. struct adf_overlay_engine_data {
  255. char name[ADF_NAME_LEN];
  256. size_t n_supported_formats;
  257. __u32 __user *supported_formats;
  258. size_t custom_data_size;
  259. void __user *custom_data;
  260. };
  261. #define ADF_MAX_SUPPORTED_FORMATS (4096 / sizeof(__u32))
  262. #define ADF_IOCTL_TYPE 'D'
  263. #define ADF_IOCTL_NR_CUSTOM 128
  264. #define ADF_SET_EVENT _IOW(ADF_IOCTL_TYPE, 0, struct adf_set_event)
  265. #define ADF_BLANK _IOW(ADF_IOCTL_TYPE, 1, __u8)
  266. #define ADF_POST_CONFIG _IOW(ADF_IOCTL_TYPE, 2, struct adf_post_config)
  267. #define ADF_SET_MODE _IOW(ADF_IOCTL_TYPE, 3, \
  268. struct drm_mode_modeinfo)
  269. #define ADF_GET_DEVICE_DATA _IOR(ADF_IOCTL_TYPE, 4, struct adf_device_data)
  270. #define ADF_GET_INTERFACE_DATA _IOR(ADF_IOCTL_TYPE, 5, \
  271. struct adf_interface_data)
  272. #define ADF_GET_OVERLAY_ENGINE_DATA \
  273. _IOR(ADF_IOCTL_TYPE, 6, \
  274. struct adf_overlay_engine_data)
  275. #define ADF_SIMPLE_POST_CONFIG _IOW(ADF_IOCTL_TYPE, 7, \
  276. struct adf_simple_post_config)
  277. #define ADF_SIMPLE_BUFFER_ALLOC _IOW(ADF_IOCTL_TYPE, 8, \
  278. struct adf_simple_buffer_alloc)
  279. #define ADF_ATTACH _IOW(ADF_IOCTL_TYPE, 9, \
  280. struct adf_attachment_config)
  281. #define ADF_DETACH _IOW(ADF_IOCTL_TYPE, 10, \
  282. struct adf_attachment_config)
  283. #endif /* _UAPI_VIDEO_ADF_H_ */