From a8ef0488cc592921a917362cca66af4a601987b9 Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 14 Aug 2019 09:24:44 -0300
Subject: 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
Signed-off-by: Steve Longerbeam
Signed-off-by: Hans Verkuil
[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
---
drivers/staging/media/imx/Kconfig | 1 +
drivers/staging/media/imx/Makefile | 3 +-
drivers/staging/media/imx/imx-media-csc-scaler.c | 926 ++++++++++++++++++++++
drivers/staging/media/imx/imx-media-dev.c | 28 +-
drivers/staging/media/imx/imx-media-internal-sd.c | 4 +
drivers/staging/media/imx/imx-media.h | 12 +
6 files changed, 972 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 f51476243016..8f1ae50a4abd 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 000000000000..de599af59ffc
--- /dev/null
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -0,0 +1,926 @@
+// 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