From nobody Thu Nov 28 03:40:01 2024 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 D16AF1E1A3E; Fri, 8 Nov 2024 09:35:18 +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=1731058520; cv=none; b=czn/ZZz/OuE1BBXIweSocexxZRSm9t98zK5q73idNULE3oS5FDvq5rt0WTOlfwlYMPfP4NBB7c/lzKDrx99YhF5WIggvFIe2gEug78D8/RJy1ViU9BAnO9Kd4VKt4GMuP3jv0HRMGlwvTKoulCibDPt+Tdhy5l8DtRqgx29TwME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058520; c=relaxed/simple; bh=OC00lpY7NpyIrSmfbWRiAoUQ/5I+ziKOYf+2u7jSrH8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YTl+C2yGJTxofw/PEFohGTsJ5NIP2Hrpthpun4N/cj1lGla4yPrsvZAKP8GIlYDBT5nM4ITBJsPYdB1ioWLQhTwipkNPt6Z8KT5aDsNQY5Ipu2vkRBFEgXr82YD6eE7u4FCEQxL15ijRnY481w+JaD0fHcQZguLECT44ZoCZEjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=XjWNrBi/; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="XjWNrBi/" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9E369A30; Fri, 8 Nov 2024 10:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058507; bh=OC00lpY7NpyIrSmfbWRiAoUQ/5I+ziKOYf+2u7jSrH8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XjWNrBi/mOLC5WZ3h5iQmW069oCnKovu/okPn0Hu8OWJW6EOrIZ5EFKcEraGaN5mI 8PVGIGoVU8TasLQNcEzBjhlB2RBP8exumELaC40A/rXPeyvj2WKJcFRiyuDbYyCiWc tR+dlB/wuyhJP0aQyKtVGC5yguXLS9YgVPTmPp2E= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:45 +0200 Subject: [PATCH v2 01/15] media: i2c: ds90ub9x3: Fix extra fwnode_handle_put() 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: <20241108-ub9xx-fixes-v2-1-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1677; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=OC00lpY7NpyIrSmfbWRiAoUQ/5I+ziKOYf+2u7jSrH8=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtN+IeuO31FN375+cuGav2V2T1fr/kDyUD3U oZPzT12uM+JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTQAKCRD6PaqMvJYe 9XlMD/41+MLDic05HXHz+QGGJfZAqVxOhUwuCUylXevDEdmIXJRgJPHt8DMD5r5wYjDe0qwvQGA aorantz1W8knvSXdYOONYkO53/LK/VCs61zH0BCjFn8OmNFU7mIdwBQ7IUrLm0kukXBy1Zhphhd bOE2+of9TfFeepRFVKiY08FC7C8581yqA6+5GdK3hypm4/HBGFxNZayVEQmtnznde4LEgkqMMEQ n3KHom5F5P+ORJS8dqCpZHzh9gFVFwVTGu/LZ3iGAvei3kBFgFgOqU0xezojzuRu/7N82JqdDzI e6AEw911/Qd1qxiYjWN8hn1o221yegcX9ImwMPnq/mijNQ0DiUNqxipvQ1VBf6kOimeA1FI1jNK weg5Yn/YqXwf7OJ1IbDawdrvM7nFW+7h3g+Z4YnX4KpSy8M2807WeYE+ih6ChoR++AfsDYKfOVP lp+R966HcqxuliEWq+GsaOuOeBU3tuCWyapFdbI72+6xN2UZN0EXWNX7bZat+ovQ+Ilaq97Gg9q 63F+xmKWYZ22HDYteXO38rKEclkJfgpXSp2UKvE/W4sDz2lgOEUed8U7B54NfEIUS0EYYnHoL+1 EjRFiN8ELjJB1pfXnSB/sNgFfSY+ryNvph+1RCLkW7iB4YJ16lVYtXCStiiQtwOdpQLDR4QhybM FUjPggJnEb6P9Og== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 The ub913 and ub953 drivers call fwnode_handle_put(priv->sd.fwnode) as part of their remove process, and if the driver is removed multiple times, eventually leads to put "overflow", possibly causing memory corruption or crash. The fwnode_handle_put() is a leftover from commit 905f88ccebb1 ("media: i2c: ds90ub9x3: Fix sub-device matching"), which changed the code related to the sd.fwnode, but missed removing these fwnode_handle_put() calls. Signed-off-by: Tomi Valkeinen Fixes: 905f88ccebb1 ("media: i2c: ds90ub9x3: Fix sub-device matching") --- drivers/media/i2c/ds90ub913.c | 1 - drivers/media/i2c/ds90ub953.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index ca9bb29dab89..150d6641516f 100644 --- a/drivers/media/i2c/ds90ub913.c +++ b/drivers/media/i2c/ds90ub913.c @@ -793,7 +793,6 @@ static void ub913_subdev_uninit(struct ub913_data *priv) v4l2_async_unregister_subdev(&priv->sd); ub913_v4l2_nf_unregister(priv); v4l2_subdev_cleanup(&priv->sd); - fwnode_handle_put(priv->sd.fwnode); media_entity_cleanup(&priv->sd.entity); } =20 diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index 16f88db14981..10daecf6f457 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -1291,7 +1291,6 @@ static void ub953_subdev_uninit(struct ub953_data *pr= iv) v4l2_async_unregister_subdev(&priv->sd); ub953_v4l2_notifier_unregister(priv); v4l2_subdev_cleanup(&priv->sd); - fwnode_handle_put(priv->sd.fwnode); media_entity_cleanup(&priv->sd.entity); } =20 --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 15EC01E2854; Fri, 8 Nov 2024 09:35:19 +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=1731058522; cv=none; b=n+mU4zik9NrrP7e4qsRiA4rY4x8KH5gEt8HzcaXLXUB8hSyIEtsTKFLH5aOLth96ii+3CkGi70H4pyJn55Re7e5V6c9capGA6OO+GL+DxXjnhHKaTsyyg54AHK61uOW6RlyHZoD+cHYjzHfnev+WVQ+2Gqt3pWqp/BeoXDL0kjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058522; c=relaxed/simple; bh=dW1qzALQAuTsR/DlBA4YNdLa29WamlEcXrtjr7uIUrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ge3Jup9/wV6UW50YlATFR30/5dHrkbkfwztxQ0cMvRTA6z60CC38gR1c4seS8Ur+092mGz+QAkJwoyTQhqumQBsYckrUNeCuDMVcMY+uJCDZy4N46pPWZ9VaKz8xVEU3l+L6innGtCE+UCr2Ne1iHkR1E8HyvMEv9WgVyPQOgcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=MsHVzlU5; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="MsHVzlU5" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3725DBC0; Fri, 8 Nov 2024 10:35:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058507; bh=dW1qzALQAuTsR/DlBA4YNdLa29WamlEcXrtjr7uIUrY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MsHVzlU5B+5R0xbZC/LtsXygJ1drzUI5Sa7zj0/+ZPcLVeZhVmMFKfvw/XLvP+tuI WbyWvQkuP9GYo6WT6FLA5AREgv3ggP501bGTcojusE012NWizOsGXWtEgRzsRzQeyZ 9P7Z43dgKJp7BWiCHZjbaU6PSGs5jIHzoLwc52fI= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:46 +0200 Subject: [PATCH v2 02/15] media: i2c: ds90ub960: Fix UB9702 refclk register access 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: <20241108-ub9xx-fixes-v2-2-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1313; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=dW1qzALQAuTsR/DlBA4YNdLa29WamlEcXrtjr7uIUrY=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtN+AmjAKjva+Jd/Oa47ZN1511HAuIKt3jJ5 0QjfeqVw+iJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTQAKCRD6PaqMvJYe 9dtrEACsDQ2vAoP18i0GIK9vKNY7r3wYO6tDtqtV7nisgNP6jz/U4wXbeO7cnPsYmr8HjqWzPDE renjseDPTvBCJNqQptqviko77vUiauBlSHaQtXMFzN518Lym+Wr1WxCuC4llLfqEeayVyPVUsHA N52uFZElnpEi6FwG1JM+DmVUsrIwE9b/LIfHDlzVU8nHJGiOjyoQzGaXtOCMnbn9YyEs8+4w4N5 tc3lMdYbxA3OoXMcewk7u0mCaAXj+0BKeQ15go3P8rivZZ7+JdMqRoNviBGPwG/AbUcxK2Kdfna u75xo18/wd85hSM/W1uPLCKraXaktZZ5tJa+8huPbN05oNFCaQc5spsZ5Q+ari8u5/xGe/MdIHg I93YYxfTXNefQNKKGs5UjIYBVi7omqiFtzIncq1rMWLTIqh9uXYomrhEZq8WnipjFm7kP27y4Ss 6OnkKUdrLwGbDRh1T3z/pjAvDxu8LOmJO2omMDo6TNpSdtZ5xFfb2C+0QyvRu9ZH7INFhD44Emz 4VOOpiKw4N/AG0BSsXYgXYUQQgRa47oCRddezyT2uvrSElihRzJwle20lD1FB0jOP+lyef7sKVI cZHKutZLqP21PR3J8xyd+52Mq+czD4ZupV7LuO8y2z/q40ko0rvLre2oEUPfMCPGPQlR77PjnfP Ev02NEMN+Tp1I/g== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 UB9702 has the refclk freq register at a different offset than UB960, but the code uses the UB960's offset for both chips. Fix this. The refclk freq is only used for a debug print, so there's no functional change here. Signed-off-by: Tomi Valkeinen Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") --- drivers/media/i2c/ds90ub960.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index ffe5f25f8647..b1e848678218 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -352,6 +352,8 @@ =20 #define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) /* < UB960_FPD_RX_NPORTS */ =20 +#define UB9702_SR_REFCLK_FREQ 0x3d + /* Indirect register blocks */ #define UB960_IND_TARGET_PAT_GEN 0x00 #define UB960_IND_TARGET_RX_ANA(n) (0x01 + (n)) @@ -3837,7 +3839,10 @@ static int ub960_enable_core_hw(struct ub960_data *p= riv) if (ret) goto err_pd_gpio; =20 - ret =3D ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq); + if (priv->hw_data->is_ub9702) + ret =3D ub960_read(priv, UB9702_SR_REFCLK_FREQ, &refclk_freq); + else + ret =3D ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq); if (ret) goto err_pd_gpio; =20 --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 EE8101E32B0; Fri, 8 Nov 2024 09:35:21 +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=1731058523; cv=none; b=BzJdPsejzS05eQaj8j5glywfZJ7JsnvblCDNfgXJUBFH4Ymfl6ckPrQ0Hm+Qh5h8oAcJ3BSaqJAadCOMPAY832riOxm+nW0pT7H2hgP0UUWAplT7mTjo77VDDMe23eAnPnqLVRczCmV48rMSqTwWox5HnPaCyBZq7K+4FfrNIws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058523; c=relaxed/simple; bh=KEJUa+NA275qqmfLngLNAjLh7UNjtzQi4qbdB1cIyjI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qK0OFt7qHF96Dkuzp0X6Es+jeUUAmwWCQxZloRePBDHV/tiy6YnM8iWieL7zT+6cUONFjDGicBf7KRQGcFfIoOBlBG+6jv6ClEDB/KmJ2PMNiVXhdC1LiqO2srBslc81sKVgHBnUKuF2RhAAgDDTBZI4KE3jIg2fSqNgzMDRu+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=L2WQ01eq; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="L2WQ01eq" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C53BDD21; Fri, 8 Nov 2024 10:35:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058508; bh=KEJUa+NA275qqmfLngLNAjLh7UNjtzQi4qbdB1cIyjI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L2WQ01eqZcwjxIZr8+LN/z1AWheDz8i0ycwPmN27K1pqUM4z3Y3y+Z1P4TYc9JwN4 HDm3bi+DHlNo+cfvoeov8CFcRP6CaaAQ0opBWVyoTdd7e3JjgV0ljCz8SrkKkJAm0s SE2HkemQ4Ysya9awETMoRTavILMiYq2mD35y2eV0= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:47 +0200 Subject: [PATCH v2 03/15] media: i2c: ds90ub960: Fix use of non-existing registers on UB9702 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: <20241108-ub9xx-fixes-v2-3-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1652; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=KEJUa+NA275qqmfLngLNAjLh7UNjtzQi4qbdB1cIyjI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtOVGM4C82BoYG0QdjOkvHIzQuGFPpQwhaLM XUTScweMImJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTgAKCRD6PaqMvJYe 9f4XD/0X6whY7P3M/FPk+E/LtIiszFNliYqfdDZPV97zqi0/gdsLTayoLMuhUMdRr/qXKpHs61j vT5xtviFBYl9iVeFfNNY8flUllCHeY8OH7arBmKgyxwnF1JdAYGtSljvGUpJMe8AgzdNNYfcuZE 7zTdk725Idh2xwrHosagYb7QM8v8S56zLlYdbh8VbvZ1+gxEjnUSoMJr/idBcNqQ6LlgCJuf9Nn bCc82dmA8dU97bo/4v0VZUqEKHrJ6x3lGP5CN732XQip1E+0cS7DJVAjoA9f7xoPapRFOE9vkPB 5CU+dugrn1CU9qkQAyqWxDMSxhjo7Qo7efWK9OcQ32HYXeVnjEjD0XacDQX0652ZIVHA2cGOhdg TghwcL9M5HrGKowCzwbPRvzagh+fjunj5FYFA7qB+oaWez5CJZXNSoohXZD+AmRbhg4d/tEwMzC JUHX+Pw0OBc8lf2056mO/OwFDiyd0hIjU6Gg70VFuUAYEPJMH/ycj93OaizmeYfm9Jm1Fr0mfOo K0/oIz3+UvmyBB3MaCZkJ50teds/VVaqtFijL0LoT7YGuwt5hJs9yRm2jw0q6h5cwJUomNn4GEE cJSr34eb4XNNBPx+7Rz+imQsE8QeIN+lKZtb0digdicMekR52hL5ysfspDVyq5PV0X7P4W6UufK oW3wyqpHdfPWaxw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 UB9702 doesn't have the registers for SP and EQ. Adjust the code in ub960_rxport_wait_locks() to not use those registers for UB9702. As these values are only used for a debug print here, there's no functional change. Signed-off-by: Tomi Valkeinen Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") --- drivers/media/i2c/ds90ub960.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index b1e848678218..24198b803eff 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -1577,16 +1577,24 @@ static int ub960_rxport_wait_locks(struct ub960_dat= a *priv, =20 ub960_rxport_read16(priv, nport, UB960_RR_RX_FREQ_HIGH, &v); =20 - ret =3D ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); - if (ret) - return ret; + if (priv->hw_data->is_ub9702) { + dev_dbg(dev, "\trx%u: locked, freq %llu Hz\n", + nport, (v * 1000000ULL) >> 8); + } else { + ret =3D ub960_rxport_get_strobe_pos(priv, nport, + &strobe_pos); + if (ret) + return ret; =20 - ret =3D ub960_rxport_get_eq_level(priv, nport, &eq_level); - if (ret) - return ret; + ret =3D ub960_rxport_get_eq_level(priv, nport, &eq_level); + if (ret) + return ret; =20 - dev_dbg(dev, "\trx%u: locked, SP: %d, EQ: %u, freq %llu Hz\n", - nport, strobe_pos, eq_level, (v * 1000000ULL) >> 8); + dev_dbg(dev, + "\trx%u: locked, SP: %d, EQ: %u, freq %llu Hz\n", + nport, strobe_pos, eq_level, + (v * 1000000ULL) >> 8); + } } =20 return 0; --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 1E51E1E3777; Fri, 8 Nov 2024 09:35:23 +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=1731058525; cv=none; b=T7Xj/4jutAYfe0pijG3fl8IRU0q/AP0gZS3CtdBn5CT3p6erFiQErmlbXCii/mLttbt8Emv753O6xxu9aqvWoaYoP0Rl0j87Z8xOcCcKPMRxMA1f9R0wLtTGiBBF+byaTVfDAiQKrYm4mqlylZWfYvhrkZpOt6ZxPXnGhp6vQP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058525; c=relaxed/simple; bh=B28bP5gitkgMyKQMXM8TB9xGzVrPus9N9HaZDbrOPW8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ArvyLxe+2y+hp2Yy+0hp/kxX8qgNEild479TkaPsVWGZWAqm5szBdfL6QhY+SmNVmXtuJW7kG2/9fC0pKkOzbTnUvAdFbAQpUrIXSXYqgT1Vra7vXkcCdBAlAYwkdqaptOjjWEiNC02pxjXdPmrREZNjKM2l0beg6geQ9ciCiQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=NFf5V4YJ; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="NFf5V4YJ" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 634CBE7C; Fri, 8 Nov 2024 10:35:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058508; bh=B28bP5gitkgMyKQMXM8TB9xGzVrPus9N9HaZDbrOPW8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NFf5V4YJVG/ndo+9Co48JfCSCrMn+lG8aXEIwQLZybDqZU53ciK4EjhDEO+pR6l1d 3O1LVGwzuevJbYobw0TuDmNSGkwUK0OsoxMnnkhzl5dZrTgJyo23Vbbd/64bHQOnU9 HXg0EBbuGealwg2PXrkyHeAfFfTJv2h7bZ9cLNRY= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:48 +0200 Subject: [PATCH v2 04/15] media: i2c: ds90ub960: Use HZ_PER_MHZ 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: <20241108-ub9xx-fixes-v2-4-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2070; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=B28bP5gitkgMyKQMXM8TB9xGzVrPus9N9HaZDbrOPW8=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtOT/G6nkqb1ne0/12bzGsFLUemd5CtBhBug svemUVIxFSJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTgAKCRD6PaqMvJYe 9ShJD/9ooDicadY0kFLETGXH7NBnr2yLGSLOZrn2Fuxpc1NjREY6TLTLQVGAdemii2hqiPFdKZZ 2jtx4PnUQteSGvk1Errr9ZqYJbdIXIxasR7c29+Y5wtej906HtmlySeYPjHAnPE6+Brsbnlv4Ds wEUlvd6FsVgOJf7XUPvA2ia9KbwSzNNK+RMhSXcTsk9yy1su8A7qBQgrfGKLWtm1XAtQqTr1yb3 mskrMpLF3H2kRsDz8dcf+T7OkU/th/9VHSyh2S7Im7f6i8JUUXv4OGKoENw7IovWNupvoWpjuyQ 8t+5HV/erMszOpTU/A/qGH3exzwGzzHa62N2JUv8/TtxDMiFj5z0sIV3icWrO/bNOjNIZU0a3Wi 4GKNlOrhcqlVWd8+1VMI1wtqmNz0q/J4fe9ILvM+pTVWFUX5pyw4u+SB9oo3SszTwurw+IYMiKR SebT5yDfn8OLgPAoo+XYcT8jTObFJ/0jYrh4NOQyz2F51CADeObMA1qVf9nOR93Y9kQke0070Q9 2B9cEL05F3WVR4KcPFkKSJKyx6vL5uv33nkxzIoqRMUg2l7TC2JPY/GEEVAsyGCwpIvSGM2loMU Xz9S1uWjbAH7XBNUokziybtiehcnV5SNDJwt7ik4Aumpa4kxolInKSM2K8wAgI8nuFDIGcRz6ih M3CkSSPhM1ONMHQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Use HZ_PER_MHZ instead of 1000000U. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 24198b803eff..6266a4558eb8 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -43,6 +43,7 @@ #include #include #include +#include #include =20 #include @@ -1579,7 +1580,7 @@ static int ub960_rxport_wait_locks(struct ub960_data = *priv, =20 if (priv->hw_data->is_ub9702) { dev_dbg(dev, "\trx%u: locked, freq %llu Hz\n", - nport, (v * 1000000ULL) >> 8); + nport, ((u64)v * HZ_PER_MHZ) >> 8); } else { ret =3D ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); @@ -1593,7 +1594,7 @@ static int ub960_rxport_wait_locks(struct ub960_data = *priv, dev_dbg(dev, "\trx%u: locked, SP: %d, EQ: %u, freq %llu Hz\n", nport, strobe_pos, eq_level, - (v * 1000000ULL) >> 8); + ((u64)v * HZ_PER_MHZ) >> 8); } } =20 @@ -3020,7 +3021,7 @@ static int ub960_log_status(struct v4l2_subdev *sd) dev_info(dev, "\trx_port_sts2 %#02x\n", v); =20 ub960_rxport_read16(priv, nport, UB960_RR_RX_FREQ_HIGH, &v16); - dev_info(dev, "\tlink freq %llu Hz\n", (v16 * 1000000ULL) >> 8); + dev_info(dev, "\tlink freq %llu Hz\n", ((u64)v16 * HZ_PER_MHZ) >> 8); =20 ub960_rxport_read16(priv, nport, UB960_RR_RX_PAR_ERR_HI, &v16); dev_info(dev, "\tparity errors %u\n", v16); @@ -3856,7 +3857,7 @@ static int ub960_enable_core_hw(struct ub960_data *pr= iv) =20 dev_dbg(dev, "refclk valid %u freq %u MHz (clk fw freq %lu MHz)\n", !!(dev_sts & BIT(4)), refclk_freq, - clk_get_rate(priv->refclk) / 1000000); + clk_get_rate(priv->refclk) / HZ_PER_MHZ); =20 /* Disable all RX ports by default */ ret =3D ub960_write(priv, UB960_SR_RX_PORT_CTL, 0); --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 EFEFE1E3DC3; Fri, 8 Nov 2024 09:35:24 +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=1731058526; cv=none; b=CEBlQpERr4lciZLpJYJYex61rcc+lPaJFAA7ZQLRsbF3Z9ZGnPOL40kXlAq5ZSPz1PE6MweEjhVryITtVn8dbFglN243i3IYKa8+eh1bhUPhdMIjp8icnoPT+6w1DPZQtwWoQK4hArXwzc6nl8KRe46EslkAwMCiFHnc5fyr+4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058526; c=relaxed/simple; bh=yWjHH4n2+6qxjpnNorGxgj4zCDnWTjIhn3bpMUFpkHQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bckhmMTPDNOGb5L3cIxt9aAoE6QXVIjrZqPDi8d9zP6g2PByphXGI+DELVTXoDopHLZNU6HKgh+sP7pHHErMSKI23SCvRAPKLvnSVTACJy48aixuH+xyyK6jHoix43DtiU/0ubuottF4QtRxK3TLpoNf2IwJrPYrLjoe6UDf5T0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=s2M9jR5L; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="s2M9jR5L" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F332F143C; Fri, 8 Nov 2024 10:35:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058509; bh=yWjHH4n2+6qxjpnNorGxgj4zCDnWTjIhn3bpMUFpkHQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=s2M9jR5L8E9iiO2wpb6i2S97R6yQsEgooTQnuO1YSbhA2CWJu80a9sgwvWSupXJrt VzmY+7rA1yQr7TlenMNVVmGa6pBU/eKE/mbU7n9y0s8pFXEbfw3sSSHb50asVkVyYi 1AAh7QIFfBBlIkRJqiTUba5elP/7Geu1ouP+modI= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:49 +0200 Subject: [PATCH v2 05/15] media: i2c: ds90ub960: Fix logging SP & EQ status only for UB9702 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: <20241108-ub9xx-fixes-v2-5-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4099; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=yWjHH4n2+6qxjpnNorGxgj4zCDnWTjIhn3bpMUFpkHQ=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtP2uVKPKcI7op32ItnawQ82SlWZ9hjrK5fW Pe07/QN3/6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTwAKCRD6PaqMvJYe 9aHUD/9m5RHUuApsOznbralzAXzJJq/+7ZQB7N/OQCZfQDbaUyyKBGUQwvF+jt//6gAjCej7uhW adh21/5DD4zteCUTf3PjhKhk2hvigNVcL0FeW4wCb2JZXJWu2OE/K0wDCAxnKQvD7v9xR3pqlEc kiZj6Bz29mYLEC5hFn4S2udBhlbrMTSvzNzxX+MW1leeRcrjK9SbT7EasU5iUe8Isa6K7YTcNKm 3VPBucFvN1FKqiHwtmL+vzC10ANEjZWR0TLeTtiq8k6aNpov8T0hGLiqnVUn1aqtK7HHic8a3wB TDli3n1JLCug7MC44k4PZyWoTYJ7oa357WPhYqwrXVL/9yNyt4DtevTKQPQwDxYvsdY4L6GKbom TxHseYhzLeDqxej5NmuCvsSaLF5ni0WSNLi7S6BXG67kiLHrBQbtwwgRaTOsa2Q5eO38SRroXOo 6mlLGn42/W9xXoOrWH6p9GhiCIpTqFmDqlxNLjbwh6wMI6YimU/pea8ORIL9Jb/DeBhI5ZpLtF5 G20+bdqd+aYSWjzMAd1qk1VeR4jQL2xyLQy/uEbiOKGfPw9MywJN12zu65VqRh2wLJ8IGOdB+Xr tJ8+r4KQjrCPHcDFaRbPeO/rQbaOWxlr+rqKb+LOw126kSkDRfLkkXz8QE2eNZjMu02QoKViN9b JHjzk+MBLkK5J1w== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 UB9702 does not have SP and EQ registers, but the driver uses them in log_status(). Fix this by separating the SP and EQ related log_status() work into a separate function (for clarity) and calling that function only for UB960. Signed-off-by: Tomi Valkeinen Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") --- drivers/media/i2c/ds90ub960.c | 90 ++++++++++++++++++++++++---------------= ---- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 6266a4558eb8..2273e79430c0 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2951,6 +2951,54 @@ static const struct v4l2_subdev_pad_ops ub960_pad_op= s =3D { .set_fmt =3D ub960_set_fmt, }; =20 +static void ub960_log_status_ub960_sp_eq(struct ub960_data *priv, + unsigned int nport) +{ + struct device *dev =3D &priv->client->dev; + u8 eq_level; + s8 strobe_pos; + u8 v =3D 0; + + /* Strobe */ + + ub960_read(priv, UB960_XR_AEQ_CTL1, &v); + + dev_info(dev, "\t%s strobe\n", + (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) ? "Adaptive" : + "Manual"); + + if (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) { + ub960_read(priv, UB960_XR_SFILTER_CFG, &v); + + dev_info(dev, "\tStrobe range [%d, %d]\n", + ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, + ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); + } + + ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); + + dev_info(dev, "\tStrobe pos %d\n", strobe_pos); + + /* EQ */ + + ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); + + dev_info(dev, "\t%s EQ\n", + (v & UB960_RR_AEQ_BYPASS_ENABLE) ? "Manual" : + "Adaptive"); + + if (!(v & UB960_RR_AEQ_BYPASS_ENABLE)) { + ub960_rxport_read(priv, nport, UB960_RR_AEQ_MIN_MAX, &v); + + dev_info(dev, "\tEQ range [%u, %u]\n", + (v >> UB960_RR_AEQ_MIN_MAX_AEQ_FLOOR_SHIFT) & 0xf, + (v >> UB960_RR_AEQ_MIN_MAX_AEQ_MAX_SHIFT) & 0xf); + } + + if (ub960_rxport_get_eq_level(priv, nport, &eq_level) =3D=3D 0) + dev_info(dev, "\tEQ level %u\n", eq_level); +} + static int ub960_log_status(struct v4l2_subdev *sd) { struct ub960_data *priv =3D sd_to_ub960(sd); @@ -2998,8 +3046,6 @@ static int ub960_log_status(struct v4l2_subdev *sd) =20 for (nport =3D 0; nport < priv->hw_data->num_rxports; nport++) { struct ub960_rxport *rxport =3D priv->rxports[nport]; - u8 eq_level; - s8 strobe_pos; unsigned int i; =20 dev_info(dev, "RX %u\n", nport); @@ -3035,44 +3081,8 @@ static int ub960_log_status(struct v4l2_subdev *sd) ub960_rxport_read(priv, nport, UB960_RR_CSI_ERR_COUNTER, &v); dev_info(dev, "\tcsi_err_counter %u\n", v); =20 - /* Strobe */ - - ub960_read(priv, UB960_XR_AEQ_CTL1, &v); - - dev_info(dev, "\t%s strobe\n", - (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) ? "Adaptive" : - "Manual"); - - if (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) { - ub960_read(priv, UB960_XR_SFILTER_CFG, &v); - - dev_info(dev, "\tStrobe range [%d, %d]\n", - ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, - ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); - } - - ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); - - dev_info(dev, "\tStrobe pos %d\n", strobe_pos); - - /* EQ */ - - ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); - - dev_info(dev, "\t%s EQ\n", - (v & UB960_RR_AEQ_BYPASS_ENABLE) ? "Manual" : - "Adaptive"); - - if (!(v & UB960_RR_AEQ_BYPASS_ENABLE)) { - ub960_rxport_read(priv, nport, UB960_RR_AEQ_MIN_MAX, &v); - - dev_info(dev, "\tEQ range [%u, %u]\n", - (v >> UB960_RR_AEQ_MIN_MAX_AEQ_FLOOR_SHIFT) & 0xf, - (v >> UB960_RR_AEQ_MIN_MAX_AEQ_MAX_SHIFT) & 0xf); - } - - if (ub960_rxport_get_eq_level(priv, nport, &eq_level) =3D=3D 0) - dev_info(dev, "\tEQ level %u\n", eq_level); + if (!priv->hw_data->is_ub9702) + ub960_log_status_ub960_sp_eq(priv, nport); =20 /* GPIOs */ for (i =3D 0; i < UB960_NUM_BC_GPIOS; i++) { --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 476751E47C0; Fri, 8 Nov 2024 09:35:27 +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=1731058529; cv=none; b=n2+jSHChSHfp3rcEVJqzQXuJNaoPlkA1AVNHExJyO4WXW88T1TqN1g+AYKq8TiHSsNAUVclwJexBMgFvdUG62jpoNJzWQT0SNFEwIo8MP5OwxLb2q1LocLFbN51NS4QSUssGBPBjFavYZsgIfztKI3eFQGO/OmBVORPR+7RVUTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058529; c=relaxed/simple; bh=Bz4feA5yfvPpER9WbwM4rVvWi4EotwX/morzNM8UD0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kX/WX6ZWWvw4ATAwtv3lqvzsiF1/HKizMtbBnzzUKAVaLjWjxTvytSRaTWk/iyYtBAk8L8ZEOXYbYuvkmYpMOmAS4K0TrYjdz+IMFmQmQfp13UhC6pHMapva3RZLxhC+2FEwda8UV4lvlGLf2BKRt86JQLuPHF9fCogB+/Iw5e4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=tzACT7YE; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="tzACT7YE" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8B12C353; Fri, 8 Nov 2024 10:35:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058509; bh=Bz4feA5yfvPpER9WbwM4rVvWi4EotwX/morzNM8UD0Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tzACT7YEuKU3gkcD4ME26Z5iWGOaykKP8dMQgeSY1J+uTwa4m2LKmiOtiGDQVLATa IoD0uZAHM2nqCSCyQb28iQuzLXDq8RE4cGIRyghXi8JzL/psMqQh6S1VuvDAEUkVaY qLTKVaqt5A6Bl0pDkd3PtncfgRnlwAtGB0GOlg1o= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:50 +0200 Subject: [PATCH v2 06/15] media: i2c: ds90ub960: Fix UB9702 VC map 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: <20241108-ub9xx-fixes-v2-6-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1211; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=Bz4feA5yfvPpER9WbwM4rVvWi4EotwX/morzNM8UD0Y=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtPNlYJRSbGS6fLhZqc4f1bWshNwiOAhx9xr YKQ26VKpcOJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTwAKCRD6PaqMvJYe 9SgVD/9x5X53aADV8vbKOQ385d5hE6UB99XJSAs9SIWEeoL6rHdd3m2W29GiVAHjDDz+T1x3Jx+ GfVPSB4X/SODycOXP4Amf/c4rySqFg5v5kKFK5GLvOihhYeiQjUggLrrMrMGw4IincRGLQd2qiY IsVWrH05oYeDbFeOa/gJSjWEvYRNvSqgzDpMXLDdQVzBKzwEVfiSSm+ztvXeEHYpcLw+M76fbQ3 PhnkSYZopnK5Py92Om6/jGgmwVbNWz/KcY/d4HZKIR0AW/1cDGlg6jevbRIg3E8EXHUaKxU1/Pn bvfRxzpA2tl9RQakm1Hs/9TLtcigLdc5tL79tSROBXFP63cgYsO69vUgVBfZm+VWNXhSqdvTsFF A0YUmdflmbpZN8PKqIB7SJqhE+EK1uYW1IBEEWYrSGS/byipo0zWlzFiwZc3UgJZ0aSzZalEfTg z8rF3o83DhPZtqDV2js+Ib72SjlJbU6JL14v9HM8kJIow8JahtCQf1gaqZNX8j+uyvb21/L8fg3 MRd8DdrDtHRXwIJKw5aF/L+5Ew87QsXEkhPNa9bpPkLQCOC1qPemjyWRsCtguvFYX1M5ynXWPO7 CYFC7oLoOey8BxQmwfB2+kL3Y2idNubOhxxjtubQDOvTPFp8fHWD+V0Rxki9LT26DpO8bB1uDR/ ClpalB7HpPqbc+A== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 The driver uses a static CSI-2 virtual channel mapping where all virtual channels from an RX port are mapped to a virtual channel number matching the RX port number. The UB960 and UB9702 have different registers for the purpose, and the UB9702 version is not correct. Each of the VC_ID_MAP registers do not contain a single mapping, as the driver currently thinks, but two. This can cause received VCs other than 0 to be mapped in a wrong way. Fix this by writing both mappings to each register. Signed-off-by: Tomi Valkeinen Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") --- drivers/media/i2c/ds90ub960.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 2273e79430c0..98d815526341 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2534,7 +2534,7 @@ static int ub960_configure_ports_for_streaming(struct= ub960_data *priv, for (i =3D 0; i < 8; i++) ub960_rxport_write(priv, nport, UB960_RR_VC_ID_MAP(i), - nport); + (nport << 4) | nport); } =20 break; --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 476D01E47C1; Fri, 8 Nov 2024 09:35:27 +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=1731058529; cv=none; b=JlV0zGir/SD7tKEpOknm4K6zaBhVv60c/V9n/1OA26zcEQfIkz4TazdFZTqmnjjMjAm0Q0oi0XLPZXZGeBKOdS2SHXl4/nNQlD3YskGnVzGppS3i48tgmKYjoZtmKX1WqnL3hXGhjd72nHwIndMl8p9vziGoQ/jkHBJZ5vaA1sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058529; c=relaxed/simple; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YxUgGfHlqOkjfUJM/W5UzE62HkN6hjeoAxrtwcd36BWvZfw8Q0S1COdFyugbGRX0rQHTwzWAyxhuDgAikqNkcTQmI2j5g5DKs7JqN8d/ZHfm2pVtjfS8RWFhix3jXLmdyCKRI7cPBxdXdoIbMXdld19UcywL4gYrMMXMDC3Auvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=kz1YJWh8; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="kz1YJWh8" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 250E9193E; Fri, 8 Nov 2024 10:35:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058510; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kz1YJWh8eWDGBrZWoME8sCvDjYZslZSKdCbtxxtuXyf645W7dznBvPZEta2dhMAGh ZjHKuplzmJIogVl0Zwy6nRlnDsHQdGyiQ5y/8JzjI0Rs76UIu7kBMMWLrcYpT3vOjV x6d9cOov0LJUgPQ5Z3Hz2s2mJmaDSaizK74pcrGA= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:51 +0200 Subject: [PATCH v2 07/15] media: i2c: ds90ub960: Add support for I2C_RX_ID 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: <20241108-ub9xx-fixes-v2-7-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2244; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtPeSItwkurJvkmwYyL6atkrUnrD3ogsKlbq 2ehmSYL8CyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bTwAKCRD6PaqMvJYe 9VYND/9HFGUGOwsdNlI37fov5B2PNwjn/xFEtCRO/WM11AS2+pM7iTMBFPOKFG5VzE6SvrmFafd 2NoRzPlLjORo7cGOB7Zj9aDYGfS3zuaGTRYxaYdzNtPQSpaStE2Y/lUeHQBCEI2Z7pi3cjtmXPH KDrpiroPStIyaT9Ybtxgft46jlP0BfPLv0cEH1/jpIoNB6X2pK82q+xwNh93e62pNFY87kTe0dp 0lUqEhnlBFd1SAK9Msf12FxfhypBQYop6eTo9yhwJO50yaxej8scNiiOo7nFlYxDOmX0UNrpsFP az+kIhdnOspTmy3FzBcWqsb6nmHOTHEpwq8VZqwYVM9LJjFut0gRCZE7ufWx5Zk3R9mjEzf37AE xXLeVs971oKjWJvkhlu/WENs+aUbh49Ty/TnaEiPmU3M0lExFw4MzlSmi4+pdQZT22rnxUjRfje gPUlPlTnoIseng+O/uHJLMuQ1ynd7AoF+wHYXJklXW2C1uRoDNGIfgp1NbrA3Y6waMHI9BerFO6 SnxeqmTxWsSzQcrluiwZ4YFTZ8sM+KJh092UQKT2nzRahUnOaekNKBiWnHt3/WKnNYrjWIsiUN/ ZT0pAzY6KtJcRoaCFYbzx6S4eZn5PngTzwrqtUYNnzApu2AzLS6b/l0jFHryY4N+UMsIxluJzO5 YIZ1C55Gu+qvJYA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Normally the driver accesses both the RX and the TX port registers via a paging mechanism: one register is used to select the page (i.e. the port), which dictates the port used when accessing the port specific registers. The downside to this is that while debugging it's almost impossible to access the port specific registers from the userspace, as the driver can change the page at any moment. The hardware supports another access mechanism: using the I2C_RX_ID registers (one for each RX port), i2c addresses can be chosen which, when accessed, will always use the specific port's registers, skipping the paging mechanism. The support is only for the RX port, but it has proven very handy while debugging and testing. So let's add the code for this, but hide it behind a disabled define. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 98d815526341..03938def6ae9 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -55,6 +55,15 @@ =20 #define MHZ(v) ((u32)((v) * 1000000U)) =20 +/* + * If this is defined, the i2c addresses from UB960_DEBUG_I2C_RX_ID to + * UB960_DEBUG_I2C_RX_ID + 3 can be used to access the paged RX port regis= ters + * directly. + * + * Only for debug purposes. + */ +/* #define UB960_DEBUG_I2C_RX_ID 0x40 */ + #define UB960_POLL_TIME_MS 500 =20 #define UB960_MAX_RX_NPORTS 4 @@ -351,7 +360,7 @@ #define UB960_SR_FPD3_RX_ID(n) (0xf0 + (n)) #define UB960_SR_FPD3_RX_ID_LEN 6 =20 -#define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) /* < UB960_FPD_RX_NPORTS */ +#define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) =20 #define UB9702_SR_REFCLK_FREQ 0x3d =20 @@ -4001,6 +4010,12 @@ static int ub960_probe(struct i2c_client *client) schedule_delayed_work(&priv->poll_work, msecs_to_jiffies(UB960_POLL_TIME_MS)); =20 +#ifdef UB960_DEBUG_I2C_RX_ID + for (unsigned int i =3D 0; i < 4; i++) + ub960_write(priv, UB960_SR_I2C_RX_ID(i), + (UB960_DEBUG_I2C_RX_ID + i) << 1); +#endif + return 0; =20 err_free_sers: --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 2C2E31E5703; Fri, 8 Nov 2024 09:35:31 +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=1731058532; cv=none; b=pWSWfoDeHmws9VKdFWqmhCdXAuH6uVmeGdfHnJUUwc2sEEm9TgeQk8dC0+WOAAyKulqxtDzxiSNopzH087AMf4JSk/zmPXhPhVyC38gCtiYIiRK0RZbL6SO10d5EqUY2bunrMObhg+nbNKfthCbpLm6mpknGKBP9fBo0iYwkARY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058532; c=relaxed/simple; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WygK8dYGml2Hjfb2UAfgD0e2JqNPnGmwdocC0KE+yz8vc6Gf/1rliTw1lVfV02FOf0nY00icXbTBAhcE9JUipuV6rpZeL+U2kHacsww2D8eecJu1/ETwAnXgegHNjI5egHx5T7+N6DiqsQIcZgcylr4T1+IdRQxPTCHgw+oOX48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=hyNw1H7D; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="hyNw1H7D" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B31EF1986; Fri, 8 Nov 2024 10:35:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058511; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hyNw1H7D/mgGtip6oku6JV4aLdgSf4biEb5l72M5UV+0ckjETk1ktPv43efRs8bV1 dQjmYVDiwVEKKqc73JWpDr6DUJPtLJ7L2m0WSgxbpR5FOEc4Vg9zkRobVQIfZR6Y4X TeU0uQh03c2EaxDGAb/UQxQSvxxTeAi/Td0NCIPQ= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:52 +0200 Subject: [PATCH v2 08/15] media: i2c: ds90ub960: Add RGB24, RAW8 and RAW10 formats 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: <20241108-ub9xx-fixes-v2-8-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2006; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtQRPbnRY0mI9A4AmR3CN4kTK+XmstTBpx+V r9jL1bDP9mJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUAAKCRD6PaqMvJYe 9WcvD/wMVZYZnp6DaSMG66WfWWbhWuO/XX80s8IKNdyU1QZP/ldTO4x+dK1g+y7lMmtnuo1sal5 yMYRAy9AlL30yr43M29OAKmcRGwsgQHpbdp1Mbje8r+kYs9NbweKDynwLzRR7pUEpeCxQrDilqD Y83krus0eyGCCQ7ukeP/ZzE/qCwZRKiItg+ql0/cBbUzV3yprk8IPS/tufDp7+JA/+ED/L56Ehc fTxwsur52Khd7SMQAzFFBQrL+OoJpMYI5WwXxoefFMYle7ZVbqa16Qo8xpzFyc75S+66cFDd0Gc iNR5QhMQLFbpm+JyyIumkH/65JRR37i5183ulLNLqSjv1OLvvyTg8KTpMUcyCq07ytuqVxxS4iv 5oiWOG5b9WU6jw9vc5ZLUS55x7zX3xOVdWz9i6OR0MflLBef/bofcMwDOe0Fbmz8s0Lk1Wt0op+ lEIQIL6cAjAu513jktbq2HDbBhXbUyELK8230shYPfG39hljVF684mWhbVWIdocDVO7DEQYIiiF sunDb522Pq2lk0OMYACyjqW/TMQoDnm9wYh271N3GwjcnGaIi834p/z+oYURbleEPHaSzbHheRO Sa38neKXXMuIDdvtZllTXCxpSfyyWIEnEdclU1RHDybq9aHLlb6YMfR1cLRDD9vhRjL+kQx1FM1 BEeS+m2GZlV+pww== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add RGB24 and RAW8 and RAW10 bayer formats. RGB24 is mostly for TPG purposes, but RAW8 and RAW10 are widely used by sensors. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 03938def6ae9..c2035cabf579 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -581,11 +581,23 @@ struct ub960_format_info { }; =20 static const struct ub960_format_info ub960_formats[] =3D { + { .code =3D MEDIA_BUS_FMT_RGB888_1X24, .bpp =3D 24, .datatype =3D MIPI_CS= I2_DT_RGB888, }, + { .code =3D MEDIA_BUS_FMT_YUYV8_1X16, .bpp =3D 16, .datatype =3D MIPI_CSI= 2_DT_YUV422_8B, }, { .code =3D MEDIA_BUS_FMT_UYVY8_1X16, .bpp =3D 16, .datatype =3D MIPI_CSI= 2_DT_YUV422_8B, }, { .code =3D MEDIA_BUS_FMT_VYUY8_1X16, .bpp =3D 16, .datatype =3D MIPI_CSI= 2_DT_YUV422_8B, }, { .code =3D MEDIA_BUS_FMT_YVYU8_1X16, .bpp =3D 16, .datatype =3D MIPI_CSI= 2_DT_YUV422_8B, }, =20 + { .code =3D MEDIA_BUS_FMT_SBGGR8_1X8, .bpp =3D 8, .datatype =3D MIPI_CSI2= _DT_RAW8, }, + { .code =3D MEDIA_BUS_FMT_SGBRG8_1X8, .bpp =3D 8, .datatype =3D MIPI_CSI2= _DT_RAW8, }, + { .code =3D MEDIA_BUS_FMT_SGRBG8_1X8, .bpp =3D 8, .datatype =3D MIPI_CSI2= _DT_RAW8, }, + { .code =3D MEDIA_BUS_FMT_SRGGB8_1X8, .bpp =3D 8, .datatype =3D MIPI_CSI2= _DT_RAW8, }, + + { .code =3D MEDIA_BUS_FMT_SBGGR10_1X10, .bpp =3D 10, .datatype =3D MIPI_C= SI2_DT_RAW10, }, + { .code =3D MEDIA_BUS_FMT_SGBRG10_1X10, .bpp =3D 10, .datatype =3D MIPI_C= SI2_DT_RAW10, }, + { .code =3D MEDIA_BUS_FMT_SGRBG10_1X10, .bpp =3D 10, .datatype =3D MIPI_C= SI2_DT_RAW10, }, + { .code =3D MEDIA_BUS_FMT_SRGGB10_1X10, .bpp =3D 10, .datatype =3D MIPI_C= SI2_DT_RAW10, }, + { .code =3D MEDIA_BUS_FMT_SBGGR12_1X12, .bpp =3D 12, .datatype =3D MIPI_C= SI2_DT_RAW12, }, { .code =3D MEDIA_BUS_FMT_SGBRG12_1X12, .bpp =3D 12, .datatype =3D MIPI_C= SI2_DT_RAW12, }, { .code =3D MEDIA_BUS_FMT_SGRBG12_1X12, .bpp =3D 12, .datatype =3D MIPI_C= SI2_DT_RAW12, }, --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 79AAD1E570B; Fri, 8 Nov 2024 09:35:31 +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=1731058533; cv=none; b=FzqWZZ6B8kjxUnHA67Fq7F1LQpymqR4V/YaTCMu0+SMes96O8ilDXadSx+ZdL3lEUzPn6TjwglvrVNHNK/+ILwWuA0z2VCF9Kn0yoXTJBiQMaMO1WzV2nYshjPl3aNAxK7Q9uHmP12k1SedJmkWeov+cmr9BK+QaCePPdgGL6p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058533; c=relaxed/simple; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Viw6vE0eS8kM4rHWqC95JpY+gaCNzrrc3gLRtYzVDnZriqnDY2k/NKp8BB4fBptklximTk0viOilx0bLtkNgbjv9SVHcnBa/zHVqcq+kLbN8RUhPYWnlDdPCynL+IwnujIavDMN8E7dLzXZPdzY2lAhH213z+QP0IM2AECeNlIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=LpI945QP; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="LpI945QP" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4D59A19E0; Fri, 8 Nov 2024 10:35:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058511; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LpI945QPDPiWjI72YsqjZUtM44gaJKinK4dON+zkFev77+HU6ahFpPujikUPTwJH5 pdiJUxjtb1P4wGfkY7CMy2k0p1PLSMh7cDTTaFYS3ULs17nUq6wWGI360v5xtMtZtK CsVEVlEq3zBrcPeXrrMaPf6V+Cj6p+HHy9UxaZHw= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:53 +0200 Subject: [PATCH v2 09/15] media: i2c: ds90ub953: Clear CRC errors in ub953_log_status() 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: <20241108-ub9xx-fixes-v2-9-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1264; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtQUN1BzEIT6awDGB5rcL2hURqqYMXMu6SZa t1Qdij5SSmJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUAAKCRD6PaqMvJYe 9XkwD/98zECV9cPq2O5socZ4tr1Dj7vNym5P5yueriPbKecwn4pXUDY9S9VNL/nUBUtYFZIQ7C9 gndwu2QDXL3iSVQRySS9Mk0lOFLhh9TocXXzlpGJAELY3DoTzW7DgzOVrtMrgHy4Qk4FD52iYPu bnfuArvKE6qo0U/AqTggh/BbctdcwDBSxzZyJNNs5KUe0Yp6fwHkErGC+OY/zABE6Nsiqag2V4J IsjeJ9dAc4MI2Yv7a3+xstJ83kCaG6jjrADT7N4SsjcxH1M9dgQ0uS4+xo2B9+CZA/EUxCFYlEO OhU1F7NNuHZbm0WbWpRkbHT8X4QeLBDVrpS+OEHzG7JkIdMc6ihh6H9Q6WhR50sY22BTY838rbY PAgMgezvOZfJfuIPdOSKKnW4dn6sHBmGQUBLzQbXkWytaNTcy2zwUJZJj/PC3b85ORJJUM1ZxL0 mrmL21I+ah8uzJd0mCi2G4YhGwm8wB2+R+v8xQSVmnM1dZVKHizFoLoPfFlPUupZTTMGSKSVZNG dz+y6Tue/mshC599TnDUDH1DDANwzV8Mze58jXzZzKrhOxI5CrqsM4XBhcphQifQ4we89uuslcq EvU859Ac6YaKUDZwbnBK8PJQVLe4Q1HgSKzGfSBPSeoyG8+cJWx1Jsuoa5B0jjZnD58B2iuiHrt uyO5sjM0EmQTuXQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Clear the CRC error counter after showing it in ub953_log_status() to make its behavior match the other counter values. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub953.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index 10daecf6f457..b6451811f906 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -66,6 +66,9 @@ #define UB953_REG_GPIO_INPUT_CTRL_OUT_EN(n) BIT(4 + (n)) #define UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(n) BIT(0 + (n)) =20 +#define UB953_REG_BC_CTRL 0x49 +#define UB953_REG_BC_CTRL_CRC_ERR_CLR BIT(3) + #define UB953_REG_REV_MASK_ID 0x50 #define UB953_REG_GENERAL_STATUS 0x52 =20 @@ -619,6 +622,12 @@ static int ub953_log_status(struct v4l2_subdev *sd) ub953_read(priv, UB953_REG_CRC_ERR_CNT2, &v2); dev_info(dev, "CRC error count %u\n", v1 | (v2 << 8)); =20 + /* Clear CRC error counter */ + if (v1 || v2) + regmap_update_bits(priv->regmap, UB953_REG_BC_CTRL, + UB953_REG_BC_CTRL_CRC_ERR_CLR, + UB953_REG_BC_CTRL_CRC_ERR_CLR); + ub953_read(priv, UB953_REG_CSI_ERR_CNT, &v); dev_info(dev, "CSI error count %u\n", v); =20 --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 A270E1E7C18; Fri, 8 Nov 2024 09:35:34 +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=1731058536; cv=none; b=IlQ041JTCAE8VQGwG8vNPl0QVdLDED/Fwpek7JlE5WaaPuoSxdIEWNK6OW5JoGDa6Twlop+2dWLgKAdrUZlnJV5W+75+uNf34b1Dk7SxAP1uOU30ej/aqQaBr6dMs0baj6YZVHZAim3J2h/dIYWp6SHb6Hke3nOput9IjbyCPKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058536; c=relaxed/simple; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=un3Dys9LS156l4+P2bzbyRsDPhIDRxrKSqT7nX8YzYgRtspCctQvDTDyuLqpTbUfI9dib6h+dWVnby1pyJSITjYgbBf1MD4WPTOpjDJ3Q1darftGH/J3vXd1kIxmC1UUEnThC4Jg2z1iZTXxOdAoKEkueZxE0O4NSRbPO09MBfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=I38L+ZOK; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="I38L+ZOK" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D9B7FA30; Fri, 8 Nov 2024 10:35:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058512; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I38L+ZOK2KWqUO8k5gcaOS4JNQD01U4wR15XJAZVHhFA0tuXlo86POxYb5Ftgpmgb x7sb7Nj8/K6LuCg8U1Lc8TG2aOa6bcsEvg5CFUylh+v3Zc06FbQ1JAwPYf3vf5mZt1 ZJr+xJdPcz5KgvuIQmCDwouFk64y/3oKRxM7suKA= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:54 +0200 Subject: [PATCH v2 10/15] media: i2c: ds90ub960: Drop unused indirect block define 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: <20241108-ub9xx-fixes-v2-10-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=855; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtQyaTOeOWPj4ux8RGsnP6uZ7JYMRdIEg6Bs vtrbvyMh3KJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUAAKCRD6PaqMvJYe 9VpgD/9ulqk3a9gB7HTG6ZKXW9mqZ8Ii3uwHGXkHobNG8wW97ytIUXIgREN9RgiB8jLSKC9mieO H8d918X2uLDzMpmXdOjyFe5k55BOb2l9snKJSeGAe8j+La321KMp/2D94K8jod3masj3NgJfG9G osL1qEaOKQ7NMzyR9QdaBktVPuCjD85TTxgE5AvlJSd3kMVMO1lHBbdgQvttzTCLtcYddas55dC 1xUd/4ev96ORrc1TN8C6XG1JF7qBGHTFJh5OpvU+ug2ERVIfGHFUYkMjkqV3WfZopFu6J0KVHkT ftcDe0pgOtmsqwnRuM9o0Ewhm3LUuaeO8TWtor2LzrGwTBwzkOBllzBvdAKbr3DTOVrpNOOj4AX tNFO/BG5s8JoHoaIwjWX7Hc2+9/J96va0fuONQdLZOItSDMvP4EJtpY09GTyDeKLeoby7V8dncw 5gdiGJXgCTs5TzDvDqnTubYkCCEVBUzPHKH5FY7pNNJbOzK22pJL6j2YH+8n9M4GJPeVCYmYQam 0F8JdL9XbaOwzao3yy+CSbZiNLaWJkFBfR89wtOnZ5aQJWIT/+FfHx+iMZIrXF22olnRv8ut5db Bpbm7iBqxg6pJa52u9e0FrH1ef4HJVAS7ZQDTARsaRB7XI0VgIKQkIXqnSWmqKEId7mMh7c4MHL A+SJHj82UlzZZ5A== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Drop the unused UB960_IND_TARGET_CSI_CSIPLL_REG_1 define. It does not even match to any block in the more recent documents, so it's possible it is not only unused but also wrong. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index c2035cabf579..a4a624816d8b 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -367,7 +367,6 @@ /* Indirect register blocks */ #define UB960_IND_TARGET_PAT_GEN 0x00 #define UB960_IND_TARGET_RX_ANA(n) (0x01 + (n)) -#define UB960_IND_TARGET_CSI_CSIPLL_REG_1 0x92 /* UB9702 */ #define UB960_IND_TARGET_CSI_ANA 0x07 =20 /* UB960_IR_PGEN_*: Indirect Registers for Test Pattern Generator */ --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 9FDD91E7C17; Fri, 8 Nov 2024 09:35:34 +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=1731058536; cv=none; b=a57KZlDlUoqjKCfYVfPfyL3Gv9lFI8X38WF3h9O93rT4g//uK6ibLZuiafu7EBwuljhOS684yVe5DDXhs4k2AoIhpBkID8MG7KotijDzsSGMmNlAHhLkdMInmivk6C2l+bHzvfrF47lqbDmYJeh06kUL+RPQF4lCDXC7WPrf9PU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058536; c=relaxed/simple; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S7zeLj/tBMc/kPaE0ywE/zIID7PrqsE4uMTrCIdLH4YHXcPngJKFJ1GbeC70KYG9VQCNRx/l//lzKfLPJHPKRYtckISxQy9okFKHWOsaoSebIJBA/ZuykEX9xoWDj6ePPIBk08EDD6VuZlWodr58QW4Oe3Lj60mg6zdCT5M9qS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=OjqPLWfe; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="OjqPLWfe" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 713643D5; Fri, 8 Nov 2024 10:35:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058512; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OjqPLWfeg+2n97q8MZsaLhO6QedFzNNGoKP+QTaJHSjsSv4xtFVqqENtnA5dKO4R1 MyHYxSxyIpWbPW24XyAHw3IiX1tdu/h+gGp3nqhc/2r8HbfP2Od4Sr/ea34Cq8ZT1u wYjil/l78/mwXEwxBVPuZO9F1ZPU723pT1vDNjl8= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:55 +0200 Subject: [PATCH v2 11/15] media: i2c: ds90ub960: Reduce sleep in ub960_rxport_wait_locks() 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: <20241108-ub9xx-fixes-v2-11-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1037; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtR1CKuB3jU2gmQdf7/cZ/y4JYsXrxP9UVcL HbXhcR28syJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUQAKCRD6PaqMvJYe 9QCmD/9Vm7ld5rEngi4kdIQoCCxIgGI6MmYrnFZP2oEomZP7DXK6u6ytMfHKhH/DQFN+KHjJF76 kX1q57B7j6Pd4DlE+/ZNNLwy0z1KP+TI7TH3q6N69EE8QF73Vs8btcY+xIcA2UvZUE5V4nVoS+x /bj+liCjOV2HGMsMkoPvyDJzoAZrtCeG4HHtl8g6SlB1r4Rr1fQbd6SZeuzWbYV9ogJpTGrUVSv 0ILqYPeC7dNOp+/PqoVkUsWwN2O5JyK0ofWhyGwE8rARanxfm+s9QEKxrxPlTspGo+d+GYfDdGv 4lYv1ssYUV314g7Hu8EcwaJ/1dDwNPTZbvRT6pr3umYdRyVfRvCdsTvat3WmOsJ6/veYcpBfy0G Ms9wa8Bbzuc38AUVviV9gVlHfo56BvAi1dRe0xhtrO5MpGDcp0Hmz8efBFmn0muIBOgb+uLS+9k 6y22JbMSRJ4XIXzLvyp5wvc73EsQtcucxQSYeUrN8RHzR6SYtnS6Zpaj8hm9C9Q3NYDdeVgU1k5 OFLsO00DhFybMJJBxSAg3dgyMh6OEry9IdsSmG9zOUG/mIu/5EM5fD2YAaZA7HkHV1tephMhFWs +LdxeQZZHeSDhb4jsM50CJjWnmeud679xRuMK82yzsp1Rqy5xr6fgSG3JMZvxpjTQvJZ3+3xhQb psG7VpuWJioMD3A== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 We currently sleep for 50 ms at the end of each iteration in ub960_rxport_wait_locks(). This feels a bit excessive, especially as we always do at least two loops, so there's always at least one sleep, even if we already have a stable lock. Change the sleep to 10 ms. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index a4a624816d8b..64b5297c5f22 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -1576,7 +1576,12 @@ static int ub960_rxport_wait_locks(struct ub960_data= *priv, if (missing =3D=3D 0) break; =20 - msleep(50); + /* + * The sleep time of 10 ms was found by testing to give a lock + * with a few iterations. It can be decreased if on some setups + * the lock can be achieved much faster. + */ + fsleep(10 * USEC_PER_MSEC); } =20 if (lock_mask) --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 B6A4D1E9067; Fri, 8 Nov 2024 09:35: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=1731058539; cv=none; b=WtDbGcYcABVd+RSvUr1aJ1SijPYMLkSRfZb7ivg/5JjZMY5WZWwZaHpSsRgI3DxDHlcKl2+VGG/n+ZeA23NCkoWku+Tmd50DYB8uh2ddRsdinz9Tt/38ixZJnTbJCVpwMNCG90D4MCbE6nQbSc8Q51AoO88/TkG3/1KmrccAkbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058539; c=relaxed/simple; bh=cvgAmZGnvd+MaIkpjSC6cQoWn3Y/Etg4xrzQpFwC5+E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fATwRxnYZw2J0Snx767skbeGPz9jc9JpVJqru0IRHFUs7ARD63MYHYrWrn2JV2/RH9WmSdRSnCltYluj6vthpTuiBsoPYFkwVWw82py7WBj6kjlv5MhA1v9PrGrJMlZPNDLxD4LdHGo3JkKqGXKmw19tct1S2UYIBynU+cNwFfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=BFU+eCir; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="BFU+eCir" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F57D19F8; Fri, 8 Nov 2024 10:35:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058513; bh=cvgAmZGnvd+MaIkpjSC6cQoWn3Y/Etg4xrzQpFwC5+E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BFU+eCirGNtjW4hEwuEH0U16PUlojgutS+8rUZbsomG1XDUHDkIUBGMLXIwEAoyiA MMow8FZeBpuZvqxAIhtESwDJ1xYrrm/5tNVQnABBKZ2RZ6BuAzlA8SEcV9TAp4zYtF Lgv9GdXYc9agIQEBDLF4gKOPkZy66l8GoPS8Hvpk= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:56 +0200 Subject: [PATCH v2 12/15] media: i2c: ds90ub960: Handle errors in ub960_log_status_ub960_sp_eq() 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: <20241108-ub9xx-fixes-v2-12-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2084; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=cvgAmZGnvd+MaIkpjSC6cQoWn3Y/Etg4xrzQpFwC5+E=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtRErQZjLah8pu+FWMv1Jjgk4eFr78wsmb1H Nlv93HlKyCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUQAKCRD6PaqMvJYe 9btyEACaH8SvLnYHyGGwu2TZ9KTo/YHMB0adC3yQmsuIwTUi5p3tPpdGM1Bpugyb3hJGr1LQ4ZK 2H0aZpsTxyZE9x4rDTs2p4/KiCfWB4K1w4JVTRZ2LEx+MTs/Hq1FtoJNZpxjSOOeR4gDKa+o6BI y9zL296l3k4x2BS1f/dGFD+Dp8GxfdK554/EBFv0jWKfAv1juJo0vzwS2UKr1+s+3A1D2TKeEoU LCggmnmoIbV3m56DlP9bgyc0oTFzE1FD2RHOBUZJ2H9tlLn2iTh6s2qGnvUMqcgDATc1eMMjdiX O4K6VAn8rY+O6LNoa/lTwwrWMKISiDRhFQwbdNnoGycihUbze1dq6W2fQS9lwfIb8B8QjiLW0dt bmR58zD+NExgRiJIu8wNfKruVkHNmUh9x0c49BtRBWwyLdTUF1kEXOAWmPnRBn0m7pCpWeJcscL mNjkxoJJg+b7GTshUXKqDbN01szFQxmkZoymyZHecTTiizxPNysQwZh1uefTSTr2wTUYZXZz/Jh PAWejtYqH02Ps9nLv73g0DLJu31NyMT+xRE/b3nAtwyNg2cYP9zcEp5pfsuF2OLTPB1/FmoEARF riXTZh55ZMKB1zw+Cbb57JQAPEwzJn69i+vS5BN8qitgcMX4mCuGFWvaQPjYuaQ9/pHZZyi3wB/ ozkxquzEKFTVwRQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add error handling for i2c read/write calls to ub960_log_status_ub960_sp_eq(). Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 64b5297c5f22..1dc10b2ba1f1 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2982,38 +2982,49 @@ static void ub960_log_status_ub960_sp_eq(struct ub9= 60_data *priv, struct device *dev =3D &priv->client->dev; u8 eq_level; s8 strobe_pos; - u8 v =3D 0; + int ret; + u8 v; =20 /* Strobe */ =20 - ub960_read(priv, UB960_XR_AEQ_CTL1, &v); + ret =3D ub960_read(priv, UB960_XR_AEQ_CTL1, &v); + if (ret) + return; =20 dev_info(dev, "\t%s strobe\n", (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) ? "Adaptive" : "Manual"); =20 if (v & UB960_XR_AEQ_CTL1_AEQ_SFILTER_EN) { - ub960_read(priv, UB960_XR_SFILTER_CFG, &v); + ret =3D ub960_read(priv, UB960_XR_SFILTER_CFG, &v); + if (ret) + return; =20 dev_info(dev, "\tStrobe range [%d, %d]\n", ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); } =20 - ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); + ret =3D ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); + if (ret) + return; =20 dev_info(dev, "\tStrobe pos %d\n", strobe_pos); =20 /* EQ */ =20 - ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); + ret =3D ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); + if (ret) + return; =20 dev_info(dev, "\t%s EQ\n", (v & UB960_RR_AEQ_BYPASS_ENABLE) ? "Manual" : "Adaptive"); =20 if (!(v & UB960_RR_AEQ_BYPASS_ENABLE)) { - ub960_rxport_read(priv, nport, UB960_RR_AEQ_MIN_MAX, &v); + ret =3D ub960_rxport_read(priv, nport, UB960_RR_AEQ_MIN_MAX, &v); + if (ret) + return; =20 dev_info(dev, "\tEQ range [%u, %u]\n", (v >> UB960_RR_AEQ_MIN_MAX_AEQ_FLOOR_SHIFT) & 0xf, --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 98DA11E9064; Fri, 8 Nov 2024 09:35: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=1731058539; cv=none; b=n39603ooQ43NXQjczYCeix7ZYHaY6w+HTCVvptccJRisIZO8K+KyD1hwWOA4DKMhNN0CfB8OsUZMu4cliRjHc4iNzWLxW0FDFQXWkDEfqEM7H7+eOp7EFBwA9moyHtn7TY7I0nkYXil8dNX6oPkgGLtntKehoZyBMcDkWPoj190= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058539; c=relaxed/simple; bh=+aGStSJXTWqelGHlqRUtWZzk5xBxaNgQWiqlHT0OzxU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PMFgLUk23QOMVfQZBaLiH0kILi8ZGahPH6R5rs1e0PRvtQd9QEXuk+tq1/d31tQatfvaZGlTQd1+0DZmgRbtWnOrq3XQ5Sb6KOOwLTnmCF1R+P6N0JmIApW4vzcdWvPIFpgRPJsjcaWmzOeM3XANG1U//iDJOPa8hdozPyDcEwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=P77SAF9T; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="P77SAF9T" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D2BEBC0; Fri, 8 Nov 2024 10:35:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058514; bh=+aGStSJXTWqelGHlqRUtWZzk5xBxaNgQWiqlHT0OzxU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P77SAF9Tkl4xw2BfrAR9Z7qU+UjiCfPbcnSeJYwB+yj/azD9ccoACR+ARAQ6CQZxE 2PNIKWcDpqUjTT4NIYQeo/DaOzTYPQD35iKQGU1J2XEh4P/60LinvW9RdVca5aCNSH vyCxXJT997Sqh+3EVD/XmVLMasGrHYyeLTjufac0= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:57 +0200 Subject: [PATCH v2 13/15] media: i2c: ds90ub913: Add error handling to ub913_hw_init() 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: <20241108-ub9xx-fixes-v2-13-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1534; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=+aGStSJXTWqelGHlqRUtWZzk5xBxaNgQWiqlHT0OzxU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtSfROzJv7xaijYKElEQV72lDFBQ4JjwB9Ww 0S3RSJfNOKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUgAKCRD6PaqMvJYe 9UjWD/9aOH+XOJaJ26NTlH3iIDlVd0Y/giIHGSOlKUPBnyLen9xM3E8GGf+5jwbhyxrRraA9R9V cNqMDeoEo+1AFYq3b48TRwHb8V4MrTvH5ujb8QeHnDIdoGYOOCMvHrPK2PYKGpETRcHWCBhReBN xT8SRVEQSG/olzBejWDNEWDrqngEGUBvnpo3QxB1DpBUnLbJbuD42qS8AxI2/shR7YKO3vi9d4E 6HtqRIOWYSkoqYBUMhzzA6SwemBMu5s0WtUhPTpha4Y23kRqudh23crRYp8B9/e+7EMbFX/3kFA CbfEB0aD2z65AKejlB9Lhan7srVnkj7shKHb/qk9t+S1bxSpkpacXoWvQZrXIXJl5Pc5bfrB905 M5o8OgkxgXZgUMZmNXK6/k+BUdW/E/kyYOa+sv+2EkRfh6qqTdWG1slIif08mFcCQ4inaqwJWDH oJvhUtdTYFLx8rQGYS4HbR7OHgFOjtuHmTfII+x2IO37VALGGWaFw61aiiszgQC98O71n/W2G1q synCUW5KU5BsKpAOPXW1Jku3aN3aC8szu/cM+xrNtp6jGJ5l3XaaKL+9iFi6F9gJpMeUbSq+ZMD jsEtkQ7Bspmcd6SKXd3WQLjIQTnBPPa0EO1YGNswN0r7o14ATvaWEZwTAYEYb/iHghlZeSpaQ/k q7UWMDbAfSumPuA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add error handling to ub913_hw_init() using a new helper function, ub913_update_bits(). Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub913.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index 150d6641516f..5db11b6e7e2b 100644 --- a/drivers/media/i2c/ds90ub913.c +++ b/drivers/media/i2c/ds90ub913.c @@ -146,6 +146,19 @@ static int ub913_write(const struct ub913_data *priv, = u8 reg, u8 val) return ret; } =20 +static int ub913_update_bits(const struct ub913_data *priv, u8 reg, u8 mas= k, + u8 val) +{ + int ret; + + ret =3D regmap_update_bits(priv->regmap, reg, mask, val); + if (ret < 0) + dev_err(&priv->client->dev, + "Cannot update register 0x%02x %d!\n", reg, ret); + + return ret; +} + /* * GPIO chip */ @@ -733,10 +746,13 @@ static int ub913_hw_init(struct ub913_data *priv) if (ret) return dev_err_probe(dev, ret, "i2c master init failed\n"); =20 - ub913_read(priv, UB913_REG_GENERAL_CFG, &v); - v &=3D ~UB913_REG_GENERAL_CFG_PCLK_RISING; - v |=3D priv->pclk_polarity_rising ? UB913_REG_GENERAL_CFG_PCLK_RISING : 0; - ub913_write(priv, UB913_REG_GENERAL_CFG, v); + ret =3D ub913_update_bits(priv, UB913_REG_GENERAL_CFG, + UB913_REG_GENERAL_CFG_PCLK_RISING, + FIELD_PREP(UB913_REG_GENERAL_CFG_PCLK_RISING, + priv->pclk_polarity_rising)); + + if (ret) + return ret; =20 return 0; } --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 7575B1EABB6; Fri, 8 Nov 2024 09:35: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=1731058542; cv=none; b=nK/nQohRI5E2RRGMcEhKcf3apw1e3yT1xNWa+lP6KS064BgedRBGKRwBfykLq36qVFjKmb/8Pr2FK01nmCdMoUrKweQBTLXMTPY+jQJMoQMK/u5ZqrrBAZqVHFjZ44OK5gfpVBm8E16rar+tt6yDMcAZWFrCJtV2FFrcQykA3mA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058542; c=relaxed/simple; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HT0HbIFjNtzp9pSs5GJbmYMnLyt3aV40dVWvo8uPsWY8YGt3tyxFLvX/MVayjMKqi6A0uaHQiTpiGg+U6NfKzA6a9pOeUnH5GLZuhXGKus3oax1PghzUrPkUJ1KacxqanwZsuzVrE8e0H81Dr2iINDGEYvumCBn/m5fMdThsnN4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=hS09JFuT; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="hS09JFuT" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 366C51A40; Fri, 8 Nov 2024 10:35:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058514; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hS09JFuTuQF+UDSKkHFJnOAy1sYOLr0r9AxRQEh5or3lcqDBOktCYqKAp8HfnqI+C ID6XcoLeHphZFbIWpBlAzLbLV30UBJsPF91h9qi/PBQE/BWvuqv8V4AcjRGAisbPc9 2IFAkVGsDUz/3IsoKTDmD0T2nectT7qp0g4WEWtM= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:58 +0200 Subject: [PATCH v2 14/15] media: i2c: ds90ub953: Add error handling for i2c reads/writes 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: <20241108-ub9xx-fixes-v2-14-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3421; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtSA/dvfkIItAqtjXkr9bFlQ3SvqZ6tMpKpr xybx66gCzGJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUgAKCRD6PaqMvJYe 9c4CD/0ZlTyV0z15FPvXSmMJqQ1SjmAYFqIOTOf7Ial3UYC98BIhi74TBfg9dcYlyfLCTNbRUIZ d+Ndr9u1WxT3MwOyy91gabwYWI+9K4Q8qG4Ux05EBsucmYIuCbzKwq39RqK9nhyzQ3NkEM8p7rv rRTsKhec18K6VgW2200vSTlBxagY2kVBvRxipP1/YURzMULvC/PTDPY7KHYJRDDpQ6noIFdV31I SqCyrOp1yoSRyJKZL7Tgf30GWH4Q3DvDxTf3C30DuScCUlFaqBfydSwKFkE/drUDZB00rPP0nzv jOasqoXhcPEm38CrY3r7XkcBAu15FASnN6tO4QrmWHBBQVLZY4/oY/XDPkCTDUVPwRl3VMrWn7Q khGlc2a7lw3nm9JVyOz2voZilbR6sITfW5M/yp2W05swOU3oQ8nqXUhEVY3R6cllBtAYfADb+ha lUyTxxMd+5g18m2FJT1rQP11bt0X0QELJVNA6IdZ6a7j38rEx6t+qVpWiulVMPqjRVcVCm8Wt6z zZ5TOHE3sCmzTWmqXtArF1FontTi9JhnAfkjR6MnGJqkjcA0fZlw6aYsgNwr3VxulWvGAMHAtlK Q3sdoTZu5cfHEADhnw8Vfy8hMhO7bY2oF+Ep61QUHt2NyaFEGGqiNc1uVBbaGLmmW/gOIT1fAEM sEwnD7mAlAwUrVA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add error handling for i2c reads/writes in various places. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub953.c | 46 ++++++++++++++++++++++++++++++---------= ---- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index b6451811f906..f8f3e31f0077 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -401,8 +401,13 @@ static int ub953_gpiochip_probe(struct ub953_data *pri= v) int ret; =20 /* Set all GPIOs to local input mode */ - ub953_write(priv, UB953_REG_LOCAL_GPIO_DATA, 0); - ub953_write(priv, UB953_REG_GPIO_INPUT_CTRL, 0xf); + ret =3D ub953_write(priv, UB953_REG_LOCAL_GPIO_DATA, 0); + if (ret) + return ret; + + ret =3D ub953_write(priv, UB953_REG_GPIO_INPUT_CTRL, 0xf); + if (ret) + return ret; =20 gc->label =3D dev_name(dev); gc->parent =3D dev; @@ -970,10 +975,11 @@ static void ub953_calc_clkout_params(struct ub953_dat= a *priv, clkout_data->rate =3D clkout_rate; } =20 -static void ub953_write_clkout_regs(struct ub953_data *priv, - const struct ub953_clkout_data *clkout_data) +static int ub953_write_clkout_regs(struct ub953_data *priv, + const struct ub953_clkout_data *clkout_data) { u8 clkout_ctrl0, clkout_ctrl1; + int ret; =20 if (priv->hw_data->is_ub971) clkout_ctrl0 =3D clkout_data->m; @@ -983,8 +989,15 @@ static void ub953_write_clkout_regs(struct ub953_data = *priv, =20 clkout_ctrl1 =3D clkout_data->n; =20 - ub953_write(priv, UB953_REG_CLKOUT_CTRL0, clkout_ctrl0); - ub953_write(priv, UB953_REG_CLKOUT_CTRL1, clkout_ctrl1); + ret =3D ub953_write(priv, UB953_REG_CLKOUT_CTRL0, clkout_ctrl0); + if (ret) + return ret; + + ret =3D ub953_write(priv, UB953_REG_CLKOUT_CTRL1, clkout_ctrl1); + if (ret) + return ret; + + return 0; } =20 static unsigned long ub953_clkout_recalc_rate(struct clk_hw *hw, @@ -1064,9 +1077,7 @@ static int ub953_clkout_set_rate(struct clk_hw *hw, u= nsigned long rate, dev_dbg(&priv->client->dev, "%s %lu (requested %lu)\n", __func__, clkout_data.rate, rate); =20 - ub953_write_clkout_regs(priv, &clkout_data); - - return 0; + return ub953_write_clkout_regs(priv, &clkout_data); } =20 static const struct clk_ops ub953_clkout_ops =3D { @@ -1091,7 +1102,9 @@ static int ub953_register_clkout(struct ub953_data *p= riv) =20 /* Initialize clkout to 25MHz by default */ ub953_calc_clkout_params(priv, UB953_DEFAULT_CLKOUT_RATE, &clkout_data); - ub953_write_clkout_regs(priv, &clkout_data); + ret =3D ub953_write_clkout_regs(priv, &clkout_data); + if (ret) + return ret; =20 priv->clkout_clk_hw.init =3D &init; =20 @@ -1238,10 +1251,15 @@ static int ub953_hw_init(struct ub953_data *priv) if (ret) return dev_err_probe(dev, ret, "i2c init failed\n"); =20 - ub953_write(priv, UB953_REG_GENERAL_CFG, - (priv->non_continous_clk ? 0 : UB953_REG_GENERAL_CFG_CONT_CLK) | - ((priv->num_data_lanes - 1) << UB953_REG_GENERAL_CFG_CSI_LANE_SEL_SH= IFT) | - UB953_REG_GENERAL_CFG_CRC_TX_GEN_ENABLE); + v =3D 0; + v |=3D priv->non_continous_clk ? 0 : UB953_REG_GENERAL_CFG_CONT_CLK; + v |=3D (priv->num_data_lanes - 1) << + UB953_REG_GENERAL_CFG_CSI_LANE_SEL_SHIFT; + v |=3D UB953_REG_GENERAL_CFG_CRC_TX_GEN_ENABLE; + + ret =3D ub953_write(priv, UB953_REG_GENERAL_CFG, v); + if (ret) + return ret; =20 return 0; } --=20 2.43.0 From nobody Thu Nov 28 03:40:01 2024 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 9FD981EABA2; Fri, 8 Nov 2024 09:35: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=1731058542; cv=none; b=cV7dwxRoVuV4652k8B4kYZYNm9o9G1ukDNvhYLrgqj43UCOImLE/TZCOqCAGU2R7roGRGYtbLGTozRZ+qlWMh39SIo1oOVYnNwKt6PgoQq1MUCqoDXRCCfwMnc3aHIubp1zmI32LIY4Ew6mHDWyg3tkzAkEH4wB+lZlcfBHQ+SQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731058542; c=relaxed/simple; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JHS2DpSid5POWaRBBmVB7Z5bs9BIv4rMJG/UeO+39IGqt9wZJd7ihe5dD4qSyplRqTJCSqhZkgG3RGlAibE2YXKSErS6ZhohKT9MxiEt9zJBEzNQuq0OqcPxMN1sDTddAefGvd6VRiEkp6uTS98L6PvCGGoTTXeH4YmHMRWI12c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (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=rt0yVxLR; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (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="rt0yVxLR" Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C650FD21; Fri, 8 Nov 2024 10:35:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731058515; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rt0yVxLRZaMWnBsgzCwAJqrH/Fdb7lfeAo0tYrqxwDOrN6ew3ylCh2QOI1RmWPvhf RAVIDjO3OOfXrYROHOHIRGI2ayN8gXlZyg5zAsYJogf6WDIxlc7TDW3jFSFQD/EO3z vkymBYwMQRLVW4zsUZy4nYnbpWZbeolsntUcYqLc= From: Tomi Valkeinen Date: Fri, 08 Nov 2024 11:34:59 +0200 Subject: [PATCH v2 15/15] media: i2c: ds90ub960: Fix shadowing of local variables 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: <20241108-ub9xx-fixes-v2-15-c7db3b2ad89f@ideasonboard.com> References: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> In-Reply-To: <20241108-ub9xx-fixes-v2-0-c7db3b2ad89f@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2197; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnLdtSeueJWCH95YIyUx2Y4TEs1qV169c7HYUSo aemv9/fQgKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZy3bUgAKCRD6PaqMvJYe 9XnyEAClaoTP9wTfeiEAMJ9L7atuJnChduzSWS0skBD4qOapfQXpUA9mMqLDkFGERZZWqNb8t0M bRUFg+RQrrdB/dRsk+Q/5hcENKLUDeblvma47RO6Swu8yXIgwPk1ymN0k/sIwjslsSaoHTw7Omf c63wzdwrqZ5hcxwCIEM2zBpHeHpAo1sbzNvlb6eT+LyLfZgBg6GOLYySxqj6GQtDksQML2Z5EoV WAnIAl+zAHyo+nOO3dL+1gHr9FP5byK+UtgtAXVrV7x0l8nx8QkVKdMq6gEMrhCGGLvGXwyzMkL NlvEvmwfhjSOaoZTQyTztuK7NFavtN+byGqf27+wRcDMqJnll/LigTEGH3Bp89VJlvfF9HRDoe0 cp+rwHH6niBXwRS97WL4vkMCuqec5p+UdsYxabzeZg6Vdf42QtEhL3W2tc4b3W0Fxmulp0RgGc9 K7f/65wUSZ4F9tVRe0FVrD5HWFMrVA3imD1PgjzbaM/dZxEKb0+aJI7aRHxHGtaqOkmOVBp3kYL T9xzwsQ5xqfw/Zj9Ov3HahBWFB0uetHX5fhFSvbzg5rvx6gklf6WYbXGgP2htNb1hhGdt22mjtc bSpIMWhvEy72riFhcpbKxW3Q79Eb/SHo3aX8bTWr09DflTouj7hGRgv+7viy/7AXZR6xWS4W9IM e9kmeSjZt6PebMA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Fix a few cases where a local shadows a previously declared local of the same name. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index 1dc10b2ba1f1..a9afada7bdc1 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2449,7 +2449,6 @@ static int ub960_configure_ports_for_streaming(struct= ub960_data *priv, } rx_data[UB960_MAX_RX_NPORTS] =3D {}; u8 vc_map[UB960_MAX_RX_NPORTS] =3D {}; struct v4l2_subdev_route *route; - unsigned int nport; int ret; =20 ret =3D ub960_validate_stream_vcs(priv); @@ -2519,7 +2518,8 @@ static int ub960_configure_ports_for_streaming(struct= ub960_data *priv, */ fwd_ctl =3D GENMASK(7, 4); =20 - for (nport =3D 0; nport < priv->hw_data->num_rxports; nport++) { + for (unsigned int nport =3D 0; nport < priv->hw_data->num_rxports; + nport++) { struct ub960_rxport *rxport =3D priv->rxports[nport]; u8 vc =3D vc_map[nport]; =20 @@ -3041,14 +3041,13 @@ static int ub960_log_status(struct v4l2_subdev *sd) struct device *dev =3D &priv->client->dev; struct v4l2_subdev_state *state; unsigned int nport; - unsigned int i; u16 v16 =3D 0; u8 v =3D 0; u8 id[UB960_SR_FPD3_RX_ID_LEN]; =20 state =3D v4l2_subdev_lock_and_get_active_state(sd); =20 - for (i =3D 0; i < sizeof(id); i++) + for (unsigned int i =3D 0; i < sizeof(id); i++) ub960_read(priv, UB960_SR_FPD3_RX_ID(i), &id[i]); =20 dev_info(dev, "ID '%.*s'\n", (int)sizeof(id), id); @@ -3082,7 +3081,6 @@ static int ub960_log_status(struct v4l2_subdev *sd) =20 for (nport =3D 0; nport < priv->hw_data->num_rxports; nport++) { struct ub960_rxport *rxport =3D priv->rxports[nport]; - unsigned int i; =20 dev_info(dev, "RX %u\n", nport); =20 @@ -3121,7 +3119,7 @@ static int ub960_log_status(struct v4l2_subdev *sd) ub960_log_status_ub960_sp_eq(priv, nport); =20 /* GPIOs */ - for (i =3D 0; i < UB960_NUM_BC_GPIOS; i++) { + for (unsigned int i =3D 0; i < UB960_NUM_BC_GPIOS; i++) { u8 ctl_reg; u8 ctl_shift; =20 --=20 2.43.0