summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2016-12-10 18:53:37 +0000
committerEmil Velikov <emil.l.velikov@gmail.com>2020-03-16 14:25:40 +0000
commit42a3148ae14c6fd0d2e2e9013971188ca721d8f8 (patch)
treec64a512c107ee7994e336b3cc595b97b029be259 /src
parenteeaaf370854b63966f0b5adbd00d2e6809b773c1 (diff)
Factor out common code to amdgpu_probe()
Keep the distinct pci/platform screen management in the separate probe entry point and fold the rest into a single function. v2: Rebase Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r--src/amdgpu_probe.c79
1 files changed, 9 insertions, 70 deletions
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 30e2d67..7ce9090 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -241,16 +241,14 @@ error_amdgpu:
return FALSE;
}
-static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
+static Bool
+amdgpu_probe(ScrnInfoPtr pScrn, int entity_num,
+ struct pci_device *pci_dev, struct xf86_platform_device *dev)
{
- ScrnInfoPtr pScrn = NULL;
EntityInfoPtr pEnt = NULL;
DevUnion *pPriv;
AMDGPUEntPtr pAMDGPUEnt;
- pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, NULL,
- NULL, NULL, NULL, NULL, NULL);
-
if (!pScrn)
return FALSE;
@@ -258,7 +256,6 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
pScrn->driverName = AMDGPU_DRIVER_NAME;
pScrn->name = AMDGPU_NAME;
pScrn->Probe = NULL;
-
pScrn->PreInit = AMDGPUPreInit_KMS;
pScrn->ScreenInit = AMDGPUScreenInit_KMS;
pScrn->SwitchMode = AMDGPUSwitchMode_KMS;
@@ -286,7 +283,7 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
goto error;
pAMDGPUEnt = pPriv->ptr;
- if (!amdgpu_device_setup(pScrn, pci_dev, NULL, pAMDGPUEnt))
+ if (!amdgpu_device_setup(pScrn, pci_dev, dev, pAMDGPUEnt))
goto error;
pAMDGPUEnt->fd_ref = 1;
@@ -321,7 +318,10 @@ static Bool
amdgpu_pci_probe(DriverPtr pDriver,
int entity_num, struct pci_device *device, intptr_t match_data)
{
- return amdgpu_get_scrninfo(entity_num, device);
+ ScrnInfoPtr pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+
+ return amdgpu_probe(pScrn, entity_num, device, NULL);
}
static Bool AMDGPUDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
@@ -350,9 +350,6 @@ amdgpu_platform_probe(DriverPtr pDriver,
{
ScrnInfoPtr pScrn;
int scr_flags = 0;
- EntityInfoPtr pEnt = NULL;
- DevUnion *pPriv;
- AMDGPUEntPtr pAMDGPUEnt;
if (!dev->pdev)
return FALSE;
@@ -365,65 +362,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
xf86SetEntityShared(entity_num);
xf86AddEntityToScreen(pScrn, entity_num);
- pScrn->driverVersion = AMDGPU_VERSION_CURRENT;
- pScrn->driverName = AMDGPU_DRIVER_NAME;
- pScrn->name = AMDGPU_NAME;
- pScrn->Probe = NULL;
- pScrn->PreInit = AMDGPUPreInit_KMS;
- pScrn->ScreenInit = AMDGPUScreenInit_KMS;
- pScrn->SwitchMode = AMDGPUSwitchMode_KMS;
- pScrn->AdjustFrame = AMDGPUAdjustFrame_KMS;
- pScrn->EnterVT = AMDGPUEnterVT_KMS;
- pScrn->LeaveVT = AMDGPULeaveVT_KMS;
- pScrn->FreeScreen = AMDGPUFreeScreen_KMS;
- pScrn->ValidMode = AMDGPUValidMode;
-
- pEnt = xf86GetEntityInfo(entity_num);
-
- /* Create a AMDGPUEntity for all chips, even with old single head
- * Radeon, need to use pAMDGPUEnt for new monitor detection routines.
- */
- xf86SetEntitySharable(entity_num);
-
- if (gAMDGPUEntityIndex == -1)
- gAMDGPUEntityIndex = xf86AllocateEntityPrivateIndex();
-
- pPriv = xf86GetEntityPrivate(pEnt->index, gAMDGPUEntityIndex);
-
- if (!pPriv->ptr) {
-
- pPriv->ptr = xnfcalloc(sizeof(AMDGPUEntRec), 1);
-
- pAMDGPUEnt = pPriv->ptr;
- if (!amdgpu_device_setup(pScrn, NULL, dev, pAMDGPUEnt))
- goto error;
-
- pAMDGPUEnt->fd_ref = 1;
-
- } else {
- pAMDGPUEnt = pPriv->ptr;
-
- if (pAMDGPUEnt->fd_ref == ARRAY_SIZE(pAMDGPUEnt->scrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Only up to %u Zaphod instances supported\n",
- (unsigned)ARRAY_SIZE(pAMDGPUEnt->scrn));
- goto error;
- }
-
- pAMDGPUEnt->fd_ref++;
- }
-
- xf86SetEntityInstanceForScreen(pScrn, pEnt->index,
- xf86GetNumEntityInstances(pEnt->
- index)
- - 1);
- free(pEnt);
-
- return TRUE;
-
-error:
- free(pEnt);
- return FALSE;
+ return amdgpu_probe(pScrn, entity_num, NULL, dev);
}
#endif