Skip to content

Commit cd4871d

Browse files
Bin Du1Naim
authored andcommitted
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 Co-developed-by: Sultan Alsawaf <sultan@kerneltoast.com> Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com> Co-developed-by: Svetoslav Stoilov <Svetoslav.Stoilov@amd.com> Signed-off-by: Svetoslav Stoilov <Svetoslav.Stoilov@amd.com> Signed-off-by: Bin Du <Bin.Du@amd.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Reviewed-by: Sultan Alsawaf <sultan@kerneltoast.com> Tested-by: Alexey Zagorodnikov <xglooom@gmail.com> Tested-by: Kate Hsuan <hpa@redhat.com>
1 parent 6de23f8 commit cd4871d

9 files changed

Lines changed: 186 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,19 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git
11621162
F: drivers/iommu/amd/
11631163
F: include/linux/amd-iommu.h
11641164

1165+
AMD ISP4 DRIVER
1166+
M: Bin Du <bin.du@amd.com>
1167+
M: Nirujogi Pratap <pratap.nirujogi@amd.com>
1168+
L: linux-media@vger.kernel.org
1169+
S: Maintained
1170+
T: git git://linuxtv.org/media.git
1171+
F: drivers/media/platform/amd/Kconfig
1172+
F: drivers/media/platform/amd/Makefile
1173+
F: drivers/media/platform/amd/isp4/Kconfig
1174+
F: drivers/media/platform/amd/isp4/Makefile
1175+
F: drivers/media/platform/amd/isp4/isp4.c
1176+
F: drivers/media/platform/amd/isp4/isp4.h
1177+
11651178
AMD KFD
11661179
M: Felix Kuehling <Felix.Kuehling@amd.com>
11671180
L: amd-gfx@lists.freedesktop.org

drivers/media/platform/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ config VIDEO_MUX
6363

6464
# Platform drivers - Please keep it alphabetically sorted
6565
source "drivers/media/platform/allegro-dvt/Kconfig"
66+
source "drivers/media/platform/amd/Kconfig"
6667
source "drivers/media/platform/amlogic/Kconfig"
6768
source "drivers/media/platform/amphion/Kconfig"
6869
source "drivers/media/platform/arm/Kconfig"

drivers/media/platform/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Place here, alphabetically sorted by directory
77
# (e. g. LC_ALL=C sort Makefile)
88
obj-y += allegro-dvt/
9+
obj-y += amd/
910
obj-y += amlogic/
1011
obj-y += amphion/
1112
obj-y += arm/

