Skip to contentSkip to conversation

media: platform: amd: Introduce amd isp4 capture driver

PATCH Superseded Bin Du 6 participants 31 messages Aug 28, 2025 – Sep 11, 2025

Subsystems (2)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Bin Du

author maintainer
#0 lore raw

PATCH v3 1/7 media: platform: amd: Introduce amd isp4 capture driver

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
 MAINTAINERS                              |  13 +++
 drivers/media/platform/Kconfig           |   1 +
 drivers/media/platform/Makefile          |   1 +
 drivers/media/platform/amd/Kconfig       |   3 +
 drivers/media/platform/amd/Makefile      |   3 +
 drivers/media/platform/amd/isp4/Kconfig  |  13 +++
 drivers/media/platform/amd/isp4/Makefile |   6 ++
 drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
 drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
 9 files changed, 185 insertions(+)
 create mode 100644 drivers/media/platform/amd/Kconfig
 create mode 100644 drivers/media/platform/amd/Makefile
 create mode 100644 drivers/media/platform/amd/isp4/Kconfig
 create mode 100644 drivers/media/platform/amd/isp4/Makefile
 create mode 100644 drivers/media/platform/amd/isp4/isp4.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4.h
MAINTAINERS +13 -0
index fe168477caa4..3ad845f1511b 100644
@@ -1133,6 +1133,19 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git
 F:	drivers/iommu/amd/
 F:	include/linux/amd-iommu.h
 
+AMD ISP4 DRIVER
+M:	Bin Du <[email protected]>
+M:	Nirujogi Pratap <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media.git
+F:	drivers/media/platform/amd/Kconfig
+F:	drivers/media/platform/amd/Makefile
+F:	drivers/media/platform/amd/isp4/Kconfig
+F:	drivers/media/platform/amd/isp4/Makefile
+F:	drivers/media/platform/amd/isp4/isp4.c
+F:	drivers/media/platform/amd/isp4/isp4.h
+
 AMD KFD
 M:	Felix Kuehling <[email protected]>
 L:	[email protected]
drivers/media/platform/Kconfig +1 -0
index 9287faafdce5..772c70665510 100644
@@ -63,6 +63,7 @@ config VIDEO_MUX
 
 # Platform drivers - Please keep it alphabetically sorted
 source "drivers/media/platform/allegro-dvt/Kconfig"
+source "drivers/media/platform/amd/Kconfig"
 source "drivers/media/platform/amlogic/Kconfig"
 source "drivers/media/platform/amphion/Kconfig"
 source "drivers/media/platform/aspeed/Kconfig"
drivers/media/platform/Makefile +1 -0
index 6fd7db0541c7..b207bd8d8022 100644
@@ -6,6 +6,7 @@
 # Place here, alphabetically sorted by directory
 # (e. g. LC_ALL=C sort Makefile)
 obj-y += allegro-dvt/
+obj-y += amd/
 obj-y += amlogic/
 obj-y += amphion/
 obj-y += aspeed/
drivers/media/platform/amd/Kconfig new file +3 -0
new file mode 100644
index 000000000000..25af49f246b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
new file mode 100644
index 000000000000..8bfc1955f22e
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += isp4/
drivers/media/platform/amd/isp4/Kconfig new file +13 -0
new file mode 100644
index 000000000000..0268060c2dae
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+config AMD_ISP4
+	tristate "AMD ISP4 and camera driver"
+	depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API
+	select VIDEOBUF2_CORE
+	select VIDEOBUF2_V4L2
+	select VIDEOBUF2_MEMOPS
+	help
+	  This is support for AMD ISP4 and camera subsystem driver.
+	  Say Y here to enable the ISP4 and camera device for video capture.
+	  To compile this driver as a module, choose M here. The module will
+	  be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
new file mode 100644
index 000000000000..de0092dad26f
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025 Advanced Micro Devices, Inc.
+
+obj-$(CONFIG_AMD_ISP4) += amd_capture.o
+amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +121 -0

121 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4.h new file +24 -0
new file mode 100644
index 000000000000..8535f662ab49
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _ISP4_H_
+#define _ISP4_H_
+
+#include <linux/mutex.h>
+#include <media/v4l2-device.h>
+#include <media/videobuf2-memops.h>
+#include <media/videobuf2-vmalloc.h>
+
+#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
+
+struct isp4_device {
+	struct v4l2_device v4l2_dev;
+	struct media_device mdev;
+
+	struct platform_device *pdev;
+	struct notifier_block i2c_nb;
+};
+
+#endif /* _ISP4_H_ */
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v3 2/7 media: platform: amd: low level support for isp4 firmware

Low level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware. Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.

---
 MAINTAINERS                                   |   1 +
 drivers/media/platform/amd/isp4/Makefile      |   2 +-
 drivers/media/platform/amd/isp4/isp4_hw_reg.h | 125 ++++++++++++++++++
 3 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.h
MAINTAINERS +1 -0
index 3ad845f1511b..d4723d0041c6 100644
@@ -1145,6 +1145,7 @@ F:	drivers/media/platform/amd/isp4/Kconfig
 F:	drivers/media/platform/amd/isp4/Makefile
 F:	drivers/media/platform/amd/isp4/isp4.c
 F:	drivers/media/platform/amd/isp4/isp4.h
+F:	drivers/media/platform/amd/isp4/isp4_hw_reg.h
 
 AMD KFD
 M:	Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +1 -1
index de0092dad26f..eb130647fbe2 100644
@@ -3,4 +3,4 @@
 # Copyright (C) 2025 Advanced Micro Devices, Inc.
 
 obj-$(CONFIG_AMD_ISP4) += amd_capture.o
-amd_capture-objs := isp4.o
+amd_capture-objs := isp4.o	\
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v3 3/7 media: platform: amd: Add isp4 fw and hw interface

In reply to Bin Du

ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu. The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start. Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.

---
 MAINTAINERS                                   |   3 +
 drivers/media/platform/amd/isp4/Makefile      |   1 +
 .../platform/amd/isp4/isp4_fw_cmd_resp.h      | 314 ++++++
 .../media/platform/amd/isp4/isp4_interface.c  | 961 ++++++++++++++++++
 .../media/platform/amd/isp4/isp4_interface.h  | 149 +++
 5 files changed, 1428 insertions(+)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
 create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.h
MAINTAINERS +3 -0
index d4723d0041c6..2824850831e5 100644
@@ -1145,7 +1145,10 @@ F:	drivers/media/platform/amd/isp4/Kconfig
 F:	drivers/media/platform/amd/isp4/Makefile
 F:	drivers/media/platform/amd/isp4/isp4.c
 F:	drivers/media/platform/amd/isp4/isp4.h
+F:	drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
 F:	drivers/media/platform/amd/isp4/isp4_hw_reg.h
+F:	drivers/media/platform/amd/isp4/isp4_interface.c
+F:	drivers/media/platform/amd/isp4/isp4_interface.h
 
 AMD KFD
 M:	Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +1 -0
index eb130647fbe2..327ed1157076 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_AMD_ISP4) += amd_capture.o
 amd_capture-objs := isp4.o	\
+			isp4_interface.o \
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +314 -0

314 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_interface.c new file +961 -0

961 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_interface.h new file +149 -0

149 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v3 4/7 media: platform: amd: isp4 subdev and firmware loading handling added

In reply to Bin Du

Isp4 sub-device is implementing v4l2 sub-device interface. It has one capture video node, and supports only preview stream. It manages firmware states, stream configuration and mipi phy configuration. This change also adds interrupt handling and notification for isp firmware to isp-subdevice.

---
 MAINTAINERS                                   |    2 +
 drivers/media/platform/amd/isp4/Makefile      |    3 +-
 drivers/media/platform/amd/isp4/isp4.c        |  120 +-
 drivers/media/platform/amd/isp4/isp4.h        |    8 +-
 drivers/media/platform/amd/isp4/isp4_subdev.c | 1096 +++++++++++++++++
 drivers/media/platform/amd/isp4/isp4_subdev.h |  131 ++
 6 files changed, 1347 insertions(+), 13 deletions(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.h
MAINTAINERS +2 -0
index 2824850831e5..70044f8ce5f1 100644
@@ -1149,6 +1149,8 @@ F:	drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
 F:	drivers/media/platform/amd/isp4/isp4_hw_reg.h
 F:	drivers/media/platform/amd/isp4/isp4_interface.c
 F:	drivers/media/platform/amd/isp4/isp4_interface.h
+F:	drivers/media/platform/amd/isp4/isp4_subdev.c
+F:	drivers/media/platform/amd/isp4/isp4_subdev.h
 
 AMD KFD
 M:	Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +2 -1
index 327ed1157076..905788bc6a1e 100644
@@ -3,5 +3,6 @@
 # Copyright (C) 2025 Advanced Micro Devices, Inc.
 
 obj-$(CONFIG_AMD_ISP4) += amd_capture.o
-amd_capture-objs := isp4.o	\
+amd_capture-objs := isp4_subdev.o \
 			isp4_interface.o \
+			isp4.o	\
drivers/media/platform/amd/isp4/isp4.c +111 -9

188 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4.h +5 -3
index 8535f662ab49..00ac11ed8fb0 100644
@@ -6,19 +6,21 @@
 #ifndef _ISP4_H_
 #define _ISP4_H_
 
+#include <drm/amd/isp.h>
 #include <linux/mutex.h>
-#include <media/v4l2-device.h>
-#include <media/videobuf2-memops.h>
-#include <media/videobuf2-vmalloc.h>
+#include "isp4_subdev.h"
 
 #define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
 
 struct isp4_device {
 	struct v4l2_device v4l2_dev;
+	struct isp4_subdev isp_sdev;
 	struct media_device mdev;
 
+	struct isp_platform_data *pltf_data;
 	struct platform_device *pdev;
 	struct notifier_block i2c_nb;
+	struct v4l2_async_notifier notifier;
 };
 
 #endif /* _ISP4_H_ */
drivers/media/platform/amd/isp4/isp4_subdev.c new file +1096 -0

1,096 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_subdev.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v3 4/7] media: platform: amd: isp4 subdev and firmware loading handling added

…

Quoted 1 line

states, stream configuration and mipi phy configuration. This change also

…

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n94

…

Quoted 2 lines

+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c

(quoted diff) +0 -0
@@ -0,0 +1,1096 @@

…

Quoted 2 lines
(quoted diff) +2 -0
+static s32 isp4sd_fw_resp_thread_wrapper(void *context)
+{

…

drivers/media/platform/amd/isp4/isp4_subdev.c line 640

Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_subdev.c new file +3 -0
+		mutex_lock(&thread_ctx->mutex);
+		isp4sd_fw_resp_func(isp_subdev, stream_id);
+		mutex_unlock(&thread_ctx->mutex);

…

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&thread_ctx->mutex);”?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/mutex.h#L228

Regards,
Markus

author maintainer
#5 lore raw

Re: [PATCH v3 4/7] media: platform: amd: isp4 subdev and firmware loading handling added

Thanks Markus Elfring.

Quoted 8 lines · Markus Elfring

…

Quoted 1 line

states, stream configuration and mipi phy configuration. This change also

…

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n94

Very clear guide, will update in the next version and also check commit message of other patches in the series.

Quoted 7 lines

…

Quoted 2 lines

+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c

(quoted diff) +0 -0
@@ -0,0 +1,1096 @@

…

