summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2019-08-13 22:02:29 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2019-08-13 22:02:29 +0000
commit79253f0d66521ca45f97fa278f24fc4b4fc5d930 (patch)
tree9cc259f2ac078bbefb8245f095c48e86a36e16e4
parent46da9636a4959c81e0974caf99f364db627ecc1d (diff)
Implement backlight control for amdgpu(4). This allows me to set
the backlight of my X395 using wsconsctl(8). Unfortunately the backlight hotkeys don't yet allow adjusting the brightness. ok jsg@ kettenis@
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c
index 526306cf86f..595afdef9f1 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c
@@ -1664,6 +1664,9 @@ int
amdgpu_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct rasops_info *ri = v;
+ struct amdgpu_device *adev = ri->ri_hw;
+ struct backlight_device *bd = adev->dm.backlight_dev;
+ struct wsdisplay_param *dp = (struct wsdisplay_param *)data;
struct wsdisplay_fbinfo *wdf;
switch (cmd) {
@@ -1677,9 +1680,32 @@ amdgpu_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
wdf->depth = ri->ri_depth;
wdf->cmsize = 0;
return 0;
- default:
- return -1;
+ case WSDISPLAYIO_GETPARAM:
+ if (bd == NULL)
+ return -1;
+
+ switch (dp->param) {
+ case WSDISPLAYIO_PARAM_BRIGHTNESS:
+ dp->min = 0;
+ dp->max = bd->props.max_brightness;
+ dp->curval = bd->ops->get_brightness(bd);
+ return (dp->max > dp->min) ? 0 : -1;
+ }
+ break;
+ case WSDISPLAYIO_SETPARAM:
+ if (bd == NULL || dp->curval > bd->props.max_brightness)
+ return -1;
+
+ switch (dp->param) {
+ case WSDISPLAYIO_PARAM_BRIGHTNESS:
+ bd->props.brightness = dp->curval;
+ backlight_update_status(bd);
+ return 0;
+ }
+ break;
}
+
+ return (-1);
}
paddr_t