From patchwork Mon May 20 22:50:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10952519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F3FC17E0 for ; Mon, 20 May 2019 22:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E5BD28948 for ; Mon, 20 May 2019 22:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5292728949; Mon, 20 May 2019 22:51:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2F0D2894C for ; Mon, 20 May 2019 22:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727366AbfETWu7 (ORCPT ); Mon, 20 May 2019 18:50:59 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44681 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbfETWuj (ORCPT ); Mon, 20 May 2019 18:50:39 -0400 Received: by mail-lf1-f68.google.com with SMTP id n134so11493253lfn.11; Mon, 20 May 2019 15:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rs6UcDEPHghR8cLHYXDtwpVUwKvGeIGqNO+qV7fU/Y8=; b=Jqqqv4aIPPFB3lnmqpiKFCGIvWuuiVwTcc37XWGSqmhI0OFXOUAnnjmVw3N/zaTUtz G/crC8GJVCjuhf3ukOFRt3otZI9d30YuH7EBKJCwd3OTdupVz+fARRwbn5OOyrNLV+Hl IMCqCfTiJ6RJvBuBM63CsA6Fg/HYcYz5XNf6bEvrKGJOq7+MN0WjW5NmyTtx287wnxPm iZJaZXXs/GqDNE7RuTx42l1VxspOY7RKv8Y513QClrMSC0B6sS2EQ2wBbJJ5jTFg9R07 LMGF9SwBqMIWGxXAxswAi9ET/UMhuzUTFlj/12qdcU+tSNNB4zpsWKHaGnSm24QULiK1 pamQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rs6UcDEPHghR8cLHYXDtwpVUwKvGeIGqNO+qV7fU/Y8=; b=h9ODroV/9CpLEuqBqWlHCx3VXvrkxcdsCy5qjFWB5WnMrSWh1J9at0p5ilJYsTr/D+ wRTxXJCr3n8woDfAQ/Jo+XR98pBqlr0CRe/CrnayDCthsKVSiRZdv5hWUeCkdNhVlPdN TB9O35fM6V0a51RojVWGm1Mh8CcagMDzZ/9llLZhDQPN0Jr3e8NhJWPHbFuTqgwVr96+ JqctAwwOrMF8D4FpPCXL3zcVNAly/0ZvKYOjGu9bRfGTZfbGTsHFnHJyxgsMRHiJrjVI nuTSigfe4Sgx7DLKU1K24xdgvz50vPl3Vbh5kXPu+tqvUTqB/3CB29ib99wygxMlANuw SOIQ== X-Gm-Message-State: APjAAAXT/HnQEaoothdXRtZA6pyBwFovDS1Ejt7vnTwtI/JOXTMweP+E XbtPrcRNZg5i6LVK9tRvZOUQ3Y7IUBA= X-Google-Smtp-Source: APXvYqz8K224U3tcSw51U0kihcPnj4Po/Sv2twtRlab76JyrMIb8ojrbaiLr9q6HXXiLZFQKQNz05g== X-Received: by 2002:ac2:5986:: with SMTP id w6mr39346785lfn.147.1558392637317; Mon, 20 May 2019 15:50:37 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id t13sm2371646lji.47.2019.05.20.15.50.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 15:50:36 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik , stable@vger.kernel.org Subject: [PATCH v2 6/9] media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support Date: Tue, 21 May 2019 00:50:04 +0200 Message-Id: <20190520225007.2308-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520225007.2308-1-jmkrzyszt@gmail.com> References: <20190520225007.2308-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit da298c6d98d5 ("[media] v4l2: replace video op g_mbus_fmt by pad op get_fmt") converted a former ov6650_g_fmt() video operation callback to an ov6650_get_fmt() pad operation callback. However, the converted function disregards a format->which flag that pad operations should obey and always returns active frame format settings. That can be fixed by always responding to V4L2_SUBDEV_FORMAT_TRY with -EINVAL, or providing the response from a pad config argument, likely updated by a former user call to V4L2_SUBDEV_FORMAT_TRY .set_fmt(). Since implementation of the latter is trivial, go for it. Fixes: da298c6d98d5 ("[media] v4l2: replace video op g_mbus_fmt by pad op get_fmt") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 731b03bef7a5..1915a43bff87 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -528,10 +528,16 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, *mf = ov6650_def_fmt; /* update media bus format code and frame size */ - mf->width = priv->rect.width >> priv->half_scale; - mf->height = priv->rect.height >> priv->half_scale; - mf->code = priv->code; + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { + mf->width = cfg->try_fmt.width; + mf->height = cfg->try_fmt.height; + mf->code = cfg->try_fmt.code; + } else { + mf->width = priv->rect.width >> priv->half_scale; + mf->height = priv->rect.height >> priv->half_scale; + mf->code = priv->code; + } return 0; }