imx-ipu-image-convert.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2012-2016 Mentor Graphics Inc.
  4. *
  5. * i.MX Queued image conversion support, with tiling and rotation.
  6. */
  7. #ifndef __IMX_IPU_IMAGE_CONVERT_H__
  8. #define __IMX_IPU_IMAGE_CONVERT_H__
  9. #include <video/imx-ipu-v3.h>
  10. struct ipu_image_convert_ctx;
  11. /**
  12. * struct ipu_image_convert_run - image conversion run request struct
  13. *
  14. * @ctx: the conversion context
  15. * @in_phys: dma addr of input image buffer for this run
  16. * @out_phys: dma addr of output image buffer for this run
  17. * @status: completion status of this run
  18. */
  19. struct ipu_image_convert_run {
  20. struct ipu_image_convert_ctx *ctx;
  21. dma_addr_t in_phys;
  22. dma_addr_t out_phys;
  23. int status;
  24. /* internal to image converter, callers don't touch */
  25. struct list_head list;
  26. };
  27. /**
  28. * ipu_image_convert_cb_t - conversion callback function prototype
  29. *
  30. * @run: the completed conversion run pointer
  31. * @ctx: a private context pointer for the callback
  32. */
  33. typedef void (*ipu_image_convert_cb_t)(struct ipu_image_convert_run *run,
  34. void *ctx);
  35. /**
  36. * ipu_image_convert_adjust() - adjust input/output images to IPU restrictions.
  37. *
  38. * @in: input image format, adjusted on return
  39. * @out: output image format, adjusted on return
  40. * @rot_mode: rotation mode
  41. *
  42. * In V4L2, drivers can call ipu_image_convert_adjust() in .try_fmt.
  43. */
  44. void ipu_image_convert_adjust(struct ipu_image *in, struct ipu_image *out,
  45. enum ipu_rotate_mode rot_mode);
  46. /**
  47. * ipu_image_convert_verify() - verify that input/output image formats
  48. * and rotation mode meet IPU restrictions.
  49. *
  50. * @in: input image format
  51. * @out: output image format
  52. * @rot_mode: rotation mode
  53. *
  54. * Returns 0 if the formats and rotation mode meet IPU restrictions,
  55. * -EINVAL otherwise.
  56. */
  57. int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out,
  58. enum ipu_rotate_mode rot_mode);
  59. /**
  60. * ipu_image_convert_prepare() - prepare a conversion context.
  61. *
  62. * @ipu: the IPU handle to use for the conversions
  63. * @ic_task: the IC task to use for the conversions
  64. * @in: input image format
  65. * @out: output image format
  66. * @rot_mode: rotation mode
  67. * @complete: run completion callback
  68. * @complete_context: a context pointer for the completion callback
  69. *
  70. * Returns an opaque conversion context pointer on success, error pointer
  71. * on failure. The input/output formats and rotation mode must already meet
  72. * IPU retrictions.
  73. *
  74. * In V4L2, drivers should call ipu_image_convert_prepare() at streamon.
  75. */
  76. struct ipu_image_convert_ctx *
  77. ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
  78. struct ipu_image *in, struct ipu_image *out,
  79. enum ipu_rotate_mode rot_mode,
  80. ipu_image_convert_cb_t complete,
  81. void *complete_context);
  82. /**
  83. * ipu_image_convert_unprepare() - unprepare a conversion context.
  84. *
  85. * @ctx: the conversion context pointer to unprepare
  86. *
  87. * Aborts any active or pending conversions for this context and
  88. * frees the context. Any currently active or pending runs belonging
  89. * to this context are returned via the completion callback with an
  90. * error run status.
  91. *
  92. * In V4L2, drivers should call ipu_image_convert_unprepare() at
  93. * streamoff.
  94. */
  95. void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx);
  96. /**
  97. * ipu_image_convert_queue() - queue a conversion run
  98. *
  99. * @run: the run request pointer
  100. *
  101. * ipu_image_convert_run must be dynamically allocated (_not_ as a local
  102. * var) by callers and filled in with a previously prepared conversion
  103. * context handle and the dma addr's of the input and output image buffers
  104. * for this conversion run.
  105. *
  106. * When this conversion completes, the run pointer is returned via the
  107. * completion callback. The caller is responsible for freeing the run
  108. * object after it completes.
  109. *
  110. * In V4L2, drivers should call ipu_image_convert_queue() while
  111. * streaming to queue the conversion of a received input buffer.
  112. * For example mem2mem devices this would be called in .device_run.
  113. */
  114. int ipu_image_convert_queue(struct ipu_image_convert_run *run);
  115. /**
  116. * ipu_image_convert_abort() - abort conversions
  117. *
  118. * @ctx: the conversion context pointer
  119. *
  120. * This will abort any active or pending conversions for this context.
  121. * Any currently active or pending runs belonging to this context are
  122. * returned via the completion callback with an error run status.
  123. */
  124. void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx);
  125. /**
  126. * ipu_image_convert() - asynchronous image conversion request
  127. *
  128. * @ipu: the IPU handle to use for the conversion
  129. * @ic_task: the IC task to use for the conversion
  130. * @in: input image format
  131. * @out: output image format
  132. * @rot_mode: rotation mode
  133. * @complete: run completion callback
  134. * @complete_context: a context pointer for the completion callback
  135. *
  136. * Request a single image conversion. Returns the run that has been queued.
  137. * A conversion context is automatically created and is available in run->ctx.
  138. * As with ipu_image_convert_prepare(), the input/output formats and rotation
  139. * mode must already meet IPU retrictions.
  140. *
  141. * On successful return the caller can queue more run requests if needed, using
  142. * the prepared context in run->ctx. The caller is responsible for unpreparing
  143. * the context when no more conversion requests are needed.
  144. */
  145. struct ipu_image_convert_run *
  146. ipu_image_convert(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
  147. struct ipu_image *in, struct ipu_image *out,
  148. enum ipu_rotate_mode rot_mode,
  149. ipu_image_convert_cb_t complete,
  150. void *complete_context);
  151. #endif /* __IMX_IPU_IMAGE_CONVERT_H__ */