diff -Naur --exclude-from /home/mulix/work/dontdiff linux-2.4.19-rc1-ac4/drivers/sound/trident.c linux-2.4.19-rc1-ac4-mx/drivers/sound/trident.c --- linux-2.4.19-rc1-ac4/drivers/sound/trident.c Mon Jul 15 23:58:04 2002 +++ linux-2.4.19-rc1-ac4-mx/drivers/sound/trident.c Tue Jul 16 00:36:55 2002 @@ -36,6 +36,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * History + * v0.14.10c + * July 16 2002 Muli Ben-Yehuda + * Cleaned up Hei Lu's 0.4.10 driver to conform to Documentation/CodingStyle + * and the coding style used in the rest of the file. * v0.14.10b * June 23 2002 Muli Ben-Yehuda * add a missing unlock_set_fmt, remove a superflous lock/unlock pair @@ -191,7 +195,7 @@ #include -#define DRIVER_VERSION "0.14.10b" +#define DRIVER_VERSION "0.14.10c" /* magic numbers to protect our data structures */ #define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */ @@ -2685,7 +2689,6 @@ struct trident_state *state = (struct trident_state *)file->private_data; struct trident_card *card; struct dmabuf *dmabuf; - unsigned long flags; lock_kernel(); card = state->card; @@ -2871,71 +2874,65 @@ } /* rewrite ac97 read and write mixer register by hulei for ALI*/ -static int acquirecodecaccess(struct trident_card * card ) +static int acquirecodecaccess(struct trident_card *card) { u16 wsemamask=0x6000; /* bit 14..13 */ u16 wsemabits; u16 wcontrol ; - int block =0; - int ncount =25; - while(1) - { - wcontrol=inw(TRID_REG(card, ALI_AC97_WRITE)); - wsemabits=(wcontrol) & wsemamask; - - if(wsemabits==0x4000) - return 1; /* 0x4000 is audio ,then success */ - if(ncount--<0) - break; - if(wsemabits==0) - { -unlock: - outl(((u32)(wcontrol & 0x1eff)|0x00004000), TRID_REG(card, ALI_AC97_WRITE)); - continue; - } - udelay(20); - + int block = 0; + int ncount = 25; + while (1) { + wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); + wsemabits = wcontrol & wsemamask; + + if (wsemabits==0x4000) + return 1; /* 0x4000 is audio ,then success */ + if (ncount-- < 0) + break; + if (wsemabits == 0) + { + unlock: + outl(((u32)(wcontrol & 0x1eff)|0x00004000), TRID_REG(card, ALI_AC97_WRITE)); + continue; + } + udelay(20); } if(!block) { - printk("accesscodecsemaphore : try unlock \n"); - block=1; -goto unlock; + printk(KERN_NOTICE "accesscodecsemaphore: try unlock\n"); + block = 1; + goto unlock; } - printk("accesscodecsemaphore :fail\n"); + printk(KERN_ERR "accesscodecsemaphore: fail\n"); return 0; } -static void releasecodecaccess(struct trident_card * card ) +static void releasecodecaccess(struct trident_card *card) { unsigned long wcontrol; - wcontrol=inl(TRID_REG(card, ALI_AC97_WRITE)); - outl((wcontrol & 0xffff1eff),TRID_REG(card, ALI_AC97_WRITE)); + wcontrol = inl(TRID_REG(card, ALI_AC97_WRITE)); + outl((wcontrol & 0xffff1eff), TRID_REG(card, ALI_AC97_WRITE)); } -static int waitforstimertick(struct trident_card * card ) +static int waitforstimertick(struct trident_card *card) { -unsigned long chk1, chk2; -unsigned int wcount= 0xffff; -chk1 = inl(TRID_REG(card, ALI_STIMER)); - -while(1) -{ - chk2 = inl(TRID_REG(card, ALI_STIMER)); - if( (wcount > 0 )&& chk1!=chk2) - return 1; - if(wcount <= 0) - break; - udelay(50); + unsigned long chk1, chk2; + unsigned int wcount = 0xffff; + chk1 = inl(TRID_REG(card, ALI_STIMER)); + + while(1) { + chk2 = inl(TRID_REG(card, ALI_STIMER)); + if( (wcount > 0) && chk1 != chk2) + return 1; + if(wcount <= 0) + break; + udelay(50); + } -} -printk(" waitforstimertick :BIT_CLK is dead \n"); -return 0; + printk(KERN_NOTICE "waitforstimertick :BIT_CLK is dead\n"); + return 0; } - - - /* Read AC97 codec registers for ALi*/ static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg) { @@ -2956,56 +2953,43 @@ if (secondary) mask |= ALI_AC97_SECONDARY; - + if (!acquirecodecaccess(card)) + printk(KERN_ERR "access codec fail\n"); - - if( !acquirecodecaccess(card)) - { - printk(" access codec fail \n"); - - } - - wcontrol=inw(TRID_REG(card, ALI_AC97_WRITE)); - wcontrol &=0xfe00; - wcontrol |=(0x8000|reg); + wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); + wcontrol &= 0xfe00; + wcontrol |= (0x8000|reg); outw(wcontrol,TRID_REG(card, ALI_AC97_WRITE)); - - - data = (mask | (reg & AC97_REG_ADDR)); - if(!waitforstimertick(card)) - { - printk(" BIT_CLOCK is dead \n"); - goto l; + if(!waitforstimertick(card)) { + printk(KERN_ERR "BIT_CLOCK is dead\n"); + goto releasecodec; } - + udelay(20); - - ncount=10; - - while(1) - { - if ((inw(TRID_REG(card,ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) != 0) - break; - if(ncount <=0) - break; - if(ncount--==1) - { - printk("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)); - } - udelay(10); - } - - data = inl(TRID_REG(card, address)); - - return ((u16) (data >> 16)); - -l: + ncount=10; + + while(1) { + if ((inw(TRID_REG(card,ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) != 0) + break; + if(ncount <=0) + break; + if(ncount--==1) { + printk(KERN_NOTICE "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)); + } + udelay(10); + } + + data = inl(TRID_REG(card, address)); + + return ((u16) (data >> 16)); + + releasecodec: releasecodecaccess(card); printk(KERN_ERR "ali: AC97 CODEC read timed out.\n"); return 0; @@ -3019,12 +3003,12 @@ unsigned int ncount; u32 data; u16 wcontrol; - + data = ((u32) val) << 16; - + if(!card) BUG(); - + address = ALI_AC97_WRITE; mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY; if (secondary) @@ -3032,49 +3016,38 @@ if (card->revision == ALI_5451_V02) mask |= ALI_AC97_WRITE_MIXER_REGISTER; - - - if(!acquirecodecaccess(card)) - printk("access codec fail \n"); + if (!acquirecodecaccess(card)) + printk(KERN_ERR "access codec fail\n"); - - - wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); - wcontrol &=0xff00; - wcontrol |=(0x8100|reg);/* bit 8=1: (ali1535 )reserved /ali1535+ write */ - outl(( data |wcontrol), TRID_REG(card,ALI_AC97_WRITE )); - - if(!waitforstimertick(card)) - { - printk(" BIT_CLOCK is dead \n"); - goto l1; + wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); + wcontrol &= 0xff00; + wcontrol |= (0x8100|reg);/* bit 8=1: (ali1535 )reserved /ali1535+ write */ + outl(( data |wcontrol), TRID_REG(card,ALI_AC97_WRITE )); + + if(!waitforstimertick(card)) { + printk(KERN_ERR "BIT_CLOCK is dead\n"); + goto releasecodec; } - + ncount = 10; - while(1) - { - - wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); - if(!wcontrol & 0x8000) - break; - if(ncount <=0) - break; - if(ncount--==1) - { - printk(" ali_ac97_set :try clear busy flag!!\n"); - outw(wcontrol & 0x7fff, TRID_REG(card, ALI_AC97_WRITE)); - } - udelay(10); - } - -l1: - releasecodecaccess(card); - return; + while(1) { + wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE)); + if(!wcontrol & 0x8000) + break; + if(ncount <= 0) + break; + if(ncount-- == 1) { + printk(KERN_NOTICE "ali_ac97_set :try clear busy flag!!\n"); + outw(wcontrol & 0x7fff, TRID_REG(card, ALI_AC97_WRITE)); + } + udelay(10); + } + + releasecodec: + releasecodecaccess(card); + return; } - - - static void ali_enable_special_channel(struct trident_state *stat) { struct trident_card *card = stat->card;