From patchwork Mon Oct 19 14:07:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 7437321 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D38B9F302 for ; Mon, 19 Oct 2015 14:08:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 731FC2067D for ; Mon, 19 Oct 2015 14:07:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AB7920684 for ; Mon, 19 Oct 2015 14:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbbJSOH6 (ORCPT ); Mon, 19 Oct 2015 10:07:58 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:35667 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961AbbJSOH5 (ORCPT ); Mon, 19 Oct 2015 10:07:57 -0400 Received: by wicll6 with SMTP id ll6so7556965wic.0 for ; Mon, 19 Oct 2015 07:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=p0U6Cs9pSlnQWBUUMLcnQD5KZHr7djjdCWMG5DBGssQ=; b=CRVDfk/VD1LfwV4cOkPgDiq1L/V7RaZNa/tdIm2so3OZ+O1OLA6TUvHFRFgLU1XMC0 towMxoztbO1k86o+ymK1znS/Fiwv4SmW3raJG1b6x/RJIKYfbixwauHPXs7hWZE7sWPQ FAazkDjs+Mlmx+pHEEhfISgRT2PTSGwWu8ymvemjc9C1G9XipyQmMaPcbqevISGKvhjj mpzaNywdvneNV9r1wX1jEzjstrmUKkY2sugJTp/T49CWlniK7gjiqKr1/TTMS9dwECDr 5mZ2//0VGHAuANJadvLuBSSr0h/wDPf+i+WB5jqR4+MrwnRDxtooxQjz7xtoayTPkmUR ajYg== X-Received: by 10.180.105.33 with SMTP id gj1mr19858365wib.90.1445263676226; Mon, 19 Oct 2015 07:07:56 -0700 (PDT) Received: from groucho.site (ipbcc0ddf2.dynamic.kabel-deutschland.de. [188.192.221.242]) by smtp.gmail.com with ESMTPSA id q8sm3241169wiz.23.2015.10.19.07.07.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Oct 2015 07:07:55 -0700 (PDT) From: Ulrich Hecht To: linux-sh@vger.kernel.org Cc: magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, william.towle@codethink.co.uk, rob.taylor@codethink.co.uk, hans.verkuil@cisco.com, ian.molton@codethink.co.uk Subject: [PATCH/RFT 2/7] media: soc_camera pad-aware driver initialisation Date: Mon, 19 Oct 2015 16:07:35 +0200 Message-Id: <1445263660-6945-3-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1445263660-6945-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1445263660-6945-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: William Towle 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 71dd71c..43615c1 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -1362,6 +1362,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 9087fed..fa459c0 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1303,6 +1303,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); @@ -1321,9 +1325,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;