exynos_drm_ipp.h 4.8 KB

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