From patchwork Wed Jun 3 13:59:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 29994 X-Patchwork-Delegate: g.liakhovetski@gmx.de Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Z09Dg-0002do-BC; Wed, 03 Jun 2015 16:00:36 +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 1Z09De-0005Lj-7H; Wed, 03 Jun 2015 16:00:35 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932186AbbFCOAU (ORCPT + 1 other); Wed, 3 Jun 2015 10:00:20 -0400 Received: from 82-70-136-246.dsl.in-addr.zen.co.uk ([82.70.136.246]:50761 "EHLO xk120.dyn.ducie.codethink.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755981AbbFCOAL (ORCPT ); Wed, 3 Jun 2015 10:00:11 -0400 Received: from william by xk120.dyn.ducie.codethink.co.uk with local (Exim 4.80) (envelope-from ) id 1Z09DC-0000XP-Fr; Wed, 03 Jun 2015 15:00:06 +0100 From: William Towle To: linux-media@vger.kernel.org, linux-kernel@lists.codethink.co.uk Cc: guennadi liakhovetski , sergei shtylyov , hans verkuil Subject: [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt Date: Wed, 3 Jun 2015 14:59:57 +0100 Message-Id: <1433340002-1691-11-git-send-email-william.towle@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1433340002-1691-1-git-send-email-william.towle@codethink.co.uk> References: <1433340002-1691-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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.6.3.135416 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' 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 Reviewed-by: Rob Taylor --- drivers/media/platform/soc_camera/rcar_vin.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 00c1034..cc993bc 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -1697,7 +1697,7 @@ 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; struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_TRY, }; @@ -1706,6 +1706,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, int width, height; int ret; + pad_cfg = v4l2_subdev_alloc_pad_config(sd); + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); if (!xlate) { xlate = icd->current_fmt; @@ -1734,10 +1736,15 @@ 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); - if (ret < 0) + format.pad = icd->src_pad_idx; + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), pad, + set_fmt, pad_cfg, + &format); + if (ret < 0) { + v4l2_subdev_free_pad_config(pad_cfg); return ret; + } /* Adjust only if VIN cannot scale */ if (pix->width > mf->width * 2) @@ -1759,13 +1766,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, */ mf->width = VIN_MAX_WIDTH; mf->height = VIN_MAX_HEIGHT; + format.pad = icd->src_pad_idx; 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, "client try_fmt() = %d\n", ret); + v4l2_subdev_free_pad_config(pad_cfg); return ret; } } @@ -1776,6 +1785,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd, pix->height = height; } + v4l2_subdev_free_pad_config(pad_cfg); return ret; }