From patchwork Fri Dec 6 08:26:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847989 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 8F3A41D47A2; Fri, 6 Dec 2024 08:27:16 +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=1733473639; cv=none; b=n7MMucNfUMmBYvsIX40WThKH3rExghPlC6rOTZfvF8MNKwIpbDKADSfdLzcQxrYzoX4AFI3vAleSWmJq6+jd96Y+iggcGN0LSRHk+gwAKWriUpjHomxgAMLMEpRCk1fkjhXJrIYpuQG1rrK1LAx2TaZTnYHi+t2fXTrdhD5mfKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473639; c=relaxed/simple; bh=hiiDMQ0QVyH5ARoHam2LktnO8Z7HGrueYA4xcpNrgdw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nfRyEraoJ6QnJOeVKLzL+YfPhoyAwivfaaP2PyjwHDsRRrTTnMgxwZp7aRusx5SCCU5N6UM8CCgAN0PbayfBLW8ft6/P92Pd9AZ+dxLZXs5Wfr7rH+e6yoDyba18KFy4DlNPR0YgaH9OlE1TS3B7m2hqRkU/xn/gy0331R/1U6k= 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=ZvV1GPDZ; 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="ZvV1GPDZ" 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 EB3DE9FC; Fri, 6 Dec 2024 09:26:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473605; bh=hiiDMQ0QVyH5ARoHam2LktnO8Z7HGrueYA4xcpNrgdw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZvV1GPDZCot0zkih/jpySTac04qrXKDORVvP+NmIcuR/iWN/NZiicck5HjdGsXIK5 zJlrxw0BML8Rhy3qMU1oaM2cGfeaLAW64vFFGLQEmBAzy6krS/7dUbm5xJRKPaApSr dyk5RGhHx8WwBWeT2SfSh6u7GbUW0XyAG57jT8rw= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:37 +0200 Subject: [PATCH v4 01/15] media: i2c: ds90ub9x3: Fix extra fwnode_handle_put() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-1-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1760; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=hiiDMQ0QVyH5ARoHam2LktnO8Z7HGrueYA4xcpNrgdw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVbjjpK7Ti/JnvvpjXOoXt0rPI+IQuUgctN8 q73htQwS3eJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1WwAKCRD6PaqMvJYe 9QI6D/4nHwnjwzsBjhbYOYf7emM5woFAfAvk8UCgl65gi1lYdLmFFQ52s9BQb0REIdNMe/G4LpX AT7f1ZB9Ur7oC1eEyk2QJe8bxzE6KaKUv8cX6TbLyp+rFxC97LwzPZ6+3UqXV4eL0poOO2hnqRR /RG7GNn3dWVA2xGOGPcjSR7NcPc5TIMQuu8GAxn6YtGssAt+ThrxGX3wjzfQo2r6HVvNGpygVJE gvyoR/ChWlc1hkIJWjcjf1mIBuZU3NKIgteRUUSB0711gccn53ZZ2UHDo3Bsj88mH9WCs+GWeSw XvHDijCX+8sghemPoaC+Dm02/iiNmfMjqkxKinoTDBIdre9AN7zu1CC1nn8zO3zcySaZgFy1cGw 5YTEntxhb/+jivfkXzX+cF0lwoPPOQ2Cy1HCOvMNnd63Z2XIfjeewR0q/ZNtf4bSOyKuUoi6Vna GWgXZds3XmWX4eUNl5RGjXuL2q0l4vOshiI4pLmkGDZxhjPIszqfDNm4q0iZ3KqaW5SpyCXDTWT f8HTxIG32tuSnvIoLQvv6/nLOyjxwqdNafBRCnlycS8Mh9+CvBQb56fiHREz0Q6Nz1zOkxd8r80 aiGWLIXrrjBh5XRzAAk7Nk5vjudoaDPlwZZd9OknH7nRC0oH9ESN5rUZpmClpqBpx+X3fUcGTQD oZ2AvA8nnHigibg== 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. Cc: stable@vger.kernel.org Fixes: 905f88ccebb1 ("media: i2c: ds90ub9x3: Fix sub-device matching") Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- 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 8eed4a200fd8..b5375d736629 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); } 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 *priv) 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); } From patchwork Fri Dec 6 08:26:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848216 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 88E011DFE2B; Fri, 6 Dec 2024 08:27: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=1733473641; cv=none; b=SGEQ9eDVVSumqvfIKqDpAlHEIrmb4Cqq6am4pi8cbvEsAqlDbUFFRi1TF0VG8bszai2GS3pOMLFVHWq72pZdAR7WUMQlODUOLicH4OZtbD2K3Rgvb8KCZIwBYdq3n+4Li4FDN8OF/p2J57PRI1cTt+f//gSQ+31zS0JQ8VkHb1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473641; c=relaxed/simple; bh=EvybpXzj4B6bnj4sfMr1dme2NoTO1hCmVx5yi/P/qAA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jFz1EbISAjyKvcp+1Dp6egQNKnnWtQWbv8kCCYKp9UJXf5OEGSkXXJaA4MxZRCBI7co5YVTKIT5okFrAzRpI69sO9khtF0OGKD7rGjjW9EsLzvRzbOEpgzAcxMm9MUtef37lGMfbSiNhuI0jJp9Bc/dcq2+GR4AJal+QB+plqOE= 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=nVsqgyxu; 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="nVsqgyxu" 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 90FA0B2B; Fri, 6 Dec 2024 09:26:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473606; bh=EvybpXzj4B6bnj4sfMr1dme2NoTO1hCmVx5yi/P/qAA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nVsqgyxuBe9Br0LulGjjdYtcLcqwDh01zTTQkaEfovi3VemnY52yFJu62buEYhx5g 4rhZSp+l21bGHgJEs/H0+EAFQ2MZzB1/f2/PgpeLn9BhLlO3LOESJu8qorxh+s3ws6 QeCBstSVedAoFvyOrCDL4FwQJQG7xQD5SavxT9BM= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:38 +0200 Subject: [PATCH v4 02/15] media: i2c: ds90ub960: Fix UB9702 refclk register access Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-2-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1396; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=EvybpXzj4B6bnj4sfMr1dme2NoTO1hCmVx5yi/P/qAA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVcDz5ZpshCNCZylbMz6qPuhIREIJ70biLar wYsUN1QfrCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XAAKCRD6PaqMvJYe 9f/ZEACLnYE7GHNeAeqq00vE5Dmhgwg5GTlO72H/UoAOVZwtp6lJBYwCfzGMAkADT1BaOgKjnPe IHWyLds58CcWGYJaQ9+hZ0/fV/KxAJIAX2crRVNn7W5KXCOjwJwub+pNS0artEyCF8A4VB+5ci8 /kXIPwIMAHJ8jaodMxhvFZsDQ0nEIKevKTQfZ0lx1U/mkeis/g7zkgjiU7/0uNTmUxPZ8CjMhSU MtTULZ9eXhq6he9DNI7jvs35IZwX1nGRsoUSv0DpTr7ROLWmUwYNWymyWrjAdtkdaXH2041lYD8 7T0+CNYkIUGBEYIvjF9R/B+ZQ6n8MnrWpekD1TSg8fG6Lue1/88l8x0Jjek/akgIYnYTNm6Zft1 UHv73K3/sXOrMEZ0dZNqu5+rKra7J+LoJMBf5JrJ3ztek/1CR4TyDABpiI8LiHW+195KrEbUS96 X0aP8FOh044ATEOT4bW4asbUwFTE5Wwks4ovPJlD5ACUbR6wa3+VSjlxkFqDnq8+qCBxuvsyhs+ OKtaFPUGLY7ZltlAzJ/BKcHK7lUlrFxkHFaZVCkKhz+cAy5zOSQfWwlaTuhDViIbaHupEFxw4VM 1HQXoWQXvJJRmBcJU/i1efF8DHoQDGooXfnap/wmyVF53t2+AvX+txSY93tLz3BTElHmqeu+j+8 2K+5WklxvqMX1wQ== 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. Cc: stable@vger.kernel.org Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") Reviewed-by: Jai Luthra 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 ffe5f25f8647..b1e848678218 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -352,6 +352,8 @@ #define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) /* < UB960_FPD_RX_NPORTS */ +#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 *priv) if (ret) goto err_pd_gpio; - ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq); + if (priv->hw_data->is_ub9702) + ret = ub960_read(priv, UB9702_SR_REFCLK_FREQ, &refclk_freq); + else + ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_freq); if (ret) goto err_pd_gpio; From patchwork Fri Dec 6 08:26:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847988 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 82DF61EBFED; Fri, 6 Dec 2024 08:27:20 +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=1733473643; cv=none; b=eTkVuvzr/SrDXlQ+1/9KCDmp46w89AACzYA7QvR5wyxkRsyg7nqif0VNglM6fBPHhiumrVmBXooViYh79726ahJpRIQ0K4SHkUZLqbJQRCx/yslt7vJPCe6mOKML+MkoNmgZGnq+Ac4Pjo1BK1qbYZfXoijSI+3633x6sUmcvsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473643; c=relaxed/simple; bh=LkrtmVOl+CazUBRYwt0hQd2QDWue5OQUhmwfZwpvQmc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S8eV1uExU4C80qdBFmCjg3w4LeacALTmm5uqPH8SSLIq8G52wRpMyjD68Yge+mtktJJOUVamO4sbGmRX7mPP9bvUjR9GsYOwuEsWs0R2NR70DAmvKnEoOvG6r3zjrdy4KIYB7eqjAsx/5s6GQVmMwnFqTmuD/ixnf8g0pGvLXsA= 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=QwDLqc0p; 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="QwDLqc0p" 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 39D6DFEF; Fri, 6 Dec 2024 09:26:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473606; bh=LkrtmVOl+CazUBRYwt0hQd2QDWue5OQUhmwfZwpvQmc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QwDLqc0p3GiO3zPyeth0dp8NyTpDYclVPTmLZcmxKkI40vruLm9vtuA3bPgBhTwji pd0UpUM7BdoLCDtLxPGa/uKsOj7DXZzTHME/Nyt9Fvj2j/i2Ra0LYupqMnx0OAhsC5 HkE/dXxuEaOlOqd/m2asKuVawPskkZOoxt+2Me88= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:39 +0200 Subject: [PATCH v4 03/15] media: i2c: ds90ub960: Fix use of non-existing registers on UB9702 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-3-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1735; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=LkrtmVOl+CazUBRYwt0hQd2QDWue5OQUhmwfZwpvQmc=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVcIUwvIuPlqnt40tgXARlYtIhiOxMk2+lk7 fifCIS29R6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XAAKCRD6PaqMvJYe 9ZHhEACxIUqxUqHcsQFg337cR5FuZNcItog6v6Qr6iyYw2uEp7YNmJoLyxvBr6PG05+mhEeryF0 nLxVZ26yxCwGLXYzsQQEGYtiQLaPC8cc8ezK2yfsYSH7uXfOwkMBBImU26dNhWdzLkDw1L5sWSB 7csQPzShu4DquwItrZklQ6Wz2rZ8hubZvfbX3Gt61Nh2tU6l/6unbFccKvARF+kWK02AjVxzjQB rqBnA3tDRss/Ity3bTczbYjiqoWb963011gX9RZBai/szKV+GdKbpFsBdildQOS0mJ8S+IHdsL0 +L8+hE6NFHHfaXFvLaYqdLNicCucHjTjBQZXlIIMPsQDh/56AkfZ111qBLlR4TVMwpgpfILGfRo GpQouB6CHfpmnnPELE6hD7gJMunQbZM0bJj7ToPxYkDEAsiapZXMhJHka6iBwjhtyOjoDMdknDv HV4vafvDxVGe1N6K18mGaTy7I3SvOOh+O0GQWH1pR2pSDrCxgfZAgUU8bbyjX5S+ErsvwH3RPwD Me1Mxg17LAhrM8xCc39xO8ChgMv9RVhD8vvfXZmmeZJdp8ghe5pwmsgPg/MQec5K+iZPfywL2wS 6qyDEe9goPs1v3Zl6dY1D78MA3hP0R2TrgijXc7OC5NaXTP+qZ90h4pLSpneW50u2Q0AZyp6urd pJU4OKX37OLTiOQ== 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. Cc: stable@vger.kernel.org Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- 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_data *priv, ub960_rxport_read16(priv, nport, UB960_RR_RX_FREQ_HIGH, &v); - ret = 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 = ub960_rxport_get_strobe_pos(priv, nport, + &strobe_pos); + if (ret) + return ret; - ret = ub960_rxport_get_eq_level(priv, nport, &eq_level); - if (ret) - return ret; + ret = ub960_rxport_get_eq_level(priv, nport, &eq_level); + if (ret) + return ret; - 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); + } } return 0; From patchwork Fri Dec 6 08:26:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848215 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 AF9C61EE01B; Fri, 6 Dec 2024 08:27:22 +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=1733473644; cv=none; b=hy7PFgudfSfTdTXDwvqvHvOuWIUTnlAvSyJrdjSAiwPFKGo7/tQNC5cAv4y6zc6tPSleYUiPdq5jqBgsnTdCiejX6/Ypa9buGXNzybzU39As/9fQUh9UA4Bst0Z5QFyzbtj7+5bgFrvM27q+IQ2LjNikzOhF8LIAPsP3E/vEd0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473644; c=relaxed/simple; bh=Cq58bbzo/NugwJpxuMZSFFqgnspSJu6mhpl9XGc+2sk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mIbMqv8BwlXlCcDsStbv4HQVI0Crtr9gQiQEsQIewOZ98eI9oFCU3tGwViuUtRNmv+lHT42CLiOtok15Hod8agaP4wwNh7d/EgfBZSt4mQICFCtuCT8H2+fdbs9HyEaVWQyiwX4WyOquVKm8sMSYyNXDrbY66QniZvS2KjtpcB0= 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=Jwv37fzO; 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="Jwv37fzO" 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 D7EF11419; Fri, 6 Dec 2024 09:26:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473607; bh=Cq58bbzo/NugwJpxuMZSFFqgnspSJu6mhpl9XGc+2sk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Jwv37fzOHBmxTMRFPJq7iBqWiYZjiHriyzh0Sry5tKvR4hCoJwV7oM2hzCGxZaU1e u4jpu3gLBlAp9NFPEdmpOER5G89lRUHofI7rNYqUoNTGxrO0JTDpVJtWb3KFaxF7h9 nPDEO9N0RK1LIJidhoP5bnVxY1NczNawm+rq0IaY= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:40 +0200 Subject: [PATCH v4 04/15] media: i2c: ds90ub960: Fix logging SP & EQ status only for UB9702 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-4-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4182; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=Cq58bbzo/NugwJpxuMZSFFqgnspSJu6mhpl9XGc+2sk=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVcXCKszF6Ap6X1Mmea7Fvk8ZCl5H7QhgB82 TrYCYzbv3OJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XAAKCRD6PaqMvJYe 9Z7qD/4107DrcdQMrsCfpnCr4zvQ58ZAnMHXESfPUD1+oagnoeijv0xqQbdg352rxHU6PEPhuST SOPyL02YwScOWqnbhipFVZUzFP4+GHTUt7EVydJ88Mpx+GNCLmnV6AseMOkr2nLcTVVwiAp+ti0 q6+xFWCgRQjhfGLPjoUjOqMQiTDpUwLlHJhe9TtvQR7bjQ89E1CFr7E/efZzOyfxYSWhmD5a2Le JZaN+LjKKA20AHDQRaZVi3m5rrN0KLACWNXzar18YL/wQyLbrbuC/nIicxBeL1gkhWv6yk8GaMf bRbe1S4m/t2oTY7osNIAvC8R21kKv7/rx7HXMyWTRe+hn2XsIIeHlcIq2/mRISog9kmIc/qzOVh Io2WLjNj1wYjlbcI4BHPS7kfmrWjkQC7KMxqno45wTUsxIJm+XvX5MwMpiWxWchEooRVwkNEnVV elMQRuxc17djdCnZG3dkrp0Y0jOWPVKxPH5NXZqQysaIDT1/PLDUvkPBRKdp1+kgcMEu+acPX1P bIIxiFMEXkxTwk5UVypISwCwel3y2ulb7Lkeree+Z3hC5qwThiCISxoh+zYjoB8HlFDLp0YNFZh w31fOh3IR1dASmRcXj5k0brbUJR6U+rXcz3eM76unrwflP02d5CU4xT9j6vnveJzc281SKc7OjR xqI19PMjpBG3nyQ== 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. Cc: stable@vger.kernel.org Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- 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 24198b803eff..94c8acf171b4 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2950,6 +2950,54 @@ static const struct v4l2_subdev_pad_ops ub960_pad_ops = { .set_fmt = ub960_set_fmt, }; +static void ub960_log_status_ub960_sp_eq(struct ub960_data *priv, + unsigned int nport) +{ + struct device *dev = &priv->client->dev; + u8 eq_level; + s8 strobe_pos; + u8 v = 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) == 0) + dev_info(dev, "\tEQ level %u\n", eq_level); +} + static int ub960_log_status(struct v4l2_subdev *sd) { struct ub960_data *priv = sd_to_ub960(sd); @@ -2997,8 +3045,6 @@ static int ub960_log_status(struct v4l2_subdev *sd) for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { struct ub960_rxport *rxport = priv->rxports[nport]; - u8 eq_level; - s8 strobe_pos; unsigned int i; dev_info(dev, "RX %u\n", nport); @@ -3034,44 +3080,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); - /* 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) == 0) - dev_info(dev, "\tEQ level %u\n", eq_level); + if (!priv->hw_data->is_ub9702) + ub960_log_status_ub960_sp_eq(priv, nport); /* GPIOs */ for (i = 0; i < UB960_NUM_BC_GPIOS; i++) { From patchwork Fri Dec 6 08:26:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847987 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 B33261F4268; Fri, 6 Dec 2024 08:27: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=1733473646; cv=none; b=sRmQeIU7nLpuRDJ/sONekHBTmc+eIIIZ4ag4FkHqDwooDaRw9Kdj/dalOXhPCByFMFbE8fZt7EuvEbINmQZCFxVoE9FFbRSnYfYcXf3d1MaLH4BZik3DXy2iow1GsC1dCuiYTyMeUdK2jPChxBWrEkk2cpWPbyiiWnudebqkcVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473646; c=relaxed/simple; bh=LqMLlax5zuUS8olZLAzmyGpPwtLJTYz6ZSYf64WP1d8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iLD2FPwC+FOEOBMSpP9q+9PfuL+NDJHOvuLlKZvnnuoJVXJIys5aAibWtFp3+5m3nGU7KEz7LSt1lHkrhvO1f1kYpeyCSAtVp2IwY0aQeS2cdTMzBaTY6C8GkxYcpeEAYe7AS3XACE2IOMxrGb5nwe9qEShQxFDxtk+6hPI9qlg= 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=t235QmXr; 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="t235QmXr" 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 7E7C116D7; Fri, 6 Dec 2024 09:26:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473608; bh=LqMLlax5zuUS8olZLAzmyGpPwtLJTYz6ZSYf64WP1d8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=t235QmXrlQhHMpzkVDDIxWUaEmM6zJpoJ2x3f9T6Vq1FiPu69p2+qeq0LjduV5KIq W/3AQtu4C21aMS3GPHwJv+VdafFkt3xV+Xuz3tB/1Ik3fWDGnju8k86UnGebwHrE+k 6WvbOOviT3rHGS4/CXfi1aMgT0U0zp1hsHthOWes= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:41 +0200 Subject: [PATCH v4 05/15] media: i2c: ds90ub960: Fix UB9702 VC map Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-5-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1294; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=LqMLlax5zuUS8olZLAzmyGpPwtLJTYz6ZSYf64WP1d8=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVdkeVpXm4moYQ4HREFcbmsMQH6wwGUrZkzb m8D5HXXd2SJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XQAKCRD6PaqMvJYe 9dltD/4o0AWt0nVl+bVSapDPIewBcE5EvWNl/wao3PDd4wGvsuVTpTXjks97PB57LGFOrubSk21 EQeVULoxcTrlUXPmOZljg+ZAP8EKptMZpjvaRwK6ayq4GHm8Y9Mb5dzuaU+ocEJrlZZVnMcVYwZ OElWDe3wnVrsUan7R4iKv/C59jZoagK4QYM8hKlov2OM/ukysj0QChqHgRJyQiYPS8hKly3Hpo0 Zb9LGB5jJ2HQ2Zt7Y+Gr7PHD7gYTLc+cRrIxwotc2mgKG+C02SBiW3i1CYmWCh9GsDBRfmPoVvT 6gY9xpm4lQB6JVDEmuRgBTWTyJTLcybXX1nyCQP5X0FjdFH48epFXmNEQbvIIPaEoRxLc/XF09E kZwyO8nOExWngD/uUhFEANBz/IRf/B1vqkEqArV9kzps9QgEIb1igtshEV8PmRwl78odJaFj4lu PPCGzV5B7wbK4EbEZLY9/XGsZPPdL7JWfLxQdkoJiv1AlsjjyTqQyw96Jpp6JFuwbSRfKG/6hMr K54wtIWcOy5Ohmq5cKzyIB2UHi5fihpNO6dfi4EIWDAgg2J6S9X37FOqESJj5d381prIFu/8z+C kUfl4My1g5AEieUvWHPKMH4Z8q/lQK9HnPGTOyGs58jMEHI879S3lHobiYTRHSgsERn0cX8uTOx O/1yKWvcu/UCbrQ== 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. Cc: stable@vger.kernel.org Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- 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 94c8acf171b4..bfffa14e2049 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2533,7 +2533,7 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv, for (i = 0; i < 8; i++) ub960_rxport_write(priv, nport, UB960_RR_VC_ID_MAP(i), - nport); + (nport << 4) | nport); } break; From patchwork Fri Dec 6 08:26:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848214 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 E5E651F540B; Fri, 6 Dec 2024 08:27:25 +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=1733473647; cv=none; b=XJHCn6OthmuXevoSZPpSXwDRyn25E6LQloIAr2I5YEfKT0oJvjg0pmDGkxY212xrOYLjUWCMlvzavaqcRRwN0gMefjOwf/A25R6+SVNTok5A2ED42MWi6MdLcC77nKeySe1BnEMbUoEUCwrOWyhUG08BBhoidgIxGk0fTWaaniM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473647; c=relaxed/simple; bh=7q9AdqxzcussrLZkhgtJewGXlU51mmi9YmOjG59P03Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TFS/kArE9weeSuxAC9az2vNLuXsC5XUy5Tm+M1XdNVQrU4xM71S087thEoYskffFwqjTffHkef+qtecn2bSixZyjj+qOGw8kD0l9WPa3W5RFD6TRalmRvvvNHuji5MuMOhSGzIefyF2F5ayzShDH3cHmnBhQnn8SVUD2cZ6pVEk= 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=CgcjtdZy; 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="CgcjtdZy" 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 2A7A0186E; Fri, 6 Dec 2024 09:26:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473608; bh=7q9AdqxzcussrLZkhgtJewGXlU51mmi9YmOjG59P03Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CgcjtdZyrxbqkEHwXqPmpRXjv95SKDj/4HAY79rE0bsd2Tvd7As87nLvYSylZO2P4 r5BVHsWK/DjcZfbsx1e3rPbc/EPjAj2tYiufmi5v259C/ciSq7FIQbv1sJATvmbxp+ /Di48AFNr7w+P1jjH9q+ponXxLFsvx+KIE3Lh5SQ= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:42 +0200 Subject: [PATCH v4 06/15] media: i2c: ds90ub960: Use HZ_PER_MHZ Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-6-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2339; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=7q9AdqxzcussrLZkhgtJewGXlU51mmi9YmOjG59P03Q=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVdDSn2UNs3KgkyUGjhb9Sw7orXzey2z4CH/ V0s1tsAHaaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XQAKCRD6PaqMvJYe 9eQND/sHoG1UbRPMa8I7TF1cR6ZS7qnFKDwH9tUPkjNftLjMN3UbgUKXVYGQra2tfw32H8KNMxH EpyNO0hl/qWvb0CT7enINnJ+nbRrrjPEH6X0tkl6+qL68eJaQNP2u9CLb/0kRSSZna6+TUV46bK wYbjuQEEZZIRg43FnGojiqRH3Km/ja2enJTSV7Rd5lUJNpgDn/F5/2DO+TgbkMpK80fh1RYMOQk EyMzQphuAOdp8anv5RePX+JLml95AinMTaH8CT+0YhvLASyUiSa0XbeLQR+mbyRb6i1xWJ83x4m 54ItJkJtXGQHS2squM2R7fLVfxOA0ttDcxd3XZ5UvrBDl9ex5RsL2xnIjGxKg/3qQmjVy+DIP5Z 8KMxIVLoYq0ACfEum+1eI/G7vVknWQP9qAxI+TtrYMDowxng7h/7xwNjMwu8UPlCKen0DxGeHcp lKhPHc1ueOr6YBodpTo3WBWKgl9khM9Xy/99V66o14cr3a8G5lfR8bIgUSJihc1ij8b+gBR36+a cjFN3o/YEzh4zfJQbfEU/KBNPMPOaIbEY5Z8ufEZ01Pa1r93iROKnJUam+eB3ZL3hJzMAS90h6u dCLD7py/XWFobLxZL4MxL8HJM/6Gey+2O8epKN+FNlpTFO7gbCoGPQ2WnnbFtavYL4IqEkC0PZC Oe07mGf52z1LkZg== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Use HZ_PER_MHZ instead of 1000000U. Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub960.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index bfffa14e2049..84631909635c 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,7 @@ #include #include -#define MHZ(v) ((u32)((v) * 1000000U)) +#define MHZ(v) ((u32)((v) * HZ_PER_MHZ)) #define UB960_POLL_TIME_MS 500 @@ -1579,7 +1580,7 @@ static int ub960_rxport_wait_locks(struct ub960_data *priv, 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 = 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); } } @@ -3066,7 +3067,7 @@ static int ub960_log_status(struct v4l2_subdev *sd) dev_info(dev, "\trx_port_sts2 %#02x\n", v); 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); ub960_rxport_read16(priv, nport, UB960_RR_RX_PAR_ERR_HI, &v16); dev_info(dev, "\tparity errors %u\n", v16); @@ -3866,7 +3867,7 @@ static int ub960_enable_core_hw(struct ub960_data *priv) 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); /* Disable all RX ports by default */ ret = ub960_write(priv, UB960_SR_RX_PORT_CTL, 0); From patchwork Fri Dec 6 08:26:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847986 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 D60E91F8F03; Fri, 6 Dec 2024 08:27: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=1733473649; cv=none; b=WkxT2pqLK4YiUAQFbcgD5+bQWehCfYXbxYD+6Ei322XhKE9toRaeDDC3CCmba3E0pX06VufmFq/dYpAxIDE+VmnUlYUITP+IMTSAyuDComrr6dHrVvUnwyRmkMCWFXzGq5uVBLd18A4pRxPse2Wmtp8nLFcpgKG9cD3dlT3gdaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473649; c=relaxed/simple; bh=GWJwFSuB1YRWNMi1zmAD0t90+bvcyNMh2WeX8gJmBeA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B8fitqICS2RlqxV11HP+0Fd3xhUy8/kiPoaIxdTSLNrIbuVXbZNj0RRhofn/pq2eUPWMl81Awv4umYAAfzV1b2DoVAbmxQ3PPrj5hHlOFx4Ih5h0aKrirDNlOmjXbZNpFMjlUhgP7UcHm+VJEA69+TYdP1T0wdb3P1BE3azQ9QQ= 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=QArz5pH3; 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="QArz5pH3" 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 BAE031966; Fri, 6 Dec 2024 09:26:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473609; bh=GWJwFSuB1YRWNMi1zmAD0t90+bvcyNMh2WeX8gJmBeA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QArz5pH39BF7A/3MKtmKkVT8ZzTtZwTXAaX6oy2N0vvtDX8SDV0bDxcWF9XdXBwxJ uQq/KATEX3h0qrFYab8QM0Nq9YcaAjkYuvltudDhlFM2rGt3vkjgF6PoLmUQWxfq2K RcwpRkO84OAmFJr6LRXtBj6Lr+fQi+BlfYnhsRB0= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:43 +0200 Subject: [PATCH v4 07/15] media: i2c: ds90ub960: Add support for I2C_RX_ID Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-7-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2326; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=GWJwFSuB1YRWNMi1zmAD0t90+bvcyNMh2WeX8gJmBeA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVdQLJSFp6rSfrjGYqsTp/MlUQGvao0gVKit cBHLU5bDQKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XQAKCRD6PaqMvJYe 9RA8D/93AVwmXH6mVCtSZ9DMr066z2SaPDxh8DFA0irQ40+Zj117K+d81axuFOi7O4Wf6jAUpiQ lQS1DpPxMHdMm/9jiQuQT+dKoTX9ZZYrTU6OQaL736jnHHRCI82Gd0QhjURbKPQ5W9hEmGcoOva qptN5cBcPCP5rAWo7a3EnvajSOSx/g6Y4qKjjoavVmD6P3bxjVyC2SruWlHAQrTZIA/4S6xIAgL qshbFQoXIw/uBR2aSpCV0nKGLpX50OfMyVkfc8ZxdIeJU8aSHq5Pm17GEuiT5vhmEW1kDZRdog/ KRI9ccblUJ0EHX26ocKqFBVx/clAOfBZRiT6nRRT/UBvok0avu+4SyUHDWuqbVi6n4GAPqHCQBj 9yf6xvgoYHevgD0+I8BybdVzA3lwqpkb1+PPz+UG+k+i3NaclXLHGr/llqD4Ezz/jdvvkwE7n/q //Ffa+IjBHxff1duLw1ykXRgm2G0AsZH7Bp5E5oH4m3Ae08u31mVbvtKp8xi2lolOTY9Q0R92AO E2TuzcNdJFo5NEP9itNbX8I8gDmp0K1E45rKIieAtSB++Qk3BJMvXFzYzvMWmbofzLX4yiL3/7w xDrBg0wD/ObQuXe4K7zz47SgMnhDBBfM0qI7IZM5gycNvDFs8IUgHvgT6ES785StNEaMbBJYUnL gdM00Rc/e1AiddQ== 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. Reviewed-by: Jai Luthra 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 84631909635c..bd575bca2b42 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -55,6 +55,15 @@ #define MHZ(v) ((u32)((v) * HZ_PER_MHZ)) +/* + * 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 registers + * directly. + * + * Only for debug purposes. + */ +/* #define UB960_DEBUG_I2C_RX_ID 0x40 */ + #define UB960_POLL_TIME_MS 500 #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 -#define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) /* < UB960_FPD_RX_NPORTS */ +#define UB960_SR_I2C_RX_ID(n) (0xf8 + (n)) #define UB9702_SR_REFCLK_FREQ 0x3d @@ -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)); +#ifdef UB960_DEBUG_I2C_RX_ID + for (unsigned int i = 0; i < priv->hw_data->num_rxports; i++) + ub960_write(priv, UB960_SR_I2C_RX_ID(i), + (UB960_DEBUG_I2C_RX_ID + i) << 1); +#endif + return 0; err_free_sers: From patchwork Fri Dec 6 08:26:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848213 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 D965F1DFDA1; Fri, 6 Dec 2024 08:27: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=1733473650; cv=none; b=VtfxOGbqaic2m75O38msGJiFZfqQUWZBhz0D6Z5AfLcHnBXoLEgkO8J6VffjdlYnOY+gDKoAO+Ri3EM86T7utprCLuAb4Umig4GyBWQCrKKrSjayF30aF+q6UXB/ehAweuq28aTwuqFuC7RvtstGkv4CobbeFviNM+Aw5xeoGjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473650; c=relaxed/simple; bh=af3P1y/AaDEhRKiWsMEMRg/+bubJgEEA6od+ONwb6wg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QsFOZsSVL8tpylX35Q4ZoEjSBMXRtQfvjA5cosl6Yif1F/w0vckRYWu4ddFjj+8Ba2JqlEKEdEFjv0AUxNk+KA9Np8hZ2nK62gqDPZNQ9WDc6V892rPwB1TisfdcSQ/UcmcwR9yPhdG+LnThcYqtPi7YD9WCHK09W2VZYMbXcpM= 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=dpo1sSO6; 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="dpo1sSO6" 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 5B8E31980; Fri, 6 Dec 2024 09:26:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473609; bh=af3P1y/AaDEhRKiWsMEMRg/+bubJgEEA6od+ONwb6wg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dpo1sSO634+Ya7VJTmUVMvhwnB5Z8Rh175cPBn0z0RbhGxfX53tKkHzQ6FUuweuEM xloQM4yddh5kQHkoQeLEjGsQbYs01657WCNX/EWfY1ZgY/Ix1gug7nK0bfhZ9DhuHN w/xzO9T6cGVfy3QfCoS2pziOiasfuHMXwXipp/MU= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:44 +0200 Subject: [PATCH v4 08/15] media: i2c: ds90ub960: Add RGB24, RAW8 and RAW10 formats Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-8-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2061; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=af3P1y/AaDEhRKiWsMEMRg/+bubJgEEA6od+ONwb6wg=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVe/jYMWYstY3ZwDXeRlraFIILoPxlvK91S8 9U5a2NADlKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XgAKCRD6PaqMvJYe 9c6nEACDVriBFbjGt9dmaNO+iwyRdZz2wJZ5/ZnfHHXw1n5VV9qOCnABPB4qLnPmMUYT1cVo+PU BseymEcl4lSGY46JJBL9mmSpqwORWo/wc2B23zaaGKdx0c+OyPiJdwWnbPwCvvuBcw9W7rQDjGE Vr1zUOv6xklhzzPm6khgfvQJq3zpm4a5jR1PZ7OmFiy3WOh/5E7rvE8bdAFZqhmWCK1yazlhc51 zWkKDwI8ZiGCs7L1VUrcsX3yG6d5fw/EACV3pGdUJs9DF3agkvkByYX94LfhcyRiFnEra85X/LJ uStKmi1Ujl4xx0Rj27k4NXbB/+1At2y/EEZOo0cODCVNgzW81ZazTdgOVkVWMWmgE9DZ+N6hjdc v9qEZbu8v93GTeAGfMOxiq3iH0BkY2ZZ5o1zv+7YxSl1zxdZ1Tgb2enZZvXR3OuaCLvOFLljIaK 5tu6gqJuIs+CYoLQrzZoBNXihAK61Hsl/PAwfUMshvJ+YVEmUYioi+9Zos0zkhLL4M7CJkHD/8X MSfBP7xD2zPOEvoLFx6dAbtMOMYuPMsdfCUzzHifrhVgSvVoveROP+II/5Pwz6Z24d5iO+eRi2v iPlEi6BYuIA/WWeAumCToUVfxeGfEk8NspYdaWZclnKPrvd9tYWsDXrD3sGKqlOwyN3hx7xQbBy pBV3vDZevzSwnpg== 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. Reviewed-by: Jai Luthra 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 bd575bca2b42..721898e5c913 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -581,11 +581,23 @@ struct ub960_format_info { }; static const struct ub960_format_info ub960_formats[] = { + { .code = MEDIA_BUS_FMT_RGB888_1X24, .bpp = 24, .datatype = MIPI_CSI2_DT_RGB888, }, + { .code = MEDIA_BUS_FMT_YUYV8_1X16, .bpp = 16, .datatype = MIPI_CSI2_DT_YUV422_8B, }, { .code = MEDIA_BUS_FMT_UYVY8_1X16, .bpp = 16, .datatype = MIPI_CSI2_DT_YUV422_8B, }, { .code = MEDIA_BUS_FMT_VYUY8_1X16, .bpp = 16, .datatype = MIPI_CSI2_DT_YUV422_8B, }, { .code = MEDIA_BUS_FMT_YVYU8_1X16, .bpp = 16, .datatype = MIPI_CSI2_DT_YUV422_8B, }, + { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .bpp = 8, .datatype = MIPI_CSI2_DT_RAW8, }, + { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, .datatype = MIPI_CSI2_DT_RAW8, }, + { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, .datatype = MIPI_CSI2_DT_RAW8, }, + { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, .datatype = MIPI_CSI2_DT_RAW8, }, + + { .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, .datatype = MIPI_CSI2_DT_RAW10, }, + { .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, .datatype = MIPI_CSI2_DT_RAW10, }, + { .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, .datatype = MIPI_CSI2_DT_RAW10, }, + { .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, .datatype = MIPI_CSI2_DT_RAW10, }, + { .code = MEDIA_BUS_FMT_SBGGR12_1X12, .bpp = 12, .datatype = MIPI_CSI2_DT_RAW12, }, { .code = MEDIA_BUS_FMT_SGBRG12_1X12, .bpp = 12, .datatype = MIPI_CSI2_DT_RAW12, }, { .code = MEDIA_BUS_FMT_SGRBG12_1X12, .bpp = 12, .datatype = MIPI_CSI2_DT_RAW12, }, From patchwork Fri Dec 6 08:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847985 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 B85C51FA279; Fri, 6 Dec 2024 08:27:30 +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=1733473652; cv=none; b=l3IfhKgNwuKZxxPD0yuFflgKihSyXQEWBeDmjD/ghmxAA4Ogth/2id0qK7GF8nTDjtI50ZDFF9TucvIHj8Rn3ri27h2Muq5L3drXlDU34HVv1RnhuVp32fowZtFpk452MXd3Rrif5auCpXugdJQKbgPF1ehO38X/Plh7s6lZL5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473652; c=relaxed/simple; bh=2l5KAyuf7uxOCItYJ/e0vlOdjvj5bF5botLs7Wr6H1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mreGFS4koyh93W7QmXw8xucH2r11PyLsrNMzZQARR4xio1Jey1ViVhXT+NV6wWCnxEuHUAVNsy36Ged1zFr2PER2D36+jdR4/IUXpeHiZnycOioctLXtWQvwD4G14/56q+m/E9KcHHCD7e9WwvPSLugyPZtAynAHgTwGnRNCwzw= 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=m37XbWz6; 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="m37XbWz6" 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 EC9AA1B83; Fri, 6 Dec 2024 09:26:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473610; bh=2l5KAyuf7uxOCItYJ/e0vlOdjvj5bF5botLs7Wr6H1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=m37XbWz67tXnIoCFcRkwC5hSP3z9Fjrjn5FqkpjC9vvexS7iOY0hpe8/SnBoJ02ID CSoR6n7RbL/jZk5q37u62zsXKb3fQrFVWtfvxDyCOUsAdwHrQFthClDeJDDDlsVIKw MDnpHoHJlOKs8HafwWaZ4CLM23C0yCw5iXxmfiZc= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:45 +0200 Subject: [PATCH v4 09/15] media: i2c: ds90ub953: Clear CRC errors in ub953_log_status() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-9-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1319; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=2l5KAyuf7uxOCItYJ/e0vlOdjvj5bF5botLs7Wr6H1I=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVeE9OpJ980Eoi+hdYVyaIC8KJFGcsxthifb XjFkvixipeJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XgAKCRD6PaqMvJYe 9cxRD/wIYWQylHzbQK/LC7CGqryRLnHARZpEop8h3X4UuAzcdVKLF2Ldz1/wXWMNjo5Wk+8sgeQ sTVg7+44K8ObqqMIErrvOytN2ENAEwd56h7fHkZ6Ar2w4/ypprYSp0Ul3fZKMORcdNDE+XpLZgp BiYc21/EB3xzdKh+o+jOdakrVHWJY9sL+Zw5qKC9WvPwMLsDmhsmoJdRc2oEjdCURnAk5JxeT29 CSypD2Njmzb+yc7YQhziw9rTqwgcFNjihwpT3FcBCQ1/TQ42i4vTd0WRGsQgGQOottC72YVcSyj WlwzP/Jbf9CLa6zWfFkInN5ki74/A+pwGYr/lofxzOnIYIz3rem4s8HlzmF9balyHS7Pm9Y6rWV pLeEt5rJgt1+7GPeNQvOVuxjSRyo569P+ORqNAMmKlJgEo45d8V9K40+h4mD4kTaJGavrsLWqDf cvqhqFJDSJNtoXGCg0X9h8xCvdVOnA2pev9vZd3/C5AyWXExV7MVDm20gSVbX9fE0emHbfJ2Qps gbX7M+dSsh0KVgXtHEdrlFKFxl0UsTTp1B7pt8wmWDKMHFM2VsySvRg4dPPYW5fAcCtJM6In6a6 1WL1ICePT96DME5krZ2yfwcsjaORa6UXIcbHM7WE9tpNQpBdPnuZrO1bw3lWn250XXjijUuDj4T 0k3qS2inV2vT/xw== 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. Reviewed-by: Jai Luthra 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)) +#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 @@ -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)); + /* 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); From patchwork Fri Dec 6 08:26:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848212 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 BC21A1DFE16; Fri, 6 Dec 2024 08:27: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=1733473653; cv=none; b=p4ZPZDzC6ILkUTM9PXd2i77Ypzhd8xMFbxnGNoEFglcfI68kmSPwr3G2zfdqJ8+SFyv05YGtoI2XcjCO0P3g8ZD2PV3Y8GFMvjh9EJIhOr3Oj/pOg/fggM2KCrpmo7H4dYSxCVmWcvD6gkf4lOcHsm8MbR+687QPFPPy8ADYoIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473653; c=relaxed/simple; bh=dnmf6wU/4o7xocF7aclEiM/jdJ6eD4w3CXKP8olVIbo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j1ClqQMhSC7V0Bt+1enXwmDkGPcn20ysR3p+dRg7PWpEJT78g366j1prkmj7OegUypgL/XRaM1dPI2movl3uRfmiRYPBkky11MnLGoHUMpnTz63vIF8Vu0yZTcBRM3BGu833ofyyvJW1BGM2RufN0OsUAacFp6wfug/8/G8+uZ8= 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=ZCWg2UOP; 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="ZCWg2UOP" 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 876E474C; Fri, 6 Dec 2024 09:26:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473610; bh=dnmf6wU/4o7xocF7aclEiM/jdJ6eD4w3CXKP8olVIbo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZCWg2UOPXRkMDMRAlGPiQ949o76D5IvStpMuSUaTTRa9cFLIjcf9wBek1jyh5Yvbm OOrV0ECNiV17LhDGIeN6yv8+mwYyElT4kl1qOHZ0Vzy8T5jRST5xb2I4/kt098aefB 7tVL/I8zTREODsq61m6/QHndvdRgO+iwVuxwDxMU= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:46 +0200 Subject: [PATCH v4 10/15] media: i2c: ds90ub960: Drop unused indirect block define Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-10-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=910; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=dnmf6wU/4o7xocF7aclEiM/jdJ6eD4w3CXKP8olVIbo=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVfL5aDwPygpfLgxwozIjPTq8f0b/NWPXmGw CwuYYgl6dqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XwAKCRD6PaqMvJYe 9YgbD/91dM1qNGxjpNp1+G6KQij6AChsVVa/9mk19P5K/jewOqg1NJNiFNSAXiwCl1L1Df8m2br Ma/AfNSWhBWQBwmxAhU6UX/qeXHOf98d5s8ymK9Hdz6YlpUQPiTohnZKpIutT4d2i/5gP3Wll2H bVXFKNs0f+rxesB1iuw+2zPOQVBeS+oTLNH2OYAscGfBy1xqwsFRUFImxt3wY0AlE7+nC9wLEmE Bzl4lAerZRnIT/hiWj535zwZ7sYr0CZZLdsLJkQXI1iaImw9FvK/Q8FSDFSxxxCjmuNXTKriDar Ke9JQtKQ8hB/wgKNE16APfbLfcyWozM3VCVv+C0Ck6gmJVgo71NDqTvxhLU0yw45dnZBErli96P eGAp/kaaKYyDn4Y1CK2co7uwu7d0hoFGfgcDMqvpwsNDhbElbMDu98g+Y/yHYvdRZjEccbCgDM9 cbTQE3WPHXMWl8I7gC3w9zT9fbwfQRE2KbmrWgDPhYINfPtpmqzuau4DrzZA/CGwHS+tFSIiAHQ BtFO72TE77SXmYyECX+4dvyDaYx8KJog72JwxOUHb92kLFEwQ2UATuvkSURif9Oxcv6erkrd6bD swQ/r3LFDmwaqI+sbOcCS406umGHI7h1catCsA5pWQjztgXXtEuqbH1l2gxFGkgu6dOZnTxUvvw R3YEaM8K+qTRcYA== 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. Reviewed-by: Jai Luthra 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 721898e5c913..51b4aead6ac6 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 /* UB960_IR_PGEN_*: Indirect Registers for Test Pattern Generator */ From patchwork Fri Dec 6 08:26:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847984 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 D75E51FC7FE; Fri, 6 Dec 2024 08:27:33 +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=1733473655; cv=none; b=aay3um7Au76sra4q3Th8dpzFliJuN4gIvKQJKKnalhIOa6AXTbHZ+T7acpfTrP/gJ+MFdCNMlbJHMEd/BXZ0VXND+R+qtu4gqySMyklyOdTSpFNRKEmOcsOYMDlk31ut9gJks9TblJEzCq9DxH6/2HAA82Ho+rU1HCJeZPkNrcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473655; c=relaxed/simple; bh=RYU/Zn5ud6P9uUYX2gMHAgrS1tNcKPspcgZ5Fhzg/Ok=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SNZgG++j7d7Xu3+ajrinRjpenJcqV9WziD7mmhthVU+Tt3hRJf8zVQoYhSZSAm6ktkrgfxqyixmqFmedgWCYAwvzl118xUBmmpmspi1b0N5eAdoHV7Q4RtOCuvvOLRQ+vQv/DIJnYXYgoraApbKjaOjaGpp42n9qkoc8HzSSRUA= 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=JGk94H5w; 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="JGk94H5w" 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 229D59FC; Fri, 6 Dec 2024 09:26:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473611; bh=RYU/Zn5ud6P9uUYX2gMHAgrS1tNcKPspcgZ5Fhzg/Ok=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JGk94H5w6kIl9NddrV0AQQtEchyVBxaBHLfVuSnpmjC/0aQ+QS+8Y33P15wCrDfeh IL1eXB1CQqZ36/8v/ancOsWTfSn5XTdAE+pVwoOYyYcfsiwOXvzXTimR0CnAG/NCdY NZK/B1FpnOs4IpGJDYgeFaOOdkgOsiKajBTs4ezI= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:47 +0200 Subject: [PATCH v4 11/15] media: i2c: ds90ub960: Reduce sleep in ub960_rxport_wait_locks() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-11-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1092; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=RYU/Zn5ud6P9uUYX2gMHAgrS1tNcKPspcgZ5Fhzg/Ok=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVfmO5H5Xl9ac3uO31GNs2TeFtKXqTK7YcjU gl8yJF85n6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XwAKCRD6PaqMvJYe 9aCHD/4p53f0HG30DIypXKDRI3AfupjVXoKgss8qyvtTB16EdHGJlDcYubFPfIwWrS3LZbaP2sM GVW0vZ6OzTuZxVDVy7caksRutph13Dul53eWgTR6B0gHY/R+UFJfe8+yVL7dtauJdEDF9cSHcLr Dv7R3hnHSdXGzbW2nDXAoqUbsjQ0SuMk25ThsQLnqo6YGVihPx05C1iwlv3r3taoDTf8MSPP/id THjBm9wKowYoL8nn0j2SDP1+xgfGXMuR7mfv892ELWQp34K3JaJoung6zfKzk4vEaHTJoo2vW7b 4e8tlefo2Nz+mNYNUKLEqxcmwwUy3+najtxWDCSiUZYX+RCXZ9q+FKjHp4lCQ65dFcRM7sVLdlC Q5y5F/xpYk7QinngcYAwc6OIaFZ4gRCgq7oPWv4PaOaXKYKMUOCfKNdlM06ChOov2OcVqI+Rrc7 mp9quN61niCyz8X37+XObY6Xf1uV+wMcrKknZ/+nvtkCQiUqN0HDC3cBK2ADzbeXMDjT7PilubG M7s8rOts7tldMY38m36lL0IbKLksNTyFQNZ6JfLqnKLF3eadNw34fMtp+THK7G9G/f93ChX7WIP Yu13qYMUpK7CCP5HcCFkAGkZHo90KcpGkbwLjfDX7AXYgaInddlnBEMHP2Tey2LY6+vxtBXgyvw rfs+1afjoox2u8Q== 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. Reviewed-by: Jai Luthra 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 51b4aead6ac6..8e8cda4475af 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 == 0) break; - 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); } if (lock_mask) From patchwork Fri Dec 6 08:26:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848211 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 A1B991FCD02; Fri, 6 Dec 2024 08:27: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=1733473656; cv=none; b=YIApQ5vbF7hQmJ0R6G5AF3KPvxBT/M992d3hHVLnMW4Ef4k/7Xm2ZAXG6+aOCMQLjc8rjrjDmRYXNKeli97nYZgqSzvWOi9hV/HE2YzLgpNsvRUXVcVfazDlP82KUVnCsAGSebVxWLlejXHZWPagaIknCWRphG+GgLlE2+72HRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473656; c=relaxed/simple; bh=5COZwvSMdK8s/hcEQR7wWr/vduphQhcGiVXzN9pyDuQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q5V+T3ooPPEalb585HgXTEjajw2F3fLKQigM4sjeSsmvvosDKq0QJ/CPTbp6kyEpOZcQs1KH3HVDqTkYCBVzGyNIzg23CHzp/Ggo0wSBZ1sSRgxic/jWaQJrLAHC0ZvwhkqBGBVSGeoSRZv0uR1uruiUVLaG4lVkvAtgxHtkMbs= 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=oDzVEB9K; 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="oDzVEB9K" 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 B35D81B86; Fri, 6 Dec 2024 09:26:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473612; bh=5COZwvSMdK8s/hcEQR7wWr/vduphQhcGiVXzN9pyDuQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oDzVEB9KkZ8oR/InPTujdu3wzcluxsMKYnOlcgSWIXEgI6zW5pTjSU4+9B3QiQ6xM iXjawqgrDhQmPEq0CS2NsDBPOHP8PGt1BNd8druAScHFqNsIxgqH6JVg9y1XVU3ouZ lcapiXqC5LiIrDAo8e4CF4IKCPvkrdFBJ2kqfoNI= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:48 +0200 Subject: [PATCH v4 12/15] media: i2c: ds90ub960: Handle errors in ub960_log_status_ub960_sp_eq() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-12-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2271; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=5COZwvSMdK8s/hcEQR7wWr/vduphQhcGiVXzN9pyDuQ=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVfvvGpuzoBnLloZQjJB+o18ZamiH29jfi0R wYmdE2F4H2JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1XwAKCRD6PaqMvJYe 9eGvD/4pBw8lsAyCu4HpP/M3bcChgVQKuZFCqAwQcNCoNsxAPuwYXBmV0HJg/7ZmTg3R/DgRu7E bTYmRYiWNpjPMQS6rEosSqaolF5/RIupCD+Hpq3MIRs+6z4o8mdf1Agm05UoUDIGP81Ht+cOD0H SnrrXEIgPDP7T6MBKTZt15s7GqLQUrZEvQz5fpHW015svpGEXO7Jufs8RZTAKeZjOFeIqr1StyK fNFFUy+epHe3Gk8+qYRx08ktcx/QSzxuBTDnEsY80eP0PIFg53lUad1Kjg5HQuniqjDrB952DEf exsA3SN6TIQ0ZX7v81IV7dIl4+CYAWGXP2bsi+zuvDhp32x3JRBPMkzQAOM2I/pZgPQ8bomHw7V Z3ARdMTaixC9cuUcR+5uTrs5DycIF2CbvldQbmwS/4gCNOrpx34yqWR9r44aQpTukLB2VPo2XKF r//Y6DTGvieux/LEU1nYgkTO4oO9DeE0yxO6gG8H6oIHAmEGIowUB+TWdSfW0OOQb8l53vndl06 oHm9rQWDz3mG8Z86M0RUs+W0rChLV0Z9ldabBBBCl0KwgqZ5fqrmFq0QgZsIX8k65I7M6if2vjO 8ODX24+k+K3PnkanYjVUpAK976i8/+gQfFcnDdEIcxV+l3EmygwwnzemDKmP0oS63cGdZWSrbSx c31UE9WHVpjWvXQ== 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(). Reported-by: Sakari Ailus Link: https://lore.kernel.org/all/Zv40EQSR__JDN_0M@kekkonen.localdomain/ Reviewed-by: Jai Luthra 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 8e8cda4475af..0db4fc980912 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 ub960_data *priv, struct device *dev = &priv->client->dev; u8 eq_level; s8 strobe_pos; - u8 v = 0; + int ret; + u8 v; /* Strobe */ - ub960_read(priv, UB960_XR_AEQ_CTL1, &v); + ret = ub960_read(priv, UB960_XR_AEQ_CTL1, &v); + if (ret) + return; 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); + ret = ub960_read(priv, UB960_XR_SFILTER_CFG, &v); + if (ret) + return; 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); + ret = ub960_rxport_get_strobe_pos(priv, nport, &strobe_pos); + if (ret) + return; dev_info(dev, "\tStrobe pos %d\n", strobe_pos); /* EQ */ - ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); + ret = ub960_rxport_read(priv, nport, UB960_RR_AEQ_BYPASS, &v); + if (ret) + return; 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); + ret = ub960_rxport_read(priv, nport, UB960_RR_AEQ_MIN_MAX, &v); + if (ret) + return; dev_info(dev, "\tEQ range [%u, %u]\n", (v >> UB960_RR_AEQ_MIN_MAX_AEQ_FLOOR_SHIFT) & 0xf, From patchwork Fri Dec 6 08:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847983 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 B88E51FCF6D; Fri, 6 Dec 2024 08:27: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=1733473658; cv=none; b=QqjwAxjXcLJT0fyZpvDxWI7pS31sySux0tv8ib4Wv3/qIzP3s1zervoZgZ1hh4ggQPNyqQYiZIxyNanftLlAfVYZaLYJh/HUGgpZy5cOEiKX38c0oZutSfY/Pnxto0+rGCicE3wsnYk2OKq2KZZIDfvGX7UxwPd9+l11tpKU0bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473658; c=relaxed/simple; bh=wawwTlrATwlu77FUSKQv7xr0i0QLJWn85E9bt6sA41A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WSMhGgqYH00GP0uui/LxmquDJXiJtk1iAR6afmPOhze2SHK6YqDtkJ5niTUSXskrPsob+X+yZrAZVv1LBB10KMj7ccespEFEGkY9C2xFKfVhb3SVrC/GB6TmGY+djxzI5fmbJcAyplGRgbUIszxTdPdaicbjwLdhxDWyYJ1+4sQ= 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=C/PDgfQT; 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="C/PDgfQT" 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 569EEB2B; Fri, 6 Dec 2024 09:26:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473612; bh=wawwTlrATwlu77FUSKQv7xr0i0QLJWn85E9bt6sA41A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C/PDgfQT4eVA6Lwkuv1VjeFvIq+d1ZHU7P43n2aq4GrgHKTLIeSbgVA7dOEAJvF5r iHUdkcBZHL+FoeNdf0B9TUMG/GRRPCLqtHDD7sUHc1WRFVioeVl8TLVUbFCaE/2tTd mne9vdsIRAcp8wB4WHe7vdS8Nyeaj78DHSYg+k/k= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:49 +0200 Subject: [PATCH v4 13/15] media: i2c: ds90ub913: Add error handling to ub913_hw_init() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-13-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1937; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=wawwTlrATwlu77FUSKQv7xr0i0QLJWn85E9bt6sA41A=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVgIo01TOohQgvPnFdvO7BBKWuIN4R5Ztks5 4Bv0NO6QcCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1YAAKCRD6PaqMvJYe 9c0VD/0c/G3Ly4P2AuQu5pGjRNxDVpgwdkbrWB8zyH9QPVZ0Y4SLOkPoZnzqqxxTowd0ucLKubG MVs8LQqzwl+2t8veCEGjevi9pMux5VcNaKswXVx5P8+A+A2Qez+jfJmrD805EsnyNKZJBtTw5oV gBBNbtxlkLYiNhsCPdq5ZcefFG72C/U2RiYLZ06UdDukyIbB4V5jp16wX0pzLfmNxbd3L5ZDLhQ odYaIKIenlMyflmhEYB+ayB+DRj6N+NBMDZN2IEguywydCGL+EguwPFZqOHLA/AR751oay6WYh0 rTmoalKIUzJ4m9xrxCHVcHBbdm3LQpMzuO790UwbjUhZZ25XNHnrvMJbW6pD4GTHIt3Vf/d8xC7 z/0fjqYbqJjfArbFGn2zLV3uf3HnLC7wJgUeXxkYC9JHwq4unQzJFFN0g2NfualnjKkEhesxtmk 4wrv0wrHsEW0n4t7D9NR/I2Fkh6jvlWwtF07aJGpVS9bfrwgNY5MnuSJHRlBU83b91l6iwPWJcl WDFSjceiNmMTWhEZrwFEt5V2L06SLgnZoYlL/VPQoo5urjKJRAwaKCJYVT7QXMbWiYVg9SVKMCm 2zQ7o3ukTuZY9xf9nUMF8T+q868dfrOKM4tV7aJi974N1Rwsc7GoTaT/0C0ik2LCQRhNMS+IoHc 59xc4o6FRooXfLA== 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(). Reported-by: Sakari Ailus Link: https://lore.kernel.org/all/Zv40EQSR__JDN_0M@kekkonen.localdomain/ Reviewed-by: Jai Luthra Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub913.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index b5375d736629..7670d6c82d92 100644 --- a/drivers/media/i2c/ds90ub913.c +++ b/drivers/media/i2c/ds90ub913.c @@ -8,6 +8,7 @@ * Copyright (c) 2023 Tomi Valkeinen */ +#include #include #include #include @@ -146,6 +147,19 @@ static int ub913_write(const struct ub913_data *priv, u8 reg, u8 val) return ret; } +static int ub913_update_bits(const struct ub913_data *priv, u8 reg, u8 mask, + u8 val) +{ + int ret; + + ret = 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 +747,13 @@ static int ub913_hw_init(struct ub913_data *priv) if (ret) return dev_err_probe(dev, ret, "i2c master init failed\n"); - ub913_read(priv, UB913_REG_GENERAL_CFG, &v); - v &= ~UB913_REG_GENERAL_CFG_PCLK_RISING; - v |= priv->pclk_polarity_rising ? UB913_REG_GENERAL_CFG_PCLK_RISING : 0; - ub913_write(priv, UB913_REG_GENERAL_CFG, v); + ret = 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; return 0; } From patchwork Fri Dec 6 08:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 848210 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 8515A1FCFC5; Fri, 6 Dec 2024 08:27: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=1733473659; cv=none; b=S8TgpnADrR5VpgJr3oeuWC2L1mpZRZEG7FshqsrtUPSMY2b7lsT3J6qsxvFLgCmqae82KC0POlum2IY04lUiArfRpMrGFzl3kH/EPKWRwR8uEJumd1pQpkoDjrK9O3KCW8eHN4lU0Wi7Q0w9PTXSQQfESFHw/WwPwUl3eSoBNpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473659; c=relaxed/simple; bh=NPmRcXS1rgzO9Z3lDRnsWUS6ctcuHylQGatMT0LfE3I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tbdyxyhJfhcPBAVtydb3w1DazWFo8aJQazL7XvROOqPq6b7zNLD8VHSWbf6t+TUZypBpNb6TiDrvc6EVPz7LpwfGnY490tgWB3OCehaFVwSTEwvAtmbXL7KSBNf8+KiWN6gfj0RahiHWHVfrR4cPlHkgCKmqKIfC8+b/oRmJttU= 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=bDntgFnV; 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="bDntgFnV" 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 E91751B98; Fri, 6 Dec 2024 09:26:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473613; bh=NPmRcXS1rgzO9Z3lDRnsWUS6ctcuHylQGatMT0LfE3I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bDntgFnVHZm4IiNH18rwpfFVZwA/UVrYQd/rAXr7n2OG421doVZnkb6FmhQvadhJa +Ugh1lqdsnNtyLLzkyh3KrWooP4dAGABBdsmiyQOfg9+dukvIJvqrYG7JtMmTySVw+ edwzGehADFHbhrxnennsStLNITMOpt/4zGNcqCQE= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:50 +0200 Subject: [PATCH v4 14/15] media: i2c: ds90ub953: Add error handling for i2c reads/writes Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-14-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3608; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=NPmRcXS1rgzO9Z3lDRnsWUS6ctcuHylQGatMT0LfE3I=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVgETNHgXRmiR66VEiftzy26XkSNzq7YK/6U vWJ/mhagVyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1YAAKCRD6PaqMvJYe 9bLAD/9XW4M2p6SV9pbpI7BQ0t4RNjXr+SSjgLfBY+uqLkIqfu4B6oEe6sSvkyN0beyg0bphTM2 ixIOLiVrhblDcmtmSon/ESvZEXdSPDykqfN9hm65q4i6o7lqJLchOVzMizXbG4a6Hptl+R2M85T /Ai0IMPdb5M8zB91WMam1I7kSDE65aZHBh+undAjBynqrafzMqYFFsDNQkk2cUK1evWnTklF1SO fyqrXhEsSSgJzPedYz3NfGlcd5t1TCmYfJBloH0lCOgN6u81RlsnezNXhY3fgWwXA2HDAGvCGQj wsrd+hh+AFRXL6g4Hc7D1AZ0O59+Bbbf4fe74wqhxs35Y0nRls1HOb6IiTnSEpICntBslDvIBkA 5odiKxKPbX/2LRFEOcIf8lKRJZWaLIwpMCzD2ibsbYY3hq+JuThWBfUpfo9wUwWVrqrFEckT5fy S1ruFuVelz3wsGBsHNd77uTz+wT04TPO6c56AXPlKD3gQfPnwNROVezuF0J3t1Dje9vSdD04mzT ZOwotJNPvsdsguwNnDsxfQtFvxmoP6moAC2ZPHigLO6M4+ULf4t1zT9fzV16KAD8HhoWK6zAKYY vSdNf0FRP6wSsrj2HhN7ysZqXLmz9HSdT7yk0bG/WT4HpxLf+AxNAEXTl2MJeazEmBIl4maxkda qIeqHGmP20ouTMg== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Add error handling for i2c reads/writes in various places. Reported-by: Sakari Ailus Link: https://lore.kernel.org/all/Zv40EQSR__JDN_0M@kekkonen.localdomain/ Reviewed-by: Jai Luthra 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 *priv) int ret; /* 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 = ub953_write(priv, UB953_REG_LOCAL_GPIO_DATA, 0); + if (ret) + return ret; + + ret = ub953_write(priv, UB953_REG_GPIO_INPUT_CTRL, 0xf); + if (ret) + return ret; gc->label = dev_name(dev); gc->parent = dev; @@ -970,10 +975,11 @@ static void ub953_calc_clkout_params(struct ub953_data *priv, clkout_data->rate = clkout_rate; } -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; if (priv->hw_data->is_ub971) clkout_ctrl0 = clkout_data->m; @@ -983,8 +989,15 @@ static void ub953_write_clkout_regs(struct ub953_data *priv, clkout_ctrl1 = clkout_data->n; - ub953_write(priv, UB953_REG_CLKOUT_CTRL0, clkout_ctrl0); - ub953_write(priv, UB953_REG_CLKOUT_CTRL1, clkout_ctrl1); + ret = ub953_write(priv, UB953_REG_CLKOUT_CTRL0, clkout_ctrl0); + if (ret) + return ret; + + ret = ub953_write(priv, UB953_REG_CLKOUT_CTRL1, clkout_ctrl1); + if (ret) + return ret; + + return 0; } 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, unsigned long rate, dev_dbg(&priv->client->dev, "%s %lu (requested %lu)\n", __func__, clkout_data.rate, rate); - ub953_write_clkout_regs(priv, &clkout_data); - - return 0; + return ub953_write_clkout_regs(priv, &clkout_data); } static const struct clk_ops ub953_clkout_ops = { @@ -1091,7 +1102,9 @@ static int ub953_register_clkout(struct ub953_data *priv) /* 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 = ub953_write_clkout_regs(priv, &clkout_data); + if (ret) + return ret; priv->clkout_clk_hw.init = &init; @@ -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"); - 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_SHIFT) | - UB953_REG_GENERAL_CFG_CRC_TX_GEN_ENABLE); + v = 0; + v |= priv->non_continous_clk ? 0 : UB953_REG_GENERAL_CFG_CONT_CLK; + v |= (priv->num_data_lanes - 1) << + UB953_REG_GENERAL_CFG_CSI_LANE_SEL_SHIFT; + v |= UB953_REG_GENERAL_CFG_CRC_TX_GEN_ENABLE; + + ret = ub953_write(priv, UB953_REG_GENERAL_CFG, v); + if (ret) + return ret; return 0; } From patchwork Fri Dec 6 08:26:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 847982 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 E940D1FF600; Fri, 6 Dec 2024 08:27:39 +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=1733473661; cv=none; b=lipEqW1PXftukI+zijwr1Vk5+Qm8KfEZJ1FbfutKclKWKj/2q1PHgycmdZJt2X3FBjkfRvqVF9knmKai8476z2BUZzKPYD3byoHKGSlPE8gcL8Hb0z+Kbc1uSUUfIpyJmEIOdFLNPZkF4M7g99U+5j6eFRYIW/p6GsP9Ez+6mdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733473661; c=relaxed/simple; bh=tx1oR0yR9dSW0a0oGSanl5R1iFOs2cxUamF2IuKTL/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cflOSnhL94P2mJFR6UyLaHP7XNDDmqdCsBijBdxBeyPWBzkqsN3DgZ2H9o6zqJDokQg0TXx1Bju7YCSaFWK3GBToY1KqL2EgjALeYilQXV1CtpK+WYbYBo3AP4nNUMH9njcHEtCO35dm19qSnN2p6nS9laxvzoWmUpApnpbreE8= 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=C1pg17Ch; 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="C1pg17Ch" 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 899AB1E0A; Fri, 6 Dec 2024 09:26:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733473614; bh=tx1oR0yR9dSW0a0oGSanl5R1iFOs2cxUamF2IuKTL/M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C1pg17ChMDvDv/8x3PF73bGq3GyVmKHSI7upAtkOJzKLfWtWppgf6KmlqHkaBWMOF cxmbookeVvBEh2GSMcTGOYgl+B9CicfvKQCRkrCx7jFbuL8gxQORP/oQ6RnbGqcYce TEtxG6KR4BKjOrsc9dnWXf3BQz1myDPdeBZfTpEo= From: Tomi Valkeinen Date: Fri, 06 Dec 2024 10:26:51 +0200 Subject: [PATCH v4 15/15] media: i2c: ds90ub960: Fix shadowing of local variables Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241206-ub9xx-fixes-v4-15-466786eec7cc@ideasonboard.com> References: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> In-Reply-To: <20241206-ub9xx-fixes-v4-0-466786eec7cc@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Andy Shevchenko , Jai Luthra Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2252; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=tx1oR0yR9dSW0a0oGSanl5R1iFOs2cxUamF2IuKTL/M=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUrVg3gEkXUWeTendUfq+hXJSRPFKXvlOyKm7g VIpDzVrU6yJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1K1YAAKCRD6PaqMvJYe 9cwgD/9819hQ26U7+CZcZxmSY7BvOlbVNJ7t1dKJHLxktalGLzaUd+b/16y2VXGjqLpJcFGXXGf JgGHTLdRHJNvB0suatsRPvef+UX2DEON88KNN5TYRX1bwFfJDaoPR946YiCSu32FvTtLQrPkn3W XZ61pfz3IIyCIh+Xi1incrvWH68c/FgTkeVRx8rIapIqN4uQuRIk50U1318tvxt56JB85i5M2Bj 3DIiYUqd4UpiND2IbWwcYdoRY7TNypEBw7f/Jmwb3PY1JLZcQxdNrfXu6l06g7N4OPZHNaMH3BO HOp/eS/23DiKB5itVmiXI5BMPhKiRgh4l77gkQ9vJYoss4qoIBE1EfU2T+2upoKcPJ14ivpjZkD KrJfhYJGjCnQ4j2bG+YIN72hLYM9v38fLzbQU1f7hVSVnsLqbqi5nLLULf5z+vxdNTyK2medrze SjXRmJRfVvORBjwjGbStJ42A9DjEI80bxZDRMyN65Bqdp4CbFLRDTolXgIrr3e665pgKzpohu5u NkoyKvNIg5/Yjw/uT2z2eC1Wq8gD1iFZLM3V8yOyrmfGC9G2xd10wCG3tc6kt+DmHihUJznl8sE tYKWiKA4Fip4caJePOw+bNLfu5F1GvVGgQvn0HBRmNCImuIJbmqfETMdM+SUGryjNP/tlgyVq1f GApgVOPdHzhC6iQ== 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. Reviewed-by: Jai Luthra 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 0db4fc980912..4cd31b1acf14 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] = {}; u8 vc_map[UB960_MAX_RX_NPORTS] = {}; struct v4l2_subdev_route *route; - unsigned int nport; int ret; ret = ub960_validate_stream_vcs(priv); @@ -2519,7 +2518,8 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv, */ fwd_ctl = GENMASK(7, 4); - for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { + for (unsigned int nport = 0; nport < priv->hw_data->num_rxports; + nport++) { struct ub960_rxport *rxport = priv->rxports[nport]; u8 vc = vc_map[nport]; @@ -3041,14 +3041,13 @@ static int ub960_log_status(struct v4l2_subdev *sd) struct device *dev = &priv->client->dev; struct v4l2_subdev_state *state; unsigned int nport; - unsigned int i; u16 v16 = 0; u8 v = 0; u8 id[UB960_SR_FPD3_RX_ID_LEN]; state = v4l2_subdev_lock_and_get_active_state(sd); - for (i = 0; i < sizeof(id); i++) + for (unsigned int i = 0; i < sizeof(id); i++) ub960_read(priv, UB960_SR_FPD3_RX_ID(i), &id[i]); dev_info(dev, "ID '%.*s'\n", (int)sizeof(id), id); @@ -3082,7 +3081,6 @@ static int ub960_log_status(struct v4l2_subdev *sd) for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { struct ub960_rxport *rxport = priv->rxports[nport]; - unsigned int i; dev_info(dev, "RX %u\n", nport); @@ -3121,7 +3119,7 @@ static int ub960_log_status(struct v4l2_subdev *sd) ub960_log_status_ub960_sp_eq(priv, nport); /* GPIOs */ - for (i = 0; i < UB960_NUM_BC_GPIOS; i++) { + for (unsigned int i = 0; i < UB960_NUM_BC_GPIOS; i++) { u8 ctl_reg; u8 ctl_shift;