aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/oxygen_lib.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-09-22 02:55:19 -0400
committerClemens Ladisch <clemens@ladisch.de>2008-09-22 02:55:19 -0400
commit9bd6a73aef955216816fd6e28f371a868ed073d5 (patch)
tree4a416d4f4ed5308a83195f47f498b946bfb9062e /sound/pci/oxygen/oxygen_lib.c
parent6627bea10e8b31cdedd3a59a311d9ad1e010059a (diff)
ALSA: oxygen: use a copy of the model struct
Put a copy of the model structure into the chip structure so that model- specific drivers can modify it depending on a particular device instance. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/pci/oxygen/oxygen_lib.c')
-rw-r--r--sound/pci/oxygen/oxygen_lib.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 22f37851045e..07b0563cc903 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -161,8 +161,8 @@ static void oxygen_gpio_changed(struct work_struct *work)
161{ 161{
162 struct oxygen *chip = container_of(work, struct oxygen, gpio_work); 162 struct oxygen *chip = container_of(work, struct oxygen, gpio_work);
163 163
164 if (chip->model->gpio_changed) 164 if (chip->model.gpio_changed)
165 chip->model->gpio_changed(chip); 165 chip->model.gpio_changed(chip);
166} 166}
167 167
168#ifdef CONFIG_PROC_FS 168#ifdef CONFIG_PROC_FS
@@ -221,7 +221,7 @@ static void oxygen_init(struct oxygen *chip)
221 221
222 chip->dac_routing = 1; 222 chip->dac_routing = 1;
223 for (i = 0; i < 8; ++i) 223 for (i = 0; i < 8; ++i)
224 chip->dac_volume[i] = chip->model->dac_volume_min; 224 chip->dac_volume[i] = chip->model.dac_volume_min;
225 chip->dac_mute = 1; 225 chip->dac_mute = 1;
226 chip->spdif_playback_enable = 1; 226 chip->spdif_playback_enable = 1;
227 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | 227 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
@@ -243,7 +243,7 @@ static void oxygen_init(struct oxygen *chip)
243 243
244 oxygen_write8_masked(chip, OXYGEN_FUNCTION, 244 oxygen_write8_masked(chip, OXYGEN_FUNCTION,
245 OXYGEN_FUNCTION_RESET_CODEC | 245 OXYGEN_FUNCTION_RESET_CODEC |
246 chip->model->function_flags, 246 chip->model.function_flags,
247 OXYGEN_FUNCTION_RESET_CODEC | 247 OXYGEN_FUNCTION_RESET_CODEC |
248 OXYGEN_FUNCTION_2WIRE_SPI_MASK | 248 OXYGEN_FUNCTION_2WIRE_SPI_MASK |
249 OXYGEN_FUNCTION_ENABLE_SPI_4_5); 249 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
@@ -255,7 +255,7 @@ static void oxygen_init(struct oxygen *chip)
255 OXYGEN_DMA_MULTICH_BURST_8); 255 OXYGEN_DMA_MULTICH_BURST_8);
256 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 256 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
257 oxygen_write8_masked(chip, OXYGEN_MISC, 257 oxygen_write8_masked(chip, OXYGEN_MISC,
258 chip->model->misc_flags, 258 chip->model.misc_flags,
259 OXYGEN_MISC_WRITE_PCI_SUBID | 259 OXYGEN_MISC_WRITE_PCI_SUBID |
260 OXYGEN_MISC_REC_C_FROM_SPDIF | 260 OXYGEN_MISC_REC_C_FROM_SPDIF |
261 OXYGEN_MISC_REC_B_FROM_AC97 | 261 OXYGEN_MISC_REC_B_FROM_AC97 |
@@ -270,21 +270,21 @@ static void oxygen_init(struct oxygen *chip)
270 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); 270 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT));
271 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); 271 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2);
272 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 272 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
273 OXYGEN_RATE_48000 | chip->model->dac_i2s_format | 273 OXYGEN_RATE_48000 | chip->model.dac_i2s_format |
274 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | 274 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
275 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 275 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
276 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1) 276 if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
277 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 277 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
278 OXYGEN_RATE_48000 | chip->model->adc_i2s_format | 278 OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
279 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | 279 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
281 else 281 else
282 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, 282 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
283 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); 283 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
284 if (chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 | 284 if (chip->model.pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 |
285 CAPTURE_2_FROM_I2S_2)) 285 CAPTURE_2_FROM_I2S_2))
286 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, 286 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
287 OXYGEN_RATE_48000 | chip->model->adc_i2s_format | 287 OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
288 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | 288 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
289 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 289 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
290 else 290 else
@@ -295,7 +295,7 @@ static void oxygen_init(struct oxygen *chip)
295 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, 295 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
296 OXYGEN_SPDIF_OUT_ENABLE | 296 OXYGEN_SPDIF_OUT_ENABLE |
297 OXYGEN_SPDIF_LOOPBACK); 297 OXYGEN_SPDIF_LOOPBACK);
298 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) 298 if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
299 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, 299 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
300 OXYGEN_SPDIF_SENSE_MASK | 300 OXYGEN_SPDIF_SENSE_MASK |
301 OXYGEN_SPDIF_LOCK_MASK | 301 OXYGEN_SPDIF_LOCK_MASK |
@@ -417,7 +417,7 @@ static void oxygen_card_free(struct snd_card *card)
417 if (chip->irq >= 0) 417 if (chip->irq >= 0)
418 free_irq(chip->irq, chip); 418 free_irq(chip->irq, chip);
419 flush_scheduled_work(); 419 flush_scheduled_work();
420 chip->model->cleanup(chip); 420 chip->model.cleanup(chip);
421 mutex_destroy(&chip->mutex); 421 mutex_destroy(&chip->mutex);
422 pci_release_regions(chip->pci); 422 pci_release_regions(chip->pci);
423 pci_disable_device(chip->pci); 423 pci_disable_device(chip->pci);
@@ -439,7 +439,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
439 chip->card = card; 439 chip->card = card;
440 chip->pci = pci; 440 chip->pci = pci;
441 chip->irq = -1; 441 chip->irq = -1;
442 chip->model = model; 442 chip->model = *model;
443 chip->model_data = chip + 1; 443 chip->model_data = chip + 1;
444 spin_lock_init(&chip->reg_lock); 444 spin_lock_init(&chip->reg_lock);
445 mutex_init(&chip->mutex); 445 mutex_init(&chip->mutex);
@@ -471,22 +471,22 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
471 card->private_free = oxygen_card_free; 471 card->private_free = oxygen_card_free;
472 472
473 oxygen_init(chip); 473 oxygen_init(chip);
474 model->init(chip); 474 chip->model.init(chip);
475 475
476 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED, 476 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
477 model->chip, chip); 477 chip->model.chip, chip);
478 if (err < 0) { 478 if (err < 0) {
479 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq); 479 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq);
480 goto err_card; 480 goto err_card;
481 } 481 }
482 chip->irq = pci->irq; 482 chip->irq = pci->irq;
483 483
484 strcpy(card->driver, model->chip); 484 strcpy(card->driver, chip->model.chip);
485 strcpy(card->shortname, model->shortname); 485 strcpy(card->shortname, chip->model.shortname);
486 sprintf(card->longname, "%s (rev %u) at %#lx, irq %i", 486 sprintf(card->longname, "%s (rev %u) at %#lx, irq %i",
487 model->longname, chip->revision, chip->addr, chip->irq); 487 chip->model.longname, chip->revision, chip->addr, chip->irq);
488 strcpy(card->mixername, model->chip); 488 strcpy(card->mixername, chip->model.chip);
489 snd_component_add(card, model->chip); 489 snd_component_add(card, chip->model.chip);
490 490
491 err = oxygen_pcm_init(chip); 491 err = oxygen_pcm_init(chip);
492 if (err < 0) 492 if (err < 0)
@@ -496,7 +496,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
496 if (err < 0) 496 if (err < 0)
497 goto err_card; 497 goto err_card;
498 498
499 if (model->misc_flags & OXYGEN_MISC_MIDI) { 499 if (chip->model.misc_flags & OXYGEN_MISC_MIDI) {
500 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, 500 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
501 chip->addr + OXYGEN_MPU401, 501 chip->addr + OXYGEN_MPU401,
502 MPU401_INFO_INTEGRATED, 0, 0, 502 MPU401_INFO_INTEGRATED, 0, 0,
@@ -508,7 +508,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
508 oxygen_proc_init(chip); 508 oxygen_proc_init(chip);
509 509
510 spin_lock_irq(&chip->reg_lock); 510 spin_lock_irq(&chip->reg_lock);
511 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) 511 if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
512 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT; 512 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
513 if (chip->has_ac97_0 | chip->has_ac97_1) 513 if (chip->has_ac97_0 | chip->has_ac97_1)
514 chip->interrupt_mask |= OXYGEN_INT_AC97; 514 chip->interrupt_mask |= OXYGEN_INT_AC97;
@@ -552,8 +552,8 @@ int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state)
552 if (chip->streams[i]) 552 if (chip->streams[i])
553 snd_pcm_suspend(chip->streams[i]); 553 snd_pcm_suspend(chip->streams[i]);
554 554
555 if (chip->model->suspend) 555 if (chip->model.suspend)
556 chip->model->suspend(chip); 556 chip->model.suspend(chip);
557 557
558 spin_lock_irq(&chip->reg_lock); 558 spin_lock_irq(&chip->reg_lock);
559 saved_interrupt_mask = chip->interrupt_mask; 559 saved_interrupt_mask = chip->interrupt_mask;
@@ -624,8 +624,8 @@ int oxygen_pci_resume(struct pci_dev *pci)
624 if (chip->has_ac97_1) 624 if (chip->has_ac97_1)
625 oxygen_restore_ac97(chip, 1); 625 oxygen_restore_ac97(chip, 1);
626 626
627 if (chip->model->resume) 627 if (chip->model.resume)
628 chip->model->resume(chip); 628 chip->model.resume(chip);
629 629
630 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); 630 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
631 631