exynos_drm_ipp.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /*
  2. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  3. *
  4. * Authors:
  5. * Eunchul Kim <chulspro.kim@samsung.com>
  6. * Jinyoung Jeon <jy0.jeon@samsung.com>
  7. * Sangmin Lee <lsmin.lee@samsung.com>
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a
  10. * copy of this software and associated documentation files (the "Software"),
  11. * to deal in the Software without restriction, including without limitation
  12. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. * and/or sell copies of the Software, and to permit persons to whom the
  14. * Software is furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the next
  17. * paragraph) shall be included in all copies or substantial portions of the
  18. * Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  25. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. #ifndef _EXYNOS_DRM_IPP_H_
  29. #define _EXYNOS_DRM_IPP_H_
  30. #define for_each_ipp_ops(pos) \
  31. for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++)
  32. #define for_each_ipp_planar(pos) \
  33. for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++)
  34. #define IPP_GET_LCD_WIDTH _IOR('F', 302, int)
  35. #define IPP_GET_LCD_HEIGHT _IOR('F', 303, int)
  36. #define IPP_SET_WRITEBACK _IOW('F', 304, u32)
  37. /* definition of state */
  38. enum drm_exynos_ipp_state {
  39. IPP_STATE_IDLE,
  40. IPP_STATE_START,
  41. IPP_STATE_STOP,
  42. };
  43. /*
  44. * A structure of command work information.
  45. * @work: work structure.
  46. * @ippdrv: current work ippdrv.
  47. * @c_node: command node information.
  48. * @ctrl: command control.
  49. */
  50. struct drm_exynos_ipp_cmd_work {
  51. struct work_struct work;
  52. struct exynos_drm_ippdrv *ippdrv;
  53. struct drm_exynos_ipp_cmd_node *c_node;
  54. enum drm_exynos_ipp_ctrl ctrl;
  55. };
  56. /*
  57. * A structure of command node.
  58. *
  59. * @priv: IPP private infomation.
  60. * @list: list head to command queue information.
  61. * @event_list: list head of event.
  62. * @mem_list: list head to source,destination memory queue information.
  63. * @cmd_lock: lock for synchronization of access to ioctl.
  64. * @mem_lock: lock for synchronization of access to memory nodes.
  65. * @event_lock: lock for synchronization of access to scheduled event.
  66. * @start_complete: completion of start of command.
  67. * @stop_complete: completion of stop of command.
  68. * @property: property information.
  69. * @start_work: start command work structure.
  70. * @stop_work: stop command work structure.
  71. * @event_work: event work structure.
  72. * @state: state of command node.
  73. */
  74. struct drm_exynos_ipp_cmd_node {
  75. struct exynos_drm_ipp_private *priv;
  76. struct list_head list;
  77. struct list_head event_list;
  78. struct list_head mem_list[EXYNOS_DRM_OPS_MAX];
  79. struct mutex cmd_lock;
  80. struct mutex mem_lock;
  81. struct mutex event_lock;
  82. struct completion start_complete;
  83. struct completion stop_complete;
  84. struct drm_exynos_ipp_property property;
  85. struct drm_exynos_ipp_cmd_work *start_work;
  86. struct drm_exynos_ipp_cmd_work *stop_work;
  87. struct drm_exynos_ipp_event_work *event_work;
  88. enum drm_exynos_ipp_state state;
  89. };
  90. /*
  91. * A structure of buffer information.
  92. *
  93. * @gem_objs: Y, Cb, Cr each gem object.
  94. * @base: Y, Cb, Cr each planar address.
  95. */
  96. struct drm_exynos_ipp_buf_info {
  97. unsigned long handles[EXYNOS_DRM_PLANAR_MAX];
  98. dma_addr_t base[EXYNOS_DRM_PLANAR_MAX];
  99. };
  100. /*
  101. * A structure of wb setting infomation.
  102. *
  103. * @enable: enable flag for wb.
  104. * @refresh: HZ of the refresh rate.
  105. */
  106. struct drm_exynos_ipp_set_wb {
  107. __u32 enable;
  108. __u32 refresh;
  109. };
  110. /*
  111. * A structure of event work information.
  112. *
  113. * @work: work structure.
  114. * @ippdrv: current work ippdrv.
  115. * @buf_id: id of src, dst buffer.
  116. */
  117. struct drm_exynos_ipp_event_work {
  118. struct work_struct work;
  119. struct exynos_drm_ippdrv *ippdrv;
  120. u32 buf_id[EXYNOS_DRM_OPS_MAX];
  121. };
  122. /*
  123. * A structure of source,destination operations.
  124. *
  125. * @set_fmt: set format of image.
  126. * @set_transf: set transform(rotations, flip).
  127. * @set_size: set size of region.
  128. * @set_addr: set address for dma.
  129. */
  130. struct exynos_drm_ipp_ops {
  131. int (*set_fmt)(struct device *dev, u32 fmt);
  132. int (*set_transf)(struct device *dev,
  133. enum drm_exynos_degree degree,
  134. enum drm_exynos_flip flip, bool *swap);
  135. int (*set_size)(struct device *dev, int swap,
  136. struct drm_exynos_pos *pos, struct drm_exynos_sz *sz);
  137. int (*set_addr)(struct device *dev,
  138. struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
  139. enum drm_exynos_ipp_buf_type buf_type);
  140. };
  141. /*
  142. * A structure of ipp driver.
  143. *
  144. * @drv_list: list head for registed sub driver information.
  145. * @parent_dev: parent device information.
  146. * @dev: platform device.
  147. * @drm_dev: drm device.
  148. * @ipp_id: id of ipp driver.
  149. * @dedicated: dedicated ipp device.
  150. * @ops: source, destination operations.
  151. * @event_workq: event work queue.
  152. * @cmd: current command information.
  153. * @cmd_list: list head for command information.
  154. * @prop_list: property informations of current ipp driver.
  155. * @check_property: check property about format, size, buffer.
  156. * @reset: reset ipp block.
  157. * @start: ipp each device start.
  158. * @stop: ipp each device stop.
  159. * @sched_event: work schedule handler.
  160. */
  161. struct exynos_drm_ippdrv {
  162. struct list_head drv_list;
  163. struct device *parent_dev;
  164. struct device *dev;
  165. struct drm_device *drm_dev;
  166. u32 ipp_id;
  167. bool dedicated;
  168. struct exynos_drm_ipp_ops *ops[EXYNOS_DRM_OPS_MAX];
  169. struct workqueue_struct *event_workq;
  170. struct drm_exynos_ipp_cmd_node *cmd;
  171. struct list_head cmd_list;
  172. struct drm_exynos_ipp_prop_list *prop_list;
  173. int (*check_property)(struct device *dev,
  174. struct drm_exynos_ipp_property *property);
  175. int (*reset)(struct device *dev);
  176. int (*start)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
  177. void (*stop)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
  178. void (*sched_event)(struct work_struct *work);
  179. };
  180. #ifdef CONFIG_DRM_EXYNOS_IPP
  181. extern int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv);
  182. extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv);
  183. extern int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
  184. struct drm_file *file);
  185. extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
  186. struct drm_file *file);
  187. extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
  188. struct drm_file *file);
  189. extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
  190. struct drm_file *file);
  191. extern int exynos_drm_ippnb_register(struct notifier_block *nb);
  192. extern int exynos_drm_ippnb_unregister(struct notifier_block *nb);
  193. extern int exynos_drm_ippnb_send_event(unsigned long val, void *v);
  194. extern void ipp_sched_cmd(struct work_struct *work);
  195. extern void ipp_sched_event(struct work_struct *work);
  196. #else
  197. static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv)
  198. {
  199. return -ENODEV;
  200. }
  201. static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv)
  202. {
  203. return -ENODEV;
  204. }
  205. static inline int exynos_drm_ipp_get_property(struct drm_device *drm_dev,
  206. void *data,
  207. struct drm_file *file_priv)
  208. {
  209. return -ENOTTY;
  210. }
  211. static inline int exynos_drm_ipp_set_property(struct drm_device *drm_dev,
  212. void *data,
  213. struct drm_file *file_priv)
  214. {
  215. return -ENOTTY;
  216. }
  217. static inline int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev,
  218. void *data,
  219. struct drm_file *file)
  220. {
  221. return -ENOTTY;
  222. }
  223. static inline int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev,
  224. void *data,
  225. struct drm_file *file)
  226. {
  227. return -ENOTTY;
  228. }
  229. static inline int exynos_drm_ippnb_register(struct notifier_block *nb)
  230. {
  231. return -ENODEV;
  232. }
  233. static inline int exynos_drm_ippnb_unregister(struct notifier_block *nb)
  234. {
  235. return -ENODEV;
  236. }
  237. static inline int exynos_drm_ippnb_send_event(unsigned long val, void *v)
  238. {
  239. return -ENOTTY;
  240. }
  241. #endif
  242. #endif /* _EXYNOS_DRM_IPP_H_ */