Commit d82f87c9 authored by Alan Cox's avatar Alan Cox Committed by Steve French

[PATCH] update trident driver for new ac97 etc

parent 2641853b
......@@ -37,6 +37,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* History
* v0.14.10h
* Sept 10 2002 Pascal Schmidt <der.eremit@email.de>
* added support for ALi 5451 joystick port
* v0.14.10g
* Sept 05 2002 Alan Cox <alan@redhat.com>
* adapt to new pci joystick attachment interface
* v0.14.10f
* July 24 2002 Muli Ben-Yehuda <mulix@actcom.co.il>
* patch from Eric Lemar (via Ian Soboroff): in suspend and resume,
......@@ -212,7 +218,7 @@
#include "trident.h"
#define DRIVER_VERSION "0.14.10f"
#define DRIVER_VERSION "0.14.10h-2.5"
/* magic numbers to protect our data structures */
#define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */
......@@ -538,7 +544,7 @@ static int trident_enable_loop_interrupts(struct trident_card * card)
outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
pr_debug("trident: Enable Loop Interrupts, globctl = 0x%08X\n",
TRDBG("trident: Enable Loop Interrupts, globctl = 0x%08X\n",
inl(TRID_REG(card, T4D_LFO_GC_CIR)));
return (TRUE);
......@@ -552,7 +558,7 @@ static int trident_disable_loop_interrupts(struct trident_card * card)
global_control &= ~(ENDLP_IE | MIDLP_IE);
outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
pr_debug("trident: Disabled Loop Interrupts, globctl = 0x%08X\n",
TRDBG("trident: Disabled Loop Interrupts, globctl = 0x%08X\n",
global_control);
return (TRUE);
......@@ -570,7 +576,7 @@ static void trident_enable_voice_irq(struct trident_card * card, unsigned int ch
#ifdef DEBUG
reg = inl(TRID_REG(card, addr));
pr_debug("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
TRDBG("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
#endif /* DEBUG */
}
......@@ -590,7 +596,7 @@ static void trident_disable_voice_irq(struct trident_card * card, unsigned int c
#ifdef DEBUG
reg = inl(TRID_REG(card, addr));
pr_debug("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
TRDBG("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
#endif /* DEBUG */
}
......@@ -609,7 +615,7 @@ static void trident_start_voice(struct trident_card * card, unsigned int channel
#ifdef DEBUG
reg = inl(TRID_REG(card, addr));
pr_debug("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n",
TRDBG("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n",
channel, addr==T4D_START_B? "START_B":"START_A",reg,addr);
#endif /* DEBUG */
}
......@@ -628,7 +634,7 @@ static void trident_stop_voice(struct trident_card * card, unsigned int channel)
#ifdef DEBUG
reg = inl(TRID_REG(card, addr));
pr_debug("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n",
TRDBG("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n",
channel, addr==T4D_STOP_B? "STOP_B":"STOP_A",reg,addr);
#endif /* DEBUG */
}
......@@ -647,7 +653,7 @@ static int trident_check_channel_interrupt(struct trident_card * card, unsigned
#ifdef DEBUG
if (reg & mask)
pr_debug("trident: channel %d has interrupt, %s = 0x%08x\n",
TRDBG("trident: channel %d has interrupt, %s = 0x%08x\n",
channel,reg==T4D_AINT_B? "AINT_B":"AINT_A", reg);
#endif /* DEBUG */
return (reg & mask) ? TRUE : FALSE;
......@@ -665,7 +671,7 @@ static void trident_ack_channel_interrupt(struct trident_card * card, unsigned i
#ifdef DEBUG
reg = inl(TRID_REG(card, T4D_AINT_B));
pr_debug("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n",
TRDBG("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n",
channel, reg);
#endif /* DEBUG */
}
......@@ -914,7 +920,7 @@ static unsigned int trident_set_dac_rate(struct trident_state * state, unsigned
trident_write_voice_regs(state);
pr_debug("trident: called trident_set_dac_rate : rate = %d\n", rate);
TRDBG("trident: called trident_set_dac_rate : rate = %d\n", rate);
return rate;
}
......@@ -934,7 +940,7 @@ static unsigned int trident_set_adc_rate(struct trident_state * state, unsigned
trident_write_voice_regs(state);
pr_debug("trident: called trident_set_adc_rate : rate = %d\n", rate);
TRDBG("trident: called trident_set_adc_rate : rate = %d\n", rate);
return rate;
}
......@@ -978,7 +984,7 @@ static void trident_play_setup(struct trident_state *state)
/* stereo */
channel->control |= CHANNEL_STEREO;
pr_debug("trident: trident_play_setup, LBA = 0x%08x, "
TRDBG("trident: trident_play_setup, LBA = 0x%08x, "
"Delta = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
channel->lba, channel->delta, channel->eso, channel->control);
......@@ -1064,8 +1070,8 @@ static void trident_rec_setup(struct trident_state *state)
/* stereo */
channel->control |= CHANNEL_STEREO;
pr_debug("trident: trident_rec_setup, LBA = 0x%08x, "
"Delta = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
TRDBG("trident: trident_rec_setup, LBA = 0x%08x, "
"Delat = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
channel->lba, channel->delta, channel->eso, channel->control);
trident_write_voice_regs(state);
......@@ -1101,7 +1107,7 @@ static inline unsigned trident_get_dma_addr(struct trident_state *state)
}
pr_debug("trident: trident_get_dma_addr: chip reported channel: %d, "
TRDBG("trident: trident_get_dma_addr: chip reported channel: %d, "
"cso = 0x%04x\n", dmabuf->channel->num, cso);
/* ESO and CSO are in units of Samples, convert to byte offset */
......@@ -1211,7 +1217,7 @@ static int alloc_dmabuf(struct dmabuf* dmabuf, struct pci_dev* pci_dev, int orde
&dmabuf->dma_handle)))
return -ENOMEM;
pr_debug("trident: allocated %ld (order = %d) bytes at %p\n",
TRDBG("trident: allocated %ld (order = %d) bytes at %p\n",
PAGE_SIZE << order, order, rawbuf);
dmabuf->ready = dmabuf->mapped = 0;
......@@ -1349,11 +1355,10 @@ static int prog_dmabuf(struct trident_state *state, unsigned rec)
/* set the ready flag for the dma buffer */
dmabuf->ready = 1;
pr_debug("trident: prog_dmabuf(%d), sample rate = %d, "
"format = %d, numfrag = %d, fragsize = %d "
"dmasize = %d\n", dmabuf->channel->num, dmabuf->rate,
dmabuf->fmt, dmabuf->numfrag, dmabuf->fragsize,
dmabuf->dmasize);
TRDBG("trident: prog_dmabuf(%d), sample rate = %d, format = %d, numfrag = %d, "
"fragsize = %d dmasize = %d\n",
dmabuf->channel->num, dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
dmabuf->fragsize, dmabuf->dmasize);
}
unlock_set_fmt(state);
return 0;
......@@ -1705,7 +1710,7 @@ static void cyber_address_interrupt(struct trident_card *card)
/* FIXED: read interrupt status only once */
irq_status=inl(TRID_REG(card, T4D_AINT_A) );
pr_debug("cyber_address_interrupt: irq_status 0x%X\n",irq_status);
TRDBG("cyber_address_interrupt: irq_status 0x%X\n",irq_status);
for (i = 0; i < NR_HW_CH; i++) {
channel = 31 - i;
......@@ -1713,7 +1718,7 @@ static void cyber_address_interrupt(struct trident_card *card)
/* clear bit by writing a 1, zeroes are ignored */
outl( (1 << channel), TRID_REG(card, T4D_AINT_A));
pr_debug("cyber_interrupt: channel %d\n", channel);
TRDBG("cyber_interrupt: channel %d\n", channel);
if ((state = card->states[i]) != NULL) {
trident_update_ptr(state);
......@@ -1736,7 +1741,7 @@ static irqreturn_t trident_interrupt(int irq, void *dev_id, struct pt_regs *regs
spin_lock(&card->lock);
event = inl(TRID_REG(card, T4D_MISCINT));
pr_debug("trident: trident_interrupt called, MISCINT = 0x%08x\n", event);
TRDBG("trident: trident_interrupt called, MISCINT = 0x%08x\n", event);
if (event & ADDRESS_IRQ) {
card->address_interrupt(card);
......@@ -1775,7 +1780,7 @@ static ssize_t trident_read(struct file *file, char *buffer, size_t count, loff_
unsigned swptr;
int cnt;
pr_debug("trident: trident_read called, count = %d\n", count);
TRDBG("trident: trident_read called, count = %d\n", count);
VALIDATE_STATE(state);
if (ppos != &file->f_pos)
......@@ -1829,7 +1834,7 @@ static ssize_t trident_read(struct file *file, char *buffer, size_t count, loff_
which results in a (potential) buffer overrun. And worse, there is
NOTHING we can do to prevent it. */
if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
pr_debug(KERN_ERR "trident: recording schedule timeout, "
TRDBG(KERN_ERR "trident: recording schedule timeout, "
"dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
dmabuf->hwptr, dmabuf->swptr);
......@@ -1887,7 +1892,7 @@ static ssize_t trident_write(struct file *file, const char *buffer, size_t count
unsigned int state_cnt;
unsigned int copy_count;
pr_debug("trident: trident_write called, count = %d\n", count);
TRDBG("trident: trident_write called, count = %d\n", count);
VALIDATE_STATE(state);
if (ppos != &file->f_pos)
......@@ -1956,7 +1961,7 @@ static ssize_t trident_write(struct file *file, const char *buffer, size_t count
which results in a (potential) buffer underrun. And worse, there is
NOTHING we can do to prevent it. */
if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
pr_debug(KERN_ERR "trident: playback schedule timeout, "
TRDBG(KERN_ERR "trident: playback schedule timeout, "
"dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
dmabuf->hwptr, dmabuf->swptr);
......@@ -2139,7 +2144,7 @@ static int trident_ioctl(struct inode *inode, struct file *file, unsigned int cm
VALIDATE_STATE(state);
mapped = ((file->f_mode & FMODE_WRITE) && dmabuf->mapped) ||
((file->f_mode & FMODE_READ) && dmabuf->mapped);
pr_debug("trident: trident_ioctl, command = %2d, arg = 0x%08x\n",
TRDBG("trident: trident_ioctl, command = %2d, arg = 0x%08x\n",
_IOC_NR(cmd), arg ? *(int *)arg : 0);
switch (cmd)
......@@ -2704,7 +2709,7 @@ static int trident_open(struct inode *inode, struct file *file)
state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
up(&card->open_sem);
pr_debug("trident: open virtual channel %d, hard channel %d\n",
TRDBG("trident: open virtual channel %d, hard channel %d\n",
state->virt, dmabuf->channel->num);
return 0;
......@@ -2726,7 +2731,7 @@ static int trident_release(struct inode *inode, struct file *file)
drain_dac(state, file->f_flags & O_NONBLOCK);
}
pr_debug("trident: closing virtual channel %d, hard channel %d\n",
TRDBG("trident: closing virtual channel %d, hard channel %d\n",
state->virt, dmabuf->channel->num);
/* stop DMA state machine and free DMA buffers/channels */
......@@ -2925,11 +2930,10 @@ static int acquirecodecaccess(struct trident_card *card)
}
if(!block)
{
pr_debug("accesscodecsemaphore: try unlock\n");
TRDBG("accesscodecsemaphore: try unlock\n");
block = 1;
goto unlock;
}
printk(KERN_ERR "accesscodecsemaphore: fail\n");
return 0;
}
......@@ -2954,8 +2958,6 @@ static int waitforstimertick(struct trident_card *card)
break;
udelay(50);
}
printk(KERN_NOTICE "waitforstimertick :BIT_CLK is dead\n");
return 0;
}
......@@ -2967,6 +2969,7 @@ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
unsigned long aud_reg;
u32 data;
u16 wcontrol;
unsigned long flags;
if(!card)
BUG();
......@@ -2979,6 +2982,8 @@ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
if (secondary)
mask |= ALI_AC97_SECONDARY;
spin_lock_irqsave(&card->lock, flags);
if (!acquirecodecaccess(card))
printk(KERN_ERR "access codec fail\n");
......@@ -2990,7 +2995,7 @@ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
data = (mask | (reg & AC97_REG_ADDR));
if(!waitforstimertick(card)) {
printk(KERN_ERR "BIT_CLOCK is dead\n");
printk(KERN_ERR "ali_ac97_read: BIT_CLOCK is dead\n");
goto releasecodec;
}
......@@ -3004,7 +3009,7 @@ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
if(ncount <=0)
break;
if(ncount--==1) {
pr_debug("ali_ac97_read :try clear busy flag\n");
TRDBG("ali_ac97_read :try clear busy flag\n");
aud_reg = inl(TRID_REG(card, ALI_AC97_WRITE));
outl((aud_reg & 0xffff7fff), TRID_REG(card, ALI_AC97_WRITE));
}
......@@ -3017,7 +3022,8 @@ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
releasecodec:
releasecodecaccess(card);
printk(KERN_ERR "ali: AC97 CODEC read timed out.\n");
spin_unlock_irqrestore(&card->lock, flags);
printk(KERN_ERR "ali_ac97_read: AC97 CODEC read timed out.\n");
return 0;
}
......@@ -3029,6 +3035,7 @@ static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 v
unsigned int ncount;
u32 data;
u16 wcontrol;
unsigned long flags;
data = ((u32) val) << 16;
......@@ -3042,8 +3049,9 @@ static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 v
if (card->revision == ALI_5451_V02)
mask |= ALI_AC97_WRITE_MIXER_REGISTER;
spin_lock_irqsave(&card->lock, flags);
if (!acquirecodecaccess(card))
printk(KERN_ERR "access codec fail\n");
printk(KERN_ERR "ali_ac97_write: access codec fail\n");
wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
wcontrol &= 0xff00;
......@@ -3063,7 +3071,7 @@ static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 v
if(ncount <= 0)
break;
if(ncount-- == 1) {
pr_debug("ali_ac97_set :try clear busy flag!!\n");
TRDBG("ali_ac97_set :try clear busy flag!!\n");
outw(wcontrol & 0x7fff, TRID_REG(card, ALI_AC97_WRITE));
}
udelay(10);
......@@ -3071,6 +3079,7 @@ static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 v
releasecodec:
releasecodecaccess(card);
spin_unlock_irqrestore(&card->lock, flags);
return;
}
......@@ -3099,6 +3108,9 @@ static u16 ali_ac97_read(struct ac97_codec *codec, u8 reg)
if(!card->mixer_regs_ready)
return ali_ac97_get(card, codec->id, reg);
/*
* FIXME: need to stop this caching some registers
*/
if(codec->id)
id = 1;
else
......@@ -3366,15 +3378,17 @@ static int ali_close_multi_channels(void)
pci_dev = pci_find_device(PCI_VENDOR_ID_AL,PCI_DEVICE_ID_AL_M1533, pci_dev);
if (pci_dev == NULL)
return -1;
temp = 0x80;
pci_write_config_byte(pci_dev, 0x59, ~temp);
pci_read_config_byte(pci_dev, 0x59, &temp);
temp &= ~0x80;
pci_write_config_byte(pci_dev, 0x59, temp);
pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
if (pci_dev == NULL)
return -1;
temp = 0x20;
pci_write_config_byte(pci_dev, 0xB8, ~temp);
pci_read_config_byte(pci_dev, 0xB8, &temp);
temp &= ~0x20;
pci_write_config_byte(pci_dev, 0xB8, temp);
return 0;
}
......@@ -3388,13 +3402,15 @@ static int ali_setup_multi_channels(struct trident_card *card, int chan_nums)
pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
if (pci_dev == NULL)
return -1;
temp = 0x80;
pci_read_config_byte(pci_dev, 0x59, &temp);
temp |= 0x80;
pci_write_config_byte(pci_dev, 0x59, temp);
pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
if (pci_dev == NULL)
return -1;
temp = 0x20;
pci_read_config_byte(pci_dev, (int)0xB8, &temp);
temp |= 0x20;
pci_write_config_byte(pci_dev, (int)0xB8,(u8) temp);
if (chan_nums == 6) {
dwValue = inl(TRID_REG(card, ALI_SCTRL)) | 0x000f0000;
......@@ -3934,10 +3950,7 @@ static int ali_reset_5451(struct trident_card *card)
return 0;
udelay(5000);
}
/* This is non fatal if you have a non PM capable codec.. */
printk(KERN_ERR "ALi 5451 did not come out of reset "
"- continuing anyway.\n");
return 0;
}
......@@ -4010,9 +4023,8 @@ static int __init trident_ac97_init(struct trident_card *card)
}
for (num_ac97 = 0; num_ac97 < NR_AC97; num_ac97++) {
if ((codec = kmalloc(sizeof(struct ac97_codec), GFP_KERNEL)) == NULL)
if ((codec = ac97_alloc_codec()) == NULL)
return -ENOMEM;
memset(codec, 0, sizeof(struct ac97_codec));
/* initialize some basic codec information, other fields will be filled
in ac97_probe_codec */
......@@ -4033,7 +4045,7 @@ static int __init trident_ac97_init(struct trident_card *card)
if ((codec->dev_mixer = register_sound_mixer(&trident_mixer_fops, -1)) < 0) {
printk(KERN_ERR "trident: couldn't register mixer!\n");
kfree(codec);
ac97_release_codec(codec);
break;
}
......@@ -4258,7 +4270,7 @@ static int __init trident_probe(struct pci_dev *pci_dev, const struct pci_device
for (i = 0; i < NR_AC97; i++) {
if (card->ac97_codec[i] != NULL) {
unregister_sound_mixer(card->ac97_codec[i]->dev_mixer);
kfree (card->ac97_codec[i]);
ac97_release_codec(card->ac97_codec[i]);
}
}
goto out_unregister_sound_dsp;
......@@ -4358,7 +4370,7 @@ static void __devexit trident_remove(struct pci_dev *pci_dev)
for (i = 0; i < NR_AC97; i++)
if (card->ac97_codec[i] != NULL) {
unregister_sound_mixer(card->ac97_codec[i]->dev_mixer);
kfree (card->ac97_codec[i]);
ac97_release_codec(card->ac97_codec[i]);
}
unregister_sound_dsp(card->dev_audio);
......
......@@ -360,4 +360,16 @@ static inline unsigned ld2(unsigned int x)
return r;
}
#ifdef DEBUG
#define TRDBG(msg, args...) do { \
printk(KERN_DEBUG msg , ##args ); \
} while (0)
#else /* !defined(DEBUG) */
#define TRDBG(msg, args...) do { } while (0)
#endif /* DEBUG */
#endif /* __TRID4DWAVE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment