Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2012-2016 Mentor Graphics Inc.
0004  *
0005  * i.MX Queued image conversion support, with tiling and rotation.
0006  */
0007 #ifndef __IMX_IPU_IMAGE_CONVERT_H__
0008 #define __IMX_IPU_IMAGE_CONVERT_H__
0009 
0010 #include <video/imx-ipu-v3.h>
0011 
0012 struct ipu_image_convert_ctx;
0013 
0014 /**
0015  * struct ipu_image_convert_run - image conversion run request struct
0016  *
0017  * @ctx:    the conversion context
0018  * @in_phys:    dma addr of input image buffer for this run
0019  * @out_phys:   dma addr of output image buffer for this run
0020  * @status: completion status of this run
0021  */
0022 struct ipu_image_convert_run {
0023     struct ipu_image_convert_ctx *ctx;
0024 
0025     dma_addr_t in_phys;
0026     dma_addr_t out_phys;
0027 
0028     int status;
0029 
0030     /* internal to image converter, callers don't touch */
0031     struct list_head list;
0032 };
0033 
0034 /**
0035  * ipu_image_convert_cb_t - conversion callback function prototype
0036  *
0037  * @run:    the completed conversion run pointer
0038  * @ctx:    a private context pointer for the callback
0039  */
0040 typedef void (*ipu_image_convert_cb_t)(struct ipu_image_convert_run *run,
0041                        void *ctx);
0042 
0043 /**
0044  * ipu_image_convert_enum_format() - enumerate the image converter's
0045  *  supported input and output pixel formats.
0046  *
0047  * @index:  pixel format index
0048  * @fourcc: v4l2 fourcc for this index
0049  *
0050  * Returns 0 with a valid index and fills in v4l2 fourcc, -EINVAL otherwise.
0051  *
0052  * In V4L2, drivers can call ipu_image_enum_format() in .enum_fmt.
0053  */
0054 int ipu_image_convert_enum_format(int index, u32 *fourcc);
0055 
0056 /**
0057  * ipu_image_convert_adjust() - adjust input/output images to IPU restrictions.
0058  *
0059  * @in:     input image format, adjusted on return
0060  * @out:    output image format, adjusted on return
0061  * @rot_mode:   rotation mode
0062  *
0063  * In V4L2, drivers can call ipu_image_convert_adjust() in .try_fmt.
0064  */
0065 void ipu_image_convert_adjust(struct ipu_image *in, struct ipu_image *out,
0066                   enum ipu_rotate_mode rot_mode);
0067 
0068 /**
0069  * ipu_image_convert_verify() - verify that input/output image formats
0070  *         and rotation mode meet IPU restrictions.
0071  *
0072  * @in:     input image format
0073  * @out:    output image format
0074  * @rot_mode:   rotation mode
0075  *
0076  * Returns 0 if the formats and rotation mode meet IPU restrictions,
0077  * -EINVAL otherwise.
0078  */
0079 int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out,
0080                  enum ipu_rotate_mode rot_mode);
0081 
0082 /**
0083  * ipu_image_convert_prepare() - prepare a conversion context.
0084  *
0085  * @ipu:    the IPU handle to use for the conversions
0086  * @ic_task:    the IC task to use for the conversions
0087  * @in:     input image format
0088  * @out:    output image format
0089  * @rot_mode:   rotation mode
0090  * @complete:   run completion callback
0091  * @complete_context:   a context pointer for the completion callback
0092  *
0093  * Returns an opaque conversion context pointer on success, error pointer
0094  * on failure. The input/output formats and rotation mode must already meet
0095  * IPU retrictions.
0096  *
0097  * In V4L2, drivers should call ipu_image_convert_prepare() at streamon.
0098  */
0099 struct ipu_image_convert_ctx *
0100 ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
0101               struct ipu_image *in, struct ipu_image *out,
0102               enum ipu_rotate_mode rot_mode,
0103               ipu_image_convert_cb_t complete,
0104               void *complete_context);
0105 
0106 /**
0107  * ipu_image_convert_unprepare() - unprepare a conversion context.
0108  *
0109  * @ctx: the conversion context pointer to unprepare
0110  *
0111  * Aborts any active or pending conversions for this context and
0112  * frees the context. Any currently active or pending runs belonging
0113  * to this context are returned via the completion callback with an
0114  * error run status.
0115  *
0116  * In V4L2, drivers should call ipu_image_convert_unprepare() at
0117  * streamoff.
0118  */
0119 void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx);
0120 
0121 /**
0122  * ipu_image_convert_queue() - queue a conversion run
0123  *
0124  * @run: the run request pointer
0125  *
0126  * ipu_image_convert_run must be dynamically allocated (_not_ as a local
0127  * var) by callers and filled in with a previously prepared conversion
0128  * context handle and the dma addr's of the input and output image buffers
0129  * for this conversion run.
0130  *
0131  * When this conversion completes, the run pointer is returned via the
0132  * completion callback. The caller is responsible for freeing the run
0133  * object after it completes.
0134  *
0135  * In V4L2, drivers should call ipu_image_convert_queue() while
0136  * streaming to queue the conversion of a received input buffer.
0137  * For example mem2mem devices this would be called in .device_run.
0138  */
0139 int ipu_image_convert_queue(struct ipu_image_convert_run *run);
0140 
0141 /**
0142  * ipu_image_convert_abort() - abort conversions
0143  *
0144  * @ctx: the conversion context pointer
0145  *
0146  * This will abort any active or pending conversions for this context.
0147  * Any currently active or pending runs belonging to this context are
0148  * returned via the completion callback with an error run status.
0149  */
0150 void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx);
0151 
0152 /**
0153  * ipu_image_convert() - asynchronous image conversion request
0154  *
0155  * @ipu:    the IPU handle to use for the conversion
0156  * @ic_task:    the IC task to use for the conversion
0157  * @in:     input image format
0158  * @out:    output image format
0159  * @rot_mode:   rotation mode
0160  * @complete:   run completion callback
0161  * @complete_context:   a context pointer for the completion callback
0162  *
0163  * Request a single image conversion. Returns the run that has been queued.
0164  * A conversion context is automatically created and is available in run->ctx.
0165  * As with ipu_image_convert_prepare(), the input/output formats and rotation
0166  * mode must already meet IPU retrictions.
0167  *
0168  * On successful return the caller can queue more run requests if needed, using
0169  * the prepared context in run->ctx. The caller is responsible for unpreparing
0170  * the context when no more conversion requests are needed.
0171  */
0172 struct ipu_image_convert_run *
0173 ipu_image_convert(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
0174           struct ipu_image *in, struct ipu_image *out,
0175           enum ipu_rotate_mode rot_mode,
0176           ipu_image_convert_cb_t complete,
0177           void *complete_context);
0178 
0179 /**
0180  * ipu_image_convert_sync() - synchronous single image conversion request
0181  *
0182  * @ipu:    the IPU handle to use for the conversion
0183  * @ic_task:    the IC task to use for the conversion
0184  * @in:     input image format
0185  * @out:    output image format
0186  * @rot_mode:   rotation mode
0187  *
0188  * Carry out a single image conversion. Returns when the conversion
0189  * completes. The input/output formats and rotation mode must already
0190  * meet IPU retrictions. The created context is automatically unprepared
0191  * and the run freed on return.
0192  */
0193 int ipu_image_convert_sync(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
0194                struct ipu_image *in, struct ipu_image *out,
0195                enum ipu_rotate_mode rot_mode);
0196 
0197 
0198 #endif /* __IMX_IPU_IMAGE_CONVERT_H__ */