* Korli renamed the driver, but forgot to let the driver ask for the new accelerant name.
* Added a TRACE_S3SAVAGE macro that turns on debug output - should be set conditionally if DEBUG is defined (see DriverInterface.h), but is currently always on, as requested by Gerald. * Some minor style fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21492 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,10 +5,10 @@
|
|||||||
Other authors:
|
Other authors:
|
||||||
Gerald Zajac 2006-2007
|
Gerald Zajac 2006-2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DRIVERINTERFACE_H
|
#ifndef DRIVERINTERFACE_H
|
||||||
#define DRIVERINTERFACE_H
|
#define DRIVERINTERFACE_H
|
||||||
|
|
||||||
|
|
||||||
#include <Accelerant.h>
|
#include <Accelerant.h>
|
||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
@@ -23,11 +23,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1 /* DEBUG */
|
||||||
|
# define TRACE_S3SAVAGE
|
||||||
|
// turns on debug output
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NUM_ELEMENTS(a) ((int)(sizeof(a) / sizeof(a[0]))) // for computing number of elements in an array
|
#define NUM_ELEMENTS(a) ((int)(sizeof(a) / sizeof(a[0]))) // for computing number of elements in an array
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
sem_id sem;
|
sem_id sem;
|
||||||
int32 ben;
|
int32 ben;
|
||||||
} benaphore;
|
} benaphore;
|
||||||
@@ -41,8 +44,7 @@ typedef struct
|
|||||||
#define SAVAGE_PRIVATE_DATA_MAGIC 0x5791 // a private driver rev, of sorts
|
#define SAVAGE_PRIVATE_DATA_MAGIC 0x5791 // a private driver rev, of sorts
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
SAVAGE_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1,
|
SAVAGE_GET_PRIVATE_DATA = B_DEVICE_OP_CODES_END + 1,
|
||||||
SAVAGE_GET_PCI,
|
SAVAGE_GET_PCI,
|
||||||
SAVAGE_SET_PCI,
|
SAVAGE_SET_PCI,
|
||||||
@@ -54,8 +56,7 @@ enum
|
|||||||
// Chip tags. These are used to group the adapters into related
|
// Chip tags. These are used to group the adapters into related
|
||||||
// families. See table SavageChipsetTable in driver.c
|
// families. See table SavageChipsetTable in driver.c
|
||||||
|
|
||||||
enum S3ChipTags
|
enum S3ChipTags {
|
||||||
{
|
|
||||||
S3_UNKNOWN = 0,
|
S3_UNKNOWN = 0,
|
||||||
S3_SAVAGE3D,
|
S3_SAVAGE3D,
|
||||||
S3_SAVAGE_MX,
|
S3_SAVAGE_MX,
|
||||||
@@ -111,9 +112,7 @@ typedef union _BMPDESC {
|
|||||||
} BMPDESC;
|
} BMPDESC;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
// Device ID info.
|
// Device ID info.
|
||||||
uint16 vendorID; // PCI vendor ID, from pci_info
|
uint16 vendorID; // PCI vendor ID, from pci_info
|
||||||
uint16 deviceID; // PCI device ID, from pci_info
|
uint16 deviceID; // PCI device ID, from pci_info
|
||||||
@@ -147,8 +146,7 @@ typedef struct
|
|||||||
int32 flags;
|
int32 flags;
|
||||||
|
|
||||||
// Cursor info.
|
// Cursor info.
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
uint16 hot_x; // Cursor hot spot. The top left corner of the cursor
|
uint16 hot_x; // Cursor hot spot. The top left corner of the cursor
|
||||||
uint16 hot_y; // is 0,0
|
uint16 hot_y; // is 0,0
|
||||||
uint16 x; // The location of the cursor hot spot on the
|
uint16 x; // The location of the cursor hot spot on the
|
||||||
@@ -164,8 +162,7 @@ typedef struct
|
|||||||
frame_buffer_config fbc; // frame buffer addresses and bytes_per_row
|
frame_buffer_config fbc; // frame buffer addresses and bytes_per_row
|
||||||
|
|
||||||
// Acceleration engine.
|
// Acceleration engine.
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
uint64 count; // last fifo slot used
|
uint64 count; // last fifo slot used
|
||||||
uint64 lastIdle; // last fifo slot we *know* the engine was idle after
|
uint64 lastIdle; // last fifo slot we *know* the engine was idle after
|
||||||
benaphore lock; // for serializing access to the acceleration engine
|
benaphore lock; // for serializing access to the acceleration engine
|
||||||
@@ -202,8 +199,7 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
// Read or write a value in PCI configuration space
|
// Read or write a value in PCI configuration space
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 magic; // magic number to make sure the caller groks us
|
uint32 magic; // magic number to make sure the caller groks us
|
||||||
uint32 offset; // Offset to read/write
|
uint32 offset; // Offset to read/write
|
||||||
uint32 size; // Number of bytes to transfer
|
uint32 size; // Number of bytes to transfer
|
||||||
@@ -212,16 +208,14 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
// Set some boolean condition (like enabling or disabling interrupts)
|
// Set some boolean condition (like enabling or disabling interrupts)
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 magic; // magic number to make sure the caller groks us
|
uint32 magic; // magic number to make sure the caller groks us
|
||||||
bool bEnable; // state to set
|
bool bEnable; // state to set
|
||||||
} SavageSetBoolState;
|
} SavageSetBoolState;
|
||||||
|
|
||||||
|
|
||||||
// Retrieve the area_id of the kernel/accelerant shared info
|
// Retrieve the area_id of the kernel/accelerant shared info
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 magic; // magic number to make sure the caller groks us
|
uint32 magic; // magic number to make sure the caller groks us
|
||||||
area_id sharedInfoArea; // ID of area containing shared information
|
area_id sharedInfoArea; // ID of area containing shared information
|
||||||
} SavageGetPrivateData;
|
} SavageGetPrivateData;
|
||||||
@@ -229,8 +223,7 @@ typedef struct
|
|||||||
|
|
||||||
// Retrieve the device name. Usefull for when we have a file handle, but want
|
// Retrieve the device name. Usefull for when we have a file handle, but want
|
||||||
// to know the device name (like when we are cloning the accelerant)
|
// to know the device name (like when we are cloning the accelerant)
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 magic; // magic number to make sure the caller groks us
|
uint32 magic; // magic number to make sure the caller groks us
|
||||||
char *name; // The name of the device, less the /dev root
|
char *name; // The name of the device, less the /dev root
|
||||||
} SavageDeviceName;
|
} SavageDeviceName;
|
||||||
@@ -240,5 +233,4 @@ typedef struct
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* DRIVERINTERFACE_H */
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ extern bool bAccelerantIsClone;// true if this is a cloned accelerant
|
|||||||
|
|
||||||
void TraceLog(const char* fmt, ...);
|
void TraceLog(const char* fmt, ...);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef TRACE_S3SAVAGE
|
||||||
#define TRACE(a) TraceLog a
|
# define TRACE(a) TraceLog a
|
||||||
#else
|
#else
|
||||||
#define TRACE(a)
|
# define TRACE(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // GLOBALDATA_H
|
#endif // GLOBALDATA_H
|
||||||
|
|||||||
@@ -269,7 +269,6 @@ UNINIT_ACCELERANT(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Kernel function dprintf() is not available in user space; however,
|
// Kernel function dprintf() is not available in user space; however,
|
||||||
// _sPrintf performs the same function in user space but is undefined
|
// _sPrintf performs the same function in user space but is undefined
|
||||||
// in the OS header files. Thus, it is defined here.
|
// in the OS header files. Thus, it is defined here.
|
||||||
|
|||||||
@@ -20,11 +20,10 @@
|
|||||||
#include <graphic_driver.h>
|
#include <graphic_driver.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TRACE_S3SAVAGE
|
||||||
#ifdef DEBUG
|
# define TRACE(a) TraceLog a
|
||||||
#define TRACE(a) TraceLog a
|
|
||||||
#else
|
#else
|
||||||
#define TRACE(a)
|
# define TRACE(a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -46,8 +45,7 @@ int32 api_version = B_CUR_DRIVER_API_VERSION;
|
|||||||
|
|
||||||
/* these structures are private to the kernel driver */
|
/* these structures are private to the kernel driver */
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint16 chipID; // PCI device id of the chipset
|
uint16 chipID; // PCI device id of the chipset
|
||||||
uint16 chipset; // assigned chipset family identifier
|
uint16 chipset; // assigned chipset family identifier
|
||||||
char* chipName; // user recognizable name for chipset (must be < 32 chars)
|
char* chipName; // user recognizable name for chipset (must be < 32 chars)
|
||||||
@@ -55,8 +53,7 @@ typedef struct
|
|||||||
|
|
||||||
/* This table maps a PCI device ID to a chipset family identifier and the chipset
|
/* This table maps a PCI device ID to a chipset family identifier and the chipset
|
||||||
name. */
|
name. */
|
||||||
static ChipInfo SavageChipTable[] =
|
static ChipInfo SavageChipTable[] = {
|
||||||
{
|
|
||||||
{ 0x8a20, S3_SAVAGE3D, "Savage3D" },
|
{ 0x8a20, S3_SAVAGE3D, "Savage3D" },
|
||||||
{ 0x8a21, S3_SAVAGE3D, "Savage3D-MV" },
|
{ 0x8a21, S3_SAVAGE3D, "Savage3D-MV" },
|
||||||
{ 0x8a22, S3_SAVAGE4, "Savage4" },
|
{ 0x8a22, S3_SAVAGE4, "Savage4" },
|
||||||
@@ -86,19 +83,16 @@ static ChipInfo SavageChipTable[] =
|
|||||||
|
|
||||||
#define VENDOR_ID_SAVAGE 0x5333 /* S3 Savage vendor ID */
|
#define VENDOR_ID_SAVAGE 0x5333 /* S3 Savage vendor ID */
|
||||||
|
|
||||||
static struct
|
static struct {
|
||||||
{
|
|
||||||
uint16 vendorID;
|
uint16 vendorID;
|
||||||
ChipInfo* devices;
|
ChipInfo* devices;
|
||||||
} SupportedDevices[] =
|
} SupportedDevices[] = {
|
||||||
{
|
|
||||||
{ VENDOR_ID_SAVAGE, SavageChipTable },
|
{ VENDOR_ID_SAVAGE, SavageChipTable },
|
||||||
{ 0x0000, NULL }
|
{ 0x0000, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 is_open; /* a count of how many times the devices has been opened */
|
uint32 is_open; /* a count of how many times the devices has been opened */
|
||||||
area_id sharedArea; /* the area shared between the driver and all of the accelerants */
|
area_id sharedArea; /* the area shared between the driver and all of the accelerants */
|
||||||
SharedInfo *si; /* a pointer to the shared area, for convenience */
|
SharedInfo *si; /* a pointer to the shared area, for convenience */
|
||||||
@@ -109,8 +103,7 @@ typedef struct
|
|||||||
} DeviceInfo;
|
} DeviceInfo;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32 count; /* number of devices actually found */
|
uint32 count; /* number of devices actually found */
|
||||||
benaphore kernel; /* for serializing opens/closes */
|
benaphore kernel; /* for serializing opens/closes */
|
||||||
char *deviceNames[MAX_DEVICES+1]; /* device name pointer storage */
|
char *deviceNames[MAX_DEVICES+1]; /* device name pointer storage */
|
||||||
@@ -146,11 +139,11 @@ static device_hooks graphics_device_hooks =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef TRACE_S3SAVAGE
|
||||||
static void
|
static void
|
||||||
TraceLog(const char *fmt, ...)
|
TraceLog(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char string[1024];
|
char string[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
strcpy(string, "savage: ");
|
strcpy(string, "savage: ");
|
||||||
@@ -521,8 +514,11 @@ exit0:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Device Hooks
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
open_hook (const char* name, uint32 flags, void** cookie)
|
open_hook(const char* name, uint32 flags, void** cookie)
|
||||||
{
|
{
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
DeviceInfo *di;
|
DeviceInfo *di;
|
||||||
@@ -642,9 +638,6 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------
|
|
||||||
read_hook - does nothing, gracefully
|
|
||||||
----- */
|
|
||||||
static status_t
|
static status_t
|
||||||
read_hook(void* dev, off_t pos, void* buf, size_t* len)
|
read_hook(void* dev, off_t pos, void* buf, size_t* len)
|
||||||
{
|
{
|
||||||
@@ -658,10 +651,6 @@ read_hook(void* dev, off_t pos, void* buf, size_t* len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------
|
|
||||||
write_hook - does nothing, gracefully
|
|
||||||
----- */
|
|
||||||
static status_t
|
static status_t
|
||||||
write_hook(void* dev, off_t pos, const void* buf, size_t* len)
|
write_hook(void* dev, off_t pos, const void* buf, size_t* len)
|
||||||
{
|
{
|
||||||
@@ -675,9 +664,6 @@ write_hook(void* dev, off_t pos, const void* buf, size_t* len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------
|
|
||||||
close_hook - does nothing, gracefully
|
|
||||||
----- */
|
|
||||||
static status_t
|
static status_t
|
||||||
close_hook(void* dev)
|
close_hook(void* dev)
|
||||||
{
|
{
|
||||||
@@ -689,9 +675,6 @@ close_hook(void* dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -----------
|
|
||||||
free_hook - close down the device
|
|
||||||
----------- */
|
|
||||||
static status_t
|
static status_t
|
||||||
free_hook(void* dev)
|
free_hook(void* dev)
|
||||||
{
|
{
|
||||||
@@ -738,11 +721,8 @@ unlock_and_exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -----------
|
|
||||||
control_hook - where the real work is done
|
|
||||||
----------- */
|
|
||||||
static status_t
|
static status_t
|
||||||
control_hook (void* dev, uint32 msg, void *buf, size_t len)
|
control_hook(void* dev, uint32 msg, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
DeviceInfo *di = (DeviceInfo *)dev;
|
DeviceInfo *di = (DeviceInfo *)dev;
|
||||||
status_t result = B_DEV_INVALID_IOCTL;
|
status_t result = B_DEV_INVALID_IOCTL;
|
||||||
@@ -753,53 +733,59 @@ control_hook (void* dev, uint32 msg, void *buf, size_t len)
|
|||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
/* the only PUBLIC ioctl */
|
/* the only PUBLIC ioctl */
|
||||||
case B_GET_ACCELERANT_SIGNATURE: {
|
case B_GET_ACCELERANT_SIGNATURE:
|
||||||
|
{
|
||||||
char *sig = (char *)buf;
|
char *sig = (char *)buf;
|
||||||
strcpy(sig, "savage.accelerant");
|
strcpy(sig, "s3savage.accelerant");
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
/* PRIVATE ioctl from here on */
|
/* PRIVATE ioctl from here on */
|
||||||
case SAVAGE_GET_PRIVATE_DATA: {
|
case SAVAGE_GET_PRIVATE_DATA:
|
||||||
|
{
|
||||||
SavageGetPrivateData *gpd = (SavageGetPrivateData *)buf;
|
SavageGetPrivateData *gpd = (SavageGetPrivateData *)buf;
|
||||||
if (gpd->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
if (gpd->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
||||||
gpd->sharedInfoArea = di->sharedArea;
|
gpd->sharedInfoArea = di->sharedArea;
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case SAVAGE_GET_PCI: {
|
case SAVAGE_GET_PCI:
|
||||||
|
{
|
||||||
SavageGetSetPci *gsp = (SavageGetSetPci *)buf;
|
SavageGetSetPci *gsp = (SavageGetSetPci *)buf;
|
||||||
if (gsp->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
if (gsp->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
||||||
pci_info *pcii = &(di->pcii);
|
pci_info *pcii = &(di->pcii);
|
||||||
gsp->value = get_pci(gsp->offset, gsp->size);
|
gsp->value = get_pci(gsp->offset, gsp->size);
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case SAVAGE_SET_PCI: {
|
case SAVAGE_SET_PCI:
|
||||||
|
{
|
||||||
SavageGetSetPci *gsp = (SavageGetSetPci *)buf;
|
SavageGetSetPci *gsp = (SavageGetSetPci *)buf;
|
||||||
if (gsp->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
if (gsp->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
||||||
pci_info *pcii = &(di->pcii);
|
pci_info *pcii = &(di->pcii);
|
||||||
set_pci(gsp->offset, gsp->size, gsp->value);
|
set_pci(gsp->offset, gsp->size, gsp->value);
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case SAVAGE_DEVICE_NAME: {
|
case SAVAGE_DEVICE_NAME:
|
||||||
|
{
|
||||||
SavageDeviceName *dn = (SavageDeviceName *)buf;
|
SavageDeviceName *dn = (SavageDeviceName *)buf;
|
||||||
if (dn->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
if (dn->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
||||||
strcpy(dn->name, di->name);
|
strcpy(dn->name, di->name);
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case SAVAGE_RUN_INTERRUPTS: {
|
case SAVAGE_RUN_INTERRUPTS:
|
||||||
|
{
|
||||||
SavageSetBoolState *ri = (SavageSetBoolState *)buf;
|
SavageSetBoolState *ri = (SavageSetBoolState *)buf;
|
||||||
if (ri->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
if (ri->magic == SAVAGE_PRIVATE_DATA_MAGIC) {
|
||||||
if (ri->bEnable) {
|
if (ri->bEnable) {
|
||||||
@@ -809,8 +795,8 @@ control_hook (void* dev, uint32 msg, void *buf, size_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user