exynos_drm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /* exynos_drm.h
  3. *
  4. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5. * Authors:
  6. * Inki Dae <inki.dae@samsung.com>
  7. * Joonyoung Shim <jy0922.shim@samsung.com>
  8. * Seung-Woo Kim <sw0312.kim@samsung.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #ifndef _EXYNOS_DRM_H_
  16. #define _EXYNOS_DRM_H_
  17. #include "drm.h"
  18. #if defined(__cplusplus)
  19. extern "C" {
  20. #endif
  21. /**
  22. * User-desired buffer creation information structure.
  23. *
  24. * @size: user-desired memory allocation size.
  25. * - this size value would be page-aligned internally.
  26. * @flags: user request for setting memory type or cache attributes.
  27. * @handle: returned a handle to created gem object.
  28. * - this handle will be set by gem module of kernel side.
  29. */
  30. struct drm_exynos_gem_create {
  31. __u64 size;
  32. __u32 flags;
  33. __u32 handle;
  34. };
  35. /**
  36. * A structure for getting a fake-offset that can be used with mmap.
  37. *
  38. * @handle: handle of gem object.
  39. * @reserved: just padding to be 64-bit aligned.
  40. * @offset: a fake-offset of gem object.
  41. */
  42. struct drm_exynos_gem_map {
  43. __u32 handle;
  44. __u32 reserved;
  45. __u64 offset;
  46. };
  47. /**
  48. * A structure to gem information.
  49. *
  50. * @handle: a handle to gem object created.
  51. * @flags: flag value including memory type and cache attribute and
  52. * this value would be set by driver.
  53. * @size: size to memory region allocated by gem and this size would
  54. * be set by driver.
  55. */
  56. struct drm_exynos_gem_info {
  57. __u32 handle;
  58. __u32 flags;
  59. __u64 size;
  60. };
  61. /**
  62. * A structure for user connection request of virtual display.
  63. *
  64. * @connection: indicate whether doing connection or not by user.
  65. * @extensions: if this value is 1 then the vidi driver would need additional
  66. * 128bytes edid data.
  67. * @edid: the edid data pointer from user side.
  68. */
  69. struct drm_exynos_vidi_connection {
  70. __u32 connection;
  71. __u32 extensions;
  72. __u64 edid;
  73. };
  74. /* memory type definitions. */
  75. enum e_drm_exynos_gem_mem_type {
  76. /* Physically Continuous memory and used as default. */
  77. EXYNOS_BO_CONTIG = 0 << 0,
  78. /* Physically Non-Continuous memory. */
  79. EXYNOS_BO_NONCONTIG = 1 << 0,
  80. /* non-cachable mapping and used as default. */
  81. EXYNOS_BO_NONCACHABLE = 0 << 1,
  82. /* cachable mapping. */
  83. EXYNOS_BO_CACHABLE = 1 << 1,
  84. /* write-combine mapping. */
  85. EXYNOS_BO_WC = 1 << 2,
  86. EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE |
  87. EXYNOS_BO_WC
  88. };
  89. struct drm_exynos_g2d_get_ver {
  90. __u32 major;
  91. __u32 minor;
  92. };
  93. struct drm_exynos_g2d_cmd {
  94. __u32 offset;
  95. __u32 data;
  96. };
  97. enum drm_exynos_g2d_buf_type {
  98. G2D_BUF_USERPTR = 1 << 31,
  99. };
  100. enum drm_exynos_g2d_event_type {
  101. G2D_EVENT_NOT,
  102. G2D_EVENT_NONSTOP,
  103. G2D_EVENT_STOP, /* not yet */
  104. };
  105. struct drm_exynos_g2d_userptr {
  106. unsigned long userptr;
  107. unsigned long size;
  108. };
  109. struct drm_exynos_g2d_set_cmdlist {
  110. __u64 cmd;
  111. __u64 cmd_buf;
  112. __u32 cmd_nr;
  113. __u32 cmd_buf_nr;
  114. /* for g2d event */
  115. __u64 event_type;
  116. __u64 user_data;
  117. };
  118. struct drm_exynos_g2d_exec {
  119. __u64 async;
  120. };
  121. /* Exynos DRM IPP v2 API */
  122. /**
  123. * Enumerate available IPP hardware modules.
  124. *
  125. * @count_ipps: size of ipp_id array / number of ipp modules (set by driver)
  126. * @reserved: padding
  127. * @ipp_id_ptr: pointer to ipp_id array or NULL
  128. */
  129. struct drm_exynos_ioctl_ipp_get_res {
  130. __u32 count_ipps;
  131. __u32 reserved;
  132. __u64 ipp_id_ptr;
  133. };
  134. enum drm_exynos_ipp_format_type {
  135. DRM_EXYNOS_IPP_FORMAT_SOURCE = 0x01,
  136. DRM_EXYNOS_IPP_FORMAT_DESTINATION = 0x02,
  137. };
  138. struct drm_exynos_ipp_format {
  139. __u32 fourcc;
  140. __u32 type;
  141. __u64 modifier;
  142. };
  143. enum drm_exynos_ipp_capability {
  144. DRM_EXYNOS_IPP_CAP_CROP = 0x01,
  145. DRM_EXYNOS_IPP_CAP_ROTATE = 0x02,
  146. DRM_EXYNOS_IPP_CAP_SCALE = 0x04,
  147. DRM_EXYNOS_IPP_CAP_CONVERT = 0x08,
  148. };
  149. /**
  150. * Get IPP hardware capabilities and supported image formats.
  151. *
  152. * @ipp_id: id of IPP module to query
  153. * @capabilities: bitmask of drm_exynos_ipp_capability (set by driver)
  154. * @reserved: padding
  155. * @formats_count: size of formats array (in entries) / number of filled
  156. * formats (set by driver)
  157. * @formats_ptr: pointer to formats array or NULL
  158. */
  159. struct drm_exynos_ioctl_ipp_get_caps {
  160. __u32 ipp_id;
  161. __u32 capabilities;
  162. __u32 reserved;
  163. __u32 formats_count;
  164. __u64 formats_ptr;
  165. };
  166. enum drm_exynos_ipp_limit_type {
  167. /* size (horizontal/vertial) limits, in pixels (min, max, alignment) */
  168. DRM_EXYNOS_IPP_LIMIT_TYPE_SIZE = 0x0001,
  169. /* scale ratio (horizonta/vertial), 16.16 fixed point (min, max) */
  170. DRM_EXYNOS_IPP_LIMIT_TYPE_SCALE = 0x0002,
  171. /* image buffer area */
  172. DRM_EXYNOS_IPP_LIMIT_SIZE_BUFFER = 0x0001 << 16,
  173. /* src/dst rectangle area */
  174. DRM_EXYNOS_IPP_LIMIT_SIZE_AREA = 0x0002 << 16,
  175. /* src/dst rectangle area when rotation enabled */
  176. DRM_EXYNOS_IPP_LIMIT_SIZE_ROTATED = 0x0003 << 16,
  177. DRM_EXYNOS_IPP_LIMIT_TYPE_MASK = 0x000f,
  178. DRM_EXYNOS_IPP_LIMIT_SIZE_MASK = 0x000f << 16,
  179. };
  180. struct drm_exynos_ipp_limit_val {
  181. __u32 min;
  182. __u32 max;
  183. __u32 align;
  184. __u32 reserved;
  185. };
  186. /**
  187. * IPP module limitation.
  188. *
  189. * @type: limit type (see drm_exynos_ipp_limit_type enum)
  190. * @reserved: padding
  191. * @h: horizontal limits
  192. * @v: vertical limits
  193. */
  194. struct drm_exynos_ipp_limit {
  195. __u32 type;
  196. __u32 reserved;
  197. struct drm_exynos_ipp_limit_val h;
  198. struct drm_exynos_ipp_limit_val v;
  199. };
  200. /**
  201. * Get IPP limits for given image format.
  202. *
  203. * @ipp_id: id of IPP module to query
  204. * @fourcc: image format code (see DRM_FORMAT_* in drm_fourcc.h)
  205. * @modifier: image format modifier (see DRM_FORMAT_MOD_* in drm_fourcc.h)
  206. * @type: source/destination identifier (drm_exynos_ipp_format_flag enum)
  207. * @limits_count: size of limits array (in entries) / number of filled entries
  208. * (set by driver)
  209. * @limits_ptr: pointer to limits array or NULL
  210. */
  211. struct drm_exynos_ioctl_ipp_get_limits {
  212. __u32 ipp_id;
  213. __u32 fourcc;
  214. __u64 modifier;
  215. __u32 type;
  216. __u32 limits_count;
  217. __u64 limits_ptr;
  218. };
  219. enum drm_exynos_ipp_task_id {
  220. /* buffer described by struct drm_exynos_ipp_task_buffer */
  221. DRM_EXYNOS_IPP_TASK_BUFFER = 0x0001,
  222. /* rectangle described by struct drm_exynos_ipp_task_rect */
  223. DRM_EXYNOS_IPP_TASK_RECTANGLE = 0x0002,
  224. /* transformation described by struct drm_exynos_ipp_task_transform */
  225. DRM_EXYNOS_IPP_TASK_TRANSFORM = 0x0003,
  226. /* alpha configuration described by struct drm_exynos_ipp_task_alpha */
  227. DRM_EXYNOS_IPP_TASK_ALPHA = 0x0004,
  228. /* source image data (for buffer and rectangle chunks) */
  229. DRM_EXYNOS_IPP_TASK_TYPE_SOURCE = 0x0001 << 16,
  230. /* destination image data (for buffer and rectangle chunks) */
  231. DRM_EXYNOS_IPP_TASK_TYPE_DESTINATION = 0x0002 << 16,
  232. };
  233. /**
  234. * Memory buffer with image data.
  235. *
  236. * @id: must be DRM_EXYNOS_IPP_TASK_BUFFER
  237. * other parameters are same as for AddFB2 generic DRM ioctl
  238. */
  239. struct drm_exynos_ipp_task_buffer {
  240. __u32 id;
  241. __u32 fourcc;
  242. __u32 width, height;
  243. __u32 gem_id[4];
  244. __u32 offset[4];
  245. __u32 pitch[4];
  246. __u64 modifier;
  247. };
  248. /**
  249. * Rectangle for processing.
  250. *
  251. * @id: must be DRM_EXYNOS_IPP_TASK_RECTANGLE
  252. * @reserved: padding
  253. * @x,@y: left corner in pixels
  254. * @w,@h: width/height in pixels
  255. */
  256. struct drm_exynos_ipp_task_rect {
  257. __u32 id;
  258. __u32 reserved;
  259. __u32 x;
  260. __u32 y;
  261. __u32 w;
  262. __u32 h;
  263. };
  264. /**
  265. * Image tranformation description.
  266. *
  267. * @id: must be DRM_EXYNOS_IPP_TASK_TRANSFORM
  268. * @rotation: DRM_MODE_ROTATE_* and DRM_MODE_REFLECT_* values
  269. */
  270. struct drm_exynos_ipp_task_transform {
  271. __u32 id;
  272. __u32 rotation;
  273. };
  274. /**
  275. * Image global alpha configuration for formats without alpha values.
  276. *
  277. * @id: must be DRM_EXYNOS_IPP_TASK_ALPHA
  278. * @value: global alpha value (0-255)
  279. */
  280. struct drm_exynos_ipp_task_alpha {
  281. __u32 id;
  282. __u32 value;
  283. };
  284. enum drm_exynos_ipp_flag {
  285. /* generate DRM event after processing */
  286. DRM_EXYNOS_IPP_FLAG_EVENT = 0x01,
  287. /* dry run, only check task parameters */
  288. DRM_EXYNOS_IPP_FLAG_TEST_ONLY = 0x02,
  289. /* non-blocking processing */
  290. DRM_EXYNOS_IPP_FLAG_NONBLOCK = 0x04,
  291. };
  292. #define DRM_EXYNOS_IPP_FLAGS (DRM_EXYNOS_IPP_FLAG_EVENT |\
  293. DRM_EXYNOS_IPP_FLAG_TEST_ONLY | DRM_EXYNOS_IPP_FLAG_NONBLOCK)
  294. /**
  295. * Perform image processing described by array of drm_exynos_ipp_task_*
  296. * structures (parameters array).
  297. *
  298. * @ipp_id: id of IPP module to run the task
  299. * @flags: bitmask of drm_exynos_ipp_flag values
  300. * @reserved: padding
  301. * @params_size: size of parameters array (in bytes)
  302. * @params_ptr: pointer to parameters array or NULL
  303. * @user_data: (optional) data for drm event
  304. */
  305. struct drm_exynos_ioctl_ipp_commit {
  306. __u32 ipp_id;
  307. __u32 flags;
  308. __u32 reserved;
  309. __u32 params_size;
  310. __u64 params_ptr;
  311. __u64 user_data;
  312. };
  313. #define DRM_EXYNOS_GEM_CREATE 0x00
  314. #define DRM_EXYNOS_GEM_MAP 0x01
  315. /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
  316. #define DRM_EXYNOS_GEM_GET 0x04
  317. #define DRM_EXYNOS_VIDI_CONNECTION 0x07
  318. /* G2D */
  319. #define DRM_EXYNOS_G2D_GET_VER 0x20
  320. #define DRM_EXYNOS_G2D_SET_CMDLIST 0x21
  321. #define DRM_EXYNOS_G2D_EXEC 0x22
  322. /* Reserved 0x30 ~ 0x33 for obsolete Exynos IPP ioctls */
  323. /* IPP - Image Post Processing */
  324. #define DRM_EXYNOS_IPP_GET_RESOURCES 0x40
  325. #define DRM_EXYNOS_IPP_GET_CAPS 0x41
  326. #define DRM_EXYNOS_IPP_GET_LIMITS 0x42
  327. #define DRM_EXYNOS_IPP_COMMIT 0x43
  328. #define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \
  329. DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
  330. #define DRM_IOCTL_EXYNOS_GEM_MAP DRM_IOWR(DRM_COMMAND_BASE + \
  331. DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
  332. #define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \
  333. DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
  334. #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \
  335. DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)
  336. #define DRM_IOCTL_EXYNOS_G2D_GET_VER DRM_IOWR(DRM_COMMAND_BASE + \
  337. DRM_EXYNOS_G2D_GET_VER, struct drm_exynos_g2d_get_ver)
  338. #define DRM_IOCTL_EXYNOS_G2D_SET_CMDLIST DRM_IOWR(DRM_COMMAND_BASE + \
  339. DRM_EXYNOS_G2D_SET_CMDLIST, struct drm_exynos_g2d_set_cmdlist)
  340. #define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \
  341. DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
  342. #define DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES DRM_IOWR(DRM_COMMAND_BASE + \
  343. DRM_EXYNOS_IPP_GET_RESOURCES, \
  344. struct drm_exynos_ioctl_ipp_get_res)
  345. #define DRM_IOCTL_EXYNOS_IPP_GET_CAPS DRM_IOWR(DRM_COMMAND_BASE + \
  346. DRM_EXYNOS_IPP_GET_CAPS, struct drm_exynos_ioctl_ipp_get_caps)
  347. #define DRM_IOCTL_EXYNOS_IPP_GET_LIMITS DRM_IOWR(DRM_COMMAND_BASE + \
  348. DRM_EXYNOS_IPP_GET_LIMITS, \
  349. struct drm_exynos_ioctl_ipp_get_limits)
  350. #define DRM_IOCTL_EXYNOS_IPP_COMMIT DRM_IOWR(DRM_COMMAND_BASE + \
  351. DRM_EXYNOS_IPP_COMMIT, struct drm_exynos_ioctl_ipp_commit)
  352. /* Exynos specific events */
  353. #define DRM_EXYNOS_G2D_EVENT 0x80000000
  354. #define DRM_EXYNOS_IPP_EVENT 0x80000002
  355. struct drm_exynos_g2d_event {
  356. struct drm_event base;
  357. __u64 user_data;
  358. __u32 tv_sec;
  359. __u32 tv_usec;
  360. __u32 cmdlist_no;
  361. __u32 reserved;
  362. };
  363. struct drm_exynos_ipp_event {
  364. struct drm_event base;
  365. __u64 user_data;
  366. __u32 tv_sec;
  367. __u32 tv_usec;
  368. __u32 ipp_id;
  369. __u32 sequence;
  370. __u64 reserved;
  371. };
  372. #if defined(__cplusplus)
  373. }
  374. #endif
  375. #endif /* _EXYNOS_DRM_H_ */