Quoted 2 lines
(quoted diff) +2 -0
+static s32 isp4sd_fw_resp_thread_wrapper(void *context)
+{

…

Quoted 9 lines

drivers/media/platform/amd/isp4/isp4_subdev.c line 640

Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_subdev.c new file +3 -0
+		mutex_lock(&thread_ctx->mutex);
+		isp4sd_fw_resp_func(isp_subdev, stream_id);
+		mutex_unlock(&thread_ctx->mutex);

…

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&thread_ctx->mutex);”?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/mutex.h#L228

Appreciate for catching this, will do the optimization in the next version.

Quoted 2 lines

Regards,
Markus

Signature · 2 lines
Regards,
Bin
#6 lore raw

Re: [PATCH v3 4/7] media: platform: amd: isp4 subdev and firmware loading handling added

In reply to Bin Du
Quoted 18 lines · Bin Du

Isp4 sub-device is implementing v4l2 sub-device interface. It has one capture video node, and supports only preview stream. It manages firmware states, stream configuration and mipi phy configuration. This change also adds interrupt handling and notification for isp firmware to isp-subdevice.

---
 MAINTAINERS                                   |    2 +
 drivers/media/platform/amd/isp4/Makefile      |    3 +-
 drivers/media/platform/amd/isp4/isp4.c        |  120 +-
 drivers/media/platform/amd/isp4/isp4.h        |    8 +-
 drivers/media/platform/amd/isp4/isp4_subdev.c | 1096 +++++++++++++++++
 drivers/media/platform/amd/isp4/isp4_subdev.h |  131 ++
 6 files changed, 1347 insertions(+), 13 deletions(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.h

[snip]

Quoted 16 lines
drivers/media/platform/amd/isp4/isp4.h +2 -3
index 8535f662ab49..00ac11ed8fb0 100644
@@ -6,19 +6,21 @@
 #ifndef _ISP4_H_
 #define _ISP4_H_
 
+#include <drm/amd/isp.h>
 #include <linux/mutex.h>
-#include <media/v4l2-device.h>
-#include <media/videobuf2-memops.h>
-#include <media/videobuf2-vmalloc.h>
+#include "isp4_subdev.h"
 
 #define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)

drivers/media/platform/amd/isp4/isp4.h line 23

Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h +3 -0
 
 struct isp4_device {
 	struct v4l2_device v4l2_dev;
+	struct isp4_subdev isp_sdev;
 	struct media_device mdev;
 
+	struct isp_platform_data *pltf_data;
 	struct platform_device *pdev;
 	struct notifier_block i2c_nb;
+	struct v4l2_async_notifier notifier;

As far as I can tell, i2c_nb and notifier are not used anymore.

Quoted 3 lines
drivers/media/platform/amd/isp4/isp4.h +0 -0
 };
 
 #endif /* _ISP4_H_ */

[snip]

Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#7 lore raw

PATCH v3 5/7 media: platform: amd: isp4 video node and buffers handling added

In reply to Bin Du

Isp video implements v4l2 video interface and supports NV12 and YUYV. It manages buffers, pipeline power and state. Cherry-picked Sultan's DMA buffer realated fix from branch v6.16-drm-tip-isp4-for-amd on
https://github.com/kerneltoast/kernel_x86_laptop.git

---
 MAINTAINERS                                   |    2 +
 drivers/media/platform/amd/isp4/Makefile      |    1 +
 drivers/media/platform/amd/isp4/isp4.c        |   10 +
 drivers/media/platform/amd/isp4/isp4_subdev.c |   95 +-
 drivers/media/platform/amd/isp4/isp4_subdev.h |    2 +
 drivers/media/platform/amd/isp4/isp4_video.c  | 1213 +++++++++++++++++
 drivers/media/platform/amd/isp4/isp4_video.h  |   87 ++
 7 files changed, 1406 insertions(+), 4 deletions(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h
MAINTAINERS +2 -0
index 70044f8ce5f1..437232d4912d 100644
@@ -1151,6 +1151,8 @@ F:	drivers/media/platform/amd/isp4/isp4_interface.c
 F:	drivers/media/platform/amd/isp4/isp4_interface.h
 F:	drivers/media/platform/amd/isp4/isp4_subdev.c
 F:	drivers/media/platform/amd/isp4/isp4_subdev.h
+F:	drivers/media/platform/amd/isp4/isp4_video.c
+F:	drivers/media/platform/amd/isp4/isp4_video.h
 
 AMD KFD
 M:	Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +1 -0
index 905788bc6a1e..33589091ca96 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o
 amd_capture-objs := isp4_subdev.o \
 			isp4_interface.o \
 			isp4.o	\
+			isp4_video.o
\ No newline at end of file
drivers/media/platform/amd/isp4/isp4.c +10 -0
index 8cec27228710..a46e110a396f 100644
@@ -178,6 +178,16 @@ static int isp4_capture_probe(struct platform_device *pdev)
 		goto err_isp4_deinit;
 	}
 
+	ret = media_create_pad_link(&isp_dev->isp_sdev.sdev.entity,
+				    0, &isp_dev->isp_sdev.isp_vdev.vdev.entity,
+				    0,
+				    MEDIA_LNK_FL_ENABLED |
+				    MEDIA_LNK_FL_IMMUTABLE);
+	if (ret) {
+		dev_err(dev, "fail to create pad link %d\n", ret);
+		goto err_isp4_deinit;
+	}
+
 	platform_set_drvdata(pdev, isp_dev);
 
 	return 0;
drivers/media/platform/amd/isp4/isp4_subdev.c +91 -4

153 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_subdev.h +2 -0
index 524a8de5e18d..322bd990bbaa 100644
@@ -17,6 +17,7 @@
 #include "isp4_fw_cmd_resp.h"
 #include "isp4_hw_reg.h"
 #include "isp4_interface.h"
+#include "isp4_video.h"
 
 /*
  * one is for none sesnor specefic response which is not used now
@@ -97,6 +98,7 @@ struct isp4_subdev_thread_param {
 struct isp4_subdev {
 	struct v4l2_subdev sdev;
 	struct isp4_interface ispif;
+	struct isp4vid_dev isp_vdev;
 
 	struct media_pad sdev_pad;
 
drivers/media/platform/amd/isp4/isp4_video.c new file +1213 -0

1,213 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_video.h new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v3 5/7] media: platform: amd: isp4 video node and buffers handling added

…

Quoted 1 line

buffer realated fix from branch v6.16-drm-tip-isp4-for-amd on

…
related?

Regards,
Markus

author maintainer
#9 lore raw

Re: [PATCH v3 5/7] media: platform: amd: isp4 video node and buffers handling added

Thanks, Markus Elfring

Quoted 8 lines · Markus Elfring

…

Quoted 1 line

buffer realated fix from branch v6.16-drm-tip-isp4-for-amd on

…
related?

Regards,
Markus

Yes, it's a typo, will fix.

Signature · 2 lines
Regards,
Bin
#10 lore raw

Re: [PATCH v3 5/7] media: platform: amd: isp4 video node and buffers handling added

In reply to Bin Du

Hi Bin,

Thank you for the patch.

Quoted 21 lines · Bin Du

Isp video implements v4l2 video interface and supports NV12 and YUYV. It manages buffers, pipeline power and state. Cherry-picked Sultan's DMA buffer realated fix from branch v6.16-drm-tip-isp4-for-amd on
https://github.com/kerneltoast/kernel_x86_laptop.git

---
 MAINTAINERS                                   |    2 +
 drivers/media/platform/amd/isp4/Makefile      |    1 +
 drivers/media/platform/amd/isp4/isp4.c        |   10 +
 drivers/media/platform/amd/isp4/isp4_subdev.c |   95 +-
 drivers/media/platform/amd/isp4/isp4_subdev.h |    2 +
 drivers/media/platform/amd/isp4/isp4_video.c  | 1213 +++++++++++++++++
 drivers/media/platform/amd/isp4/isp4_video.h  |   87 ++
 7 files changed, 1406 insertions(+), 4 deletions(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h

[snip]

Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +0 -0
new file mode 100644
index 000000000000..642faff83287

[snip]

drivers/media/platform/amd/isp4/isp4_video.c line 580

Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +8 -0
+static int isp4vid_ioctl_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
+{
+	struct isp4vid_dev *isp_vdev = video_drvdata(file);
+
+	strscpy(cap->driver, ISP4VID_ISP_DRV_NAME, sizeof(cap->driver));
+	snprintf(cap->card, sizeof(cap->card), "%s", ISP4VID_ISP_DRV_NAME);
+	snprintf(cap->bus_info, sizeof(cap->bus_info),
+		 "platform:%s", ISP4VID_ISP_DRV_NAME);

The bus_info is set by v4l_quercap, I think you can drop it here (please double-check the result).

drivers/media/platform/amd/isp4/isp4_video.c line 583

Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +3 -0
+
+	cap->capabilities |= (V4L2_CAP_STREAMING |
+			      V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_IO_MC);

You can now drop V4L2_CAP_IO_MC (and there's no need for parentheses).

Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +6 -0
+
+	dev_dbg(isp_vdev->dev, "%s|capabilities=0x%X",
+		isp_vdev->vdev.name, cap->capabilities);
+
+	return 0;
+}

[snip]

Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#11 lore raw

Re: [PATCH v3 5/7] media: platform: amd: isp4 video node and buffers handling added

Thanks Laurent Pinchart,

Quoted 37 lines · Laurent Pinchart

Hi Bin,

Thank you for the patch.

Quoted 21 lines · Bin Du

Isp video implements v4l2 video interface and supports NV12 and YUYV. It manages buffers, pipeline power and state. Cherry-picked Sultan's DMA buffer realated fix from branch v6.16-drm-tip-isp4-for-amd on
https://github.com/kerneltoast/kernel_x86_laptop.git

---
  MAINTAINERS                                   |    2 +
  drivers/media/platform/amd/isp4/Makefile      |    1 +
  drivers/media/platform/amd/isp4/isp4.c        |   10 +
  drivers/media/platform/amd/isp4/isp4_subdev.c |   95 +-
  drivers/media/platform/amd/isp4/isp4_subdev.h |    2 +
  drivers/media/platform/amd/isp4/isp4_video.c  | 1213 +++++++++++++++++
  drivers/media/platform/amd/isp4/isp4_video.h  |   87 ++
  7 files changed, 1406 insertions(+), 4 deletions(-)

create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h

[snip]

Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +0 -0
new file mode 100644
index 000000000000..642faff83287

[snip]

Quoted 12 lines

drivers/media/platform/amd/isp4/isp4_video.c line 580

Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +8 -0
+static int isp4vid_ioctl_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
+{
+	struct isp4vid_dev *isp_vdev = video_drvdata(file);
+
+	strscpy(cap->driver, ISP4VID_ISP_DRV_NAME, sizeof(cap->driver));
+	snprintf(cap->card, sizeof(cap->card), "%s", ISP4VID_ISP_DRV_NAME);
+	snprintf(cap->bus_info, sizeof(cap->bus_info),
+		 "platform:%s", ISP4VID_ISP_DRV_NAME);

The bus_info is set by v4l_quercap, I think you can drop it here (please double-check the result).

Yes, you are definitely correct. bus_info is set by media_set_bus_info call in v4l_querycap. Will drop it in the next version.

Quoted 6 lines

drivers/media/platform/amd/isp4/isp4_video.c line 583

Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +3 -0
+
+	cap->capabilities |= (V4L2_CAP_STREAMING |
+			      V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_IO_MC);

You can now drop V4L2_CAP_IO_MC (and there's no need for parentheses).

Sure, will update in the next version.

Quoted 9 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_video.c new file +6 -0
+
+	dev_dbg(isp_vdev->dev, "%s|capabilities=0x%X",
+		isp_vdev->vdev.name, cap->capabilities);
+
+	return 0;
+}

[snip]

Signature · 2 lines
Regards,
Bin
author maintainer
#12 lore raw

PATCH v3 6/7 media: platform: amd: isp4 debug fs logging and more descriptive errors

In reply to Bin Du

Add debug fs for isp4 driver and add more detailed descriptive error info to some of the log message

---
 MAINTAINERS                                   |   2 +
 drivers/media/platform/amd/isp4/Makefile      |   1 +
 drivers/media/platform/amd/isp4/isp4.c        |   4 +
 drivers/media/platform/amd/isp4/isp4_debug.c  | 272 ++++++++++++++++++
 drivers/media/platform/amd/isp4/isp4_debug.h  |  41 +++
 .../media/platform/amd/isp4/isp4_interface.c  |  41 ++-
 drivers/media/platform/amd/isp4/isp4_subdev.c |  29 +-
 7 files changed, 368 insertions(+), 22 deletions(-)
 create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.h
MAINTAINERS +2 -0
index 437232d4912d..7724620896e7 100644
@@ -1145,6 +1145,8 @@ F:	drivers/media/platform/amd/isp4/Kconfig
 F:	drivers/media/platform/amd/isp4/Makefile
 F:	drivers/media/platform/amd/isp4/isp4.c
 F:	drivers/media/platform/amd/isp4/isp4.h
+F:	drivers/media/platform/amd/isp4/isp4_debug.c
+F:	drivers/media/platform/amd/isp4/isp4_debug.h
 F:	drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
 F:	drivers/media/platform/amd/isp4/isp4_hw_reg.h
 F:	drivers/media/platform/amd/isp4/isp4_interface.c
drivers/media/platform/amd/isp4/Makefile +1 -0
index 33589091ca96..c89355fb2374 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_AMD_ISP4) += amd_capture.o
 amd_capture-objs := isp4_subdev.o \
+			isp4_debug.o \
 			isp4_interface.o \
 			isp4.o	\
 			isp4_video.o
\ No newline at end of file
drivers/media/platform/amd/isp4/isp4.c +4 -0
index a46e110a396f..f129a9fbf315 100644
@@ -10,6 +10,7 @@
 #include <media/v4l2-ioctl.h>
 
 #include "isp4.h"
+#include "isp4_debug.h"
 #include "isp4_hw_reg.h"
 
 #define ISP4_DRV_NAME "amd_isp_capture"
@@ -189,6 +190,7 @@ static int isp4_capture_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, isp_dev);
+	isp_debugfs_create(isp_dev);
 
 	return 0;
 
@@ -204,6 +206,8 @@ static void isp4_capture_remove(struct platform_device *pdev)
 {
 	struct isp4_device *isp_dev = platform_get_drvdata(pdev);
 
+	isp_debugfs_remove(isp_dev);
+
 	v4l2_device_unregister_subdev(&isp_dev->isp_sdev.sdev);
 
 	media_device_unregister(&isp_dev->mdev);
drivers/media/platform/amd/isp4/isp4_debug.c new file +272 -0

272 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_debug.h new file +41 -0

41 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_interface.c +26 -15

113 lines not on this page · raw message

drivers/media/platform/amd/isp4/isp4_subdev.c +22 -7
index 2eb9446bfea7..a82ea4c80ea3 100644
@@ -7,6 +7,7 @@
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 
+#include "isp4_debug.h"
 #include "isp4_fw_cmd_resp.h"
 #include "isp4_interface.h"
 #include "isp4_subdev.h"
@@ -252,7 +253,9 @@ static int isp4sd_setup_output(struct isp4_subdev *isp_subdev,
 		return -EINVAL;
 	}
 
-	dev_dbg(dev, "channel: w:h=%u:%u,lp:%u,cp%u\n",
+	dev_dbg(dev, "channel:%s,fmt %s,w:h=%u:%u,lp:%u,cp%u\n",
+		isp4dbg_get_out_ch_str(cmd_ch_prop.ch),
+		isp4dbg_get_img_fmt_str(cmd_ch_prop.image_prop.image_format),
 		cmd_ch_prop.image_prop.width, cmd_ch_prop.image_prop.height,
 		cmd_ch_prop.image_prop.luma_pitch,
 		cmd_ch_prop.image_prop.chroma_pitch);
@@ -275,6 +278,9 @@ static int isp4sd_setup_output(struct isp4_subdev *isp_subdev,
 		return ret;
 	}
 
+	dev_dbg(dev, "enable channel %s\n",
+		isp4dbg_get_out_ch_str(cmd_ch_en.ch));
+
 	if (!sensor_info->start_stream_cmd_sent) {
 		ret = isp4sd_kickoff_stream(isp_subdev, out_prop->width,
 					    out_prop->height);
@@ -428,8 +434,9 @@ static void isp4sd_fw_resp_cmd_done(struct isp4_subdev *isp_subdev,
 		isp4if_rm_cmd_from_cmdq(ispif, para->cmd_seq_num, para->cmd_id);
 	struct device *dev = isp_subdev->dev;
 
-	dev_dbg(dev, "stream %d,cmd (0x%08x)(%d),seq %u, ele %p\n",
+	dev_dbg(dev, "stream %d,cmd %s(0x%08x)(%d),seq %u, ele %p\n",
 		stream_id,
+		isp4dbg_get_cmd_str(para->cmd_id),
 		para->cmd_id, para->cmd_status, para->cmd_seq_num,
 		ele);
 
@@ -486,8 +493,9 @@ isp4sd_preview_done(struct isp4_subdev *isp_subdev,
 			pcb->preview.status = ISP4VID_BUF_DONE_STATUS_SUCCESS;
 		}
 	} else if (meta->preview.enabled) {
-		dev_err(dev, "fail bad preview status %u\n",
-			meta->preview.status);
+		dev_err(dev, "fail bad preview status %u(%s)\n",
+			meta->preview.status,
+			isp4dbg_get_buf_done_str(meta->preview.status));
 	}
 
 	return prev;
@@ -546,14 +554,18 @@ static void isp4sd_fw_resp_frame_done(struct isp4_subdev *isp_subdev,
 	pcb.poc = meta->poc;
 	pcb.cam_id = 0;
 
-	dev_dbg(dev, "ts:%llu,streamId:%d,poc:%u,preview_en:%u,(%i)\n",
+	dev_dbg(dev, "ts:%llu,streamId:%d,poc:%u,preview_en:%u,%s(%i)\n",
 		ktime_get_ns(), stream_id, meta->poc,
 		meta->preview.enabled,
+		isp4dbg_get_buf_done_str(meta->preview.status),
 		meta->preview.status);
 
 	prev = isp4sd_preview_done(isp_subdev, meta, &pcb);
-	if (pcb.preview.status != ISP4VID_BUF_DONE_STATUS_ABSENT)
+	if (pcb.preview.status != ISP4VID_BUF_DONE_STATUS_ABSENT) {
+		isp4dbg_show_bufmeta_info(dev, "prev", &meta->preview,
+					  &pcb.preview.buf);
 		isp4vid_notify(&isp_subdev->isp_vdev, &pcb);
+	}
 
 	isp4if_dealloc_buffer_node(prev);
 
@@ -574,6 +586,8 @@ static void isp4sd_fw_resp_func(struct isp4_subdev *isp_subdev,
 	if (ispif->status < ISP4IF_STATUS_FW_RUNNING)
 		return;
 
+	isp_fw_log_print(isp_subdev);
+
 	while (true) {
 		s32 ret;
 
@@ -591,7 +605,8 @@ static void isp4sd_fw_resp_func(struct isp4_subdev *isp_subdev,
 						  &resp.param.frame_done);
 			break;
 		default:
-			dev_err(dev, "-><- fail respid (0x%x)\n",
+			dev_err(dev, "-><- fail respid %s(0x%x)\n",
+				isp4dbg_get_resp_str(resp.resp_id),
 				resp.resp_id);
 			break;
 		}
Signature · 1 line
2.34.1
author maintainer
#13 lore raw

PATCH v3 7/7 Documentation: add documentation of AMD isp 4 driver

In reply to Bin Du

Add documentation for AMD isp 4 and describe the main components

---
 Documentation/admin-guide/media/amdisp4-1.rst | 66 +++++++++++++++++++
 Documentation/admin-guide/media/amdisp4.dot   |  8 +++
 .../admin-guide/media/v4l-drivers.rst         |  1 +
 MAINTAINERS                                   |  2 +
 4 files changed, 77 insertions(+)
 create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst
 create mode 100644 Documentation/admin-guide/media/amdisp4.dot
Documentation/admin-guide/media/amdisp4-1.rst new file +66 -0
new file mode 100644
index 000000000000..a5ed78912d0f
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>
+
+====================================
+AMD Image Signal Processor (amdisp4)
+====================================
+
+Introduction
+============
+
+This file documents the driver for the AMD ISP4 that is part of
+AMD Ryzen AI Max 385 SoC.
+
+The driver is located under drivers/media/platform/amd/isp4 and uses
+the Media-Controller API.
+
+Topology
+========
+
+.. _amdisp4_topology_graph:
+
+.. kernel-figure:: amdisp4.dot
+     :alt:   Diagram of the media pipeline topology
+     :align: center
+
+
+
+The driver has 1 sub-device:
+
+- isp: used to resize and process bayer raw frames in to yuv.
+
+The driver has 1 video device:
+
+- capture video device: capture device for retrieving images.
+
+
+  - ISP4 Image Signal Processing Subdevice Node
+
+-----------------------------------------------
+
+The isp4 is represented as a single V4L2 subdev, the sub-device does not
+provide interface to the user space. The sub-device is connected to one video node
+(isp4_capture) with immutable active link. The isp entity is connected
+to sensor pad 0 and receives the frames using CSI-2 protocol. The sub-device is
+also responsible to configure CSI2-2 receiver.
+The sub-device processes bayer raw data from the connected sensor and output
+them to different YUV formats. The isp also has scaling capabilities.
+
+  - isp4_capture - Frames Capture Video Node
+
+--------------------------------------------
+
+Isp4_capture is a capture device to capture frames to memory.
+This entity is the DMA engine that write the frames to memory.
+The entity is connected to isp4 sub-device.
+
+Capturing Video Frames Example
+==============================
+
+.. code-block:: bash
+
+         # set the links
+
+         # start streaming:
+         v4l2-ctl "-d" "/dev/video0" "--set-fmt-video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "--stream-count=10"
Documentation/admin-guide/media/amdisp4.dot new file +8 -0
new file mode 100644
index 000000000000..a4c2f0cceb30
@@ -0,0 +1,8 @@
+digraph board {
+	rankdir=TB
+	n00000001 [label="{{<port0> 0} | amd isp4\n | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n00000004 [style=bold]
+	n00000004 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n0000000a [label="{{} | ov05c10 22-0010\n/dev/v4l-subdev0 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
+	n0000000a:port0 -> n00000001:port0 [style=bold]
+}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
index 3bac5165b134..6027416e5373 100644
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation
 .. toctree::
 	:maxdepth: 2
 
+	amdisp4-1
 	bttv
 	c3-isp
 	cafe_ccic
MAINTAINERS +2 -0
index 7724620896e7..72ef7c77d881 100644
@@ -1139,6 +1139,8 @@ M:	Nirujogi Pratap <[email protected]>
 L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media.git
+F:	Documentation/admin-guide/media/amdisp4-1.rst
+F:	Documentation/admin-guide/media/amdisp4.dot
 F:	drivers/media/platform/amd/Kconfig
 F:	drivers/media/platform/amd/Makefile
 F:	drivers/media/platform/amd/isp4/Kconfig
Signature · 1 line
2.34.1
Reviewed-by on v3 7/7
#14 lore raw

Re: [PATCH v3 7/7] Documentation: add documentation of AMD isp 4 driver

Just two small nits to me.

Quoted 1 line · Bin

Add documentation for AMD isp 4 and describe the main components

Probably should be "ISP"

Quoted 4 lines
Quoted 18 lines
---
  Documentation/admin-guide/media/amdisp4-1.rst | 66 +++++++++++++++++++
  Documentation/admin-guide/media/amdisp4.dot   |  8 +++
  .../admin-guide/media/v4l-drivers.rst         |  1 +
  MAINTAINERS                                   |  2 +
  4 files changed, 77 insertions(+)

create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot

Documentation/admin-guide/media/amdisp4-1.rst new file +3 -0
new file mode 100644
index 000000000000..a5ed78912d0f
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>

Documentation/admin-guide/media/amdisp4-1.rst line 13

Quoted 10 lines
Documentation/admin-guide/media/amdisp4-1.rst new file +10 -0
+
+====================================
+AMD Image Signal Processor (amdisp4)
+====================================
+
+Introduction
+============
+
+This file documents the driver for the AMD ISP4 that is part of
+AMD Ryzen AI Max 385 SoC.

It's in 390 too isn't it?

Maybe it's better to say:
Ryzen AI Max 300 Series

That's what https://www.amd.com/en/products/processors/laptop/ryzen/ai-300-series/amd-ryzen-ai-max-plus-395.html uses after all.

Quoted 92 lines
Documentation/admin-guide/media/amdisp4-1.rst new file +53 -0
+
+The driver is located under drivers/media/platform/amd/isp4 and uses
+the Media-Controller API.
+
+Topology
+========
+
+.. _amdisp4_topology_graph:
+
+.. kernel-figure:: amdisp4.dot
+     :alt:   Diagram of the media pipeline topology
+     :align: center
+
+
+
+The driver has 1 sub-device:
+
+- isp: used to resize and process bayer raw frames in to yuv.
+
+The driver has 1 video device:
+
+- capture video device: capture device for retrieving images.
+
+
+  - ISP4 Image Signal Processing Subdevice Node
+
+-----------------------------------------------
+
+The isp4 is represented as a single V4L2 subdev, the sub-device does not
+provide interface to the user space. The sub-device is connected to one video node
+(isp4_capture) with immutable active link. The isp entity is connected
+to sensor pad 0 and receives the frames using CSI-2 protocol. The sub-device is
+also responsible to configure CSI2-2 receiver.
+The sub-device processes bayer raw data from the connected sensor and output
+them to different YUV formats. The isp also has scaling capabilities.
+
+  - isp4_capture - Frames Capture Video Node
+
+--------------------------------------------
+
+Isp4_capture is a capture device to capture frames to memory.
+This entity is the DMA engine that write the frames to memory.
+The entity is connected to isp4 sub-device.
+
+Capturing Video Frames Example
+==============================
+
+.. code-block:: bash
+
+         # set the links
+
+         # start streaming:
+         v4l2-ctl "-d" "/dev/video0" "--set-fmt-video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "--stream-count=10"
Documentation/admin-guide/media/amdisp4.dot new file +8 -0
new file mode 100644
index 000000000000..a4c2f0cceb30
@@ -0,0 +1,8 @@
+digraph board {
+	rankdir=TB
+	n00000001 [label="{{<port0> 0} | amd isp4\n | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n00000004 [style=bold]
+	n00000004 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n0000000a [label="{{} | ov05c10 22-0010\n/dev/v4l-subdev0 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
+	n0000000a:port0 -> n00000001:port0 [style=bold]
+}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
index 3bac5165b134..6027416e5373 100644
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation
  .. toctree::
  	:maxdepth: 2
 
+	amdisp4-1
  	bttv
  	c3-isp
  	cafe_ccic
MAINTAINERS +2 -0
index 7724620896e7..72ef7c77d881 100644
@@ -1139,6 +1139,8 @@ M:	Nirujogi Pratap <[email protected]>
  L:	[email protected]
  S:	Maintained
  T:	git git://linuxtv.org/media.git
+F:	Documentation/admin-guide/media/amdisp4-1.rst
+F:	Documentation/admin-guide/media/amdisp4.dot
  F:	drivers/media/platform/amd/Kconfig
  F:	drivers/media/platform/amd/Makefile
  F:	drivers/media/platform/amd/isp4/Kconfig
author maintainer
#15 lore raw

Re: [PATCH v3 7/7] Documentation: add documentation of AMD isp 4 driver

Thanks Mario.

Quoted 7 lines · Mario Limonciello

Just two small nits to me.

Quoted 1 line · Bin

Add documentation for AMD isp 4 and describe the main components

Probably should be "ISP"

Sure, will update

Quoted 7 lines
Quoted 4 lines

Many thanks for the review.

Quoted 31 lines
Quoted 18 lines

---
  Documentation/admin-guide/media/amdisp4-1.rst | 66 +++++++++++++++++++ Documentation/admin-guide/media/amdisp4.dot   |  8 +++ .../admin-guide/media/v4l-drivers.rst         |  1 + MAINTAINERS                                   |  2 +

  4 files changed, 77 insertions(+)

  create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot

Documentation/admin-guide/media/amdisp4-1.rst new file +3 -0
new file mode 100644
index 000000000000..a5ed78912d0f
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>

Documentation/admin-guide/media/amdisp4-1.rst line 13

Quoted 10 lines
Documentation/admin-guide/media/amdisp4-1.rst new file +10 -0
+
+====================================
+AMD Image Signal Processor (amdisp4)
+====================================
+
+Introduction
+============
+
+This file documents the driver for the AMD ISP4 that is part of
+AMD Ryzen AI Max 385 SoC.

It's in 390 too isn't it?

Quoted 5 lines

Maybe it's better to say:
Ryzen AI Max 300 Series

That's what https://www.amd.com/en/products/processors/laptop/ryzen/ ai-300-series/amd-ryzen-ai-max-plus-395.html uses after all.

Yes, it's better, will update

Quoted 99 lines
Quoted 98 lines
Documentation/admin-guide/media/amdisp4-1.rst new file +30 -0
+
+The driver is located under drivers/media/platform/amd/isp4 and uses
+the Media-Controller API.
+
+Topology
+========
+
+.. _amdisp4_topology_graph:
+
+.. kernel-figure:: amdisp4.dot
+     :alt:   Diagram of the media pipeline topology
+     :align: center
+
+
+
+The driver has 1 sub-device:
+
+- isp: used to resize and process bayer raw frames in to yuv.
+
+The driver has 1 video device:
+
+- capture video device: capture device for retrieving images.
+
+
+  - ISP4 Image Signal Processing Subdevice Node
+
+-----------------------------------------------
+
+The isp4 is represented as a single V4L2 subdev, the sub-device does not
+provide interface to the user space. The sub-device is connected to 

one video node

Documentation/admin-guide/media/amdisp4-1.rst new file +2 -0
+(isp4_capture) with immutable active link. The isp entity is connected
+to sensor pad 0 and receives the frames using CSI-2 protocol. The 

sub-device is

Documentation/admin-guide/media/amdisp4-1.rst new file +2 -0
+also responsible to configure CSI2-2 receiver.
+The sub-device processes bayer raw data from the connected sensor and 

output

Documentation/admin-guide/media/amdisp4-1.rst new file +19 -0
+them to different YUV formats. The isp also has scaling capabilities.
+
+  - isp4_capture - Frames Capture Video Node
+
+--------------------------------------------
+
+Isp4_capture is a capture device to capture frames to memory.
+This entity is the DMA engine that write the frames to memory.
+The entity is connected to isp4 sub-device.
+
+Capturing Video Frames Example
+==============================
+
+.. code-block:: bash
+
+         # set the links
+
+         # start streaming:
+         v4l2-ctl "-d" "/dev/video0" "--set-fmt- 

video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "-- stream-count=10"

Documentation/admin-guide/media/amdisp4.dot new file +3 -0
new file mode 100644
index 000000000000..a4c2f0cceb30
@@ -0,0 +1,8 @@
+digraph board {
+    rankdir=TB
+    n00000001 [label="{{<port0> 0} | amd isp4\n | {<port1> 1}}", 

shape=Mrecord, style=filled, fillcolor=green]
+    n00000001:port1 -> n00000004 [style=bold]
+    n00000004 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+    n0000000a [label="{{} | ov05c10 22-0010\n/dev/v4l-subdev0 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green] +    n0000000a:port0 -> n00000001:port0 [style=bold]

Documentation/admin-guide/media/amdisp4.dot new file +1 -0
+}
Documentation/admin-guide/media/v4l-drivers.rst +0 -0
index 3bac5165b134..6027416e5373 100644
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation

  .. toctree::
      :maxdepth: 2
+    amdisp4-1
      bttv
      c3-isp
      cafe_ccic

MAINTAINERS +0 -0
index 7724620896e7..72ef7c77d881 100644
@@ -1139,6 +1139,8 @@ M:    Nirujogi Pratap <[email protected]>

  L:    [email protected]
  S:    Maintained
  T:    git git://linuxtv.org/media.git

MAINTAINERS +2 -0
+F:    Documentation/admin-guide/media/amdisp4-1.rst
+F:    Documentation/admin-guide/media/amdisp4.dot

  F:    drivers/media/platform/amd/Kconfig
  F:    drivers/media/platform/amd/Makefile
  F:    drivers/media/platform/amd/isp4/Kconfig

Signature · 2 lines
Regards,
Bin
#16 lore raw

Re: [PATCH v3 7/7] Documentation: add documentation of AMD isp 4 driver

In reply to Bin Du

Hi Bin,

Thank you for the patch.

Quoted 92 lines · Bin Du

Add documentation for AMD isp 4 and describe the main components

---
 Documentation/admin-guide/media/amdisp4-1.rst | 66 +++++++++++++++++++
 Documentation/admin-guide/media/amdisp4.dot   |  8 +++
 .../admin-guide/media/v4l-drivers.rst         |  1 +
 MAINTAINERS                                   |  2 +
 4 files changed, 77 insertions(+)
 create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst
 create mode 100644 Documentation/admin-guide/media/amdisp4.dot
Documentation/admin-guide/media/amdisp4-1.rst new file +66 -0
new file mode 100644
index 000000000000..a5ed78912d0f
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>
+
+====================================
+AMD Image Signal Processor (amdisp4)
+====================================
+
+Introduction
+============
+
+This file documents the driver for the AMD ISP4 that is part of
+AMD Ryzen AI Max 385 SoC.
+
+The driver is located under drivers/media/platform/amd/isp4 and uses
+the Media-Controller API.
+
+Topology
+========
+
+.. _amdisp4_topology_graph:
+
+.. kernel-figure:: amdisp4.dot
+     :alt:   Diagram of the media pipeline topology
+     :align: center
+
+
+
+The driver has 1 sub-device:
+
+- isp: used to resize and process bayer raw frames in to yuv.
+
+The driver has 1 video device:
+
+- capture video device: capture device for retrieving images.
+
+
+  - ISP4 Image Signal Processing Subdevice Node
+
+-----------------------------------------------
+
+The isp4 is represented as a single V4L2 subdev, the sub-device does not
+provide interface to the user space. The sub-device is connected to one video node
+(isp4_capture) with immutable active link. The isp entity is connected
+to sensor pad 0 and receives the frames using CSI-2 protocol. The sub-device is
+also responsible to configure CSI2-2 receiver.
+The sub-device processes bayer raw data from the connected sensor and output
+them to different YUV formats. The isp also has scaling capabilities.
+
+  - isp4_capture - Frames Capture Video Node
+
+--------------------------------------------
+
+Isp4_capture is a capture device to capture frames to memory.
+This entity is the DMA engine that write the frames to memory.
+The entity is connected to isp4 sub-device.
+
+Capturing Video Frames Example
+==============================
+
+.. code-block:: bash
+
+         # set the links
+
+         # start streaming:
+         v4l2-ctl "-d" "/dev/video0" "--set-fmt-video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "--stream-count=10"
Documentation/admin-guide/media/amdisp4.dot new file +0 -0
new file mode 100644
index 000000000000..a4c2f0cceb30

Documentation/admin-guide/media/amdisp4.dot line 6

Quoted 6 lines
Documentation/admin-guide/media/amdisp4.dot new file +6 -0
@@ -0,0 +1,8 @@
+digraph board {
+	rankdir=TB
+	n00000001 [label="{{<port0> 0} | amd isp4\n | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n00000004 [style=bold]
+	n00000004 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n0000000a [label="{{} | ov05c10 22-0010\n/dev/v4l-subdev0 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]

Does the driver still have a subdev for the sensor, or is that a leftover ? Looking at the source code, I don't see where the sensor would be handled.

Quoted 27 lines
Documentation/admin-guide/media/amdisp4.dot new file +2 -0
+	n0000000a:port0 -> n00000001:port0 [style=bold]
+}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
index 3bac5165b134..6027416e5373 100644
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation
 .. toctree::
 	:maxdepth: 2
 
+	amdisp4-1
 	bttv
 	c3-isp
 	cafe_ccic
MAINTAINERS +2 -0
index 7724620896e7..72ef7c77d881 100644
@@ -1139,6 +1139,8 @@ M:	Nirujogi Pratap <[email protected]>
 L:	[email protected]
 S:	Maintained
 T:	git git://linuxtv.org/media.git
+F:	Documentation/admin-guide/media/amdisp4-1.rst
+F:	Documentation/admin-guide/media/amdisp4.dot
 F:	drivers/media/platform/amd/Kconfig
 F:	drivers/media/platform/amd/Makefile
 F:	drivers/media/platform/amd/isp4/Kconfig
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#17 lore raw

Re: [PATCH v3 7/7] Documentation: add documentation of AMD isp 4 driver

Thanks Laurent Pinchart for your careful review.

Quoted 99 lines · Laurent Pinchart

Hi Bin,

Thank you for the patch.

Quoted 94 lines · Bin Du

Add documentation for AMD isp 4 and describe the main components

---
  Documentation/admin-guide/media/amdisp4-1.rst | 66 +++++++++++++++++++
  Documentation/admin-guide/media/amdisp4.dot   |  8 +++
  .../admin-guide/media/v4l-drivers.rst         |  1 +
  MAINTAINERS                                   |  2 +
  4 files changed, 77 insertions(+)

create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot

Documentation/admin-guide/media/amdisp4-1.rst new file +66 -0
new file mode 100644
index 000000000000..a5ed78912d0f
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. include:: <isonum.txt>
+
+====================================
+AMD Image Signal Processor (amdisp4)
+====================================
+
+Introduction
+============
+
+This file documents the driver for the AMD ISP4 that is part of
+AMD Ryzen AI Max 385 SoC.
+
+The driver is located under drivers/media/platform/amd/isp4 and uses
+the Media-Controller API.
+
+Topology
+========
+
+.. _amdisp4_topology_graph:
+
+.. kernel-figure:: amdisp4.dot
+     :alt:   Diagram of the media pipeline topology
+     :align: center
+
+
+
+The driver has 1 sub-device:
+
+- isp: used to resize and process bayer raw frames in to yuv.
+
+The driver has 1 video device:
+
+- capture video device: capture device for retrieving images.
+
+
+  - ISP4 Image Signal Processing Subdevice Node
+
+-----------------------------------------------
+
+The isp4 is represented as a single V4L2 subdev, the sub-device does not
+provide interface to the user space. The sub-device is connected to one video node
+(isp4_capture) with immutable active link. The isp entity is connected
+to sensor pad 0 and receives the frames using CSI-2 protocol. The sub-device is
+also responsible to configure CSI2-2 receiver.
+The sub-device processes bayer raw data from the connected sensor and output
+them to different YUV formats. The isp also has scaling capabilities.
+
+  - isp4_capture - Frames Capture Video Node
+
+--------------------------------------------
+
+Isp4_capture is a capture device to capture frames to memory.
+This entity is the DMA engine that write the frames to memory.
+The entity is connected to isp4 sub-device.
+
+Capturing Video Frames Example
+==============================
+
+.. code-block:: bash
+
+         # set the links
+
+         # start streaming:
+         v4l2-ctl "-d" "/dev/video0" "--set-fmt-video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "--stream-count=10"
Documentation/admin-guide/media/amdisp4.dot new file +2 -0
new file mode 100644
index 000000000000..a4c2f0cceb30
@@ -0,0 +1,8 @@
+digraph board {
+	rankdir=TB
Quoted 9 lines

Documentation/admin-guide/media/amdisp4.dot line 6

Quoted 4 lines
Documentation/admin-guide/media/amdisp4.dot new file +4 -0
+	n00000001 [label="{{<port0> 0} | amd isp4\n | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n00000004 [style=bold]
+	n00000004 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n0000000a [label="{{} | ov05c10 22-0010\n/dev/v4l-subdev0 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]

Does the driver still have a subdev for the sensor, or is that a leftover ? Looking at the source code, I don't see where the sensor would be handled.

Yes, you are definitely correct, no sensor subdev anymore. My fault, i forgot to sync the document to the latest one, will update in the next version, really sorry for that.

Quoted 28 lines
Quoted 27 lines
Documentation/admin-guide/media/amdisp4.dot new file +2 -0
+	n0000000a:port0 -> n00000001:port0 [style=bold]
+}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
index 3bac5165b134..6027416e5373 100644
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation
  .. toctree::
  	:maxdepth: 2
 
+	amdisp4-1
  	bttv
  	c3-isp
  	cafe_ccic
MAINTAINERS +2 -0
index 7724620896e7..72ef7c77d881 100644
@@ -1139,6 +1139,8 @@ M:	Nirujogi Pratap <[email protected]>
  L:	[email protected]
  S:	Maintained
  T:	git git://linuxtv.org/media.git
+F:	Documentation/admin-guide/media/amdisp4-1.rst
+F:	Documentation/admin-guide/media/amdisp4.dot
  F:	drivers/media/platform/amd/Kconfig
  F:	drivers/media/platform/amd/Makefile
  F:	drivers/media/platform/amd/isp4/Kconfig
Signature · 2 lines
Regards,
Bin
Reviewed-by on v3 1/7
#18 lore raw
In reply to Bin Du
Quoted 9 lines · Bin

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

Quoted 271 lines
  MAINTAINERS                              |  13 +++
  drivers/media/platform/Kconfig           |   1 +
  drivers/media/platform/Makefile          |   1 +
  drivers/media/platform/amd/Kconfig       |   3 +
  drivers/media/platform/amd/Makefile      |   3 +
  drivers/media/platform/amd/isp4/Kconfig  |  13 +++
  drivers/media/platform/amd/isp4/Makefile |   6 ++
  drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
  drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
  9 files changed, 185 insertions(+)

create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

MAINTAINERS +13 -0
index fe168477caa4..3ad845f1511b 100644
@@ -1133,6 +1133,19 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git
  F:	drivers/iommu/amd/
  F:	include/linux/amd-iommu.h
 
+AMD ISP4 DRIVER
+M:	Bin Du <[email protected]>
+M:	Nirujogi Pratap <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media.git
+F:	drivers/media/platform/amd/Kconfig
+F:	drivers/media/platform/amd/Makefile
+F:	drivers/media/platform/amd/isp4/Kconfig
+F:	drivers/media/platform/amd/isp4/Makefile
+F:	drivers/media/platform/amd/isp4/isp4.c
+F:	drivers/media/platform/amd/isp4/isp4.h
+
  AMD KFD
  M:	Felix Kuehling <[email protected]>
  L:	[email protected]
drivers/media/platform/Kconfig +1 -0
index 9287faafdce5..772c70665510 100644
@@ -63,6 +63,7 @@ config VIDEO_MUX
 
  # Platform drivers - Please keep it alphabetically sorted
  source "drivers/media/platform/allegro-dvt/Kconfig"
+source "drivers/media/platform/amd/Kconfig"
  source "drivers/media/platform/amlogic/Kconfig"
  source "drivers/media/platform/amphion/Kconfig"
  source "drivers/media/platform/aspeed/Kconfig"
drivers/media/platform/Makefile +1 -0
index 6fd7db0541c7..b207bd8d8022 100644
@@ -6,6 +6,7 @@
  # Place here, alphabetically sorted by directory
  # (e. g. LC_ALL=C sort Makefile)
  obj-y += allegro-dvt/
+obj-y += amd/
  obj-y += amlogic/
  obj-y += amphion/
  obj-y += aspeed/
drivers/media/platform/amd/Kconfig new file +3 -0
new file mode 100644
index 000000000000..25af49f246b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
new file mode 100644
index 000000000000..8bfc1955f22e
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += isp4/
drivers/media/platform/amd/isp4/Kconfig new file +13 -0
new file mode 100644
index 000000000000..0268060c2dae
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+config AMD_ISP4
+	tristate "AMD ISP4 and camera driver"
+	depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API
+	select VIDEOBUF2_CORE
+	select VIDEOBUF2_V4L2
+	select VIDEOBUF2_MEMOPS
+	help
+	  This is support for AMD ISP4 and camera subsystem driver.
+	  Say Y here to enable the ISP4 and camera device for video capture.
+	  To compile this driver as a module, choose M here. The module will
+	  be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
new file mode 100644
index 000000000000..de0092dad26f
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025 Advanced Micro Devices, Inc.
+
+obj-$(CONFIG_AMD_ISP4) += amd_capture.o
+amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +121 -0
new file mode 100644
index 000000000000..6ff3ded4310a
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/pm_runtime.h>
+#include <linux/vmalloc.h>
+#include <media/v4l2-ioctl.h>
+
+#include "isp4.h"
+
+#define VIDEO_BUF_NUM 5
+
+#define ISP4_DRV_NAME "amd_isp_capture"
+
+/* interrupt num */
+static const u32 isp4_ringbuf_interrupt_num[] = {
+	0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */
+	1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */
+	3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */
+	4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */
+};
+
+#define to_isp4_device(dev) \
+	((struct isp4_device *)container_of(dev, struct isp4_device, v4l2_dev))
+
+static irqreturn_t isp4_irq_handler(int irq, void *arg)
+{
+	return IRQ_HANDLED;
+}
+
+static int isp4_capture_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct isp4_device *isp_dev;
+	int i, irq, ret;
+
+	isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL);
+	if (!isp_dev)
+		return -ENOMEM;
+
+	isp_dev->pdev = pdev;
+	dev->init_name = ISP4_DRV_NAME;
+
+	for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) {
+		irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]);
+		if (irq < 0)
+			return dev_err_probe(dev, -ENODEV,
+					     "fail to get irq %d\n",
+					     isp4_ringbuf_interrupt_num[i]);
+		ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0,
+				       "ISP_IRQ", &pdev->dev);
+		if (ret)
+			return dev_err_probe(dev, ret, "fail to req irq %d\n",
+					     irq);
+	}
+
+	/* Link the media device within the v4l2_device */
+	isp_dev->v4l2_dev.mdev = &isp_dev->mdev;
+
+	/* Initialize media device */
+	strscpy(isp_dev->mdev.model, "amd_isp41_mdev",
+		sizeof(isp_dev->mdev.model));
+	snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info),
+		 "platform:%s", ISP4_DRV_NAME);
+	isp_dev->mdev.dev = &pdev->dev;
+	media_device_init(&isp_dev->mdev);
+
+	/* register v4l2 device */
+	snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name),
+		 "AMD-V4L2-ROOT");
+	ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "fail register v4l2 device\n");
+
+	ret = media_device_register(&isp_dev->mdev);
+	if (ret) {
+		dev_err(dev, "fail to register media device %d\n", ret);
+		goto err_unreg_v4l2;
+	}
+
+	platform_set_drvdata(pdev, isp_dev);
+
+	pm_runtime_set_suspended(dev);
+	pm_runtime_enable(dev);
+
+	return 0;
+
+err_unreg_v4l2:
+	v4l2_device_unregister(&isp_dev->v4l2_dev);
+
+	return dev_err_probe(dev, ret, "isp probe fail\n");
+}
+
+static void isp4_capture_remove(struct platform_device *pdev)
+{
+	struct isp4_device *isp_dev = platform_get_drvdata(pdev);
+
+	media_device_unregister(&isp_dev->mdev);
+	v4l2_device_unregister(&isp_dev->v4l2_dev);
+}
+
+static struct platform_driver isp4_capture_drv = {
+	.probe = isp4_capture_probe,
+	.remove = isp4_capture_remove,
+	.driver = {
+		.name = ISP4_DRV_NAME,
+		.owner = THIS_MODULE,
+	}
+};
+
+module_platform_driver(isp4_capture_drv);
+
+MODULE_ALIAS("platform:" ISP4_DRV_NAME);
+MODULE_IMPORT_NS("DMA_BUF");
+
+MODULE_DESCRIPTION("AMD ISP4 Driver");
+MODULE_AUTHOR("Bin Du <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/media/platform/amd/isp4/isp4.h new file +24 -0
new file mode 100644
index 000000000000..8535f662ab49
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _ISP4_H_
+#define _ISP4_H_
+
+#include <linux/mutex.h>
+#include <media/v4l2-device.h>
+#include <media/videobuf2-memops.h>
+#include <media/videobuf2-vmalloc.h>
+
+#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
+
+struct isp4_device {
+	struct v4l2_device v4l2_dev;
+	struct media_device mdev;
+
+	struct platform_device *pdev;
+	struct notifier_block i2c_nb;
+};
+
+#endif /* _ISP4_H_ */
author maintainer
#19 lore raw

Many thanks Mario for the review.

Quoted 283 lines · Mario Limonciello
Quoted 9 lines · Bin

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

Quoted 271 lines

  MAINTAINERS                              |  13 +++ drivers/media/platform/Kconfig           |   1 + drivers/media/platform/Makefile          |   1 + drivers/media/platform/amd/Kconfig       |   3 + drivers/media/platform/amd/Makefile      |   3 + drivers/media/platform/amd/isp4/Kconfig  |  13 +++ drivers/media/platform/amd/isp4/Makefile |   6 ++ drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h   |  24 +++++

  9 files changed, 185 insertions(+)

  create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

MAINTAINERS +0 -0
index fe168477caa4..3ad845f1511b 100644
@@ -1133,6 +1133,19 @@ T:    git git://git.kernel.org/pub/scm/linux/ 

kernel/git/iommu/linux.git
  F:    drivers/iommu/amd/
  F:    include/linux/amd-iommu.h

MAINTAINERS +13 -0
+AMD ISP4 DRIVER
+M:    Bin Du <[email protected]>
+M:    Nirujogi Pratap <[email protected]>
+L:    [email protected]
+S:    Maintained
+T:    git git://linuxtv.org/media.git
+F:    drivers/media/platform/amd/Kconfig
+F:    drivers/media/platform/amd/Makefile
+F:    drivers/media/platform/amd/isp4/Kconfig
+F:    drivers/media/platform/amd/isp4/Makefile
+F:    drivers/media/platform/amd/isp4/isp4.c
+F:    drivers/media/platform/amd/isp4/isp4.h
+

  AMD KFD
  M:    Felix Kuehling <[email protected]>
  L:    [email protected]

drivers/media/platform/Kconfig +0 -0
index 9287faafdce5..772c70665510 100644
@@ -63,6 +63,7 @@ config VIDEO_MUX
   # Platform drivers - Please keep it alphabetically sorted

  source "drivers/media/platform/allegro-dvt/Kconfig" +source "drivers/media/platform/amd/Kconfig" source "drivers/media/platform/amlogic/Kconfig" source "drivers/media/platform/amphion/Kconfig" source "drivers/media/platform/aspeed/Kconfig"

drivers/media/platform/Makefile +0 -0
index 6fd7db0541c7..b207bd8d8022 100644
@@ -6,6 +6,7 @@
   # Place here, alphabetically sorted by directory
   # (e. g. LC_ALL=C sort Makefile)

  obj-y += allegro-dvt/
+obj-y += amd/
  obj-y += amlogic/
  obj-y += amphion/
  obj-y += aspeed/

drivers/media/platform/amd/Kconfig new file +3 -0
new file mode 100644
index 000000000000..25af49f246b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
new file mode 100644
index 000000000000..8bfc1955f22e
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += isp4/
drivers/media/platform/amd/isp4/Kconfig new file +13 -0
new file mode 100644
index 000000000000..0268060c2dae
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+config AMD_ISP4
+    tristate "AMD ISP4 and camera driver"
+    depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API
+    select VIDEOBUF2_CORE
+    select VIDEOBUF2_V4L2
+    select VIDEOBUF2_MEMOPS
+    help
+      This is support for AMD ISP4 and camera subsystem driver.
+      Say Y here to enable the ISP4 and camera device for video capture.
+      To compile this driver as a module, choose M here. The module will
+      be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
new file mode 100644
index 000000000000..de0092dad26f
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025 Advanced Micro Devices, Inc.
+
+obj-$(CONFIG_AMD_ISP4) += amd_capture.o
+amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +25 -0
new file mode 100644
index 000000000000..6ff3ded4310a
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/pm_runtime.h>
+#include <linux/vmalloc.h>
+#include <media/v4l2-ioctl.h>
+
+#include "isp4.h"
+
+#define VIDEO_BUF_NUM 5
+
+#define ISP4_DRV_NAME "amd_isp_capture"
+
+/* interrupt num */
+static const u32 isp4_ringbuf_interrupt_num[] = {
+    0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */
+    1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */
+    3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */
+    4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */
+};
+
+#define to_isp4_device(dev) \
+    ((struct isp4_device *)container_of(dev, struct isp4_device, 

v4l2_dev))

drivers/media/platform/amd/isp4/isp4.c new file +96 -0
+
+static irqreturn_t isp4_irq_handler(int irq, void *arg)
+{
+    return IRQ_HANDLED;
+}
+
+static int isp4_capture_probe(struct platform_device *pdev)
+{
+    struct device *dev = &pdev->dev;
+    struct isp4_device *isp_dev;
+    int i, irq, ret;
+
+    isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL);
+    if (!isp_dev)
+        return -ENOMEM;
+
+    isp_dev->pdev = pdev;
+    dev->init_name = ISP4_DRV_NAME;
+
+    for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) {
+        irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]);
+        if (irq < 0)
+            return dev_err_probe(dev, -ENODEV,
+                         "fail to get irq %d\n",
+                         isp4_ringbuf_interrupt_num[i]);
+        ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0,
+                       "ISP_IRQ", &pdev->dev);
+        if (ret)
+            return dev_err_probe(dev, ret, "fail to req irq %d\n",
+                         irq);
+    }
+
+    /* Link the media device within the v4l2_device */
+    isp_dev->v4l2_dev.mdev = &isp_dev->mdev;
+
+    /* Initialize media device */
+    strscpy(isp_dev->mdev.model, "amd_isp41_mdev",
+        sizeof(isp_dev->mdev.model));
+    snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info),
+         "platform:%s", ISP4_DRV_NAME);
+    isp_dev->mdev.dev = &pdev->dev;
+    media_device_init(&isp_dev->mdev);
+
+    /* register v4l2 device */
+    snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name),
+         "AMD-V4L2-ROOT");
+    ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev);
+    if (ret)
+        return dev_err_probe(dev, ret,
+                     "fail register v4l2 device\n");
+
+    ret = media_device_register(&isp_dev->mdev);
+    if (ret) {
+        dev_err(dev, "fail to register media device %d\n", ret);
+        goto err_unreg_v4l2;
+    }
+
+    platform_set_drvdata(pdev, isp_dev);
+
+    pm_runtime_set_suspended(dev);
+    pm_runtime_enable(dev);
+
+    return 0;
+
+err_unreg_v4l2:
+    v4l2_device_unregister(&isp_dev->v4l2_dev);
+
+    return dev_err_probe(dev, ret, "isp probe fail\n");
+}
+
+static void isp4_capture_remove(struct platform_device *pdev)
+{
+    struct isp4_device *isp_dev = platform_get_drvdata(pdev);
+
+    media_device_unregister(&isp_dev->mdev);
+    v4l2_device_unregister(&isp_dev->v4l2_dev);
+}
+
+static struct platform_driver isp4_capture_drv = {
+    .probe = isp4_capture_probe,
+    .remove = isp4_capture_remove,
+    .driver = {
+        .name = ISP4_DRV_NAME,
+        .owner = THIS_MODULE,
+    }
+};
+
+module_platform_driver(isp4_capture_drv);
+
+MODULE_ALIAS("platform:" ISP4_DRV_NAME);
+MODULE_IMPORT_NS("DMA_BUF");
+
+MODULE_DESCRIPTION("AMD ISP4 Driver");
+MODULE_AUTHOR("Bin Du <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/media/platform/amd/isp4/isp4.h new file +24 -0
new file mode 100644
index 000000000000..8535f662ab49
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _ISP4_H_
+#define _ISP4_H_
+
+#include <linux/mutex.h>
+#include <media/v4l2-device.h>
+#include <media/videobuf2-memops.h>
+#include <media/videobuf2-vmalloc.h>
+
+#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
+
+struct isp4_device {
+    struct v4l2_device v4l2_dev;
+    struct media_device mdev;
+
+    struct platform_device *pdev;
+    struct notifier_block i2c_nb;
+};
+
+#endif /* _ISP4_H_ */
Signature · 2 lines
Regards,
Bin
#20 lore raw
In reply to Bin Du

Hi Bin,

Quoted 9 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

Could you elaborate what are the changes in this version compared to the previous one, please?

Signature · 3 lines
Regards,

Sakari Ailus
#21 lore raw
Quoted 9 lines · Sakari Ailus

Hi Bin,

Quoted 6 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

Quoted 6 lines
Quoted 3 lines

Could you elaborate what are the changes in this version compared to the previous one, please?

Ah, I missed there was a cover page in a different thread. Please ignore.

Signature · 1 line
Sakari Ailus
author maintainer
#22 lore raw

Hi Sakari Ailus,

Quoted 10 lines · Sakari Ailus
Quoted 9 lines · Sakari Ailus

Hi Bin,

Quoted 6 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Could you elaborate what are the changes in this version compared to the previous one, please?

Ah, I missed there was a cover page in a different thread. Please ignore.

Yes, https://lore.kernel.org/linux-media/[email protected]/ is the cover letter, because of some server issue, the cover letter and left patches are sent separately, really sorry for the confusing.

Signature · 2 lines
Regards,
Bin
author maintainer
#24 lore raw

Thanks Markus.

Quoted 6 lines · Markus Elfring
Quoted 1 line

AMD isp4 capture is a v4l2 media device which …

Will a cover letter become helpful for such a patch series?

Regards,
Markus

https://lore.kernel.org/linux-media/[email protected]/ is the cover letter, because of some server issue, the cover letter and left patches are sent separately, really sorry for the inconvenience.

Signature · 2 lines
Regards,
Bin
#25 lore raw
In reply to Bin Du

Hi Bin,

Could you please provide the v4l2-compliance report (please use the very latest version of v4l2-compliance), as well as the output of media-ctl -p -d /dev/media0 (replacing media0 with the appropriate device) ?

Generally speaking, you should include a cover letter in patch series, and that information can be included in the cover letter.

Quoted 26 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
 MAINTAINERS                              |  13 +++
 drivers/media/platform/Kconfig           |   1 +
 drivers/media/platform/Makefile          |   1 +
 drivers/media/platform/amd/Kconfig       |   3 +
 drivers/media/platform/amd/Makefile      |   3 +
 drivers/media/platform/amd/isp4/Kconfig  |  13 +++
 drivers/media/platform/amd/isp4/Makefile |   6 ++
 drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
 drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
 9 files changed, 185 insertions(+)
 create mode 100644 drivers/media/platform/amd/Kconfig
 create mode 100644 drivers/media/platform/amd/Makefile
 create mode 100644 drivers/media/platform/amd/isp4/Kconfig
 create mode 100644 drivers/media/platform/amd/isp4/Makefile
 create mode 100644 drivers/media/platform/amd/isp4/isp4.c
 create mode 100644 drivers/media/platform/amd/isp4/isp4.h
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#26 lore raw

Thanks Laurent Pinchart

Quoted 10 lines · Laurent Pinchart

Hi Bin,

Could you please provide the v4l2-compliance report (please use the very latest version of v4l2-compliance), as well as the output of media-ctl -p -d /dev/media0 (replacing media0 with the appropriate device) ?

Generally speaking, you should include a cover letter in patch series, and that information can be included in the cover letter.

Yes, there is a cover letter for the patch series https://lore.kernel.org/linux-media/[email protected]/, because of some server issue, the cover letter and left patches are sent separately, really sorry for the confusing. It does contain v4l2-compliance report, but the media-ctl output is missing, many thanks for the guide, will include it either in the next patch

Quoted 28 lines · Bin Du
Quoted 26 lines

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
  MAINTAINERS                              |  13 +++
  drivers/media/platform/Kconfig           |   1 +
  drivers/media/platform/Makefile          |   1 +
  drivers/media/platform/amd/Kconfig       |   3 +
  drivers/media/platform/amd/Makefile      |   3 +
  drivers/media/platform/amd/isp4/Kconfig  |  13 +++
  drivers/media/platform/amd/isp4/Makefile |   6 ++
  drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
  drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
  9 files changed, 185 insertions(+)

create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

Signature · 2 lines
Regards,
Bin
#27 lore raw
Quoted 14 lines · Bin

Thanks Laurent Pinchart

Quoted 10 lines · Laurent Pinchart

Hi Bin,

Could you please provide the v4l2-compliance report (please use the very latest version of v4l2-compliance), as well as the output of media-ctl -p -d /dev/media0 (replacing media0 with the appropriate device) ?

Generally speaking, you should include a cover letter in patch series, and that information can be included in the cover letter.

Quoted 6 lines

Yes, there is a cover letter for the patch series
https://lore.kernel.org/linux-media/[email protected]/,
because of some server issue, the cover letter and left patches are sent separately, really sorry for the confusing. It does contain v4l2-compliance report, but the media-ctl output is missing, many thanks for the guide, will include it either in the next patch

My bad, I even replied to that cover letter, but then forgot about it.

Quoted 27 lines
Quoted 27 lines · Bin Du
Quoted 26 lines

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
  MAINTAINERS                              |  13 +++
  drivers/media/platform/Kconfig           |   1 +
  drivers/media/platform/Makefile          |   1 +
  drivers/media/platform/amd/Kconfig       |   3 +
  drivers/media/platform/amd/Makefile      |   3 +
  drivers/media/platform/amd/isp4/Kconfig  |  13 +++
  drivers/media/platform/amd/isp4/Makefile |   6 ++
  drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
  drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
  9 files changed, 185 insertions(+)

create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#28 lore raw
Quoted 15 lines · Laurent Pinchart
Quoted 14 lines · Bin

Thanks Laurent Pinchart

Quoted 10 lines · Laurent Pinchart

Hi Bin,

Could you please provide the v4l2-compliance report (please use the very latest version of v4l2-compliance), as well as the output of media-ctl -p -d /dev/media0 (replacing media0 with the appropriate device) ?

Generally speaking, you should include a cover letter in patch series, and that information can be included in the cover letter.

Quoted 9 lines
Quoted 6 lines

Yes, there is a cover letter for the patch series
https://lore.kernel.org/linux-media/[email protected]/,
because of some server issue, the cover letter and left patches are sent separately, really sorry for the confusing. It does contain v4l2-compliance report, but the media-ctl output is missing, many thanks for the guide, will include it either in the next patch

My bad, I even replied to that cover letter, but then forgot about it.

Never mind, considering you have hundreds of mails, :)

