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 arch/arm64/boot/dts/apple/s800x-6s.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@
power-domains = <&ps_disp0 &ps_mipi_dsi>;
};

/*
* The backlight goes off and on with the pipe. It does not hold up the pipe's
* probe: the driver looks it up when the pipe is next enabled or disabled.
*/
&disp0 {
backlight = <&dwi_bl>;
post-init-providers = <&dwi_bl>;
};

&i2c0 {
status = "okay";

Expand Down
77 changes: 58 additions & 19 deletions drivers/gpu/drm/adbe/adbe_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,36 @@ static void adbe_dsi_panel_set(struct adbe *adbe, bool on)
}
}

static void adbe_panel_attach(struct adbe *adbe);
static bool adbe_backlight_find(struct adbe *adbe);

/*
* The backlight follows the pipe: off when the CRTC goes off (a compositor's
* DPMS off, a power-down fbdev blank: this kernel has no FB_BACKLIGHT), on
* when it comes back. A backlight held off after a failed panel wake stays
* off. Never under panel_lock: suspend and resume take it around, not
* inside, the CRTC's disable and enable.
*/
static void adbe_backlight_set(struct adbe *adbe, bool on)
{
mutex_lock(&adbe->panel_lock);
adbe_panel_attach(adbe);
adbe_backlight_find(adbe);
if (adbe->backlight && !adbe->bl_held) {
if (on)
backlight_enable(adbe->backlight);
else
backlight_disable(adbe->backlight);
}
mutex_unlock(&adbe->panel_lock);
}

static void adbe_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
drm_crtc_vblank_on(crtc);
adbe_dsi_panel_set(to_adbe(crtc->dev), true);
adbe_backlight_set(to_adbe(crtc->dev), true);
}

static void adbe_crtc_atomic_disable(struct drm_crtc *crtc,
Expand All @@ -1126,6 +1151,7 @@ static void adbe_crtc_atomic_disable(struct drm_crtc *crtc,
struct drm_pending_vblank_event *done;
unsigned long flags;

adbe_backlight_set(adbe, false);
timer_delete_sync(&adbe->flip_timer);
spin_lock_irqsave(&crtc->dev->event_lock, flags);
done = adbe->event;
Expand Down Expand Up @@ -2450,6 +2476,36 @@ static int adbe_link_train(struct adbe *adbe)
return ret;
}

/*
* Under panel_lock: the backlight the "backlight" phandle names. False while
* it has not registered yet. Boards without a panel supply (the MIPI DSI
* panels) have one too, so this does not depend on the DisplayPort window.
*/
static bool adbe_backlight_find(struct adbe *adbe)
{
struct device *dev = adbe->drm.dev;
struct device_node *np;

if (adbe->bl_link)
return true;
np = of_parse_phandle(dev->of_node, "backlight", 0);
if (!np)
return true;
adbe->backlight = of_find_backlight_by_node(np);
of_node_put(np);
if (!adbe->backlight)
return false;
adbe->bl_link = device_link_add(&adbe->backlight->dev, dev,
DL_FLAG_STATELESS);
if (!adbe->bl_link) {
dev_warn(dev, "cannot order the backlight after the panel\n");
put_device(&adbe->backlight->dev);
adbe->backlight = NULL;
return false;
}
return true;
}

/*
* Look up the panel supply and the backlight once, before the first sleep,
* and order system sleep: the display pipe suspends before the PMU GPIO
Expand All @@ -2459,7 +2515,6 @@ static int adbe_link_train(struct adbe *adbe)
static void adbe_panel_attach(struct adbe *adbe)
{
struct device *dev = adbe->drm.dev;
struct device_node *np;
struct gpio_desc *ldo;

if (adbe->panel_ready || !adbe->dp)
Expand Down Expand Up @@ -2487,24 +2542,8 @@ static void adbe_panel_attach(struct adbe *adbe)
}
}

np = of_parse_phandle(dev->of_node, "backlight", 0);
if (np && !adbe->bl_link) {
adbe->backlight = of_find_backlight_by_node(np);
if (!adbe->backlight) {
of_node_put(np);
return; /* not registered yet: next sleep */
}
adbe->bl_link = device_link_add(&adbe->backlight->dev, dev,
DL_FLAG_STATELESS);
if (!adbe->bl_link) {
dev_warn(dev, "cannot order the backlight after the panel\n");
put_device(&adbe->backlight->dev);
adbe->backlight = NULL;
of_node_put(np);
return;
}
}
of_node_put(np);
if (!adbe_backlight_find(adbe))
return; /* not registered yet: next sleep */
adbe->panel_ready = true;
}

Expand Down
Loading