Skip to contentSkip to conversation

media: pci: add AVMatrix HWS capture driver

PATCH In review [email protected] 2 participants 2 messages May 19

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v8 1/1 media: pci: add AVMatrix HWS capture driver

From: Ben Hoff <[email protected]>

Add an in-tree AVMatrix HWS PCIe capture driver. The driver supports up to four HDMI inputs and exposes the video capture path through V4L2 with vb2-dma-contig streaming, DV timings, and per-input controls. Audio support is intentionally omitted from this submission.

This patch also adds the MAINTAINERS entry for the new driver.

This driver is derived from a GPL out-of-tree driver.

Changes since v7:
- remove unused g_ctrl, s_ctrl and queryctrl ioctl declarations

Changes since v6:
- v6 accidently contained legacy history, resubmitting with latest
- remove an unused mode-change label reported by W=1

Changes since v5:
- keep queue_setup() and alloc_sizeimage on the logical sizeimage value
- drop the dead queue_setup() fallback that rebuilt pix.sizeimage on the fly
- clarify that hws_calc_sizeimage() models the packed-YUYV-only path
- add Assisted-by attribution for Codex

Changes since v4:
- replace plain 64-bit elapsed-time divisions in debug logging with div_u64() so i386 module builds do not emit __udivdi3 references

Changes since v3:
- fold the MAINTAINERS update into this patch so per-patch CI sees the new file pattern
- wrap the validation text for checkpatch

Changes since v2:
- keep scratch DMA allocation on a single probe-owned path
- avoid double-freeing V4L2 control handlers on register unwind
- drop the extra per-node resolution sysfs ABI
- turn live geometry changes into explicit SOURCE_CHANGE renegotiation
- report live DV timings and reject attempts to retime a live source
- stop advertising RESOLUTION source changes for fps-only updates
- keep live fps state across harmless S_FMT restarts
- stop exposing an unvalidated DV RX power-present signal
- clean the imported sources for checkpatch and W=1 builds

Validation:
- build-tested with W=1 against a local kernel build tree
- compiled the driver with ARCH=i386 allmodconfig and verified the resulting hws_pci.o, hws_video.o, and hws.o do not reference __udivdi3
- v4l2-compliance 1.33.0-5459 from v4l-utils commit 4a0d2c3b4f523406cb9a6f4c541ef14f72f19f3d on /dev/video2:
48 tests succeeded, 0 failed, 1 warning

DV_RX_POWER_PRESENT is intentionally left unsupported in this revision because current hardware evidence does not expose a validated receiver-side power-detect signal distinct from active video presence.

---
 MAINTAINERS                            |    6 +
 drivers/media/pci/Kconfig              |    1 +
 drivers/media/pci/Makefile             |    1 +
 drivers/media/pci/hws/Kconfig          |   12 +
 drivers/media/pci/hws/Makefile         |    4 +
 drivers/media/pci/hws/hws.h            |  173 +++
 drivers/media/pci/hws/hws_irq.c        |  269 +++++
 drivers/media/pci/hws/hws_irq.h        |   10 +
 drivers/media/pci/hws/hws_pci.c        |  865 ++++++++++++++
 drivers/media/pci/hws/hws_reg.h        |  136 +++
 drivers/media/pci/hws/hws_v4l2_ioctl.c |  919 +++++++++++++++
 drivers/media/pci/hws/hws_v4l2_ioctl.h |   33 +
 drivers/media/pci/hws/hws_video.c      | 1490 ++++++++++++++++++++++++
 drivers/media/pci/hws/hws_video.h      |   29 +
 14 files changed, 3948 insertions(+)
 create mode 100644 drivers/media/pci/hws/Kconfig
 create mode 100644 drivers/media/pci/hws/Makefile
 create mode 100644 drivers/media/pci/hws/hws.h
 create mode 100644 drivers/media/pci/hws/hws_irq.c
 create mode 100644 drivers/media/pci/hws/hws_irq.h
 create mode 100644 drivers/media/pci/hws/hws_pci.c
 create mode 100644 drivers/media/pci/hws/hws_reg.h
 create mode 100644 drivers/media/pci/hws/hws_v4l2_ioctl.c
 create mode 100644 drivers/media/pci/hws/hws_v4l2_ioctl.h
 create mode 100644 drivers/media/pci/hws/hws_video.c
 create mode 100644 drivers/media/pci/hws/hws_video.h
MAINTAINERS +6 -0
index c2c6d79275c6..4d970b78c54c 100644
@@ -7481,6 +7481,12 @@ S:	Maintained
 F:	Documentation/admin-guide/media/mgb4.rst
 F:	drivers/media/pci/mgb4/
 
+AVMATRIX HWS DRIVER
+M:	Ben Hoff <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/pci/hws/
+
 DIOLAN U2C-12 I2C DRIVER
 M:	Guenter Roeck <[email protected]>
 L:	[email protected]
drivers/media/pci/Kconfig +1 -0
index eebb16c58f3d..bfdb200f85a3 100644
@@ -13,6 +13,7 @@ if MEDIA_PCI_SUPPORT
 if MEDIA_CAMERA_SUPPORT
 	comment "Media capture support"
 