Quoted 28 lines
Quoted 27 lines
Quoted 27 lines · Bin Du
Quoted 26 lines

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
   MAINTAINERS                              |  13 +++
   drivers/media/platform/Kconfig           |   1 +
   drivers/media/platform/Makefile          |   1 +
   drivers/media/platform/amd/Kconfig       |   3 +
   drivers/media/platform/amd/Makefile      |   3 +
   drivers/media/platform/amd/isp4/Kconfig  |  13 +++
   drivers/media/platform/amd/isp4/Makefile |   6 ++
   drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
   drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
   9 files changed, 185 insertions(+)

create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

Signature · 2 lines
Regards,
Bin
#29 lore raw
In reply to Bin Du
Quoted 99 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
  MAINTAINERS                              |  13 +++
  drivers/media/platform/Kconfig           |   1 +
  drivers/media/platform/Makefile          |   1 +
  drivers/media/platform/amd/Kconfig       |   3 +
  drivers/media/platform/amd/Makefile      |   3 +
  drivers/media/platform/amd/isp4/Kconfig  |  13 +++
  drivers/media/platform/amd/isp4/Makefile |   6 ++
  drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++
  drivers/media/platform/amd/isp4/isp4.h   |  24 +++++
  9 files changed, 185 insertions(+)

