Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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