xf86-video-intel: 2 commits - src/backlight.c src/backlight.h src/sna/sna_display.c src/sna/sna_driver.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Thu Feb 20 12:03:10 PST 2014


 src/backlight.c       |   38 ++++++++++++++++++++
 src/backlight.h       |    3 +
 src/sna/sna.h         |    3 +
 src/sna/sna_display.c |   93 ++++++++++++++++++--------------------------------
 src/sna/sna_driver.c  |   20 +++++-----
 5 files changed, 89 insertions(+), 68 deletions(-)

New commits:
commit 0b92b1285ce553c4f475c7fb8ac57ba418009682
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 20 19:18:46 2014 +0000

    backlight: Make search routine for device specific backlight common
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/backlight.c b/src/backlight.c
index 6b74a21..d5b10a0 100644
--- a/src/backlight.c
+++ b/src/backlight.c
@@ -43,6 +43,7 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <xf86.h>
+#include <pciaccess.h>
 
 #include "backlight.h"
 #include "fd.h"
@@ -452,3 +453,40 @@ void backlight_close(struct backlight *b)
 	if (b->pid)
 		waitpid(b->pid, NULL, 0);
 }
+
+char *backlight_find_for_device(struct pci_device *pci)
+{
+	char path[200];
+	unsigned best_type = INT_MAX;
+	char *best_iface = NULL;
+	DIR *dir;
+	struct dirent *de;
+
+	snprintf(path, sizeof(path),
+		 "/sys/bus/pci/devices/%04x:%02x:%02x.%d/backlight",
+		 pci->domain, pci->bus, pci->dev, pci->func);
+
+	dir = opendir(path);
+	if (dir == NULL)
+		return NULL;
+
+	while ((de = readdir(dir))) {
+		int v;
+
+		if (*de->d_name == '.')
+			continue;
+
+		v = backlight_exists(de->d_name);
+		if (v < best_type) {
+			char *copy = strdup(de->d_name);
+			if (copy) {
+				free(best_iface);
+				best_iface = copy;
+				best_type = v;
+			}
+		}
+	}
+	closedir(dir);
+
+	return best_iface;
+}
diff --git a/src/backlight.h b/src/backlight.h
index 6eeaff6..c251bd9 100644
--- a/src/backlight.h
+++ b/src/backlight.h
@@ -50,4 +50,7 @@ int backlight_get(struct backlight *backlight);
 void backlight_disable(struct backlight *backlight);
 void backlight_close(struct backlight *backlight);
 
+struct pci_device;
+char *backlight_find_for_device(struct pci_device *pci);
+
 #endif /* BACKLIGHT_H */
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 0902f80..496a300 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -35,7 +35,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <dirent.h>
 #include <errno.h>
 #include <poll.h>
 #include <ctype.h>
@@ -349,57 +348,11 @@ has_user_backlight_override(xf86OutputPtr output)
 	return strdup(str);
 }
 
