From patchwork Tue Sep 3 20:11: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: 11128703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 473141510 for ; Tue, 3 Sep 2019 20:13:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27C0A22CF8 for ; Tue, 3 Sep 2019 20:13:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vh/OUISB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbfICUND (ORCPT ); Tue, 3 Sep 2019 16:13:03 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38883 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbfICUNB (ORCPT ); Tue, 3 Sep 2019 16:13:01 -0400 Received: by mail-lj1-f195.google.com with SMTP id h3so10514136ljb.5; Tue, 03 Sep 2019 13:13:00 -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=bEcAPc5QA3wF+/4wLcZWH7jU+CdtRX6IAxGP+R1Ah10=; b=Vh/OUISBTVP0NkGSkNqB95kQyQUBjvw3lj23q2dEfU1UsgTSSmXDJZP6GZt/WrScl1 e5E58pVLrAIJ84qhSlcbai1PwuCLOBLEiGH4tPD8eOYsa/RolQS0Ic1YFxgNnZKFn9Nh I7/DDvsSOtSD65bdoPJfDcVEyEvgZ/BNMMkzQHUhWxK7PXKgF4XJA8k0/2aZXl5tZvie QMV5SkobgGkcNmz28fe2DpLuGiDPxZowqEE14LL3qMLquDCRhee98kVnJ+JBF1/eWLBC XbGQN0tlktJpHdeGaFU740QAQ5RH4qMIPI56zrYWsvYCvLuuDqC3G3ior9lBqXc/6vFC iI/g== 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=bEcAPc5QA3wF+/4wLcZWH7jU+CdtRX6IAxGP+R1Ah10=; b=H6w2NRV728kDY9qbzDd8DlR+j9+C18/gmiZMHKox9w9GFaJDn+5QB25I5Q+hD8uao5 JvdupwP46YwJTPsRFi3qePCivN81DmjqmIAhFbq5dnfJ5ECt/toteHq2/8RwwgH9eVmc Ajba94wb4vUuRdW2IHhZh4sjEBo1+8bQ36cqHQ/sbM/2fyMJTcdSWYCcpjNsf/Vpe8Zm +6l8ptlLjrRcB389B93HbRf1Tu7FK4P9Q57cA3qdGcLDiL4Nju7k00XnRZgVX/mndD9d naivYmGoe1v35fxS4YbYZwIm3WYCxDHrTZiMy1EXfZnBLxgWHCrYu02An6PuNEgMfICr Z23A== X-Gm-Message-State: APjAAAXH1RpqZqJ5/xJyTPbHSDpy3mgpJwqy9Quucc8gmsxl6gz7B2OQ L9VyZSm74LApITlydstFjpc= X-Google-Smtp-Source: APXvYqwsNdbQFWygN50xYCTgNU+i01y5RV/csJGkJf33FA3Jkcf56+4t0thjpVPRQ3Z2nqAGXUFVXA== X-Received: by 2002:a2e:5c43:: with SMTP id q64mr21009365ljb.14.1567541579705; Tue, 03 Sep 2019 13:12:59 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.12.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:12:59 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 1/9] media: ov6650: Fix MODULE_DESCRIPTION Date: Tue, 3 Sep 2019 22:11:36 +0200 Message-Id: <20190903201144.13219-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 5b9af5e5b7f1..53550cae2353 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -1041,6 +1041,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: 11128707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E33121398 for ; Tue, 3 Sep 2019 20:13:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C38AA230F2 for ; Tue, 3 Sep 2019 20:13:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m7jca7Fl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbfICUNj (ORCPT ); Tue, 3 Sep 2019 16:13:39 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46780 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfICUND (ORCPT ); Tue, 3 Sep 2019 16:13:03 -0400 Received: by mail-lf1-f68.google.com with SMTP id t8so1485101lfc.13; Tue, 03 Sep 2019 13:13:01 -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=DVgj8XCKgz3RPtqDOp3TFgbusGBaGE3UZiXYJQE5YAA=; b=m7jca7Fl/b8d6z/zX+kZ2AuRa6Nwt92MF8QyW6Ku5LA/OTZmZpd4zrMukkUmLsmRRQ AXmb4Zw06TQfoYbUAcqKbgjisEqqKG51N0VkaW4srhbRW8WQxHbHK0DDIclplczcYzKx qVjaEYEtY7z/bFYoQ7tYwIsA3vBtwotrMnFCmJgHeJY4xWDVVxhGvvYi4qVD1rjhR+T5 mluXvO69RN1NHr47r1YjK0+27ee/uPxtAgsFSYHkc6KptTGhC9qyNiUCp93nBDhaQCmD 6cy3aVqltP8y/+lXzFOhiqZnieJDzBK10tdxRw5T6EZJzTuMpXZyeaueoz0/KMQXUNI2 5tTg== 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=DVgj8XCKgz3RPtqDOp3TFgbusGBaGE3UZiXYJQE5YAA=; b=ucQKtPF1jBoKtyaLfltx4MmZfna5MDzrnnO60f5OK/M1Et5GgwhreN1lEjxz9SwhzG DQG/WvpDfh6w927Ixyn1/alvEWYBMtHIlT2xLaZOPkr4HjCIrQ2abT0gLHiuhGa0BFuZ EhiHeBv+rymRNI8Gl50VfYvxZ9Di8/14TUbTMz3Rd+bea01WQsXyQ9/MxAzQEOJ+XNB7 bwDUSj8RrEsm1gD4ZPuy7EtydBFWXI2hl6NuptgbsP3cRFvbmAFhRkgqz72+GTbgn6Zj WRNWvaUTqPs0B0iLDUnQukNyAhUHRCNSWvNhAzLm/8ekjrKBpgp+HEPoOLXc1yw4U5DW FDZw== X-Gm-Message-State: APjAAAWdtiIr9qlxMD1IMi4T2zrYZhXVAXATOthiBjXB+D14GYGtosJS S7psrIGTjklrRlyO1RsRbtbSfcgw5/OkYg== X-Google-Smtp-Source: APXvYqx4zk1y64c29k/34P0hqbCBcB68Fkz1iNXi6yjO4vno3fSms0xb4uXiBmILvmAI1sG5ZHGkJw== X-Received: by 2002:a19:644c:: with SMTP id b12mr4613090lfj.104.1567541580950; Tue, 03 Sep 2019 13:13:00 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.12.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:00 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 2/9] media: ov6650: Fix control handler not freed on init error Date: Tue, 3 Sep 2019 22:11:37 +0200 Message-Id: <20190903201144.13219-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 53550cae2353..cb2aa76cd6cc 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -989,8 +989,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); @@ -1008,8 +1010,10 @@ static int ov6650_probe(struct i2c_client *client, priv->subdev.internal_ops = &ov6650_internal_ops; 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 Tue Sep 3 20:11: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: 11128705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9D151813 for ; Tue, 3 Sep 2019 20:13:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99E3122DCC for ; Tue, 3 Sep 2019 20:13:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CNWUdGO7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbfICUNe (ORCPT ); Tue, 3 Sep 2019 16:13:34 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46780 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfICUNE (ORCPT ); Tue, 3 Sep 2019 16:13:04 -0400 Received: by mail-lf1-f67.google.com with SMTP id t8so1485148lfc.13; Tue, 03 Sep 2019 13:13:02 -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=Q5KotmXfTnoMjmOgmgzzUJPt9WlkNFv2bSSb35yjqRk=; b=CNWUdGO7uuMPHYOgYW6iDsqxHyNy9BsD762YI1yn2WOED6HCz5fseybmpfLm2VybDp 93fSFjmNitS0DnGX9lm16h6I1TjwU4L23csUf6V/jF4j0GtNAxxEWFXiAd6R1g+04mTQ 3g0k/71RcZtpUwblCpL/Dl9NQce7vrltsrbQbrL/kbbC16J96jSktGcrmEHX4eAsxv3h 43mguN94H5f4UfnmeeMrnZJzRG1MxDiVr4GNJMrfueM03FGI7XpzIoAIZWH80HQjgMpW mBxZS3KBTRuy0sqxS513VQPfwrZZNSvsbevN1HB7icFf7U2AsKGmJpHO9mYdXaTY1RJ0 3HQA== 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=Q5KotmXfTnoMjmOgmgzzUJPt9WlkNFv2bSSb35yjqRk=; b=NsSB5TDW+mtQHvoh1vZyQWPnTn79xe4xBkbDRHFr9dqN6hXwNn4LmPs3gcYeq97dnI hrdZF6EBppQ8JwCAtxvhbCihmp9y3+YX2ydRt21/eyCnpvNIsuzWotqxg1+kd1R2ajvG sc0sx21lS1zvXtVCfgL7/OW1Dngut9ES4KH1MQsjgBEzZsJssc2fRMdrXwgoMhpGp6Ex xf6TiDgNZiQMh9MM8g2t+GuioS7QOP7D+rlN6qKQC/LYvo8/sGsmPogwXMYZYGNycefI YmjDHPB4afHdWo9sRPWkNQNWHmRi1eE79KOjrPBqqMgR9myojRGGFw2pBIf5pbbBEyam +W3Q== X-Gm-Message-State: APjAAAUhZ16ZpUG46APQuXwFnPua6/s32eAmbwQ6nd6hcvdZsjecM49r 1cpNuJL8AE34pBu6Z5pU/qs= X-Google-Smtp-Source: APXvYqw7nj5yFdTfTa//BtM9y29LRoHdCR68OzikYhUGFy3Zu/29vQCe1aWKhxqJUexxaM3JrWSnhg== X-Received: by 2002:ac2:4201:: with SMTP id y1mr13035055lfh.127.1567541582228; Tue, 03 Sep 2019 13:13:02 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:01 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 3/9] media: ov6650: Fix crop rectangle alignment not passed back Date: Tue, 3 Sep 2019 22:11:38 +0200 Message-Id: <20190903201144.13219-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 operation 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 --- 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 cb2aa76cd6cc..983b72f33930 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -465,38 +465,37 @@ 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->which != V4L2_SUBDEV_FORMAT_ACTIVE || 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 Tue Sep 3 20:11: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: 11128701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B42FD1398 for ; Tue, 3 Sep 2019 20:13:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9306A22CF8 for ; Tue, 3 Sep 2019 20:13:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="umuOCnMl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbfICUNG (ORCPT ); Tue, 3 Sep 2019 16:13:06 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44695 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbfICUNF (ORCPT ); Tue, 3 Sep 2019 16:13:05 -0400 Received: by mail-lj1-f194.google.com with SMTP id u14so10780239ljj.11; Tue, 03 Sep 2019 13:13:04 -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=O5/bkw5TmSKSwUpx+OzbBVv/K0PHXiHAe7Oql4bTfH0=; b=umuOCnMl3ytygV0zn0WRsCvCPVb8lrFutX6lXn7PqyvPQxPq0tXw4qhZ2h+HvjqRPT eYYBESH8Yj/tu7YM8Uoc0ab+Ef+t9X5aFoPAas0gZia4tR2gJ+9ERPeN9FLSN6aCvxTM Rfh35B5tfC6K4KIb+McxeqPirMny6wUJYiFhYOv7l4eoTc1NmvxLZPpcCgnzjQ/4cN3I ftWtYpeiFJGtj6mPdx+hfMyZ8PhriHf8iPQQ3cnmYcRHdT8m2kd22OcMrC7kKerPDXX5 XoWl6FTPy3BKTL6KjPFdkouNlc3nhhFMQGdj4WC2CC2m/6ZwS759RsMJKBlCiZtkPghZ 0SSg== 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=O5/bkw5TmSKSwUpx+OzbBVv/K0PHXiHAe7Oql4bTfH0=; b=RFSpoDKBW80h8y55x2l/GbAXOo4wv/Eeprb2hiM/WXuL4qUTZUWZ6XGbnxQYMR7Hv6 ab3ssOPhqgHP1o+J3AKOK3VU0B/sZOAOlsxxoJCyDUFA/BuKtdltwG2fm9kWlBPhqV5d a6cO/J2GN5ItbIxKT1Ogl3t/AoDWS6S203z9cM5baJXkr3BxbYNIyD7naFdP5lyFMz8a 4gcILkdy7ApJKu5KynZ1goHMsfbtPp6StZjngCqNERRwuaRvGjK0fM3LuxfaRhTtqTAx +xgChbJ+8tnQWynGxUkkuRaBaoflc8mQsYCCo49ijD3nUF2NCTfEakDpaDYhy3IR3r8j oBnA== X-Gm-Message-State: APjAAAWM1FtD6/CUyMrLWyv701vp2c4KwsWoZoNTO3xt8NLEDnc/bLAb XeXunIoyUyD/Hc+Oza4STb8= X-Google-Smtp-Source: APXvYqzazWgg+TgBeqCSgVkhqVt98Qmfe0gLc3unFkvgTfQr5xW/2KkBLQLzNWL+FyLqiJWZX+/5KA== X-Received: by 2002:a2e:412:: with SMTP id 18mr11478720lje.96.1567541583411; Tue, 03 Sep 2019 13:13:03 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.13.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:02 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 4/9] media: ov6650: Fix incorrect use of JPEG colorspace Date: Tue, 3 Sep 2019 22:11:39 +0200 Message-Id: <20190903201144.13219-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 983b72f33930..a7930ace3744 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -200,7 +200,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; }; @@ -514,7 +513,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; @@ -622,11 +621,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; @@ -657,7 +651,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; } @@ -680,6 +673,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: @@ -690,13 +684,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; } @@ -1004,7 +996,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; From patchwork Tue Sep 3 20:11: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: 11128691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B33F1398 for ; Tue, 3 Sep 2019 20:13:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72E1F230F2 for ; Tue, 3 Sep 2019 20:13:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CZ2Zhacq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727043AbfICUNI (ORCPT ); Tue, 3 Sep 2019 16:13:08 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42600 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfICUNI (ORCPT ); Tue, 3 Sep 2019 16:13:08 -0400 Received: by mail-lj1-f194.google.com with SMTP id y23so6251691lje.9; Tue, 03 Sep 2019 13:13:05 -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=u4M8z8ECmeACr3s3aRSkLkxoiDnREOEztNYDP4Gz67c=; b=CZ2Zhacqw3CZt3hXWkGJcsV8T8g+BAhVmBziXWiiZC+uqv7ivOAAgtFrj7ucQhGriI xWaHCCCMtnasetRuOTVziokBNwYPI1YFQ8F/SkLvIIp/eqobGDAZPxjyPZkQm6RkflaU o1GAyHl/RyzfHNk5qgn4aHngpmE35xr1HcTa1GQ2Uy1/3wrmuI3gWiFPLBzMwNagKBH/ Km+bEq7kwj0FndOui3fArnVKoBTC/X53ZrvyyE66qotA94IYxBSdF6TqHuaeYSiLjB0W GVO8T2YOrwLRGlVT668EDlYgtlikeQNQ77f07PoCGIScFijekYYjoEzawqo5IoOtFx47 8AkQ== 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=u4M8z8ECmeACr3s3aRSkLkxoiDnREOEztNYDP4Gz67c=; b=ijV4OchcmaaRFs0D5sbkpJYSE4RSeLx3lVUfR/ZWdAa5PZQ7mV+79Str1trJPM5uCz RnWHu0F4SyLy4KjZM4B9JOTQWVT9hIIWuCOw7vO7xH9dGtpl9ogesN9f6LdVG6g2nqmJ z/62k8UhLK/fyBkMKi7ACi/vjrgEbx6vlqOkv0nbBIvwA4w7RnE5CTln6M8jb39E4Jv+ KKXsQKeVxra3BtXzeMP5ci7caw2+rbtoFMi5DaSZZYjRo7hUzKKhBvvFu2iSnNADwiOl a5NQVTEG2beiFUIgJdpeXi0Cqnew9mXdds4DqkU4apgUD7IJeCmOvRHn03BeKK/jntVv olHQ== X-Gm-Message-State: APjAAAUHLmSV0qJjxeehrCB5mW2hI9E7UMvYjMiQiAiwcdxrJ6Es75Se 8eYx1xwWzrOjXkrszwXjABs= X-Google-Smtp-Source: APXvYqw9u9fUh6uzUxZac95gSEdPzY+hGA9grGMvnv+Zsb0Byitn7GBWoVq8/jbrh0M2NuQfrj6ACg== X-Received: by 2002:a2e:80c2:: with SMTP id r2mr21121267ljg.44.1567541585007; Tue, 03 Sep 2019 13:13:05 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.13.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:04 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 5/9] media: ov6650: Fix some format attributes not under control Date: Tue, 3 Sep 2019 22:11:40 +0200 Message-Id: <20190903201144.13219-6-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 a7930ace3744..fd608aebb68d 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -212,6 +212,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) { @@ -510,11 +521,13 @@ 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 */ 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; } @@ -650,10 +663,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; } @@ -672,9 +681,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; @@ -692,10 +698,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 Tue Sep 3 20:11: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: 11128699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDAEE1510 for ; Tue, 3 Sep 2019 20:13:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D6E822DCC for ; Tue, 3 Sep 2019 20:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UBpua2ds" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727381AbfICUN2 (ORCPT ); Tue, 3 Sep 2019 16:13:28 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37291 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbfICUNI (ORCPT ); Tue, 3 Sep 2019 16:13:08 -0400 Received: by mail-lf1-f66.google.com with SMTP id w67so13940978lff.4; Tue, 03 Sep 2019 13:13:06 -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=Nit08PqZRdOCZG6pI6hGmpbHfDHgVaB9FLstBMxcWsE=; b=UBpua2dsaeCTkowGWUzhbotSf4EFHYmqAUMUyTw5jk0QMXUyy+hS1GsYaJVkjKLNS8 5tU4BsHpo+NRc1waBD6mOA8ytcOjF0gYv5tFIbJrS62A5MaovDd4mod/uMBPFeyyWbwQ Sqd/UyqO68RWv/XbBvAtjJ5vHk/EI2YWJKM2HSnpgab1ocjLKRPBacVyYeK5D/Rata8w VnJXJRyl80bJBYpSWpsFO0TcDAFIqAo5jxhPf+D4Jd4tGCWEkQFOOTzqrZ94Titbg0sG 0Kb40lZrmmUkkmpSOGAHNtolERwor8jKPsLjRFah05dhe+x9W7xyYpBa/mi3r1n+VuEq SO4Q== 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=Nit08PqZRdOCZG6pI6hGmpbHfDHgVaB9FLstBMxcWsE=; b=Jgm+omVEp2Lo+23dC0m3soHym2mhe4DP7tev7mOvK1GdRzTqPlt1nRB+wdjQrESlS+ rSn2AjNVFAouOwDo1keuXihq9+GlfS+XvKDchDpCAADUouWvpP5yGEaAaeb9HMLnCYH0 H048eyBbPLlFryuMsU8Xnr5xkm9YW6Sc4grS4BpF52KUBpQpiYiqFkjrd0sz9Q4S1USJ lcMnOWbWR4zwVb15EVXQhnY0zCU9miNtoMaDRPpQ8Mj5JDE7uWcKAgW7y5RAbzzwbwxF 10INqNbDbsIPLlIxPtbIVZXljbwKHBzrxp9wybB08feJPn4S8mmPcTBk8D+aY7b2F8Z6 cvBQ== X-Gm-Message-State: APjAAAVtc0EtqsZXee9JbYBZEOP7m642i9iRgUu715ZTrxoT4BmD+Mrf ZHEsf1QtoKlaZxdWaNS9NXE= X-Google-Smtp-Source: APXvYqyo0mbyM1XvJjVusOgSygXXjQdnWYW4jE8D0PEY5WIIf1kS+iNzjeK+ZhUVyCCTBvnk97MRVw== X-Received: by 2002:ac2:43c5:: with SMTP id u5mr3839738lfl.47.1567541586184; Tue, 03 Sep 2019 13:13:06 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id u14sm2960884ljd.14.2019.09.03.13.13.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:05 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 6/9] media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support Date: Tue, 3 Sep 2019 22:11:41 +0200 Message-Id: <20190903201144.13219-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 fd608aebb68d..b62a238a83d0 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -525,10 +525,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; } From patchwork Tue Sep 3 20:11: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: 11128697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 189A51510 for ; Tue, 3 Sep 2019 20:13:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBA5B22CED for ; Tue, 3 Sep 2019 20:13:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KC6b25HR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfICUNL (ORCPT ); Tue, 3 Sep 2019 16:13:11 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36613 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbfICUNJ (ORCPT ); Tue, 3 Sep 2019 16:13:09 -0400 Received: by mail-lf1-f67.google.com with SMTP id x80so2842064lff.3; Tue, 03 Sep 2019 13:13:08 -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=Bh968WKzvOHUV69AW7moq22N2w8QalvqKBJ2DHbuK8s=; b=KC6b25HRW5azF/IKLGdHId4dmVFA1YCHZiaC1ZYftVAh+ibv+BbzZQE30HiR5izHsn ILIbhYKbzw6UM04XBAybmkkFickeZzVut8tLR/ROteJOs69WW3PzYhC/DoX9fzo9/t6b OEt67JEW9vFBJEHrRJkU84dPeVsnjJ/3KIpHNU/jHjGkB0IQGD+1NAsInboRxhsAGCia orPyRoM8CKDap/qSXSSPEWKcxwl3kLdjMk2IZgNPowYtRrHqPxUVKgSwlijmt5VjWzpi faqCb21fso44HXhOgOje/Fu9tEFTn/fDdg1sVsMnuEDCb8R7s3B0s6Q+sNjk2qYYJzTz dyPA== 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=Bh968WKzvOHUV69AW7moq22N2w8QalvqKBJ2DHbuK8s=; b=RUKaDPQ3DGeTUL2r/sN+xMs8Ep//ErDLYTTDV8N+qsZqT2tcxHHiVhFQYiNvilv+d2 ivORf27kAF/Xlv3eexii/pUnuGg//6oXqGEMpWaZ8Jot+VodHCyKfO4dFo42lptY7KoG //ewPqaOXGeJBjErumuTnhhJmhNxvLkcNvxWf5oL6zd0Eh+37YIyDwcZoOg++Qy/7ZDC XBSpYU4GtSDp1DTzHg4h8pz6Pwg/NT5jH0dRK0MWwW0eS1gj1KwqZ1jFHXztGVTueiQL Ngo1DIXe2ys35MEHu/jPWQ8mNoH3o+OXJShyUKXh4QvXpDLPrCV7tMj6vEh7TGf6cVtr 2yMQ== X-Gm-Message-State: APjAAAXLrOrHveX90cMZQa0nhmqFxCg7XlvQ5MyNUAedIlxSzbfBondL wOinKd/eKtN09X2igVpmutI= X-Google-Smtp-Source: APXvYqwuB8kjOVtfMK+e2kzyfbEgyUdFvzqDVSa7iYNs1FYee9HRA9v5XJjr4xo+yM3UWokmXAHEeg== X-Received: by 2002:a19:e204:: with SMTP id z4mr21572361lfg.157.1567541587445; Tue, 03 Sep 2019 13:13: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 u14sm2960884ljd.14.2019.09.03.13.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:06 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 7/9] media: ov6650: Fix default format not applied on device probe Date: Tue, 3 Sep 2019 22:11:42 +0200 Message-Id: <20190903201144.13219-8-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 --- 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 b62a238a83d0..4fd8ac8e3994 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -873,6 +873,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); @@ -1027,8 +1032,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; From patchwork Tue Sep 3 20:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11128695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0950E1398 for ; Tue, 3 Sep 2019 20:13:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCA4122DCC for ; Tue, 3 Sep 2019 20:13:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZHE34QUZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727347AbfICUNX (ORCPT ); Tue, 3 Sep 2019 16:13:23 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43646 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfICUNL (ORCPT ); Tue, 3 Sep 2019 16:13:11 -0400 Received: by mail-lf1-f65.google.com with SMTP id q27so13911906lfo.10; Tue, 03 Sep 2019 13:13: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=6IcqZJ12KOyIHhnyKrSM4vVin/1ptnU9c0uX7Y+r6P0=; b=ZHE34QUZHjaD8xN46LMKJTKDy6CuT/CxEHdme6rddkEvoEX1IWFhCEq6z9vql7y+Pe VobQYvOv276vE5pLiIjQC24s8Rl41VpQnagPaLjKeZei+kjCnGfnswJS2zdDWuTX2XB/ Y4r3iFIk6UhbpnDtzcVVnH48qppykNexh2RYPZBHGglHkGMQa2gbP1GIuRcC7WbwII+2 zX0ihy58T/wdXb50OoDfuT7UyNQrgSS8w4iybBb91l/UCWZ7nqj/nLgnGtfYU5kt/OnS itsU5ZBU6rO3nrJiNQqkZI0oPMCHUT2T2XVFBxtiABF5g99REHt8fXyAGKmbjktxV3S7 mYTQ== 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=6IcqZJ12KOyIHhnyKrSM4vVin/1ptnU9c0uX7Y+r6P0=; b=AXwUe/dqol3wYH6Mrvga+7Bl8/G9Fe8uRUmDfxURGy4bLATg96mckK/dR/e6e6Hib8 sWwO0BfruBgQAgK3Q0XnpKTAMGuWj88o0RW3Pr49ynPsjxVO/1L9oXtRE8f2DRxj2tlh v/CwIZemSr7wYXZD2GmRIneE1xF1ZrrFnZzL240WJ1fBx/himxYSMuhvm6oZfZB1XR0B c2YGT3AT4cpwrxiZT4r1dK57cl+/NNs7JcNZn9gObQabZ9g1Mr2jhYItUUf+5Tu9RK4L 0CCno+I7Uj23PTcztcYVa1XPfB4NgEYLFOP9Tz87BHsg8ursvVDMGcjL3Jsx7kX9R8RC GNtA== X-Gm-Message-State: APjAAAWAQ/S3NgsPWe+Vv2SXsEyJXe3wyd0ADtwXxn/5XQd47XRaJvU/ +PySD5Xbdf8kQssNDH2NSWw= X-Google-Smtp-Source: APXvYqzPMsICAJ50n2zYxbzUO9NsodqXdGQQ/0/IR2iZHwaySiVATABd1nminonJFouKbx6Byd/X/A== X-Received: by 2002:ac2:495e:: with SMTP id o30mr7585162lfi.82.1567541588869; Tue, 03 Sep 2019 13:13: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 u14sm2960884ljd.14.2019.09.03.13.13.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:08 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 8/9] media: ov6650: Fix stored frame format not in sync with hardware Date: Tue, 3 Sep 2019 22:11:43 +0200 Message-Id: <20190903201144.13219-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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 bridge 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 --- 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 4fd8ac8e3994..126a662be301 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -627,7 +627,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) { @@ -648,7 +647,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; @@ -666,8 +664,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 Tue Sep 3 20:11:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11128693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA47B1510 for ; Tue, 3 Sep 2019 20:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C858922DCC for ; Tue, 3 Sep 2019 20:13:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EvNJLpof" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbfICUNN (ORCPT ); Tue, 3 Sep 2019 16:13:13 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33009 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbfICUNM (ORCPT ); Tue, 3 Sep 2019 16:13:12 -0400 Received: by mail-lj1-f196.google.com with SMTP id a22so205297ljd.0; Tue, 03 Sep 2019 13:13: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=qhHCXko5D/FCS0uQslLsv5tvuSiKAItzGjWfdeWXw6I=; b=EvNJLpofgvO4m6y+PySnbZ+7SQyxmQymiVN8fJ6z3LTeKYG16oA/P7fiYNwDAu0Y3Q Jqs4YfI3FqRyBD/nkNoPtWguZnon9RKzIFh1g1qQBS4FlFllb41SmSf8sKObVFqpQJ4D qQh+GAQM7IpVzEsxPl8ze3rAilGUKOaLQlCYYrNlRo7KCsUR6PWwHdK+diGr5qjaY6IY xF3wenpSHNzEwXRfZ7NxZ7KuTtoyQMcmt37fycyP9LpqS2jezn2TaN1naPjY8gTQO5KU 76oeYndpIsV0dLBOMbn84M4WcU7PWhcD6Rdc7b5CfiWBB8KjCWa1tDNEpIZd08YW0djW WEQg== 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=qhHCXko5D/FCS0uQslLsv5tvuSiKAItzGjWfdeWXw6I=; b=jqqChJbT1POgMLmzhoKDsQQRf3SDC9nDE6fkB63elPpuCZKpQqOREI83omTPjndwHk nF308gRZhjTyZRFdRX1zHhDHL8x07d7iV+3kpnVNQJctLUC7OGx/juTvTExLU2ClEj6Y 6vfo8rrA3byCkcu1HSDFu5hslUbj+l1hKWmUJZepinOnrE+lf63VY1obkEP/U/hss8ht 9BbUaRVtk7ChQz5Q08M/+Ka0xWcCFNuEZTft/2hmTeTLlR0BhzrxCCCtQ74SCKRlnsMf 0xtEQdd2h8JpKgyRYvwWbGSNVkq3TjeDGUKUM3Z+6aei7fa6QB0ooy/08hXgOHnfX1o7 qrpg== X-Gm-Message-State: APjAAAVKtd0dWBm2pX2oo4kicpzYWJ8XCcNEF0Uy8Ma2AIUTiut8Cu86 H7gK5vV7B6vCpKG8rYUK2Og= X-Google-Smtp-Source: APXvYqwNCxdP71s5xubuBZhxVj9mM3/PA4BJO/4BFEUT6yEeRNQdLeV+FvXw8YL2i2wuoR9r8qll9A== X-Received: by 2002:a2e:9c03:: with SMTP id s3mr12966228lji.109.1567541590101; Tue, 03 Sep 2019 13:13: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 u14sm2960884ljd.14.2019.09.03.13.13.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Sep 2019 13:13:09 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus , Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 9/9] media: ov6650: Fix stored crop rectangle not in sync with hardware Date: Tue, 3 Sep 2019 22:11:44 +0200 Message-Id: <20190903201144.13219-10-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903201144.13219-1-jmkrzyszt@gmail.com> References: <20190903201144.13219-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 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/set_fmt() may return incorrect information. That in turn may affect ability of a bridge device to use correct DMA transfer settings if such incorrect informamtion on active frame format returned by .get/set_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 --- 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 126a662be301..16887049f0cd 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -491,6 +491,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); @@ -500,6 +501,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);