create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

MAINTAINERS +13 -0
index fe168477caa4..3ad845f1511b 100644
@@ -1133,6 +1133,19 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git
  F:	drivers/iommu/amd/
  F:	include/linux/amd-iommu.h
 
+AMD ISP4 DRIVER
+M:	Bin Du <[email protected]>
+M:	Nirujogi Pratap <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media.git
+F:	drivers/media/platform/amd/Kconfig
+F:	drivers/media/platform/amd/Makefile
+F:	drivers/media/platform/amd/isp4/Kconfig
+F:	drivers/media/platform/amd/isp4/Makefile
+F:	drivers/media/platform/amd/isp4/isp4.c
+F:	drivers/media/platform/amd/isp4/isp4.h
+
  AMD KFD
  M:	Felix Kuehling <[email protected]>
  L:	[email protected]
drivers/media/platform/Kconfig +1 -0
index 9287faafdce5..772c70665510 100644
@@ -63,6 +63,7 @@ config VIDEO_MUX
 
  # Platform drivers - Please keep it alphabetically sorted
  source "drivers/media/platform/allegro-dvt/Kconfig"
+source "drivers/media/platform/amd/Kconfig"
  source "drivers/media/platform/amlogic/Kconfig"
  source "drivers/media/platform/amphion/Kconfig"
  source "drivers/media/platform/aspeed/Kconfig"