drivers/media/platform/amd/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0+
2+
3+
source "drivers/media/platform/amd/isp4/Kconfig"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0+
2+
3+
obj-y += isp4/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-License-Identifier: GPL-2.0+
2+
3+
config VIDEO_AMD_ISP4_CAPTURE
4+
tristate "AMD ISP4 and camera driver"
5+
depends on DRM_AMD_ISP && VIDEO_DEV && HAS_DMA
6+
select VIDEOBUF2_CORE
7+
select VIDEOBUF2_MEMOPS
8+
select VIDEOBUF2_V4L2
9+
select VIDEOBUF2_VMALLOC
10+
select VIDEO_V4L2_SUBDEV_API
11+
help
12+
This is support for AMD ISP4 and camera subsystem driver.
13+
Say Y here to enable the ISP4 and camera device for video capture.
14+
To compile this driver as a module, choose M here. The module will
15+
be called amd_isp4_capture.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: GPL-2.0+
2+
#
3+
# Copyright (C) 2025 Advanced Micro Devices, Inc.
4+
5+
obj-$(CONFIG_VIDEO_AMD_ISP4_CAPTURE) += amd_isp4_capture.o
6+
amd_isp4_capture-objs := isp4.o
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* Copyright (C) 2025 Advanced Micro Devices, Inc.
4+
*/
5+
6+
#include <linux/pm_runtime.h>
7+
#include <linux/vmalloc.h>
8+
#include <media/v4l2-ioctl.h>
9+
10+
#include "isp4.h"
11+
12+
#define ISP4_DRV_NAME "amd_isp_capture"
13+
14+
static const struct {
15+
const char *name;
16+
u32 status_mask;
17+
u32 en_mask;
18+
u32 ack_mask;
19+
u32 rb_int_num;
20+
} isp4_irq[] = {
21+
/* The IRQ order is aligned with the isp4_subdev.fw_resp_thread order */
22+
{
23+
.name = "isp_irq_global",
24+
.rb_int_num = 4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */
25+
},
26+
{
27+
.name = "isp_irq_stream1",
28+
.rb_int_num = 0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */
29+
},
30+
};
31+
32+
static irqreturn_t isp4_irq_handler(int irq, void *arg)
33+
{
34+
return IRQ_HANDLED;
35+
}
36+
37+
static int isp4_capture_probe(struct platform_device *pdev)
38+
{
39+
struct device *dev = &pdev->dev;
40+
int irq[ARRAY_SIZE(isp4_irq)];
41+
struct isp4_device *isp_dev;
42+
int ret;
43+
44+
isp_dev = devm_kzalloc(dev, sizeof(*isp_dev), GFP_KERNEL);
45+
if (!isp_dev)
46+
return -ENOMEM;
47+
48+
dev->init_name = ISP4_DRV_NAME;
49+
50+
for (size_t i = 0; i < ARRAY_SIZE(isp4_irq); i++) {
51+
irq[i] = platform_get_irq(pdev, isp4_irq[i].rb_int_num);
52+
if (irq[i] < 0)
53+
return dev_err_probe(dev, irq[i],
54+
"fail to get irq %d\n",
55+
isp4_irq[i].rb_int_num);
56+
57+
ret = devm_request_irq(dev, irq[i], isp4_irq_handler,
58+
IRQF_NO_AUTOEN, isp4_irq[i].name, dev);
59+
if (ret)
60+
return dev_err_probe(dev, ret, "fail to req irq %d\n",
61+
irq[i]);
62+
}
63+
64+
isp_dev->v4l2_dev.mdev = &isp_dev->mdev;
65+
66+
strscpy(isp_dev->mdev.model, "amd_isp41_mdev",
67+
sizeof(isp_dev->mdev.model));
68+
isp_dev->mdev.dev = dev;
69+
media_device_init(&isp_dev->mdev);
70+
71+
snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name),
72+
"AMD-V4L2-ROOT");
73+
ret = v4l2_device_register(dev, &isp_dev->v4l2_dev);
74+
if (ret) {
75+
dev_err_probe(dev, ret, "fail register v4l2 device\n");
76+
goto err_clean_media;
77+
}
78+
79+
pm_runtime_set_suspended(dev);
80+
pm_runtime_enable(dev);
81+
ret = media_device_register(&isp_dev->mdev);
82+
if (ret) {
83+
dev_err_probe(dev, ret, "fail to register media device\n");
84+
goto err_isp4_deinit;
85+
}
86+
87+
platform_set_drvdata(pdev, isp_dev);
88+
89+
return 0;
90+
91+
err_isp4_deinit:
92+
pm_runtime_disable(dev);
93+
v4l2_device_unregister(&isp_dev->v4l2_dev);
94+
err_clean_media:
95+
media_device_cleanup(&isp_dev->mdev);
96+
97+
return ret;
98+
}
99+
100+
static void isp4_capture_remove(struct platform_device *pdev)
101+
{
102+
struct isp4_device *isp_dev = platform_get_drvdata(pdev);
103+
struct device *dev = &pdev->dev;
104+
105+
media_device_unregister(&isp_dev->mdev);
106+
pm_runtime_disable(dev);
107+
v4l2_device_unregister(&isp_dev->v4l2_dev);
108+
media_device_cleanup(&isp_dev->mdev);
109+
}
110+
111+
static struct platform_driver isp4_capture_drv = {
112+
.probe = isp4_capture_probe,
113+
.remove = isp4_capture_remove,
114+
.driver = {
115+
.name = ISP4_DRV_NAME,
116+
}
117+
};
118+
119+
module_platform_driver(isp4_capture_drv);
120+
121+
MODULE_ALIAS("platform:" ISP4_DRV_NAME);
122+
MODULE_IMPORT_NS("DMA_BUF");
123+
124+
MODULE_DESCRIPTION("AMD ISP4 Driver");
125+
MODULE_AUTHOR("Bin Du <bin.du@amd.com>");
126+
MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
127+
MODULE_LICENSE("GPL");
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
/*
3+
* Copyright (C) 2025 Advanced Micro Devices, Inc.
4+
*/
5+
6+
#ifndef _ISP4_H_
7+
#define _ISP4_H_
8+
9+
#include <media/v4l2-device.h>
10+
#include <media/videobuf2-memops.h>
11+
12+
struct isp4_device {
13+
struct v4l2_device v4l2_dev;
14+
struct media_device mdev;
15+
};
16+
17+
#endif /* _ISP4_H_ */

0 commit comments

Comments
 (0)