From patchwork Wed Dec 4 11:05:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893563 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 E1E4E1B4137; Wed, 4 Dec 2024 11:05:46 +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=1733310348; cv=none; b=MC1vuOq12cW3fETI+N1wKAooz5X1HpX+FAEdPiOpoibwVQvXQgc3fA73fujlpzPtcOBbDE1TPHKUDXD+sC6pvXJYPscQMPA+LT8sc73BPWgilsoxnLfDPcvXw4BXmtwMz6iwFIXSMnj9hQQvtWQxUmjJD5VS0A2Zj1hopBmEFCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310348; c=relaxed/simple; bh=9Q+3PN+oneMKxhelptmjC5NFHWuyRqKXnKfK75CmdQA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d2D/xUv6vKM8Fcjs469i1qDn2j0QoRBn5DOYGM+M2YBG5IqjXHG94X2OljJj3Ea3B2yEXZZlnwC3c8CKYyU4zHr8Ge2QpoTMtY9hbhfdbW9FJEQ8jA2zYsIe4fsRXJA6jYLcMezDUniLkFonUsUFNGhL7QUbOuDZ9tAP9AcR5No= 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=Oe+XQYUm; 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="Oe+XQYUm" 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 7E4FA9FC; Wed, 4 Dec 2024 12:05:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310317; bh=9Q+3PN+oneMKxhelptmjC5NFHWuyRqKXnKfK75CmdQA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Oe+XQYUmbcpz24w5x9pat9Trho1+HN6/tcmsmXPGy+b3rTGhZNkEw+pjlWZ+whDjC 5hxLp3QRDiZUjJ3E99Elo+xxH4KyTQDRGFZ9MUL0RfUkyopcQiC+ESQVZj/t7VVpRF mZ0xDAPCF0rtLEPerXVcFcZ8mDqOgcQaUWLTehQU= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:15 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-1-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1705; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=9Q+3PN+oneMKxhelptmjC5NFHWuyRqKXnKfK75CmdQA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeBYVp5Kfg9W7I/Qp2qHxiACwAa47wM0BRoh 5lxVibt42iJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3gQAKCRD6PaqMvJYe 9XMbEACQ9pwMYU9SaQdXTYK+M49PDywbL5xCbOnk7bTQjSc6U77i1AR9nMAQSxN5EivAoBczkl4 RZzhaFt33HkIQI8QerX2POTtu+vaO6UYPjeWkELNwbp6VQ9ZWHos1gpVtAN00VcAOxxmFoeD5ld yg81gyHY6PR3w0IUvhqsgR8XXqRr0gKWrPYndGpzOkSnsW/o65JFuxSJWULFTuk1z+i9ZaBkp8Q dmePwIz7/BGpMaAF8laEXUSiixF+7kMZKvnaTz/Ylyygpt9+LeuIa2WmfPcp6ViCtZ3coaYwYOD YnvSi0PaflK8s7NHvMssI2zchX0IEFPV8A42wHDwz72Xluklt0NAxMcDSeQ0FOe+epvyuUALdLN y8hyHIWwid+FtcvHLEfeDycL3QTufZr8m+Wkav7o1BO/vM9+zgugE/Nt3mzzqDWUTBCUQe6kICT o/s5LJfcNvCEiEz3pGlAFgaWiqrUWcyTtFX4BhickpPLH6P3rEJpSAgHKh/7m9PabNjQ3esUWQb sAf9gMY6Zt3PcV+gxa3RdHHF2kGXvWU72kxntzOsiU5+5xPFu2J1r+NknFddJjakcSvkArtb5Jc FakmFfIaMS5F7gwWm/sxh1SodJUZTZSOvKyu+qNmJovfIKnu25UU+l8cP3gTUJaRCNktKzEYUYr bu1fplZHVVksbCw== 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 Cc: stable@vger.kernel.org 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 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 Wed Dec 4 11:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893564 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 7A49A1B4F15; Wed, 4 Dec 2024 11:05:49 +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=1733310351; cv=none; b=iM9bDDMmfeIipzo4N4jBHbfKdAn+UMMEApXWHnmoFpHT/IsyMNpp+o+MM0Eukufo2FAGIA+LqC+3TVgXnk3VX8lWJnU+mtVvCpFNTyuwB4m4KEe9v5Yjl0oqm2GepVoqTfzeyz5vzLdDblvwRlHeGhc+uwT/9qX9SZz15mYtPsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310351; c=relaxed/simple; bh=JiGQ0b5hfc6zIlLKLwEQZtJz1RrCwE+wHub95g3gf8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CBli1TQoFBThbf8F43YraTDMyWxjne1uOXkwlUFPtxyMIpfdruzR2KFsB+ho3PjvxarYWuX59mti/jUBHc1HmmhMEuKc/7oDk0TS/HHs5ZxSmgNctfOhDiBjnoVrAfjKktY9gtvwocjUiJWU064dixSv0/YblK9bZcq3CzTDfb4= 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=Robn0ufy; 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="Robn0ufy" 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 27B25B2B; Wed, 4 Dec 2024 12:05:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310317; bh=JiGQ0b5hfc6zIlLKLwEQZtJz1RrCwE+wHub95g3gf8Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Robn0ufyBOG+hqQdgKF/N4beJb1DNDm9RxsarXTM7NGftKcnjHYN+J6jrGmyMiQoX BDRRmBRsDcTA9R4r7QbXHCNZNvMNNr4Q/b2i+jlR+7UTmyZQ/ofQHCBgo5WGW36UZv KMk6lgZC8Nfd5oPQapZ6d+Wdt3g8GHrUkc+9njZM= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:16 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-2-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1341; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=JiGQ0b5hfc6zIlLKLwEQZtJz1RrCwE+wHub95g3gf8Q=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeCRelz6rQj2edvFCi2rJaavv+P4syT8E82O bvOHkiM7p2JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3ggAKCRD6PaqMvJYe 9QP6EACZkXJIm8OWPDB5CPgg9sL7DBp6UbTF+C5UgJ64YDMgOM2gIg92Kk8p47qRwu8MzSqy5Qz dMvwwKzfkeYI6SreqhiSpIFNB1dF1TowOKcuEd1oQPRTKtAdmPkRhCgNjorPmLnLPFPmF/mpn8e sAm3HkmJ3Xwhx9qTmzs/oRNs1hm/iq4cKXbxTiW5tE5vUwOmNvTjDWFHKwDlBtDdn+wMkA6BfXg BSoSIkMxHrHY/fqWnwrovqaDeOcCg59ZlMBISXlyzPgLalOtWBnBu53wxl+GXOwv1Ic6ZlHEGB7 iyxr1z6UbnSwR0H6VLrZbMrx41q4iQXgRpEsngyzg9fsW6hrpsexSMWWCaX/GDkGJ7sUIsW8Ye5 QDnHXQlhAT2IKsxyXprugIM4HkFHbTqweMA+DOx0djlFKKhPgLkplfrX2OmEx8SlBnMXFkIyZ4Z YdpdUwST9TtA77PVecDk2e8S2+xRtcTlFjyU4XV8Q9QGY2lmR327dWdtnCMuoZuxHwnZNB8O6S6 lzMIIQ0ChuWXzDjD6pUQKOTkWMykpJ0iZ8H6J/ILtmKCh8KUgXhYG9RIubjHQUXLcWxFKEyRHoy l1i5uPHNFZYxqTFFKnz0CCjxIgd8NXo94wAU7uhmQI8tcYzsLfTrc+tDrumg5c2PTLBvEZecLbg n/8nso7MkHoQtFQ== 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 Cc: stable@vger.kernel.org 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 @@ #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 Wed Dec 4 11:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893565 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 10DBA1B4F3A; Wed, 4 Dec 2024 11:05:49 +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=1733310351; cv=none; b=hpIDUSz2JQTTRVu+mEwG3yKQ8RJ5R+oqJySJX10j2Ux0ofxli7TU1dKUg1Yd4jRbk3o9t/VSgriaLvFGS2Ar1Hj1385LLqIpxo1wMTrib9b8Irg69TUDFo3T3t8+00egwXo65u6OtBp2d5sObHUGlrPH1WGbJms/YobP0gCfJ2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310351; c=relaxed/simple; bh=xIzfZpPEYKwaGmQ1wVvwBLTIhY24t7t/JYtth8aWl+Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F3qzEt7HOCevDHtlga3Cq46JBsDS3caKA6eENmXjBChulf/ph49JEthPLot0OW2I3EIUZg3hVxpmKVNotNAzx+7/UxO1UTset5JW1hH+aSEjFkjUO4I1trUjveEtBTrCKWuFlJpUt723EncPijbA6noWII2mV09ZCmPlwi1cWHI= 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=jyVEkWW8; 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="jyVEkWW8" 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 C0AD1D04; Wed, 4 Dec 2024 12:05:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310318; bh=xIzfZpPEYKwaGmQ1wVvwBLTIhY24t7t/JYtth8aWl+Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jyVEkWW8fgq9PrtMQLyOOovtn1Snsyx+HeyjvghRBz9DUtaPdg0XsHgVzVTFPDFbY vq7gXPPqv/DrL3RypMeuF4Jbpk07EiUsTWUY/jLEtsG0V/SF0VzD5xIBTli8KB5Snr gmOZsfMW5uJc8At/tTKooECkQPjiLaDTGTKgq+cc= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:17 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-3-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1680; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=xIzfZpPEYKwaGmQ1wVvwBLTIhY24t7t/JYtth8aWl+Q=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeCrwuDRfLsIsRWvmZPRxkvWteYpRXpcbJlV EvY1mJgxJOJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3ggAKCRD6PaqMvJYe 9Q4xD/9PXWkKEgSwQx0exAQ6eBW3jsCrJ3LYUGDoiqtm9qmnNPu/5vjRNPN/8+h3KL8ORZB+T/3 5Uv389m77V0IIzC58AJ1V3hTJ/F3KW9fUtGq1G7/XTj43OTYagi3FFdtpHQnyMkW19At8z45UQ3 4eIN7kMCLn8iVH/Xbb3+ZIfUZhenXDTqoi7kJ3yuD2Wz3oqoZthKNbT7fS9FcGJewU4TPwGObjm O3AvZH9kWiYairDTwuE9nv5XEWASXCyr+EGAQ2HzaW8fQq9hQDTBMkdViptg7Poz4Yc28EYTUN5 Uz8p75+va1onkguk5N58QuGzeEsNEnJmNqrjsPIaVch0EsDa8ABiKxNybXJL7YZOj5P/7Re9qQX DYNuZcaI5eUeziYPy5ShKikY+ZfF0nYBBTiLS0ioB2LywIQhfBCTkYzYcDRnhUj02HsheiaDLxs cJLKEzIhRNoExnIIcQgRze0nF9w7EkLepPyHepU6B4tiLQFdEkoQ46nSi+njP73vYMOTVQaypYH DoSDALbYQYURoWBVaFS4OlshtFkw96SfOtysyGKL5DtjRfWckoNlgrayKsJs6sjstJq9aZlSRcR h8oKG1oqAj74AF6aW5lWY7YAGdEjZDzXuvtOUXGPlk7q8pX2O9VKKRCG3JwvUAZEAOheXDTmDrS hqc7802yzofvRFw== 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 Cc: stable@vger.kernel.org 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_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 Wed Dec 4 11:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893566 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 749921B87CE; Wed, 4 Dec 2024 11:05:52 +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=1733310354; cv=none; b=fXBWqRRpK6j7R5DRP66PGCvKyXfdz12Afg06quQR5aH3pDxDzO/FvAyhRFvnSKoaZK+j27kGsH+1AjUtJmbMfW0MAMWdUh1zJyrG5gVLCdKtmAl81iHRmsa/+UfMV1Nybn32cvI4n2DDAGVy+GCOR+i51kX2CbBtMEEJ00lLbYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310354; c=relaxed/simple; bh=cHK+FvowlOFAeLxYTLErV9QO7P1rU8Vzws3yIpYDj/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oXqF0/300TG7Dsn+E4Xs3NNl6rSy0K7Ozz6GOkitpKTyScB10CnIkiMI+J5lM+hJpm1fjkAzzcdnZjDhJJG1CqdrfQYSHeltRKQ1PIMPdxSxvdzVeodOMqt2RgqIni5aUQZRprWiL713STm5wmu4+4I5J0Lwc6JoSPJNv0O1yiA= 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=O7Nj/+pj; 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="O7Nj/+pj" 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 67600DEE; Wed, 4 Dec 2024 12:05:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310318; bh=cHK+FvowlOFAeLxYTLErV9QO7P1rU8Vzws3yIpYDj/c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=O7Nj/+pjLh/Me1yxrVmtpcGZySsGAoHMk7GbixfuE4fwWAUnQQOBQ+/M9aRq0l1kb 9YO5cvHmO9+7N0PJ893aXmUV8oQMim6+vmyoz0cjtkRu4XC69d0CCVbms95qCArsWW 7/M6Mav09LUA5poDTKn77WzIPZyrdi1EmxKHp8X0= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:18 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-4-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=4127; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=cHK+FvowlOFAeLxYTLErV9QO7P1rU8Vzws3yIpYDj/c=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeCmff/IdOjYuhPXZI9o/v80viV7pENuYMod KUxv110AKyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3ggAKCRD6PaqMvJYe 9XsQD/4qeQlX04HK6glic51T/8oqthKz+Jf1My+M2LAdnsfGBDRpj1soaDOrmtnrjdx5bYeJ23s KqTE9L3VxmKWvIqz7mlTY4unqHfxcg0T63Q6uecbjgt2TIo5mLG1Qhl5HNYPZM4y66Ow4mQ6bPs KzaR5LojmgqtsWsBNFrIJXzjluo+Xz06omqEjr7Ol0vOYJx8uzjkTO1Lmwi9pS4YSBovH6WPyqJ dOMPST1KAn4BnNFcI2c4d+R/1VAAp8qmtCVwWLJY+5rXDiyeVyPuofNUvkTFxH9sd+tIECUCdDb hhTCFD3devq8ioV5VVAqnQ3NVJ1EFBcwDh1qnb8kG2aaJz7nGGPPYrlUaOEMjQ2TG6oxtH28HwH 6adB4/3HafLUQ/1NCWEgsQRQdtXRdWvdXfJfHqDpYkwOukPeV7r5r1wludvxWOt4jctRA+S6P0s GbEcRXlbXTWWVSkxlJznund/VdxQ+VBjJShNyRWtCixZpL9YW5PnoTMU3GuPvVIrLQd80+fEde+ lTOA4fu5JlSW0l5PtGIwK4iCV21KDjJYPUr3j+J+G/cuVdL4moxOmY2+rljyHEclcI1jyMO2gxg a1xUNfMfNnas1MGQQZlMIZlJ5cC1FIerxpTOVG0j9eCuM9EL0WvsE+MNRpnlq1Hb0tGdLdMMRwh eGhpwUu44WUDYDQ== 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 Cc: stable@vger.kernel.org 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 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 Wed Dec 4 11:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893567 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 2A7B61B87D5; Wed, 4 Dec 2024 11:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310355; cv=none; b=GL5UPgM18WeJLKb43kNJ13MAgVuuTmpUlL1kI6pRcQq3JuzyPYabtcgXfP20Rr2uqtfhrx1xspd4PwYFUyganHaJ4Z3mw5M7XId3v/o97v1rh2RI5USvbd1gaZFRAbrFLfOrLfyd5m4tFzNj3JQ+hvDY46egruZJ+8pK0IRYDi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310355; c=relaxed/simple; bh=9uSVonVe6lZLjDKA/C9zzamzFDTm7nGbHwPAR/udAeA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S946lsFNA20TXZJd1+cxCsRIQ7IxoCARqLgd4S5hU2aBUqYP9nb3tfsviYlElvXSOqFR9IGCKi2tKXmZOBOgTXpLdS/uTDLwmS21T7BrPYAF0gZbt7I/jk5XR3rLYu/4WbmQfEUiJ2Oa9Hj7ct96XKtkN2K77DQYnEs1GsPthCM= 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=NePGoTkI; 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="NePGoTkI" 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 0F73F10B6; Wed, 4 Dec 2024 12:05:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310319; bh=9uSVonVe6lZLjDKA/C9zzamzFDTm7nGbHwPAR/udAeA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NePGoTkIlWnIGV5/qykt/8mfPwGkSlkDR1VHXr8XEUtyLJHJML120/V7bf6gj3E2A /idymrPt8lU+dItMCGriMAU8ZDgAlORClptd1WyjavfEj8g5Ub42+PyLiV4a6U5ghv oAwUub/A3lwAVYg0fPG/cUXLGOHIpMANYq8lHlr8= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:19 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-5-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1239; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=9uSVonVe6lZLjDKA/C9zzamzFDTm7nGbHwPAR/udAeA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeDh5EI4nS+x0sy2KhC3GhDuX0OqJz1HwjYs O4z9AFLcauJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3gwAKCRD6PaqMvJYe 9WtoEACUBTbwuaEtEIZI7xtSRJmQmRJPNOfO1yf7K2fzyj99t9CUj6/cH/M274hqI/7+CEzrN7q JVAgnz9iEHhTL1U4pkxI07otQxVYd+/Q46f+NdtM1Gzc30XjVcK7qyGktOPJOgD5cb+eNm1js2e XtzUFqOrOfDFQQqpQply64UKqUBLJIP3knT/pOBcZrCaFFZQwKV+OTC+heUwJ0I/BwerRItqhfI AVTns1hDkpvv7sNs2W+tfh8192uR+al144AMZg/jAVdm8mOPQQ4O9BwCk035BRGxoWPZkSJ6A5U xgFweiGLUGwojsa8W+EVve0YzYxUXVj+jRx3MIIBObdhQXQb1Uzwrj8lHyncFJyVkYNh07uzH8C BeXlX0faDDThswWAHIl/LVMBXe2ANXUPNQL+WVW26U0jFxoR/WXyImaOhlDy0x16DVSaqDjmYWX FIAmE2Y1K6fkL0EFoUTE3y7Gz2xHqnFdmdpP9LNlqGpflr+lVO8+4llSI0gcSakZjMiA3yzXSs/ cC+X3erfYzHZ8AdEv1Plkc2SHSolGNhSTJJ1zti9Z9vzhUuCsrJIcWH8fKlfx5afv6+K1quT21t MWikN8l9D2fx/meHFN2vMnSbRGMEyx3lDq/MHGm4Mt9h2SR8r/EWD82dEpd7gXmOuVPfPd6b7RJ 6gi4lFQpRcoo8ig== 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 Cc: stable@vger.kernel.org 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 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 Wed Dec 4 11:05:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893568 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 1ABC81BD014; Wed, 4 Dec 2024 11:05:55 +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=1733310357; cv=none; b=hJ/vmLc3JvwTFosFCDFzVicNNUY8Gtaj3LQZUNfuWEWWqMcWQQUWRnSM4Bz7oJ6+lKB9mhGOzHRafdA8Y99YSooA9DZkUPPjOwSX3URCh5iae6CcQ3M7lY0k0l8BDyjkEQKI7hvW0aolQ9vuWMb7Bl5IkYysuCT+7v2aQ9KBn0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310357; c=relaxed/simple; bh=LcTkzRMj8n16JAAp2ctpyU8mBul44P0JDcLlKMR2mlU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fCKWesHHFwP/4hwmj8ZpObMJGplb8P2DdQo9pq2kjSe9Bo4UpaZeXZ8wDesUK07mCWVvTV+KgRLzyAVE9sf1WHeZo/XFC0+5Vv2OBZ/T5Y24ruH6wQ+URWAMb/ZwIH20RSqEHGcl/UmwLP5C4vFLVwtyWCUbPdapcS6cRawz3ec= 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=SN02lYlj; 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="SN02lYlj" 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 AAB9D157E; Wed, 4 Dec 2024 12:05:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310320; bh=LcTkzRMj8n16JAAp2ctpyU8mBul44P0JDcLlKMR2mlU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SN02lYlj4CLu2hyyXlZbuz8fSWVMIgn8Jor4OM44zw1+f15RIhelyfF9u1A9D5EhA sDLJ332RDPDL6veyLBaIg2pFPom747fhzYA4I8nj84xE9LOS3X5M33Lp2holewZG0K II1zPY4oEH/wjyDsq6U0pKblHvqwkQitc39u6gxM= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:20 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-6-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=2070; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=LcTkzRMj8n16JAAp2ctpyU8mBul44P0JDcLlKMR2mlU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeDDj2N1BDnEYZnNtlEnXNb/4CrhhGkctte1 XncBjmHwtGJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3gwAKCRD6PaqMvJYe 9SmoEACgX2EoExcCknhpChKYeuh8W6UFJr+to6FBICFba3vlOeal7GtKzK00JS6cyXQup98IDr1 +EzL0VlVHFNS2DC8gS5IZuzikavqkIEBb6SNJ6TR+8sKxhqTGy73P3sjwrgyfVvC2hVseZN0XRh dfA4HogHxtSaWXWkmj2L7cmNZeakwQwCuGxCKgQYXweFFvH95VFiAJwPjyWZSIykmtqEgEH1YBz 9SPlFZaZxulm6zPGiX2SxMR8KOX1SSvOXXFZu1kRojjFj+EtnwS1NQRvPbumG9IWzJ6c2wjCdCQ YAo7muRZv/X5lIRvvbk0h4NBOhl3ivxFmmoKfbVomo0/4hIbw6hhDQUKQ0BCd5O73wDkBdVQd4D loh+XCNSm60CIab/y5dV0XKah0CDoKJ7GfIZ+01d9CKHMd395kt4tAHDWnIN37Zsf4N6/zpKKoQ yKhQaDT7YFW9MK43hopZs7fybsV+u0q0tQlPYC90PGiFFsG/oY9ONnAnrZVu/LE9GwyYBLK40+x r1YYMPMjPRvVkhWF0lJNZ9HFr9hMxFnUqoKEtsgoDHHO2Oaq2jtE1zykZ9lfmTZgsGytycIxpe4 IUAvPHwpsVhNyP0QvWUrMWJYcHuUNhqenkxRNYzbzf2FrtfFQd31doaeotDr+7xSh5vJX3Lu26E jCavL+j2t0UiCZw== 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 bfffa14e2049..98d815526341 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -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 Wed Dec 4 11:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893569 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 CD9921B393E; Wed, 4 Dec 2024 11:05:56 +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=1733310358; cv=none; b=KzvbPXkZavyeEZeNJx159IewrHrhWuqfWsd1bOUr4LCuyWCkeNwUwRmnptXQyhN+tujgA8shbmlBAGN7NrOgDE9YpOE7WNB/G5qP/bXG9qcU/H1Bd5ClutvO99CGRE8ZeQKflwjgiHWqwckVCpkvlpcJ7bpFSmJfWXAlH77B764= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310358; c=relaxed/simple; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qnLsOFH9kMKLrAJV3i5wpQt1lASIKRbAZNAxn+mLIj9EZB+BI47Tkr+73/+gnJO6l8ObexuVym5NqCbKrcTLzv9bN994asn0C8hHoDVA7FkU5GLga/R6io5bYZhuLE3PwyR1PqhV1pLL/7rloM8adaEtw7xz5Wunz6tQfSuWPT0= 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=INwXpIBI; 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="INwXpIBI" 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 44A271777; Wed, 4 Dec 2024 12:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310320; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=INwXpIBIRikan0T1ICrWbAWo4xasR94LAFzD/WGnN/QlDwpcESDs8xkTFOc9BvA66 p9/1vq+m9xbuOybgg5W5Iys3wsaMwudae5YZUUTkaRoZ6vxs/0jbZtloAUkX3M0Izn ybdayYbadPuOKxY0YrmG3L+KiYCkqTndkhxeeMF8= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:21 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-7-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=2244; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=4OfPIQt0zMS+sz9kFlchXcDE+D5zy5L6pKGSTiX11uc=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeEiFf3PjGLBuQ4lsVQaagvN8Vu/ebGcss/T Rnn0lDaALaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hAAKCRD6PaqMvJYe 9ewtD/4g15gNdEVwJl3JnbXkNENE5Y48iozJgeLBnKW0OQQeeADmWldGQPh44gfvcQRwtu19uL0 SkNGBXTi/kvguryzJHvBD40EPr6Z1EafZPCpmrXdayJE+HwidW4JNxmncSkqLNUt09SOAAQHhk0 Oe+TlhNriBGCHN2ArQ4PKIM+tgVIgEPhMMmYd9FXYnyY+ZjK4bj7vCZbVduzTFV+mNt0DH7+K9e yrpsgFxObAeT1xEtTq+89oyTWPRovXGfzRM/8U2ZomLwbecaDL9YcQhHT9/G+MBVknBopK9foTz shuyhSVrNa1GRYHxH7fB2RjcnrTGLm2EyUUzo7vw+xD7n8hOke74SuC6dOXUD/q3GGzVTEJL4nD OcsGNpgAeOV8W6YlnXsNTuALkXFSLBB0v9k8qJBX3D9TRIOXrPm4sa/HxvHUjOetk83aiH5T6JF pgXot9gjSwy9S9zFTdcpkQVbrAv3k5UMUFIzuSTzaxvxWnwfQ7rfog/S4s1bZ5qManhhzrW/CVe H3ksSJqhCNOKMEdlsOdfcHOaxqPjNfw3kO0TVzudNhn/bmcSe1P1V81w/4orbRPt+vDWiXkzrtO d1nttWvNI1K0pOh8d02mZs/TGTQBbxH7R586K1INdEQwFGBRy+E5rjs3Rk74sWQHCEq6FnPEvd8 lGqRv/4W0mXyzUA== 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 @@ #define MHZ(v) ((u32)((v) * 1000000U)) +/* + * 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 < 4; 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 Wed Dec 4 11:05:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893570 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 265FD1B3950; Wed, 4 Dec 2024 11:05:58 +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=1733310360; cv=none; b=YwiqtA8SaeMYXVev+8DPl4AdyIFekt1/GnSZJHZvOFSG6KiY4BOFuGQUM7LHmIHiOiErF+9XmYGhI1l7cUxkdlSdwi+/4wEH+fvSDS5N/KS/Fvj2y5iw+6DwxIX7OzixGPE0dHFI3wI0D4zPbq9Zl192H0jcwygQpRzZZ4ClSAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310360; c=relaxed/simple; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=py+8F6HnThrdVW0ZGd3X4qFpia0iTn6W6gSxytm9ugtRi0IrHSIk0V6UvKodWSxL3yIXTlEXbScSJkqBhpftlnclXsPMCgvSqZZLRxM3dsH6uB0zKZDtlKRANuVPXyWGie7rzXysLmjXsVjq3CvnBaqbHTI4pTwOx22rW7SGf5Q= 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=XNw0MJT6; 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="XNw0MJT6" 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 D6BC918E5; Wed, 4 Dec 2024 12:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310321; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XNw0MJT6ZUVIy5flAibVFIOsW0ruof6oIUXTaAOURitWr6lYWHCocKyFEY8Fwhvn6 yqQQ2L9gqOWoaTicxYxwYTVuaFmYsJyGU1uKeKz5SmbmAMBJzjbrlgYTvU7PQfHRxB tEzpvzwGT+o9qi2EBYljeHHAyyDEpMgFYd8ou824= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:22 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-8-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=2006; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=/xIm447+xdq2t3RQ6TKOBOkTeZS8d2PO9dwv9gsXniE=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeENfy+291E3/4FKwDUrE/ZK90sE+2PGhwsC iZhIlBk4nqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hAAKCRD6PaqMvJYe 9ZxVD/9axHsielmtClBguKUXT5S7Uy0qa9NGZDwqYp6VJ5ZCqimRHA8edQfVIbU+e6QtFfqHg3V VYMA9eho/Lzf9vvlbBNCsIT1eACx3DQObvSNVRrpHgcjWGMUC7y0lPBg/u2xoDNf3bJ5ukcG92N CjQKJuXJeiy1E2979W6CTBJn3XdMM22Z0h4mxJiRaqUlJUAIE88YKp8BTu+cTRGb5QftTXZe6dL zIq9M9f0azKXhNv7ri5bZgVEycYKuLCSkXu9DFW4CgY6g/q6n+N8jQFr0PnC8GDUEqN3E+ERkOD 8cIQNQayU/IEjSs22klMf+xdiIV9XU+5146fn0S5KZIU2YwVydPp8R4D6iN3r8O3hMT8RmWnvwm p2qVmlO8FPS81+04TsG0KFthZpB09jNdoBq2+7Uw6f+UKHt0wbcs+cIFmOLCd4aGsAaoyRY4f9f Qk6Gvs64l0f4MdgHq/fgsZvuo9orcQ2xGoOaTK6/7HUjqTaVh1CYnVdS8VwRNKMU+wn0xOsaOt3 +F9NOS2bF2VPz8f3LN2qEkCRyV3ghYG1aa6X7/Z2zLCQMXYmj9V6XmxYhFrPazp9L8TgMkQGYcN j6lUbRu77BjIWWP54MYPzH+kl5w8wJAQvPdoSFZ0LBr3WhKaQ6Hv6BXSvULmxNmt0GLJ+5urgVT tdINWGKlbZ2Qo6w== 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 { }; 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 Wed Dec 4 11:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893571 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 BD28C1CD1E0; Wed, 4 Dec 2024 11:05:59 +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=1733310361; cv=none; b=Ux5mB14Kmhy3CyTnNmgRGNFph8Osq8ctNDPdczvO/J3s0McBFLFwQeHLJtSGH8QD1SpTHocn2rifQF9BXimL0OX9A7rtIxH7fX7XjIotUEL8zvVFD9WJDmyCp2Lf0JE/T1auikeW6Iq8TuhELdFGFW3UsMpYIkfLMSEKm5phYhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310361; c=relaxed/simple; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m1AEehdavT3c9FwAFRXseoWU3k6qm95zjo4gEWzAR4soiDvgTh9sfPVqPnqT7zvimOnts29wm+RP6MMhHKJjigIvaaoaMEoHFJH4BPQsNZbNwcqeXTkLzkZgT0xg17bUmRenLyNkvFAc/BpeMc4O2naQGhKX3pzSmm06EKdNUhw= 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=fIPv5Y+7; 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="fIPv5Y+7" 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 72971191D; Wed, 4 Dec 2024 12:05:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310321; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fIPv5Y+784RXwWoioPl4HrH6MB2mIZnXTbn9LMK3UUt63yAaA+wDznE6y+bs+MNx/ Nhlybj5om6w1xI1Er33NHx2mwpwd6z1CCIEseJOa1HYJUM58KMZhQAl+62Z7qh6o4r 8iWyVeW+x1jnluTBZIQdNdV0P9rxTXORHY/G3D8U= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:23 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-9-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1264; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=jgGbPlVw9htVnBapbccOdLIZ3VXgt0d8E6hbJmD4w3s=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeEW6K9zkA3utlp52CqjbrxvksMonJEE1hFM cNfEIviZhyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hAAKCRD6PaqMvJYe 9Z9gD/93SrW1FOL75LWW8pJBHJofe7m7TEbJdyCS/G4x2G3eTN3FmbCF6kyjnjoW73pRguOMvLx qrTSVNjwdF7r2tI/ocLJumYChx6kDhSCdJg/SjNwOVhBbgWaitoJl4vLw3+LQdMFCU+uCZnmbc3 i3xhEW9EI4cD8oQkOIiWdi/qU8KKrz+bXog3yobf3QGCZM7nMILp1gWkd/i5QPEbxE+EGWpwqut 0r9BKwFQ/6YD1UVWyz8O1Yi3THAoLQeeudcP812bo0jl1TcYPqmAPeB+ysfBTmHrlRnHAoJEINi sQaZTWmml7yXKC6JN6En3uumjZWeyb98uYXVnTcLCOw6xa6uhHFewGGXrrAm8I9QXl7lfyLgTMd N1Ftn7a4HhaT14eAO4U20tyTX5EVnSi8hQmgr7ttYK5Kbqr2FemQ0eYnI8SVvcmX6V+FkJ+3YIP ZWYmdcB2caSURTQp6SpGzSOG3MH5U+HHqaKLtuSmLPmj2m17VDc7UxAsz/me5evMtprXDgXatK4 gP9IyLULF1Fm9qnMXJzeFLmt5uPdG1y4VV+lcb4S9w5doWX6L4iUm8GlKS05lxmC3y2jae9rciH wZIDWBloZaBHGSy7j7n+xJLSTXPm931t4rYjWy9IKwWnfJc+FWoEw58ItBSquqUW6hIvVA0SsE2 Rgd70anvXaWIFew== 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)) +#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 Wed Dec 4 11:05:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893572 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 00E2B1B3922; Wed, 4 Dec 2024 11:06:01 +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=1733310363; cv=none; b=MJjZeV/62EcFM3ntudCu0DZlNfncfRQm2cietAOp71vpu3knUHfwz+wjgMZEI1YVjOSgz/fmDggJvTGsX3pqbsy6jB9i3n8JmehI2/oz5T1HrIzc5ihjr7rvdRcsi39r5bVRjUjoIDjdm2tGOtZERjcLniXOu+m+vAHJwG1oqfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310363; c=relaxed/simple; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jtaQykhhH70GFCZdHpt/8R7tlLbF0QHO/iFyTiSLXBiMTWtRk6VRHgZmdVxWyF3zJZLApSF3A34BubmXopI6HDgfnF/0dOnMwNR0Bzw2R7JbyAYtXGPykhEMB67PIWgyI9eQKGD+Z818cSr9SrOcrhNwpn8xK3uNsf2zT5ZzX18= 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=h4j4YHdE; 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="h4j4YHdE" 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 0F06B9FC; Wed, 4 Dec 2024 12:05:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310322; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h4j4YHdEdqk5YmTRH+SpsrbjAEysy4ZHLxadpHZnu/czpjuq7C6+RH22w+raF1dXd YkTXG8lUJZTqHMhpjwN5VDLByjWgFUYliqzq/HTkOaK+ZjuVpkrbfMfOc80DDTCPYW s6Lof7pwhjbcQRKthFTOmLf1FmyLIUTL+iZQN/dc= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:24 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-10-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=855; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=heR8KYwFA0qbODgROfqUDYupEapASDH6h0/td17hWK0=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeFknKjkMmuZJRKMzfjngbiy02y66IPxiWE+ auFOJZ19xiJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hQAKCRD6PaqMvJYe 9dF+D/99Aaa26m+WQTcSqvC/fB17RTs/2bqMwyEt/xIpW1boFzFEmR8ucr8mbUELCgoT2FEnnQh Vv8oJBPcmpq4aZu2uYGDsZwGsEe94vufd3BWCSdng7kBUw337aGNla4kWk2e4HUUOtmFZTGGDXY Q0IDSK8kNG2KlHJ4uXdzKKXUaxAg4qMMqYKvLM5j/fOivkwA5846q510dpDozX4FUF6XJgqQPMI iNg/GATgGmgu4a0FEkrV4yWADzzxIepCWQPf09QTf+Nz7LTk3WeY1z8IXhGFzF4+cGuRVx1+/gj rJwCII+eOv2uTh+8Mug8nehqGi8n36o6MuJpFJcI5omeGQWEtVpnL2EESx9tFPetXGRDqg3HQya /g6HfQsgWAlrvXSTkkXXrdVsnoOB7g32AOA1O0PVjJhBPiXvRDQKlP/F0/a70Z9pUYddK2CmHlQ EnfmSBu8FZCaG9dWO9QFZRfHg+kxctkhmjRQELgwCYnt23RV1ByNJ2/Sz9kx39WCjayWaslivLP hQxDZjerqmsTOLu0Z1v5r/4IMSj/b0WWAfIVzh5xJBLEs6IVEm2hTZYpaAroQ49xDwySqGNdVYX iklTJjbsKSihB4uTWAKcHBQqlQPvq7JUU0q0E4kSjnJ25dj+kiKrsp5m4dco00E8hl39bI4WLF+ 1vBNGj6BD+RJL1g== 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 /* UB960_IR_PGEN_*: Indirect Registers for Test Pattern Generator */ From patchwork Wed Dec 4 11:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893573 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 BE88A1DF27F; Wed, 4 Dec 2024 11:06:02 +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=1733310364; cv=none; b=bw8Z142RuiyLjbkYv56MgePalhJEh2BQBasIQOTxhxmWrMMhS3dKeW40mtmxFMg90dS2kOEas29/RIkBQKx75TpQP7qJu/C6qkeUmm80xCjEmxLXPWcUwhEQIk+jALavyDpoEMQKEM2G4ZqQ6amwoc3opTDj3752PZO93eHKWb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310364; c=relaxed/simple; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kf/Mg3m3bGWaGYzgyB+/ai4fxMfGFQmybhH6hn1bv9xtgMYcjChNIqR/F3AQiZfqBs/vnlavhYAL2xhzqVXNQ6pfJBW8XEqfxzvFQJKnfUkDET969BA8bBhTKrBibUNLvHo713+QCn5Ox91L0Coaih6IZvmpom2S+k3GsCNzGWo= 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=S6352A0O; 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="S6352A0O" 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 9D0961BAE; Wed, 4 Dec 2024 12:05:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310323; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=S6352A0OQm6YlChebAOFZxg/y0VAAm7bkXqWySCNYBORbZUA89EVcElHf894qv5p7 LQub0m08blSETNzfPgxurhKOuOO4Y8kmqaUdNDkiVou8Lc8BFoRzVgDj6BTAWQRsH7 Y+Cn1MnT0qTGOZn78aHmiC601BexbsA1S7FRVgGY= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:25 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-11-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1037; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=5VLNvEv71o419ZM2snWjQCE3gPk5HEiEVCAtwv2Uo+I=; b=owEBbAKT/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeFxi7Bh/OZerZzPkJUWz0YZXB8ex6QaO3Aq egoGezotVWJAjIEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hQAKCRD6PaqMvJYe 9aEID/dPTiL52Z5ftbFp2/hb3sX6uKhMxZ3pFqz1QIA/tlFjj1zvTw3aSJEPCa6NrkHSo1NnaVg /QdlhPml3tUukpxkWWt1Dc4hFwQFWGcHu6Veyu5VgBdCaO47H9buGQewEnUWjYIfc5nDXpoDRhn dkLBJb3UtDvH+TdBAWsYCL3lwW3mvIM3e5xHew0f9LfZOvLQDE8S/0Gi1f095y6QuUPayAXfUOC l4Us4mtu1LTr0Mgbj47KWcXZsHbeVaNGmXvGAT/tgAE5yyTeqnuJV5uDSQKdW4Rr77vr3gRuVrA RVw9+ni85Ro9YEof9eT2eOTvCPfXmrCmSXtjWVpIG3gYtywDsV+SauU+ATEtMB8mKc9Sc+5bSMv LVO2O5JdzIpT26F2qRF3ZGLxC0rRnEOwUehtAWH3gMq5oAhxwHS9R1X5UDqheA04N230C02QiLR r7S00rTojNMJCfGvGSzq9z0oylvBLFPURmYhu3kSTGsVEt1UAPhk/MUQjUmM5mhzgTYkqbQUsAb TpDzaNxnItcuToReRWX7b2LVfjIzr/yDPZhm+JoqTbi22mZ4Iy2ko4JFAGUc8GHdiTKSjUiW/3i trhrPEGlsH4WlDhPh4W/JVAGIld5Eppv5DUdAURYI8LFVq1iEwt6/q9tuPYMs1Y6strYy82/DJX XB6oY6BjmbIJc 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 == 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 Wed Dec 4 11:05:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893574 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 16E081EE006; Wed, 4 Dec 2024 11:06:04 +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=1733310366; cv=none; b=FVqae3OEgJloEQ8D1nB2x7AJ5/szsid8TJD+HTu+54KctALf7mAZi+462xnFa8Gb3ubclC+KMbvwwa5XeQ82T2ongbvV6jlgeoDHzxNVSiDbiPzw1QwZ3NpHmh61e1drA1z/nwCCQerJxBo/dd3wRbp/qM0WUz+4b6XC0NOa8sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310366; 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=IWSyBAcrpskinr0dBljpXiDnURrPbTsXMVlSwj0VGG7ZCyn5fDJxgaNWjcGHCXn0Y9wpjPLQr71J1fr94VfvBM28puwwtdDE06gg+6h2ZJdy7nVO6A8VBuuJn3SR48k3reE96PrmyR+C/XW/TEjenyDKTWn31DYJO6v7aBcVIfs= 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=f3TYs03S; 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="f3TYs03S" 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 3BFBA1D29; Wed, 4 Dec 2024 12:05:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310323; bh=cvgAmZGnvd+MaIkpjSC6cQoWn3Y/Etg4xrzQpFwC5+E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=f3TYs03SgifWvbv+gGweK5Bw/WH3wzU9SiwJYm27xL0NT4G8rmJ/M0vcCQ2vXAEe2 5roim0w8RPJ041vFu/QTUAP4Msy7o5CbVt5bYn3k+7mrxyd4JVECGkKs5SINHHbBXj vNdc/JdbLmv/IHw5iAVepkNjml5eUxRcl9NYoYis= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:26 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-12-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=2084; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=cvgAmZGnvd+MaIkpjSC6cQoWn3Y/Etg4xrzQpFwC5+E=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeF6SG7tS/eiKXoOzcD2sDQM4nC9mte+P+7b tQ7bhTo/MeJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hQAKCRD6PaqMvJYe 9UpHD/9adFtA1QLcFEJKFxFjDQp1UUULtz21QokXid773ecBjFkD8OpdRDD4Q9+x7+Cg200mPr7 Cq51u+2yFiw4LDgp9QK+pLdZnwalxy4zPnHAfjPApkdjy920L73NPzQv+L/JqPXXKuCokijRuMA q7TZwyCUbzLUGDtAH3N2lm2uU8TL7gcmIDnQJLqhB52BFXHq1sYnjwprI5nGvoUaxdQ7fhESbQ0 981oxzOiJzu9HcadL+GvVnA6KHOAyNmjXHx2LEJwldyRlHwd1hT0xBlCuNGdxceAal9e5wBKRnk xErBZQjrcQmeF13mzY5dZQac9qM+IbYCAryGTyuynxVP3pJLd93epYLkSJjCgOzlMlq3rvOW0Mg +CYiHs8n+x6f3BScN3PccNFD0DesugsRA1XTTkkMi9b2UMp3vOpla+VtG3lGtZtBYESW/JdABjo 7JJNr2tiR9WK6Jxd79QidvKXOQyCCGW7I4Yuq2cpVIIUDuGGlIiF3DaiJ72CZ8d75TTuJdUHE/k 4u/0+SZqsE9SGRDJ6kTIqg6XJh5RQWNCZQ0ZJnxmdRKQyMF2qENAI38g7VuxZbA99fGr/AtBDAU 8u8YhPH6M5eEGQB4rr1n2awpt5NMYCuQ2NtY8RTdgBau4i6r63lNQD7hOmCov3zFoFuy+jFSC0e 9696riyYmu4TarA== 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 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 Wed Dec 4 11:05:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893575 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 BDD841B3955; Wed, 4 Dec 2024 11:06:05 +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=1733310367; cv=none; b=eAklhgLiwnxfU+zdVfpgCsds+fOpMKMObsudDdVvaKg4xOl2jrCjGKBjotqNuPEcyoQryYvnN1UkiV9IA5thPpZP0BmoxLrrc49cvBYGSBQgPuVkV82I9UUaI7g2Wp/Vexr4wJwj7EBwKENlyJpMcDmEI9FpwTeVhH2DX7om+O4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310367; c=relaxed/simple; bh=ivD5dRvUaz4myV9dQNU7bKA0VacIzVN1VBewFKJTG9o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UNpCQUi0P2roJn8M1z2XiY3o9I5UACgvmSViMwvaQLCAUU+F51QJigAD29YRRUlZEkiwuncECAnUG9C+jTzazV815i0c5GzZTg8CfqA9RdeNywUdm5cS3Uo0KlzPDojIe1I+ih5ekV4C9XqeQm32mgYiT4i3ieryC3epqGynZ3Q= 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=p8PbDpcW; 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="p8PbDpcW" 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 CD38E1DA1; Wed, 4 Dec 2024 12:05:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310324; bh=ivD5dRvUaz4myV9dQNU7bKA0VacIzVN1VBewFKJTG9o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=p8PbDpcW0ENlmxPv1s0jmBggzHcTRO8Thxw9zjaw8FImVUOynZyELABsJhqVTPaR0 4JdhpS0yJwZFLUtsp4Osta1GDdA4Xl4O1GzW5WewoYJRKU8rGA5bwPPRS/J2vgU10J QI6vDryqg/DDAUIiUMVPyuF4ktOqOKJOiCPau+jU= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:27 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-13-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=1750; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=ivD5dRvUaz4myV9dQNU7bKA0VacIzVN1VBewFKJTG9o=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeGPXe1noBnnx3mQJFJyXevBYE6dVpItPCyY oj4fxglXKqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hgAKCRD6PaqMvJYe 9cSjD/0fVPIqmiaV/dII5LZ5ksz/pvvz4MxNWpLuz3pOMg1xLN9t9/fy+5D+IQI7vHjBHFffYvK TWD7RcgW0XyDECCkFkrChtFzFKxnqRcYSr5WO6AWB2JZFKrvNEZSaDXN7BhLjxbHo/AhUlWNWlo cf4WkRnAdVNG8FVJNZb7Vv3l7PjrHqxzTD4BGSHf1s3TY5rullgd/pZCtml63TKFGu6Ns2NLbMe bIrftWAptbeD/BJN5va/TEodlEAAM7gl4tz9CnGh5Yjj+ulY5DbtXbq8jpVdlyI8/vi7D+sAc92 czQP7GcJG6XcC5Ku0OkFHL7PgXMiSpQhFXb0HMNAk9AwyAc3S0I2pcCOr05VnozpOxawOAge1sd AJxAk9G/Dkg/1a9NsOfwd8o7WfHvSx4BM7fGUQaTKPb9peNuV+twB2gkSBe8hap6gTcRFbPlov6 YbOcfPtr/4mOfCj8aKyI1Zd9zBJ+fIW3sr104ps1AZwepOjMn0eZojg+APSFliRQFJSFgpJ7L0N nWJ6VWbPyiSvp/VU1pjZZWrlPQW0P/dp6hzcFaAuC5lTtPw2YmDvpnvamog2/Z5vocl9JU3A5p0 AtUGjJWXJ8S8MMKhdGnqIxcg+giRz95BnrefFlRu5kxRaB6X48pAITW7h/yZXiVERWDuy9WMiXe f51esaTgwqjECsA== 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 | 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 Wed Dec 4 11:05:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893576 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 20C931F7061; Wed, 4 Dec 2024 11:06:07 +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=1733310369; cv=none; b=Z5lqZNtHJHMND9kEZZdnEDWYh4YehycUP9so3UBXNn+rmexaIAOKp1iz0qjMDusWNU+hWh5isucvEXK9c2LMKj0baFz3XDG9vmxOoBJxPpvP9+NG2BPr45Izu7+/zErzj7v0yIPE/14y5vZJecXJDVU5zfs/xPH+yTDoxiQwquI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310369; c=relaxed/simple; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rOkVV7eF8PdYQjihewL4npGgFaQLo/H5xTTxtq42JOgYmdpsYFQPxgwpppGgHY/hLvHyu2jiaOALRHeQrdpA+0zhecZCI0vaJCL+y6lV5BVU+AyzOq6eOTwzcD3eftBK6/i24Y7i1C3TpyAwe1lToC1yFK6yMxTEXx2ozGxvtHs= 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=SS5F1O7f; 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="SS5F1O7f" 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 67E43B2B; Wed, 4 Dec 2024 12:05:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310324; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SS5F1O7f86sQAp3f39ULcd+DLu5J11aiUTNv8JW3ts51KEpH1xEOWUQFzM9Huymiy +al5pAcmLGZLNlwwoLAQdt5RWcXcTSU76rhMGVudFgvxWsZbT+lVwZzQJPzVvjTaiu gM5ilqHX0ZiVzcbeIo5utMlSGqNkE8RjWDZARAN4= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:28 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-14-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=3421; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=h/Wucr0WK1pNJOQNFzwHPdnYZcspI5Mizs3II33asmI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeGk/Dq4BHcqF4yxTfZcSNdZmUp6VN91Hi9S RGl9RjA8oaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hgAKCRD6PaqMvJYe 9RRlD/9Y4nGs1k0Zozw4lFGWJnt1103CIYNlZB5IXt+vV7E+p9M0uTmv5DIB4jJQyqBDjuSrvye mTf85RbIJGlVuCYIlMu+myKxVh6IehJLspTp7rOsX5E6gAkjK8N2x4xLpJXpy/iLDrTAT6jxJY2 kYHgOlx/SMY3bckit2dNqMyLBvVa1UxdmrziliUTVDeTD70RfPPHE6ot/eIUq4B7/bXooAH52Ux 3P4WwuLZTvSCiX+zrg3XHlpVu9iJqiN3f0EbvqJdcH73ugUBOL6fn7zmpi2DyF5dVq7cp5buYU6 26OhyMt7G2l2xXiEU/kBUIINfCiyTwvFiSjR5dbqylDvVTZDAYlgRyjiwBx4J1lo9NZPtuULeOG YddngP9nw0SB1LH18Jal/Upyv2VCF7AqhYGnK1Lhchg9rxCle9JkbJbuARNJQZEsw2gpd5ISPzg JRovXCqWbfWAbjt/+QohnLHToBgiKqixB5zUNIwzbwwIYaEBy8gDMJwyn6i+Rj+y6+zQeT5rFkh /nubblFynGkfFzfcnkeBwEPHdLGjQ208oNa/JD2VFB3zh4Cp9TsM3oj24XQfKuMQpsNZdzdqQUt ZJ3VKpqyGSapDmtjgV6Hs2GeoeuyYyJwtMz8gR1HNakSFcGBhSRU77nFe8OmHZAJDMMRhrzCdmo v6KH5n+gmMGp+3w== 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 *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 Wed Dec 4 11:05:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13893577 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 A32E81F707A; Wed, 4 Dec 2024 11:06:08 +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=1733310370; cv=none; b=tl/KNurscG35kEWd8fJTAngLi+wco+BYSwz16SkiXCq5dKSw2dtYfhgFCXbPQ0DqiNnJigGgfAl5JPx0+A/Fu6tGaGFmfplAh8VmdkH7a/OHVEAvg3NejtyTTh2qCSYL2QWEeckwD0zvvp87VChqFk0Bdt+/4g5t4yAUpcQ+Ubg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733310370; c=relaxed/simple; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KhHG32nYcAwgs7I3ImcQTamVU6nVQXqWjf38KpKdVNxsZ1f2IoqDvhQb0024rN+5llwLqU5SLJsPjJMplajxxDEWffBK1UHKtdvE/WHZMChNkdAqG7V1CR7sjukVHvxwLvqeQRV9Rvmp6yzJse3rGkMsdR1VOju/UJtk7JnLO/c= 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=qRiXfGCI; 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="qRiXfGCI" 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 0241BD04; Wed, 4 Dec 2024 12:05:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310325; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qRiXfGCI/q05wx4tfn+K5MNWhdCr+jSKK4lNilxn/mWxlszW+lquCMbmHElFnU9Yn 8Dig7++Un4TO40H5p+UvTjDsLlvOaPdA0cSFdT4ypW5yL+sHk+/gajVXtyVTmLJGr6 EZiHJKxBgFJ1xRZd73pq1IqFGe5VbkkL3bDizmBA= From: Tomi Valkeinen Date: Wed, 04 Dec 2024 13:05:29 +0200 Subject: [PATCH v3 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: <20241204-ub9xx-fixes-v3-15-a933c109b323@ideasonboard.com> References: <20241204-ub9xx-fixes-v3-0-a933c109b323@ideasonboard.com> In-Reply-To: <20241204-ub9xx-fixes-v3-0-a933c109b323@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=2197; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=F4Yp+U6nA046A4kQeZWpOFa99vdkMkgLtGHd/gDDUno=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnUDeHDsGS6sHdQ72vklvrsxC57Lnab+5ZACq/P 1kt/QdpRSCJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZ1A3hwAKCRD6PaqMvJYe 9b2tEACXUh+aYh0Kri5QlXdTZYTUo6aFoWFS4VnOZUhHtws+f2TNq6aR+y/ebtfIOFrL14BB3dP O8/1eHAu2wOFRWtQFRy43cCaNSl/QoQ7S0UjomoOqhJ3YlsfiWfy5uay2QXk4mLh2wluRoodPjb DLSxnqofabLXfgF8YsfEuevO8UGaAMUS5WAjRWbf8+lRIKvC0ijbphwme1jZHHQVTnbDTxI2dQi eM+xh0a4q/BJK5fgF1TPN3R8at2diVbIhubMl6vZPMRA7OES93rfnROY8aEaOcpZzXXcfLu5ktH OF+wuJJM2LcLAYazqB9vaRQFBElIEw1wIAPJyP1zicETjwA+Cf5ne6X+M4jM2J28HgwcqSEFvEu Q+FMcoYKu3MpWwds+jKLdtiIRCx4aAc+ZpboWbJLaXzxSNf0ZjoTDMFhgp3UpiZsC5zvVYQhZLq NoF5Mtw56GPMjSoeDxt+lM+yc5bDSeB71ceLlDJ5z7A9gvAgKlT66Yu23Zocm5JYoNXc3oT7Yia M98EtCAbMAGVXoSMT/Hm8x0zQ3iMS1qGhrioivuzYtVPsPT6eb0U0MUKJxob3dbfUcL2NVzuU2G G8SAwh8hnoqcpOP+Li8UFtXLdCzni/d/S1RpJ1RobiCEGSr8sJ+lCmseLNAF387UtrSXZIlFxvH zK2liPQ8VDofmHg== 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] = {}; 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;