Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp511296pxh; Tue, 9 Nov 2021 14:27:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGDBexjVvt/lEz3D3AjRcJzTGLjK5arCjdu18OuiphAPz5dDndrgxwAA1xxq2IsZruIpv9 X-Received: by 2002:a05:6402:22d6:: with SMTP id dm22mr14688143edb.400.1636496852727; Tue, 09 Nov 2021 14:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636496852; cv=none; d=google.com; s=arc-20160816; b=SyZSARIn3FpivD7NuxPx88DMotPehsPzFcillpDD51/9lYfY6dAmv3vMcdPqGZbEhI rGxhOxdMzDFyaXQBbZhHOSWNhvoEYw3Mesaj6g+RDyrnjYqOrKyCW9d53X09PPRMNTYN wVejAN9YEobmBU3hEy7xFHapxVHHROIqjtmAPJnmEIWUlwlle8XAPznrOIfSxYvA9TVd WaC6tRFCbluDqBcVxGOdSpeIE6zvj6lCkE/Ta/+lgF0UH+qtboAV9bKVZd1tJJx/W44M 2zQAy9fuPzkNajSdiy6J93bp+AvbF5JRNhPVDGDFj3K/DECDrq4/QgU4rezWgTMcZbxP 3jUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:cc :references:to:subject:dkim-signature; bh=pObiHK5TKPRRKiV3HmVFL+C7RxHF51IpPh9HQK8MKac=; b=Ftd0Eobl4jGy3z2X44iL5hNIASEaUpBOTVHlWBv0U0dzoeuJ8YDeHwYSTSqHBsl9Q5 9a+n7fzNkt8lvhw7DClTWKbcsCh88E0v9ggxW2uo639siQnIA2524jdJPrkSSctTLs7U K2/ATJK934mwgDAwxmNSbN+ajmx1kzAY8UNKHRPF57/p273DT2bbYq2R39D8RPqz8atN h0seRysKA+cRcvBX1r7pI7uCVjgIrKNuMZtNGmpbDmQMzMgthPwvLT3xfNBY+ZJhuSHd BEVX2EtR/QHt1ip3l3CAxAFP+Rd+NUbZmUIxfPjU6tp4Mp1KC/BUm88kkrHoMkPFG0pn Ck4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=dlcWvimf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si2197571edb.287.2021.11.09.14.26.42; Tue, 09 Nov 2021 14:27:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=dlcWvimf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235073AbhKIOW3 (ORCPT + 99 others); Tue, 9 Nov 2021 09:22:29 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:41980 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbhKIOWX (ORCPT ); Tue, 9 Nov 2021 09:22:23 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1A9D30bt004720; Tue, 9 Nov 2021 15:19:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=pObiHK5TKPRRKiV3HmVFL+C7RxHF51IpPh9HQK8MKac=; b=dlcWvimfYkcgPfkZLEtAMdMXia7A52ITLRmkeKmmom4MXXNty2jSY+TvSCiQIUtWPoeO KK+z38QjV0ktz9e9N+L2k8nUDZwdnhGDF16VYWeKbjAtoz13aUovo6ABleuKy3+1WRk9 iAMgBYKoizkA7GKZAUG4VtU7MYGPgL+YbHNGmk/CvVI+QUAChfCRL74nV5qy4dmOWg9f +TvhXVd9tVkraUKX5ZxJG8TsqGmSJF12XFnhR1AGQttQrRJBFomSFioAvW/dcigSOmNX wtMl0fCMCD5z3iKSzBU+3qiBAkDHulyPlaYcEPTj8DLGJfUFRqdZpZq7I7qKq8sMJKjQ Uw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3c7er8d52q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Nov 2021 15:19:29 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9BEBB10002A; Tue, 9 Nov 2021 15:19:27 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 92088231DC6; Tue, 9 Nov 2021 15:19:27 +0100 (CET) Received: from [10.201.23.19] (10.75.127.50) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 9 Nov 2021 15:19:26 +0100 Subject: Re: [PATCH] media: ov5640: Fix set format, v4l2_mbus_pixelcode not updated To: "Mirela Rabulea (OSS)" , , Steve Longerbeam , References: <20211101195251.700674-1-mirela.rabulea@oss.nxp.com> CC: , , , , , , , Mirela Rabulea From: Hugues FRUCHET - FOSS Message-ID: <7f74b844-809b-6255-fe4a-e4cef55cbae7@foss.st.com> Date: Tue, 9 Nov 2021 15:19:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-09_03,2021-11-08_02,2020-04-07_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mirela, Thanks for patch, tested OK on my side: Acked-by: Hugues Fruchet Tested-by: Hugues Fruchet BR, Hugues. > > > -----Original Message----- > From: Mirela Rabulea (OSS) > Sent: lundi 1 novembre 2021 20:53 > To: slongerbeam@gmail.com; mchehab@kernel.org; Hugues FRUCHET ; jacopo+renesas@jmondi.org > Cc: guoniu.zhou@nxp.com; manish.bajaj@nxp.com; robert.chiras@nxp.com; xavier.roumegue@oss.nxp.com; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-imx@nxp.com; Mirela Rabulea > Subject: [PATCH] media: ov5640: Fix set format, v4l2_mbus_pixelcode not updated > > From: Mirela Rabulea > > In ov5640_set_fmt, pending_fmt_change will always be false, because the sensor format is saved before comparing it with the previous format: > fmt = &sensor->fmt;... > *fmt = *mbus_fmt;... > if (mbus_fmt->code != sensor->fmt.code) > sensor->pending_fmt_change = true; > This causes the sensor to capture with the previous pixelcode. > > Also, changes might happen even for V4L2_SUBDEV_FORMAT_TRY, so fix that. > > Basically, revert back to the state before commit 071154499193 ("media: ov5640: Fix set format regression") as it was more clear, and then update format even when pixelcode does not change, as resolution might change. > > Fixes: 071154499193 ("media: ov5640: Fix set format regression") > Fixes: 6949d864776e ("media: ov5640: do not change mode if format or frame interval is unchanged") > Fixes: fb98e29ff1ea5 ("media: ov5640: fix mode change regression") > > Signed-off-by: Mirela Rabulea > --- > drivers/media/i2c/ov5640.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index ddbd71394db3..db5a19babe67 100644 > --- a/drivers/media/i2c/ov5640.c > +++ b/drivers/media/i2c/ov5640.c > @@ -2293,7 +2293,6 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, > struct ov5640_dev *sensor = to_ov5640_dev(sd); > const struct ov5640_mode_info *new_mode; > struct v4l2_mbus_framefmt *mbus_fmt = &format->format; > - struct v4l2_mbus_framefmt *fmt; > int ret; > > if (format->pad != 0) > @@ -2311,12 +2310,10 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, > if (ret) > goto out; > > - if (format->which == V4L2_SUBDEV_FORMAT_TRY) > - fmt = v4l2_subdev_get_try_format(sd, sd_state, 0); > - else > - fmt = &sensor->fmt; > - > - *fmt = *mbus_fmt; > + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { > + *v4l2_subdev_get_try_format(sd, sd_state, 0) = *mbus_fmt; > + goto out; > + } > > if (new_mode != sensor->current_mode) { > sensor->current_mode = new_mode; > @@ -2325,6 +2322,9 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, > if (mbus_fmt->code != sensor->fmt.code) > sensor->pending_fmt_change = true; > > + /* update format even if code is unchanged, resolution might change */ > + sensor->fmt = *mbus_fmt; > + > __v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_rate, > ov5640_calc_pixel_rate(sensor)); > out: > -- > 2.25.1 >