Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Documentation/ABI/testing/sysfs-driver-apple-isp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
What: /sys/bus/platform/drivers/apple-isp/<dev>/sensor
Date: November 2026
Contact: Artyom Astafurov <artyom.astafurov@gmail.com>
Description:
Read-only identifier of the detected built-in camera sensor
module (for example "imx958-uw" or "imx558"), also reachable at
/sys/class/video4linux/videoX/device/sensor. On hardware with
deferred camera startup, reading this attribute before the
first stream detects the camera fails with -ENODATA.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,7 @@ B: https://github.com/AsahiLinux/linux/issues
C: irc://irc.oftc.net/asahi-dev
T: git https://github.com/AsahiLinux/linux.git
F: Documentation/ABI/testing/sysfs-driver-apple-dart
F: Documentation/ABI/testing/sysfs-driver-apple-isp
F: Documentation/ABI/testing/sysfs-driver-apple-pmp-dram
F: Documentation/devicetree/bindings/arm/apple.yaml
F: Documentation/devicetree/bindings/arm/apple/*
Expand Down
14 changes: 9 additions & 5 deletions arch/arm64/boot/dts/apple/t6041.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,14 @@
};

/*
* The ISP DART's address filter, from the J616c ADT's dart-isp0
* The ISP DART's address filter, from the full-die J616c ADT's dart-isp0
* dapf-instance-0 (its sixth reg window), in the ADT's order: the
* firmware's PMGR, PMP and DSID windows, with one window for each of the
* six AMCCs. The filter goes off with the ISP system domain and is written
* back when the DART powers up again, so the ISP firmware can start again
* after the ISP has been powered down between streams, as on T6040.
* eight AMCCs (aura syncs apple,dapf-ranges from this boot's ADT so six-AMCC
* parts get their six windows). The filter goes off with the ISP system
* domain and is written back when the DART powers up again, so the ISP
* firmware can start again after the ISP has been powered down between
* streams, as on T6040.
*/
&isp_dart0 {
reg = <0x5 0x828c0000 0x0 0xc000>,
Expand All @@ -483,5 +485,7 @@
0x224004000 0x2241d62fc
0x226004000 0x2261d62fc
0x228004000 0x2281d62fc
0x22a004000 0x22a1d62fc>;
0x22a004000 0x22a1d62fc
0x22c004000 0x22c1d62fc
0x22e004000 0x22e1d62fc>;
};
28 changes: 28 additions & 0 deletions drivers/media/platform/apple/isp/isp-cam-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,33 @@ static void isp_test_call_size_capabilities(struct kunit *test)
KUNIT_EXPECT_EQ(test, isp->presets[8].output_dim.y, 1536);
}

static void isp_test_sensor_names(struct kunit *test)
{
struct apple_isp *isp = isp_test_capture_alloc(test);
struct isp_format *fmt = isp_get_current_format(isp);

mutex_init(&isp->video_lock);
for (unsigned int i = 0; i < ARRAY_SIZE(isp_setfiles); i++) {
KUNIT_ASSERT_NOT_NULL_MSG(test, isp_setfiles[i].sensor,
"setfile %u", i);
KUNIT_EXPECT_NE_MSG(test, isp_setfiles[i].sensor[0], '\0',
"setfile %u", i);
}
KUNIT_EXPECT_STREQ(test, isp_setfiles[ISP_IMX248_1820_01].sensor,
"imx248");
KUNIT_EXPECT_STREQ(test, isp_setfiles[ISP_IMX558_1925_03].sensor,
"imx558");
KUNIT_EXPECT_STREQ(test, isp_setfiles[ISP_IMX958_2224_01].sensor,
"imx958-uw");
KUNIT_EXPECT_STREQ(test, isp_setfiles[ISP_VD56G0_6221_01].sensor,
"vd56g0");

KUNIT_EXPECT_NULL(test, apple_isp_sensor_name(isp));
fmt->id = ISP_IMX958_2224_01;
isp->camera_detected = true;
KUNIT_EXPECT_STREQ(test, apple_isp_sensor_name(isp), "imx958-uw");
}