-static char *
-has_device_backlight(xf86OutputPtr output)
-{
-	struct sna *sna = to_sna(output->scrn);
-	struct pci_device *pci;
-	char path[1024];
-	unsigned best_type = INT_MAX;
-	char *best_iface = NULL;
-	DIR *dir;
-	struct dirent *de;
-
-	pci = xf86GetPciInfoForEntity(sna->pEnt->index);
-	if (pci == NULL)
-		return NULL;
-
-	snprintf(path, sizeof(path),
-		 "/sys/bus/pci/devices/%04x:%02x:%02x.%d/backlight",
-		 pci->domain, pci->bus, pci->dev, pci->func);
-
-	DBG(("%s: scanning %s\n", __FUNCTION__, path));
-	dir = opendir(path);
-	if (dir == NULL)
-		return NULL;
-
-	while ((de = readdir(dir))) {
-		int v;
-
-		if (*de->d_name == '.')
-			continue;
-
-		v = backlight_exists(de->d_name);
-		DBG(("%s: %s: exists=%d\n", __FUNCTION__, de->d_name, v));
-
-		if (v < best_type) {
-			char *copy = strdup(de->d_name);
-			if (copy) {
-				free(best_iface);
-				best_iface = copy;
-				best_type = v;
-			}
-		}
-	}
-	closedir(dir);
-
-	return best_iface;
-}
-
 static void
 sna_output_backlight_init(xf86OutputPtr output)
 {
 	struct sna_output *sna_output = output->driver_private;
+	struct pci_device *pci;
 	MessageType from;
 	char *best_iface;
 
@@ -410,11 +363,9 @@ sna_output_backlight_init(xf86OutputPtr output)
 
 	/* XXX detect right backlight for multi-GPU/panels */
 	from = X_PROBED;
-	best_iface = has_device_backlight(output);
-	if (best_iface)
-		goto done;
-
-	best_iface = NULL;
+	pci = xf86GetPciInfoForEntity(to_sna(output->scrn)->pEnt->index);
+	if (pci != NULL)
+		best_iface = backlight_find_for_device(pci);
 
 done:
 	DBG(("%s(%s) opening backlight %s\n", __FUNCTION__,
commit caaf52834015c084704cf638f453b1fc3316eaa9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 20 07:51:40 2014 +0000

    sna: Query cursor size from the kernel
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 7dc5067..1b0a4e5 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -279,6 +279,9 @@ struct sna {
 		int shadow_flip;
 		int front_active;
 
+		unsigned short cursor_width;
+		unsigned short cursor_height;
+
 		unsigned num_real_crtc;
 		unsigned num_real_output;
 		unsigned num_fake;
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index e769546..0902f80 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1680,7 +1680,7 @@ sna_crtc_hide_cursor(xf86CrtcPtr crtc)
 	VG_CLEAR(arg);
 	arg.flags = DRM_MODE_CURSOR_BO;
 	arg.crtc_id = sna_crtc->id;
-	arg.width = arg.height = 64;
+	arg.width = arg.height = 0;
 	arg.handle = 0;
 
 	(void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg);
@@ -1690,6 +1690,7 @@ static void
 sna_crtc_show_cursor(xf86CrtcPtr crtc)
 {
 	struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
+	struct sna *sna = to_sna(crtc->scrn);
 	struct drm_mode_cursor arg;
 
 	__DBG(("%s: CRTC:%d\n", __FUNCTION__, sna_crtc->id));
@@ -1697,10 +1698,11 @@ sna_crtc_show_cursor(xf86CrtcPtr crtc)
 	VG_CLEAR(arg);
 	arg.flags = DRM_MODE_CURSOR_BO;
 	arg.crtc_id = sna_crtc->id;
-	arg.width = arg.height = 64;
+	arg.width = sna->mode.cursor_width;
+	arg.height = sna->mode.cursor_height;
 	arg.handle = sna_crtc->cursor;
 
-	(void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg);
+	(void)drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg);
 }
 
 static void
@@ -1731,6 +1733,7 @@ sna_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
 static void
 sna_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 {
+	struct sna *sna = to_sna(crtc->scrn);
 	struct drm_i915_gem_pwrite pwrite;
 
 	__DBG(("%s: CRTC:%d\n", __FUNCTION__, to_sna_crtc(crtc)->id));
@@ -1738,9 +1741,9 @@ sna_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 	VG_CLEAR(pwrite);
 	pwrite.handle = to_sna_crtc(crtc)->cursor;
 	pwrite.offset = 0;
-	pwrite.size = 64*64*4;
+	pwrite.size = sna->mode.cursor_width*sna->mode.cursor_height*4;
 	pwrite.data_ptr = (uintptr_t)image;
-	(void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
+	(void)drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
 }
 
 static void
@@ -1902,7 +1905,8 @@ sna_crtc_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
 		return false;
 	}
 
-	sna_crtc->cursor = gem_create(sna->kgem.fd, 64*64*4);
+	sna_crtc->cursor = gem_create(sna->kgem.fd,
+				      sna->mode.cursor_width*sna->mode.cursor_height*4);
 	if (!sna_crtc->cursor) {
 		xf86CrtcDestroy(crtc);
 		free(sna_crtc);
@@ -3517,6 +3521,24 @@ sna_crtc_config_notify(ScreenPtr screen)
 	sna_mode_update(to_sna_from_screen(screen));
 }
 
+static void
+sna_cursor_pre_init(struct sna *sna)
+{
+	uint64_t value;
+
+#define DRM_CAP_CURSOR_WIDTH 8
+#define DRM_CAP_CURSOR_HEIGHT 9
+
+	sna->mode.cursor_width = SNA_CURSOR_X;
+	sna->mode.cursor_height = SNA_CURSOR_Y;
+
+	if (drmGetCap(sna->kgem.fd, DRM_CAP_CURSOR_WIDTH, &value) == 0)
+		sna->mode.cursor_width = value;
+
+	if (drmGetCap(sna->kgem.fd, DRM_CAP_CURSOR_HEIGHT, &value) == 0)
+		sna->mode.cursor_height = value;
+}
+
 #if HAS_PIXMAP_SHARING
 #define sna_setup_provider(scrn) xf86ProviderSetup(scrn, NULL, "Intel")
 #else
@@ -3529,6 +3551,8 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna)
 	int num_fake = 0;
 	int i;
 
+	sna_cursor_pre_init(sna);
+
 	if (sna->flags & SNA_IS_HOSTED) {
 		sna_setup_provider(scrn);
 		return true;
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 4ecef3c..01d34f8 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -1000,15 +1000,17 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL)
 		return FALSE;
 
 	if ((sna->flags & SNA_IS_HOSTED) == 0 &&
-	    xf86_cursors_init(screen, SNA_CURSOR_X, SNA_CURSOR_Y,
-			       HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
-			       HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
-			       HARDWARE_CURSOR_INVERT_MASK |
-			       HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
-			       HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
-			       HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
-			       HARDWARE_CURSOR_UPDATE_UNHIDDEN |
-			       HARDWARE_CURSOR_ARGB))
+	    xf86_cursors_init(screen,
+			      sna->mode.cursor_width,
+			      sna->mode.cursor_height,
+			      HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+			      HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+			      HARDWARE_CURSOR_INVERT_MASK |
+			      HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+			      HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+			      HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+			      HARDWARE_CURSOR_UPDATE_UNHIDDEN |
+			      HARDWARE_CURSOR_ARGB))
 		xf86DrvMsg(scrn->scrnIndex, X_INFO, "HW Cursor enabled\n");
 
 	/* Must force it before EnterVT, so we are in control of VT and


More information about the xorg-commit mailing list