aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/drivers/modesetting/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/drivers/modesetting/driver.c')
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/driver.c677
1 files changed, 385 insertions, 292 deletions
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
index adfb69c9f..c62147a0f 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/driver.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
@@ -61,13 +61,18 @@
#include "driver.h"
+#ifdef GLAMOR
+#define GLAMOR_FOR_XORG 1
+#include "glamor.h"
+#endif
+
static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
static Bool CloseScreen(ScreenPtr pScreen);
static Bool EnterVT(ScrnInfoPtr pScrn);
static void Identify(int flags);
static const OptionInfoRec *AvailableOptions(int chipid, int busid);
-static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose,
- int flags);
+static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ Bool verbose, int flags);
static void FreeScreen(ScrnInfoPtr pScrn);
static void LeaveVT(ScrnInfoPtr pScrn);
static Bool SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
@@ -76,26 +81,25 @@ static Bool PreInit(ScrnInfoPtr pScrn, int flags);
static Bool Probe(DriverPtr drv, int flags);
static Bool ms_pci_probe(DriverPtr driver,
- int entity_num, struct pci_device *device,
- intptr_t match_data);
-static Bool ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op,
- void *data);
+ int entity_num, struct pci_device *device,
+ intptr_t match_data);
+static Bool ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data);
#ifdef XSERVER_LIBPCIACCESS
static const struct pci_id_match ms_device_match[] = {
{
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
- 0x00030000, 0x00ff0000, 0
- },
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+ 0x00030000, 0x00ff0000, 0},
- { 0, 0, 0 },
+ {0, 0, 0},
};
#endif
#ifdef XSERVER_PLATFORM_BUS
static Bool ms_platform_probe(DriverPtr driver,
- int entity_num, int flags, struct xf86_platform_device *device,
- intptr_t match_data);
+ int entity_num, int flags,
+ struct xf86_platform_device *device,
+ intptr_t match_data);
#endif
_X_EXPORT DriverRec modesetting = {
@@ -115,21 +119,22 @@ _X_EXPORT DriverRec modesetting = {
};
static SymTabRec Chipsets[] = {
- {0, "kms" },
+ {0, "kms"},
{-1, NULL}
};
-typedef enum
-{
+typedef enum {
OPTION_SW_CURSOR,
OPTION_DEVICE_PATH,
OPTION_SHADOW_FB,
+ OPTION_ACCEL_METHOD,
} modesettingOpts;
static const OptionInfoRec Options[] = {
{OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
- {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE },
- {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
+ {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE},
+ {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
@@ -155,25 +160,26 @@ static XF86ModuleVersionInfo VersRec = {
_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL };
static void *
-Setup(void * module, void * opts, int *errmaj, int *errmin)
+Setup(void *module, void *opts, int *errmaj, int *errmin)
{
static Bool setupDone = 0;
/* This module should be loaded only once, but check to be sure.
*/
if (!setupDone) {
- setupDone = 1;
- xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
- /*
- * The return value must be non-NULL on success even though there
- * is no TearDownProc.
- */
- return (void *) 1;
- } else {
- if (errmaj)
- *errmaj = LDR_ONCEONLY;
- return NULL;
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (void *) 1;
+ }
+ else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
}
}
@@ -181,28 +187,31 @@ static void
Identify(int flags)
{
xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
- Chipsets);
+ Chipsets);
}
-static int open_hw(const char *dev)
+static int
+open_hw(const char *dev)
{
int fd;
+
if (dev)
- fd = open(dev, O_RDWR, 0);
+ fd = open(dev, O_RDWR, 0);
else {
- dev = getenv("KMSDEVICE");
- if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
- dev = "/dev/dri/card0";
- fd = open(dev,O_RDWR, 0);
- }
+ dev = getenv("KMSDEVICE");
+ if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+ dev = "/dev/dri/card0";
+ fd = open(dev, O_RDWR, 0);
+ }
}
if (fd == -1)
- xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno));
+ xf86DrvMsg(-1, X_ERROR, "open %s: %s\n", dev, strerror(errno));
return fd;
}
-static int check_outputs(int fd)
+static int
+check_outputs(int fd)
{
drmModeResPtr res = drmModeGetResources(fd);
int ret;
@@ -214,7 +223,8 @@ static int check_outputs(int fd)
return ret;
}
-static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
+static Bool
+probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
{
int fd;
@@ -230,6 +240,7 @@ static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
fd = open_hw(dev);
if (fd != -1) {
int ret = check_outputs(fd);
+
close(fd);
return ret;
}
@@ -248,15 +259,15 @@ ms_DRICreatePCIBusID(const struct pci_device *dev)
return busID;
}
-
-static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
+static Bool
+probe_hw_pci(const char *dev, struct pci_device *pdev)
{
int ret = FALSE, fd = open_hw(dev);
char *id, *devid;
drmSetVersion sv;
if (fd == -1)
- return FALSE;
+ return FALSE;
sv.drm_di_major = 1;
sv.drm_di_minor = 4;
@@ -267,7 +278,6 @@ static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
return FALSE;
}
-
id = drmGetBusid(fd);
devid = ms_DRICreatePCIBusID(pdev);
@@ -279,6 +289,7 @@ static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
free(devid);
return ret;
}
+
static const OptionInfoRec *
AvailableOptions(int chipid, int busid)
{
@@ -289,55 +300,63 @@ static Bool
ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
{
xorgHWFlags *flag;
-
+
switch (op) {
- case GET_REQUIRED_HW_INTERFACES:
- flag = (CARD32 *)data;
- (*flag) = 0;
- return TRUE;
- case SUPPORTS_SERVER_FDS:
- return TRUE;
- default:
- return FALSE;
+ case GET_REQUIRED_HW_INTERFACES:
+ flag = (CARD32 *) data;
+ (*flag) = 0;
+ return TRUE;
+ case SUPPORTS_SERVER_FDS:
+ return TRUE;
+ default:
+ return FALSE;
}
}
+static void
+ms_setup_scrn_hooks(ScrnInfoPtr scrn)
+{
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modeset";
+
+ scrn->Probe = NULL;
+ scrn->PreInit = PreInit;
+ scrn->ScreenInit = ScreenInit;
+ scrn->SwitchMode = SwitchMode;
+ scrn->AdjustFrame = AdjustFrame;
+ scrn->EnterVT = EnterVT;
+ scrn->LeaveVT = LeaveVT;
+ scrn->FreeScreen = FreeScreen;
+ scrn->ValidMode = ValidMode;
+}
+
#if XSERVER_LIBPCIACCESS
static Bool
ms_pci_probe(DriverPtr driver,
- int entity_num, struct pci_device *dev, intptr_t match_data)
+ int entity_num, struct pci_device *dev, intptr_t match_data)
{
ScrnInfoPtr scrn = NULL;
scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL,
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL);
if (scrn) {
- const char *devpath;
- GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
- scrn->entityInstanceList[0]);
-
- devpath = xf86FindOptionValue(devSection->options, "kmsdev");
- if (probe_hw_pci(devpath, dev)) {
- scrn->driverVersion = 1;
- scrn->driverName = "modesetting";
- scrn->name = "modeset";
- scrn->Probe = NULL;
- scrn->PreInit = PreInit;
- scrn->ScreenInit = ScreenInit;
- scrn->SwitchMode = SwitchMode;
- scrn->AdjustFrame = AdjustFrame;
- scrn->EnterVT = EnterVT;
- scrn->LeaveVT = LeaveVT;
- scrn->FreeScreen = FreeScreen;
- scrn->ValidMode = ValidMode;
-
- xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
- "claimed PCI slot %d@%d:%d:%d\n",
- dev->bus, dev->domain, dev->dev, dev->func);
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "using %s\n", devpath ? devpath : "default device");
- } else
- scrn = NULL;
+ const char *devpath;
+ GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
+ scrn->entityInstanceList[0]);
+
+ devpath = xf86FindOptionValue(devSection->options, "kmsdev");
+ if (probe_hw_pci(devpath, dev)) {
+ ms_setup_scrn_hooks(scrn);
+
+ xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
+ "claimed PCI slot %d@%d:%d:%d\n",
+ dev->bus, dev->domain, dev->dev, dev->func);
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "using %s\n", devpath ? devpath : "default device");
+ }
+ else
+ scrn = NULL;
}
return scrn != NULL;
}
@@ -346,29 +365,22 @@ ms_pci_probe(DriverPtr driver,
#ifdef XSERVER_PLATFORM_BUS
static Bool
ms_platform_probe(DriverPtr driver,
- int entity_num, int flags, struct xf86_platform_device *dev, intptr_t match_data)
+ int entity_num, int flags, struct xf86_platform_device *dev,
+ intptr_t match_data)
{
ScrnInfoPtr scrn = NULL;
const char *path = xf86_platform_device_odev_attributes(dev)->path;
int scr_flags = 0;
if (flags & PLATFORM_PROBE_GPU_SCREEN)
- scr_flags = XF86_ALLOCATE_GPU_SCREEN;
+ scr_flags = XF86_ALLOCATE_GPU_SCREEN;
if (probe_hw(path, dev)) {
scrn = xf86AllocateScreen(driver, scr_flags);
xf86AddEntityToScreen(scrn, entity_num);
- scrn->driverName = "modesetting";
- scrn->name = "modesetting";
- scrn->PreInit = PreInit;
- scrn->ScreenInit = ScreenInit;
- scrn->SwitchMode = SwitchMode;
- scrn->AdjustFrame = AdjustFrame;
- scrn->EnterVT = EnterVT;
- scrn->LeaveVT = LeaveVT;
- scrn->FreeScreen = FreeScreen;
- scrn->ValidMode = ValidMode;
+ ms_setup_scrn_hooks(scrn);
+
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"using drv %s\n", path ? path : "default device");
}
@@ -388,44 +400,34 @@ Probe(DriverPtr drv, int flags)
/* For now, just bail out for PROBE_DETECT. */
if (flags & PROBE_DETECT)
- return FALSE;
+ return FALSE;
/*
* Find the config file Device sections that match this
* driver, and return if there are none.
*/
if ((numDevSections = xf86MatchDevice("modesetting", &devSections)) <= 0) {
- return FALSE;
+ return FALSE;
}
for (i = 0; i < numDevSections; i++) {
- dev = xf86FindOptionValue(devSections[i]->options,"kmsdev");
- if (probe_hw(dev, NULL)) {
- int entity;
- entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
- scrn = xf86ConfigFbEntity(scrn, 0, entity,
- NULL, NULL, NULL, NULL);
- }
-
- if (scrn) {
- foundScreen = TRUE;
- scrn->driverVersion = 1;
- scrn->driverName = "modesetting";
- scrn->name = "modesetting";
- scrn->Probe = Probe;
- scrn->PreInit = PreInit;
- scrn->ScreenInit = ScreenInit;
- scrn->SwitchMode = SwitchMode;
- scrn->AdjustFrame = AdjustFrame;
- scrn->EnterVT = EnterVT;
- scrn->LeaveVT = LeaveVT;
- scrn->FreeScreen = FreeScreen;
- scrn->ValidMode = ValidMode;
-
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "using %s\n", dev ? dev : "default device");
- }
+ dev = xf86FindOptionValue(devSections[i]->options, "kmsdev");
+ if (probe_hw(dev, NULL)) {
+ int entity;
+
+ entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
+ scrn = xf86ConfigFbEntity(scrn, 0, entity, NULL, NULL, NULL, NULL);
+ }
+
+ if (scrn) {
+ foundScreen = TRUE;
+ ms_setup_scrn_hooks(scrn);
+ scrn->Probe = Probe;
+
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "using %s\n", dev ? dev : "default device");
+ }
}
free(devSections);
@@ -437,51 +439,51 @@ static Bool
GetRec(ScrnInfoPtr pScrn)
{
if (pScrn->driverPrivate)
- return TRUE;
+ return TRUE;
pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1);
return TRUE;
}
-static int dispatch_dirty_region(ScrnInfoPtr scrn,
- PixmapPtr pixmap,
- DamagePtr damage,
- int fb_id)
+static int
+dispatch_dirty_region(ScrnInfoPtr scrn,
+ PixmapPtr pixmap, DamagePtr damage, int fb_id)
{
modesettingPtr ms = modesettingPTR(scrn);
RegionPtr dirty = DamageRegion(damage);
unsigned num_cliprects = REGION_NUM_RECTS(dirty);
if (num_cliprects) {
- drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
- BoxPtr rect = REGION_RECTS(dirty);
- int i, ret;
-
- if (!clip)
- return -ENOMEM;
-
- /* XXX no need for copy? */
- for (i = 0; i < num_cliprects; i++, rect++) {
- clip[i].x1 = rect->x1;
- clip[i].y1 = rect->y1;
- clip[i].x2 = rect->x2;
- clip[i].y2 = rect->y2;
- }
-
- /* TODO query connector property to see if this is needed */
- ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
- free(clip);
- DamageEmpty(damage);
- if (ret) {
- if (ret == -EINVAL)
- return ret;
- }
+ drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
+ BoxPtr rect = REGION_RECTS(dirty);
+ int i, ret;
+
+ if (!clip)
+ return -ENOMEM;
+
+ /* XXX no need for copy? */
+ for (i = 0; i < num_cliprects; i++, rect++) {
+ clip[i].x1 = rect->x1;
+ clip[i].y1 = rect->y1;
+ clip[i].x2 = rect->x2;
+ clip[i].y2 = rect->y2;
+ }
+
+ /* TODO query connector property to see if this is needed */
+ ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
+ free(clip);
+ DamageEmpty(damage);
+ if (ret) {
+ if (ret == -EINVAL)
+ return ret;
+ }
}
return 0;
}
-static void dispatch_dirty(ScreenPtr pScreen)
+static void
+dispatch_dirty(ScreenPtr pScreen)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
modesettingPtr ms = modesettingPTR(scrn);
@@ -491,16 +493,18 @@ static void dispatch_dirty(ScreenPtr pScreen)
ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
if (ret == -EINVAL || ret == -ENOSYS) {
- ms->dirty_enabled = FALSE;
- DamageUnregister(ms->damage);
- DamageDestroy(ms->damage);
- ms->damage = NULL;
- xf86DrvMsg(scrn->scrnIndex, X_INFO, "Disabling kernel dirty updates, not required.\n");
- return;
+ ms->dirty_enabled = FALSE;
+ DamageUnregister(ms->damage);
+ DamageDestroy(ms->damage);
+ ms->damage = NULL;
+ xf86DrvMsg(scrn->scrnIndex, X_INFO,
+ "Disabling kernel dirty updates, not required.\n");
+ return;
}
}
-static void dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
+static void
+dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
{
modesettingPtr ms = modesettingPTR(scrn);
PixmapPtr pixmap = crtc->randr_crtc->scanout_pixmap;
@@ -516,25 +520,27 @@ static void dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
}
}
-static void dispatch_slave_dirty(ScreenPtr pScreen)
+static void
+dispatch_slave_dirty(ScreenPtr pScreen)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c;
for (c = 0; c < xf86_config->num_crtc; c++) {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
- if (!crtc->randr_crtc)
- continue;
- if (!crtc->randr_crtc->scanout_pixmap)
- continue;
+ if (!crtc->randr_crtc)
+ continue;
+ if (!crtc->randr_crtc->scanout_pixmap)
+ continue;
- dispatch_dirty_crtc(scrn, crtc);
+ dispatch_dirty_crtc(scrn, crtc);
}
}
-static void msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
+static void
+msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
{
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
@@ -568,7 +574,7 @@ FreeRec(ScrnInfoPtr pScrn)
else
#ifdef XF86_PDEV_SERVER_FD
if (!(ms->pEnt->location.type == BUS_PLATFORM &&
- (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)))
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)))
#endif
ret = close(ms->fd);
(void) ret;
@@ -578,6 +584,43 @@ FreeRec(ScrnInfoPtr pScrn)
}
+static void
+try_enable_glamor(ScrnInfoPtr pScrn)
+{
+ modesettingPtr ms = modesettingPTR(pScrn);
+ const char *accel_method_str = xf86GetOptValString(ms->Options,
+ OPTION_ACCEL_METHOD);
+ Bool do_glamor = (!accel_method_str ||
+ strcmp(accel_method_str, "glamor") == 0);
+
+ ms->glamor = FALSE;
+
+#ifdef GLAMOR
+ if (!do_glamor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "glamor disabled\n");
+ return;
+ }
+
+ if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
+ if (glamor_egl_init(pScrn, ms->fd)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
+ ms->glamor = TRUE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "glamor initialization failed\n");
+ }
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to load glamor module.\n");
+ }
+#else
+ if (do_glamor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "No glamor support in the X Server\n");
+ }
+#endif
+}
+
#ifndef DRM_CAP_CURSOR_WIDTH
#define DRM_CAP_CURSOR_WIDTH 0x8
#endif
@@ -595,45 +638,46 @@ PreInit(ScrnInfoPtr pScrn, int flags)
EntPtr msEnt = NULL;
char *BusID = NULL;
const char *devicename;
- Bool prefer_shadow = TRUE;
uint64_t value = 0;
int ret;
int bppflags;
int defaultdepth, defaultbpp;
if (pScrn->numEntities != 1)
- return FALSE;
+ return FALSE;
pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
if (flags & PROBE_DETECT) {
- return FALSE;
+ return FALSE;
}
/* Allocate driverPrivate */
if (!GetRec(pScrn))
- return FALSE;
+ return FALSE;
ms = modesettingPTR(pScrn);
ms->SaveGeneration = -1;
ms->pEnt = pEnt;
- pScrn->displayWidth = 640; /* default it */
+ pScrn->displayWidth = 640; /* default it */
/* Allocate an entity private if necessary */
if (xf86IsEntityShared(pScrn->entityList[0])) {
- msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
- modesettingEntityIndex)->ptr;
- ms->entityPrivate = msEnt;
- } else
- ms->entityPrivate = NULL;
+ msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+ modesettingEntityIndex)->ptr;
+ ms->entityPrivate = msEnt;
+ }
+ else
+ ms->entityPrivate = NULL;
if (xf86IsEntityShared(pScrn->entityList[0])) {
- if (xf86IsPrimInitDone(pScrn->entityList[0])) {
- /* do something */
- } else {
- xf86SetPrimInitDone(pScrn->entityList[0]);
- }
+ if (xf86IsPrimInitDone(pScrn->entityList[0])) {
+ /* do something */
+ }
+ else {
+ xf86SetPrimInitDone(pScrn->entityList[0]);
+ }
}
pScrn->monitor = pScrn->confScreen->monitor;
@@ -644,15 +688,19 @@ PreInit(ScrnInfoPtr pScrn, int flags)
if (pEnt->location.type == BUS_PLATFORM) {
#ifdef XF86_PDEV_SERVER_FD
if (pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)
- ms->fd = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->fd;
+ ms->fd =
+ xf86_platform_device_odev_attributes(pEnt->location.id.plat)->
+ fd;
else
#endif
{
- char *path = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->path;
+ char *path =
+ xf86_platform_device_odev_attributes(pEnt->location.id.plat)->
+ path;
ms->fd = open_hw(path);
}
}
- else
+ else
#endif
if (pEnt->location.type == BUS_PCI) {
ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
@@ -670,12 +718,13 @@ PreInit(ScrnInfoPtr pScrn, int flags)
);
}
ms->fd = drmOpen(NULL, BusID);
- } else {
+ }
+ else {
devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev");
ms->fd = open_hw(devicename);
}
if (ms->fd < 0)
- return FALSE;
+ return FALSE;
ms->drmmode.fd = ms->fd;
@@ -689,81 +738,93 @@ PreInit(ScrnInfoPtr pScrn, int flags)
#endif
drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
if (defaultdepth == 24 && defaultbpp == 24)
- bppflags = SupportConvert32to24 | Support24bppFb;
+ bppflags = SupportConvert32to24 | Support24bppFb;
else
- bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
-
+ bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
+
if (!xf86SetDepthBpp
- (pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
- return FALSE;
+ (pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
+ return FALSE;
switch (pScrn->depth) {
case 15:
case 16:
case 24:
- break;
+ break;
default:
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Given depth (%d) is not supported by the driver\n",
- pScrn->depth);
- return FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by the driver\n",
+ pScrn->depth);
+ return FALSE;
}
xf86PrintDepthBpp(pScrn);
/* Process the options */
xf86CollectOptions(pScrn, NULL);
if (!(ms->Options = malloc(sizeof(Options))))
- return FALSE;
+ return FALSE;
memcpy(ms->Options, Options, sizeof(Options));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
- return FALSE;
+ return FALSE;
if (!xf86SetDefaultVisual(pScrn, -1))
- return FALSE;
+ return FALSE;
if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
- ms->drmmode.sw_cursor = TRUE;
- }
-
- ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
- if (!ret) {
- prefer_shadow = !!value;
+ ms->drmmode.sw_cursor = TRUE;
}
ms->cursor_width = 64;
ms->cursor_height = 64;
ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
if (!ret) {
- ms->cursor_width = value;
+ ms->cursor_width = value;
}
ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_HEIGHT, &value);
if (!ret) {
- ms->cursor_height = value;
+ ms->cursor_height = value;
}
- ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
+ try_enable_glamor(pScrn);
+
+ if (!ms->glamor) {
+ Bool prefer_shadow = TRUE;
+
+ ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
+ if (!ret) {
+ prefer_shadow = !!value;
+ }
+
+ ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options,
+ OPTION_SHADOW_FB,
+ prefer_shadow);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "ShadowFB: preferred %s, enabled %s\n",
+ prefer_shadow ? "YES" : "NO",
+ ms->drmmode.shadow_enable ? "YES" : "NO");
+ }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n", prefer_shadow ? "YES" : "NO", ms->drmmode.shadow_enable ? "YES" : "NO");
if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
- goto fail;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
+ goto fail;
}
/*
* If the driver can do gamma correction, it should call xf86SetGamma() here.
*/
{
- Gamma zeros = { 0.0, 0.0, 0.0 };
+ Gamma zeros = { 0.0, 0.0, 0.0 };
- if (!xf86SetGamma(pScrn, zeros)) {
- return FALSE;
- }
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
}
if (pScrn->modes == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
- return FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
+ return FALSE;
}
pScrn->currentMode = pScrn->modes;
@@ -773,23 +834,23 @@ PreInit(ScrnInfoPtr pScrn, int flags)
/* Load the required sub modules */
if (!xf86LoadSubModule(pScrn, "fb")) {
- return FALSE;
+ return FALSE;
}
if (ms->drmmode.shadow_enable) {
- if (!xf86LoadSubModule(pScrn, "shadow")) {
- return FALSE;
- }
+ if (!xf86LoadSubModule(pScrn, "shadow")) {
+ return FALSE;
+ }
}
return TRUE;
- fail:
+ fail:
return FALSE;
}
static void *
msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
- CARD32 *size, void *closure)
+ CARD32 *size, void *closure)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(pScrn);
@@ -798,7 +859,7 @@ msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
*size = stride;
- return ((uint8_t *)ms->drmmode.front_bo->ptr + row * stride + offset);
+ return ((uint8_t *) ms->drmmode.front_bo->ptr + row * stride + offset);
}
static void
@@ -815,12 +876,27 @@ CreateScreenResources(ScreenPtr pScreen)
PixmapPtr rootPixmap;
Bool ret;
void *pixels;
+
pScreen->CreateScreenResources = ms->createScreenResources;
ret = pScreen->CreateScreenResources(pScreen);
pScreen->CreateScreenResources = CreateScreenResources;
if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
- return FALSE;
+ return FALSE;
+
+#ifdef GLAMOR
+ if (ms->glamor) {
+ if (!glamor_egl_create_textured_screen_ext(pScreen,
+ ms->drmmode.front_bo->handle,
+ pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8,
+ NULL)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "glamor_egl_create_textured_screen_ext() failed\n");
+ return FALSE;
+ }
+ }
+#endif
drmmode_uevent_init(pScrn, &ms->drmmode);
@@ -828,33 +904,34 @@ CreateScreenResources(ScreenPtr pScreen)
drmmode_map_cursor_bos(pScrn, &ms->drmmode);
pixels = drmmode_map_front_bo(&ms->drmmode);
if (!pixels)
- return FALSE;
+ return FALSE;
rootPixmap = pScreen->GetScreenPixmap(pScreen);
if (ms->drmmode.shadow_enable)
- pixels = ms->drmmode.shadow_fb;
-
+ pixels = ms->drmmode.shadow_fb;
+
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
- FatalError("Couldn't adjust screen pixmap\n");
+ FatalError("Couldn't adjust screen pixmap\n");
if (ms->drmmode.shadow_enable) {
- if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked,
- msShadowWindow, 0, 0))
- return FALSE;
+ if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked,
+ msShadowWindow, 0, 0))
+ return FALSE;
}
ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
pScreen, rootPixmap);
if (ms->damage) {
- DamageRegister(&rootPixmap->drawable, ms->damage);
- ms->dirty_enabled = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to create screen damage record\n");
- return FALSE;
+ DamageRegister(&rootPixmap->drawable, ms->damage);
+ ms->dirty_enabled = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to create screen damage record\n");
+ return FALSE;
}
return ret;
}
@@ -863,7 +940,7 @@ static Bool
msShadowInit(ScreenPtr pScreen)
{
if (!shadowSetup(pScreen)) {
- return FALSE;
+ return FALSE;
}
return TRUE;
}
@@ -876,11 +953,11 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
modesettingPtr ms = modesettingPTR(scrn);
Bool ret;
int size = ppix->devKind * ppix->drawable.height;
- int ihandle = (int)(long)fd_handle;
+ int ihandle = (int) (long) fd_handle;
ret = drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, ppix->devKind, size);
if (ret == FALSE)
- return ret;
+ return ret;
return TRUE;
}
@@ -893,7 +970,7 @@ SetMaster(ScrnInfoPtr pScrn)
#ifdef XF86_PDEV_SERVER_FD
if (ms->pEnt->location.type == BUS_PLATFORM &&
- (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
return TRUE;
#endif
@@ -920,62 +997,77 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
/* HW dependent - FIXME */
pScrn->displayWidth = pScrn->virtualX;
if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
- return FALSE;
+ return FALSE;
if (ms->drmmode.shadow_enable) {
- ms->drmmode.shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY *
- ((pScrn->bitsPerPixel + 7) >> 3));
- if (!ms->drmmode.shadow_fb)
- ms->drmmode.shadow_enable = FALSE;
- }
-
+ ms->drmmode.shadow_fb =
+ calloc(1,
+ pScrn->displayWidth * pScrn->virtualY *
+ ((pScrn->bitsPerPixel + 7) >> 3));
+ if (!ms->drmmode.shadow_fb)
+ ms->drmmode.shadow_enable = FALSE;
+ }
+
miClearVisualTypes();
if (!miSetVisualTypes(pScrn->depth,
- miGetDefaultVisualMask(pScrn->depth),
- pScrn->rgbBits, pScrn->defaultVisual))
- return FALSE;
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
if (!miSetPixmapDepths())
- return FALSE;
+ return FALSE;
- if (!dixRegisterScreenSpecificPrivateKey(pScreen, &ms->drmmode.pixmapPrivateKeyRec,
- PRIVATE_PIXMAP, sizeof(msPixmapPrivRec))) {
- return FALSE;
+ if (!dixRegisterScreenSpecificPrivateKey
+ (pScreen, &ms->drmmode.pixmapPrivateKeyRec, PRIVATE_PIXMAP,
+ sizeof(msPixmapPrivRec))) {
+ return FALSE;
}
pScrn->memPhysBase = 0;
pScrn->fbOffset = 0;
if (!fbScreenInit(pScreen, NULL,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth, pScrn->bitsPerPixel))
- return FALSE;
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth, pScrn->bitsPerPixel))
+ return FALSE;
if (pScrn->bitsPerPixel > 8) {
- /* Fixup RGB ordering */
- visual = pScreen->visuals + pScreen->numVisuals;
- while (--visual >= pScreen->visuals) {
- if ((visual->class | DynamicClass) == DirectColor) {
- visual->offsetRed = pScrn->offset.red;
- visual->offsetGreen = pScrn->offset.green;
- visual->offsetBlue = pScrn->offset.blue;
- visual->redMask = pScrn->mask.red;
- visual->greenMask = pScrn->mask.green;
- visual->blueMask = pScrn->mask.blue;
- }
- }
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
}
fbPictureInit(pScreen, NULL, 0);
+#ifdef GLAMOR
+ if (ms->glamor) {
+ if (!glamor_init(pScreen,
+ GLAMOR_USE_EGL_SCREEN |
+ GLAMOR_USE_SCREEN |
+ GLAMOR_USE_PICTURE_SCREEN)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to initialize glamor at ScreenInit() time.\n");
+ return FALSE;
+ }
+ }
+#endif
+
if (ms->drmmode.shadow_enable && !msShadowInit(pScreen)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "shadow fb init failed\n");
- return FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "shadow fb init failed\n");
+ return FALSE;
}
-
+
ms->createScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = CreateScreenResources;
@@ -987,9 +1079,9 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
/* Need to extend HWcursor support to handle mask interleave */
if (!ms->drmmode.sw_cursor)
- xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
- HARDWARE_CURSOR_ARGB);
+ xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+ HARDWARE_CURSOR_ARGB);
/* Must force it before EnterVT, so we are in control of VT and
* later memory should be bound when allocating, e.g rotate_mem */
@@ -1005,15 +1097,15 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
pScreen->SetSharedPixmapBacking = msSetSharedPixmapBacking;
if (!xf86CrtcScreenInit(pScreen))
- return FALSE;
+ return FALSE;
if (!miCreateDefColormap(pScreen))
- return FALSE;
+ return FALSE;
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
if (serverGeneration == 1)
- xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
return EnterVT(pScrn);
}
@@ -1036,13 +1128,14 @@ static void
LeaveVT(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
+
xf86_hide_cursors(pScrn);
pScrn->vtSema = FALSE;
#ifdef XF86_PDEV_SERVER_FD
if (ms->pEnt->location.type == BUS_PLATFORM &&
- (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+ (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
return;
#endif
@@ -1062,7 +1155,7 @@ EnterVT(ScrnInfoPtr pScrn)
SetMaster(pScrn);
if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -1080,15 +1173,15 @@ CloseScreen(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
if (ms->damage) {
- DamageUnregister(ms->damage);
- DamageDestroy(ms->damage);
- ms->damage = NULL;
+ DamageUnregister(ms->damage);
+ DamageDestroy(ms->damage);
+ ms->damage = NULL;
}
if (ms->drmmode.shadow_enable) {
- shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
- free(ms->drmmode.shadow_fb);
- ms->drmmode.shadow_fb = NULL;
+ shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+ free(ms->drmmode.shadow_fb);
+ ms->drmmode.shadow_fb = NULL;
}
drmmode_uevent_fini(pScrn, &ms->drmmode);