mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
media: imx: add csc/scaler mem2mem device
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. [slongerbeam@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: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: correct two minor checkpatch issues] [hverkuil-cisco@xs4all.nl: sparse warning: make imx6_media_probe_complete static] Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
14d5511691
commit
a8ef0488cc
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
926
drivers/staging/media/imx/imx-media-csc-scaler.c
Normal file
926
drivers/staging/media/imx/imx-media-csc-scaler.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -37,10 +37,35 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* async subdev complete notifier */
|
||||
static int imx6_media_probe_complete(struct v4l2_async_notifier *notifier)
|
||||
{
|
||||
struct imx_media_dev *imxmd = notifier2dev(notifier);
|
||||
int ret;
|
||||
|
||||
/* call the imx5/6/7 common probe completion handler */
|
||||
ret = imx_media_probe_complete(notifier);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&imxmd->mutex);
|
||||
|
||||
imxmd->m2m_vdev = imx_media_csc_scaler_device_init(imxmd);
|
||||
if (IS_ERR(imxmd->m2m_vdev)) {
|
||||
ret = PTR_ERR(imxmd->m2m_vdev);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ret = imx_media_csc_scaler_device_register(imxmd->m2m_vdev);
|
||||
unlock:
|
||||
mutex_unlock(&imxmd->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* async subdev complete notifier */
|
||||
static const struct v4l2_async_notifier_operations imx_media_notifier_ops = {
|
||||
.bound = imx_media_subdev_bound,
|
||||
.complete = imx_media_probe_complete,
|
||||
.complete = imx6_media_probe_complete,
|
||||
};
|
||||
|
||||
static int imx_media_probe(struct platform_device *pdev)
|
||||
@@ -85,6 +110,7 @@ static int imx_media_remove(struct platform_device *pdev)
|
||||
v4l2_async_notifier_unregister(&imxmd->notifier);
|
||||
imx_media_unregister_ipu_internal_subdevs(imxmd);
|
||||
v4l2_async_notifier_cleanup(&imxmd->notifier);
|
||||
imx_media_csc_scaler_device_unregister(imxmd->m2m_vdev);
|
||||
media_device_unregister(&imxmd->md);
|
||||
v4l2_device_unregister(&imxmd->v4l2_dev);
|
||||
media_device_cleanup(&imxmd->md);
|
||||
|
||||
@@ -210,6 +210,10 @@ int imx_media_register_ipu_internal_subdevs(struct imx_media_dev *imxmd,
|
||||
|
||||
mutex_lock(&imxmd->mutex);
|
||||
|
||||
/* record this IPU */
|
||||
if (!imxmd->ipu[ipu_id])
|
||||
imxmd->ipu[ipu_id] = ipu;
|
||||
|
||||
/* register the synchronous subdevs */
|
||||
for (i = 0; i < NUM_IPU_SUBDEVS; i++) {
|
||||
intsd = &int_subdev[i];
|
||||
|
||||
@@ -136,9 +136,15 @@ struct imx_media_dev {
|
||||
/* master video device list */
|
||||
struct list_head vdev_list;
|
||||
|
||||
/* IPUs this media driver control, valid after subdevs bound */
|
||||
struct ipu_soc *ipu[2];
|
||||
|
||||
/* for async subdev registration */
|
||||
struct v4l2_async_notifier notifier;
|
||||
|
||||
/* IC scaler/CSC mem2mem video device */
|
||||
struct imx_media_video_dev *m2m_vdev;
|
||||
|
||||
/* the IPU internal subdev's registered synchronously */
|
||||
struct v4l2_subdev *sync_sd[2][NUM_IPU_SUBDEVS];
|
||||
};
|
||||
@@ -269,6 +275,12 @@ struct imx_media_buffer *
|
||||
imx_media_capture_device_next_buf(struct imx_media_video_dev *vdev);
|
||||
void imx_media_capture_device_error(struct imx_media_video_dev *vdev);
|
||||
|
||||
/* imx-media-csc-scaler.c */
|
||||
struct imx_media_video_dev *
|
||||
imx_media_csc_scaler_device_init(struct imx_media_dev *dev);
|
||||
int imx_media_csc_scaler_device_register(struct imx_media_video_dev *vdev);
|
||||
void imx_media_csc_scaler_device_unregister(struct imx_media_video_dev *vdev);
|
||||
|
||||
/* subdev group ids */
|
||||
#define IMX_MEDIA_GRP_ID_CSI2 BIT(8)
|
||||
#define IMX_MEDIA_GRP_ID_CSI BIT(9)
|
||||
|
||||
Reference in New Issue
Block a user