Есть чудо машинка ebox-2300m размером с пачку сигарет. Собрана на SIS чипсете.
Фря 4.11 и 6.2 даже стала и работает! Все замечательно. (Одна такая машинка управляет сканером в холле здания. Через SANE естественно. Кнопку жмешь на сканере и скан в 300 дпи валится в сетевую папку с текущей датой.)
Так вот. Возникла идея сделать FM радиовещательный автомат на базе этой коробочки. То есть можно было бы припрячь и стандартный системник или старый ноут, но жрут оне гады зело много, а планируется машинку поставить на автономное питание. FM автомат представляет собой автоматический плеер со сменой плейлистов по cron-у и передачей сигналов точного времени, и тд и тп. Такой автомат в большом системнике уже создан и работает больше 2х лет, 4 звуковые карты, каждая выводит звук на свою радиостанцию. Все работает под одной freebsd 4.11 и есть не просит.
Это была преамбула собственно.
амбула блин в том что нету драйвера под фрю на эту долбаную встроенную звуковуху SIS 7019
Под линукс драйвер есть, а под фрю нету.
Есть файл sis.c линуксовый. Возможно ли его переписать каким то образом под фрю? Большой это геморрой?
Ну не ставить же линукс матьиво....
Файл собственно:
Код: Выделить всё
/*******************************define value*******************************/
//#define sunburst_kernel_lock
#define _LOOSE_KERNEL_NAMES
#undef smp_num_cpus
#undef smp_message_pass
/*******************************include header******************************/
//#include <linux/modversions.h> //arthurlee@030210 mask
#include <linux/config.h>
#include <linux/version.h>
#include <linux/ac97_codec.h>
#include <stdarg.h>
#ifdef sunburst_kernel_lock
#include <asm/spinlock.h>
#endif
#include <linux/module.h> //arthurlee@030210 add
#include <linux/param.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/fcntl.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/mm.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#if LINUX_VERSION_CODE >= 132096 /* 2.4.x */
#include <asm/processor.h>
#endif
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/io.h>
#include <linux/pci.h>
#include <linux/apm_bios.h>
#include <asm/segment.h>
#include <linux/tqueue.h>
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
#include <asm/uaccess.h>
#include <linux/poll.h>
static char kernel_version[32] = UTS_RELEASE;
#else
#include <linux/bios32.h>
#endif
#include <asm/system.h>
#include <asm/dma.h>
#if LINUX_VERSION_CODE < 131097
#include <sys/kd.h>
#endif
#include <linux/wait.h>
#include <linux/malloc.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/tqueue.h>
//#include <linux/spinlock.h>
#if LINUX_VERSION_CODE>=132095
#include <linux/pm.h>
#endif
#include "../include/wrap.h"
static struct pci_driver * pcidvr;
static struct file_operations *mixerfop;
static struct file_operations *audiofop;
typedef u16 (*ac97_read_t) (struct ac97_codec *,u8);
typedef void (*ac97_write_t) (struct ac97_codec *,u8,u16);
typedef int (*probe_t) (struct pci_dev *,const struct pci_device_id *);
typedef void (*remove_t) (struct pci_dev *);
/*
* These typedefs must match definition of struct file_operations.
* (See notes in routine module_register_chrdev).
*/
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
typedef long long (*llseek_t) (struct inode *, struct file *, long long, int);
typedef ssize_t (*read_t) (struct file *, char *, size_t, loff_t *);
typedef ssize_t (*write_t) (struct file *, const char *, size_t, loff_t *);
typedef unsigned int (*poll_t) (struct file *, poll_table *);
typedef poll_table select_table;
#else
typedef int (*lseek_t) (struct inode *, struct file *, off_t, int);
typedef int (*read_t) (struct inode *, struct file *, char *, int);
typedef int (*write_t) (struct inode *, struct file *, const char *, int);
typedef int (*select_t) (struct inode *, struct file *, int, select_table *);
#endif
typedef int (*readdir_t) (struct inode *, struct file *, void *, filldir_t);
typedef int (*ioctl_t) (struct inode *, struct file *, unsigned int,
unsigned long);
#if LINUX_VERSION_CODE >= 131359 /* 2.1.31 */
typedef int (*mmap_t) (struct file *, struct vm_area_struct *);
#else
typedef int (*mmap_t) (struct inode *, struct file *,
struct vm_area_struct *);
#endif
typedef int (*open_t) (struct inode *, struct file *);
#if LINUX_VERSION_CODE >= 131359 /* 2.1.31 */
typedef int (*release_t) (struct inode *, struct file *);
typedef int (*fasync_t) (int, struct file *, int);
#else
typedef void (*release_t) (struct inode *, struct file *);
typedef int (*fasync_t) (struct inode *, struct file *, int);
#endif
typedef int (*fsync_t) (struct inode *, struct file *);
#if LINUX_VERSION_CODE<131858 /* Prior 2.3.x */
typedef int (*check_media_change_t) (kdev_t dev);
typedef int (*revalidate_t) (kdev_t dev);
#else
#define MAX_KMALLOCS 1024
//static int nr_kmallocs = 0;
//static void *kmallocs[MAX_KMALLOCS];
#endif
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
static loff_t
no_llseek (struct file *file, loff_t offset, int orig)
{
return -EINVAL;
}
#ifndef MAP_NR
/* 2.4.0-test6 or later */
static int
no_fsync (struct file *f, struct dentry *d, int datasync)
{
return -EINVAL;
}
#else
static int
no_fsync (struct file *f, struct dentry *d)
{
return -EINVAL;
}
#endif
static int
no_fasync (int x, struct file *f, int m)
{
return -EINVAL;
}
#endif
////////////////////////////////////////////////////////////////////////////
// Function : alloc_pci_driver
// Description :
// Allocate a struct pci_driver,return it to register pci_driver
// Input :
// dp
// Return :
// a struct pci_driver item which is transformed from dp
////////////////////////////////////////////////////////////////////////////
static struct pci_driver *
alloc_pci_driver(struct pci_driver_handle *dp)
{
struct pci_driver *pdvr;
char *tmp_name = dp->name;
const struct pci_device_id *tmp_id_table = dp->id_table;
probe_t tmp_probe = (probe_t) dp->probe;
remove_t tmp_remove = (remove_t) dp->remove;
pdvr = (struct pci_driver *)
kmalloc (sizeof (struct pci_driver), GFP_KERNEL);
memset ((char *) pdvr, 0, sizeof (struct pci_driver));
pdvr->name = tmp_name;
pdvr->id_table = tmp_id_table;
pdvr->probe = tmp_probe;
pdvr->remove = tmp_remove;
pcidvr = pdvr;
return pdvr;
}
/////////////////////////////////////////////////////////////////////////////
// Function: alloc_fop
// Description:
// Allocate a structure file_operations, return it to register
// device
// Parameters:
// op:
// tmpfop: used to kfree item when unregister device
// Return :
// A struct file_operations which is transformed from op
////////////////////////////////////////////////////////////////////////////
static struct file_operations *
alloc_fop (struct file_operation_handle *op,struct file_operations *tmpfop)
{
struct file_operations *fop;
#if LINUX_VERSION_CODE >=132096
struct module *tmp_owner = (struct module *) op->owner;
#endif
#if LINUX_VERSION_CODE <= 131328 /* 2.1.x */
lseek_t tmp_lseek = (lseek_t) op->lseek;
select_t tmp_select = (select_t) op->select;
fsync_t tmp_fsync = (fsync_t) op->fsync;
fasync_t tmp_fasync = (fasync_t) op->fasync;
#else
poll_t tmp_poll = (poll_t) op->poll;
#endif
read_t tmp_read = (read_t) op->read;
write_t tmp_write = (write_t) op->write;
/* readdir_t tmp_readdir = (readdir_t)op->readdir; */
ioctl_t tmp_ioctl = (ioctl_t) op->ioctl;
mmap_t tmp_mmap = (mmap_t) op->mmap;
open_t tmp_open = (open_t) op->open;
release_t tmp_release = (release_t) op->release;
#if LINUX_VERSION_CODE<131858 /* Prior 2.3.x */
check_media_change_t tmp_check_media_change =
(check_media_change_t) op->check_media_change;
revalidate_t tmp_revalidate = (revalidate_t) op->revalidate;
#endif
fop = (struct file_operations *)
kmalloc (sizeof (struct file_operations), GFP_KERNEL);
memset ((char *) fop, 0, sizeof (struct file_operations));
/*
* Now the assignment
*/
#if LINUX_VERSION_CODE >=132096
fop->owner = tmp_owner;
#endif
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
fop->llseek = no_llseek;
#else
fop->lseek = tmp_lseek;
#endif
fop->read = tmp_read;
fop->write = tmp_write;
fop->readdir = NULL; /* tmp_readdir; */
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
fop->poll = tmp_poll;
#else
fop->select = tmp_select;
#endif
fop->ioctl = tmp_ioctl;
fop->mmap = tmp_mmap;
fop->open = tmp_open;
fop->release = tmp_release;
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
fop->fsync = no_fsync;
fop->fasync = no_fasync;
#else
fop->fsync = tmp_fsync;
fop->fasync = tmp_fasync;
#endif
#if LINUX_VERSION_CODE<131858 /* Prior 2.3.x */
fop->check_media_change = tmp_check_media_change;
fop->revalidate = tmp_revalidate;
#else
fop->lock = NULL;
fop->flush = NULL;
#endif
tmpfop = fop;
return fop;
}
////////////////////////////////////////////////////////////////////////////
// Function : struct file access routines.
// Description :
// Routines used for seting/geting member from struct file
// Parameters :
//
// Return :
// get : the member in struct file
// set : none
////////////////////////////////////////////////////////////////////////////
mode_t
file_get_mode(file_handle * file)
{
return ((struct file *) file)->f_mode;
}
int
file_get_flags (file_handle * file)
{
return ((struct file *) file)->f_flags;
}
loff_t *
file_get_f_pos(file_handle * file)
{
return &((struct file *) file)->f_pos;
}
void *
file_get_private (file_handle * file)
{
return ((struct file *) file)->private_data;
}
void
file_set_flags (file_handle * file, int flags)
{
((struct file *) file)->f_flags |= flags;
}
void
file_set_private (file_handle * file, void *v)
{
((struct file *) file)->private_data = v;
}
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
dentry_handle *
file_get_dentry (file_handle * file)
{
return (dentry_handle *) dget (((struct file *) file)->f_dentry);
}
inode_handle * dentry_get_inode (dentry_handle * d)
{
return (inode_handle *) ((struct dentry *) d)->d_inode;
}
#endif
inode_handle *
file_get_inode (file_handle * file)
{
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
if (((struct file *) file)->f_dentry == NULL ||
((struct file *) file)->f_dentry->d_inode == NULL)
panic ("sndobj: file_get_inode called for bad file\n");
return (inode_handle *) ((struct file *) file)->f_dentry->d_inode;
#else
return (inode_handle *) ((struct file *) file)->f_inode;
#endif
}
////////////////////////////////////////////////////////////////////////////
// Function : vm_area_struct access routines
// Description :
// Routines used for seting/geting member from struct vm_area_struct
// Parameters :
//
// Return :
// get : the member in struct vm_area_struct
// set : none
////////////////////////////////////////////////////////////////////////////
#if LINUX_VERSION_CODE<131858 /* Prior 2.3.x */
#if LINUX_VERSION_CODE > 131328 /* 2.1.x */
void
vma_mmap_file (vm_area_handle * vma, file_handle * file)
{
((struct vm_area_struct *) vma)->vm_file = (struct file *) file;
((struct file *) file)->f_count++;
}
#else
void
vma_set_inode (vm_area_handle * vma, inode_handle * inode)
{
((struct vm_area_struct *) vma)->vm_inode = (struct inode *) inode;
}
#endif
#endif
int
vma_get_flags (vm_area_handle * vma)
{
return ((struct vm_area_struct *) vma)->vm_flags;
}
unsigned long
vma_get_offset (vm_area_handle * vma)
{
#if LINUX_VERSION_CODE<131858 /* Prior 2.3.x */
return ((struct vm_area_struct *) vma)->vm_offset;
#else
return ((struct vm_area_struct *) vma)->vm_pgoff;
#endif
}
unsigned long
vma_get_start (vm_area_handle * vma)
{
return ((struct vm_area_struct *) vma)->vm_start;
}
unsigned long
vma_get_end (vm_area_handle * vma)
{
return ((struct vm_area_struct *) vma)->vm_end;
}
pgprot_t vma_get_page_prot (vm_area_handle * vma)
{
return ((struct vm_area_struct *) vma)->vm_page_prot;
}
/**********************************global variable**********************************/
static int wrapper_initialized = 1;
/**********************************export symbol**************************************/
/* EXPORT_SYMBOL from sound_core.c */
extern int register_sound_mixer(struct file_operations *,int);
extern int register_sound_dsp(struct file_operations *,int);
extern int register_sound_special(struct file_operations *,int);
extern int register_sound_midi(struct file_operations *,int);
extern int register_sound_synth(struct file_operations *,int);
extern void unregister_sound_special(int);
extern void unregister_sound_mixer(int);
extern void unregister_sound_midi(int);
extern void unregister_sound_dsp(int);
extern void unregister_sound_synth(int);
/* EXPORT_SYMBOL from ac97_codec.c */
extern int ac97_read_proc(char *,char **,off_t,int,int *,void *);
extern int ac97_probe_codec(struct ac97_codec *);
#ifdef sunburst_kernel_lock
extern void kernel_lock(void);
extern void kernel_unlock(void);
#endif
/**********************************function************************************/
/**********************************ac97_codec routine*********************/
#if LINUX_VERSION_CODE >= 132106
unsigned int sis_ac97_set_adc_rate(struct ac97_codec *codec, unsigned int rate)
{
return ac97_set_adc_rate(codec,rate);
}
#else
unsigned int sis_ac97_set_adc_rate(struct ac97_codec *codec, unsigned int rate)
{
return 0;
}
#endif
/**********************************version check routine***********************/
int sis_connect(void)
{
// printk ("version is %d\n",LINUX_VERSION_CODE);
return (LINUX_VERSION_CODE);
}
/**********************************spin_lock routine***************************/
void sis_spin_unlock(spinlock_t * lock)
{
spin_unlock(lock);
}
void sis_spin_lock(spinlock_t *lock)
{
spin_lock(lock);
}
void sis_spin_lock_init(spinlock_t *lock)
{
spin_lock_init(lock);
}
void sis_spin_lock_irqsave(spinlock_t * lock,unsigned long *flag)
{
spin_lock_irqsave(lock,*flag);
}
void sis_spin_unlock_irqrestore(spinlock_t * lock, unsigned long *flag)
{
spin_unlock_irqrestore(lock,*flag);
}
#ifdef sunburst_kernel_lock
static void sis_lock_kernel(void)
{
lock_kernel();
}
static void sis_unlock_kernel(void)
{
unlock_kernel();
}
#endif
/******************************************irq routine************************/
void sis_synchronize_irq(void)
{
synchronize_irq();
}
int sis_request_irq(unsigned int irq,void (*handler)(int, void *, struct pt_regs *),unsigned long shirq,const char *name,void *devid)
{
return request_irq(irq,handler,shirq,name,devid);
}
void sis_free_irq(unsigned int irq,void *obj)
{
free_irq(irq,obj);
}
/******************************************memory management routine**************/
void * sis_memset(void *x,int i,size_t t)
{
return memset(x,i,t);
}
int sis_remap_page_range(unsigned long from,unsigned long to,unsigned long size,pgprot_t prot)
{
return remap_page_range(from,to,size,prot);
}
void * sis_get_free_pages(int order)
{
return (void *)__get_free_pages(GFP_KERNEL | GFP_DMA, order);
}
void sis_free_pages(unsigned long addr,unsigned int order)
{
free_pages(addr,order);
}
void sis_kfree(void *addr)
{
kfree(addr);
}
void * sis_kmalloc(unsigned long s, int oldmask)
{
int mask=0;
if (oldmask&OSS_GFP_KERNEL)mask|=GFP_KERNEL;
return kmalloc (s, mask);
}
void sis_mem_map_set(unsigned long map)
{
set_bit(PG_reserved,&mem_map[map].flags);
}
void sis_mem_map_clear(unsigned long map)
{
clear_bit(PG_reserved,&mem_map[map].flags);
}
void sis_mem_map_unreserve(struct page *page)
{
clear_bit(PG_reserved,&(page->flags));
// return (mem_map_unreserve(page));
}
void sis_mem_map_reserve(struct page *page)
{
set_bit(PG_reserved,&(page->flags));
// return (mem_map_reserve(page));
}
void * sis_ioremap (unsigned long offset, unsigned long size)
{
return ioremap(offset,size);
}
void sis_iounmap(void *addr)
{
iounmap(addr);
}
#if LINUX_VERSION_CODE >= 132096
struct page * sis_virt_to_page(char *buf)
{
return virt_to_page(buf);
}
#endif
void
sis_reserve_page(void * rawbuf,unsigned int size)
{
struct page *pend,*page;
pend = sis_virt_to_page(rawbuf+size);
for(page=sis_virt_to_page(rawbuf);page<=pend;page++)
sis_mem_map_reserve(page);
}
void
sis_unreserve_page(void * rawbuf,unsigned int size)
{
struct page *pend,*page;
pend = sis_virt_to_page(rawbuf+size);
for(page=sis_virt_to_page(rawbuf);page<=pend;page++)
sis_mem_map_unreserve(page);
}
/*******************************************ac97_codec routine*****************/
int sis_ac97_probe_codec(ac97_codec_handle *codec)
{
struct ac97_codec * co = (struct ac97_codec *) codec;
return ac97_probe_codec(co);
}
int sis_ac97_read_proc(char *page,char **start,off_t off,int count,int *eof,void *data)
{
return ac97_read_proc(page,start,off,count,eof,data);
}
/******************************************task routine************************/
void sis_udelay(unsigned long delay)
{
udelay(delay);
}
void sis_mdelay(unsigned long delay)
{
mdelay(delay);
}
#if LINUX_VERSION_CODE>=131858
void sis_interruptible_sleep_on_timeout(wait_handle *p,signed long tout)
{
wait_queue_head_t *w = (wait_queue_head_t *) p;
if (w == NULL)
{
printk ("tsleep wait_handle == NULL\n");
return;
}
interruptible_sleep_on_timeout (w, tout);
}
#else
void sis_interruptible_sleep_on_timeout(wait_handle **p,signed long tout)
{
struct wait_queue **w = (struct wait_queue **) p;
if (w == NULL)
{
printk ("tsleep wait_handle == NULL\n");
return;
}
interruptible_sleep_on_timeout (w, tout);
}
#endif
void sis_schedule_timeout(signed long timeout)
{
// current->state = TASK_INTERRUPTIBLE;
schedule_timeout(timeout);
}
#if LINUX_VERSION_CODE>=131858
void sis_wake_up (wait_handle * p)
{
wait_queue_head_t *w = (wait_queue_head_t *) p;
if (w == NULL)
{
printk ("wake wait_handle == NULL\n");
return;
}
wake_up (w);
}
#else
void sis_wake_up (wait_handle ** p)
{
struct wait_queue **w = (struct wait_queue **) p;
if (w == NULL)
{
printk ("wake wait_handle == NULL\n");
return;
}
wake_up (w);
}
#endif
#if LINUX_VERSION_CODE >= 131858
void sis_add_wait_queue(wait_handle *q,wait_handle *new)
{
wait_queue_head_t *w;
wait_queue_t *n;
w = (wait_queue_head_t *) q;
n = (wait_queue_t *) new;
add_wait_queue(w,n);
}
#else
void sis_add_wait_queue(wait_handle **q,wait_handle *new)
{
struct wait_queue **w;
struct wait_queue *n;
w = (struct wait_queue **) q;
n = (struct wait_queue *) new;
add_wait_queue(w,n);
}
#endif
#if LINUX_VERSION_CODE >= 131858
void sis_remove_wait_queue(wait_handle * head, wait_handle * old)
{
wait_queue_head_t *h;
wait_queue_t *o;
h = (wait_queue_head_t *) head;
o = (wait_queue_t *) old;
remove_wait_queue(h,o);
}
#else
void sis_remove_wait_queue(wait_handle ** head, wait_handle * old)
{
struct wait_queue **h;
struct wait_queue *o;
h = (struct wait_queue **) head;
o = (struct wait_queue *) old;
remove_wait_queue(h,o);
}
#endif
static wait_handle * sis_declare_waitqueue(void)
{
// DECLARE_WAITQUEUE(wait,current);
wait_queue_t *wa = (wait_queue_t *)kmalloc(sizeof(wait_queue_t),GFP_KERNEL);
wa->flags = 0x0;
wa->task = current;
wa->task_list.next = NULL;
wa->task_list.prev = NULL;
#if WAITQUEUE_DEBUG
wa->__magic = (long)&(current).__magic;
wa->__creator = 0;
#endif
return ((wait_handle *) wa);
}
static void sis_remove_queue(wait_handle * wait)
{
wait_queue_t * wa = (wait_queue_t *)wait;
kfree(wa);
}
void sis_init_waitqueue_head(wait_handle * wait)
{
wait_queue_head_t *w = (wait_queue_head_t *) wait;
init_waitqueue_head(w);
}
#if LINUX_VERSION_CODE>= 131858
void sis_poll_wait (file_handle * filp, wait_handle * wait_address,poll_table_handle * p)
{
wait_queue_head_t * w = (wait_queue_head_t *) wait_address;
poll_table *t = (poll_table *) p;
struct file *fil = (struct file *) filp;
poll_wait(fil,w,t);
// return poll_wait(filp,wait_address,p);
}
#else
void sis_poll_wait (file_handle * filp, wait_handle ** wait_address,poll_table_handle * p)
{
struct wait_queue ** w = (struct wait_queue **) wait_address;
poll_table *t = (poll_table *) p;
struct file *fil = (struct file *) filp;
poll_wait(fil,w,t);
// return poll_wait(filp,wait_address,p);
}
#endif
/***********************************io routing**************************/
void sis_request_region(unsigned long start,unsigned long n,const char *name)
{
request_region(start,n,name);
}
void sis_release_region(unsigned long start,unsigned long range)
{
return release_region(start,range);
}
int sis_check_region(unsigned long from, unsigned long extent)
{
return check_region (from, extent);
}
/***********************************user interface routing******************/
void sis_copy_from_user(void *to,const void *from, unsigned long n)
{
copy_from_user(to,from,n);
}
void sis_copy_to_user(void *to,const void *from, unsigned long n)
{
copy_to_user(to,from,n);
}
int sis_printk(const char * fmt)
{
return printk(fmt);
}
void sis_print_size(unsigned int size,const char *str)
{
printk("%s size %x\n",str,size);
}
/******************************pci routine***************************************/
/*#if LINUX_VERSION_CODE >= 132096
unsigned long sis_pci_resource_start(struct pci_dev *pci_dev,int unit)
{
return pci_resource_start(pci_dev,unit);
}
#endif*/ //arthurlee@030207 mask
int sis_pci_present(void)
{
return pci_present();
}
int sis_pcibios_find_device(unsigned short vendor,unsigned short device,unsigned short index,unsigned char *bus,unsigned char *fun)
{
return pcibios_find_device(vendor,device,index,bus,fun);
}
int sis_pcibios_write_config_byte(unsigned char bus,unsigned char fun,unsigned char where,unsigned char val)
{
return pcibios_write_config_byte(bus,fun,where,val);
}
int sis_pcibios_read_config_byte(unsigned char bus,unsigned char fun,unsigned char where,unsigned char *val)
{
return pcibios_read_config_byte(bus,fun,where,val);
}
/*
int sis_pci_set_dma_mask(struct pci_dev *hw,dma_addr_t mask)
{
return pci_set_dma_mask(hw,mask);
}
*/
#if LINUX_VERSION_CODE >= 132096
int sis_pci_dma_supported(pci_dev_handle *hwdev,dma_addr_t mask)
{
return pci_dma_supported((struct pci_dev *)hwdev,mask);
}
//void sis_pci_unregister_driver(struct pci_driver *drv)
//{
// pci_unregister_driver(drv);
//}
//int sis_pci_register_driver(struct pci_driver *drv)
//{
// return pci_register_driver(drv);
//}
int sis_pci_enable_device(pci_dev_handle *dev)
{
return pci_enable_device((struct pci_dev *)dev);
}
/***************************************************************************/
unsigned long sis_pci_resource_start(pci_dev_handle *dev,int unit) //arthurlee@030207
{
return pci_resource_start((struct pci_dev *)dev,unit);
}
unsigned long sis_pci_resource_len(pci_dev_handle *dev,int unit)
{
return pci_resource_len((struct pci_dev *)dev,unit);
}
void sis_pci_release_regions(pci_dev_handle *dev)
{
pci_release_regions((struct pci_dev *)dev);
}
/***************************************************************************/
// by sunburst 2002/3/19 with 70196.c, try to trans pci_dev and pci_driver
void * sis_pci_alloc_consistent(pci_dev_handle *hwdev,size_t size,dma_addr_handle *dmahandle)
{
struct pci_dev *hw = (struct pci_dev *) hwdev;
return pci_alloc_consistent(hw,size,(dma_addr_t *)dmahandle);
}
void sis_pci_free_consistent(pci_dev_handle *hwdev,size_t size,void *vaddr,dma_addr_handle *dmahandle)
{
struct pci_dev *hw = (struct pci_dev *) hwdev;
dma_addr_t *dh = (dma_addr_t *)dmahandle;
pci_free_consistent(hw,size,vaddr,*dh);
}
void sis_pci_read_config_byte(unsigned short vendor, unsigned short device,int where,u8 *val)
{
struct pci_dev *dev = NULL;
dev = pci_find_device(vendor, device, dev);
pci_read_config_byte(dev,where,val);
}
unsigned long sis_pciread(unsigned long vendor,unsigned long device,unsigned long offset,unsigned long mask)
{
unsigned long check = vendor | (device<<16);
unsigned long i;
unsigned long result;
unsigned long regVal;
int found = 0;
for(i=0x80000000;i<0x8000ff00;i+=0x100)
{
outl(i, 0xcf8);
if(inl(0xcfc)==check)
{
found = 1;
break;
}
}
if(found)
{
outl(i+offset, 0xcf8);
regVal = inl(0xcfc);
result=(unsigned long)regVal&mask;
//printk("iobase %x\n",AudioBase);
return(result);
}
return 0;
}
//void *sis_pci_alloc_consistent(size_t size, dma_addr_handle *dma_handle)
//{
// void *ret;
// int gfp = GFP_ATOMIC;
// dma_addr_t * addr= (dma_addr_t *) dma_handle;
// ret = (void *)__get_free_pages(gfp,get_order(size));
// if(ret != NULL) {
// memset(ret,0,size);
// *addr = virt_to_bus(ret);
// }
// return ret;
//}
//void sis_pci_free_consistent(size_t size,void *vaddr, dma_addr_handle * dma_handle)
//{
// free_pages((unsigned long) vaddr, get_order(size));
//}
#endif
//void sis_pci_set_master(unsigned short vendor,unsigned short device)
//{
// struct pci_dev *dev = NULL;
// dev = pci_find_device(vendor,device,dev);
// pci_set_master(dev);
//}
void sis_pci_set_master(pci_dev_handle *pci_dev)
{
pci_set_master((struct pci_dev *)pci_dev);
}
/**********************************soundcore routine****************************/
void sis_unregister_sound_synth(int unit)
{
return unregister_sound_synth(unit);
}
void sis_unregister_sound_dsp(int unit)
{
unregister_sound_dsp(unit);
kfree(audiofop);
}
void sis_unregister_sound_midi(int unit)
{
return unregister_sound_midi(unit);
}
void sis_unregister_sound_mixer(int unit)
{
unregister_sound_mixer(unit);
kfree(mixerfop);
}
void sis_unregister_sound_special(int unit)
{
return unregister_sound_special(unit);
}
int sis_register_sound_synth(struct file_operations *fops,int dev)
{
return register_sound_synth(fops,dev);
}
int sis_register_sound_midi(struct file_operations *fops,int dev)
{
return register_sound_midi(fops,dev);
}
int sis_register_sound_special(struct file_operations *fops,int unit)
{
return register_sound_special(fops,unit);
}
int sis_register_sound_mixer(struct file_operation_handle *fops, int dev)
{
return register_sound_mixer(alloc_fop(fops,mixerfop),dev);
}
int sis_register_sound_dsp(struct file_operation_handle *fops, int dev)
{
return register_sound_dsp(alloc_fop(fops,audiofop),dev);
}
int
init_wrapper (void)
{
wrapper_initialized = 1;
#if WAITQUEUE_DEBUG
printk("sis7019 : WAITQUEUE_DEBUG = 1 maybe result in errors with this driver\n");
printk("sis7019 : Stop to active this driver\n");
return 0;
#endif
return 1;
}
/*************************cli,save_flags,restore_flags***********/
static void sis_cli(void)
{
cli();
}
static void sis_save_flags(unsigned long *flags)
{
save_flags(*flags);
}
static void sis_restore_flags(unsigned long *flags)
{
restore_flags(*flags);
}
///////////////////////ac97 set/get routine////////////////////////
size_t ac97_getsize(void)
{
return sizeof(struct ac97_codec);
}
void * ac97_get_private(ac97_codec_handle * codec)
{
struct ac97_codec * ac97 = (struct ac97_codec *) codec;
return ac97->private_data;
}
int ac97_get_dev_mixer(ac97_codec_handle * codec)
{
return ((struct ac97_codec *)codec)->dev_mixer;
}
void ac97_set_private(ac97_codec_handle *codec,void * private)
{
((struct ac97_codec *)codec)->private_data = private;
}
void ac97_set_id(ac97_codec_handle *codec,int id)
{
((struct ac97_codec *)codec)->id = id;
}
int ac97_get_id(ac97_codec_handle *codec)
{
return ((struct ac97_codec *)codec)->id;
}
void ac97_set_codec_read(ac97_codec_handle *codec,phandle *p)
{
ac97_read_t tmp = (ac97_read_t) p;
((struct ac97_codec *)codec)->codec_read = tmp;
}
void ac97_set_codec_write(ac97_codec_handle *codec,phandle *p)
{
ac97_write_t tmp = (ac97_write_t) p;
((struct ac97_codec *)codec)->codec_write = tmp;
}
int ac97_set_dev_mixer(ac97_codec_handle *codec,struct file_operation_handle *fp)
{
struct ac97_codec * co = (struct ac97_codec *) codec;
if((co->dev_mixer = register_sound_mixer(alloc_fop(fp,mixerfop),-1))<0)
return 1;
else
return 0;
}
int sis_ac97_mixer_ioctl(ac97_codec_handle *codec,unsigned int cmd,unsigned long arg)
{
return ((struct ac97_codec *)codec)->mixer_ioctl((struct ac97_codec *)codec,cmd,arg);
}
u16 ac97_test(ac97_codec_handle * codec)
{
return ((struct ac97_codec *)codec)->codec_read((struct ac97_codec *)codec,AC97_PCM_FRONT_DAC_RATE);
}
///////////////////////inode routine////////////////////////////////////
int inode_get_i_rdev(inode_handle *inode)
{
return MINOR(((struct inode *)inode)->i_rdev);
}
////////////////////////mutex routine///////////////////////////////////
void sis_init_MUTEX(semaphore_handle *sem)
{
init_MUTEX((struct semaphore *)sem);
}
void sis_up(struct semaphore * sem)
{
up(sem);
}
void sis_down(struct semaphore *sem)
{
down(sem);
}
///////////////////////current routine////////////////////////////////
static task_handle * sis_get_current(void)
{
return (task_handle *) current;
}
static void sis_set_current_state(long flags)
{
current->state = flags;
}
static int sis_got_signal(void)
{
return signal_pending(current);
}
////////////////////////checking routine///////////////////////////
static int sis_chk_dma_addr_t(void)
{
//#ifdef CONFIG_HIGHMEM
// printk("sis : Using 64-bit DMA addresses\n");
// return 0;
//#endif
if(sizeof(dma_addr_t)==sizeof(unsigned int))
return 1;
else
return 0;
}
///////////////////////no use routine/////////////////////////////////
void dont_use_this_function(void)
{
unsigned long flags;
char k[32];
wait_handle *wait;
sis_cli();
sis_save_flags(&flags);
sis_restore_flags(&flags);
wait = sis_declare_waitqueue();
sis_remove_queue((wait_handle *)wait);
sis_get_current();
sis_got_signal();
sis_set_current_state(0);
strcpy(k,kernel_version);
sis_chk_dma_addr_t();
}
//////////////////////////pci register driver routine////////////////////////
int sis_pci_register_driver(struct pci_driver_handle *pd)
{
return pci_register_driver(alloc_pci_driver(pd));
}
void sis_pci_unregister_driver(struct pci_driver_handle *pd)
{
pci_unregister_driver(pcidvr);
kfree(pcidvr);
}
//////////////////////////pci set/get routine/////////////////////////////////
void sis_pci_set_drvdata(pci_dev_handle *ph,void *data)
{
((struct pci_dev *)ph)->driver_data = data;
}
void * sis_pci_get_drvdata(pci_dev_handle *ph)
{
return ((struct pci_dev *)ph)->driver_data;
}
void sis_pci_set_dma_mask(pci_dev_handle *ph,u64 mask)
{
((struct pci_dev *)ph)->dma_mask = mask;
}
//////////////////////////test routine///////////////////////////////////////
#define SIS_OP(deviceID) \
void deviceID##_help(void) \
{ \
printk("test success\n"); \
}
SIS_OP(sis);