From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:57452 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754800AbcJNRfB (ORCPT ); Fri, 14 Oct 2016 13:35:01 -0400 From: Philipp Zabel To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Marek Vasut , Hans Verkuil , Gary Bisson , kernel@pengutronix.de, Philipp Zabel , Sascha Hauer , Marc Kleine-Budde Subject: [PATCH v2 08/21] [media] imx: Add i.MX IPUv3 capture driver Date: Fri, 14 Oct 2016 19:34:28 +0200 Message-Id: <1476466481-24030-9-git-send-email-p.zabel@pengutronix.de> In-Reply-To: <1476466481-24030-1-git-send-email-p.zabel@pengutronix.de> References: <1476466481-24030-1-git-send-email-p.zabel@pengutronix.de> Sender: linux-media-owner@vger.kernel.org List-ID: This driver uses the IDMAC module's double buffering feature to do the processing of finished frames in the new frame acknowledge (NFACK) interrupt handler while the next frame is already being captured. This avoids a race condition between the end of frame interrupt and NFACK for very short blanking intervals, but causes the driver to need at least two buffers in flight. The last remaining frame will never be handed out to userspace until a new one is queued. It supports interlaced input and allows to translate between sequential and interlaced field formats using the IDMAC scan order and interlace offset parameters. Currently the direct CSI -> SMFC -> IDMAC path is supported. Signed-off-by: Sascha Hauer Signed-off-by: Marc Kleine-Budde Signed-off-by: Philipp Zabel --- Changes since v1: - Remove v4l2_media_subdev_prepare_stream and v4l2_media_subdev_s_stream, subdevices will propagate s_stream calls to their upstream subdevices themselves. - Fix width/height to CSI output size - Use colorspace provided by CSI output - Implement enum/g/s/_input for v4l2-compliance - Fix ipu_capture_g_parm to use the correct pad --- drivers/media/platform/imx/Kconfig | 9 + drivers/media/platform/imx/Makefile | 1 + drivers/media/platform/imx/imx-ipu-capture.c | 1015 ++++++++++++++++++++++++++ drivers/media/platform/imx/imx-ipu.h | 9 + drivers/media/platform/imx/imx-ipuv3-csi.c | 29 +- 5 files changed, 1061 insertions(+), 2 deletions(-) create mode 100644 drivers/media/platform/imx/imx-ipu-capture.c diff --git a/drivers/media/platform/imx/Kconfig b/drivers/media/platform/imx/Kconfig index a88c4f7..69e8648 100644 --- a/drivers/media/platform/imx/Kconfig +++ b/drivers/media/platform/imx/Kconfig @@ -9,6 +9,15 @@ config MEDIA_IMX config VIDEO_IMX_IPU_COMMON tristate +config VIDEO_IMX_IPU_CAPTURE + tristate "i.MX5/6 Video Capture driver" + depends on IMX_IPUV3_CORE && VIDEO_V4L2_SUBDEV_API && MEDIA_IMX + select VIDEOBUF2_DMA_CONTIG + select VIDEO_IMX_IPU_COMMON + select VIDEO_IMX_IPUV3 + help + This is a v4l2 video capture driver for the IPUv3 on i.MX5/6. + config VIDEO_IMX_IPU_CSI tristate "i.MX5/6 CMOS Sensor Interface driver" depends on VIDEO_DEV && IMX_IPUV3_CORE && MEDIA_IMX diff --git a/drivers/media/platform/imx/Makefile b/drivers/media/platform/imx/Makefile index 82a3616..919eaa1 100644 --- a/drivers/media/platform/imx/Makefile +++ b/drivers/media/platform/imx/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_MEDIA_IMX) += imx-media.o obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o +obj-$(CONFIG_VIDEO_IMX_IPU_CAPTURE) += imx-ipu-capture.o obj-$(CONFIG_VIDEO_IMX_IPU_CSI) += imx-ipuv3-csi.o diff --git a/drivers/media/platform/imx/imx-ipu-capture.c b/drivers/media/platform/imx/imx-ipu-capture.c new file mode 100644 index 0000000..1308c1e --- /dev/null +++ b/drivers/media/platform/imx/imx-ipu-capture.c @@ -0,0 +1,1015 @@ +/* + * i.MX IPUv3 V4L2 Capture Driver + * + * Copyright (C) 2016, Pengutronix, Philipp Zabel + * + * Based on code + * Copyright (C) 2006, Pengutronix, Sascha Hauer + * Copyright (C) 2008, Guennadi Liakhovetski + * Copyright (C) 2008, Paulius Zaleckas + * Copyright (C) 2009, Darius Augulis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include