exynos_drm_ipp.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #ifndef _EXYNOS_DRM_IPP_H_
  10. #define _EXYNOS_DRM_IPP_H_
  11. #include <drm/drmP.h>
  12. struct exynos_drm_ipp;
  13. struct exynos_drm_ipp_task;
  14. /**
  15. * struct exynos_drm_ipp_funcs - exynos_drm_ipp control functions
  16. */
  17. struct exynos_drm_ipp_funcs {
  18. /**
  19. * @commit:
  20. *
  21. * This is the main entry point to start framebuffer processing
  22. * in the hardware. The exynos_drm_ipp_task has been already validated.
  23. * This function must not wait until the device finishes processing.
  24. * When the driver finishes processing, it has to call
  25. * exynos_exynos_drm_ipp_task_done() function.
  26. *
  27. * RETURNS:
  28. *
  29. * 0 on success or negative error codes in case of failure.
  30. */
  31. int (*commit)(struct exynos_drm_ipp *ipp,
  32. struct exynos_drm_ipp_task *task);
  33. /**
  34. * @abort:
  35. *
  36. * Informs the driver that it has to abort the currently running
  37. * task as soon as possible (i.e. as soon as it can stop the device
  38. * safely), even if the task would not have been finished by then.
  39. * After the driver performs the necessary steps, it has to call
  40. * exynos_drm_ipp_task_done() (as if the task ended normally).
  41. * This function does not have to (and will usually not) wait
  42. * until the device enters a state when it can be stopped.
  43. */
  44. void (*abort)(struct exynos_drm_ipp *ipp,
  45. struct exynos_drm_ipp_task *task);
  46. };
  47. /**
  48. * struct exynos_drm_ipp - central picture processor module structure
  49. */
  50. struct exynos_drm_ipp {
  51. struct drm_device *dev;
  52. struct list_head head;
  53. unsigned int id;
  54. const char *name;
  55. const struct exynos_drm_ipp_funcs *funcs;
  56. unsigned int capabilities;
  57. const struct exynos_drm_ipp_formats *formats;
  58. unsigned int num_formats;
  59. atomic_t sequence;
  60. spinlock_t lock;
  61. struct exynos_drm_ipp_task *task;
  62. struct list_head todo_list;
  63. wait_queue_head_t done_wq;
  64. };
  65. struct exynos_drm_ipp_buffer {
  66. struct drm_exynos_ipp_task_buffer buf;
  67. struct drm_exynos_ipp_task_rect rect;
  68. struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
  69. const struct drm_format_info *format;
  70. dma_addr_t dma_addr[MAX_FB_BUFFER];
  71. };
  72. /**
  73. * struct exynos_drm_ipp_task - a structure describing transformation that
  74. * has to be performed by the picture processor hardware module
  75. */
  76. struct exynos_drm_ipp_task {
  77. struct drm_device *dev;
  78. struct exynos_drm_ipp *ipp;
  79. struct list_head head;
  80. struct exynos_drm_ipp_buffer src;
  81. struct exynos_drm_ipp_buffer dst;
  82. struct drm_exynos_ipp_task_transform transform;
  83. struct drm_exynos_ipp_task_alpha alpha;
  84. struct work_struct cleanup_work;
  85. unsigned int flags;
  86. int ret;
  87. struct drm_pending_exynos_ipp_event *event;
  88. };
  89. #define DRM_EXYNOS_IPP_TASK_DONE (1 << 0)
  90. #define DRM_EXYNOS_IPP_TASK_ASYNC (1 << 1)
  91. struct exynos_drm_ipp_formats {
  92. uint32_t fourcc;
  93. uint32_t type;
  94. uint64_t modifier;
  95. const struct drm_exynos_ipp_limit *limits;
  96. unsigned int num_limits;
  97. };
  98. /* helper macros to set exynos_drm_ipp_formats structure and limits*/
  99. #define IPP_SRCDST_MFORMAT(f, m, l) \
  100. .fourcc = DRM_FORMAT_##f, .modifier = m, .limits = l, \
  101. .num_limits = ARRAY_SIZE(l), \
  102. .type = (DRM_EXYNOS_IPP_FORMAT_SOURCE | \
  103. DRM_EXYNOS_IPP_FORMAT_DESTINATION)
  104. #define IPP_SRCDST_FORMAT(f, l) IPP_SRCDST_MFORMAT(f, 0, l)
  105. #define IPP_SIZE_LIMIT(l, val...) \
  106. .type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SIZE | \
  107. DRM_EXYNOS_IPP_LIMIT_SIZE_##l), val
  108. #define IPP_SCALE_LIMIT(val...) \
  109. .type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SCALE), val
  110. int exynos_drm_ipp_register(struct drm_device *dev, struct exynos_drm_ipp *ipp,
  111. const struct exynos_drm_ipp_funcs *funcs, unsigned int caps,
  112. const struct exynos_drm_ipp_formats *formats,
  113. unsigned int num_formats, const char *name);
  114. void exynos_drm_ipp_unregister(struct drm_device *dev,
  115. struct exynos_drm_ipp *ipp);
  116. void exynos_drm_ipp_task_done(struct exynos_drm_ipp_task *task, int ret);
  117. #ifdef CONFIG_DRM_EXYNOS_IPP
  118. int exynos_drm_ipp_get_res_ioctl(struct drm_device *dev, void *data,
  119. struct drm_file *file_priv);
  120. int exynos_drm_ipp_get_caps_ioctl(struct drm_device *dev, void *data,
  121. struct drm_file *file_priv);
  122. int exynos_drm_ipp_get_limits_ioctl(struct drm_device *dev, void *data,
  123. struct drm_file *file_priv);
  124. int exynos_drm_ipp_commit_ioctl(struct drm_device *dev,
  125. void *data, struct drm_file *file_priv);
  126. #else
  127. static inline int exynos_drm_ipp_get_res_ioctl(struct drm_device *dev,
  128. void *data, struct drm_file *file_priv)
  129. {
  130. struct drm_exynos_ioctl_ipp_get_res *resp = data;
  131. resp->count_ipps = 0;
  132. return 0;
  133. }
  134. static inline int exynos_drm_ipp_get_caps_ioctl(struct drm_device *dev,
  135. void *data, struct drm_file *file_priv)
  136. {
  137. return -ENODEV;
  138. }
  139. static inline int exynos_drm_ipp_get_limits_ioctl(struct drm_device *dev,
  140. void *data, struct drm_file *file_priv)
  141. {
  142. return -ENODEV;
  143. }
  144. static inline int exynos_drm_ipp_commit_ioctl(struct drm_device *dev,
  145. void *data, struct drm_file *file_priv)
  146. {
  147. return -ENODEV;
  148. }
  149. #endif
  150. #endif