2006-11-26 13:00:15 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
|
|
|
|
* VA Linux Systems Inc., Fremont, California.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation on the rights to use, copy, modify, merge,
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
|
|
* subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
|
|
|
|
* THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
2012-03-04 09:01:12 -07:00
|
|
|
#include <stdlib.h>
|
2006-11-26 13:00:15 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Kevin E. Martin <martin@xfree86.org>
|
|
|
|
* Rickard E. Faith <faith@valinux.com>
|
2012-03-04 09:01:12 -07:00
|
|
|
* KMS support - Dave Airlie <airlied@redhat.com>
|
2006-11-26 13:00:15 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "radeon_probe.h"
|
|
|
|
#include "radeon_version.h"
|
|
|
|
#include "atipciids.h"
|
2008-07-12 09:18:32 -06:00
|
|
|
#include "atipcirename.h"
|
2006-11-26 13:00:15 -07:00
|
|
|
|
|
|
|
#include "xf86.h"
|
|
|
|
|
2012-03-04 09:01:12 -07:00
|
|
|
#include "xf86drmMode.h"
|
2018-02-19 21:49:19 -07:00
|
|
|
|
|
|
|
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,19,99,1,0)
|
|
|
|
#include <xf86Pci.h>
|
|
|
|
#else
|
2012-03-04 09:01:12 -07:00
|
|
|
#include "dri.h"
|
2018-02-19 21:49:19 -07:00
|
|
|
#endif
|
2013-08-16 11:04:02 -06:00
|
|
|
|
2014-04-09 14:21:16 -06:00
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
#include <xf86_OSproc.h>
|
|
|
|
#endif
|
|
|
|
|
2013-08-16 11:04:02 -06:00
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
#include <xf86platformBus.h>
|
2012-03-04 09:01:12 -07:00
|
|
|
#endif
|
|
|
|
|
2008-07-12 09:18:32 -06:00
|
|
|
#include "radeon_chipset_gen.h"
|
2006-11-26 13:00:15 -07:00
|
|
|
|
2008-07-12 09:18:32 -06:00
|
|
|
#include "radeon_pci_chipset_gen.h"
|
|
|
|
|
|
|
|
#include "radeon_pci_device_match_gen.h"
|
2012-03-04 09:01:12 -07:00
|
|
|
|
2008-07-12 09:18:32 -06:00
|
|
|
_X_EXPORT int gRADEONEntityIndex = -1;
|
2006-11-26 13:00:15 -07:00
|
|
|
|
|
|
|
/* Return the options for supported chipset 'n'; NULL otherwise */
|
2008-07-12 09:18:32 -06:00
|
|
|
static const OptionInfoRec *
|
2006-11-26 13:00:15 -07:00
|
|
|
RADEONAvailableOptions(int chipid, int busid)
|
|
|
|
{
|
2008-07-12 09:18:32 -06:00
|
|
|
return RADEONOptionsWeak();
|
2006-11-26 13:00:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the string name for supported chipset 'n'; NULL otherwise. */
|
2008-07-12 09:18:32 -06:00
|
|
|
static void
|
2006-11-26 13:00:15 -07:00
|
|
|
RADEONIdentify(int flags)
|
|
|
|
{
|
|
|
|
xf86PrintChipsets(RADEON_NAME,
|
2018-02-19 21:49:19 -07:00
|
|
|
"Driver for ATI/AMD Radeon chipsets",
|
|
|
|
RADEONUniqueChipsets);
|
2006-11-26 13:00:15 -07:00
|
|
|
}
|
|
|
|
|
2012-03-04 09:01:12 -07:00
|
|
|
|
|
|
|
static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci_dev)
|
|
|
|
{
|
|
|
|
char *busIdString;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
|
|
|
|
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
|
|
|
|
"[KMS] No DRICreatePCIBusID symbol, no kernel modesetting.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
busIdString = DRICreatePCIBusID(pci_dev);
|
|
|
|
ret = drmCheckModesettingSupported(busIdString);
|
2014-04-09 14:21:16 -06:00
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
if (ret) {
|
|
|
|
if (xf86LoadKernelModule("radeonkms"))
|
|
|
|
ret = drmCheckModesettingSupported(busIdString);
|
|
|
|
}
|
|
|
|
#endif
|
2012-03-04 09:01:12 -07:00
|
|
|
free(busIdString);
|
|
|
|
if (ret) {
|
|
|
|
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
|
|
|
|
"[KMS] drm report modesetting isn't supported.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
|
|
|
|
"[KMS] Kernel modesetting enabled.\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-07-12 09:18:32 -06:00
|
|
|
static Bool
|
2012-03-04 09:01:12 -07:00
|
|
|
radeon_get_scrninfo(int entity_num, void *pci_dev)
|
2008-07-12 09:18:32 -06:00
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = NULL;
|
|
|
|
EntityInfoPtr pEnt;
|
|
|
|
|
|
|
|
pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, RADEONPciChipsets,
|
|
|
|
NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (!pScrn)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-11-13 07:42:27 -07:00
|
|
|
if (!radeon_kernel_mode_enabled(pScrn, pci_dev))
|
2013-08-16 11:04:02 -06:00
|
|
|
return FALSE;
|
2012-03-04 09:01:12 -07:00
|
|
|
|
2008-07-12 09:18:32 -06:00
|
|
|
pScrn->driverVersion = RADEON_VERSION_CURRENT;
|
|
|
|
pScrn->driverName = RADEON_DRIVER_NAME;
|
|
|
|
pScrn->name = RADEON_NAME;
|
|
|
|
pScrn->Probe = NULL;
|
2012-03-04 09:01:12 -07:00
|
|
|
|
2013-08-16 11:04:02 -06:00
|
|
|
pScrn->PreInit = RADEONPreInit_KMS;
|
|
|
|
pScrn->ScreenInit = RADEONScreenInit_KMS;
|
|
|
|
pScrn->SwitchMode = RADEONSwitchMode_KMS;
|
|
|
|
pScrn->AdjustFrame = RADEONAdjustFrame_KMS;
|
|
|
|
pScrn->EnterVT = RADEONEnterVT_KMS;
|
|
|
|
pScrn->LeaveVT = RADEONLeaveVT_KMS;
|
|
|
|
pScrn->FreeScreen = RADEONFreeScreen_KMS;
|
|
|
|
pScrn->ValidMode = RADEONValidMode;
|
2008-07-12 09:18:32 -06:00
|
|
|
|
|
|
|
pEnt = xf86GetEntityInfo(entity_num);
|
|
|
|
|
|
|
|
/* Create a RADEONEntity for all chips, even with old single head
|
|
|
|
* Radeon, need to use pRADEONEnt for new monitor detection routines.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
DevUnion *pPriv;
|
|
|
|
|
|
|
|
xf86SetEntitySharable(entity_num);
|
|
|
|
|
|
|
|
if (gRADEONEntityIndex == -1)
|
|
|
|
gRADEONEntityIndex = xf86AllocateEntityPrivateIndex();
|
|
|
|
|
|
|
|
pPriv = xf86GetEntityPrivate(pEnt->index,
|
|
|
|
gRADEONEntityIndex);
|
|
|
|
|
2012-03-04 09:01:12 -07:00
|
|
|
xf86SetEntityInstanceForScreen(pScrn, pEnt->index, xf86GetNumEntityInstances(pEnt->index) - 1);
|
2012-02-06 15:53:02 -07:00
|
|
|
|
2016-04-02 01:37:34 -06:00
|
|
|
if (!pPriv->ptr)
|
2008-07-12 09:18:32 -06:00
|
|
|
pPriv->ptr = xnfcalloc(sizeof(RADEONEntRec), 1);
|
|
|
|
}
|
|
|
|
|
2012-03-04 09:01:12 -07:00
|
|
|
free(pEnt);
|
2008-07-12 09:18:32 -06:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
radeon_pci_probe(
|
|
|
|
DriverPtr pDriver,
|
|
|
|
int entity_num,
|
|
|
|
struct pci_device *device,
|
|
|
|
intptr_t match_data
|
|
|
|
)
|
|
|
|
{
|
2012-03-04 09:01:12 -07:00
|
|
|
return radeon_get_scrninfo(entity_num, (void *)device);
|
2008-07-12 09:18:32 -06:00
|
|
|
}
|
|
|
|
|
2013-08-16 11:04:02 -06:00
|
|
|
static Bool
|
|
|
|
RADEONDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
|
|
|
|
{
|
|
|
|
xorgHWFlags *flag;
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case GET_REQUIRED_HW_INTERFACES:
|
|
|
|
flag = (CARD32 *)data;
|
|
|
|
(*flag) = 0;
|
|
|
|
return TRUE;
|
2015-04-14 13:55:48 -06:00
|
|
|
#if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(1,15,99,0,0)
|
|
|
|
case SUPPORTS_SERVER_FDS:
|
|
|
|
return TRUE;
|
|
|
|
#endif
|
2013-08-16 11:04:02 -06:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
static Bool
|
|
|
|
radeon_platform_probe(DriverPtr pDriver,
|
|
|
|
int entity_num, int flags,
|
|
|
|
struct xf86_platform_device *dev,
|
|
|
|
intptr_t match_data)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn;
|
|
|
|
int scr_flags = 0;
|
|
|
|
EntityInfoPtr pEnt;
|
|
|
|
|
|
|
|
if (!dev->pdev)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (flags & PLATFORM_PROBE_GPU_SCREEN)
|
|
|
|
scr_flags = XF86_ALLOCATE_GPU_SCREEN;
|
|
|
|
|
|
|
|
pScrn = xf86AllocateScreen(pDriver, scr_flags);
|
|
|
|
if (xf86IsEntitySharable(entity_num))
|
|
|
|
xf86SetEntityShared(entity_num);
|
|
|
|
xf86AddEntityToScreen(pScrn, entity_num);
|
|
|
|
|
|
|
|
if (!radeon_kernel_mode_enabled(pScrn, dev->pdev))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pScrn->driverVersion = RADEON_VERSION_CURRENT;
|
|
|
|
pScrn->driverName = RADEON_DRIVER_NAME;
|
|
|
|
pScrn->name = RADEON_NAME;
|
|
|
|
pScrn->Probe = NULL;
|
|
|
|
pScrn->PreInit = RADEONPreInit_KMS;
|
|
|
|
pScrn->ScreenInit = RADEONScreenInit_KMS;
|
|
|
|
pScrn->SwitchMode = RADEONSwitchMode_KMS;
|
|
|
|
pScrn->AdjustFrame = RADEONAdjustFrame_KMS;
|
|
|
|
pScrn->EnterVT = RADEONEnterVT_KMS;
|
|
|
|
pScrn->LeaveVT = RADEONLeaveVT_KMS;
|
|
|
|
pScrn->FreeScreen = RADEONFreeScreen_KMS;
|
|
|
|
pScrn->ValidMode = RADEONValidMode;
|
|
|
|
|
|
|
|
pEnt = xf86GetEntityInfo(entity_num);
|
|
|
|
|
|
|
|
/* Create a RADEONEntity for all chips, even with old single head
|
|
|
|
* Radeon, need to use pRADEONEnt for new monitor detection routines.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
DevUnion *pPriv;
|
|
|
|
RADEONEntPtr pRADEONEnt;
|
|
|
|
|
|
|
|
xf86SetEntitySharable(entity_num);
|
|
|
|
|
|
|
|
if (gRADEONEntityIndex == -1)
|
|
|
|
gRADEONEntityIndex = xf86AllocateEntityPrivateIndex();
|
|
|
|
|
|
|
|
pPriv = xf86GetEntityPrivate(pEnt->index,
|
|
|
|
gRADEONEntityIndex);
|
|
|
|
|
|
|
|
xf86SetEntityInstanceForScreen(pScrn, pEnt->index, xf86GetNumEntityInstances(pEnt->index) - 1);
|
|
|
|
|
|
|
|
if (!pPriv->ptr) {
|
|
|
|
pPriv->ptr = xnfcalloc(sizeof(RADEONEntRec), 1);
|
|
|
|
pRADEONEnt = pPriv->ptr;
|
|
|
|
} else {
|
|
|
|
pRADEONEnt = pPriv->ptr;
|
|
|
|
}
|
2015-04-14 13:55:48 -06:00
|
|
|
pRADEONEnt->platform_dev = dev;
|
2013-08-16 11:04:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
free(pEnt);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2008-07-12 09:18:32 -06:00
|
|
|
|
|
|
|
_X_EXPORT DriverRec RADEON =
|
|
|
|
{
|
|
|
|
RADEON_VERSION_CURRENT,
|
|
|
|
RADEON_DRIVER_NAME,
|
|
|
|
RADEONIdentify,
|
|
|
|
NULL,
|
|
|
|
RADEONAvailableOptions,
|
|
|
|
NULL,
|
|
|
|
0,
|
2013-08-16 11:04:02 -06:00
|
|
|
RADEONDriverFunc,
|
2008-07-12 09:18:32 -06:00
|
|
|
radeon_device_match,
|
2013-08-16 11:04:02 -06:00
|
|
|
radeon_pci_probe,
|
|
|
|
#ifdef XSERVER_PLATFORM_BUS
|
|
|
|
radeon_platform_probe
|
2008-07-12 09:18:32 -06:00
|
|
|
#endif
|
|
|
|
};
|