diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-09 11:34:39 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-09 11:46:24 +0100 |
commit | b6b5c3f009585151eb772dfc2526843c7cee82b3 (patch) | |
tree | 63ab8d9eb0a2eb4864db92bc5250d3909fe76238 | |
parent | ab445c23079a76eaa2a7d499ec4755599012bd2f (diff) |
intel: Disable incompatible features whilst hosted
Start adding the infrastructure to disable direct hardware access if X
is being run under a system compositor (aka "hosted").
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/intel_device.c | 13 | ||||
-rw-r--r-- | src/intel_driver.h | 2 | ||||
-rw-r--r-- | src/intel_module.c | 9 | ||||
-rw-r--r-- | src/sna/sna.h | 1 | ||||
-rw-r--r-- | src/sna/sna_display.c | 18 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 12 | ||||
-rw-r--r-- | src/sna/sna_video_overlay.c | 3 | ||||
-rw-r--r-- | src/sna/sna_video_sprite.c | 3 |
8 files changed, 52 insertions, 9 deletions
diff --git a/src/intel_device.c b/src/intel_device.c index c5f0a38d..d9ff8bcc 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -92,7 +92,7 @@ static int __intel_check_device(int fd) if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) ret = FALSE; } - if (ret) { + if (ret && !hosted()) { struct drm_mode_card_res res; memset(&res, 0, sizeof(res)); @@ -199,6 +199,12 @@ int intel_open_device(int entity_num, dev->open_count = 0; dev->master_count = 0; + /* If hosted under a system compositor, just pretend to be master */ + if (hosted()) { + dev->open_count++; + dev->master_count++; + } + xf86GetEntityPrivate(entity_num, intel_device_key)->ptr = dev; return fd; @@ -222,6 +228,8 @@ int intel_get_device(ScrnInfoPtr scrn) drmSetVersion sv; int retry = 2000; + assert(!hosted()); + /* Check that what we opened was a master or a * master-capable FD, by setting the version of the * interface we'll use to talk to it. @@ -267,6 +275,7 @@ int intel_get_master(ScrnInfoPtr scrn) if (dev->master_count++ == 0) { int retry = 2000; + assert(!hosted()); do { ret = drmSetMaster(dev->fd); if (ret == 0) @@ -288,6 +297,7 @@ int intel_put_master(ScrnInfoPtr scrn) ret = 0; assert(dev->master_count); if (--dev->master_count == 0) { + assert(!hosted()); assert(drmSetMaster(dev->fd) == 0); ret = drmDropMaster(dev->fd); } @@ -317,6 +327,7 @@ void intel_put_device(ScrnInfoPtr scrn) if (--dev->open_count) return; + assert(!hosted()); intel_set_device(scrn, NULL); drmClose(dev->fd); diff --git a/src/intel_driver.h b/src/intel_driver.h index 1e67eab0..47685364 100644 --- a/src/intel_driver.h +++ b/src/intel_driver.h @@ -129,4 +129,6 @@ void intel_put_device(ScrnInfoPtr scrn); void __intel_uxa_release_device(ScrnInfoPtr scrn); +#define hosted() (0) + #endif /* INTEL_DRIVER_H */ diff --git a/src/intel_module.c b/src/intel_module.c index 47e494c3..42fa8d8b 100644 --- a/src/intel_module.c +++ b/src/intel_module.c @@ -382,6 +382,9 @@ static Bool intel_driver_func(ScrnInfoPtr pScrn, #else (*flag) = HW_IO | HW_MMIO; #endif + if (hosted()) + (*flag) = HW_SKIP_CONSOLE; + return TRUE; default: /* Unknown or deprecated function */ @@ -410,6 +413,9 @@ static enum accel_method { UXA, SNA } get_accel_method(void) enum accel_method accel_method = DEFAULT_ACCEL_METHOD; XF86ConfDevicePtr dev; + if (hosted()) + return SNA; + dev = _xf86findDriver("intel", xf86configptr->conf_device_lst); if (dev && dev->dev_option_lst) { const char *s; @@ -493,7 +499,8 @@ static Bool intel_pci_probe(DriverPtr driver, case PCI_CHIP_I810_DC100: case PCI_CHIP_I810_E: case PCI_CHIP_I815: - break; + if (!hosted()) + break; default: return FALSE; } diff --git a/src/sna/sna.h b/src/sna/sna.h index caf671f3..73870888 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -229,6 +229,7 @@ struct sna { #define SNA_TEAR_FREE 0x10 #define SNA_FORCE_SHADOW 0x20 #define SNA_FLUSH_GTT 0x40 +#define SNA_IS_HOSTED 0x80 #define SNA_REPROBE 0x80000000 unsigned cpu_features; diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 5dcf47fa..f86d93d5 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3151,11 +3151,22 @@ sna_crtc_config_notify(ScreenPtr screen) sna_mode_update(to_sna_from_screen(screen)); } +#if HAS_PIXMAP_SHARING +#define sna_setup_provider(scrn) xf86ProviderSetup(scrn, NULL, "Intel") +#else +#define sna_setup_provider(scrn) +#endif + bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna) { struct sna_mode *mode = &sna->mode; int i; + if (sna->flags & SNA_IS_HOSTED) { + sna_setup_provider(scrn); + return true; + } + mode->kmode = drmModeGetResources(sna->kgem.fd); if (mode->kmode) { xf86CrtcConfigInit(scrn, &sna_mode_funcs); @@ -3172,9 +3183,7 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna) if (!xf86IsEntityShared(scrn->entityList[0])) sna_mode_compute_possible_clones(scrn); -#if HAS_PIXMAP_SHARING - xf86ProviderSetup(scrn, NULL, "Intel"); -#endif + sna_setup_provider(scrn); } else { if (!sna_mode_fake_init(sna)) return false; @@ -3200,6 +3209,9 @@ sna_mode_close(struct sna *sna) while (sna_mode_has_pending_events(sna)) sna_mode_wakeup(sna); + if (sna->flags & SNA_IS_HOSTED) + return; + for (i = 0; i < xf86_config->num_crtc; i++) sna_crtc_disable_shadow(sna, to_sna_crtc(xf86_config->crtc[i])); } diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index fc8773bc..7f2c0acc 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -287,7 +287,7 @@ static bool has_pageflipping(struct sna *sna) drm_i915_getparam_t gp; int v; - if (sna->flags & SNA_NO_WAIT) + if (sna->flags & (SNA_IS_HOSTED | SNA_NO_WAIT)) return false; v = 0; @@ -413,6 +413,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) sna = to_sna(scrn); sna->scrn = scrn; sna->pEnt = pEnt; + sna->flags = 0; scrn->displayWidth = 640; /* default it */ @@ -425,7 +426,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) fd = intel_get_device(scrn); if (fd == -1) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, - "Failed to become DRM master.\n"); + "Failed to claim DRM device.\n"); goto cleanup; } @@ -484,7 +485,6 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) if (xf86ReturnOptValBool(sna->Options, OPTION_TILING_FB, FALSE)) sna->tiling &= ~SNA_TILING_FB; - sna->flags = 0; if (!xf86ReturnOptValBool(sna->Options, OPTION_SWAPBUFFERS_WAIT, TRUE)) sna->flags |= SNA_NO_WAIT; if (xf86ReturnOptValBool(sna->Options, OPTION_TRIPLE_BUFFER, TRUE)) @@ -629,6 +629,9 @@ sna_uevent_init(ScrnInfoPtr scrn) Bool hotplug; MessageType from = X_CONFIG; + if (sna->flags & SNA_IS_HOSTED) + return; + DBG(("%s\n", __FUNCTION__)); /* RandR will be disabled if Xinerama is active, and so generating @@ -895,7 +898,8 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL) if (!miDCInitialize(screen, xf86GetPointerScreenFuncs())) return FALSE; - if (xf86_cursors_init(screen, SNA_CURSOR_X, SNA_CURSOR_Y, + 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 | diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index a0b4db9b..a68a173b 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -683,6 +683,9 @@ void sna_video_overlay_setup(struct sna *sna, ScreenPtr screen) struct sna_video *video; XvPortPtr port; + if (sna->flags & SNA_IS_HOSTED) + return; + if (!sna_has_overlay(sna)) return; diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 07e59bd4..a8d50ab2 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -456,6 +456,9 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) struct sna_video *video; XvPortPtr port; + if (sna->flags & SNA_IS_HOSTED) + return; + memset(&r, 0, sizeof(struct drm_mode_get_plane_res)); if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETPLANERESOURCES, &r)) return; |