From patchwork Mon Jul 27 12:35:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 30694 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1ZJhd9-00060R-G3; Mon, 27 Jul 2015 14:35:43 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-5) with esmtp id 1ZJhd7-0006nh-7Y; Mon, 27 Jul 2015 14:35:43 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbbG0Mff (ORCPT + 1 other); Mon, 27 Jul 2015 08:35:35 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:36913 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752909AbbG0Mfe (ORCPT ); Mon, 27 Jul 2015 08:35:34 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id EA194461AFB; Mon, 27 Jul 2015 13:35:32 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9hgevepWtEqY; Mon, 27 Jul 2015 13:35:29 +0100 (BST) Received: from xk120.dyn.ducie.codethink.co.uk (xk120.dyn.ducie.codethink.co.uk [10.24.1.159]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPSA id BEB46461AD5; Mon, 27 Jul 2015 13:35:29 +0100 (BST) Date: Mon, 27 Jul 2015 13:35:28 +0100 (BST) From: William Towle X-X-Sender: william@xk120.dyn.ducie.codethink.co.uk To: Hans Verkuil cc: William Towle , linux-media@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Guennadi Liakhovetski , Sergei Shtylyov Subject: Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation In-Reply-To: <55B24941.1040803@xs4all.nl> Message-ID: References: <1437654103-26409-1-git-send-email-william.towle@codethink.co.uk> <1437654103-26409-8-git-send-email-william.towle@codethink.co.uk> <55B24941.1040803@xs4all.nl> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.7.27.123018 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' On Fri, 24 Jul 2015, Hans Verkuil wrote: > Why would you want to init vdev->entity? soc-camera doesn't create a media controller > device, so there is no point in doing this. Thanks, I hadn't quite understood that about the code I was transplanting to/from. Please find an update below. Cheers, Wills. ... Subject: [PATCH] media: soc_camera pad-aware driver initialisation Add detection of source pad number for drivers aware of the media controller API, so that the combination of soc_camera and rcar_vin can create device nodes to support modern drivers such as adv7604.c (for HDMI on Lager) and the converted adv7180.c (for composite) underneath. Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in line with requirements for building the drivers associated with it. Signed-off-by: William Towle Signed-off-by: Rob Taylor --- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/rcar_vin.c | 1 + drivers/media/platform/soc_camera/soc_camera.c | 20 +++++++++++++++++++- include/media/soc_camera.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig index f2776cd..5c45c83 100644 --- a/drivers/media/platform/soc_camera/Kconfig +++ b/drivers/media/platform/soc_camera/Kconfig @@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN depends on VIDEO_DEV && SOC_CAMERA depends on ARCH_SHMOBILE || COMPILE_TEST depends on HAS_DMA + depends on MEDIA_CONTROLLER select VIDEOBUF2_DMA_CONTIG select SOC_CAMERA_SCALE_CROP ---help--- diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 16352a8..00c1034 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx, struct device *dev = icd->parent; int shift; + fmt.pad = icd->src_pad_idx; ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt); if (ret < 0) return ret; diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index d708df4..82d3ebe 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1293,6 +1293,10 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd) .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; struct v4l2_mbus_framefmt *mf = &fmt.format; +#if defined(CONFIG_MEDIA_CONTROLLER) + struct media_pad pad; + int pad_idx; +#endif int ret; sd->grp_id = soc_camera_grp_id(icd); @@ -1311,9 +1315,23 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd) } /* At this point client .probe() should have run already */ + icd->src_pad_idx = 0; +#if defined(CONFIG_MEDIA_CONTROLLER) + for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++) + if (sd->entity.pads[pad_idx].flags + == MEDIA_PAD_FL_SOURCE) + break; + if (pad_idx >= sd->entity.num_pads) + goto eusrfmt; + + icd->src_pad_idx = pad_idx; +#endif + ret = soc_camera_init_user_formats(icd); - if (ret < 0) + if (ret < 0) { + icd->src_pad_idx = -1; goto eusrfmt; + } icd->field = V4L2_FIELD_ANY; diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 2f6261f..30193cf 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -42,6 +42,7 @@ struct soc_camera_device { unsigned char devnum; /* Device number per host */ struct soc_camera_sense *sense; /* See comment in struct definition */ struct video_device *vdev; + int src_pad_idx; /* For media-controller drivers */ struct v4l2_ctrl_handler ctrl_handler; const struct soc_camera_format_xlate *current_fmt; struct soc_camera_format_xlate *user_formats;