static struct kunit_case isp_cam_test_cases[] = {
KUNIT_CASE(isp_test_call_crop),
KUNIT_CASE(isp_test_call_crop_bounds),
Expand All @@ -715,6 +742,7 @@ static struct kunit_case isp_cam_test_cases[] = {
KUNIT_CASE(isp_test_command_ack_failures),
KUNIT_CASE(isp_test_stop_key_on_debug),
KUNIT_CASE(isp_test_sensor_geometry),
KUNIT_CASE(isp_test_sensor_names),
KUNIT_CASE(isp_test_sensor_config_list),
KUNIT_CASE(isp_test_sensor_config_failure),
KUNIT_CASE(isp_test_preview_stream),
Expand Down
121 changes: 69 additions & 52 deletions drivers/media/platform/apple/isp/isp-cam.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum isp_temporal_filter {

struct isp_setfile {
u32 version;
const char *sensor;
u32 magic;
const char *path;
size_t size;
Expand All @@ -37,58 +38,58 @@ struct isp_setfile {

// clang-format off
static const struct isp_setfile isp_setfiles[] = {
[ISP_IMX248_1820_01] = {0x248, 0x18200103, "apple/isp_1820_01XX.dat", 0x442c},
[ISP_IMX248_1822_02] = {0x248, 0x18220201, "apple/isp_1822_02XX.dat", 0x442c},
[ISP_IMX343_5221_02] = {0x343, 0x52210211, "apple/isp_5221_02XX.dat", 0x4870},
[ISP_IMX354_9251_02] = {0x354, 0x92510208, "apple/isp_9251_02XX.dat", 0xa5ec},
[ISP_IMX356_4820_01] = {0x356, 0x48200107, "apple/isp_4820_01XX.dat", 0x9324},
[ISP_IMX356_4820_02] = {0x356, 0x48200206, "apple/isp_4820_02XX.dat", 0x9324},
[ISP_IMX364_8720_01] = {0x364, 0x87200103, "apple/isp_8720_01XX.dat", 0x36ac},
[ISP_IMX364_8723_01] = {0x364, 0x87230101, "apple/isp_8723_01XX.dat", 0x361c},
[ISP_IMX372_3820_01] = {0x372, 0x38200108, "apple/isp_3820_01XX.dat", 0xfdb0},
[ISP_IMX372_3820_02] = {0x372, 0x38200205, "apple/isp_3820_02XX.dat", 0xfdb0},
[ISP_IMX372_3820_11] = {0x372, 0x38201104, "apple/isp_3820_11XX.dat", 0xfdb0},
[ISP_IMX372_3820_12] = {0x372, 0x38201204, "apple/isp_3820_12XX.dat", 0xfdb0},
[ISP_IMX405_9720_01] = {0x405, 0x97200102, "apple/isp_9720_01XX.dat", 0x92c8},
[ISP_IMX405_9721_01] = {0x405, 0x97210102, "apple/isp_9721_01XX.dat", 0x9818},
[ISP_IMX405_9723_01] = {0x405, 0x97230101, "apple/isp_9723_01XX.dat", 0x92c8},
[ISP_IMX414_2520_01] = {0x414, 0x25200102, "apple/isp_2520_01XX.dat", 0xa444},
[ISP_IMX503_7820_01] = {0x503, 0x78200109, "apple/isp_7820_01XX.dat", 0xb268},
[ISP_IMX503_7820_02] = {0x503, 0x78200206, "apple/isp_7820_02XX.dat", 0xb268},
[ISP_IMX505_3921_01] = {0x505, 0x39210102, "apple/isp_3921_01XX.dat", 0x89b0},
[ISP_IMX514_2820_01] = {0x514, 0x28200108, "apple/isp_2820_01XX.dat", 0xa198},
[ISP_IMX514_2820_02] = {0x514, 0x28200205, "apple/isp_2820_02XX.dat", 0xa198},
[ISP_IMX514_2820_03] = {0x514, 0x28200305, "apple/isp_2820_03XX.dat", 0xa198},
[ISP_IMX514_2820_04] = {0x514, 0x28200405, "apple/isp_2820_04XX.dat", 0xa198},
[ISP_IMX558_1921_01] = {0x558, 0x19210106, "apple/isp_1921_01XX.dat", 0xad40},
[ISP_IMX558_1922_02] = {0x558, 0x19220201, "apple/isp_1922_02XX.dat", 0xad40},
[ISP_IMX558_1925_03] = {0x558, 0x19250306, "apple/isp_1925_03XX.dat", 0xcbc0, 0xcba6,
ISP_TEMPORAL_FILTER_OFF},
[ISP_IMX603_7920_01] = {0x603, 0x79200109, "apple/isp_7920_01XX.dat", 0xad2c},
[ISP_IMX603_7920_02] = {0x603, 0x79200205, "apple/isp_7920_02XX.dat", 0xad2c},
[ISP_IMX603_7921_01] = {0x603, 0x79210104, "apple/isp_7921_01XX.dat", 0xad90},
[ISP_IMX613_4920_01] = {0x613, 0x49200108, "apple/isp_4920_01XX.dat", 0x9324},
[ISP_IMX613_4920_02] = {0x613, 0x49200204, "apple/isp_4920_02XX.dat", 0x9324},
[ISP_IMX614_2921_01] = {0x614, 0x29210107, "apple/isp_2921_01XX.dat", 0xed6c},
[ISP_IMX614_2921_02] = {0x614, 0x29210202, "apple/isp_2921_02XX.dat", 0xed6c},
[ISP_IMX614_2922_02] = {0x614, 0x29220201, "apple/isp_2922_02XX.dat", 0xed6c},
[ISP_IMX633_3622_01] = {0x633, 0x36220111, "apple/isp_3622_01XX.dat", 0x100d4},
[ISP_IMX703_7721_01] = {0x703, 0x77210106, "apple/isp_7721_01XX.dat", 0x936c},
[ISP_IMX703_7722_01] = {0x703, 0x77220106, "apple/isp_7722_01XX.dat", 0xac20},
[ISP_IMX713_4721_01] = {0x713, 0x47210107, "apple/isp_4721_01XX.dat", 0x936c},
[ISP_IMX713_4722_01] = {0x713, 0x47220109, "apple/isp_4722_01XX.dat", 0x9218},
[ISP_IMX714_2022_01] = {0x714, 0x20220107, "apple/isp_2022_01XX.dat", 0xa198},
[ISP_IMX772_3721_01] = {0x772, 0x37210106, "apple/isp_3721_01XX.dat", 0xfdf8},
[ISP_IMX772_3721_11] = {0x772, 0x37211106, "apple/isp_3721_11XX.dat", 0xfe14},
[ISP_IMX772_3722_01] = {0x772, 0x37220104, "apple/isp_3722_01XX.dat", 0xfca4},
[ISP_IMX772_3723_01] = {0x772, 0x37230106, "apple/isp_3723_01XX.dat", 0xfca4},
[ISP_IMX814_2123_01] = {0x814, 0x21230101, "apple/isp_2123_01XX.dat", 0xed54},
[ISP_IMX853_7622_01] = {0x853, 0x76220112, "apple/isp_7622_01XX.dat", 0x247f8},
[ISP_IMX913_7523_01] = {0x913, 0x75230107, "apple/isp_7523_01XX.dat", 0x247f8},
[ISP_IMX958_2224_01] = {0x958, 0x22240106, "apple/isp_2224_01XX.dat", 0x6ff4, 0,
ISP_TEMPORAL_FILTER_BAND0},
[ISP_VD56G0_6221_01] = {0xd56, 0x62210102, "apple/isp_6221_01XX.dat", 0x1b80},
[ISP_VD56G0_6222_01] = {0xd56, 0x62220102, "apple/isp_6222_01XX.dat", 0x1b80},
[ISP_IMX248_1820_01] = {0x248, "imx248", 0x18200103, "apple/isp_1820_01XX.dat", 0x442c},
[ISP_IMX248_1822_02] = {0x248, "imx248", 0x18220201, "apple/isp_1822_02XX.dat", 0x442c},
[ISP_IMX343_5221_02] = {0x343, "imx343", 0x52210211, "apple/isp_5221_02XX.dat", 0x4870},
[ISP_IMX354_9251_02] = {0x354, "imx354", 0x92510208, "apple/isp_9251_02XX.dat", 0xa5ec},
[ISP_IMX356_4820_01] = {0x356, "imx356", 0x48200107, "apple/isp_4820_01XX.dat", 0x9324},
[ISP_IMX356_4820_02] = {0x356, "imx356", 0x48200206, "apple/isp_4820_02XX.dat", 0x9324},
[ISP_IMX364_8720_01] = {0x364, "imx364", 0x87200103, "apple/isp_8720_01XX.dat", 0x36ac},
[ISP_IMX364_8723_01] = {0x364, "imx364", 0x87230101, "apple/isp_8723_01XX.dat", 0x361c},
[ISP_IMX372_3820_01] = {0x372, "imx372", 0x38200108, "apple/isp_3820_01XX.dat", 0xfdb0},
[ISP_IMX372_3820_02] = {0x372, "imx372", 0x38200205, "apple/isp_3820_02XX.dat", 0xfdb0},
[ISP_IMX372_3820_11] = {0x372, "imx372", 0x38201104, "apple/isp_3820_11XX.dat", 0xfdb0},
[ISP_IMX372_3820_12] = {0x372, "imx372", 0x38201204, "apple/isp_3820_12XX.dat", 0xfdb0},
[ISP_IMX405_9720_01] = {0x405, "imx405", 0x97200102, "apple/isp_9720_01XX.dat", 0x92c8},
[ISP_IMX405_9721_01] = {0x405, "imx405", 0x97210102, "apple/isp_9721_01XX.dat", 0x9818},
[ISP_IMX405_9723_01] = {0x405, "imx405", 0x97230101, "apple/isp_9723_01XX.dat", 0x92c8},
[ISP_IMX414_2520_01] = {0x414, "imx414", 0x25200102, "apple/isp_2520_01XX.dat", 0xa444},
[ISP_IMX503_7820_01] = {0x503, "imx503", 0x78200109, "apple/isp_7820_01XX.dat", 0xb268},
[ISP_IMX503_7820_02] = {0x503, "imx503", 0x78200206, "apple/isp_7820_02XX.dat", 0xb268},
[ISP_IMX505_3921_01] = {0x505, "imx505", 0x39210102, "apple/isp_3921_01XX.dat", 0x89b0},
[ISP_IMX514_2820_01] = {0x514, "imx514", 0x28200108, "apple/isp_2820_01XX.dat", 0xa198},
[ISP_IMX514_2820_02] = {0x514, "imx514", 0x28200205, "apple/isp_2820_02XX.dat", 0xa198},
[ISP_IMX514_2820_03] = {0x514, "imx514", 0x28200305, "apple/isp_2820_03XX.dat", 0xa198},
[ISP_IMX514_2820_04] = {0x514, "imx514", 0x28200405, "apple/isp_2820_04XX.dat", 0xa198},
[ISP_IMX558_1921_01] = {0x558, "imx558", 0x19210106, "apple/isp_1921_01XX.dat", 0xad40},
[ISP_IMX558_1922_02] = {0x558, "imx558", 0x19220201, "apple/isp_1922_02XX.dat", 0xad40},
[ISP_IMX558_1925_03] = {0x558, "imx558", 0x19250306, "apple/isp_1925_03XX.dat", 0xcbc0,
0xcba6, ISP_TEMPORAL_FILTER_OFF},
[ISP_IMX603_7920_01] = {0x603, "imx603", 0x79200109, "apple/isp_7920_01XX.dat", 0xad2c},
[ISP_IMX603_7920_02] = {0x603, "imx603", 0x79200205, "apple/isp_7920_02XX.dat", 0xad2c},
[ISP_IMX603_7921_01] = {0x603, "imx603", 0x79210104, "apple/isp_7921_01XX.dat", 0xad90},
[ISP_IMX613_4920_01] = {0x613, "imx613", 0x49200108, "apple/isp_4920_01XX.dat", 0x9324},
[ISP_IMX613_4920_02] = {0x613, "imx613", 0x49200204, "apple/isp_4920_02XX.dat", 0x9324},
[ISP_IMX614_2921_01] = {0x614, "imx614", 0x29210107, "apple/isp_2921_01XX.dat", 0xed6c},
[ISP_IMX614_2921_02] = {0x614, "imx614", 0x29210202, "apple/isp_2921_02XX.dat", 0xed6c},
[ISP_IMX614_2922_02] = {0x614, "imx614", 0x29220201, "apple/isp_2922_02XX.dat", 0xed6c},
[ISP_IMX633_3622_01] = {0x633, "imx633", 0x36220111, "apple/isp_3622_01XX.dat", 0x100d4},
[ISP_IMX703_7721_01] = {0x703, "imx703", 0x77210106, "apple/isp_7721_01XX.dat", 0x936c},
[ISP_IMX703_7722_01] = {0x703, "imx703", 0x77220106, "apple/isp_7722_01XX.dat", 0xac20},
[ISP_IMX713_4721_01] = {0x713, "imx713", 0x47210107, "apple/isp_4721_01XX.dat", 0x936c},
[ISP_IMX713_4722_01] = {0x713, "imx713", 0x47220109, "apple/isp_4722_01XX.dat", 0x9218},
[ISP_IMX714_2022_01] = {0x714, "imx714", 0x20220107, "apple/isp_2022_01XX.dat", 0xa198},
[ISP_IMX772_3721_01] = {0x772, "imx772", 0x37210106, "apple/isp_3721_01XX.dat", 0xfdf8},
[ISP_IMX772_3721_11] = {0x772, "imx772", 0x37211106, "apple/isp_3721_11XX.dat", 0xfe14},
[ISP_IMX772_3722_01] = {0x772, "imx772", 0x37220104, "apple/isp_3722_01XX.dat", 0xfca4},
[ISP_IMX772_3723_01] = {0x772, "imx772", 0x37230106, "apple/isp_3723_01XX.dat", 0xfca4},
[ISP_IMX814_2123_01] = {0x814, "imx814", 0x21230101, "apple/isp_2123_01XX.dat", 0xed54},
[ISP_IMX853_7622_01] = {0x853, "imx853", 0x76220112, "apple/isp_7622_01XX.dat", 0x247f8},
[ISP_IMX913_7523_01] = {0x913, "imx913", 0x75230107, "apple/isp_7523_01XX.dat", 0x247f8},
[ISP_IMX958_2224_01] = {0x958, "imx958-uw", 0x22240106, "apple/isp_2224_01XX.dat", 0x6ff4,
0, ISP_TEMPORAL_FILTER_BAND0},
[ISP_VD56G0_6221_01] = {0xd56, "vd56g0", 0x62210102, "apple/isp_6221_01XX.dat", 0x1b80},
[ISP_VD56G0_6222_01] = {0xd56, "vd56g0", 0x62220102, "apple/isp_6222_01XX.dat", 0x1b80},
};
// clang-format on

Expand Down Expand Up @@ -594,6 +595,22 @@ int apple_isp_detect_camera(struct apple_isp *isp)
return err;
}

const char *apple_isp_sensor_name(struct apple_isp *isp)
{
const struct isp_format *fmt;
const char *sensor = NULL;

mutex_lock(&isp->video_lock);
if (isp->camera_detected) {
fmt = isp_get_current_format(isp);
if ((unsigned int)fmt->id < ARRAY_SIZE(isp_setfiles))
sensor = isp_setfiles[fmt->id].sensor;
}
mutex_unlock(&isp->video_lock);

return sensor;
}

/*
* A setfile is a chain of { le32 size, le32 0, le32 tag, payload } sections
* from 0x14 on, size counting what follows it. The lens shading sections
Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/apple/isp/isp-cam.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define ISP_FRAME_RATE_DEFAULT 30

int apple_isp_detect_camera(struct apple_isp *isp);
const char *apple_isp_sensor_name(struct apple_isp *isp);

int apple_isp_start_camera(struct apple_isp *isp);
void apple_isp_stop_camera(struct apple_isp *isp);
Expand Down
25 changes: 25 additions & 0 deletions drivers/media/platform/apple/isp/isp-drv-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,33 @@ static void isp_test_firmware_lifetime(struct kunit *test)
}
}

static void isp_test_sensor_sysfs(struct kunit *test)
{
struct device *dev = kunit_device_register(test, "apple-isp-sensor-test");
struct apple_isp *isp;
char buf[32];

KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
KUNIT_EXPECT_EQ(test, sensor_show(dev, &dev_attr_sensor, buf), -ENODATA);

isp = kunit_kzalloc(test, sizeof(*isp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, isp);
mutex_init(&isp->video_lock);
dev_set_drvdata(dev, isp);

/* Before detection on deferred-start hardware, report -ENODATA. */
KUNIT_EXPECT_EQ(test, sensor_show(dev, &dev_attr_sensor, buf), -ENODATA);

isp_get_current_format(isp)->id = ISP_IMX958_2224_01;
isp->camera_detected = true;
KUNIT_EXPECT_EQ(test, sensor_show(dev, &dev_attr_sensor, buf),
(ssize_t)strlen("imx958-uw\n"));
KUNIT_EXPECT_STREQ(test, buf, "imx958-uw\n");
}

static struct kunit_case isp_hw_test_cases[] = {
KUNIT_CASE(isp_test_firmware_lifetime),
KUNIT_CASE(isp_test_sensor_sysfs),
{}
};

Expand Down
Loading