* Copyright (c) 2002-2004, Thomas Kurschel
* Distributed under the terms of the MIT license.
*/
#ifndef _RADEON_DRIVER_H
#define _RADEON_DRIVER_H
#include "radeon_interface.h"
#include "memory_manager.h"
#include <KernelExport.h>
#include <GraphicsDefs.h>
#include "AGP.h"
extern int debug_level_flow;
extern int debug_level_info;
extern int debug_level_error;
#define DEBUG_WAIT_ON_ERROR 1000000*/
#define DEBUG_MSG_PREFIX "Radeon - "
#include "debug_ext.h"
#include "log_coll.h"
#define MAX_DEVICES 8
#define PCI_GART_SIZE 1024*1024
#define CP_RING_SIZE 2048
typedef struct {
struct {
area_id area;
size_t size;
void *ptr;
area_id unaligned_area;
} buffer;
struct {
area_id area;
uint32 *ptr;
uint32 phys;
} GATT;
} GART_info;
typedef struct {
int ml;
int MB;
int Trcd;
int Trp;
int Twr;
int CL;
int Tr2w;
int loop_latency;
int Rloop;
int width;
} ram_info;
typedef struct {
area_id bios_area;
uint32 phys_address;
uint32 size;
uint8 *bios_ptr;
uint8 *rom_ptr;
} rom_info;
typedef struct {
timer te;
struct device_info *di;
bigtime_t when_target;
} timer_info;
typedef struct device_info {
uint32 is_open;
area_id shared_area;
shared_info *si;
area_id virtual_card_area;
virtual_card *vc;
vuint8 *regs;
radeon_type asic;
uint8 num_crtc;
tv_chip_type tv_chip;
bool is_mobility;
bool new_pll;
bool has_vip;
bool is_igp;
bool has_no_i2c;
bool acc_dma;
fp_info fp_info;
disp_entity routing;
general_pll_info pll;
tmds_pll_info tmds_pll[4];
ram_info ram;
char ram_type[32];
uint32 local_mem_size;
rom_info rom;
bool is_atombios;
GART_info pci_gart;
GART_info agp_gart;
memory_type_e nonlocal_map;
mem_info *memmgr[mt_last+1];
uint32 interrupt_count;
uint32 vbi_count[2];
int32 shutdown_virtual_irq;
timer_info ti_a;
timer_info ti_b;
timer_info *current_timer;
sem_id dma_sem;
uint32 dma_desc_max_num;
uint32 dma_desc_handle;
uint32 dma_desc_offset;
spinlock cap_spinlock;
sem_id cap_sem;
uint32 cap_int_status;
uint32 cap_counter;
bigtime_t cap_timestamp;
uint32 dac2_cntl;
radeon_settings settings;
pci_info pcii;
agp_info agpi;
char name[MAX_RADEON_DEVICE_NAME_LENGTH];
char video_name[MAX_RADEON_DEVICE_NAME_LENGTH];
} device_info;
typedef struct {
uint32 count;
benaphore kernel;
char *device_names[2*MAX_DEVICES+1];
device_info di[MAX_DEVICES];
} radeon_devices;
extern pci_module_info *pci_bus;
extern agp_gart_module_info *sAGP;
extern radeon_devices *devices;
bool Radeon_CardDetect( void );
void Radeon_ProbeDevices( void );
status_t Radeon_FirstOpen( device_info *di );
void Radeon_LastClose( device_info *di );
status_t Radeon_MapDevice( device_info *di, bool mmio_only );
void Radeon_UnmapDevice(device_info *di);
status_t Radeon_MapBIOS( pci_info *pcii, rom_info *ri );
void Radeon_UnmapBIOS( rom_info *ri );
status_t Radeon_ReadBIOSData( device_info *di );
status_t Radeon_InitPCIGART( device_info *di );
void Radeon_CleanupPCIGART( device_info *di );
status_t Radeon_SetupIRQ( device_info *di, char *buffer );
void Radeon_CleanupIRQ( device_info *di );
void Radeon_Set_AGP( device_info *di, bool enable_agp );
void Radeon_InitMemController( device_info *di );
void Radeon_WaitForIdle( device_info *di, bool acquire_lock, bool keep_lock );
void Radeon_WaitForFifo( device_info *di, int entries );
void Radeon_ResetEngine( device_info *di );
status_t Radeon_InitCP( device_info *di );
void Radeon_UninitCP( device_info *di );
void Radeon_SetDynamicClock( device_info *di, int mode );
bool Radeon_VIPRead( device_info *di, uint channel, uint address, uint32 *data, bool lock );
bool Radeon_VIPWrite( device_info *di, uint8 channel, uint address, uint32 data, bool lock );
bool Radeon_VIPFifoRead(device_info *di, uint8 channel, uint32 address, uint32 count, uint8 *buffer, bool lock);
bool Radeon_VIPFifoWrite(device_info *di, uint8 channel, uint32 address, uint32 count, uint8 *buffer, bool lock);
int Radeon_FindVIPDevice( device_info *di, uint32 device_id );
void Radeon_VIPReset( device_info *di, bool lock );
status_t Radeon_InitDMA( device_info *di );
status_t Radeon_DMACopy(
device_info *di, uint32 src, char *target, size_t size,
bool lock_mem, bool contiguous );
#endif