powerpc/powernv: Report size of OPAL memcons log
[linux/fpc-iii.git] / include / video / imx-ipu-image-convert.h
blob7b87efc6d77a90f3491f4ec2995bfc902ad38ba7
1 /*
2 * Copyright (C) 2012-2016 Mentor Graphics Inc.
4 * i.MX Queued image conversion support, with tiling and rotation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
16 #ifndef __IMX_IPU_IMAGE_CONVERT_H__
17 #define __IMX_IPU_IMAGE_CONVERT_H__
19 #include <video/imx-ipu-v3.h>
21 struct ipu_image_convert_ctx;
23 /**
24 * struct ipu_image_convert_run - image conversion run request struct
26 * @ctx: the conversion context
27 * @in_phys: dma addr of input image buffer for this run
28 * @out_phys: dma addr of output image buffer for this run
29 * @status: completion status of this run
31 struct ipu_image_convert_run {
32 struct ipu_image_convert_ctx *ctx;
34 dma_addr_t in_phys;
35 dma_addr_t out_phys;
37 int status;
39 /* internal to image converter, callers don't touch */
40 struct list_head list;
43 /**
44 * ipu_image_convert_cb_t - conversion callback function prototype
46 * @run: the completed conversion run pointer
47 * @ctx: a private context pointer for the callback
49 typedef void (*ipu_image_convert_cb_t)(struct ipu_image_convert_run *run,
50 void *ctx);
52 /**
53 * ipu_image_convert_enum_format() - enumerate the image converter's
54 * supported input and output pixel formats.
56 * @index: pixel format index
57 * @fourcc: v4l2 fourcc for this index
59 * Returns 0 with a valid index and fills in v4l2 fourcc, -EINVAL otherwise.
61 * In V4L2, drivers can call ipu_image_enum_format() in .enum_fmt.
63 int ipu_image_convert_enum_format(int index, u32 *fourcc);
65 /**
66 * ipu_image_convert_adjust() - adjust input/output images to IPU restrictions.
68 * @in: input image format, adjusted on return
69 * @out: output image format, adjusted on return
70 * @rot_mode: rotation mode
72 * In V4L2, drivers can call ipu_image_convert_adjust() in .try_fmt.
74 void ipu_image_convert_adjust(struct ipu_image *in, struct ipu_image *out,
75 enum ipu_rotate_mode rot_mode);
77 /**
78 * ipu_image_convert_verify() - verify that input/output image formats
79 * and rotation mode meet IPU restrictions.
81 * @in: input image format
82 * @out: output image format
83 * @rot_mode: rotation mode
85 * Returns 0 if the formats and rotation mode meet IPU restrictions,
86 * -EINVAL otherwise.
88 int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out,
89 enum ipu_rotate_mode rot_mode);
91 /**
92 * ipu_image_convert_prepare() - prepare a conversion context.
94 * @ipu: the IPU handle to use for the conversions
95 * @ic_task: the IC task to use for the conversions
96 * @in: input image format
97 * @out: output image format
98 * @rot_mode: rotation mode
99 * @complete: run completion callback
100 * @complete_context: a context pointer for the completion callback
102 * Returns an opaque conversion context pointer on success, error pointer
103 * on failure. The input/output formats and rotation mode must already meet
104 * IPU retrictions.
106 * In V4L2, drivers should call ipu_image_convert_prepare() at streamon.
108 struct ipu_image_convert_ctx *
109 ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
110 struct ipu_image *in, struct ipu_image *out,
111 enum ipu_rotate_mode rot_mode,
112 ipu_image_convert_cb_t complete,
113 void *complete_context);
116 * ipu_image_convert_unprepare() - unprepare a conversion context.
118 * @ctx: the conversion context pointer to unprepare
120 * Aborts any active or pending conversions for this context and
121 * frees the context. Any currently active or pending runs belonging
122 * to this context are returned via the completion callback with an
123 * error run status.
125 * In V4L2, drivers should call ipu_image_convert_unprepare() at
126 * streamoff.
128 void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx);
131 * ipu_image_convert_queue() - queue a conversion run
133 * @run: the run request pointer
135 * ipu_image_convert_run must be dynamically allocated (_not_ as a local
136 * var) by callers and filled in with a previously prepared conversion
137 * context handle and the dma addr's of the input and output image buffers
138 * for this conversion run.
140 * When this conversion completes, the run pointer is returned via the
141 * completion callback. The caller is responsible for freeing the run
142 * object after it completes.
144 * In V4L2, drivers should call ipu_image_convert_queue() while
145 * streaming to queue the conversion of a received input buffer.
146 * For example mem2mem devices this would be called in .device_run.
148 int ipu_image_convert_queue(struct ipu_image_convert_run *run);
151 * ipu_image_convert_abort() - abort conversions
153 * @ctx: the conversion context pointer
155 * This will abort any active or pending conversions for this context.
156 * Any currently active or pending runs belonging to this context are
157 * returned via the completion callback with an error run status.
159 void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx);
162 * ipu_image_convert() - asynchronous image conversion request
164 * @ipu: the IPU handle to use for the conversion
165 * @ic_task: the IC task to use for the conversion
166 * @in: input image format
167 * @out: output image format
168 * @rot_mode: rotation mode
169 * @complete: run completion callback
170 * @complete_context: a context pointer for the completion callback
172 * Request a single image conversion. Returns the run that has been queued.
173 * A conversion context is automatically created and is available in run->ctx.
174 * As with ipu_image_convert_prepare(), the input/output formats and rotation
175 * mode must already meet IPU retrictions.
177 * On successful return the caller can queue more run requests if needed, using
178 * the prepared context in run->ctx. The caller is responsible for unpreparing
179 * the context when no more conversion requests are needed.
181 struct ipu_image_convert_run *
182 ipu_image_convert(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
183 struct ipu_image *in, struct ipu_image *out,
184 enum ipu_rotate_mode rot_mode,
185 ipu_image_convert_cb_t complete,
186 void *complete_context);
189 * ipu_image_convert_sync() - synchronous single image conversion request
191 * @ipu: the IPU handle to use for the conversion
192 * @ic_task: the IC task to use for the conversion
193 * @in: input image format
194 * @out: output image format
195 * @rot_mode: rotation mode
197 * Carry out a single image conversion. Returns when the conversion
198 * completes. The input/output formats and rotation mode must already
199 * meet IPU retrictions. The created context is automatically unprepared
200 * and the run freed on return.
202 int ipu_image_convert_sync(struct ipu_soc *ipu, enum ipu_ic_task ic_task,
203 struct ipu_image *in, struct ipu_image *out,
204 enum ipu_rotate_mode rot_mode);
207 #endif /* __IMX_IPU_IMAGE_CONVERT_H__ */