diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-12-05 07:40:22 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-12-05 07:40:22 +0000 |
commit | 93b6f7269000e3850f66d45a3d7544a250232e1b (patch) | |
tree | 7c964c9c90d0816d5a8c64648289748af5264b0d | |
parent | 2a68cea7fed2937705b9078a49a10b0f24279a84 (diff) |
Add support for the Backlight connector property like we already have for
inteldrm(4). This makes xbacklight(1) work when using the Xorg modesetting
driver. The Xorg amdgpu driver needs a small change for this that should
land soon.
ok jsg@
-rw-r--r-- | sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c index 27666951fed..7d8ca55e09a 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c @@ -2039,6 +2039,7 @@ amdgpu_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) case WSDISPLAYIO_PARAM_BRIGHTNESS: bd->props.brightness = dp->curval; backlight_update_status(bd); + KNOTE(&adev->ddev.note, NOTE_CHANGE); return 0; } break; @@ -2118,6 +2119,32 @@ amdgpu_enter_ddb(void *v, void *cookie) drm_fb_helper_debug_enter(fb_helper->fbdev); } +void +amdgpu_init_backlight(struct amdgpu_device *adev) +{ + struct drm_device *dev = &adev->ddev; + struct backlight_device *bd = adev->dm.backlight_dev[0]; + struct drm_connector_list_iter conn_iter; + struct drm_connector *connector; + + if (bd == NULL) + return; + + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS && + connector->connector_type != DRM_MODE_CONNECTOR_eDP && + connector->connector_type != DRM_MODE_CONNECTOR_DSI) + continue; + + connector->backlight_device = bd; + connector->backlight_property = drm_property_create_range(dev, + 0, "Backlight", 0, bd->props.max_brightness); + drm_object_attach_property(&connector->base, + connector->backlight_property, bd->props.brightness); + } + drm_connector_list_iter_end(&conn_iter); +} void amdgpu_attachhook(struct device *self) @@ -2175,6 +2202,8 @@ amdgpu_attachhook(struct device *self) struct wsemuldisplaydev_attach_args aa; struct rasops_info *ri = &adev->ro; + amdgpu_init_backlight(adev); + task_set(&adev->switchtask, amdgpu_doswitch, ri); if (ri->ri_bits == NULL) |