summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-06-14 11:58:01 +0200
committerAdam Jackson <ajax@redhat.com>2016-07-06 13:21:19 -0400
commit713a21cc702561931ed5e84c3a5c3d7e7c580725 (patch)
tree28c421f6911496c7ee6e6f410e4d4cbc0c35f9a4 /hw
parenta9f970fe28d76bd2c57b44aa02ac38eb8aab8acf (diff)
modesetting: Load on GPU-s with 0 outputs
In newer laptops with switchable graphics, the GPU may have 0 outputs, in this case the modesetting driver should still load if the GPU is SourceOffload capable, so that it can be used as an offload source provider. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (cherry picked from commit 60ad701a6a8cb9f1eacb72acfe2cb8d3b7a865dc)
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c29
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c6
2 files changed, 24 insertions, 11 deletions
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index e7f6e8dac..b05ad810c 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -214,14 +214,26 @@ open_hw(const char *dev)
}
static int
-check_outputs(int fd)
+check_outputs(int fd, int *count)
{
drmModeResPtr res = drmModeGetResources(fd);
int ret;
if (!res)
return FALSE;
+
+ if (count)
+ *count = res->count_connectors;
+
ret = res->count_connectors > 0;
+#if defined DRM_CAP_PRIME && GLAMOR_HAS_GBM_LINEAR
+ if (ret == FALSE) {
+ uint64_t value = 0;
+ if (drmGetCap(fd, DRM_CAP_PRIME, &value) == 0 &&
+ (value & DRM_PRIME_CAP_EXPORT))
+ ret = TRUE;
+ }
+#endif
drmModeFreeResources(res);
return ret;
}
@@ -236,13 +248,13 @@ probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
fd = xf86_platform_device_odev_attributes(platform_dev)->fd;
if (fd == -1)
return FALSE;
- return check_outputs(fd);
+ return check_outputs(fd, NULL);
}
#endif
fd = open_hw(dev);
if (fd != -1) {
- int ret = check_outputs(fd);
+ int ret = check_outputs(fd, NULL);
close(fd);
return ret;
@@ -285,7 +297,7 @@ probe_hw_pci(const char *dev, struct pci_device *pdev)
devid = ms_DRICreatePCIBusID(pdev);
if (id && devid && !strcmp(id, devid))
- ret = check_outputs(fd);
+ ret = check_outputs(fd, NULL);
close(fd);
free(id);
@@ -772,7 +784,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
EntityInfoPtr pEnt;
uint64_t value = 0;
int ret;
- int bppflags;
+ int bppflags, connector_count;
int defaultdepth, defaultbpp;
if (pScrn->numEntities != 1)
@@ -809,6 +821,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
ms->drmmode.fd = ms->fd;
+ if (!check_outputs(ms->fd, &connector_count))
+ return FALSE;
+
drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
if (defaultdepth == 24 && defaultbpp == 24)
bppflags = SupportConvert32to24 | Support24bppFb;
@@ -888,7 +903,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
#ifdef DRM_CAP_PRIME
ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value);
if (ret == 0) {
- if (value & DRM_PRIME_CAP_IMPORT) {
+ if (connector_count && (value & DRM_PRIME_CAP_IMPORT)) {
pScrn->capabilities |= RR_Capability_SinkOutput;
if (ms->drmmode.glamor)
pScrn->capabilities |= RR_Capability_SinkOffload;
@@ -916,7 +931,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
}
}
- if (pScrn->modes == NULL) {
+ if (!(pScrn->is_gpu && connector_count == 0) && pScrn->modes == NULL) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
return FALSE;
}
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index bc2ca3d01..35a372cdc 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1639,10 +1639,8 @@ static Bool
drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
{
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- drmmode_crtc_private_ptr
- drmmode_crtc = xf86_config->crtc[0]->driver_private;
- drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ modesettingPtr ms = modesettingPTR(scrn);
+ drmmode_ptr drmmode = &ms->drmmode;
drmmode_bo old_front;
Bool ret;
ScreenPtr screen = xf86ScrnToScreen(scrn);