aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/fm801.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/fm801.c')
-rw-r--r--sound/pci/fm801.c226
1 files changed, 121 insertions, 105 deletions
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index db18ccabadd6..529f5f4f4c9c 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/io.h>
26#include <linux/pci.h> 27#include <linux/pci.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/module.h> 29#include <linux/module.h>
@@ -34,8 +35,6 @@
34#include <sound/opl3.h> 35#include <sound/opl3.h>
35#include <sound/initval.h> 36#include <sound/initval.h>
36 37
37#include <asm/io.h>
38
39#ifdef CONFIG_SND_FM801_TEA575X_BOOL 38#ifdef CONFIG_SND_FM801_TEA575X_BOOL
40#include <media/tea575x.h> 39#include <media/tea575x.h>
41#endif 40#endif
@@ -80,7 +79,10 @@ MODULE_PARM_DESC(radio_nr, "Radio device numbers");
80 * Direct registers 79 * Direct registers
81 */ 80 */
82 81
83#define FM801_REG(chip, reg) (chip->port + FM801_##reg) 82#define fm801_writew(chip,reg,value) outw((value), chip->port + FM801_##reg)
83#define fm801_readw(chip,reg) inw(chip->port + FM801_##reg)
84
85#define fm801_writel(chip,reg,value) outl((value), chip->port + FM801_##reg)
84 86
85#define FM801_PCM_VOL 0x00 /* PCM Output Volume */ 87#define FM801_PCM_VOL 0x00 /* PCM Output Volume */
86#define FM801_FM_VOL 0x02 /* FM Output Volume */ 88#define FM801_FM_VOL 0x02 /* FM Output Volume */
@@ -156,21 +158,27 @@ MODULE_PARM_DESC(radio_nr, "Radio device numbers");
156#define FM801_GPIO_GS3 (1<<15) 158#define FM801_GPIO_GS3 (1<<15)
157#define FM801_GPIO_GS(x) (1<<(12+(x))) 159#define FM801_GPIO_GS(x) (1<<(12+(x)))
158 160
159/* 161/**
160 162 * struct fm801 - describes FM801 chip
163 * @port: I/O port number
164 * @multichannel: multichannel support
165 * @secondary: secondary codec
166 * @secondary_addr: address of the secondary codec
167 * @tea575x_tuner: tuner access method & flags
168 * @ply_ctrl: playback control
169 * @cap_ctrl: capture control
161 */ 170 */
162
163struct fm801 { 171struct fm801 {
164 int irq; 172 int irq;
165 173
166 unsigned long port; /* I/O port number */ 174 unsigned long port;
167 unsigned int multichannel: 1, /* multichannel support */ 175 unsigned int multichannel: 1,
168 secondary: 1; /* secondary codec */ 176 secondary: 1;
169 unsigned char secondary_addr; /* address of the secondary codec */ 177 unsigned char secondary_addr;
170 unsigned int tea575x_tuner; /* tuner access method & flags */ 178 unsigned int tea575x_tuner;
171 179
172 unsigned short ply_ctrl; /* playback control */ 180 unsigned short ply_ctrl;
173 unsigned short cap_ctrl; /* capture control */ 181 unsigned short cap_ctrl;
174 182
175 unsigned long ply_buffer; 183 unsigned long ply_buffer;
176 unsigned int ply_buf; 184 unsigned int ply_buf;
@@ -222,6 +230,30 @@ MODULE_DEVICE_TABLE(pci, snd_fm801_ids);
222 * common I/O routines 230 * common I/O routines
223 */ 231 */
224 232
233static bool fm801_ac97_is_ready(struct fm801 *chip, unsigned int iterations)
234{
235 unsigned int idx;
236
237 for (idx = 0; idx < iterations; idx++) {
238 if (!(fm801_readw(chip, AC97_CMD) & FM801_AC97_BUSY))
239 return true;
240 udelay(10);
241 }
242 return false;
243}
244
245static bool fm801_ac97_is_valid(struct fm801 *chip, unsigned int iterations)
246{
247 unsigned int idx;
248
249 for (idx = 0; idx < iterations; idx++) {
250 if (fm801_readw(chip, AC97_CMD) & FM801_AC97_VALID)
251 return true;
252 udelay(10);
253 }
254 return false;
255}
256
225static int snd_fm801_update_bits(struct fm801 *chip, unsigned short reg, 257static int snd_fm801_update_bits(struct fm801 *chip, unsigned short reg,
226 unsigned short mask, unsigned short value) 258 unsigned short mask, unsigned short value)
227{ 259{
@@ -244,73 +276,54 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97,
244 unsigned short val) 276 unsigned short val)
245{ 277{
246 struct fm801 *chip = ac97->private_data; 278 struct fm801 *chip = ac97->private_data;
247 int idx;
248 279
249 /* 280 /*
250 * Wait until the codec interface is not ready.. 281 * Wait until the codec interface is not ready..
251 */ 282 */
252 for (idx = 0; idx < 100; idx++) { 283 if (!fm801_ac97_is_ready(chip, 100)) {
253 if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) 284 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
254 goto ok1; 285 return;
255 udelay(10);
256 } 286 }
257 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
258 return;
259 287
260 ok1:
261 /* write data and address */ 288 /* write data and address */
262 outw(val, FM801_REG(chip, AC97_DATA)); 289 fm801_writew(chip, AC97_DATA, val);
263 outw(reg | (ac97->addr << FM801_AC97_ADDR_SHIFT), FM801_REG(chip, AC97_CMD)); 290 fm801_writew(chip, AC97_CMD, reg | (ac97->addr << FM801_AC97_ADDR_SHIFT));
264 /* 291 /*
265 * Wait until the write command is not completed.. 292 * Wait until the write command is not completed..
266 */ 293 */
267 for (idx = 0; idx < 1000; idx++) { 294 if (!fm801_ac97_is_ready(chip, 1000))
268 if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) 295 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n",
269 return; 296 ac97->num);
270 udelay(10);
271 }
272 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
273} 297}
274 298
275static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short reg) 299static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short reg)
276{ 300{
277 struct fm801 *chip = ac97->private_data; 301 struct fm801 *chip = ac97->private_data;
278 int idx;
279 302
280 /* 303 /*
281 * Wait until the codec interface is not ready.. 304 * Wait until the codec interface is not ready..
282 */ 305 */
283 for (idx = 0; idx < 100; idx++) { 306 if (!fm801_ac97_is_ready(chip, 100)) {
284 if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) 307 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
285 goto ok1; 308 return 0;
286 udelay(10);
287 } 309 }
288 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
289 return 0;
290 310
291 ok1:
292 /* read command */ 311 /* read command */
293 outw(reg | (ac97->addr << FM801_AC97_ADDR_SHIFT) | FM801_AC97_READ, 312 fm801_writew(chip, AC97_CMD,
294 FM801_REG(chip, AC97_CMD)); 313 reg | (ac97->addr << FM801_AC97_ADDR_SHIFT) | FM801_AC97_READ);
295 for (idx = 0; idx < 100; idx++) { 314 if (!fm801_ac97_is_ready(chip, 100)) {
296 if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) 315 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n",
297 goto ok2; 316 ac97->num);
298 udelay(10); 317 return 0;
299 } 318 }
300 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
301 return 0;
302 319
303 ok2: 320 if (!fm801_ac97_is_valid(chip, 1000)) {
304 for (idx = 0; idx < 1000; idx++) { 321 dev_err(chip->card->dev,
305 if (inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_VALID) 322 "AC'97 interface #%d is not valid (2)\n", ac97->num);
306 goto ok3; 323 return 0;
307 udelay(10);
308 } 324 }
309 dev_err(chip->card->dev, "AC'97 interface #%d is not valid (2)\n", ac97->num);
310 return 0;
311 325
312 ok3: 326 return fm801_readw(chip, AC97_DATA);
313 return inw(FM801_REG(chip, AC97_DATA));
314} 327}
315 328
316static unsigned int rates[] = { 329static unsigned int rates[] = {
@@ -384,7 +397,7 @@ static int snd_fm801_playback_trigger(struct snd_pcm_substream *substream,
384 snd_BUG(); 397 snd_BUG();
385 return -EINVAL; 398 return -EINVAL;
386 } 399 }
387 outw(chip->ply_ctrl, FM801_REG(chip, PLY_CTRL)); 400 fm801_writew(chip, PLY_CTRL, chip->ply_ctrl);
388 spin_unlock(&chip->reg_lock); 401 spin_unlock(&chip->reg_lock);
389 return 0; 402 return 0;
390} 403}
@@ -419,7 +432,7 @@ static int snd_fm801_capture_trigger(struct snd_pcm_substream *substream,
419 snd_BUG(); 432 snd_BUG();
420 return -EINVAL; 433 return -EINVAL;
421 } 434 }
422 outw(chip->cap_ctrl, FM801_REG(chip, CAP_CTRL)); 435 fm801_writew(chip, CAP_CTRL, chip->cap_ctrl);
423 spin_unlock(&chip->reg_lock); 436 spin_unlock(&chip->reg_lock);
424 return 0; 437 return 0;
425} 438}
@@ -457,12 +470,13 @@ static int snd_fm801_playback_prepare(struct snd_pcm_substream *substream)
457 } 470 }
458 chip->ply_ctrl |= snd_fm801_rate_bits(runtime->rate) << FM801_RATE_SHIFT; 471 chip->ply_ctrl |= snd_fm801_rate_bits(runtime->rate) << FM801_RATE_SHIFT;
459 chip->ply_buf = 0; 472 chip->ply_buf = 0;
460 outw(chip->ply_ctrl, FM801_REG(chip, PLY_CTRL)); 473 fm801_writew(chip, PLY_CTRL, chip->ply_ctrl);
461 outw(chip->ply_count - 1, FM801_REG(chip, PLY_COUNT)); 474 fm801_writew(chip, PLY_COUNT, chip->ply_count - 1);
462 chip->ply_buffer = runtime->dma_addr; 475 chip->ply_buffer = runtime->dma_addr;
463 chip->ply_pos = 0; 476 chip->ply_pos = 0;
464 outl(chip->ply_buffer, FM801_REG(chip, PLY_BUF1)); 477 fm801_writel(chip, PLY_BUF1, chip->ply_buffer);
465 outl(chip->ply_buffer + (chip->ply_count % chip->ply_size), FM801_REG(chip, PLY_BUF2)); 478 fm801_writel(chip, PLY_BUF2,
479 chip->ply_buffer + (chip->ply_count % chip->ply_size));
466 spin_unlock_irq(&chip->reg_lock); 480 spin_unlock_irq(&chip->reg_lock);
467 return 0; 481 return 0;
468} 482}
@@ -483,12 +497,13 @@ static int snd_fm801_capture_prepare(struct snd_pcm_substream *substream)
483 chip->cap_ctrl |= FM801_STEREO; 497 chip->cap_ctrl |= FM801_STEREO;
484 chip->cap_ctrl |= snd_fm801_rate_bits(runtime->rate) << FM801_RATE_SHIFT; 498 chip->cap_ctrl |= snd_fm801_rate_bits(runtime->rate) << FM801_RATE_SHIFT;
485 chip->cap_buf = 0; 499 chip->cap_buf = 0;
486 outw(chip->cap_ctrl, FM801_REG(chip, CAP_CTRL)); 500 fm801_writew(chip, CAP_CTRL, chip->cap_ctrl);
487 outw(chip->cap_count - 1, FM801_REG(chip, CAP_COUNT)); 501 fm801_writew(chip, CAP_COUNT, chip->cap_count - 1);
488 chip->cap_buffer = runtime->dma_addr; 502 chip->cap_buffer = runtime->dma_addr;
489 chip->cap_pos = 0; 503 chip->cap_pos = 0;
490 outl(chip->cap_buffer, FM801_REG(chip, CAP_BUF1)); 504 fm801_writel(chip, CAP_BUF1, chip->cap_buffer);
491 outl(chip->cap_buffer + (chip->cap_count % chip->cap_size), FM801_REG(chip, CAP_BUF2)); 505 fm801_writel(chip, CAP_BUF2,
506 chip->cap_buffer + (chip->cap_count % chip->cap_size));
492 spin_unlock_irq(&chip->reg_lock); 507 spin_unlock_irq(&chip->reg_lock);
493 return 0; 508 return 0;
494} 509}
@@ -501,8 +516,8 @@ static snd_pcm_uframes_t snd_fm801_playback_pointer(struct snd_pcm_substream *su
501 if (!(chip->ply_ctrl & FM801_START)) 516 if (!(chip->ply_ctrl & FM801_START))
502 return 0; 517 return 0;
503 spin_lock(&chip->reg_lock); 518 spin_lock(&chip->reg_lock);
504 ptr = chip->ply_pos + (chip->ply_count - 1) - inw(FM801_REG(chip, PLY_COUNT)); 519 ptr = chip->ply_pos + (chip->ply_count - 1) - fm801_readw(chip, PLY_COUNT);
505 if (inw(FM801_REG(chip, IRQ_STATUS)) & FM801_IRQ_PLAYBACK) { 520 if (fm801_readw(chip, IRQ_STATUS) & FM801_IRQ_PLAYBACK) {
506 ptr += chip->ply_count; 521 ptr += chip->ply_count;
507 ptr %= chip->ply_size; 522 ptr %= chip->ply_size;
508 } 523 }
@@ -518,8 +533,8 @@ static snd_pcm_uframes_t snd_fm801_capture_pointer(struct snd_pcm_substream *sub
518 if (!(chip->cap_ctrl & FM801_START)) 533 if (!(chip->cap_ctrl & FM801_START))
519 return 0; 534 return 0;
520 spin_lock(&chip->reg_lock); 535 spin_lock(&chip->reg_lock);
521 ptr = chip->cap_pos + (chip->cap_count - 1) - inw(FM801_REG(chip, CAP_COUNT)); 536 ptr = chip->cap_pos + (chip->cap_count - 1) - fm801_readw(chip, CAP_COUNT);
522 if (inw(FM801_REG(chip, IRQ_STATUS)) & FM801_IRQ_CAPTURE) { 537 if (fm801_readw(chip, IRQ_STATUS) & FM801_IRQ_CAPTURE) {
523 ptr += chip->cap_count; 538 ptr += chip->cap_count;
524 ptr %= chip->cap_size; 539 ptr %= chip->cap_size;
525 } 540 }
@@ -533,12 +548,12 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id)
533 unsigned short status; 548 unsigned short status;
534 unsigned int tmp; 549 unsigned int tmp;
535 550
536 status = inw(FM801_REG(chip, IRQ_STATUS)); 551 status = fm801_readw(chip, IRQ_STATUS);
537 status &= FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU|FM801_IRQ_VOLUME; 552 status &= FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU|FM801_IRQ_VOLUME;
538 if (! status) 553 if (! status)
539 return IRQ_NONE; 554 return IRQ_NONE;
540 /* ack first */ 555 /* ack first */
541 outw(status, FM801_REG(chip, IRQ_STATUS)); 556 fm801_writew(chip, IRQ_STATUS, status);
542 if (chip->pcm && (status & FM801_IRQ_PLAYBACK) && chip->playback_substream) { 557 if (chip->pcm && (status & FM801_IRQ_PLAYBACK) && chip->playback_substream) {
543 spin_lock(&chip->reg_lock); 558 spin_lock(&chip->reg_lock);
544 chip->ply_buf++; 559 chip->ply_buf++;
@@ -546,10 +561,10 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id)
546 chip->ply_pos %= chip->ply_size; 561 chip->ply_pos %= chip->ply_size;
547 tmp = chip->ply_pos + chip->ply_count; 562 tmp = chip->ply_pos + chip->ply_count;
548 tmp %= chip->ply_size; 563 tmp %= chip->ply_size;
549 outl(chip->ply_buffer + tmp, 564 if (chip->ply_buf & 1)
550 (chip->ply_buf & 1) ? 565 fm801_writel(chip, PLY_BUF1, chip->ply_buffer + tmp);
551 FM801_REG(chip, PLY_BUF1) : 566 else
552 FM801_REG(chip, PLY_BUF2)); 567 fm801_writel(chip, PLY_BUF2, chip->ply_buffer + tmp);
553 spin_unlock(&chip->reg_lock); 568 spin_unlock(&chip->reg_lock);
554 snd_pcm_period_elapsed(chip->playback_substream); 569 snd_pcm_period_elapsed(chip->playback_substream);
555 } 570 }
@@ -560,10 +575,10 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id)
560 chip->cap_pos %= chip->cap_size; 575 chip->cap_pos %= chip->cap_size;
561 tmp = chip->cap_pos + chip->cap_count; 576 tmp = chip->cap_pos + chip->cap_count;
562 tmp %= chip->cap_size; 577 tmp %= chip->cap_size;
563 outl(chip->cap_buffer + tmp, 578 if (chip->cap_buf & 1)
564 (chip->cap_buf & 1) ? 579 fm801_writel(chip, CAP_BUF1, chip->cap_buffer + tmp);
565 FM801_REG(chip, CAP_BUF1) : 580 else
566 FM801_REG(chip, CAP_BUF2)); 581 fm801_writel(chip, CAP_BUF2, chip->cap_buffer + tmp);
567 spin_unlock(&chip->reg_lock); 582 spin_unlock(&chip->reg_lock);
568 snd_pcm_period_elapsed(chip->capture_substream); 583 snd_pcm_period_elapsed(chip->capture_substream);
569 } 584 }
@@ -747,7 +762,7 @@ static struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = {
747static void snd_fm801_tea575x_set_pins(struct snd_tea575x *tea, u8 pins) 762static void snd_fm801_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
748{ 763{
749 struct fm801 *chip = tea->private_data; 764 struct fm801 *chip = tea->private_data;
750 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 765 unsigned short reg = fm801_readw(chip, GPIO_CTRL);
751 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip); 766 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
752 767
753 reg &= ~(FM801_GPIO_GP(gpio.data) | 768 reg &= ~(FM801_GPIO_GP(gpio.data) |
@@ -759,13 +774,13 @@ static void snd_fm801_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
759 /* WRITE_ENABLE is inverted */ 774 /* WRITE_ENABLE is inverted */
760 reg |= (pins & TEA575X_WREN) ? 0 : FM801_GPIO_GP(gpio.wren); 775 reg |= (pins & TEA575X_WREN) ? 0 : FM801_GPIO_GP(gpio.wren);
761 776
762 outw(reg, FM801_REG(chip, GPIO_CTRL)); 777 fm801_writew(chip, GPIO_CTRL, reg);
763} 778}
764 779
765static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea) 780static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea)
766{ 781{
767 struct fm801 *chip = tea->private_data; 782 struct fm801 *chip = tea->private_data;
768 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 783 unsigned short reg = fm801_readw(chip, GPIO_CTRL);
769 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip); 784 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
770 u8 ret; 785 u8 ret;
771 786
@@ -780,7 +795,7 @@ static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea)
780static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output) 795static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output)
781{ 796{
782 struct fm801 *chip = tea->private_data; 797 struct fm801 *chip = tea->private_data;
783 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 798 unsigned short reg = fm801_readw(chip, GPIO_CTRL);
784 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip); 799 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
785 800
786 /* use GPIO lines and set write enable bit */ 801 /* use GPIO lines and set write enable bit */
@@ -811,7 +826,7 @@ static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output
811 FM801_GPIO_GP(gpio.clk)); 826 FM801_GPIO_GP(gpio.clk));
812 } 827 }
813 828
814 outw(reg, FM801_REG(chip, GPIO_CTRL)); 829 fm801_writew(chip, GPIO_CTRL, reg);
815} 830}
816 831
817static struct snd_tea575x_ops snd_fm801_tea_ops = { 832static struct snd_tea575x_ops snd_fm801_tea_ops = {
@@ -962,7 +977,7 @@ static int snd_fm801_get_mux(struct snd_kcontrol *kcontrol,
962 struct fm801 *chip = snd_kcontrol_chip(kcontrol); 977 struct fm801 *chip = snd_kcontrol_chip(kcontrol);
963 unsigned short val; 978 unsigned short val;
964 979
965 val = inw(FM801_REG(chip, REC_SRC)) & 7; 980 val = fm801_readw(chip, REC_SRC) & 7;
966 if (val > 4) 981 if (val > 4)
967 val = 4; 982 val = 4;
968 ucontrol->value.enumerated.item[0] = val; 983 ucontrol->value.enumerated.item[0] = val;
@@ -1073,12 +1088,12 @@ static int wait_for_codec(struct fm801 *chip, unsigned int codec_id,
1073{ 1088{
1074 unsigned long timeout = jiffies + waits; 1089 unsigned long timeout = jiffies + waits;
1075 1090
1076 outw(FM801_AC97_READ | (codec_id << FM801_AC97_ADDR_SHIFT) | reg, 1091 fm801_writew(chip, AC97_CMD,
1077 FM801_REG(chip, AC97_CMD)); 1092 reg | (codec_id << FM801_AC97_ADDR_SHIFT) | FM801_AC97_READ);
1078 udelay(5); 1093 udelay(5);
1079 do { 1094 do {
1080 if ((inw(FM801_REG(chip, AC97_CMD)) & (FM801_AC97_VALID|FM801_AC97_BUSY)) 1095 if ((fm801_readw(chip, AC97_CMD) &
1081 == FM801_AC97_VALID) 1096 (FM801_AC97_VALID | FM801_AC97_BUSY)) == FM801_AC97_VALID)
1082 return 0; 1097 return 0;
1083 schedule_timeout_uninterruptible(1); 1098 schedule_timeout_uninterruptible(1);
1084 } while (time_after(timeout, jiffies)); 1099 } while (time_after(timeout, jiffies));
@@ -1093,10 +1108,10 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1093 goto __ac97_ok; 1108 goto __ac97_ok;
1094 1109
1095 /* codec cold reset + AC'97 warm reset */ 1110 /* codec cold reset + AC'97 warm reset */
1096 outw((1<<5) | (1<<6), FM801_REG(chip, CODEC_CTRL)); 1111 fm801_writew(chip, CODEC_CTRL, (1 << 5) | (1 << 6));
1097 inw(FM801_REG(chip, CODEC_CTRL)); /* flush posting data */ 1112 fm801_readw(chip, CODEC_CTRL); /* flush posting data */
1098 udelay(100); 1113 udelay(100);
1099 outw(0, FM801_REG(chip, CODEC_CTRL)); 1114 fm801_writew(chip, CODEC_CTRL, 0);
1100 1115
1101 if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0) 1116 if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0)
1102 if (!resume) { 1117 if (!resume) {
@@ -1117,7 +1132,7 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1117 for (i = 3; i > 0; i--) { 1132 for (i = 3; i > 0; i--) {
1118 if (!wait_for_codec(chip, i, AC97_VENDOR_ID1, 1133 if (!wait_for_codec(chip, i, AC97_VENDOR_ID1,
1119 msecs_to_jiffies(50))) { 1134 msecs_to_jiffies(50))) {
1120 cmdw = inw(FM801_REG(chip, AC97_DATA)); 1135 cmdw = fm801_readw(chip, AC97_DATA);
1121 if (cmdw != 0xffff && cmdw != 0) { 1136 if (cmdw != 0xffff && cmdw != 0) {
1122 chip->secondary = 1; 1137 chip->secondary = 1;
1123 chip->secondary_addr = i; 1138 chip->secondary_addr = i;
@@ -1135,23 +1150,24 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1135 __ac97_ok: 1150 __ac97_ok:
1136 1151
1137 /* init volume */ 1152 /* init volume */
1138 outw(0x0808, FM801_REG(chip, PCM_VOL)); 1153 fm801_writew(chip, PCM_VOL, 0x0808);
1139 outw(0x9f1f, FM801_REG(chip, FM_VOL)); 1154 fm801_writew(chip, FM_VOL, 0x9f1f);
1140 outw(0x8808, FM801_REG(chip, I2S_VOL)); 1155 fm801_writew(chip, I2S_VOL, 0x8808);
1141 1156
1142 /* I2S control - I2S mode */ 1157 /* I2S control - I2S mode */
1143 outw(0x0003, FM801_REG(chip, I2S_MODE)); 1158 fm801_writew(chip, I2S_MODE, 0x0003);
1144 1159
1145 /* interrupt setup */ 1160 /* interrupt setup */
1146 cmdw = inw(FM801_REG(chip, IRQ_MASK)); 1161 cmdw = fm801_readw(chip, IRQ_MASK);
1147 if (chip->irq < 0) 1162 if (chip->irq < 0)
1148 cmdw |= 0x00c3; /* mask everything, no PCM nor MPU */ 1163 cmdw |= 0x00c3; /* mask everything, no PCM nor MPU */
1149 else 1164 else
1150 cmdw &= ~0x0083; /* unmask MPU, PLAYBACK & CAPTURE */ 1165 cmdw &= ~0x0083; /* unmask MPU, PLAYBACK & CAPTURE */
1151 outw(cmdw, FM801_REG(chip, IRQ_MASK)); 1166 fm801_writew(chip, IRQ_MASK, cmdw);
1152 1167
1153 /* interrupt clear */ 1168 /* interrupt clear */
1154 outw(FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU, FM801_REG(chip, IRQ_STATUS)); 1169 fm801_writew(chip, IRQ_STATUS,
1170 FM801_IRQ_PLAYBACK | FM801_IRQ_CAPTURE | FM801_IRQ_MPU);
1155 1171
1156 return 0; 1172 return 0;
1157} 1173}
@@ -1165,9 +1181,9 @@ static int snd_fm801_free(struct fm801 *chip)
1165 goto __end_hw; 1181 goto __end_hw;
1166 1182
1167 /* interrupt setup - mask everything */ 1183 /* interrupt setup - mask everything */
1168 cmdw = inw(FM801_REG(chip, IRQ_MASK)); 1184 cmdw = fm801_readw(chip, IRQ_MASK);
1169 cmdw |= 0x00c3; 1185 cmdw |= 0x00c3;
1170 outw(cmdw, FM801_REG(chip, IRQ_MASK)); 1186 fm801_writew(chip, IRQ_MASK, cmdw);
1171 1187
1172 __end_hw: 1188 __end_hw:
1173#ifdef CONFIG_SND_FM801_TEA575X_BOOL 1189#ifdef CONFIG_SND_FM801_TEA575X_BOOL
@@ -1339,15 +1355,15 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
1339 return err; 1355 return err;
1340 } 1356 }
1341 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801, 1357 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801,
1342 FM801_REG(chip, MPU401_DATA), 1358 chip->port + FM801_MPU401_DATA,
1343 MPU401_INFO_INTEGRATED | 1359 MPU401_INFO_INTEGRATED |
1344 MPU401_INFO_IRQ_HOOK, 1360 MPU401_INFO_IRQ_HOOK,
1345 -1, &chip->rmidi)) < 0) { 1361 -1, &chip->rmidi)) < 0) {
1346 snd_card_free(card); 1362 snd_card_free(card);
1347 return err; 1363 return err;
1348 } 1364 }
1349 if ((err = snd_opl3_create(card, FM801_REG(chip, OPL3_BANK0), 1365 if ((err = snd_opl3_create(card, chip->port + FM801_OPL3_BANK0,
1350 FM801_REG(chip, OPL3_BANK1), 1366 chip->port + FM801_OPL3_BANK1,
1351 OPL3_HW_OPL3_FM801, 1, &opl3)) < 0) { 1367 OPL3_HW_OPL3_FM801, 1, &opl3)) < 0) {
1352 snd_card_free(card); 1368 snd_card_free(card);
1353 return err; 1369 return err;