Module Name:    xsrc
Committed By:   macallan
Date:           Wed Jul 29 18:15:38 UTC 2015

Modified Files:
        xsrc/external/mit/xf86-video-r128/dist/src: r128.h r128_driver.c
            r128_output.c

Log Message:
- make sure the wsdisplay we talk to is actually the one handling the chip
  we're about to use
- make sure we habe backlight control via wsdisplay before attempting to use it
- use wsdisplay backlight control for blanking if available


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 xsrc/external/mit/xf86-video-r128/dist/src/r128.h
cvs rdiff -u -r1.14 -r1.15 \
    xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c
cvs rdiff -u -r1.2 -r1.3 \
    xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-r128/dist/src/r128.h
diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.6 xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.7
--- xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.6	Mon Jul 20 00:55:42 2015
+++ xsrc/external/mit/xf86-video-r128/dist/src/r128.h	Wed Jul 29 18:15:38 2015
@@ -311,6 +311,10 @@ typedef struct {
     Bool              FBDev;
 #endif
 
+#ifdef __NetBSD__
+    Bool	      HaveWSDisplay;
+    Bool	      HaveBacklightControl;
+#endif
     unsigned long     LinearAddr;   /* Frame buffer physical address         */
     unsigned long     MMIOAddr;     /* MMIO region physical address          */
     unsigned long     BIOSAddr;     /* BIOS physical address                 */

Index: xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c
diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.14 xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.15
--- xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.14	Wed Jul 29 01:51:18 2015
+++ xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c	Wed Jul 29 18:15:38 2015
@@ -596,7 +596,8 @@ void R128GetPanelInfoFromBIOS(xf86Output
     return;
 fallback:
 #ifdef __NetBSD__
-    if (!r128_output->PanelXRes || !r128_output->PanelYRes) {
+    if ((!r128_output->PanelXRes || !r128_output->PanelYRes)  &&
+        (info->HaveWSDisplay)) {
 	/*
 	 * we may not be on x86 so check wsdisplay for panel dimensions
 	 * XXX this assumes that the r128 is the console, although that should
@@ -1313,6 +1314,9 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int 
 {
     R128InfoPtr      info;
     xf86Int10InfoPtr pInt10 = NULL;
+#ifdef __NetBSD__
+    struct wsdisplayio_bus_id bid;
+#endif
 
     R128TRACE(("R128PreInit\n"));
 
@@ -1340,6 +1344,29 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int 
 	       PCI_DEV_DEV(info->PciInfo),
 	       PCI_DEV_FUNC(info->PciInfo));
 
+#ifdef __NetBSD__
+    /* now check if this is the console */
+    info->HaveWSDisplay = FALSE;
+    info->HaveBacklightControl = FALSE;
+    if (ioctl(xf86Info.screenFd, WSDISPLAYIO_GET_BUSID, &bid) != -1) {
+    	if ((bid.bus_type == WSDISPLAYIO_BUS_PCI) &&
+    	    (bid.ubus.pci.bus == PCI_DEV_BUS(info->PciInfo)) &&
+    	    (bid.ubus.pci.device == PCI_DEV_DEV(info->PciInfo)) &&
+    	    (bid.ubus.pci.function == PCI_DEV_FUNC(info->PciInfo))) {
+    	    	struct wsdisplay_param p;
+    	    	xf86Msg(X_INFO, "Alright, this is the console\n");
+    	    	info->HaveWSDisplay = TRUE;
+
+    	    	/* now see if we have hacklight control */
+    	    	p.param = WSDISPLAYIO_PARAM_BACKLIGHT;
+		if (ioctl(xf86Info.screenFd, WSDISPLAYIO_GETPARAM, &p) != -1) {
+		    xf86Msg(X_INFO, "... and we have backlight control\n");
+		    info->HaveBacklightControl = TRUE; 	 
+		}   	
+    	}
+    }
+#endif
+
 #ifndef XSERVER_LIBPCIACCESS
     info->PciTag        = pciTag(PCI_DEV_BUS(info->PciInfo),
 				PCI_DEV_DEV(info->PciInfo),

Index: xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c
diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.2 xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.3
--- xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.2	Wed Jul 29 01:51:18 2015
+++ xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c	Wed Jul 29 18:15:38 2015
@@ -189,9 +189,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 __NetBSD__
+	if (info->HaveBacklightControl) {
+	    struct wsdisplay_param p;
+
+	    p.param = WSDISPLAYIO_PARAM_BACKLIGHT;
+	    p.curval = 1;
+	    ioctl(xf86Info.screenFd, 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:
@@ -218,7 +229,18 @@ void R128DPMSSetOff(xf86OutputPtr output
 
     switch(MonType) {
     case MT_LCD:
-        OUTREGP(R128_LVDS_GEN_CNTL, 0, ~(R128_LVDS_BLON | R128_LVDS_ON));
+#ifdef __NetBSD__
+	if (info->HaveBacklightControl) {
+	    struct wsdisplay_param p;
+
+	    p.param = WSDISPLAYIO_PARAM_BACKLIGHT;
+	    p.curval = 0;
+	    ioctl(xf86Info.screenFd, 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:
@@ -247,22 +269,24 @@ static R128MonitorType R128DisplayDDCCon
 
     if (r128_output->type == OUTPUT_LVDS) {
 #ifdef __NetBSD__
-	struct wsdisplayio_edid_info ei;
-	char *buffer;
-	xf86MonPtr tmp;
-
-	buffer = malloc(1024);
-	ei.edid_data = buffer;
-	ei.buffer_size = 1024;
-	if (ioctl(xf86Info.screenFd, WSDISPLAYIO_GET_EDID, &ei) != -1) {
-	    xf86Msg(X_ERROR, "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);
+	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.screenFd, 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) {

Reply via email to