[PATCH v6 2/8] media: tw9900: accept the TW9910 chip ID
From: Matthew Laux
Date: Wed Nov 18 2026 - 15:43:36 EST
Allow tw9900.c to accept the tw9910's chip ID and revision fields as
well as the tw9900's. The tw9910 is a superset of the tw9900 for the
functionality used by the tw9900 driver, and USB3HDCAP/XCAPTURE-1
capture devices can have either chip.
Signed-off-by: Matthew Laux <matthew.laux@xxxxxxxxx>
---
drivers/media/i2c/tw9900.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/tw9900.c b/drivers/media/i2c/tw9900.c
index e07924faa84b..60d5686716f7 100644
--- a/drivers/media/i2c/tw9900.c
+++ b/drivers/media/i2c/tw9900.c
@@ -23,6 +23,8 @@
#include <media/v4l2-subdev.h>
#define TW9900_REG_CHIP_ID 0x00
+#define TW9900_REG_CHIP_ID_ID_MASK GENMASK(7, 3)
+#define TW9900_REG_CHIP_ID_REV_MASK GENMASK(2, 0)
#define TW9900_REG_CHIP_STATUS 0x01
#define TW9900_REG_CHIP_STATUS_VDLOSS BIT(7)
#define TW9900_REG_CHIP_STATUS_HLOCK BIT(6)
@@ -51,6 +53,7 @@
#define TW9900_REG_VVBI 0x55
#define TW9900_CHIP_ID 0x00
+#define TW9910_CHIP_ID 0x0B
#define TW9900_STD_NTSC_M 0
#define TW9900_STD_PAL_BDGHI 1
#define TW9900_STD_AUTO 7
@@ -574,6 +577,7 @@ static int tw9900_check_id(struct tw9900 *tw9900,
struct i2c_client *client)
{
struct device *dev = &tw9900->client->dev;
+ u8 id, rev;
int ret;
ret = pm_runtime_resume_and_get(&tw9900->client->dev);
@@ -581,7 +585,7 @@ static int tw9900_check_id(struct tw9900 *tw9900,
return ret;
mutex_lock(&tw9900->mutex);
- ret = tw9900_read_reg(client, TW9900_CHIP_ID);
+ ret = tw9900_read_reg(client, TW9900_REG_CHIP_ID);
mutex_unlock(&tw9900->mutex);
pm_runtime_put(&tw9900->client->dev);
@@ -589,11 +593,17 @@ static int tw9900_check_id(struct tw9900 *tw9900,
if (ret < 0)
return ret;
- if (ret != TW9900_CHIP_ID) {
- dev_err(dev, "Unexpected decoder id %#x\n", ret);
+ id = FIELD_GET(TW9900_REG_CHIP_ID_ID_MASK, ret);
+ rev = FIELD_GET(TW9900_REG_CHIP_ID_REV_MASK, ret);
+
+ if (id != TW9900_CHIP_ID && id != TW9910_CHIP_ID) {
+ dev_err(dev, "Unexpected decoder id %#x (rev %u)\n", id, rev);
return -ENODEV;
}
+ dev_dbg(dev, "Found %s revision %u\n",
+ id == TW9910_CHIP_ID ? "TW9910" : "TW9900", rev);
+
return 0;
}
--
2.47.3