summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2024-01-23 15:48:29 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2024-01-23 15:48:29 +0000
commit34ddc189288e66bf4aa813b6170abb2c98e4e296 (patch)
tree6fc079fcc7df3dad55ef5a8cdb7cd889abce54fa /sys
parent0625a3977a423ad09756c2bc18cfaa57a1452b6e (diff)
drm: apple: backlight: force backlight update after resume
From Mark Kettenis fcad9f366ba0c934f877662ee8199051b636d2e1 in jannau's bits/200-dcp
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/apple/dcp-internal.h3
-rw-r--r--sys/dev/pci/drm/apple/dcp.c10
-rw-r--r--sys/dev/pci/drm/apple/dcp_backlight.c31
-rw-r--r--sys/dev/pci/drm/apple/iomfb_template.c1
4 files changed, 32 insertions, 13 deletions
diff --git a/sys/dev/pci/drm/apple/dcp-internal.h b/sys/dev/pci/drm/apple/dcp-internal.h
index 55d6303599d..a8425daea0f 100644
--- a/sys/dev/pci/drm/apple/dcp-internal.h
+++ b/sys/dev/pci/drm/apple/dcp-internal.h
@@ -212,6 +212,8 @@ struct apple_dcp {
/* Workqueue for updating the initial initial brightness */
struct work_struct bl_register_wq;
struct rwlock bl_register_mutex;
+ /* Workqueue for updating the brightness */
+ struct work_struct bl_update_wq;
/* integrated panel if present */
struct dcp_panel panel;
@@ -241,6 +243,7 @@ struct apple_dcp {
};
int dcp_backlight_register(struct apple_dcp *dcp);
+int dcp_backlight_update(struct apple_dcp *dcp);
bool dcp_has_panel(struct apple_dcp *dcp);
#define DCP_AUDIO_MAX_CHANS 15
diff --git a/sys/dev/pci/drm/apple/dcp.c b/sys/dev/pci/drm/apple/dcp.c
index 6eb2d552299..bf797bc8d97 100644
--- a/sys/dev/pci/drm/apple/dcp.c
+++ b/sys/dev/pci/drm/apple/dcp.c
@@ -516,6 +516,15 @@ out_unlock:
mutex_unlock(&dcp->bl_register_mutex);
}
+static void dcp_work_update_backlight(struct work_struct *work)
+{
+ struct apple_dcp *dcp;
+
+ dcp = container_of(work, struct apple_dcp, bl_update_wq);
+
+ dcp_backlight_update(dcp);
+}
+
static int dcp_create_piodma_iommu_dev(struct apple_dcp *dcp)
{
int ret;
@@ -836,6 +845,7 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
dcp->connector_type = DRM_MODE_CONNECTOR_eDP;
INIT_WORK(&dcp->bl_register_wq, dcp_work_register_backlight);
rw_init(&dcp->bl_register_mutex, "dcpbl");
+ INIT_WORK(&dcp->bl_update_wq, dcp_work_update_backlight);
} else if (of_property_match_string(dev->of_node, "apple,connector-type", "HDMI-A") >= 0)
dcp->connector_type = DRM_MODE_CONNECTOR_HDMIA;
else if (of_property_match_string(dev->of_node, "apple,connector-type", "DP") >= 0)
diff --git a/sys/dev/pci/drm/apple/dcp_backlight.c b/sys/dev/pci/drm/apple/dcp_backlight.c
index d3e9a33b79e..54bbaec6335 100644
--- a/sys/dev/pci/drm/apple/dcp_backlight.c
+++ b/sys/dev/pci/drm/apple/dcp_backlight.c
@@ -172,20 +172,8 @@ done:
return ret;
}
-static int dcp_set_brightness(struct backlight_device *bd)
+int dcp_backlight_update(struct apple_dcp *dcp)
{
- int ret = 0;
- struct apple_dcp *dcp = bl_get_data(bd);
- struct drm_modeset_acquire_ctx ctx;
- int brightness = backlight_get_brightness(bd);
-
- DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
-
- dcp->brightness.dac = calculate_dac(dcp, brightness);
- dcp->brightness.update = true;
-
- DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);
-
/*
* Do not actively try to change brightness if no mode is set.
* TODO: should this be reflected the in backlight's power property?
@@ -202,6 +190,23 @@ static int dcp_set_brightness(struct backlight_device *bd)
return drm_crtc_set_brightness(dcp);
}
+static int dcp_set_brightness(struct backlight_device *bd)
+{
+ int ret = 0;
+ struct apple_dcp *dcp = bl_get_data(bd);
+ struct drm_modeset_acquire_ctx ctx;
+ int brightness = backlight_get_brightness(bd);
+
+ DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
+
+ dcp->brightness.dac = calculate_dac(dcp, brightness);
+ dcp->brightness.update = true;
+
+ DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);
+
+ return dcp_backlight_update(dcp);
+}
+
static const struct backlight_ops dcp_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.get_brightness = dcp_get_brightness,
diff --git a/sys/dev/pci/drm/apple/iomfb_template.c b/sys/dev/pci/drm/apple/iomfb_template.c
index 7c8dc5a25d1..c2f8dc003c4 100644
--- a/sys/dev/pci/drm/apple/iomfb_template.c
+++ b/sys/dev/pci/drm/apple/iomfb_template.c
@@ -497,6 +497,7 @@ static void iomfbep_cb_enable_backlight_message_ap_gated(struct apple_dcp *dcp,
* syslog: "[BrightnessLCD.cpp:743][AFK]nitsToDBV: iDAC out of range"
*/
dcp->brightness.update = true;
+ schedule_work(&dcp->bl_update_wq);
}
/* Chunked data transfer for property dictionaries */