+source "drivers/media/pci/hws/Kconfig"
 source "drivers/media/pci/mgb4/Kconfig"
 source "drivers/media/pci/solo6x10/Kconfig"
 source "drivers/media/pci/tw5864/Kconfig"
drivers/media/pci/Makefile +1 -0
index 02763ad88511..c4508b6723a9 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_VIDEO_CX23885) += cx23885/
 obj-$(CONFIG_VIDEO_CX25821) += cx25821/
 obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_DT3155) += dt3155/
+obj-$(CONFIG_VIDEO_HWS) += hws/
 obj-$(CONFIG_VIDEO_IVTV) += ivtv/
 obj-$(CONFIG_VIDEO_MGB4) += mgb4/
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
drivers/media/pci/hws/Kconfig new file +12 -0
new file mode 100644
index 000000000000..b606d5ffadef
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIDEO_HWS
+	tristate "AVMatrix HWS capture driver"
+	depends on VIDEO_DEV && PCI
+	select VIDEOBUF2_DMA_CONTIG
+	help
+	  This is a Video4Linux2 driver for AVMatrix HWS PCIe capture cards.
+	  It provides a PCIe capture interface with V4L2 streaming, DV timings,
+	  and per-input controls for the supported HWS boards.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called hws.
drivers/media/pci/hws/Makefile new file +4 -0
new file mode 100644
index 000000000000..a66aebd348e5
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+hws-objs := hws_pci.o hws_irq.o hws_video.o hws_v4l2_ioctl.o
+
+obj-$(CONFIG_VIDEO_HWS) += hws.o
drivers/media/pci/hws/hws.h new file +173 -0

173 lines not on this page · raw message

drivers/media/pci/hws/hws_irq.c new file +269 -0

269 lines not on this page · raw message

drivers/media/pci/hws/hws_irq.h new file +10 -0
new file mode 100644
index 000000000000..a42867aa0c46
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef HWS_INTERRUPT_H
+#define HWS_INTERRUPT_H
+
+#include <linux/pci.h>
+#include "hws.h"
+
+irqreturn_t hws_irq_handler(int irq, void *info);
+
+#endif /* HWS_INTERRUPT_H */
drivers/media/pci/hws/hws_pci.c new file +865 -0

865 lines not on this page · raw message

drivers/media/pci/hws/hws_reg.h new file +136 -0

136 lines not on this page · raw message

drivers/media/pci/hws/hws_v4l2_ioctl.c new file +919 -0

919 lines not on this page · raw message

drivers/media/pci/hws/hws_v4l2_ioctl.h new file +33 -0
new file mode 100644
index 000000000000..3efdc78b21cd
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef HWS_V4L2_IOCTL_H
+#define HWS_V4L2_IOCTL_H
+
+#include <media/v4l2-ctrls.h>
+#include <linux/fs.h>
+
+extern const struct v4l2_ctrl_ops hws_ctrl_ops;
+
+int hws_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap);
+int hws_vidioc_enum_fmt_vid_cap(struct file *file, void *priv_fh, struct v4l2_fmtdesc *f);
+int hws_vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt);
+int hws_vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f);
+int hws_vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorms);
+int hws_vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms);
+int hws_vidioc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *setfps);
+int hws_vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i);
+int hws_vidioc_g_input(struct file *file, void *priv, unsigned int *i);
+int hws_vidioc_s_input(struct file *file, void *priv, unsigned int i);
+int hws_vidioc_dv_timings_cap(struct file *file, void *fh,
+			      struct v4l2_dv_timings_cap *cap);
+int hws_vidioc_s_dv_timings(struct file *file, void *fh,
+			    struct v4l2_dv_timings *timings);
+
+int hws_vidioc_g_dv_timings(struct file *file, void *fh,
+			    struct v4l2_dv_timings *timings);
+int hws_vidioc_enum_dv_timings(struct file *file, void *fh,
+			       struct v4l2_enum_dv_timings *edv);
+int hws_vidioc_query_dv_timings(struct file *file, void *fh,
+				struct v4l2_dv_timings *timings);
+int hws_vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f);
+
+#endif
drivers/media/pci/hws/hws_video.c new file +1490 -0

553 lines not on this page · raw message

drivers/media/pci/hws/hws_video.h new file +29 -0
new file mode 100644
index 000000000000..4feaf5b2f5a9

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.53.0

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 8 lines · On 19/05/2026 18:12, [email protected] wrote:

From: Ben Hoff <[email protected]>

Add an in-tree AVMatrix HWS PCIe capture driver. The driver supports up to four HDMI inputs and exposes the video capture path through V4L2 with vb2-dma-contig streaming, DV timings, and per-input controls. Audio support is intentionally omitted from this submission.

Quoted 6 lines

This patch also adds the MAINTAINERS entry for the new driver.

This driver is derived from a GPL out-of-tree driver.

Changes since v7:
- remove unused g_ctrl, s_ctrl and queryctrl ioctl declarations

Ah, no. I don't need a v8 since v7 has already been merged in our tree. I just need a follow-up patch on top that removes those unused declarations.

The next branch in our media-committers tree:

https://gitlab.freedesktop.org/linux-media/media-committers/

contains the patches that will flow into the next kernel version (v7.2).

Regards,

Hans