diff options
author | nia <nia@NetBSD.org> | 2024-05-06 01:14:34 +0200 |
---|---|---|
committer | nia <nia@NetBSD.org> | 2024-05-06 01:26:31 +0200 |
commit | f753d699fd2d1832e06d9eb3fd2e706fdb15fa39 (patch) | |
tree | 512e3ebe2cc5e4a0db698ce8cc1d908b2c8b4066 /src/r128_output.c | |
parent | 09ca76bf1dbf28957d9d2db46923ff43da1797b5 (diff) |
backlight control and console detection for wsdisplay systems
based on a patch by Michael Lorenz.
Signed-off-by: Nia Alarie <nia@NetBSD.org>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-video-r128/-/merge_requests/7>
Diffstat (limited to 'src/r128_output.c')
-rw-r--r-- | src/r128_output.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/r128_output.c b/src/r128_output.c index 737d8b1..275ebcc 100644 --- a/src/r128_output.c +++ b/src/r128_output.c @@ -33,8 +33,15 @@ #include <string.h> #include <stdio.h> +#ifdef HAVE_DEV_WSCONS_WSCONSIO_H +#include <sys/ioctl.h> +#include <dev/wscons/wsconsio.h> +#endif + #include "xf86.h" #include "xf86Modes.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" #ifdef HAVE_XEXTPROTO_71 #include "X11/extensions/dpmsconst.h" @@ -211,9 +218,20 @@ void R128DPMSSetOn(xf86OutputPtr output) switch(MonType) { case MT_LCD: - OUTREGP(R128_LVDS_GEN_CNTL, R128_LVDS_BLON, ~R128_LVDS_BLON); - usleep(r128_output->PanelPwrDly * 1000); - OUTREGP(R128_LVDS_GEN_CNTL, R128_LVDS_ON, ~R128_LVDS_ON); +#ifdef WSDISPLAYIO_PARAM_BACKLIGHT + if (info->HaveBacklightControl) { + struct wsdisplay_param p; + + p.param = WSDISPLAYIO_PARAM_BACKLIGHT; + p.curval = 1; + ioctl(xf86Info.consoleFd, WSDISPLAYIO_SETPARAM, &p); + } else +#endif + { + OUTREGP(R128_LVDS_GEN_CNTL, R128_LVDS_BLON, ~R128_LVDS_BLON); + usleep(r128_output->PanelPwrDly * 1000); + OUTREGP(R128_LVDS_GEN_CNTL, R128_LVDS_ON, ~R128_LVDS_ON); + } save->lvds_gen_cntl |= (R128_LVDS_ON | R128_LVDS_BLON); break; case MT_DFP: @@ -240,7 +258,18 @@ void R128DPMSSetOff(xf86OutputPtr output) switch(MonType) { case MT_LCD: - OUTREGP(R128_LVDS_GEN_CNTL, 0, ~(R128_LVDS_BLON | R128_LVDS_ON)); +#ifdef WSDISPLAYIO_PARAM_BACKLIGHT + if (info->HaveBacklightControl) { + struct wsdisplay_param p; + + p.param = WSDISPLAYIO_PARAM_BACKLIGHT; + p.curval = 0; + ioctl(xf86Info.consoleFd, WSDISPLAYIO_SETPARAM, &p); + } else +#endif + { + OUTREGP(R128_LVDS_GEN_CNTL, 0, ~(R128_LVDS_BLON | R128_LVDS_ON)); + } save->lvds_gen_cntl &= ~(R128_LVDS_BLON | R128_LVDS_ON); break; case MT_DFP: @@ -269,6 +298,26 @@ static R128MonitorType R128DisplayDDCConnected(xf86OutputPtr output) uint32_t mask1, mask2; if (r128_output->type == OUTPUT_LVDS) { +#ifdef WSDISPLAYIO_GET_EDID + if (info->HaveWSDisplay) { + struct wsdisplayio_edid_info ei; + char *buffer; + xf86MonPtr tmp; + + buffer = malloc(1024); + ei.edid_data = buffer; + ei.buffer_size = 1024; + if (ioctl(xf86Info.consoleFd, WSDISPLAYIO_GET_EDID, &ei) != -1) { + xf86Msg(X_INFO, "got %d bytes worth of EDID from wsdisplay\n", + ei.data_size); + tmp = xf86InterpretEEDID(pScrn->scrnIndex, buffer); + tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA; + *MonInfo = tmp; + xf86OutputSetEDID(output, tmp); + } else + free(buffer); + } +#endif return MT_LCD; } else if (r128_output->type == OUTPUT_VGA) { mask1 = R128_GPIO_MONID_MASK_1 | (pR128Ent->HasCRTC2 ? R128_GPIO_MONID_MASK_3 : R128_GPIO_MONID_MASK_2); |