diff --git a/drivers/gpu/drm/apple/dcp-display-metadata.c b/drivers/gpu/drm/apple/dcp-display-metadata.c index 1e393c2ea9d2b..6b9d14d4eaa04 100644 --- a/drivers/gpu/drm/apple/dcp-display-metadata.c +++ b/drivers/gpu/drm/apple/dcp-display-metadata.c @@ -428,7 +428,8 @@ const struct drm_edid *dcp_metadata_edid(const struct dcp_display_metadata *meta /* * This identity-only DTD is not enumerated or programmed. Keep the DCP clock, - * active area and blanking, but fit vertical sync placement into EDID's six-bit + * active area and blanking, give a sync polarity where the firmware gives none + * (as on M4), and fit vertical sync placement into EDID's six-bit * fields. Notch hiding expands the real sync pulse beyond those fields; the * exact syncs remain in the authoritative TimingElements catalogue. */ @@ -438,6 +439,7 @@ static int dcp_panel_identity_timing(struct detailed_timing *timing, { struct drm_display_mode summary = *mode; + dcp_metadata_timing_polarity(&summary); /* Refuse invalid source geometry before reducing the EDID summary. */ if (mode->vdisplay <= 0 || mode->vdisplay > 4095 || mode->vsync_start < mode->vdisplay || mode->vsync_end <= mode->vsync_start || diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index c4934fcb3fef3..d65eb5b4525c3 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7605,6 +7605,13 @@ static int dcp_comp_bind_pipe(struct device *dev, struct device *main, void *dat ret = dcp_pin_live_session(dcp); if (ret) return ret; + if (dcp->panel_identity) { + of_property_read_u32(dev->of_node, "apple,panel-width-mm", + &dcp->panel.width_mm); + of_property_read_u32(dev->of_node, "apple,panel-height-mm", + &dcp->panel.height_mm); + dcp_panel_read_adt(dcp); + } ret = iomfb_m4_start(dcp, main); if (!ret) WRITE_ONCE(dcp->active, true); @@ -8897,6 +8904,12 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) if (!dcp->panel_identity) return -ENOMEM; } + } else if (of_property_present(dev->of_node, "apple,panel-width-mm")) { + /* Its node describes the panel itself, without a child. */ + dcp->panel_identity = devm_kzalloc(dev, sizeof(*dcp->panel_identity), + GFP_KERNEL); + if (!dcp->panel_identity) + return -ENOMEM; } if (fw_compat == DCP_FIRMWARE_V_27_0) { char compat_str[DCP_FW_VERSION_STR_LEN]; diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index b507be69895a7..e996aef48c2ff 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -2902,6 +2902,26 @@ void dcp_link_report(struct apple_dcp *dcp, const struct drm_display_mode *mode) dev_info(dcp->dev, "ext %u: %s\n", dcp->index ? dcp->index - 1 : 0, line); } +/* + * The EDID of an M4 internal panel: the identity and colour target of every + * internal panel, with the firmware's one timing. + */ +static void dcp_m4_panel_edid(struct apple_dcp *dcp, struct drm_connector *connector, + const struct drm_display_mode *timing) +{ + struct dcp_display_mode mode = { .mode = *timing }; + const struct drm_edid *edid; + u64 generation; + + edid = dcp_panel_edid_snapshot(dcp, &mode, 1, &generation); + if (IS_ERR(edid)) { + dev_dbg(dcp->dev, "panel EDID generation failed: %pe\n", edid); + edid = NULL; + } + drm_edid_connector_update(connector, edid); + drm_edid_free(edid); +} + int dcp_get_modes(struct drm_connector *connector) { struct apple_connector *apple_connector = to_apple_connector(connector); @@ -2973,6 +2993,9 @@ int dcp_get_modes(struct drm_connector *connector) drm_mode_probed_add(connector, mode); n++; } + /* The panel's EDID lists its timing, not its notch-free twin. */ + dcp_m4_panel_edid(dcp, connector, &fixed); + /* The EDID's size is in whole centimetres. */ of_property_read_u32(dcp->dev->of_node, "apple,panel-width-mm", &connector->display_info.width_mm); of_property_read_u32(dcp->dev->of_node, "apple,panel-height-mm", diff --git a/drivers/gpu/drm/apple/parser-test.c b/drivers/gpu/drm/apple/parser-test.c index 340e1157108d6..e798a489f6ae3 100644 --- a/drivers/gpu/drm/apple/parser-test.c +++ b/drivers/gpu/drm/apple/parser-test.c @@ -1555,6 +1555,26 @@ static void parser_panel_color_target(struct kunit *test) KUNIT_EXPECT_EQ(test, raw->gamma, 0xff); } +/* A timing without a sync polarity, as M4 firmware gives, still describes the panel. */ +static void parser_panel_timing_polarity(struct kunit *test) +{ + static const struct dcp_display_metadata metadata = { + .manufacturer = "APP", .name = "Apple Panel", + }; + struct dcp_display_mode mode = panel_color_mode; + const struct drm_edid *edid; + + mode.mode.flags = 0; + edid = dcp_panel_edid(&metadata, dcp_color_space_lookup("display-p3"), &mode, 1, 290, 188); + KUNIT_ASSERT_FALSE(test, IS_ERR(edid)); + KUNIT_EXPECT_TRUE(test, drm_edid_valid(edid)); + KUNIT_EXPECT_EQ(test, drm_edid_raw(edid)->detailed_timings[0].data.pixel_data.misc, + 0x18 | DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE); + drm_edid_free(edid); + /* The mode published stays the firmware's. */ + KUNIT_EXPECT_EQ(test, mode.mode.flags, 0U); +} + static size_t parser_adt_property(u8 *out, size_t capacity, const char *name, const void *value, u32 size) { @@ -2426,6 +2446,7 @@ static struct kunit_case parser_cases[] = { KUNIT_CASE(parser_panel_identity_stable), KUNIT_CASE(parser_panel_identity), KUNIT_CASE(parser_panel_color_target), + KUNIT_CASE(parser_panel_timing_polarity), KUNIT_CASE(parser_panel_adt_color_target), KUNIT_CASE(parser_tiled_size_keeps_dsc_modes), KUNIT_CASE(parser_score_presence),