From patchwork Wed May 20 16:39:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 6453481 Return-Path: X-Original-To: patchwork-linux-media@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 3958F9F1CC for ; Thu, 21 May 2015 09:03:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 642C2203B7 for ; Thu, 21 May 2015 09:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B8E82028D for ; Thu, 21 May 2015 09:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932190AbbEUJD0 (ORCPT ); Thu, 21 May 2015 05:03:26 -0400 Received: from 82-70-136-246.dsl.in-addr.zen.co.uk ([82.70.136.246]:56650 "EHLO xk120.dyn.ducie.codethink.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753370AbbEUJDZ (ORCPT ); Thu, 21 May 2015 05:03:25 -0400 Received: from william by xk120.dyn.ducie.codethink.co.uk with local (Exim 4.80) (envelope-from ) id 1Yv72G-0004Br-S5; Wed, 20 May 2015 17:40:00 +0100 From: William Towle To: linux-kernel@lists.codethink.co.uk, linux-media@vger.kernel.org Cc: g.liakhovetski@gmx.de, sergei.shtylyov@cogentembedded.com, hverkuil@xs4all.nl, rob.taylor@codethink.co.uk Subject: [PATCH 09/20] media: rcar_vin: Use correct pad number in try_fmt Date: Wed, 20 May 2015 17:39:29 +0100 Message-Id: <1432139980-12619-10-git-send-email-william.towle@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432139980-12619-1-git-send-email-william.towle@codethink.co.uk> References: <1432139980-12619-1-git-send-email-william.towle@codethink.co.uk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Rob Taylor Fix rcar_vin_try_fmt to use the correct pad number when calling the subdev set_fmt. Previously pad number 0 was always used, resulting in EINVAL if the subdev cares about the pad number (e.g. ADV7612). Signed-off-by: William Towle Taylor Reviewed-by: Rob Taylor --- drivers/media/platform/soc_camera/rcar_vin.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index b4e9b43..571ab20 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -1707,12 +1707,13 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, const struct soc_camera_format_xlate *xlate; struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_subdev *sd = soc_camera_to_subdev(icd); - struct v4l2_subdev_pad_config pad_cfg; + struct v4l2_subdev_pad_config pad_cfg[sd->entity.num_pads]; struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_TRY, }; struct v4l2_mbus_framefmt *mf = &format.format; __u32 pixfmt = pix->pixelformat; + struct media_pad *remote_pad; int width, height; int ret; @@ -1744,17 +1745,24 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, mf->code = xlate->code; mf->colorspace = pix->colorspace; - ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), - pad, set_fmt, &pad_cfg, &format); + remote_pad = media_entity_remote_pad( + &icd->vdev->entity.pads[0]); + format.pad = remote_pad->index; + + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), pad, + set_fmt, pad_cfg, + &format); if (ret < 0) return ret; - /* Adjust only if VIN cannot scale */ - if (pix->width > mf->width * 2) - pix->width = mf->width * 2; - if (pix->height > mf->height * 3) - pix->height = mf->height * 3; - + /* In case the driver has adjusted 'fmt' to match the + * resolution of the live stream, 'pix' needs to pass this + * change out so that the buffer userland creates for the + * captured image/video has these dimensions + */ + pix->width = mf->width; + pix->height = mf->height; pix->field = mf->field; pix->colorspace = mf->colorspace; @@ -1769,9 +1777,10 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, */ mf->width = VIN_MAX_WIDTH; mf->height = VIN_MAX_HEIGHT; + format.pad = remote_pad->index; ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd), - pad, set_fmt, &pad_cfg, + pad, set_fmt, pad_cfg, &format); if (ret < 0) { dev_err(icd->parent,