From patchwork Mon Apr 8 21:42:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890205 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 2C3A81669 for ; Mon, 8 Apr 2019 21:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1732D28305 for ; Mon, 8 Apr 2019 21:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B10528385; Mon, 8 Apr 2019 21:44:42 +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 A44BF28305 for ; Mon, 8 Apr 2019 21:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbfDHVnK (ORCPT ); Mon, 8 Apr 2019 17:43:10 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40129 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbfDHVnJ (ORCPT ); Mon, 8 Apr 2019 17:43:09 -0400 Received: by mail-lj1-f193.google.com with SMTP id q66so12636477ljq.7; Mon, 08 Apr 2019 14:43:07 -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=JZGMHVwL/wB6dikUoQRPrzvmQgfUVtWFgGUr1uNGhMY=; b=mQwhqBuQTIXPblU4ESPPmFjwApe521h4TYIx6DoWH7QyZqIBlB2+W+QKl60WqEWq2Z mTleF0qCmpJHjj0TSo3iQPzPhWMCP65/yIC4r17NjLG36rL33dE6n/vm6AvpwYikCvex aBzDhZOfyy8s/tBAzgEGJxbDLB92RFXEGXQI2vtyjXnkqHWohzqtEY5ydkooECTXhFZX /S4eEZ7RFVetDDqNFcGiO1tZSM6rmlDYbChvrX9Yv6A5Xp0m1/Sb36721kdO1fycnZ0H pdeghNy5pFMvvQ7rI48Kkj0BOH9mhgH4IzbpddxXLMr+C4uMrgg9Dzh5TFM7H1TjVlgV /tDA== 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=JZGMHVwL/wB6dikUoQRPrzvmQgfUVtWFgGUr1uNGhMY=; b=pP/4HlwDnnDAbZ7i+3/Md69r93rELVkpngd320F+vG1Waj3Et22AHRnLP+XgvMGY3U sKabdoHv9WHaKJIUAhHOOTYmDH66nn8wSWaSzN2TVB8GNQU33nXXzU2WqNDYQUDOJX9A G4DE93yrAFRVau0A9IwJujksqn6U82CSGhAf9x505Ro9opzQN4bPdtviGGb4a5ouGv5l ZXtQqrCHy+s/CYuUeRzP2Pz+vSZAwWCWrQqGYUmV783oFvZ4j69QUi0JHgQLjGh7L9Zc JtI+I4X61A6fIB42739cFdVd5tqqD+xkKuilOnVsypNQvAbFtBdfwa8R1iSfJDoBk8NA 9y0w== X-Gm-Message-State: APjAAAUflV2Ros2J1hjaTkiz1FIvyoMT9Pvi+37v0dulMYWcr2yIwRZO u5J8jd7Pgr9ILSwO/nuLGkI= X-Google-Smtp-Source: APXvYqzg8anJQbJWblybucPJ3c5h0r4nX2dbwzEuxrYYctHEH9GkwKi4ygVEotZfoL2e7nyEmgKVAA== X-Received: by 2002:a2e:3e18:: with SMTP id l24mr18377256lja.68.1554759787065; Mon, 08 Apr 2019 14:43:07 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:06 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 01/14] media: ov6650: Fix MODDULE_DESCRIPTION Date: Mon, 8 Apr 2019 23:42:29 +0200 Message-Id: <20190408214242.9603-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 23a52386fabe ("media: ov6650: convert to standalone v4l2 subdevice") converted the driver from a soc_camera sensor to a standalone V4L subdevice driver. Unfortunately, module description was not updated to reflect the change. Fix it. While being at it, update email address of the module author. Fixes: 23a52386fabe ("media: ov6650: convert to standalone v4l2 subdevice") Signed-off-by: Janusz Krzysztofik cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 1b972e591b48..a3d00afcb0c8 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -1045,6 +1045,6 @@ static struct i2c_driver ov6650_i2c_driver = { module_i2c_driver(ov6650_i2c_driver); -MODULE_DESCRIPTION("SoC Camera driver for OmniVision OV6650"); -MODULE_AUTHOR("Janusz Krzysztofik "); +MODULE_DESCRIPTION("V4L2 subdevice driver for OmniVision OV6650 camera sensor"); +MODULE_AUTHOR("Janusz Krzysztofik X-Patchwork-Id: 10890207 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 61F9517E0 for ; Mon, 8 Apr 2019 21:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CBE928305 for ; Mon, 8 Apr 2019 21:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FA828385; Mon, 8 Apr 2019 21:44:48 +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 E0DCC28305 for ; Mon, 8 Apr 2019 21:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbfDHVol (ORCPT ); Mon, 8 Apr 2019 17:44:41 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44647 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfDHVnK (ORCPT ); Mon, 8 Apr 2019 17:43:10 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so12592310ljg.11; Mon, 08 Apr 2019 14:43:09 -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=Vxf6jf0I3TNkNsrZiapyq8fbjujSIosIG2y16ynybBA=; b=kEd6eRqE0z2WuDnDs75PDb7FoCwTYeelkZLzX0z2TqwCfxh+waChPeEgq6aCK9OpoY h1kHL8aToAd026GdN3VUqTlMVxIU4z3oKOYKy8CVU3VpIKibmaGb6bnXhJGDbyefryx+ 2bz4M5FxHg8R+qOzBo94YmUIvXUd/owjrvC62SC78g5apa+I5rwqKHpv8gQmYhbGENB/ PFzqcMEM8HNnTVvkrCphbfcnbzi4AKxs+L5otKtXHkzpbZGECc6N2enxLPja9RHftexX cMPbqaYNs9y51xZMsxMiakKFSDB75KlV2M99BDdL6peg2sqkedDm0BZUTcKb80UeFUea 0nig== 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=Vxf6jf0I3TNkNsrZiapyq8fbjujSIosIG2y16ynybBA=; b=uQxbzsBMqth+EFVwXxNl8BFoEV7DIMUW2OPr+Ze/zWSHBQMWN9ZxFTJNQfIAbbc0Mp 94a0tDc61Cd9mu6NwOKxHFJHCJO+0PYWeZNs0iTyv+U/HOzg9NE0WZb2jrtbzKA3Cach lnF5Eqa9hd3FRHrWDuPuQ2J3PGKbazsI94GSCQNhM+87L0w8Alhm58qaNXkLh3af1us7 j3m6NVQSEf5xJf4x57fPxjhX3FHUSWQhmcYjrdb9+5c9v0NWPr5nm1ZCR43YENh7ZLsn 1FZUr/C0gmjcPFne8jSZHB1H/ynIMBM+4Lsp2PhKZ7EfQkFyXD5Nj7CssQtzbkuOZkD+ 9BTQ== X-Gm-Message-State: APjAAAWcNgA/qqrAOiwSxSwDjEmTDESgCBSZ0eI0CeEOOE0B558LPsFx d0ssCW6EDJZxRT6lZzjqWRU= X-Google-Smtp-Source: APXvYqzF+x9ytABIqa1o88uB0Zp0yJSvBJXKEgO47uCtT1EVk1NKFlUbXcwp1Q/VV6hlVh6c+HPwTA== X-Received: by 2002:a2e:380c:: with SMTP id f12mr18327410lja.116.1554759788393; Mon, 08 Apr 2019 14:43:08 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:07 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 02/14] media: ov6650: Fix control handler not freed on init error Date: Mon, 8 Apr 2019 23:42:30 +0200 Message-Id: <20190408214242.9603-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 Since commit afd9690c72c3 ("[media] ov6650: convert to the control framework"), if an error occurs during initialization of a control handler, resources possibly allocated to the handler are not freed before device initialiaton is aborted. Fix it. Fixes: afd9690c72c3 ("[media] ov6650: convert to the control framework") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index a3d00afcb0c8..007f0ca24913 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -992,8 +992,10 @@ static int ov6650_probe(struct i2c_client *client, V4L2_CID_GAMMA, 0, 0xff, 1, 0x12); priv->subdev.ctrl_handler = &priv->hdl; - if (priv->hdl.error) - return priv->hdl.error; + if (priv->hdl.error) { + ret = priv->hdl.error; + goto ectlhdlfree; + } v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true); v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true); @@ -1012,8 +1014,10 @@ static int ov6650_probe(struct i2c_client *client, priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ret = v4l2_async_register_subdev(&priv->subdev); - if (ret) - v4l2_ctrl_handler_free(&priv->hdl); + if (!ret) + return 0; +ectlhdlfree: + v4l2_ctrl_handler_free(&priv->hdl); return ret; } From patchwork Mon Apr 8 21:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890203 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 BFE0A1669 for ; Mon, 8 Apr 2019 21:44:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F2328305 for ; Mon, 8 Apr 2019 21:44:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9F628385; Mon, 8 Apr 2019 21:44:40 +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 43FC628305 for ; Mon, 8 Apr 2019 21:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728762AbfDHVoe (ORCPT ); Mon, 8 Apr 2019 17:44:34 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37436 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbfDHVnM (ORCPT ); Mon, 8 Apr 2019 17:43:12 -0400 Received: by mail-lj1-f194.google.com with SMTP id v13so12621426ljk.4; Mon, 08 Apr 2019 14:43:10 -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=wVGmZYRQa/9aCw2opSqt9la4dXQ+gNuOGKIGTuXbWis=; b=FL1aVqazYKyeiRdnsIA7ddxCVe0Za9WN2WqRdAKtqzjisAhJH8ey3NCk58rCjxY6mv fF7EqAcyglUEgTqJURsbvfgy5oY0gn5c9XuNjxr/xRZdXCERpKpJq/oTbQpD98d3A97F rcf9w9K931fdlpf8y5dfwPaIl6LxeuOKyxpW9xOk8w3jeTXOWScmnEiiUBsN1162dYbM xlLtkOC1eRAUP4/qbCai8bRkhZmjJr5sC0YzY8+9CCdn9XKr3LBeWOSMpeb2UTspgbx6 fLemcikKvnyD0Zc4D//MzbzWnZFjNu2vR0+yFQkkruz4JF+PbhtmDD3a++OEhxEaenLL vkMQ== 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=wVGmZYRQa/9aCw2opSqt9la4dXQ+gNuOGKIGTuXbWis=; b=S8AA4Y92dCkLga5Dh8e++UGoLm67LOHiT805KLUyoVPWUSQvUf9zRegNFpxCyeR436 PNYCmnmIShW8Ywr5e51yZFQjDoynbLXM0KrrwxI7HgsNgjBKut3Mftbz1TUCcpW0QfXn SAOTXUA7VFKwDJHy3gBMUn12N9bDQLc0+KfxSOvlNK/EeZ7A+rOokLbm1Sz1XMm0q/lM +tOlrI1hFPaNwHHjxJ8PoHKB0sBbXM52VfEdRSSJBzq/6+P0uWMDe5MdsmmZx3OCEQ1R YknsaVNnpCxrOVdpCjqKWdaPMRQL1SsZTebL5voIShMGRv1NBnpqQE393TRVCZv4rGMu tVpw== X-Gm-Message-State: APjAAAVX6RPWd9J0ZUdIrdSY2m8iTi7oqw8Tk27LcVYlc6l1hUwmPyvI V02rxeK4W52X9uWiVsNMhLo= X-Google-Smtp-Source: APXvYqzKeN1U1hF7Hdb+KN0Fz/pjr4bIGcje3CKRAxpZRdNWlFHPKkBSkgWqmEWNw2NfkC3tIol2wA== X-Received: by 2002:a2e:9e4d:: with SMTP id g13mr14908111ljk.12.1554759789708; Mon, 08 Apr 2019 14:43:09 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:09 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 03/14] media: ov6650: Fix unverified arguments used in .set_fmt() Date: Mon, 8 Apr 2019 23:42:31 +0200 Message-Id: <20190408214242.9603-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_fmt") converted a former ov6650_try_fmt() video operation callback to an ov6650_set_fmt() pad operation callback. However, the function does not verify correctness of user provided format->which flag and pad config pointer arguments. Fix it. Fixes: 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_fmt") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 007f0ca24913..3062c9a6c57b 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -679,6 +679,17 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + switch (format->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + if (is_unscaled_ok(mf->width, mf->height, &priv->rect)) v4l_bound_align_image(&mf->width, 2, W_CIF, 1, &mf->height, 2, H_CIF, 1, 0); From patchwork Mon Apr 8 21:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890201 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 449AD17E0 for ; Mon, 8 Apr 2019 21:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B2E227F8F for ; Mon, 8 Apr 2019 21:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1989928396; Mon, 8 Apr 2019 21:44:33 +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 BD63327F8F for ; Mon, 8 Apr 2019 21:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbfDHVnR (ORCPT ); Mon, 8 Apr 2019 17:43:17 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39047 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbfDHVnN (ORCPT ); Mon, 8 Apr 2019 17:43:13 -0400 Received: by mail-lj1-f194.google.com with SMTP id l7so12625838ljg.6; Mon, 08 Apr 2019 14:43:11 -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=xnC2Q7NaDaS6u2MiZtA1HALfljD2ysiOfTyMydRHW5s=; b=jwI1amulwo1LNJ7let0l3PYX2sHWrU0Wk/Aa+C+fZ9at8nr+emkX5+/J+ENdx4uMnW XDzn106OibE71EMGOgwlbOdgM4hz9PnzZUwEJz8IP1VDIHhWIXvuKVrwR7zOyp7nhq9t ilbOIVFzMf7/jYUfSb5kCd7DxGZ+qN+hSBJYjIRHKYaloZobk/Yo9TD9HG7uImliYS9K NJ+HbW7O8aahkrFBRDm1uYAlfdS1NWECBkJPV9nWUog+J069Z+AcsqOBuvfvNxYQizO+ bLD0fgKWnDbQTQN5aWpinFKKZCl2Ak8dEf49cI4p7D0tgxUTbxwEMJAqU+IKIh3EvnXp Cvog== 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=xnC2Q7NaDaS6u2MiZtA1HALfljD2ysiOfTyMydRHW5s=; b=H4+1H8WvPiyvIIhz6G604hJCJMgRrYUQrphcYZApOv5HlSwQX9Ul8i+4vAveSDdCYf O8C1X8rNxZjHlKuKCHtV6VWBFol4TPeEa4G3TKLDFdm2mdLq0gls+rjWXWIhCmRDtIkI 8i2Km0AhB91SKBcMVZ9KR5TD6BsNOD/EfRDwItVKk9TocBp+Q3u2R3LaPp4Zab2fCF82 xg0L2KXddqXbzVirpWSUI/0G/eHKDUVQAahnLhUN7P+JYXWRN+h1S3eK/naOp1Xmj29j 8JEBAtCR4VpnUgOxmT2qLO7Xf4L6qerIEJ/kMYI3iv1mGnaYD076+kAEUWgQkb86YdYB iaMA== X-Gm-Message-State: APjAAAVlbGZuQOvfGt2Ob4dji6RxBdJ8DDFYMlQS/GQ1ihDvXwvOELtT 0NTgrWNYNoKlP118NmFQwPo= X-Google-Smtp-Source: APXvYqxauJIfcTHs7hvjNNsT7DBEM4bIBQ3n+vkcEWHA4MvX9iX4iOn5984BYUfeQv30NsrUVEPm+Q== X-Received: by 2002:a2e:7c02:: with SMTP id x2mr14248044ljc.176.1554759790982; Mon, 08 Apr 2019 14:43:10 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:10 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 04/14] media: ov6650: Fix unverified arguments accepted by .get_fmt() Date: Mon, 8 Apr 2019 23:42:32 +0200 Message-Id: <20190408214242.9603-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 function does not verify correctness of user provided format->which flag and pad config pointer arguments. Fix it. Even if the function never dereferences the pad config pointer argument, return -EINVAL if it is NULL on V4L2_SUBDEV_FORMAT_TRY. 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 3062c9a6c57b..5c1738c5a847 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -515,6 +515,17 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + switch (format->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + mf->width = priv->rect.width >> priv->half_scale; mf->height = priv->rect.height >> priv->half_scale; mf->code = priv->code; From patchwork Mon Apr 8 21:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890197 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 C47F01669 for ; Mon, 8 Apr 2019 21:44:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF4DA27F8F for ; Mon, 8 Apr 2019 21:44:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3A4828396; Mon, 8 Apr 2019 21:44:25 +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 53A2527F8F for ; Mon, 8 Apr 2019 21:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfDHVnR (ORCPT ); Mon, 8 Apr 2019 17:43:17 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41667 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfDHVnO (ORCPT ); Mon, 8 Apr 2019 17:43:14 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so12614235lja.8; Mon, 08 Apr 2019 14:43:13 -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=rbgUHGjL1xlbhm4c7TA1e007Ia4N5yQjhJSCjSQrlG4=; b=Gz2yzpBFmZKAVC3+G4MSMz9MbVA6uZZz81GdKDIQjv2OLQa5OJgapvd/gWAoBN/W3N d5c/eacu7gHMpO8hDJ/6rSaRjLjvxqqA0XY2DrqFiiBr367oX3sS7y5y0GaSK9xUbnGD K0Y/q6X8Bnu67LGPv/vrGWRR8lTdKX/sCtqdWWDGVOSDDkexs3VlWDwVDH8Y/xPoZW8/ /D6jFuIYw5geVquOTVdQUWouhxHvDCI8X2jL8UXcaPo61hIWAi74fCrdo+G8aRZxPzKv lZsl3F+jSolFiWISXm+qBAwtOQ6fXmcV1Q0gOcIFTiW6lizXlKi5JADSSsGTe5uZnCZn 2l9A== 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=rbgUHGjL1xlbhm4c7TA1e007Ia4N5yQjhJSCjSQrlG4=; b=Pzw9vsDbZJrfmQq38ya/ZSgYj1uy8phXcZsj3jBZRM6zcTpBqEa9iUod0orYhcyCci HVixrrQuBcqowsob3CrpBkUe+zHdRw2G0mPdqFsuMyi+5ah1vc3MyoghJ/f+c83GYota ZVBMKeEJWJV+EIPJqXhVn1WpIiyPFuAtS64zftOy4hlB8xAqCj4RabhWrfockv2bSrVT +ZzX3GOQChRm3RpPtHSLq5jxCHzWFccGITdhHtrROqnm8DXOwtirr/DfLHU80oxupS9e QXEXfa3O4of9SmG0gyC6qlnehsiH53m9nmJAwkw2Cd1h3U2040O6jAqoEGPn7D+Fd40/ Cw4A== X-Gm-Message-State: APjAAAVpgao5xRKbVjrlZdmja+7h2IcLWG7V+XKCEwUPur/jdfC7V5Ur 1AZpo/Tlyo97Ah9p3zTUVGo= X-Google-Smtp-Source: APXvYqwaLCRlql5xhgTnrM13tvT/qr8vUX1h+Jj5AJzgIpGqjFfKxlqRPG/MhURFuNZ16uthFe+Vzw== X-Received: by 2002:a2e:3803:: with SMTP id f3mr18200964lja.165.1554759792252; Mon, 08 Apr 2019 14:43:12 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:11 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 05/14] media: ov6650: Fix unverified arguments accepted by .enum_mbus_code() Date: Mon, 8 Apr 2019 23:42:33 +0200 Message-Id: <20190408214242.9603-6-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 ebcff5fce6b1 ("[media] v4l2: replace enum_mbus_fmt by enum_mbus_code") converted a former ov6650_enum_fmt() video operation callback to an ov6650_enum_mbus_fmt() pad operation callback. However, the function dees not verify correctness of code->which flag and pad config pointer arguments. Fix it. Even if the function has no need to dereference the pad config pointer argument, return -EINVAL if it is NULL on V4L2_SUBDEV_FORMAT_TRY. Fixes: ebcff5fce6b1 ("[media] v4l2: replace enum_mbus_fmt by enum_mbus_code") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 5c1738c5a847..d72fcf56930a 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -737,7 +737,21 @@ static int ov6650_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { - if (code->pad || code->index >= ARRAY_SIZE(ov6650_codes)) + if (code->pad) + return -EINVAL; + + switch (code->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + + if (code->index >= ARRAY_SIZE(ov6650_codes)) return -EINVAL; code->code = ov6650_codes[code->index]; From patchwork Mon Apr 8 21:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890181 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 A032417E0 for ; Mon, 8 Apr 2019 21:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88E00287BB for ; Mon, 8 Apr 2019 21:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 872192880D; Mon, 8 Apr 2019 21:43:19 +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 2D160287CD for ; Mon, 8 Apr 2019 21:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbfDHVnR (ORCPT ); Mon, 8 Apr 2019 17:43:17 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36315 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbfDHVnP (ORCPT ); Mon, 8 Apr 2019 17:43:15 -0400 Received: by mail-lj1-f193.google.com with SMTP id r24so888106ljg.3; Mon, 08 Apr 2019 14:43:14 -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=ina1sug/tV7DpNodQARtmW1O98Az5HmyxzHtxFz5C9Q=; b=rYZEMZFg+74Q9FodscmpozPnMJuIdLHxCJndLHe2yscN20QYNhLv/YdqkTQS+tG1i4 thcQYHx9arols07rgNbhTqeur93BE8OVhWgFYmn/pu6gF2U8Kr3ONa1kFw97n75JDlF/ k7wq0tJS5yHvzIzsAuojmP4zHKmKBVf5bxJA3AUMiRJcx79eJCyxo8uTT9U43cL9oRYA 8XqXQfwnGNBT9fzIGFErRQkzkDK3djby9+vo7euW3e3vwW7v1JkAHaPzBMq22biqcumC n4FvK9aBgth/X3uaEMBdHE+xmwNPGAaLjKuIGN2bsoRiOnzknJE7KSn5sJdIENdwqxEB xp1A== 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=ina1sug/tV7DpNodQARtmW1O98Az5HmyxzHtxFz5C9Q=; b=W8OA242bo0aP+RRg/9/1y3C2aRlGJBupnffYCAFGhSEkLBTw0odxgOf5VOX8EevIEH kjUE+wt5QMtSwNpZnyjGEi9YVmMGmNngBUL8ILBp2HE5ojPEuksalBtU0XnlQjq4KzKv PnnjVkdcoYCiJXeA84ONsqZMBme6hUIC35Q1I30zGz3MCI3XQ5km365QrjycnoDeUfTc CiLy8/kT0lI1Bok73kZo6oum031LzwEHjaUFnQtqtx8hYyFMnzFootD6VA7Iq3IMwLNW NggZUoRTJwz9qzZ2VZFQoeK5k7Gshc7fTnYw5Nv7wD+D9dC2yyBUPC2PQfv5+1ogpnkE biyg== X-Gm-Message-State: APjAAAXf4XgpuuvN4IsFshFkZCy1dw8nZzfU6xnPEz7Gjl4sEJSa+Pzv ksjb9GqPVpeyGr838LU/yTE= X-Google-Smtp-Source: APXvYqxUKZ8HkAowwwJVw6qY9IRGO66+uJ1o+tPgFTPL4mO4y/5S4k1evlo5zb2J0WPbkIvVRf7FYw== X-Received: by 2002:a2e:9ec3:: with SMTP id h3mr1550336ljk.131.1554759793535; Mon, 08 Apr 2019 14:43:13 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:12 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 06/14] media: ov6650: Fix unverified pad IDs accepted by .get/set_selectioon() Date: Mon, 8 Apr 2019 23:42:34 +0200 Message-Id: <20190408214242.9603-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") converted former ov6650_g/s_crop() video operation callbacks to ov6650_get/set_selection() pad operation callbacks. However, the new functions don't verify correctness of pad IDs passed in user arguments. Fix it. Even if pad ID arguments are not actually used in those functions, assumed to be 0, always return -EINVAL if an operation on an invalid (non-zero) pad is requested by a user. Fixes: 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index d72fcf56930a..5df81dec06ae 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -444,6 +444,9 @@ static int ov6650_get_selection(struct v4l2_subdev *sd, struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); + if (sel->pad) + return -EINVAL; + if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) return -EINVAL; @@ -471,6 +474,9 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, struct v4l2_rect rect = sel->r; int ret; + if (sel->pad) + return -EINVAL; + if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE || sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; From patchwork Mon Apr 8 21:42:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890199 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 0DD5517E0 for ; Mon, 8 Apr 2019 21:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB61127F8F for ; Mon, 8 Apr 2019 21:44:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE2AA28396; Mon, 8 Apr 2019 21:44:30 +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 8890427F8F for ; Mon, 8 Apr 2019 21:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbfDHVoZ (ORCPT ); Mon, 8 Apr 2019 17:44:25 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40606 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbfDHVnR (ORCPT ); Mon, 8 Apr 2019 17:43:17 -0400 Received: by mail-lf1-f66.google.com with SMTP id a28so10627473lfo.7; Mon, 08 Apr 2019 14:43:15 -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=JZJX0cBW48BfmEFVskcagOwO7Nr6Cx7mLM31SY93LnA=; b=setoFDWkhlc33k/Jfb0WClbzs9jH7Er0bGixMeKL6L7VlVvgVqiTOu5Vcn36/VCb1q Qwq39P4QV49WN+vDiTsrE/hXr1gSctgQOUeMlvTJ9q19Lgh0eY5niJNBT04EKYKbXE+M G79Wnkzzya9nS0X1Px4lHlG7tLIxFOkodHKriIehIlQtMv8+wtIt2PSA5VGpgYgzXZbd YjpnfFyT5wAYrkua6kDFPyZiYK2F2EJLw6VJz2AfkwBKZH/Sv+Vrsi1ipglqL7bJe2z7 NbdTtFpuWrFOiZQTu/TrV3A6HMJOOFsZEpTUTF1jDUjhgBU0h/Vj1Oo2I1ZE0GsxBIil WHTA== 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=JZJX0cBW48BfmEFVskcagOwO7Nr6Cx7mLM31SY93LnA=; b=l8Ik8wNxGwMgUQvlvYphY5HnXvSa9HLX7GKMxqHuDIsygHXkJOb8qqjGyWCgHHZmGD lc+rXBUHno/egCo6GjFt3b4qX5FuSIP5eOOXL9VPgHPoMeoTfRGh3AVM+FE/MkJC7lSr jNgNxrJmLG7D/gF8qpkrdFkP00NcCkYlUuIVWGlP0rz7g6LFEsKktGAI4TelKeRjKCN3 QUZABZuqZAs6/rbkyyxEilmJ2erdZG9UJEoAuJhDw/rlyeCC05IPc6f5lUKpA6rYCZ8E Zw5P5s7lnxUMmNTR+OG3t9t8QU3JE8qrE+yoaz+vupea4dT/L52F2k1wihxkGtmM6pD3 hy2w== X-Gm-Message-State: APjAAAXZ5qM1/IXeMQR2M0ypwhQ5TEk911GAEaX+OtmmwXoIEuSUM6yu 4CWZaH4o2yPvRsx58KvPiPgnO9aW4n4= X-Google-Smtp-Source: APXvYqx4OJ+CQMPT+7DgGtrZQp8tX7Y66jbzrL9XKamSwfI59Ang55K1DZoGGzUlWYmS4Wz8QMIkTQ== X-Received: by 2002:ac2:4115:: with SMTP id b21mr17756590lfi.54.1554759794879; Mon, 08 Apr 2019 14:43:14 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:14 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 07/14] media: ov6650: Fix unverified pad IDs accepted by .g/s_frame_interval() Date: Mon, 8 Apr 2019 23:42:35 +0200 Message-Id: <20190408214242.9603-8-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 4471109e3894 ("media: convert g/s_parm to g/s_frame_interval in subdevs") comverted former ov6650_g/s_parm() video_operation_callbacks to ov6650_g/s_frame_interval() pad operation callbacks. Howeveer, the new functions don't verify correcntess of pad IDs passed in user arguments. Fix it. Even if pad ID arguments are not actually used in those functions, assumed to be 0, always return -EINVAL if an operation on an invalid (non-zero) pad is requested by a user. Fixes: 4471109e3894 ("media: convert g/s_parm to g/s_frame_interval in subdevs") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 5df81dec06ae..1daef0c7ad91 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -770,6 +770,9 @@ static int ov6650_g_frame_interval(struct v4l2_subdev *sd, struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); + if (ival->pad) + return -EINVAL; + ival->interval.numerator = GET_CLKRC_DIV(to_clkrc(&priv->tpf, priv->pclk_limit, priv->pclk_max)); ival->interval.denominator = FRAME_RATE_MAX; @@ -789,6 +792,9 @@ static int ov6650_s_frame_interval(struct v4l2_subdev *sd, int div, ret; u8 clkrc; + if (ival->pad) + return -EINVAL; + if (tpf->numerator == 0 || tpf->denominator == 0) div = 1; /* Reset to full rate */ else From patchwork Mon Apr 8 21:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890195 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 BDDFB1669 for ; Mon, 8 Apr 2019 21:44:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A781727F8F for ; Mon, 8 Apr 2019 21:44:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B91F28396; Mon, 8 Apr 2019 21:44:17 +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 2A06627F8F for ; Mon, 8 Apr 2019 21:44:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbfDHVoL (ORCPT ); Mon, 8 Apr 2019 17:44:11 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44654 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfDHVnT (ORCPT ); Mon, 8 Apr 2019 17:43:19 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so12592510ljg.11; Mon, 08 Apr 2019 14:43:17 -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=TDPWX+c9T8wtLVwEqZLlhf3dHuEObpXGSnaRZkfVeqo=; b=ZTWZdhB/OFzD9rVvGhiW8mkmgo5pEDqG3JYgsUK7mzudPv5RFiwjuaF//snIOzR4Cm WTV3mvQPERZcfbhRcbL3SIojFa2j6lbCl3xN4WelY3qwb2B3tMqZ8Q5ki+QxMwWTd38O a5n9hbTFw9pL1cOKjHFgzTch82Qm7VeTli0niIukU7WBgpuPMIMACpShltGfNEReKHHL 1ky6VlyIHhuEO+HvU8xLAh/fReOGdtut5Xn3zAmjGsVck/BeRJVQ32y72A7jq8ZeUSHi 3bCJ3eVW0H1JGWNzTCjqrxjg2UvGH8xvVQWUPoFuXksCOchByJn3cn5qqbEMDlrZSsIx tGQQ== 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=TDPWX+c9T8wtLVwEqZLlhf3dHuEObpXGSnaRZkfVeqo=; b=ifUDjKipSb07lNkt1+LKymhWgkII4etPy3F3+iV1eXhn+UTAQlKrUc78XEPdJI2iE3 3lm0OQQ9LrU2tu1plNnSqlgBLIe2oUT/wyOFKJnnPy6Y+4T6uiKpgxWIgfOX5m97kxSn Fbyn145saaSfm4StCjgoz0HyG4tgIVG/DkdBD5BmwvW9x3k2y2IN3So7doLnI6XtuqJI Xs48ZKP+lhq5j7DJNTB78tjH8kVhSSPD3QKZv/NAygyRbDenewJnPTr2CDCZV/JroK2V vM7hzCnO0NTWHE8ok/wS4QPpPhUz6jx9bIi5AlcGqvX0fvKw+wUCHn3J/yZs3RedrtNB SYdw== X-Gm-Message-State: APjAAAXcOMAL6KToCOu4ESuTjQFBfxSf5TBNJRo13/KuFSD1AP1TMxZe bpEoUjt5c0hvpXD7cONcHyo= X-Google-Smtp-Source: APXvYqybad6RwzU9/9VlZroERFMff7Ldyv/jJ+o8b73V8h3WGCqzgR/gQj9hPSGOZ/5uKoPMywP1LQ== X-Received: by 2002:a2e:808e:: with SMTP id i14mr18167106ljg.103.1554759796391; Mon, 08 Apr 2019 14:43:16 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:15 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik , staable@vger.kernel.org Subject: [PATCH 08/14] media: ov6650: Fix crop rectangle alignment not passed back Date: Mon, 8 Apr 2019 23:42:36 +0200 Message-Id: <20190408214242.9603-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 4f996594ceaf ("[media] v4l2: make vidioc_s_crop const") introduced a writable copy of constified user requested crop rectangle in order to be able to perform hardware alignments on it. Later on, commit 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") replaced s_crop() video operaion using that const argument with set_selection() pad operation which had a corresponding argument not constified, however the original behavior of the driver was not restored. Since that time, any hardware alignment applied on a user requested crop rectangle is not passed back to the user calling .set_selection() as it should be. Fix the issue by dropping the copy and replacing all references to it with references to the crop rectangle embedded in the user argument. Fixes: 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") Signed-off-by: Janusz Krzysztofik Cc: staable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 1daef0c7ad91..07d7a0708cca 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -471,7 +471,6 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); - struct v4l2_rect rect = sel->r; int ret; if (sel->pad) @@ -481,31 +480,31 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - v4l_bound_align_image(&rect.width, 2, W_CIF, 1, - &rect.height, 2, H_CIF, 1, 0); - v4l_bound_align_image(&rect.left, DEF_HSTRT << 1, - (DEF_HSTRT << 1) + W_CIF - (__s32)rect.width, 1, - &rect.top, DEF_VSTRT << 1, - (DEF_VSTRT << 1) + H_CIF - (__s32)rect.height, 1, - 0); + v4l_bound_align_image(&sel->r.width, 2, W_CIF, 1, + &sel->r.height, 2, H_CIF, 1, 0); + v4l_bound_align_image(&sel->r.left, DEF_HSTRT << 1, + (DEF_HSTRT << 1) + W_CIF - (__s32)sel->r.width, 1, + &sel->r.top, DEF_VSTRT << 1, + (DEF_VSTRT << 1) + H_CIF - (__s32)sel->r.height, + 1, 0); - ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1); + ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1); if (!ret) { - priv->rect.left = rect.left; + priv->rect.left = sel->r.left; ret = ov6650_reg_write(client, REG_HSTOP, - (rect.left + rect.width) >> 1); + (sel->r.left + sel->r.width) >> 1); } if (!ret) { - priv->rect.width = rect.width; - ret = ov6650_reg_write(client, REG_VSTRT, rect.top >> 1); + priv->rect.width = sel->r.width; + ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1); } if (!ret) { - priv->rect.top = rect.top; + priv->rect.top = sel->r.top; ret = ov6650_reg_write(client, REG_VSTOP, - (rect.top + rect.height) >> 1); + (sel->r.top + sel->r.height) >> 1); } if (!ret) - priv->rect.height = rect.height; + priv->rect.height = sel->r.height; return ret; } From patchwork Mon Apr 8 21:42:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890183 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 1A7FC1669 for ; Mon, 8 Apr 2019 21:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0354D28537 for ; Mon, 8 Apr 2019 21:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBED8287CD; Mon, 8 Apr 2019 21:43:24 +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 83BE428537 for ; Mon, 8 Apr 2019 21:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727287AbfDHVnX (ORCPT ); Mon, 8 Apr 2019 17:43:23 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40607 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbfDHVnU (ORCPT ); Mon, 8 Apr 2019 17:43:20 -0400 Received: by mail-lf1-f66.google.com with SMTP id a28so10627541lfo.7; Mon, 08 Apr 2019 14:43:18 -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=NENsT2NLOI8UTcTWM+JMOR9wkbUmlrUzrLqxG+pnjm4=; b=MrI82FVbWabTUtG+jGIz5JUUtLm0LgLp8ckjj6x6m43Zsn8elameDJOQd9ey3Xn49V ev8XkZLV6MqnevpQ5zyoGiGI1YJwMGQIXX9/6hwBsRcLyQ2uDCzZ7Gghc2XnXLxBJAN2 yg+4kg0By0Sud9WNhVqHWs65bugYE8gUpzjuhRKn/nbZiL1leW/a94+ZTPea5gglR01p a/r+kFxHESY6xfVnhQnae2v+ZTVBkXx4NFDlMykYh1BsfjBwH39i1T343NiR1Vk9Dz8z Yt+mUAhRWNatijLWVXwjcuFjMCM/gzmaMODnwFt5eKpniCzwLWALTQPdxX3RvfCNGQkd oKyQ== 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=NENsT2NLOI8UTcTWM+JMOR9wkbUmlrUzrLqxG+pnjm4=; b=WiD3JTup6Lod24gtj63j+1GkTDB/MT5WzcbqEA8b61m2vYj4ft2D9Y8CuqdJBCH6LW 6FbJl6REK64RqSAcJjmQZ7HCP+ipYEXXwfvY2kmmDYwhEjC8mle87lxBMFICjyCMxfEL lTX+rlLt1NkT357AncrOAehQqR7kPK0M9q2kc3UCSjX8tLNFE1JmadhQ3s+/GmaHVw2g HHX5cScMaQBztRXL3yBYfnQPYEsOKoXLUWFTE24uxFSpfw0H+J12j9CRrrFGdxm7clMA Ao4iWosb/XFSSUiWKaT/uWHZJXpvxPvpgDbWGr+GEyqwwJn3Y0mNFcjEPjH+yslokE0u FqHA== X-Gm-Message-State: APjAAAW5r3cfQErJ4lBcGhz+YwNz+6KLCJDUKMp22RGPaTS2I917brQq 4jvvuHrJHMBR6qLQxukaBmY= X-Google-Smtp-Source: APXvYqzlNvX6eZVRQHIFMamGG3srIfiy6oDh4zCEp5Qxcz+J/IaujKlokld4iI9+htuxcPhR1WqjeQ== X-Received: by 2002:a19:d14e:: with SMTP id i75mr3025684lfg.55.1554759797611; Mon, 08 Apr 2019 14:43:17 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:17 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 09/14] media: ov6650: Fix incorrect use of JPEG colorspace Date: Mon, 8 Apr 2019 23:42:37 +0200 Message-Id: <20190408214242.9603-10-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 Since its initial submission, the driver selects V4L2_COLORSPACE_JPEG for supported formats other than V4L2_MBUS_FMT_SBGGR8_1X8. According to v4l2-compliance test program, V4L2_COLORSPACE_JPEG applies exclusively to V4L2_PIX_FMT_JPEG. Since the sensor does not support JPEG format, fix it to always select V4L2_COLORSPACE_SRGB. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 07d7a0708cca..dfee07ec976e 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -203,7 +203,6 @@ struct ov6650 { unsigned long pclk_max; /* from resolution and format */ struct v4l2_fract tpf; /* as requested with s_frame_interval */ u32 code; - enum v4l2_colorspace colorspace; }; @@ -534,7 +533,7 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, mf->width = priv->rect.width >> priv->half_scale; mf->height = priv->rect.height >> priv->half_scale; mf->code = priv->code; - mf->colorspace = priv->colorspace; + mf->colorspace = V4L2_COLORSPACE_SRGB; mf->field = V4L2_FIELD_NONE; return 0; @@ -642,11 +641,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) priv->pclk_max = 8000000; } - if (code == MEDIA_BUS_FMT_SBGGR8_1X8) - priv->colorspace = V4L2_COLORSPACE_SRGB; - else if (code != 0) - priv->colorspace = V4L2_COLORSPACE_JPEG; - if (half_scale) { dev_dbg(&client->dev, "max resolution: QCIF\n"); coma_set |= COMA_QCIF; @@ -677,7 +671,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask); if (!ret) { - mf->colorspace = priv->colorspace; mf->width = priv->rect.width >> half_scale; mf->height = priv->rect.height >> half_scale; } @@ -711,6 +704,7 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, &mf->height, 2, H_CIF, 1, 0); mf->field = V4L2_FIELD_NONE; + mf->colorspace = V4L2_COLORSPACE_SRGB; switch (mf->code) { case MEDIA_BUS_FMT_Y10_1X10: @@ -721,13 +715,11 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, case MEDIA_BUS_FMT_YUYV8_2X8: case MEDIA_BUS_FMT_VYUY8_2X8: case MEDIA_BUS_FMT_UYVY8_2X8: - mf->colorspace = V4L2_COLORSPACE_JPEG; break; default: mf->code = MEDIA_BUS_FMT_SBGGR8_1X8; /* fall through */ case MEDIA_BUS_FMT_SBGGR8_1X8: - mf->colorspace = V4L2_COLORSPACE_SRGB; break; } @@ -1055,7 +1047,6 @@ static int ov6650_probe(struct i2c_client *client, priv->rect.height = H_CIF; priv->half_scale = false; priv->code = MEDIA_BUS_FMT_YUYV8_2X8; - priv->colorspace = V4L2_COLORSPACE_JPEG; priv->subdev.internal_ops = &ov6650_internal_ops; priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; From patchwork Mon Apr 8 21:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890191 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 2E1C617E0 for ; Mon, 8 Apr 2019 21:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 175D628385 for ; Mon, 8 Apr 2019 21:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B8872870B; Mon, 8 Apr 2019 21:44:00 +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 62221287A9 for ; Mon, 8 Apr 2019 21:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727258AbfDHVnW (ORCPT ); Mon, 8 Apr 2019 17:43:22 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:43371 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfDHVnV (ORCPT ); Mon, 8 Apr 2019 17:43:21 -0400 Received: by mail-lf1-f66.google.com with SMTP id g7so10615782lfh.10; Mon, 08 Apr 2019 14:43:19 -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=tpgBHfdugHtSLDjxeKpwcp9o2D+S4DB29Nc+VO4NBko=; b=pLfOv2EnDzLRhBTQw/uaMX3KbgMLELjbECTK+qcI2yoOirS/jpInJDAQ9cPNJ7xXjP WtFK1b1nlBawFE6gGvhzU93XFZPgrmKsXZ4PW4R1zivpXy1FxB0mgwvlTMTglmcLLjVN 2s9w352FiaGGjsa0Z2vin0q2UiNvuM9zoYbi0wXpdbYyRRI1gyLZ228z7WPH+8PiLmPC 7egoKfxLUX2p4wgR0Fp/COl3a9KgwnTzaVmeQMN4k5oW92OKJuTGuZGidC2SnTZKqhWD 9qU/TphZLCVc1eOCeDN+Q/mhHEoozURxADsikzopKHpgK+nnJ01fMjAThot8ei/Fm1B9 O6RQ== 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=tpgBHfdugHtSLDjxeKpwcp9o2D+S4DB29Nc+VO4NBko=; b=FVwAZgg/cXW3rgBBKHQoD5FYMgzu8cb3lQ2qLcanWCZ3EoH0f5X9BpmcOZnaj3sRQK cSKRrfxNW8h1+fDAO7YRBmK7o7J3b9xt7Q0B8WdB403dXxYwe0R6KbkZqE40A/DQaT0T ubH1649uZfN4R1mJnQKClueH9fSJI9Vx5RYRbWe/RE5dR/kwPzeZwtu7yx/gOz1/MS8i jUvocc20alVs4bD2gke1W63uwCxVF19WKLtzDLHRZk7Cbco87HhvaO17aDQxUIXOUtyO Eva1jOABVtm8gSQ267gL5Ptf+PIMF63z6wjrSuTktEvLWIjgH1s6RQ1j7f+wUl80vRFu 0Ruw== X-Gm-Message-State: APjAAAX6lgdBjDo/SxdQbS6Iib2pZR5ojJYIq+MoLH0NRnfxApU3T+Op KNtSbEMEA/pyNo3ABCoxptM= X-Google-Smtp-Source: APXvYqzzTo2PWLsrOTa6Rn5v2Z+MLKGPDye2F8sOiRpIEJ+kSqcZ6Oa+WW6rsaKAYDXlsrqHv+l0Nw== X-Received: by 2002:a19:7114:: with SMTP id m20mr17297213lfc.63.1554759798853; Mon, 08 Apr 2019 14:43:18 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:18 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 10/14] media: ov6650: Fix some format attributes not under control Date: Mon, 8 Apr 2019 23:42:38 +0200 Message-Id: <20190408214242.9603-11-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 User arguments passed to .get/set_fmt() pad operation callbacks may contain unsupported values. The driver takes control over frame size and pixel code as well as colorspace and field attributes but has never cared for remainig format attributes, i.e., ycbcr_enc, quantization and xfer_func, introduced by commit 11ff030c7365 ("[media] v4l2-mediabus: improve colorspace support"). Fix it. Set up a static v4l2_mbus_framefmt structure with attributes initialized to reasonable defaults and use it for updating content of user provided arguments. In case of V4L2_SUBDEV_FORMAT_ACTIVE, postpone frame size update, now performed from inside ov6650_s_fmt() helper, util the user argument is first updated in ov6650_set_fmt() with default frame format content. For V4L2_SUBDEV_FORMAT_TRY, don't copy all attributes to pad config, only those handled by the driver, then fill the response with the default frame format updated with resulting pad config format code and frame size. Fixes: 11ff030c7365 ("[media] v4l2-mediabus: improve colorspace support") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 51 +++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index dfee07ec976e..f6b0b77c5abf 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -215,6 +215,17 @@ static u32 ov6650_codes[] = { MEDIA_BUS_FMT_Y8_1X8, }; +static const struct v4l2_mbus_framefmt ov6650_def_fmt = { + .width = W_CIF, + .height = H_CIF, + .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .colorspace = V4L2_COLORSPACE_SRGB, + .field = V4L2_FIELD_NONE, + .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT, + .quantization = V4L2_QUANTIZATION_DEFAULT, + .xfer_func = V4L2_XFER_FUNC_DEFAULT, +}; + /* read a register */ static int ov6650_reg_read(struct i2c_client *client, u8 reg, u8 *val) { @@ -530,11 +541,13 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, return -EINVAL; } + /* initialize response with default media bus frame format */ + *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; - mf->colorspace = V4L2_COLORSPACE_SRGB; - mf->field = V4L2_FIELD_NONE; return 0; } @@ -670,10 +683,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) if (!ret) ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask); - if (!ret) { - mf->width = priv->rect.width >> half_scale; - mf->height = priv->rect.height >> half_scale; - } return ret; } @@ -703,9 +712,6 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, v4l_bound_align_image(&mf->width, 2, W_CIF, 1, &mf->height, 2, H_CIF, 1, 0); - mf->field = V4L2_FIELD_NONE; - mf->colorspace = V4L2_COLORSPACE_SRGB; - switch (mf->code) { case MEDIA_BUS_FMT_Y10_1X10: mf->code = MEDIA_BUS_FMT_Y8_1X8; @@ -723,10 +729,31 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd, break; } - if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) - return ov6650_s_fmt(sd, mf); - cfg->try_fmt = *mf; + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { + /* store media bus format code and frame size in pad config */ + cfg->try_fmt.width = mf->width; + cfg->try_fmt.height = mf->height; + cfg->try_fmt.code = mf->code; + /* return default mbus frame format updated with pad config */ + *mf = ov6650_def_fmt; + mf->width = cfg->try_fmt.width; + mf->height = cfg->try_fmt.height; + mf->code = cfg->try_fmt.code; + + } else { + /* apply new media bus format code and frame size */ + int ret = ov6650_s_fmt(sd, mf); + + if (ret) + return ret; + + /* return default format updated with active size and code */ + *mf = ov6650_def_fmt; + mf->width = priv->rect.width >> priv->half_scale; + mf->height = priv->rect.height >> priv->half_scale; + mf->code = priv->code; + } return 0; } From patchwork Mon Apr 8 21:42:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890193 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 D81A217E0 for ; Mon, 8 Apr 2019 21:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C27A32862A for ; Mon, 8 Apr 2019 21:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6F8D2880A; Mon, 8 Apr 2019 21:44:07 +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 3B9502862A for ; Mon, 8 Apr 2019 21:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbfDHVoA (ORCPT ); Mon, 8 Apr 2019 17:44:00 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45685 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbfDHVnW (ORCPT ); Mon, 8 Apr 2019 17:43:22 -0400 Received: by mail-lf1-f65.google.com with SMTP id t15so6780012lfl.12; Mon, 08 Apr 2019 14:43:20 -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=X/wndm5aXTboBKQBo07EQSuwKC5btc/Z56ajATwmTuc=; b=dVaUmxO4/6iYQ0WLE5PxeLWpy9nu79cgZkPAQIuUkm9WqoHxj1JTPDzbUTjd7gIOx9 WEOivKC+LeSDawac2O8vBOUgzma0stzZ+DTk0iD1no5VDHWQZmjWBxnWOHnCR0/R2tK0 8uYZPRsirgid2kTq4h36QmsOMTm7g71EDbqI049RE+LCAMLfkkiGM3RQeoAc2JEJGPAW 1YdaaYyukdQGsfFCJENu/VhBStac6YfsJXiiluMnUi91ISpIKmElWwE7afqLKw/dInUH denVDV2F8x5DSoHGflQ+ge/zOJk99u401VR+d6DYmHURLWApU/fbVMkv1jteogdgUbv/ cqDQ== 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=X/wndm5aXTboBKQBo07EQSuwKC5btc/Z56ajATwmTuc=; b=OmtdVuXa+bOkD3gQhT8eq+ZAOgztMPJ205BFgjXgT1qglYo4RVJGtp7Doukc+gh+5H q2caVcRnHjGNXT0iN5aFsAM5S21+46dEequb2+MjnYoh1ocVOBQ7xyD/RGGpHbu/xOB2 R66DLmzyZGaDyZ79RaHRS2zFybkVh0bRd1RANAKaAU+1kOyXgSkxMdPZj/tDTAFBE6FX IksoDDp/LKvxLqU0k0Oah2bUc7QreiWITMM3BqChp09oxF7YcBpCIIxsPcwXbPDLssWY F7EL90sCgQLH+U3Yuc6hyf3dLQ80Aibl0KnDyWb+Vm3hFPPs1cSYt5QRSmF3AoAab90V TPHw== X-Gm-Message-State: APjAAAWrVYqjC0qFJnsUfoMTJi2qrliWOeh1HAKZDvlqNvjYVVaUG+4+ 6gZY8BEFVEM11Z4lvZ+Lixo= X-Google-Smtp-Source: APXvYqxhVhDkM6TknGge7y3V37XWk+l8+LbUla4iG9ZeTbpYFUkEB+K9yFyok7+Mg4l6HJlQRFp0ww== X-Received: by 2002:ac2:4424:: with SMTP id w4mr14293963lfl.148.1554759800118; Mon, 08 Apr 2019 14:43:20 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:19 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 11/14] media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support Date: Mon, 8 Apr 2019 23:42:39 +0200 Message-Id: <20190408214242.9603-12-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index f6b0b77c5abf..e72210653f55 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -530,25 +530,27 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + /* initialize response with default media bus frame format */ + *mf = ov6650_def_fmt; + + /* update media bus format code and frame size */ switch (format->which) { case V4L2_SUBDEV_FORMAT_ACTIVE: + mf->width = priv->rect.width >> priv->half_scale; + mf->height = priv->rect.height >> priv->half_scale; + mf->code = priv->code; break; case V4L2_SUBDEV_FORMAT_TRY: - if (cfg) + if (cfg) { + mf->width = cfg->try_fmt.width; + mf->height = cfg->try_fmt.height; + mf->code = cfg->try_fmt.code; break; + } /* fall through */ default: return -EINVAL; } - - /* initialize response with default media bus frame format */ - *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; - return 0; } From patchwork Mon Apr 8 21:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890189 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 1EAE51669 for ; Mon, 8 Apr 2019 21:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A939287C8 for ; Mon, 8 Apr 2019 21:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F32A228806; Mon, 8 Apr 2019 21:43:56 +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 A4AAC287C8 for ; Mon, 8 Apr 2019 21:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbfDHVnv (ORCPT ); Mon, 8 Apr 2019 17:43:51 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40612 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbfDHVnX (ORCPT ); Mon, 8 Apr 2019 17:43:23 -0400 Received: by mail-lf1-f68.google.com with SMTP id a28so10627648lfo.7; Mon, 08 Apr 2019 14:43:22 -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=jt3SeGFqkjvpf0KDzystQKves66Jxmw/RGatgrGKn4Y=; b=iA9bWOQuNvDMWOdo2jgDFys0mxYtOymkJEjF1UN9A6cO4mGbPzJ+alLYUwmeo99WGG kb07/WnBPfSHDR6CepfnVesd45dlxYLqL6g+9THwb01CB50MVo9/pphyy3zjYF6NPoc1 TAF8KZifqgNavKnrSHHFqn3iRoLqKLv62UkDhtPN+bAzqkUlnxmH2UjkwFPSiQWASaIC Q31jLWQwvZ7NjeUD5M/nk2l27/ZoqKK44Hq5cCKOjmYvYGTs29Fl2zH9krKbVE3OLKBo /aUL8oKAbvxI6dp41gWG96FetC+jzxTKt9QNCEd2CSdnXyAhDYR756+jGqJzHzecbsTu JSGg== 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=jt3SeGFqkjvpf0KDzystQKves66Jxmw/RGatgrGKn4Y=; b=MZiJDmBr1UXiB43X34Zc1Ur3gwC0XOScmf6XA2e3nuSrWMRFkTe39kRTa+j4pHI0zL dGLjvYu5BfHNIfuOruXm/CnyQ7Mm/P8zm5x+dmljA9SdEHpAuWGbXjd1tqCgpDX/SLOl FFobBV1S5l3usGZ1nlld6v0tCEWqbzavfCZjbVoMJ1R0DlxE5T3hSIz3t0qqD3rV8SjT rFupqEMpGy+owf1Fy3vFINUmEKDgiCmKXkJHd9GPKyGUg54apWXf4CH9GKN7VpUTqO3h SUELx1j0OiLrakEwwsLaApHj/IJk3UHQLHZ7gHjphX+z56dqdDjDg/T9DreEO9vmy2fk 5ECg== X-Gm-Message-State: APjAAAWAZsGN6v0ZXjAPSzsBSD4pHwu/cVg8wxjq2BSVv3UU6dqP0gt4 eWi4poey3DEJAcIMu6rq18I= X-Google-Smtp-Source: APXvYqwN8ZILNOKD9i12z9cPOVTFvP0prVi+KBGVdRaMyM3gFv+qwUKPrkjio6nY9f8twjnEkMDEUQ== X-Received: by 2002:ac2:495c:: with SMTP id o28mr17749542lfi.16.1554759801505; Mon, 08 Apr 2019 14:43:21 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:20 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 12/14] media: ov6650: Fix default format not applied on device probe Date: Mon, 8 Apr 2019 23:42:40 +0200 Message-Id: <20190408214242.9603-13-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 It is not clear what pixel format is actually configured in hardware on reset. MEDIA_BUS_FMT_YUYV8_2X8, assumed on device probe since the driver was intiially submitted, is for sure not the one. Fix it by explicitly applying a known, driver default frame format just after initial device reset. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index e72210653f55..8013afea0c02 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -920,6 +920,11 @@ static int ov6650_video_probe(struct v4l2_subdev *sd) ret = ov6650_reset(client); if (!ret) ret = ov6650_prog_dflt(client); + if (!ret) { + struct v4l2_mbus_framefmt mf = ov6650_def_fmt; + + ret = ov6650_s_fmt(sd, &mf); + } if (!ret) ret = v4l2_ctrl_handler_setup(&priv->hdl); @@ -1074,8 +1079,6 @@ static int ov6650_probe(struct i2c_client *client, priv->rect.top = DEF_VSTRT << 1; priv->rect.width = W_CIF; priv->rect.height = H_CIF; - priv->half_scale = false; - priv->code = MEDIA_BUS_FMT_YUYV8_2X8; priv->subdev.internal_ops = &ov6650_internal_ops; priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; From patchwork Mon Apr 8 21:42:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890187 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 8323017E0 for ; Mon, 8 Apr 2019 21:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B57E28385 for ; Mon, 8 Apr 2019 21:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 561D328806; Mon, 8 Apr 2019 21:43:48 +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 EC3FF28537 for ; Mon, 8 Apr 2019 21:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfDHVnZ (ORCPT ); Mon, 8 Apr 2019 17:43:25 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42574 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727300AbfDHVnZ (ORCPT ); Mon, 8 Apr 2019 17:43:25 -0400 Received: by mail-lj1-f193.google.com with SMTP id v22so12617991lje.9; Mon, 08 Apr 2019 14:43:23 -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=dapVIysTDyZCwZbl3QKUERGjrDSrapcmOu05WaEF+Qo=; b=vVUKrlW+MHCjzgLRsR79p9GnKX8WigbpLjV8YQ8y4x8R+SbRbTMwekeHOxPL4SU6A3 RpKzxX+f7PecTdCKy8d23gKaUtJKUUOKB69yjMtuK1orEz4kPlQLR6CJuJve/GlPvP3f bEMQ6pZ8MAIrFrS93enDYvl8ic9CTyYG/dO+tuA4LIGHHj837tCCZdpQxgA4kdI9lUnn P1jrYUmRFkXaHNG+MQnPhrZ+xZnULx9y26bTdFz0VMLh6P7GagvVq3iqiIxRwdTT/Anx IG0k2D3fzzUaLquSU6db7XNyWdr1rM0Kv3EQ38IEesUTp5+Y3jPRQvchwFAjxwrDou7E y6uQ== 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=dapVIysTDyZCwZbl3QKUERGjrDSrapcmOu05WaEF+Qo=; b=q0z+IbXv2MMQ/3FO1c0zGQFF9r6NM7AAowzp9LuYUMoc2naW9tZVpj5BEAMQL6WNCc vECqOO82ANDvpSh4eHhFSFmFCJZGhXSas0tU6blTwZRg+pSeDWxbjk4I7fEvBdSWw0J9 M3MtubUQsgy4NO6npSkExhjiflB8brEErG0m4d1qumBAkk/KWFk7FwpMNRqs6/VTnxZN hOSsG2dW6nnXpk1d1Tis6RZd0ihZ42vtLEklcrQnJS9bQKqVySN1NYdWoXnR/0tzo9eo je0T02oDJ2nujrBN1IQ2qlAspdU67Qj5LuWHNO7SB9PANBEhmAI9rnuXm2HCvlz5/ifU 4TBQ== X-Gm-Message-State: APjAAAWz+YpvRvQX/CyVPMFPKseBKdeKO/wQE3O4+sIPMKmW9dJ29SLN Y2WJ+ZJ741jUY71TnW6fJg4= X-Google-Smtp-Source: APXvYqwQjD+eFot/DZwg5Hix3eiJughBLRJPJM790tkpcULc5G3bqKMeuvaBYN/SR5Cj3PixO+RqFg== X-Received: by 2002:a2e:86c7:: with SMTP id n7mr13163553ljj.44.1554759802787; Mon, 08 Apr 2019 14:43:22 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:22 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 13/14] media: ov6650: Fix stored frame format not in sync with hardware Date: Mon, 8 Apr 2019 23:42:41 +0200 Message-Id: <20190408214242.9603-14-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 The driver stores frame format settings supposed to be in line with hardware state in a device private structure. Since the driver initial submission, those settings are updated before they are actually applied on hardware. If an error occurs on device update, the stored settings my not reflect hardware state anymore and consecutive calls to .get_fmt() may return incorrect information. That in turn may affect ability of a host device to use correct DMA transfer settings if such incorrect informmation on active frame format returned by .get_fmt() is used. Assuming a failed device update means its state hasn't changed, update frame format related settings stored in the device private structure only after they are successfully applied so the stored values always reflect hardware state as closely as possible. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 8013afea0c02..001457d39742 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -643,7 +643,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) dev_err(&client->dev, "Pixel format not handled: 0x%x\n", code); return -EINVAL; } - priv->code = code; if (code == MEDIA_BUS_FMT_Y8_1X8 || code == MEDIA_BUS_FMT_SBGGR8_1X8) { @@ -664,7 +663,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) dev_dbg(&client->dev, "max resolution: CIF\n"); coma_mask |= COMA_QCIF; } - priv->half_scale = half_scale; clkrc = CLKRC_12MHz; mclk = 12000000; @@ -682,8 +680,13 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) ret = ov6650_reg_rmw(client, REG_COMA, coma_set, coma_mask); if (!ret) ret = ov6650_reg_write(client, REG_CLKRC, clkrc); - if (!ret) + if (!ret) { + priv->half_scale = half_scale; + ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask); + } + if (!ret) + priv->code = code; return ret; } From patchwork Mon Apr 8 21:42:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10890185 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 8357817E0 for ; Mon, 8 Apr 2019 21:43:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EC1228806 for ; Mon, 8 Apr 2019 21:43:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 630102880D; Mon, 8 Apr 2019 21:43:44 +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 D0A3B28806 for ; Mon, 8 Apr 2019 21:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbfDHVnd (ORCPT ); Mon, 8 Apr 2019 17:43:33 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36327 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727339AbfDHVn0 (ORCPT ); Mon, 8 Apr 2019 17:43:26 -0400 Received: by mail-lj1-f194.google.com with SMTP id r24so888436ljg.3; Mon, 08 Apr 2019 14:43:24 -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=2KBWTMEMtRtwMsmta6uI9Ct0NHdu3EaaYE8CORm6INI=; b=LA29vNTytL0sLNYaMiFFsRIL/lSZMN3uwNOF3pEDmU7OwoDOl0KyZ9nfn6KnAzvjtt 3wMhrqdJ3TCCEs0IP9l3jCZjYGzB6db1fVqZBxTHym4uEcL1tUEKiikqhMprBU303zQi 7QFKiq1KcRgOMJ0yNbdtgduq/r6Iq6KUp76K+s7PaeWooX37khDiCwUgAbblLifeqkdx tEJ9qle158Gk0gp+OgtO/pVPo0gbzI/Q8MppbeP3ndxtdiR/D6asjQrUTgNUu4fDImHd cUb9YAznrWn8nhp3Wkazc4pUenkQBEVO6CHKHQxqUFPkqFhkOeL1BYIoSUbh1z1cKj4+ ixGw== 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=2KBWTMEMtRtwMsmta6uI9Ct0NHdu3EaaYE8CORm6INI=; b=nw7h5n/HPJEYTU0yh25qDm1GcO+K2ztllPqgawgVm/nF4wXedNKjuO7L8U9a49J8pj jY3yKBzoQ2vHZmj0QwNxjDAnxu21ey8oaFUIqx6jfW97dZPbWuq7S4TMrxJA11G00s/H EGfdsmLszpJlpA8DkyKfcar1cs9PHBE2T1Rvvu17reyra2YVT0LFp4dYbS8pDfyPTYuG OECC90nGcRUhkDORalsQazhE5zu1TGwF7DHIzSrFyjuqPx6omLFrYSPuVWlTQ9DB9ieY COhCfGDTyonzK4deKT/X7d2S5b8AhM6jf8eQbuWjRxftZLr4dYjywhlah/8O6nA3yjTR sanA== X-Gm-Message-State: APjAAAXOI2e+ouVU91SlI5wR9KO8gPVwCccqfsTmObgLUhBVycPTIE8T 70kLqk2pT1ri8jyQ4U2rOBE= X-Google-Smtp-Source: APXvYqyuu4ewWklTqwI/KvE07ZiNVBG3SAeOZrAjin8lu0uhLSJ5KjxskcBtZ5UQOUeJY1pu9lfU+A== X-Received: by 2002:a2e:7215:: with SMTP id n21mr18254086ljc.105.1554759804177; Mon, 08 Apr 2019 14:43:24 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:23 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 14/14] media: ov6650: Fix stored crop rectangle not in sync with hardware Date: Mon, 8 Apr 2019 23:42:42 +0200 Message-Id: <20190408214242.9603-15-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-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 The driver stores crop rectangle settings supposed to be in line with hardware state in a device private structure. Since the driver initial submission, crop rectangle width and height settings are not updated correctly when rectangle offset settings are applied on hardware. If an error occurs while the device is updated, the stored settings my no longer reflect hardware state and consecutive calls to .get_selection() as well as .get_fmt() may return incorrect information. That in turn may affect ability of a host device to use correct DMA transfer settings if such incorrect informamtion on active frame format returned by .get_fmt() is used. Assuming a failed update of the device means its actual settings haven't changed, update crop rectangle width and height settings stored in the device private structure correctly while the rectangle offset is successfully applied on hardware so the stored values always reflect actual hardware state to the extent possible. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 001457d39742..cffe6aa906b2 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -500,6 +500,7 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1); if (!ret) { + priv->rect.width += priv->rect.left - sel->r.left; priv->rect.left = sel->r.left; ret = ov6650_reg_write(client, REG_HSTOP, (sel->r.left + sel->r.width) >> 1); @@ -509,6 +510,7 @@ static int ov6650_set_selection(struct v4l2_subdev *sd, ret = ov6650_reg_write(client, REG_VSTRT, sel->r.top >> 1); } if (!ret) { + priv->rect.height += priv->rect.top - sel->r.top; priv->rect.top = sel->r.top; ret = ov6650_reg_write(client, REG_VSTOP, (sel->r.top + sel->r.height) >> 1);