drivers/media/platform/Makefile +1 -0
index 6fd7db0541c7..b207bd8d8022 100644
@@ -6,6 +6,7 @@
  # Place here, alphabetically sorted by directory
  # (e. g. LC_ALL=C sort Makefile)
  obj-y += allegro-dvt/
+obj-y += amd/
  obj-y += amlogic/
  obj-y += amphion/
  obj-y += aspeed/
drivers/media/platform/amd/Kconfig new file +3 -0
new file mode 100644
index 000000000000..25af49f246b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
new file mode 100644
index 000000000000..8bfc1955f22e
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += isp4/
drivers/media/platform/amd/isp4/Kconfig new file +0 -0
new file mode 100644
index 000000000000..0268060c2dae

drivers/media/platform/amd/isp4/Kconfig line 5

Quoted 5 lines
drivers/media/platform/amd/isp4/Kconfig new file +5 -0
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+config AMD_ISP4
+	tristate "AMD ISP4 and camera driver"
+	depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API

depends on DRM_AMD_ISP> + select VIDEOBUF2_CORE

Quoted 176 lines
drivers/media/platform/amd/isp4/Kconfig new file +7 -0
+	select VIDEOBUF2_V4L2
+	select VIDEOBUF2_MEMOPS
+	help
+	  This is support for AMD ISP4 and camera subsystem driver.
+	  Say Y here to enable the ISP4 and camera device for video capture.
+	  To compile this driver as a module, choose M here. The module will
+	  be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
new file mode 100644
index 000000000000..de0092dad26f
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025 Advanced Micro Devices, Inc.
+
+obj-$(CONFIG_AMD_ISP4) += amd_capture.o
+amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +121 -0
new file mode 100644
index 000000000000..6ff3ded4310a
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/pm_runtime.h>
+#include <linux/vmalloc.h>
+#include <media/v4l2-ioctl.h>
+
+#include "isp4.h"
+
+#define VIDEO_BUF_NUM 5
+
+#define ISP4_DRV_NAME "amd_isp_capture"
+
+/* interrupt num */
+static const u32 isp4_ringbuf_interrupt_num[] = {
+	0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */
+	1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */
+	3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */
+	4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */
+};
+
+#define to_isp4_device(dev) \
+	((struct isp4_device *)container_of(dev, struct isp4_device, v4l2_dev))
+
+static irqreturn_t isp4_irq_handler(int irq, void *arg)
+{
+	return IRQ_HANDLED;
+}
+
+static int isp4_capture_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct isp4_device *isp_dev;
+	int i, irq, ret;
+
+	isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL);
+	if (!isp_dev)
+		return -ENOMEM;
+
+	isp_dev->pdev = pdev;
+	dev->init_name = ISP4_DRV_NAME;
+
+	for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) {
+		irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]);
+		if (irq < 0)
+			return dev_err_probe(dev, -ENODEV,
+					     "fail to get irq %d\n",
+					     isp4_ringbuf_interrupt_num[i]);
+		ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0,
+				       "ISP_IRQ", &pdev->dev);
+		if (ret)
+			return dev_err_probe(dev, ret, "fail to req irq %d\n",
+					     irq);
+	}
+
+	/* Link the media device within the v4l2_device */
+	isp_dev->v4l2_dev.mdev = &isp_dev->mdev;
+
+	/* Initialize media device */
+	strscpy(isp_dev->mdev.model, "amd_isp41_mdev",
+		sizeof(isp_dev->mdev.model));
+	snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info),
+		 "platform:%s", ISP4_DRV_NAME);
+	isp_dev->mdev.dev = &pdev->dev;
+	media_device_init(&isp_dev->mdev);
+
+	/* register v4l2 device */
+	snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name),
+		 "AMD-V4L2-ROOT");
+	ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "fail register v4l2 device\n");
+
+	ret = media_device_register(&isp_dev->mdev);
+	if (ret) {
+		dev_err(dev, "fail to register media device %d\n", ret);
+		goto err_unreg_v4l2;
+	}
+
+	platform_set_drvdata(pdev, isp_dev);
+
+	pm_runtime_set_suspended(dev);
+	pm_runtime_enable(dev);
+
+	return 0;
+
+err_unreg_v4l2:
+	v4l2_device_unregister(&isp_dev->v4l2_dev);
+
+	return dev_err_probe(dev, ret, "isp probe fail\n");
+}
+
+static void isp4_capture_remove(struct platform_device *pdev)
+{
+	struct isp4_device *isp_dev = platform_get_drvdata(pdev);
+
+	media_device_unregister(&isp_dev->mdev);
+	v4l2_device_unregister(&isp_dev->v4l2_dev);
+}
+
+static struct platform_driver isp4_capture_drv = {
+	.probe = isp4_capture_probe,
+	.remove = isp4_capture_remove,
+	.driver = {
+		.name = ISP4_DRV_NAME,
+		.owner = THIS_MODULE,
+	}
+};
+
+module_platform_driver(isp4_capture_drv);
+
+MODULE_ALIAS("platform:" ISP4_DRV_NAME);
+MODULE_IMPORT_NS("DMA_BUF");
+
+MODULE_DESCRIPTION("AMD ISP4 Driver");
+MODULE_AUTHOR("Bin Du <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/media/platform/amd/isp4/isp4.h new file +24 -0
new file mode 100644
index 000000000000..8535f662ab49
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _ISP4_H_
+#define _ISP4_H_
+
+#include <linux/mutex.h>
+#include <media/v4l2-device.h>
+#include <media/videobuf2-memops.h>
+#include <media/videobuf2-vmalloc.h>
+
+#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
+
+struct isp4_device {
+	struct v4l2_device v4l2_dev;
+	struct media_device mdev;
+
+	struct platform_device *pdev;
+	struct notifier_block i2c_nb;
+};
+
+#endif /* _ISP4_H_ */
author maintainer
#30 lore raw

Thanks Mario

Quoted 97 lines · Mario Limonciello
Quoted 96 lines · Bin Du

AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file

---
  MAINTAINERS                              |  13 +++ drivers/media/platform/Kconfig           |   1 + drivers/media/platform/Makefile          |   1 + drivers/media/platform/amd/Kconfig       |   3 + drivers/media/platform/amd/Makefile      |   3 + drivers/media/platform/amd/isp4/Kconfig  |  13 +++ drivers/media/platform/amd/isp4/Makefile |   6 ++ drivers/media/platform/amd/isp4/isp4.c   | 121 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h   |  24 +++++

  9 files changed, 185 insertions(+)

  create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h

MAINTAINERS +0 -0
index fe168477caa4..3ad845f1511b 100644
@@ -1133,6 +1133,19 @@ T:    git git://git.kernel.org/pub/scm/linux/ 

kernel/git/iommu/linux.git
  F:    drivers/iommu/amd/
  F:    include/linux/amd-iommu.h

MAINTAINERS +13 -0
+AMD ISP4 DRIVER
+M:    Bin Du <[email protected]>
+M:    Nirujogi Pratap <[email protected]>
+L:    [email protected]
+S:    Maintained
+T:    git git://linuxtv.org/media.git
+F:    drivers/media/platform/amd/Kconfig
+F:    drivers/media/platform/amd/Makefile
+F:    drivers/media/platform/amd/isp4/Kconfig
+F:    drivers/media/platform/amd/isp4/Makefile
+F:    drivers/media/platform/amd/isp4/isp4.c
+F:    drivers/media/platform/amd/isp4/isp4.h
+

  AMD KFD
  M:    Felix Kuehling <[email protected]>
  L:    [email protected]

drivers/media/platform/Kconfig +0 -0
index 9287faafdce5..772c70665510 100644
@@ -63,6 +63,7 @@ config VIDEO_MUX
   # Platform drivers - Please keep it alphabetically sorted

  source "drivers/media/platform/allegro-dvt/Kconfig" +source "drivers/media/platform/amd/Kconfig" source "drivers/media/platform/amlogic/Kconfig" source "drivers/media/platform/amphion/Kconfig" source "drivers/media/platform/aspeed/Kconfig"

drivers/media/platform/Makefile +0 -0
index 6fd7db0541c7..b207bd8d8022 100644
@@ -6,6 +6,7 @@
   # Place here, alphabetically sorted by directory
   # (e. g. LC_ALL=C sort Makefile)

  obj-y += allegro-dvt/
+obj-y += amd/
  obj-y += amlogic/
  obj-y += amphion/
  obj-y += aspeed/

drivers/media/platform/amd/Kconfig new file +3 -0
new file mode 100644
index 000000000000..25af49f246b2
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
new file mode 100644
index 000000000000..8bfc1955f22e
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += isp4/
drivers/media/ platform/amd/isp4/Kconfig new file +0 -1
new file mode 100644
index 000000000000..0268060c2dae
--- /dev/null
Quoted 8 lines

drivers/media/ platform/amd/isp4/Kconfig line 5

Quoted 7 lines

+++ b/drivers/media/platform/amd/isp4/Kconfig

drivers/media/ platform/amd/isp4/Kconfig new file +5 -0
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+config AMD_ISP4
+    tristate "AMD ISP4 and camera driver"
+    depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API

depends on DRM_AMD_ISP

Thanks, will add in the next version

Quoted 178 lines
Quoted 177 lines
drivers/media/ platform/amd/isp4/Kconfig new file +7 -0
+    select VIDEOBUF2_CORE>> +    select VIDEOBUF2_V4L2
+    select VIDEOBUF2_MEMOPS
+    help
+      This is support for AMD ISP4 and camera subsystem driver.
+      Say Y here to enable the ISP4 and camera device for video capture.
+      To compile this driver as a module, choose M here. The module will
+      be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
new file mode 100644
index 000000000000..de0092dad26f
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2025 Advanced Micro Devices, Inc.
+
+obj-$(CONFIG_AMD_ISP4) += amd_capture.o
+amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +25 -0
new file mode 100644
index 000000000000..6ff3ded4310a
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/pm_runtime.h>
+#include <linux/vmalloc.h>
+#include <media/v4l2-ioctl.h>
+
+#include "isp4.h"
+
+#define VIDEO_BUF_NUM 5
+
+#define ISP4_DRV_NAME "amd_isp_capture"
+
+/* interrupt num */
+static const u32 isp4_ringbuf_interrupt_num[] = {
+    0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */
+    1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */
+    3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */
+    4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */
+};
+
+#define to_isp4_device(dev) \
+    ((struct isp4_device *)container_of(dev, struct isp4_device, 

v4l2_dev))

drivers/media/platform/amd/isp4/isp4.c new file +96 -0
+
+static irqreturn_t isp4_irq_handler(int irq, void *arg)
+{
+    return IRQ_HANDLED;
+}
+
+static int isp4_capture_probe(struct platform_device *pdev)
+{
+    struct device *dev = &pdev->dev;
+    struct isp4_device *isp_dev;
+    int i, irq, ret;
+
+    isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL);
+    if (!isp_dev)
+        return -ENOMEM;
+
+    isp_dev->pdev = pdev;
+    dev->init_name = ISP4_DRV_NAME;
+
+    for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) {
+        irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]);
+        if (irq < 0)
+            return dev_err_probe(dev, -ENODEV,
+                         "fail to get irq %d\n",
+                         isp4_ringbuf_interrupt_num[i]);
+        ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0,
+                       "ISP_IRQ", &pdev->dev);
+        if (ret)
+            return dev_err_probe(dev, ret, "fail to req irq %d\n",
+                         irq);
+    }
+
+    /* Link the media device within the v4l2_device */
+    isp_dev->v4l2_dev.mdev = &isp_dev->mdev;
+
+    /* Initialize media device */
+    strscpy(isp_dev->mdev.model, "amd_isp41_mdev",
+        sizeof(isp_dev->mdev.model));
+    snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info),
+         "platform:%s", ISP4_DRV_NAME);
+    isp_dev->mdev.dev = &pdev->dev;
+    media_device_init(&isp_dev->mdev);
+
+    /* register v4l2 device */
+    snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name),
+         "AMD-V4L2-ROOT");
+    ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev);
+    if (ret)
+        return dev_err_probe(dev, ret,
+                     "fail register v4l2 device\n");
+
+    ret = media_device_register(&isp_dev->mdev);
+    if (ret) {
+        dev_err(dev, "fail to register media device %d\n", ret);
+        goto err_unreg_v4l2;
+    }
+
+    platform_set_drvdata(pdev, isp_dev);
+
+    pm_runtime_set_suspended(dev);
+    pm_runtime_enable(dev);
+
+    return 0;
+
+err_unreg_v4l2:
+    v4l2_device_unregister(&isp_dev->v4l2_dev);
+
+    return dev_err_probe(dev, ret, "isp probe fail\n");
+}
+
+static void isp4_capture_remove(struct platform_device *pdev)
+{
+    struct isp4_device *isp_dev = platform_get_drvdata(pdev);
+
+    media_device_unregister(&isp_dev->mdev);
+    v4l2_device_unregister(&isp_dev->v4l2_dev);
+}
+
+static struct platform_driver isp4_capture_drv = {
+    .probe = isp4_capture_probe,
+    .remove = isp4_capture_remove,
+    .driver = {
+        .name = ISP4_DRV_NAME,
+        .owner = THIS_MODULE,
+    }
+};
+
+module_platform_driver(isp4_capture_drv);
+
+MODULE_ALIAS("platform:" ISP4_DRV_NAME);
+MODULE_IMPORT_NS("DMA_BUF");
+
+MODULE_DESCRIPTION("AMD ISP4 Driver");
+MODULE_AUTHOR("Bin Du <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/media/platform/amd/isp4/isp4.h new file +24 -0
new file mode 100644
index 000000000000..8535f662ab49
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#ifndef _ISP4_H_
+#define _ISP4_H_
+
+#include <linux/mutex.h>
+#include <media/v4l2-device.h>
+#include <media/videobuf2-memops.h>
+#include <media/videobuf2-vmalloc.h>
+
+#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio)
+
+struct isp4_device {
+    struct v4l2_device v4l2_dev;
+    struct media_device mdev;
+
+    struct platform_device *pdev;
+    struct notifier_block i2c_nb;
+};
+
+#endif /* _ISP4_H_ */
Signature · 2 lines
Regards,
Bin