diff --git a/Documentation/ABI/testing/sysfs-driver-apple-isp b/Documentation/ABI/testing/sysfs-driver-apple-isp new file mode 100644 index 0000000000000..9833222c472cc --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-apple-isp @@ -0,0 +1,9 @@ +What: /sys/bus/platform/drivers/apple-isp//sensor +Date: November 2026 +Contact: Artyom Astafurov +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. diff --git a/MAINTAINERS b/MAINTAINERS index 3f919f3e327f3..d73bebe00fa6e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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/* diff --git a/arch/arm64/boot/dts/apple/t6041.dtsi b/arch/arm64/boot/dts/apple/t6041.dtsi index be2b09cc1dfd5..8108d0e2e9368 100644 --- a/arch/arm64/boot/dts/apple/t6041.dtsi +++ b/arch/arm64/boot/dts/apple/t6041.dtsi @@ -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>, @@ -483,5 +485,7 @@ 0x224004000 0x2241d62fc 0x226004000 0x2261d62fc 0x228004000 0x2281d62fc - 0x22a004000 0x22a1d62fc>; + 0x22a004000 0x22a1d62fc + 0x22c004000 0x22c1d62fc + 0x22e004000 0x22e1d62fc>; }; diff --git a/drivers/media/platform/apple/isp/isp-cam-test.c b/drivers/media/platform/apple/isp/isp-cam-test.c index 4cb1ae2800182..486bc30d8826f 100644 --- a/drivers/media/platform/apple/isp/isp-cam-test.c +++ b/drivers/media/platform/apple/isp/isp-cam-test.c @@ -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), @@ -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), diff --git a/drivers/media/platform/apple/isp/isp-cam.c b/drivers/media/platform/apple/isp/isp-cam.c index e3c39232e727b..8ef517baccf9e 100644 --- a/drivers/media/platform/apple/isp/isp-cam.c +++ b/drivers/media/platform/apple/isp/isp-cam.c @@ -27,6 +27,7 @@ enum isp_temporal_filter { struct isp_setfile { u32 version; + const char *sensor; u32 magic; const char *path; size_t size; @@ -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 @@ -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 diff --git a/drivers/media/platform/apple/isp/isp-cam.h b/drivers/media/platform/apple/isp/isp-cam.h index 51c2f2ec6c079..66bcacd8569af 100644 --- a/drivers/media/platform/apple/isp/isp-cam.h +++ b/drivers/media/platform/apple/isp/isp-cam.h @@ -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); diff --git a/drivers/media/platform/apple/isp/isp-drv-test.c b/drivers/media/platform/apple/isp/isp-drv-test.c index 37cffe14aa9b8..7ec962b810034 100644 --- a/drivers/media/platform/apple/isp/isp-drv-test.c +++ b/drivers/media/platform/apple/isp/isp-drv-test.c @@ -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), {} }; diff --git a/drivers/media/platform/apple/isp/isp-drv.c b/drivers/media/platform/apple/isp/isp-drv.c index 40fd29f743bd9..016784c2d1c3f 100644 --- a/drivers/media/platform/apple/isp/isp-drv.c +++ b/drivers/media/platform/apple/isp/isp-drv.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "isp-cam.h" @@ -285,6 +286,8 @@ static int apple_isp_copy_fw_data(struct apple_isp *isp) * trees from before those were described run it resident instead * (hw->resident_fallback), as it ran before. */ +#define ISP_T6041_NON_AMCC_MMIO 7 + static void apple_isp_select_hw(struct apple_isp *isp) { struct device *dev = isp->dev; @@ -296,6 +299,36 @@ static void apple_isp_select_hw(struct apple_isp *isp) struct device_node *dart __free(device_node) = of_parse_phandle(dev->of_node, "iommus", 0); + /* + * apple,t6041-isp is also the T6040 ISP: T6040 has four AMCCs, T6041 + * six on binned parts and eight on full-die parts. Trim the mapped DSID + * windows and broadcast-clear count to the AMCC ranges described on + * isp_dart0. Without them, keep the four that every part has, as + * before T6041's own windows were described. + */ + if (of_device_is_compatible(dev->of_node, "apple,t6041-isp")) { + unsigned int amccs = 4; + int n = dart ? of_property_count_u64_elems(dart, "apple,dapf-ranges") : -EINVAL; + + if (n > 0 && !(n % 2)) { + unsigned int found = 0; + + for (int i = 0; i < n; i += 2) { + u64 start = 0; + + if (!of_property_read_u64_index(dart, "apple,dapf-ranges", + i, &start) && + start >= 0x220004000ULL && start <= 0x22e004000ULL && + !((start - 0x220004000ULL) % 0x2000000ULL)) + found++; + } + if (found >= 4 && found <= 8) + amccs = found; + } + hw->dsid_count = amccs; + hw->num_fw_mmio = ISP_T6041_NON_AMCC_MMIO + amccs; + } + /* * Resident firmware that starts again (hw->fw_restart) runs from its own * memory, but after a power-down it reaches its MMIO only once the first @@ -1331,6 +1364,78 @@ static const struct apple_isp_hw apple_isp_hw_t6040 = { .meta_exposure = true, }; +/* + * T6041: the seven PMGR/PMP/fabric windows of J616c's dart-isp0 filter + * followed by up to eight AMCC DSID broadcast-clear windows (six on binned + * parts, eight on full-die parts; apple_isp_select_hw() trims to the active + * AMCCs listed on isp_dart0). + */ +static const struct isp_mmio_window apple_isp_fw_mmio_t6041[] = { + { 0x485660000, 0x4000 }, + { 0x5003c0000, 0x28000 }, /* PMGR, with the PMP clock scratch */ + { 0x500e3c000, 0x4000 }, + { 0x502284000, 0x4000 }, /* PMGR, ISP power states */ + { 0x502880000, 0x8000 }, + { 0x504824000, 0x4000 }, /* PMP bandwidth scratch */ + { 0x51062c000, 0x20000 }, + { 0x220004000, 0x1d4000 }, /* DSID broadcast-clear windows */ + { 0x222004000, 0x1d4000 }, + { 0x224004000, 0x1d4000 }, + { 0x226004000, 0x1d4000 }, + { 0x228004000, 0x1d4000 }, + { 0x22a004000, 0x1d4000 }, + { 0x22c004000, 0x1d4000 }, + { 0x22e004000, 0x1d4000 }, +}; + +static const u64 apple_isp_dsid_t6041[] = { + 0x2201d4000, + 0x2221d4000, + 0x2241d4000, + 0x2261d4000, + 0x2281d4000, + 0x22a1d4000, + 0x22c1d4000, + 0x22e1d4000, +}; + +static const struct apple_isp_hw apple_isp_hw_t6041 = { + .gen = ISP_GEN_T6040, + .fw_abi = ISP_FW_ABI_H17, + .pmu_base = 0x0, + + .dsid_count = ARRAY_SIZE(apple_isp_dsid_t6041), + .dsid_slots = 8, + .dsid_clr_bases = apple_isp_dsid_t6041, + .dsid_clr_range0 = 0x2fc, + + .clock_scratch = 0x5003d0fa8, + .clock_base = 0x0, + .clock_bit = 0x0, + .clock_size = 0x8, + .bandwidth_scratch = 0x504824000, + .bandwidth_base = 0x0, + .bandwidth_bit = 0x0, + .bandwidth_size = 0x8, + .mbox_irq_enable = ISP_MBOX_IRQ_ENABLE_T6031, + + .scl1 = true, + .lpdp = false, + .meta_size = ISP_META_SIZE_T8140, + .fw_mmio = apple_isp_fw_mmio_t6041, + .num_fw_mmio = ARRAY_SIZE(apple_isp_fw_mmio_t6041), + + .coproc_control = ISP_COPROC_CONTROL_T8140, + .coproc_status = ISP_COPROC_STATUS_T8140, + .coproc_quiesce = ISP_COPROC_QUIESCE_T8140, + .boot_mode = 1, + .shared_size = 0xde600000, + .resident_fw = true, + .fw_restart = true, + .fw_idle_ms = 5000, + .meta_exposure = true, +}; + /* * T8132 runs T6040's coprocessor and firmware interface, booted the same * way. Its two AMCCs (ADT mcc amcc_aperture_count) give two broadcast-clear @@ -1519,7 +1624,7 @@ static const struct of_device_id apple_isp_of_match[] = { { .compatible = "apple,t6031-isp", .data = &apple_isp_hw_t6031 }, { .compatible = "apple,t8140-isp", .data = &apple_isp_hw_t8140 }, { .compatible = "apple,t8142-isp", .data = &apple_isp_hw_t8142 }, - { .compatible = "apple,t6041-isp", .data = &apple_isp_hw_t6040 }, + { .compatible = "apple,t6041-isp", .data = &apple_isp_hw_t6041 }, { .compatible = "apple,t8132-isp", .data = &apple_isp_hw_t8132 }, {}, }; @@ -1668,11 +1773,35 @@ static void apple_isp_shutdown(struct platform_device *pdev) mutex_unlock(&isp->video_lock); } +static ssize_t sensor_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct apple_isp *isp = dev_get_drvdata(dev); + const char *sensor; + + if (!isp) + return -ENODATA; + + sensor = apple_isp_sensor_name(isp); + if (!sensor) + return -ENODATA; + + return sysfs_emit(buf, "%s\n", sensor); +} +static DEVICE_ATTR_RO(sensor); + +static struct attribute *apple_isp_attrs[] = { + &dev_attr_sensor.attr, + NULL, +}; +ATTRIBUTE_GROUPS(apple_isp); + static struct platform_driver apple_isp_driver = { .driver = { .name = "apple-isp", .of_match_table = apple_isp_of_match, .pm = pm_ptr(&apple_isp_pm_ops), + .dev_groups = apple_isp_groups, }, .probe = apple_isp_probe, .remove = apple_isp_remove, diff --git a/drivers/media/platform/apple/isp/isp-v4l2-test.c b/drivers/media/platform/apple/isp/isp-v4l2-test.c index 9bc37954f6a57..721e4818eb800 100644 --- a/drivers/media/platform/apple/isp/isp-v4l2-test.c +++ b/drivers/media/platform/apple/isp/isp-v4l2-test.c @@ -159,8 +159,11 @@ static void isp_test_p010_format(struct kunit *test) KUNIT_EXPECT_EQ(test, fmt->strides[0], 2560); KUNIT_EXPECT_EQ(test, fmt->total_size, (size_t)2764800); /* NV12 remains the default and restores the existing pool capacity. */ + f.fmt.pix.quantization = V4L2_QUANTIZATION_FULL_RANGE; KUNIT_ASSERT_EQ(test, isp_set_preset(isp, fmt, &preset, V4L2_PIX_FMT_NV12), 0); + isp_get_sp_pix_format(isp, &f, fmt); KUNIT_EXPECT_EQ(test, fmt->pixelformat, V4L2_PIX_FMT_NV12); + KUNIT_EXPECT_EQ(test, f.fmt.pix.quantization, V4L2_QUANTIZATION_LIM_RANGE); KUNIT_EXPECT_EQ(test, fmt->total_size, (size_t)1382400); KUNIT_EXPECT_EQ(test, isp_num_rendered(isp), ISP_MAX_BUFFERS); KUNIT_EXPECT_EQ(test, isp_num_meta(isp), ISP_MAX_BUFFERS); diff --git a/drivers/media/platform/apple/isp/isp-v4l2.c b/drivers/media/platform/apple/isp/isp-v4l2.c index 41e63a487c3b4..956fb678d08bc 100644 --- a/drivers/media/platform/apple/isp/isp-v4l2.c +++ b/drivers/media/platform/apple/isp/isp-v4l2.c @@ -895,8 +895,7 @@ static inline void isp_get_sp_pix_format(struct apple_isp *isp, f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_709; f->fmt.pix.xfer_func = V4L2_XFER_FUNC_709; - if (fmt->pixelformat == V4L2_PIX_FMT_P010) - f->fmt.pix.quantization = V4L2_QUANTIZATION_LIM_RANGE; + f->fmt.pix.quantization = V4L2_QUANTIZATION_LIM_RANGE; } static int isp_vidioc_get_format(struct file *file, void *fh,