Re: [PATCH v9] media: imx: add csc/scaler mem2mem device
Hi Steve, On Fri, 2019-08-16 at 16:17 -0700, Steve Longerbeam wrote: > Hi Philipp, > > If you haven't already, can you please test rotation with this version, > with both non-tiled and tiled scaling conversions. I found rotation was > broken in v8. > > Steve I've tested a few resolutions with both 90° and 270° rotations. Upscale: 32x24 320x240 640x480 768x320 768x432 720x404 720x480 1024x768 -> 768x1024 768x1280 1080x1920 1600x2560 1280x720 -> 1080x1920 Downscale: 3840x2160 -> 1080x1920 1920x1080 -> 1080x1280 768x1024 576x1024 576x1024 540x960 Note that for horizontal flips the seam hiding does not work properly, due to not being able to overshoot the input scanline backwards. This is apparent when scaling 32x24 -> 768x1280 1080x1920 with 180° or 270° rotation, for example. regards Philipp
Re: [PATCH v9] media: imx: add csc/scaler mem2mem device
Hi Philipp, If you haven't already, can you please test rotation with this version, with both non-tiled and tiled scaling conversions. I found rotation was broken in v8. Steve On 8/14/19 5:24 AM, Philipp Zabel wrote: Add a single imx-media mem2mem video device that uses the IPU IC PP (image converter post processing) task for scaling and colorspace conversion. On i.MX6Q/DL SoCs with two IPUs currently only the first IPU is used. The hardware only supports writing to destination buffers up to 1024x1024 pixels in a single pass, arbitrary sizes can be achieved by rendering multiple tiles per frame. Signed-off-by: Philipp Zabel [slongerb...@gmail.com: use ipu_image_convert_adjust(), fix device_run() error handling, add missing media-device header, unregister and remove the mem2mem device in error paths in imx_media_probe_complete() and in imx_media_remove(), updated for sync subdev registration] Signed-off-by: Steve Longerbeam --- Changes since v8 [1]: - Change subject to be more descriptive. - Call video_unregister_device unconditionally, it handles gracefully handles unregistered video devices. - Rebased onto commit 6d01b7ff5233 ("media: staging/imx: Switch to sync registration for IPU subdevs") - propagate colorimetry info from queue format to image converter - replace devm_kzalloc by kzalloc and release on video_device.release to avoid priv being freed immediately when the driver is unbound while a video device is still opened. This allows to get rid of imx_media_csc_scaler_device_remove() altogether. - update SPDX license identifier [1] https://patchwork.linuxtv.org/patch/55776/ --- drivers/staging/media/imx/Kconfig | 1 + drivers/staging/media/imx/Makefile| 3 +- .../staging/media/imx/imx-media-csc-scaler.c | 925 ++ drivers/staging/media/imx/imx-media-dev.c | 28 +- .../staging/media/imx/imx-media-internal-sd.c | 4 + drivers/staging/media/imx/imx-media.h | 12 + 6 files changed, 971 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/media/imx/imx-media-csc-scaler.c diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig index 4c726345dc25..56b4d7ea3022 100644 --- a/drivers/staging/media/imx/Kconfig +++ b/drivers/staging/media/imx/Kconfig @@ -7,6 +7,7 @@ config VIDEO_IMX_MEDIA depends on HAS_DMA select VIDEOBUF2_DMA_CONTIG select V4L2_FWNODE + select V4L2_MEM2MEM_DEV help Say yes here to enable support for video4linux media controller driver for the i.MX5/6 SOC. diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index aa6c4b4ad37e..9bd9e873ba7c 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 imx6-media-objs := imx-media-dev.o imx-media-internal-sd.o \ - imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o imx-media-vdic.o + imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o imx-media-vdic.o \ + imx-media-csc-scaler.o imx-media-common-objs := imx-media-capture.o imx-media-dev-common.o \ imx-media-of.o imx-media-utils.o diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c new file mode 100644 index ..0cebb013831d --- /dev/null +++ b/drivers/staging/media/imx/imx-media-csc-scaler.c @@ -0,0 +1,925 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * i.MX IPUv3 IC PP mem2mem CSC/Scaler driver + * + * Copyright (C) 2011 Pengutronix, Sascha Hauer + * Copyright (C) 2018 Pengutronix, Philipp Zabel + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "imx-media.h" + +#define fh_to_ctx(__fh)container_of(__fh, struct ipu_csc_scaler_ctx, fh) + +enum { + V4L2_M2M_SRC = 0, + V4L2_M2M_DST = 1, +}; + +struct ipu_csc_scaler_priv { + struct imx_media_video_dev vdev; + + struct v4l2_m2m_dev *m2m_dev; + struct device *dev; + + struct imx_media_dev*md; + + struct mutexmutex; /* mem2mem device mutex */ +}; + +#define vdev_to_priv(v) container_of(v, struct ipu_csc_scaler_priv, vdev) + +/* Per-queue, driver-specific private data */ +struct ipu_csc_scaler_q_data { + struct v4l2_pix_format cur_fmt; + struct v4l2_rectrect; +}; + +struct ipu_csc_scaler_ctx { + struct ipu_csc_scaler_priv *priv; + + struct v4l2_fh fh; + struct ipu_csc_scaler_q_dataq_data[2]; + struct ipu_image_convert_ctx*icc; + + struct v4l2_ctrl_handlerctrl_hdlr; + int rotate; + boolhflip; + bool
Re: [PATCH v9] media: imx: add csc/scaler mem2mem device
On Wed, 2019-08-14 at 14:24 +0200, Philipp Zabel wrote: > Add a single imx-media mem2mem video device that uses the IPU IC PP > (image converter post processing) task for scaling and colorspace > conversion. > On i.MX6Q/DL SoCs with two IPUs currently only the first IPU is used. [...] Output of 'v4l2-compliance -d 10 -e 10 -s -P', with the ipu-v3 fixes at [1] applied. 'v4l2-compliance -f' works for most format combinations, but fails with CMA trying to allocate physically contiguous 4096x4096 32-bit RGB buffers on both queues, on my test system: [1] https://patchwork.kernel.org/series/159687/mbox --8<-- v4l2-compliance SHA: 8d411705aa29f3ad77a4d48797b7ad07bfcce471, 32 bits Compliance test for imx-media-csc-s device /dev/video10: Driver Info: Driver name : imx-media-csc-s Card type: imx-media-csc-scaler Bus info : platform:imx-media-csc-scaler Driver version : 5.3.0 Capabilities : 0x84208000 Video Memory-to-Memory Streaming Extended Pix Format Device Capabilities Device Caps : 0x04208000 Video Memory-to-Memory Streaming Extended Pix Format Media Driver Info: Driver name : imx-media Model: imx-media Serial : Bus info : Media version: 5.3.0 Hardware revision: 0x (0) Driver version : 5.3.0 Required ioctls: test VIDIOC_QUERYCAP: OK Allow for multiple opens: test second /dev/video10 open: OK test VIDIOC_QUERYCAP: OK test VIDIOC_G/S_PRIORITY: OK test for unlimited opens: OK Debug ioctls: test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported) Input ioctls: test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported) test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported) Inputs: 0 Audio Inputs: 0 Tuners: 0 Output ioctls: test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported) Outputs: 0 Audio Outputs: 0 Modulators: 0 Input/Output configuration ioctls: test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported) Control ioctls: test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK test VIDIOC_G/S_CTRL: OK test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 4 Private Controls: 0 Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK test VIDIOC_TRY_FMT: OK test VIDIOC_S_FMT: OK test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK test Composing: OK test Scaling: OK Codec ioctls: test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported) Buffer ioctls: test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK test Requests: OK (Not Supported) Test input 0: Streaming ioctls: test read/write: OK (Not Supported) test blocking wait: OK Video Capture: Captured 58 buffers test MMAP (no poll): OK Video Capture: Captured 58 buffers test MMAP (select): OK Video Capture: Captured 58 buffers test MMAP (epoll): OK test USERPTR (no poll): OK (Not Supported) test USERPTR (select): OK (Not Supported) Video Capture: Captured 58 buffers test DMABUF (no poll): OK Video Capture: Captured 58 buffers test DMABUF (select): OK Total for imx-media-csc-s device /dev/video10: 53, Succeeded: 53, Failed: 0, Warnings: 0 -->8-- regards Philipp