/* 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;
};
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
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;
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)
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?
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,