From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 724F93CA499; Fri, 1 May 2026 15:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649970; cv=none; b=m05/TTmvwMFtvD75aX/CkwUEU/F3MwLHSt3sui1FYwDTzOhIf9Om+UILCkweQuBMBekp8328TNjqUCncZSf4FrSrrtY/C6zSttOxyxK6oic5G+mSktA/cJUbV2J3EOYdQzg2ZOapcBnhTHdM//hdkXCnv1T0AMEKow/alOyi+Uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649970; c=relaxed/simple; bh=ZiqHYLgH9r/Q7zxIHs8cGRe43k8mG5yTH+Z8muQgmoQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I5XRbLYUwX7NaYcLVare+sXrR4qSWxn0J5EYYSAwqTpRI0gwETQqlqoTQBYee9pkrhWn6kdlYRVAKp8tnG8DISUo+aFaR0Jzg36+jRwmOZfqfG00jMJIdd2TDU/UNGU+chzs6VlJSz3XupFq3jRz8nIrxdyPbfccKhoCOlgH3fM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=mxdlmt9W; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mxdlmt9W" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 13FD0664; Fri, 1 May 2026 17:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649855; bh=ZiqHYLgH9r/Q7zxIHs8cGRe43k8mG5yTH+Z8muQgmoQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mxdlmt9WHOb/vwXyMi4YX2kg1lWYX6Jxs2C8A/3fCsWtghEjYuasatZwF7jiF8aYw xZ6GKySnGDV34jZqQ8KqwPI5xtsuTaT4FNfEPTPk0bQZiqjhJty5lJQNykhf+3VTmm OHK5oGSTlQW4WFBq7xzYEN5Ejus+mi/EaqEjQU/Y= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:03 +0100 Subject: [PATCH 01/11] media: i2c: ov5640: Set default WB gains Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-1-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=1049; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=ZiqHYLgH9r/Q7zxIHs8cGRe43k8mG5yTH+Z8muQgmoQ=; b=m7DTuQIRhEgKtYEe+1YdhqmnREZTq4abpYz51XXPllIZPxUQcMAoASJc9gerXMBvSCAc9Wz7y EcFVw0FF468ACRBrkjSH8U9V6x/yBFnjeD4bfUnsnSjdgbs89MIJ5zu X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= The default values for the Blue and Red balance should be the same as the Green balance (0x400/1024). Update the values to ensure no change is applied by default. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 85ecc23b3587..01ea6b2bfeeb 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -3470,9 +3470,9 @@ static int ov5640_init_controls(struct ov5640_dev *se= nsor) V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); ctrls->blue_balance =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BLUE_BALANCE, - 0, 4095, 1, 0); + 0, 4095, 1, 1024); ctrls->red_balance =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_RED_BALANCE, - 0, 4095, 1, 0); + 0, 4095, 1, 1024); /* Auto/manual exposure */ ctrls->auto_exp =3D v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_EXPOSURE_AUTO, --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AF333D1CA4; Fri, 1 May 2026 15:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649974; cv=none; b=BslvM5/9RW2aPPw4KBRERvI/K7cvi++U+xa64DBeNgl0vs4oQ8CoCdbGt/05gUaIJ49J7idAIE3nWmR9iyHQIPZ//DMQUDuEC2dTw1GKC/INmCNQUQL2jfNuXg+QACYSZ1kXCeTSyzQGVxhnhGnGIId5m4cC/m4KfOG6cVlCe5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649974; c=relaxed/simple; bh=WezbV1kNoUX4SC2XbNke5CRabFXs5Z6dwCGzIqX1Kp4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IIPMkLGlKedUMmnUuH8d3IYlly0ZydbRSLP4x++W33IqO5eoYOz/DpJ5TtQCswPnMkYeKL3XuHqBQKTqermCd+8xeu+gITT77RMPLcmPtuhMNMcPHYC08AMS//PICLBldELGQ7yI1gJtrn+Kk8HGLUVHxpsQU1VPUKf5OdXMr0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=mjpohP6Z; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mjpohP6Z" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69FA27CE; Fri, 1 May 2026 17:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649855; bh=WezbV1kNoUX4SC2XbNke5CRabFXs5Z6dwCGzIqX1Kp4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mjpohP6Zil3wDDWcN5IzC5NkE3qvIS5dY/KPmmnWBcb8MBCzeX1VGXYA9vGFl3tiT lHKf1FJGz2eAtmt0YRC53hkaB1Hg28Q2NIm3PRPpf9sGU8HQpn4ToXS2bwiO7ccRE3 dBgFmLTNO03QR1GW/akbQEIZEYQKOJip57keU3jc= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:04 +0100 Subject: [PATCH 02/11] media: i2c: ov5640: Set exposure minimum and defaults Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-2-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=888; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=WezbV1kNoUX4SC2XbNke5CRabFXs5Z6dwCGzIqX1Kp4=; b=Ud1RpjJU6BdVFfKU8aBqd9Wm4Z+1czJMXz0eMMHc53LXtrNIthcxIUeIL3VrIAvTVb39mBYsl uiRZUMH5DN6ChIkTczQ9E0dqwyFhgfJvCQFDx2HGdvXhc+3QM4tT81t X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= A zero exposure would be a fully black image and not useful as a sensor. Increase the minimum and default control values to sane parameters. Signed-off-by: Kieran Bingham --- drivers/media/i2c/ov5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 01ea6b2bfeeb..b5e529ea662b 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -3479,7 +3479,7 @@ static int ov5640_init_controls(struct ov5640_dev *se= nsor) V4L2_EXPOSURE_MANUAL, 0, V4L2_EXPOSURE_AUTO); ctrls->exposure =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_EXPOSURE, - 0, 65535, 1, 0); + 4, 65535, 1, 1000); /* Auto/manual gain */ ctrls->auto_gain =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_AUTOGAIN, 0, 1, 1, 1); --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D00963D16E6; Fri, 1 May 2026 15:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649975; cv=none; b=g8CAs0ndcVRkMChNmYu6kSMvqe2/fOokVQAX4+KU463h7dctS7OUhPUrHLWWdBbl2YD5ysOekmp9uiRYkqf42K5wdihun55ZQpz5AxfwHqpFjgWDWpnnkoWK3EGCGUCQVDbXXWl8YE6vp678VZ6sPwWGheMZeQqoIbFAgzcEv3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649975; c=relaxed/simple; bh=CU4HZUz7ruXCTQJa+/VVoz7nbR/QBujPNiNoL4lLDkg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OJzWfJFHrhFJmx6pQoombZbdTHhphJy75e/2YEou7BQf5zotp6/4QluqWoKkBJA/c8EB2/iZOsrx+6cDJ0dBC/5ursDQ2HcZYQMPLq5LPgSD7VXBjj7dpk+g59tSPaE1+4P6Hr6JxV89C69cDxVJoRTuGPtL8rsJou8NlqPzqUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=KFAoeQvb; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KFAoeQvb" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B91CE802; Fri, 1 May 2026 17:37:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649855; bh=CU4HZUz7ruXCTQJa+/VVoz7nbR/QBujPNiNoL4lLDkg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KFAoeQvbMmnf3m1jiA0wU+yLn/ax1md4cnKDqLoleYC5xWy81Lc5znueSGdmXfs4+ pGAtC33gHP+HYQpCyw6dz0bS4FzYltgnXghGu0tuGhUBRpVWTY6lsC1UcKen4MrM/P ThZ/xAhhiOVESXI4X0vLPDFNXmqiECZ0AbwPwbQY= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:05 +0100 Subject: [PATCH 03/11] media: i2c: ov5640: Fix minimum gain to 1.0x Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-3-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=1044; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=CU4HZUz7ruXCTQJa+/VVoz7nbR/QBujPNiNoL4lLDkg=; b=h1G2rhWBmZA9xidxk4iGYhVrEWIzjEfQkEeoxgxXGKrF1PwD8Ko52L8i8pf4gztY6pyTZ/GDB AD9ASPoYwn+DYzqZ9zQ7Z3s+po0HhUOp1AkfSaeZxklDwnNMAAm+jSr X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= Adjust the Analogue Gain control to only provide a minimum gain of 1.0, and ensure that this is the default value rather than '0' which is invalid. Requesting an Analogue gain of 0 would result in a black frame, and when the sensor is over exposed the Exposure should be reduced instead. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index b5e529ea662b..0dc4f4272d05 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -3484,7 +3484,7 @@ static int ov5640_init_controls(struct ov5640_dev *se= nsor) ctrls->auto_gain =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_AUTOGAIN, 0, 1, 1, 1); ctrls->gain =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_ANALOGUE_GAIN, - 0, 1023, 1, 0); + 16, 1023, 1, 16); =20 ctrls->saturation =3D v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION, 0, 255, 1, 64); --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7091F3D1CD2; Fri, 1 May 2026 15:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649979; cv=none; b=sOLwmyWsX+BDUEWtxK42LJWKjOBeuycR0/XvDAd9PsSf8Zqb3arOM5W9giuE1T7HNqPD2HR1FPBMV774hVMFyNgOe7rdXcfgteSTR/FeVoKzMjhYh0Q23VkiPjCpdIcm+SmRbHS52bpGlBoVp3xAFwNHqSumHvKQ23KHOTpLcc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649979; c=relaxed/simple; bh=H0+s9bGtbc+qAdvqWBzge9Hq3+hGPxbdSEbGobjqmeY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xc3HLhtsrRf0DXToXS+XD9pYUT6engU6bwb/y2jS0MYgpqgwQj/VRjU5pUvwWLFFlaQuCUc9oOERVHYrpslO8lqxkEmReszVCAMnF1OvDqUjTEEKl6gIVfbPifJB5JXVN/KRW/viKlzQkxPchzyOQP2HhFLr1xQn0yln+EVtNGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=L26sPWp9; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L26sPWp9" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1AB0C99F; Fri, 1 May 2026 17:37:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649856; bh=H0+s9bGtbc+qAdvqWBzge9Hq3+hGPxbdSEbGobjqmeY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L26sPWp9OZVrf8JTp1WTpmRoPF92lpd0U31u42NfYKwNAusSyMAuhheFZRMbD6Cut kXtiq5xKQOdmkQm4QL/aXLKkaksgBX4ysqPhAyS3w5gseiZmg/4CRPJdG7LLMMqyeS an334Buzg6NYI8rh4uvrjp9v1uhQTZddRRrwC6wk= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:06 +0100 Subject: [PATCH 04/11] media: i2c: ov5640: fix error path in ov5640_set_mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-4-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=849; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=H0+s9bGtbc+qAdvqWBzge9Hq3+hGPxbdSEbGobjqmeY=; b=QFKFyghTzzm09YpgOWaebBMF/UbZGBzcN3mE1Fzn8q5LFn8rICrWOHBHqAHhfEtV4ZyCEvCyG oyvGUHG1jm2BNiQBH3VxGGSOhgpyUhvmNtGaefYagjhfr5f4+OudQz0 X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= During ov5640_set_mode if the call to set the pclk fails, we should correctly restore the state of the auto exposure and auto gain if they were modified on entry into the function. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 0dc4f4272d05..244c341d0e77 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -2349,7 +2349,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor) else ret =3D ov5640_set_dvp_pclk(sensor); if (ret < 0) - return 0; + goto restore_auto_exp_gain; =20 if ((dn_mode =3D=3D SUBSAMPLING && orig_dn_mode =3D=3D SCALING) || (dn_mode =3D=3D SCALING && orig_dn_mode =3D=3D SUBSAMPLING)) { --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 750BB3D093C; Fri, 1 May 2026 15:39:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649979; cv=none; b=V7wUCy1dNsE7Z1ZRUzajhcFBGnZUoXMHhrO8CK1bgIAvMJWX0H87V1O4GPV+/JSbR8XO5Z9eXckmwT7EwTBqGY3kHtKBRcU96qyGCsWpdLBEFNPeutRXlgZ0jSkKPVt//tjF81iRdAje0gN6z3nMg4vD907U/jLl8epT55Hzwf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649979; c=relaxed/simple; bh=pMb3Azb11NTN5VD1FvHVEEgQFjrkVkk5H7PL52CjrFE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xu4UU6cl7HTVnoOeR9+G/e89NNBEyrz1Bhj1sEyvuqOpW8JNDM+85mdTpPNRUpl7F3EiEFLGSk2V4TNuzQojbmUms6DDicZQThHW0YSlhTgw7tK1EUTGsHodc7t6qdp7zorIiHDAxrn2FuzKdhDYu8v/sxJMOfZQdyVj+0Mckf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=kWL/yujE; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kWL/yujE" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 68F35A64; Fri, 1 May 2026 17:37:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649856; bh=pMb3Azb11NTN5VD1FvHVEEgQFjrkVkk5H7PL52CjrFE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kWL/yujE653lukYQ4cdU+vxedQgFr3cFelYzj12I9emmb2YXh5euUksSeKbzLiBTd IOu8KFnq7JFuPFAH/WVr0LEpzV/hHghtaRVDHAp3GJag6f9qxLFwilcByPrvUegQdr 19nl9hncVCmcO9Vw70yuE8j1uIUfNFxMBFMr3b1E= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:07 +0100 Subject: [PATCH 05/11] media: i2c: ov5640: Remove unsupported bayer orders Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-5-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=1276; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=pMb3Azb11NTN5VD1FvHVEEgQFjrkVkk5H7PL52CjrFE=; b=mXI5OGGwHCPHqMSpjcrKJl/+rKjm83qqA+rYfd2YhIEY8D1oyUeOayUQNL4a+0+tK79JtRTNT bzU4fgtjOGGDGyv740EBKuSEJ/J93nb8rDjbTlx64fF1YzRdKMmjuot X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= The OV5640 only outputs SBGGR8. Remove the incorrectly advertised alternatives which allow a misconfigured pipeline to be established. Signed-off-by: Kieran Bingham --- drivers/media/i2c/ov5640.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 244c341d0e77..e1e253730206 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -309,27 +309,6 @@ static const struct ov5640_pixfmt ov5640_csi2_formats[= ] =3D { .bpp =3D 8, .ctrl00 =3D 0x00, .mux =3D OV5640_FMT_MUX_RAW_DPC, - }, { - /* Raw bayer, GBGB... / RGRG... */ - .code =3D MEDIA_BUS_FMT_SGBRG8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .bpp =3D 8, - .ctrl00 =3D 0x01, - .mux =3D OV5640_FMT_MUX_RAW_DPC, - }, { - /* Raw bayer, GRGR... / BGBG... */ - .code =3D MEDIA_BUS_FMT_SGRBG8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .bpp =3D 8, - .ctrl00 =3D 0x02, - .mux =3D OV5640_FMT_MUX_RAW_DPC, - }, { - /* Raw bayer, RGRG... / GBGB... */ - .code =3D MEDIA_BUS_FMT_SRGGB8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .bpp =3D 8, - .ctrl00 =3D 0x03, - .mux =3D OV5640_FMT_MUX_RAW_DPC, }, { /* sentinel */ } }; --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 161873D3012; Fri, 1 May 2026 15:39:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649982; cv=none; b=ZxyNSRzOMQiiWAXH7ZmxYR2C52CIR31r7m4d3Scx4aSiNSSMcD4QXpfJfaqmMBGN1BoD+o46vpm0SkQKOvwEZ2+B4IbkYo6h5q6/4+iDWb1witS4QGAGlTjp6nfY2iuuA5kYsrjcaiGd24j8msmOAKqOZHvs4td8od2t0zC6QCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649982; c=relaxed/simple; bh=BkWFgUMIeraNgKW1ihJz0ELUrmnvjAwizQFcqrXGMgA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dy7oHORxNB0jygRJ8zUGrVUc9qczKvefKXYSbZWfTvS4w5qxmuDAlEpV6clUOQIs/3QlUNwsFl8rHIq+oGnzHIwu2tiyoaMmI3fcVz10Da1kBdm8IbCXo0PFDuHpmu26nqB6NhOIrnawG3W0fvLOW3tZZsm+bMpK8+RmAbane30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Aon8KcmS; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Aon8KcmS" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C0E64EB4; Fri, 1 May 2026 17:37:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649857; bh=BkWFgUMIeraNgKW1ihJz0ELUrmnvjAwizQFcqrXGMgA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Aon8KcmSgVgYXuiJd35TtzpvdyYcJx0XVXBMqofpQYAbTy3xTEW2MFW1WRH1z7XAz uWbll1kcWCqy19n9ynsi8oTF6xsEzQJxo/UTJUh1/3b6kZcO7H02Fc0AxdB1TWHndb fgwgX5X8S2VPF6aqKcDzbzA323jD0Et0uU6bwN3A= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:08 +0100 Subject: [PATCH 06/11] media: i2c: ov5640: split out the LSC registers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-6-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=5314; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=BkWFgUMIeraNgKW1ihJz0ELUrmnvjAwizQFcqrXGMgA=; b=4IssL5xAEoSw7dZmXTvAo7JkWyKBO46so/7xzM/9/CWB2zymBk+Jn7d7TcN+2QhKVMgHbxiLd lgAC12yShqzAWv66dNxlm45oxMg/UNiJRJQ8RzzHh5RCVTN7HFBk0pd X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= Lens shading is a characteristic which is specific to the lens of a given module. Separate the Lens Shading Calibration registers from the init_setting to identify the registers which must be updated when changing a lens. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- The ordering of the table entries here are maintained and not resorted (i.e. that first line) to make it easy to confirm that no adjustment is made to the data here. I've also moved the LSC 'above' the init table as otherwise the diff becomes unreviewable - as it shows a different hunk being conceptually moved instead and hides the ability to see what is moving. Though that itself also confirms that the values don't change here, so I'm happy to move it down if requested. --- drivers/media/i2c/ov5640.c | 51 +++++++++++++++++++++++++++---------------= ---- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index e1e253730206..b4e1ec4364df 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -522,6 +522,31 @@ static const struct v4l2_mbus_framefmt ov5640_dvp_defa= ult_fmt =3D { .field =3D V4L2_FIELD_NONE, }; =20 +static const struct reg_value ov5640_lsc[] =3D { + /* Lens Shading Correction */ + {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, + {0x5802, 0x0f, 0, 0}, {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, + {0x5805, 0x26, 0, 0}, {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, + {0x5808, 0x05, 0, 0}, {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, + {0x580b, 0x0d, 0, 0}, {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, + {0x580e, 0x00, 0, 0}, {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, + {0x5811, 0x09, 0, 0}, {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, + {0x5814, 0x00, 0, 0}, {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, + {0x5817, 0x08, 0, 0}, {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, + {0x581a, 0x05, 0, 0}, {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, + {0x581d, 0x0e, 0, 0}, {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, + {0x5820, 0x11, 0, 0}, {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, + {0x5823, 0x28, 0, 0}, {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, + {0x5826, 0x08, 0, 0}, {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, + {0x5829, 0x26, 0, 0}, {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, + {0x582c, 0x24, 0, 0}, {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, + {0x582f, 0x22, 0, 0}, {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, + {0x5832, 0x24, 0, 0}, {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, + {0x5835, 0x22, 0, 0}, {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, + {0x5838, 0x44, 0, 0}, {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, + {0x583b, 0x28, 0, 0}, {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, +}; + static const struct reg_value ov5640_init_setting[] =3D { {0x3103, 0x11, 0, 0}, {0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0}, @@ -574,27 +599,8 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x548d, 0xcd, 0, 0}, {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, {0x5490, 0x1d, 0, 0}, {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x10, 0, 0}, {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, - {0x558b, 0xf8, 0, 0}, {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, - {0x5802, 0x0f, 0, 0}, {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, - {0x5805, 0x26, 0, 0}, {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, - {0x5808, 0x05, 0, 0}, {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, - {0x580b, 0x0d, 0, 0}, {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, - {0x580e, 0x00, 0, 0}, {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, - {0x5811, 0x09, 0, 0}, {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, - {0x5814, 0x00, 0, 0}, {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, - {0x5817, 0x08, 0, 0}, {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, - {0x581a, 0x05, 0, 0}, {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, - {0x581d, 0x0e, 0, 0}, {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, - {0x5820, 0x11, 0, 0}, {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, - {0x5823, 0x28, 0, 0}, {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, - {0x5826, 0x08, 0, 0}, {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, - {0x5829, 0x26, 0, 0}, {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, - {0x582c, 0x24, 0, 0}, {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, - {0x582f, 0x22, 0, 0}, {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, - {0x5832, 0x24, 0, 0}, {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, - {0x5835, 0x22, 0, 0}, {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, - {0x5838, 0x44, 0, 0}, {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, - {0x583b, 0x28, 0, 0}, {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, + {0x558b, 0xf8, 0, 0}, + {0x5025, 0x00, 0, 0}, {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, {0x3a1b, 0x30, 0, 0}, {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x14, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3c00, 0x04, 0, 300}, @@ -2396,6 +2402,9 @@ static int ov5640_restore_mode(struct ov5640_dev *sen= sor) ov5640_load_regs(sensor, ov5640_init_setting, ARRAY_SIZE(ov5640_init_setting)); =20 + /* Load the Lens Shading Correction Table */ + ov5640_load_regs(sensor, ov5640_lsc, ARRAY_SIZE(ov5640_lsc)); + ret =3D ov5640_mod_reg(sensor, OV5640_REG_SYS_ROOT_DIVIDER, 0x3f, (ilog2(OV5640_SCLK2X_ROOT_DIV) << 2) | ilog2(OV5640_SCLK_ROOT_DIV)); --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CF853D091B; Fri, 1 May 2026 15:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649982; cv=none; b=OEFF0GsuWoTahMptYjCxZvnfALj6Gd5dq0fnn8sNaMtTFD1Gz3LR7/77yO01DcEDMJLwXuFjGEOUZI5hVnfHSVbt2W6oOJYQ/AI4dq/I2/wQMnA78+eAYVboaBQ+cF4MmtB+04XUR8r89f8B0PZe0qjzbHrXea8vUCnAA1taxhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649982; c=relaxed/simple; bh=DQCUjDrCnDe0ZfwbDnnalWvDQSrt/yIfBPdK5RXwdf8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YpLtUTyaE16S/PfkxaKt8wdtafnM1FJVweGQHTddO/AQlUTHkUksBkjleGGnDyyDKl7Hka19CRzT7z7j/R+AqjYGKacF0wGgAFbNyLcegN2HgTnRpG+wIps9uICL5pIsHk8YYuKHziJxklBlgL4pVOyKRT1n69GnLDNYHeOQCVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Ekkw31iT; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ekkw31iT" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 226D813BA; Fri, 1 May 2026 17:37:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649857; bh=DQCUjDrCnDe0ZfwbDnnalWvDQSrt/yIfBPdK5RXwdf8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ekkw31iTBo/GppkOmZXgqA7DkbITYKGIwH6wf9NlLDBKL7vdzMMzNcBw0lBD3EpQr RpMISPw/pw9/6CATx97ED2me1ad/zbEm9W7rG0DKqPbYEVZYUFeYm2RiTUUcm/U4GK KrgEQD/OAK1L0oSrciCgjUSxboKhvNdI0vAR70+M= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:09 +0100 Subject: [PATCH 07/11] media: i2c: ov5640: Split out AWB registers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-7-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=2682; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=DQCUjDrCnDe0ZfwbDnnalWvDQSrt/yIfBPdK5RXwdf8=; b=INH3F+izvzn4SBYWPNSW2mW7VGJON9Div9c9HFeqcKu73aN0USWM7IFyxorLR61YrvklXli49 BJb8zjTCm8pD+u+tEuCD6ZigvywUGDIw2ytil1py7deCDq5XgxHSeyh X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= Move the AWB registers to their own lines and split out from the bulk block independently as a first stage before documenting to ensure no registers values get lost or reordered during the updates. Signed-off-by: Kieran Bingham --- drivers/media/i2c/ov5640.c | 46 +++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index b4e1ec4364df..4b6804fc47e1 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -573,17 +573,41 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, - {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, - {0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, - {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, - {0x5187, 0x09, 0, 0}, {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, - {0x518a, 0x54, 0, 0}, {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, - {0x518d, 0x50, 0, 0}, {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, - {0x5190, 0x46, 0, 0}, {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, - {0x5193, 0x70, 0, 0}, {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, - {0x5196, 0x03, 0, 0}, {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, - {0x5199, 0x6c, 0, 0}, {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, - {0x519c, 0x09, 0, 0}, {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, + {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, + + /* AWB Control */ + {0x5180, 0xff, 0, 0}, + {0x5181, 0xf2, 0, 0}, + {0x5182, 0x00, 0, 0}, + {0x5183, 0x14, 0, 0}, + {0x5184, 0x25, 0, 0}, + {0x5185, 0x24, 0, 0}, + {0x5186, 0x09, 0, 0}, + {0x5187, 0x09, 0, 0}, + {0x5188, 0x09, 0, 0}, + {0x5189, 0x88, 0, 0}, + {0x518a, 0x54, 0, 0}, + {0x518b, 0xee, 0, 0}, + {0x518c, 0xb2, 0, 0}, + {0x518d, 0x50, 0, 0}, + {0x518e, 0x34, 0, 0}, + {0x518f, 0x6b, 0, 0}, + {0x5190, 0x46, 0, 0}, + {0x5191, 0xf8, 0, 0}, + {0x5192, 0x04, 0, 0}, + {0x5193, 0x70, 0, 0}, + {0x5194, 0xf0, 0, 0}, + {0x5195, 0xf0, 0, 0}, + {0x5196, 0x03, 0, 0}, + {0x5197, 0x01, 0, 0}, + {0x5198, 0x04, 0, 0}, + {0x5199, 0x6c, 0, 0}, + {0x519a, 0x04, 0, 0}, + {0x519b, 0x00, 0, 0}, + {0x519c, 0x09, 0, 0}, + {0x519d, 0x2b, 0, 0}, + {0x519e, 0x38, 0, 0}, + {0x5381, 0x1e, 0, 0}, {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, {0x5387, 0x7c, 0, 0}, {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 649B33D331C; Fri, 1 May 2026 15:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649992; cv=none; b=hksBgKk6itNFY4l3xomXwCZMM/VmrnmiyhFbMNKzyXUUApWSyS2XUlotrSBCaGelPUhm4lBLMGc8mTiER0/NxhHnMYS8/WsfeukuMhF/2E0XWdUWu2RRcKDvoosj/OEnkfEPWFj1OSldhTafIPEo5/2TOJ6OHYy9ph0J88RT5XI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649992; c=relaxed/simple; bh=6VgTwInBWVrzLLsEb7C28IGZSXo4bBF+2sNl5yXZVcE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aha46fVzPS5xHjCDZlch4A5xXl7e1NwhQ5T5OLrMcrRVnJoVRPyorWltzjGsr+OLZbhYARHbG9kX7Vb4IhizKLYUUc0G5UrCk2XWJ0imVuMfrzU5o3yWMp5tlluHztNC/01VwXb41rouuE2AG6743Cqi3yudekuwGlDqRTIeDD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=nxafne+c; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nxafne+c" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 72DFB13CA; Fri, 1 May 2026 17:37:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649857; bh=6VgTwInBWVrzLLsEb7C28IGZSXo4bBF+2sNl5yXZVcE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nxafne+cPN7hZylWKMhnV134eXYD/H82zZouqeDBmwaJmqZ2U0j5jTPHJTyBY/QhY 13Eu4zvvuLKVu0IpvA8An3zbtouLrODmrgQTJwKjmKgI/aMhVpMrvHuOKmsb9+vohu zJBQj9YboB18C7Q+PtD8wXrXwtzt436Syw2yZ4M0= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:10 +0100 Subject: [PATCH 08/11] media: i2c: ov5640: Document AWB control registers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-8-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=4678; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=6VgTwInBWVrzLLsEb7C28IGZSXo4bBF+2sNl5yXZVcE=; b=8UvS0f1C9X9dyALzP1GlfNVsTPuhzfzi4VEXuobddAV9FcyhRicGYVmLNcsEtEX+kqbik67Xt FZTWBw7w8soBAMFTQT5nI5U/tHdRlYKiEm990f4ZMjO4BYIJq3wRurQ X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= Identify and map the registers that are controlling the AWB and document their current impact inline in the register set. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 61 +++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 4b6804fc47e1..34fe7f51e17b 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -112,6 +112,34 @@ #define OV5640_REG_PCLK_PERIOD 0x4837 #define OV5640_REG_ISP_FORMAT_MUX_CTRL 0x501f #define OV5640_REG_PRE_ISP_TEST_SET1 0x503d + +#define OV5640_REG_AWB_CONTROL_00 0x5180 /* AWB B block */ +#define OV5640_REG_AWB_CONTROL_01 0x5181 /* AWB Step and Slope control */ +#define OV5640_REG_AWB_CONTROL_02 0x5182 /* 7:4 Max local counter 3:0 mas = fast counter */ +#define OV5640_REG_AWB_CONTROL_03 0x5183 /* AWB Simple/Advanced control */ +#define OV5640_REG_AWB_CONTROL_04 0x5184 /* Count and G enable */ +#define OV5640_REG_AWB_CONTROL_05 0x5185 /* Stable Range Thresholds */ + +#define OV5640_REG_AWB_CONTROL_17 0x5191 /* AWB Top limit */ +#define OV5640_REG_AWB_CONTROL_18 0x5192 /* AWB Bottom limit */ +#define OV5640_REG_AWB_CONTROL_19 0x5193 /* Red limit */ +#define OV5640_REG_AWB_CONTROL_20 0x5194 /* Green limit */ +#define OV5640_REG_AWB_CONTROL_21 0x5195 /* Blue limit */ + +#define OV5640_REG_AWB_CONTROL_22 0x5196 /* AWB Freeze and Simple Selectio= n */ +#define OV5640_AWB_FREEZE BIT(5) /* AWB freeze */ +#define OV5640_AWB_SIMPLE_SELECT_MASK GENMASK(3, 2) +#define OV5640_AWB_SIMPLE_AFTER_AWB_0 0 /* AWB simple from after AWB gain = */ +#define OV5640_AWB_SIMPLE_AFTER_GMA_0 1 /* AWB simple from after RAW GMA */ +#define OV5640_AWB_SIMPLE_AFTER_GMA_1 2 /* AWB simple from after RAW GMA */ +#define OV5640_AWB_SIMPLE_AFTER_AWB_1 3 /* AWB simple from after AWB gain = */ +#define OV5640_AWB_FAST_ENABLE BIT(1) /* AWB fast enable */ +#define OV5640_AWB_BIAS_STAT BIT(0) + +#define OV5640_REG_AWB_CONTROL_23 0x5197 /* Local Limit */ + +#define OV5640_REG_AWB_CONTROL_30 0x519e /* Local limit and Stable Select = */ + #define OV5640_REG_SDE_CTRL0 0x5580 #define OV5640_REG_SDE_CTRL1 0x5581 #define OV5640_REG_SDE_CTRL3 0x5583 @@ -576,12 +604,14 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, =20 /* AWB Control */ - {0x5180, 0xff, 0, 0}, - {0x5181, 0xf2, 0, 0}, - {0x5182, 0x00, 0, 0}, - {0x5183, 0x14, 0, 0}, - {0x5184, 0x25, 0, 0}, - {0x5185, 0x24, 0, 0}, + {OV5640_REG_AWB_CONTROL_00, 0xff, 0, 0}, /* AWB B Block */ + {OV5640_REG_AWB_CONTROL_01, 0xf2, 0, 0}, /* Step and Slope - one zone, 0= slope, step fast=3Dstep local =3D 3 */ + {OV5640_REG_AWB_CONTROL_02, 0x00, 0, 0}, /* Local/Fast counters @ 0 */ + {OV5640_REG_AWB_CONTROL_03, 0x14, 0, 0}, /* Advanced AWB: AWB SIMF, AWB W= in =3D 1 */ + {OV5640_REG_AWB_CONTROL_04, 0x25, 0, 0}, /* G-Enable, Count-limit=3D1, co= unt threshold=3D1 */ + {OV5640_REG_AWB_CONTROL_05, 0x24, 0, 0}, /* Stable Ranges: Threshold for = [7:4] unstable to stable [3:0] stable to unstable */ + + /* AWB Advanced Control - Undocumented */ {0x5186, 0x09, 0, 0}, {0x5187, 0x09, 0, 0}, {0x5188, 0x09, 0, 0}, @@ -593,20 +623,23 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, {0x5190, 0x46, 0, 0}, - {0x5191, 0xf8, 0, 0}, - {0x5192, 0x04, 0, 0}, - {0x5193, 0x70, 0, 0}, - {0x5194, 0xf0, 0, 0}, - {0x5195, 0xf0, 0, 0}, - {0x5196, 0x03, 0, 0}, - {0x5197, 0x01, 0, 0}, + + {OV5640_REG_AWB_CONTROL_17, 0xf8, 0, 0}, /* AWB Top limit (Default 0xff)*/ + {OV5640_REG_AWB_CONTROL_18, 0x04, 0, 0}, /* AWB Bottom limit (Default 0x0= 0) */ + {OV5640_REG_AWB_CONTROL_19, 0x70, 0, 0}, /* Red limit (Default 0xf0) */ + {OV5640_REG_AWB_CONTROL_20, 0xf0, 0, 0}, /* Green Limit (Default 0xf0) */ + {OV5640_REG_AWB_CONTROL_21, 0xf0, 0, 0}, /* Blue limit (Default 0xf0) */ + {OV5640_REG_AWB_CONTROL_22, 0x03, 0, 0}, /* AWB after AWB gain; Fast enab= le; Bias stat; */ + {OV5640_REG_AWB_CONTROL_23, 0x01, 0, 0}, /* Local limit (Default 0x02) */ + + /* Debug mode - Undocumented */ {0x5198, 0x04, 0, 0}, {0x5199, 0x6c, 0, 0}, {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x09, 0, 0}, {0x519d, 0x2b, 0, 0}, - {0x519e, 0x38, 0, 0}, + {OV5640_REG_AWB_CONTROL_30, 0x38, 0, 0}, /* [7:4] Debug =3D 3; [3] Local = Limit Select =3D 1; [2] Simple stable select=3D0; [1:0] Debug=3D0 */ =20 {0x5381, 0x1e, 0, 0}, {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64A493D331D; Fri, 1 May 2026 15:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649996; cv=none; b=IxvVU/zAqno3c0c0h+h1sI2XgSzpAZM1vFPJ6Z935vMZ/tg1qZf0nXtMqEtFh5gDbtl1b3eiwMPNfiqIaQ9NYwx53+wQDAPdqRshLwtrX8vuVpmW1bF+VgDZRLzYKZNN08z/5zswToBcDUchMsU57B3ey7yae8SAhwFSuJOTu3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649996; c=relaxed/simple; bh=Bv+aA0Un6jxPT3sP5HXuqKuE8Sfx1qAXIhAULNpfPRM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kzmpBneTehngjE7uXGT6t3cnXyjm0wZ4jfRIx+gm5Frfr67S8Mip4APQyKP996IYVtL0bilS/QiZNUhUr3dieQTUIikClhhoin6F6C8KO7S5446tsz2h5eZ/WNA5MCUrxFc9NblYcAlsMXVoSFIDKnwsBPuuepbmo0sFGZOCwYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=VK9tflmI; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VK9tflmI" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C1FDA13D7; Fri, 1 May 2026 17:37:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649858; bh=Bv+aA0Un6jxPT3sP5HXuqKuE8Sfx1qAXIhAULNpfPRM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VK9tflmIkchD4umkRVUZB/SrVadTVXpVmXwgHjsjs+Gv3DrMXsxTZiyP1FO1R2pJ7 yoJGat+M30pQOBbkiI8PSDOKkhVRnnMysH4/+Va43BigGcj2h9xfPxgb14JvZws83z IxpIY2BsdPFUw0XeU0b+G4FiMoyqocAVpHVQxCgM= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:11 +0100 Subject: [PATCH 09/11] media: i2c: ov5640: Add ISP Control registers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-9-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=1723; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=Bv+aA0Un6jxPT3sP5HXuqKuE8Sfx1qAXIhAULNpfPRM=; b=chYR7ZZJY/l32y+0vkmyc0QA8dAMmmD/vlEE6Jwj4ufDSyOfVi+4xFmabHYps4EqKUe9J6S2G THMBXDbZLVbBkm60s/lKhq+DHFBc00UTDYvmk1vzbJSutwKHYCWgAii X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= Define the bits for the ISP control register to be able to use and explain component enablement. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 34fe7f51e17b..fd369a13463e 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -110,6 +110,21 @@ #define OV5640_REG_MIPI_CTRL00 0x4800 #define OV5640_REG_DEBUG_MODE 0x4814 #define OV5640_REG_PCLK_PERIOD 0x4837 + +#define OV5640_REG_ISP_CTRL00 0x5000 +#define OV5640_ISP_00_LENC_ENABLE BIT(7) +#define OV5640_ISP_00_GMA_ENABLE BIT(5) +#define OV5640_ISP_00_BPC_ENABLE BIT(2) +#define OV5640_ISP_00_WPC_ENABLE BIT(1) +#define OV5640_ISP_00_CIP_ENABLE BIT(0) + +#define OV5640_REG_ISP_CTRL01 0x5001 +#define OV5640_ISP_01_SDE_ENABLE BIT(7) +#define OV5640_ISP_01_SCL_ENABLE BIT(5) +#define OV5640_ISP_01_UVA_ENABLE BIT(2) +#define OV5640_ISP_01_CMX_ENABLE BIT(1) +#define OV5640_ISP_01_AWB_ENABLE BIT(0) + #define OV5640_REG_ISP_FORMAT_MUX_CTRL 0x501f #define OV5640_REG_PRE_ISP_TEST_SET1 0x503d =20 @@ -601,7 +616,10 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, - {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, + + /* ISP Control */ + {OV5640_REG_ISP_CTRL00, 0xa7, 0, 0}, + {OV5640_REG_ISP_CTRL01, 0xa3, 0, 0}, =20 /* AWB Control */ {OV5640_REG_AWB_CONTROL_00, 0xff, 0, 0}, /* AWB B Block */ --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E5E43D16F4; Fri, 1 May 2026 15:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649997; cv=none; b=bUdUYePgCOPUIEgHC2fJkwb6iIz6T58WhdaEjPXAdumswB8NHhtM2HNB8kA1QENx9hyMKn/Gd4tCUVN5vrttzq4gr0WdSdCOh+CA8S7UEmSRs1Aw8fVPtayw8VQ1D2yOZKVLEx62LjW2iJNbMwQj7kfLZxIn8dAwBawGI//+iiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649997; c=relaxed/simple; bh=dq4DMCXqSYdS73+YUge5/htblgYG6RQnLmA/JkmcKPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CqPDydbGNA1iH10QJ4W4Y+Xd82W0B64+zxQlWQYWZRLxQLVWlwqKhPV9DcXDa4UcDNpIHgVlCTyRPUjaIipSVJI9yVnls/zcYy5MjxW44JtsEOo/2xqx2+DpcPu8J+pQXLa0f4Qei2TeTM4vhQuM+g1wKUgcbOWgKAldfW5Ahvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Kn9vmVSn; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Kn9vmVSn" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1EBF519D6; Fri, 1 May 2026 17:37:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649858; bh=dq4DMCXqSYdS73+YUge5/htblgYG6RQnLmA/JkmcKPU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Kn9vmVSnnhXoVL5cp66yibNJ5ihGPZVVuZ2wT0k5uh5wVzixNvi02CvYgq8oWFFQX sZS+fyKtyzzVERkBbrQHCoKpI+/JIY4XyIbQKUqgqCzHOQPdhiafwdxk6AVizeqHcR 4TKntwbFy7SuOjsvydJNO6ofXBMNiii3xaLKelCo= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:12 +0100 Subject: [PATCH 10/11] media: i2c: ov5640: Disable ISP for raw output Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-10-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=3940; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=dq4DMCXqSYdS73+YUge5/htblgYG6RQnLmA/JkmcKPU=; b=xw4QGoclVSO7tSIaroiJ+VJb5MVyXwscstU9Qg8ygk9BEn9qt6nJHiZfHchdRYeu88kET+8Ig gd19jYAcadQAqoSjHwufQG2uzZrb0bIpTFLs0t5ImMPm3kMzU25rIqA X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= The OV5640 has ISP operations that can run even when outputting RAW bayer data. These include the Lens Shading Correction, Gamma and Auto white balance which need to be disabled when performing module calibration using RAW data. Signed-off-by: Kieran Bingham --- drivers/media/i2c/ov5640.c | 45 ++++++++++++++++++++++++++++++++++++++----= --- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index fd369a13463e..f63d81640f54 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -280,28 +280,28 @@ static const struct ov5640_pixfmt ov5640_dvp_formats[= ] =3D { }, { /* Raw, BGBG... / GRGR... */ .code =3D MEDIA_BUS_FMT_SBGGR8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, + .colorspace =3D V4L2_COLORSPACE_RAW, .bpp =3D 8, .ctrl00 =3D 0x00, .mux =3D OV5640_FMT_MUX_RAW_DPC, }, { /* Raw bayer, GBGB... / RGRG... */ .code =3D MEDIA_BUS_FMT_SGBRG8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, + .colorspace =3D V4L2_COLORSPACE_RAW, .bpp =3D 8, .ctrl00 =3D 0x01, .mux =3D OV5640_FMT_MUX_RAW_DPC, }, { /* Raw bayer, GRGR... / BGBG... */ .code =3D MEDIA_BUS_FMT_SGRBG8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, + .colorspace =3D V4L2_COLORSPACE_RAW, .bpp =3D 8, .ctrl00 =3D 0x02, .mux =3D OV5640_FMT_MUX_RAW_DPC, }, { /* Raw bayer, RGRG... / GBGB... */ .code =3D MEDIA_BUS_FMT_SRGGB8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, + .colorspace =3D V4L2_COLORSPACE_RAW, .bpp =3D 8, .ctrl00 =3D 0x03, .mux =3D OV5640_FMT_MUX_RAW_DPC, @@ -348,7 +348,7 @@ static const struct ov5640_pixfmt ov5640_csi2_formats[]= =3D { }, { /* Raw, BGBG... / GRGR... */ .code =3D MEDIA_BUS_FMT_SBGGR8_1X8, - .colorspace =3D V4L2_COLORSPACE_SRGB, + .colorspace =3D V4L2_COLORSPACE_RAW, .bpp =3D 8, .ctrl00 =3D 0x00, .mux =3D OV5640_FMT_MUX_RAW_DPC, @@ -473,6 +473,7 @@ struct ov5640_dev { =20 struct v4l2_mbus_framefmt fmt; bool pending_fmt_change; + bool is_raw; =20 const struct ov5640_mode_info *current_mode; const struct ov5640_mode_info *last_mode; @@ -618,8 +619,13 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, =20 /* ISP Control */ - {OV5640_REG_ISP_CTRL00, 0xa7, 0, 0}, - {OV5640_REG_ISP_CTRL01, 0xa3, 0, 0}, + {OV5640_REG_ISP_CTRL00, OV5640_ISP_00_LENC_ENABLE | OV5640_ISP_00_GMA_ENA= BLE | + OV5640_ISP_00_BPC_ENABLE | OV5640_ISP_00_WPC_ENABLE | + OV5640_ISP_00_CIP_ENABLE, 0, 0}, + + /* OV5640_ISP_01_UVA_ENABLE is not enabled */ + {OV5640_REG_ISP_CTRL01, OV5640_ISP_01_SDE_ENABLE | OV5640_ISP_01_SCL_ENAB= LE | + OV5640_ISP_01_CMX_ENABLE | OV5640_ISP_01_AWB_ENABLE, 0, 0}, =20 /* AWB Control */ {OV5640_REG_AWB_CONTROL_00, 0xff, 0, 0}, /* AWB B Block */ @@ -3116,6 +3122,31 @@ static int ov5640_set_framefmt(struct ov5640_dev *se= nsor, if (ret) return ret; =20 + /* + * Disable all ISP image processing (Lens Shading, Gamma, AWB...) for + * RAW modes to facilitate module tuning. + */ + sensor->is_raw =3D pixfmt->colorspace =3D=3D V4L2_COLORSPACE_RAW; + if (sensor->is_raw) { + ret =3D ov5640_write_reg(sensor, OV5640_REG_ISP_CTRL00, 0); + if (ret) + return ret; + } else { + ret =3D ov5640_write_reg(sensor, OV5640_REG_ISP_CTRL00, + OV5640_ISP_00_LENC_ENABLE | OV5640_ISP_00_GMA_ENABLE | + OV5640_ISP_00_BPC_ENABLE | OV5640_ISP_00_WPC_ENABLE | + OV5640_ISP_00_CIP_ENABLE); + if (ret) + return ret; + + /* OV5640_ISP_01_UVA_ENABLE is not enabled */ + ret =3D ov5640_write_reg(sensor, OV5640_REG_ISP_CTRL01, + OV5640_ISP_01_SDE_ENABLE | OV5640_ISP_01_SCL_ENABLE | + OV5640_ISP_01_CMX_ENABLE | OV5640_ISP_01_AWB_ENABLE); + if (ret) + return ret; + } + /* * TIMING TC REG21: * - [5]: JPEG enable --=20 2.52.0 From nobody Sun Jun 14 07:49:20 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5FB03D16FB; Fri, 1 May 2026 15:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649999; cv=none; b=Y2eUMh+82yo5JuEZXukPoXK9KoU8a3mqvwktswBiqIoRiiAXmrB2xYQeuOHUwUSD40slelrjkWaMKCbURabPXX0MJ+388W35WuZF+3u+fIe1BGe8lklKki6IVsAyaWnovNoJV+chLR9+rPUHcVDP65ApqJ//gV/S7abhkKdRLOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777649999; c=relaxed/simple; bh=/tTFcB4pXBUazkM9VhFOOhHmHjtzSclslrw6PRtHrHM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j7AC74mIsXNs09a8UAABnU/oHy5ANwSglScK0MpW84PDjiMrDw6kQBYijeNxctmfvB1CWp5+lLRaevTXHDGpFRuouSGENrPz9xzETBGXiHOgLCUatI9Dr9Gef5gp0mDojkyGGEy6xTQEmJa+lmcMyUQ7AtDIWaQ+jvnDbhNjjxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=FWw6s/X+; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FWw6s/X+" Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 753CC1E1E; Fri, 1 May 2026 17:37:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777649858; bh=/tTFcB4pXBUazkM9VhFOOhHmHjtzSclslrw6PRtHrHM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FWw6s/X+hOKQDu4gBtzpqG3hku0607s89h12ZJpbP+fwlXVFWEFVUwIs+2apkYqU8 /GQt/IJY1cngppWlXEYx7UU//WFZ2D8mVr6UiESflc7hdo+KD7NmHwHVCpd76p/0Yj d3hZ+5Jl1HMeb6IBM0lYZlEYWCbohZZwNHiQdzHg= From: Kieran Bingham Date: Fri, 01 May 2026 16:39:13 +0100 Subject: [PATCH 11/11] media: i2c: ov5640: Split out format mux registers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260501-ov5640_cleanup-v1-11-0869a7802a33@ideasonboard.com> References: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> In-Reply-To: <20260501-ov5640_cleanup-v1-0-0869a7802a33@ideasonboard.com> To: Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777649959; l=1355; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=/tTFcB4pXBUazkM9VhFOOhHmHjtzSclslrw6PRtHrHM=; b=ezTvfZ8rJcydZVN7WtBketHeifw7iS99k05Hg9BLsuF7yAIJVdSWIhtHddKluQAb4Jvenw8s6 wWziGP7Qt7JDWEDqrxGOXmjfb0RneK/aZcLM2W3PzsDpRglHCv2wzeq X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= The init_setting table configures format control and mux to default for YUV420 output. These are later determined by the users format selection, and so are candidates for removal from the init table. Split the additions out from the register block and document them. Signed-off-by: Kieran Bingham --- drivers/media/i2c/ov5640.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index f63d81640f54..477f6a3ddbf6 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -615,8 +615,13 @@ static const struct reg_value ov5640_init_setting[] = =3D { {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, - {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0}, - {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, + {0x302e, 0x08, 0, 0}, + + /* Format control, Mux control */ + {0x4300, 0x3f, 0, 0}, /* YUV420 YYYY... / UYVY... */ + {0x501f, 0x00, 0, 0}, /* ISP YUV422 */ + + {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0}, =20 /* ISP Control */ {OV5640_REG_ISP_CTRL00, OV5640_ISP_00_LENC_ENABLE | OV5640_ISP_00_GMA_ENA= BLE | --=20 2.52.0