diff options
author | Dave Airlie <airlied@redhat.com> | 2016-09-19 22:24:26 +0200 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-09-19 22:24:26 +0200 |
commit | 26e34d2d8ba7aca0fe86e5362ce5811749df77b2 (patch) | |
tree | 51fba9f283f18d86de24bf5a21d150c57c14121d /include | |
parent | Merge tag 'drm-intel-next-2016-09-19' of git://anongit.freedesktop.org/drm-in... (diff) | |
parent | gpu: ipu-v3: Add queued image conversion support (diff) | |
download | linux-26e34d2d8ba7aca0fe86e5362ce5811749df77b2.tar.xz linux-26e34d2d8ba7aca0fe86e5362ce5811749df77b2.zip |
Merge tag 'imx-drm-next-2016-09-19' of git://git.pengutronix.de/git/pza/linux into drm-next
imx-drm active plane reconfiguration, cleanup, FSU/IC/IRT/VDIC support
- add active plane reconfiguration support (v4),
use the atomic_disable callback
- stop calling disable_plane manually in the plane destroy path
- let mode cleanup destroy mode objects on driver unbind
- drop deprecated load/unload drm_driver ops
- add exclusive fence to plane state, so the atomic helper can
wait on them, remove the open-coded fence wait from imx-drm
- add low level deinterlacer (VDIC) support
- add support for channel linking via the frame synchronisation unit (FSU)
- add queued image conversion support for memory-to-memory scaling, rotation,
and color space conversion, using IC and IRT.
* tag 'imx-drm-next-2016-09-19' of git://git.pengutronix.de/git/pza/linux:
gpu: ipu-v3: Add queued image conversion support
gpu: ipu-v3: Add ipu_rot_mode_is_irt()
gpu: ipu-v3: fix a possible NULL dereference
drm/imx: parallel-display: detach bridge or panel on unbind
drm/imx: imx-ldb: detach bridge on unbind
drm/imx: imx-ldb: detach panel on unbind
gpu: ipu-v3: Add FSU channel linking support
gpu: ipu-v3: Add Video Deinterlacer unit
drm/imx: add exclusive fence to plane state
drm/imx: fold ipu_plane_disable into ipu_disable_plane
drm/imx: don't destroy mode objects manually on driver unbind
drm/imx: drop deprecated load/unload drm_driver ops
drm/imx: don't call disable_plane in plane destroy path
drm/imx: Add active plane reconfiguration support
drm/imx: Use DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET flag
drm/imx: ipuv3-crtc: Use the callback ->atomic_disable instead of ->disable
gpu: ipu-v3: Do not wait for DMFC FIFO to clear when disabling DMFC channel
Diffstat (limited to 'include')
-rw-r--r-- | include/video/imx-ipu-image-convert.h | 207 | ||||
-rw-r--r-- | include/video/imx-ipu-v3.h | 58 |
2 files changed, 258 insertions, 7 deletions
diff --git a/include/video/imx-ipu-image-convert.h b/include/video/imx-ipu-image-convert.h new file mode 100644 index 000000000000..7b87efc6d77a --- /dev/null +++ b/include/video/imx-ipu-image-convert.h @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2012-2016 Mentor Graphics Inc. + * + * i.MX Queued image conversion support, with tiling and rotation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#ifndef __IMX_IPU_IMAGE_CONVERT_H__ +#define __IMX_IPU_IMAGE_CONVERT_H__ + +#include <video/imx-ipu-v3.h> + +struct ipu_image_convert_ctx; + +/** + * struct ipu_image_convert_run - image conversion run request struct + * + * @ctx: the conversion context + * @in_phys: dma addr of input image buffer for this run + * @out_phys: dma addr of output image buffer for this run + * @status: completion status of this run + */ +struct ipu_image_convert_run { + struct ipu_image_convert_ctx *ctx; + + dma_addr_t in_phys; + dma_addr_t out_phys; + + int status; + + /* internal to image converter, callers don't touch */ + struct list_head list; +}; + +/** + * ipu_image_convert_cb_t - conversion callback function prototype + * + * @run: the completed conversion run pointer + * @ctx: a private context pointer for the callback + */ +typedef void (*ipu_image_convert_cb_t)(struct ipu_image_convert_run *run, + void *ctx); + +/** + * ipu_image_convert_enum_format() - enumerate the image converter's + * supported input and output pixel formats. + * + * @index: pixel format index + * @fourcc: v4l2 fourcc for this index + * + * Returns 0 with a valid index and fills in v4l2 fourcc, -EINVAL otherwise. + * + * In V4L2, drivers can call ipu_image_enum_format() in .enum_fmt. + */ +int ipu_image_convert_enum_format(int index, u32 *fourcc); + +/** + * ipu_image_convert_adjust() - adjust input/output images to IPU restrictions. + * + * @in: input image format, adjusted on return + * @out: output image format, adjusted on return + * @rot_mode: rotation mode + * + * In V4L2, drivers can call ipu_image_convert_adjust() in .try_fmt. + */ +void ipu_image_convert_adjust(struct ipu_image *in, struct ipu_image *out, + enum ipu_rotate_mode rot_mode); + +/** + * ipu_image_convert_verify() - verify that input/output image formats + * and rotation mode meet IPU restrictions. + * + * @in: input image format + * @out: output image format + * @rot_mode: rotation mode + * + * Returns 0 if the formats and rotation mode meet IPU restrictions, + * -EINVAL otherwise. + */ +int ipu_image_convert_verify(struct ipu_image *in, struct ipu_image *out, + enum ipu_rotate_mode rot_mode); + +/** + * ipu_image_convert_prepare() - prepare a conversion context. + * + * @ipu: the IPU handle to use for the conversions + * @ic_task: the IC task to use for the conversions + * @in: input image format + * @out: output image format + * @rot_mode: rotation mode + * @complete: run completion callback + * @complete_context: a context pointer for the completion callback + * + * Returns an opaque conversion context pointer on success, error pointer + * on failure. The input/output formats and rotation mode must already meet + * IPU retrictions. + * + * In V4L2, drivers should call ipu_image_convert_prepare() at streamon. + */ +struct ipu_image_convert_ctx * +ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task, + struct ipu_image *in, struct ipu_image *out, + enum ipu_rotate_mode rot_mode, + ipu_image_convert_cb_t complete, + void *complete_context); + +/** + * ipu_image_convert_unprepare() - unprepare a conversion context. + * + * @ctx: the conversion context pointer to unprepare + * + * Aborts any active or pending conversions for this context and + * frees the context. Any currently active or pending runs belonging + * to this context are returned via the completion callback with an + * error run status. + * + * In V4L2, drivers should call ipu_image_convert_unprepare() at + * streamoff. + */ +void ipu_image_convert_unprepare(struct ipu_image_convert_ctx *ctx); + +/** + * ipu_image_convert_queue() - queue a conversion run + * + * @run: the run request pointer + * + * ipu_image_convert_run must be dynamically allocated (_not_ as a local + * var) by callers and filled in with a previously prepared conversion + * context handle and the dma addr's of the input and output image buffers + * for this conversion run. + * + * When this conversion completes, the run pointer is returned via the + * completion callback. The caller is responsible for freeing the run + * object after it completes. + * + * In V4L2, drivers should call ipu_image_convert_queue() while + * streaming to queue the conversion of a received input buffer. + * For example mem2mem devices this would be called in .device_run. + */ +int ipu_image_convert_queue(struct ipu_image_convert_run *run); + +/** + * ipu_image_convert_abort() - abort conversions + * + * @ctx: the conversion context pointer + * + * This will abort any active or pending conversions for this context. + * Any currently active or pending runs belonging to this context are + * returned via the completion callback with an error run status. + */ +void ipu_image_convert_abort(struct ipu_image_convert_ctx *ctx); + +/** + * ipu_image_convert() - asynchronous image conversion request + * + * @ipu: the IPU handle to use for the conversion + * @ic_task: the IC task to use for the conversion + * @in: input image format + * @out: output image format + * @rot_mode: rotation mode + * @complete: run completion callback + * @complete_context: a context pointer for the completion callback + * + * Request a single image conversion. Returns the run that has been queued. + * A conversion context is automatically created and is available in run->ctx. + * As with ipu_image_convert_prepare(), the input/output formats and rotation + * mode must already meet IPU retrictions. + * + * On successful return the caller can queue more run requests if needed, using + * the prepared context in run->ctx. The caller is responsible for unpreparing + * the context when no more conversion requests are needed. + */ +struct ipu_image_convert_run * +ipu_image_convert(struct ipu_soc *ipu, enum ipu_ic_task ic_task, + struct ipu_image *in, struct ipu_image *out, + enum ipu_rotate_mode rot_mode, + ipu_image_convert_cb_t complete, + void *complete_context); + +/** + * ipu_image_convert_sync() - synchronous single image conversion request + * + * @ipu: the IPU handle to use for the conversion + * @ic_task: the IC task to use for the conversion + * @in: input image format + * @out: output image format + * @rot_mode: rotation mode + * + * Carry out a single image conversion. Returns when the conversion + * completes. The input/output formats and rotation mode must already + * meet IPU retrictions. The created context is automatically unprepared + * and the run freed on return. + */ +int ipu_image_convert_sync(struct ipu_soc *ipu, enum ipu_ic_task ic_task, + struct ipu_image *in, struct ipu_image *out, + enum ipu_rotate_mode rot_mode); + + +#endif /* __IMX_IPU_IMAGE_CONVERT_H__ */ diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index c3de7406474b..173073eb6aaf 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -63,23 +63,41 @@ enum ipu_csi_dest { /* * Enumeration of IPU rotation modes */ +#define IPU_ROT_BIT_VFLIP (1 << 0) +#define IPU_ROT_BIT_HFLIP (1 << 1) +#define IPU_ROT_BIT_90 (1 << 2) + enum ipu_rotate_mode { IPU_ROTATE_NONE = 0, - IPU_ROTATE_VERT_FLIP, - IPU_ROTATE_HORIZ_FLIP, - IPU_ROTATE_180, - IPU_ROTATE_90_RIGHT, - IPU_ROTATE_90_RIGHT_VFLIP, - IPU_ROTATE_90_RIGHT_HFLIP, - IPU_ROTATE_90_LEFT, + IPU_ROTATE_VERT_FLIP = IPU_ROT_BIT_VFLIP, + IPU_ROTATE_HORIZ_FLIP = IPU_ROT_BIT_HFLIP, + IPU_ROTATE_180 = (IPU_ROT_BIT_VFLIP | IPU_ROT_BIT_HFLIP), + IPU_ROTATE_90_RIGHT = IPU_ROT_BIT_90, + IPU_ROTATE_90_RIGHT_VFLIP = (IPU_ROT_BIT_90 | IPU_ROT_BIT_VFLIP), + IPU_ROTATE_90_RIGHT_HFLIP = (IPU_ROT_BIT_90 | IPU_ROT_BIT_HFLIP), + IPU_ROTATE_90_LEFT = (IPU_ROT_BIT_90 | + IPU_ROT_BIT_VFLIP | IPU_ROT_BIT_HFLIP), }; +/* 90-degree rotations require the IRT unit */ +#define ipu_rot_mode_is_irt(m) (((m) & IPU_ROT_BIT_90) != 0) + enum ipu_color_space { IPUV3_COLORSPACE_RGB, IPUV3_COLORSPACE_YUV, IPUV3_COLORSPACE_UNKNOWN, }; +/* + * Enumeration of VDI MOTION select + */ +enum ipu_motion_sel { + MOTION_NONE = 0, + LOW_MOTION, + MED_MOTION, + HIGH_MOTION, +}; + struct ipuv3_channel; enum ipu_channel_irq { @@ -97,6 +115,14 @@ enum ipu_channel_irq { #define IPUV3_CHANNEL_CSI2 2 #define IPUV3_CHANNEL_CSI3 3 #define IPUV3_CHANNEL_VDI_MEM_IC_VF 5 +/* + * NOTE: channels 6,7 are unused in the IPU and are not IDMAC channels, + * but the direct CSI->VDI linking is handled the same way as IDMAC + * channel linking in the FSU via the IPU_FS_PROC_FLOW registers, so + * these channel names are used to support the direct CSI->VDI link. + */ +#define IPUV3_CHANNEL_CSI_DIRECT 6 +#define IPUV3_CHANNEL_CSI_VDI_PREV 7 #define IPUV3_CHANNEL_MEM_VDI_PREV 8 #define IPUV3_CHANNEL_MEM_VDI_CUR 9 #define IPUV3_CHANNEL_MEM_VDI_NEXT 10 @@ -133,6 +159,7 @@ enum ipu_channel_irq { #define IPUV3_CHANNEL_ROT_PP_MEM 50 #define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA 51 #define IPUV3_CHANNEL_MEM_BG_ASYNC_ALPHA 52 +#define IPUV3_NUM_CHANNELS 64 int ipu_map_irq(struct ipu_soc *ipu, int irq); int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, @@ -176,6 +203,10 @@ int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num); void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num); +int ipu_fsu_link(struct ipu_soc *ipu, int src_ch, int sink_ch); +int ipu_fsu_unlink(struct ipu_soc *ipu, int src_ch, int sink_ch); +int ipu_idmac_link(struct ipuv3_channel *src, struct ipuv3_channel *sink); +int ipu_idmac_unlink(struct ipuv3_channel *src, struct ipuv3_channel *sink); /* * IPU Channel Parameter Memory (cpmem) functions @@ -335,6 +366,19 @@ void ipu_ic_put(struct ipu_ic *ic); void ipu_ic_dump(struct ipu_ic *ic); /* + * IPU Video De-Interlacer (vdi) functions + */ +struct ipu_vdi; +void ipu_vdi_set_field_order(struct ipu_vdi *vdi, v4l2_std_id std, u32 field); +void ipu_vdi_set_motion(struct ipu_vdi *vdi, enum ipu_motion_sel motion_sel); +void ipu_vdi_setup(struct ipu_vdi *vdi, u32 code, int xres, int yres); +void ipu_vdi_unsetup(struct ipu_vdi *vdi); +int ipu_vdi_enable(struct ipu_vdi *vdi); +int ipu_vdi_disable(struct ipu_vdi *vdi); +struct ipu_vdi *ipu_vdi_get(struct ipu_soc *ipu); +void ipu_vdi_put(struct ipu_vdi *vdi); + +/* * IPU Sensor Multiple FIFO Controller (SMFC) functions */ struct ipu_smfc *ipu_smfc_get(struct ipu_soc *ipu, unsigned int chno); |