[PATCH] media: hws: fix device info register field masks

Ben Hoff <[email protected]> Sat, 1 Aug 2026 01:37:41 -0400
Newsgroups org.kernel.vger.linux-media,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The baseline driver decodes the device version from bits 15:8 and the
sub-version from bits 23:16 of HWS_REG_DEVICE_INFO. The current masks
decode both fields one byte too low, reading the device version from a
byte the baseline driver ignores and the sub-version from the device
version field.

hws_configure_hardware_capabilities() uses the device version to
classify the hardware generation. An incorrect version can classify
newer hardware as legacy, select the legacy capture path, and skip
HWS_REG_DMA_MAX_SIZE programming.

Correct both field masks and update the register layout documentation.

Signed-off-by: Ben Hoff <[email protected]>
---
 drivers/media/pci/hws/hws_pci.c | 4 ++--
 drivers/media/pci/hws/hws_reg.h | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/hws/hws_pci.c b/drivers/media/pci/hws/hws_pci.c
index 30bb7d34465b..75be77d6c197 100644
--- a/drivers/media/pci/hws/hws_pci.c
+++ b/drivers/media/pci/hws/hws_pci.c
@@ -33,8 +33,8 @@ static unsigned long long hws_elapsed_us(u64 start_ns)
 }
 
 /* register layout inside HWS_REG_DEVICE_INFO */
-#define DEVINFO_VER GENMASK(7, 0)
-#define DEVINFO_SUBVER GENMASK(15, 8)
+#define DEVINFO_VER GENMASK(15, 8)
+#define DEVINFO_SUBVER GENMASK(23, 16)
 #define DEVINFO_YV12 GENMASK(31, 28)
 #define DEVINFO_HWKEY GENMASK(27, 24)
 #define DEVINFO_PORTID GENMASK(25, 24) /* low 2 bits of HW-key */
diff --git a/drivers/media/pci/hws/hws_reg.h b/drivers/media/pci/hws/hws_reg.h
index e4fb4af44434..ac607360d628 100644
--- a/drivers/media/pci/hws/hws_reg.h
+++ b/drivers/media/pci/hws/hws_reg.h
@@ -121,9 +121,10 @@
 #define HWS_REG_DEVICE_INFO   (CVBS_IN_BASE +  88 * PCIE_BARADDROFSIZE)
 /*
  * Reading this 32-bit word returns:
- *   bits 7:0   = "device version"
- *   bits 15:8  = "device sub-version"
- *   bits 23:24 = "HW key / port ID" etc.
+ *   bits 7:0   = unused by the baseline driver
+ *   bits 15:8  = device version
+ *   bits 23:16 = device sub-version
+ *   bits 27:24 = HW key (port ID in bits 25:24)
  *   bits 31:28 = "support YV12" flags
  */
 
-- 
2.43.0