Skip to content
Merged
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
6 changes: 1 addition & 5 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,12 @@ static int apple_drm_init_dcp(struct device *dev)

for_each_matching_node(np, apple_dcp_id_tbl) {
bool dcp_ext;
if (!apple_dcp_usable(np)) {
of_node_put(np);
if (!apple_dcp_usable(np))
continue;
}
dcp_ext = of_device_is_compatible(np, "apple,dcpext") ||
of_property_present(np, "phys");

dcp[num_dcp] = of_find_device_by_node(np);
of_node_put(np);
if (!dcp[num_dcp])
continue;

Expand Down Expand Up @@ -875,7 +872,6 @@ static int add_dcp_components(struct device *dev,
of_node_put(port);
}
}
of_node_put(np);
}

return num;
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3844,6 +3844,12 @@ static void dcp_drain_for_sleep(struct apple_dcp *dcp)
* the first attempt and the policy's three retries.
*/
for (pass = 0; pass < 4; pass++) {
/*
* A crashed or stopped DCP takes no more presents, so a level
* still pending there can never be sent and is not waited for.
*/
if (READ_ONCE(dcp->crashed) || READ_ONCE(dcp->iomfb.stopped))
return;
flush_delayed_work(&dcp->iomfb.backlight_retry);
if (dcp_has_panel(dcp))
flush_work(&dcp->bl_update_wq);
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/apple/dcp_backlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ static inline int dcp_bl_init(struct dcp_backlight_state *state, u32 maximum,
return 0;
}

/* A decoded powerlog sample can seed takeover only before Linux control. */
/*
* A decoded powerlog sample can seed takeover only before Linux control.
* It reports the level the panel shows, so the level is then known.
*/
static inline bool dcp_bl_seed(struct dcp_backlight_state *state, u32 nits)
{
if (!state->ready || state->controlled || nits > state->maximum)
return false;
state->target = nits;
state->actual = nits;
state->level_known = true;
return true;
}

Expand Down
26 changes: 26 additions & 0 deletions drivers/gpu/drm/apple/dcp_backlight_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,31 @@ static void backlight_fallback_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, present.nits, 262U);
}

static void backlight_seed_known_test(struct kunit *test)
{
struct dcp_backlight_state state;
struct dcp_backlight_present present;

/* A loader sample seeded over a registration default is known. */
KUNIT_ASSERT_EQ(test, dcp_bl_init(&state, 525, false, 0, true, 262), 0);
KUNIT_EXPECT_FALSE(test, state.level_known);
KUNIT_EXPECT_TRUE(test, dcp_bl_seed(&state, 180));
KUNIT_EXPECT_TRUE(test, state.level_known);
state.controlled = true;
KUNIT_EXPECT_TRUE(test, dcp_bl_resend(&state));
KUNIT_ASSERT_EQ(test, dcp_bl_prepare(&state, true, &present), 0);
KUNIT_EXPECT_EQ(test, present.nits, 180U);

/* A refused sample leaves the default unknown. */
KUNIT_ASSERT_EQ(test, dcp_bl_init(&state, 525, false, 0, true, 262), 0);
KUNIT_EXPECT_FALSE(test, dcp_bl_seed(&state, 526));
KUNIT_EXPECT_FALSE(test, state.level_known);
state.controlled = true;
KUNIT_EXPECT_FALSE(test, dcp_bl_seed(&state, 180));
KUNIT_EXPECT_FALSE(test, state.level_known);
KUNIT_EXPECT_FALSE(test, dcp_bl_resend(&state));
}

static struct kunit_case backlight_cases[] = {
KUNIT_CASE(backlight_millinits_takeover_test),
KUNIT_CASE(backlight_takeover_test),
Expand All @@ -304,6 +329,7 @@ static struct kunit_case backlight_cases[] = {
KUNIT_CASE(backlight_inflight_dpms_test),
KUNIT_CASE(backlight_resend_test),
KUNIT_CASE(backlight_fallback_test),
KUNIT_CASE(backlight_seed_known_test),
{}
};

Expand Down