Path: blob/master/include/video/imx-ipu-image-convert.h
26285 views
/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* Copyright (C) 2012-2016 Mentor Graphics Inc.3*4* i.MX Queued image conversion support, with tiling and rotation.5*/6#ifndef __IMX_IPU_IMAGE_CONVERT_H__7#define __IMX_IPU_IMAGE_CONVERT_H__89#include <video/imx-ipu-v3.h>1011struct ipu_image_convert_ctx;1213/**14* struct ipu_image_convert_run - image conversion run request struct15*16* @ctx: the conversion context17* @in_phys: dma addr of input image buffer for this run18* @out_phys: dma addr of output image buffer for this run19* @status: completion status of this run20*/21struct ipu_image_convert_run {22struct ipu_image_convert_ctx *ctx;2324dma_addr_t in_phys;25dma_addr_t out_phys;2627int status;2829/* internal to image converter, callers don't touch */30struct list_head list;31};3233/**34* ipu_image_convert_cb_t - conversion callback function prototype35*36* @run: the completed conversion run pointer37* @ctx: a private context pointer for the callback38*/39typedef void (*ipu_image_convert_cb_t)(struct ipu_image_convert_run *run,40void *ctx);4142/**43* ipu_image_convert_adjust() - adjust input/output images to IPU restrictions.44*45* @in: input image format, adjusted on return46* @out: output image format, adjusted on return47* @rot_mode: rotation mode48*49* In V4L2, drivers can call ipu_image_convert_adjust() in .try_fmt.50*/51void ipu_image_convert_adjust(struct ipu_image *in, struct ipu_image *out,52enum ipu_rotate_mode rot_mode);5354/**55* ipu_image_convert_verify() - verify that input/output image formats56* and rotation mode meet IPU restrictions.57*58* @in: input image format59* @out: output image format60* @rot_mode: rotation mode61*62* Returns 0 if the formats and rotation mode meet IPU restrictions,63* -EINVAL otherwise.64*/65int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out,66enum ipu_rotate_mode rot_mode);6768/**69* ipu_image_convert_prepare() - prepare a conversion context.70*71* @ipu: the IPU handle to use for the conversions72* @ic_task: the IC task to use for the conversions73* @in: input image format74* @out: output image format75* @rot_mode: rotation mode76* @complete: run completion callback77* @complete_context: a context pointer for the completion callback78*79* Returns an opaque conversion context pointer on success, error pointer80* on failure. The input/output formats and rotation mode must already meet81* IPU retrictions.82*83* In V4L2, drivers should call ipu_image_convert_prepare() at streamon.84*/85struct ipu_image_convert_ctx *86ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task,87struct ipu_image *in, struct ipu_image *out,88enum ipu_rotate_mode rot_mode,89ipu_image_convert_cb_t complete,90void *complete_context);9192/**93* ipu_image_convert_unprepare() - unprepare a conversion context.94*95* @ctx: the conversion context pointer to unprepare96*97* Aborts any active or pending conversions for this context and98* frees the context. Any currently active or pending runs belonging99* to this context are returned via the completion callback with an100* error run status.101*102* In V4L2, drivers should call ipu_image_convert_unprepare() at103* streamoff.104*/105void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx);106107/**108* ipu_image_convert_queue() - queue a conversion run109*110* @run: the run request pointer111*112* ipu_image_convert_run must be dynamically allocated (_not_ as a local113* var) by callers and filled in with a previously prepared conversion114* context handle and the dma addr's of the input and output image buffers115* for this conversion run.116*117* When this conversion completes, the run pointer is returned via the118* completion callback. The caller is responsible for freeing the run119* object after it completes.120*121* In V4L2, drivers should call ipu_image_convert_queue() while122* streaming to queue the conversion of a received input buffer.123* For example mem2mem devices this would be called in .device_run.124*/125int ipu_image_convert_queue(struct ipu_image_convert_run *run);126127/**128* ipu_image_convert_abort() - abort conversions129*130* @ctx: the conversion context pointer131*132* This will abort any active or pending conversions for this context.133* Any currently active or pending runs belonging to this context are134* returned via the completion callback with an error run status.135*/136void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx);137138/**139* ipu_image_convert() - asynchronous image conversion request140*141* @ipu: the IPU handle to use for the conversion142* @ic_task: the IC task to use for the conversion143* @in: input image format144* @out: output image format145* @rot_mode: rotation mode146* @complete: run completion callback147* @complete_context: a context pointer for the completion callback148*149* Request a single image conversion. Returns the run that has been queued.150* A conversion context is automatically created and is available in run->ctx.151* As with ipu_image_convert_prepare(), the input/output formats and rotation152* mode must already meet IPU retrictions.153*154* On successful return the caller can queue more run requests if needed, using155* the prepared context in run->ctx. The caller is responsible for unpreparing156* the context when no more conversion requests are needed.157*/158struct ipu_image_convert_run *159ipu_image_convert(struct ipu_soc *ipu, enum ipu_ic_task ic_task,160struct ipu_image *in, struct ipu_image *out,161enum ipu_rotate_mode rot_mode,162ipu_image_convert_cb_t complete,163void *complete_context);164165#endif /* __IMX_IPU_IMAGE_CONVERT_H__ */166167168