[PATCH v2 xserver 02/11] modesetting: add is_primary to mark entity type
Qiang Yu
Qiang.Yu at amd.com
Sat Jan 7 08:01:23 UTC 2017
Screen is primary, GPUScreen is not primary.
Signed-off-by: Qiang Yu <Qiang.Yu at amd.com>
---
hw/xfree86/drivers/modesetting/driver.c | 32 ++++++++++++++++++++++++++++----
hw/xfree86/drivers/modesetting/driver.h | 1 +
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index ebaeba9..c16bc0b 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -414,6 +414,7 @@ ms_platform_probe(DriverPtr driver,
if (probe_hw(path, dev)) {
static ScrnInfoPtr scrn_all = NULL;
+ modesettingEntPtr ms_ent;
if (getenv("MS_ALL_IN_ONE")) {
if (!scrn_all) {
@@ -437,6 +438,9 @@ ms_platform_probe(DriverPtr driver,
scrn_all ? "enabled" : "disabled");
ms_setup_entity(scrn, entity_num);
+
+ ms_ent = xf86GetEntityPrivate(entity_num, ms_entity_index)->ptr;
+ ms_ent->is_primary = !(flags & PLATFORM_PROBE_GPU_SCREEN);
}
return scrn != NULL;
@@ -899,11 +903,31 @@ PreInit(ScrnInfoPtr pScrn, int flags)
int ret;
int bppflags, connector_count;
int defaultdepth, defaultbpp;
+ int primary_entity = -1;
if (pScrn->numEntities <= 0)
return FALSE;
+ else if (pScrn->numEntities > 1) {
+ int i;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ modesettingEntPtr ms_ent = xf86GetEntityPrivate(
+ pScrn->entityList[i], ms_entity_index)->ptr;
+ if (ms_ent->is_primary) {
+ primary_entity = pScrn->entityList[i];
+ break;
+ }
+ }
+
+ if (primary_entity == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "all in one: no primary entity\n");
+ return FALSE;
+ }
+ }
+ else
+ primary_entity = pScrn->entityList[0];
- pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ pEnt = xf86GetEntityInfo(primary_entity);
if (flags & PROBE_DETECT) {
return FALSE;
@@ -919,11 +943,11 @@ PreInit(ScrnInfoPtr pScrn, int flags)
ms->drmmode.is_secondary = FALSE;
pScrn->displayWidth = 640; /* default it */
- if (xf86IsEntityShared(pScrn->entityList[0])) {
- if (xf86IsPrimInitDone(pScrn->entityList[0]))
+ if (xf86IsEntityShared(primary_entity)) {
+ if (xf86IsPrimInitDone(primary_entity))
ms->drmmode.is_secondary = TRUE;
else
- xf86SetPrimInitDone(pScrn->entityList[0]);
+ xf86SetPrimInitDone(primary_entity);
}
pScrn->monitor = pScrn->confScreen->monitor;
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index eee96e5..37d6c6a 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -62,6 +62,7 @@ typedef struct
unsigned long fd_wakeup_registered; /* server generation for which fd has been registered for wakeup handling */
int fd_wakeup_ref;
unsigned int assigned_crtcs;
+ Bool is_primary;
} modesettingEntRec, *modesettingEntPtr;
typedef void (*ms_drm_handler_proc)(uint64_t frame,
--
2.7.4
More information about the xorg-devel
mailing list