@@ -78,6 +78,7 @@
#define PMF_POLICY_STT_SKINTEMP_APU 7
#define PMF_POLICY_STT_SKINTEMP_HS2 8
#define PMF_POLICY_SYSTEM_STATE 9
+#define PMF_POLICY_DISPLAY_BRIGHTNESS 12
#define PMF_POLICY_P3T 38
/* TA macros */
@@ -503,6 +504,7 @@ enum ta_pmf_error_type {
};
struct pmf_action_table {
+ unsigned long display_brightness;
enum system_state system_state;
u32 spl; /* in mW */
u32 sppt; /* in mW */
@@ -77,8 +77,10 @@ static int amd_pmf_update_uevents(struct amd_pmf_dev *dev, u16 event)
return 0;
}
-static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out)
+static int amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_result *out)
{
+ struct thermal_cooling_device *cdev = dev->gfx_data.cooling_dev;
+ unsigned long state;
u32 val;
int idx;
@@ -154,8 +156,21 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n",
amd_pmf_uevent_as_str(val));
break;
+
+ case PMF_POLICY_DISPLAY_BRIGHTNESS:
+ if (!dev->drm_dev)
+ return -ENODEV;
+
+ cdev->ops->get_cur_state(cdev, &state);
+ if (state != val) {
+ cdev->ops->set_cur_state(cdev, val);
+ dev_dbg(dev->dev, "update DISPLAY_BRIGHTNESS: %u\n", val);
+ }
+ break;
}
}
+
+ return 0;
}
static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
@@ -192,7 +207,9 @@ static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
amd_pmf_dump_ta_inputs(dev, in);
dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count,
ta_sm->pmf_result);
- amd_pmf_apply_policies(dev, out);
+ ret = amd_pmf_apply_policies(dev, out);
+ if (ret)
+ return ret;
}
return 0;
@@ -423,6 +440,23 @@ static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)
tee_client_close_context(dev->tee_ctx);
}
+static int amd_pmf_gpu_set_cur_state(struct thermal_cooling_device *cooling_dev,
+ unsigned long state)
+{
+ struct backlight_device *bd;
+
+ if (acpi_video_get_backlight_type() != acpi_backlight_native)
+ return -ENODEV;
+
+ bd = backlight_device_get_by_type(BACKLIGHT_RAW);
+ if (!bd)
+ return -ENODEV;
+
+ backlight_device_set_brightness(bd, state);
+
+ return 0;
+}
+
static int amd_pmf_gpu_get_cur_state(struct thermal_cooling_device *cooling_dev,
unsigned long *state)
{
@@ -463,6 +497,7 @@ static int amd_pmf_gpu_get_max_state(struct thermal_cooling_device *cooling_dev,
static const struct thermal_cooling_device_ops bd_cooling_ops = {
.get_max_state = amd_pmf_gpu_get_max_state,
.get_cur_state = amd_pmf_gpu_get_cur_state,
+ .set_cur_state = amd_pmf_gpu_set_cur_state,
};
static int amd_pmf_get_gpu_handle(struct pci_dev *pdev, void *data)