aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
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
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')
-rw-r--r--sound/pci/oxygen/oxygen.h72
-rw-r--r--sound/pci/oxygen/oxygen_lib.c54
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c40
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c42
4 files changed, 104 insertions, 104 deletions
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 74a644880074..5f3fbf802222 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -51,42 +51,7 @@ struct snd_pcm_hardware;
51struct snd_pcm_hw_params; 51struct snd_pcm_hw_params;
52struct snd_kcontrol_new; 52struct snd_kcontrol_new;
53struct snd_rawmidi; 53struct snd_rawmidi;
54struct oxygen_model; 54struct oxygen;
55
56struct oxygen {
57 unsigned long addr;
58 spinlock_t reg_lock;
59 struct mutex mutex;
60 struct snd_card *card;
61 struct pci_dev *pci;
62 struct snd_rawmidi *midi;
63 int irq;
64 const struct oxygen_model *model;
65 void *model_data;
66 unsigned int interrupt_mask;
67 u8 dac_volume[8];
68 u8 dac_mute;
69 u8 pcm_active;
70 u8 pcm_running;
71 u8 dac_routing;
72 u8 spdif_playback_enable;
73 u8 revision;
74 u8 has_ac97_0;
75 u8 has_ac97_1;
76 u32 spdif_bits;
77 u32 spdif_pcm_bits;
78 struct snd_pcm_substream *streams[PCM_COUNT];
79 struct snd_kcontrol *controls[CONTROL_COUNT];
80 struct work_struct spdif_input_bits_work;
81 struct work_struct gpio_work;
82 wait_queue_head_t ac97_waitqueue;
83 union {
84 u8 _8[OXYGEN_IO_SIZE];
85 __le16 _16[OXYGEN_IO_SIZE / 2];
86 __le32 _32[OXYGEN_IO_SIZE / 4];
87 } saved_registers;
88 u16 saved_ac97_registers[2][0x40];
89};
90 55
91struct oxygen_model { 56struct oxygen_model {
92 const char *shortname; 57 const char *shortname;
@@ -122,6 +87,41 @@ struct oxygen_model {
122 u16 adc_i2s_format; 87 u16 adc_i2s_format;
123}; 88};
124 89
90struct oxygen {
91 unsigned long addr;
92 spinlock_t reg_lock;
93 struct mutex mutex;
94 struct snd_card *card;
95 struct pci_dev *pci;
96 struct snd_rawmidi *midi;
97 int irq;
98 void *model_data;
99 unsigned int interrupt_mask;
100 u8 dac_volume[8];
101 u8 dac_mute;
102 u8 pcm_active;
103 u8 pcm_running;
104 u8 dac_routing;
105 u8 spdif_playback_enable;
106 u8 revision;
107 u8 has_ac97_0;
108 u8 has_ac97_1;
109 u32 spdif_bits;
110 u32 spdif_pcm_bits;
111 struct snd_pcm_substream *streams[PCM_COUNT];
112 struct snd_kcontrol *controls[CONTROL_COUNT];
113 struct work_struct spdif_input_bits_work;
114 struct work_struct gpio_work;
115 wait_queue_head_t ac97_waitqueue;
116 union {
117 u8 _8[OXYGEN_IO_SIZE];
118 __le16 _16[OXYGEN_IO_SIZE / 2];
119 __le32 _32[OXYGEN_IO_SIZE / 4];
120 } saved_registers;
121 u16 saved_ac97_registers[2][0x40];
122 struct oxygen_model model;
123};
124
125/* oxygen_lib.c */ 125/* oxygen_lib.c */
126 126
127int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, 127int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
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
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 99c422ceb203..b7226b60eab6 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -31,9 +31,9 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
31 struct oxygen *chip = ctl->private_data; 31 struct oxygen *chip = ctl->private_data;
32 32
33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
34 info->count = chip->model->dac_channels; 34 info->count = chip->model.dac_channels;
35 info->value.integer.min = chip->model->dac_volume_min; 35 info->value.integer.min = chip->model.dac_volume_min;
36 info->value.integer.max = chip->model->dac_volume_max; 36 info->value.integer.max = chip->model.dac_volume_max;
37 return 0; 37 return 0;
38} 38}
39 39
@@ -44,7 +44,7 @@ static int dac_volume_get(struct snd_kcontrol *ctl,
44 unsigned int i; 44 unsigned int i;
45 45
46 mutex_lock(&chip->mutex); 46 mutex_lock(&chip->mutex);
47 for (i = 0; i < chip->model->dac_channels; ++i) 47 for (i = 0; i < chip->model.dac_channels; ++i)
48 value->value.integer.value[i] = chip->dac_volume[i]; 48 value->value.integer.value[i] = chip->dac_volume[i];
49 mutex_unlock(&chip->mutex); 49 mutex_unlock(&chip->mutex);
50 return 0; 50 return 0;
@@ -59,13 +59,13 @@ static int dac_volume_put(struct snd_kcontrol *ctl,
59 59
60 changed = 0; 60 changed = 0;
61 mutex_lock(&chip->mutex); 61 mutex_lock(&chip->mutex);
62 for (i = 0; i < chip->model->dac_channels; ++i) 62 for (i = 0; i < chip->model.dac_channels; ++i)
63 if (value->value.integer.value[i] != chip->dac_volume[i]) { 63 if (value->value.integer.value[i] != chip->dac_volume[i]) {
64 chip->dac_volume[i] = value->value.integer.value[i]; 64 chip->dac_volume[i] = value->value.integer.value[i];
65 changed = 1; 65 changed = 1;
66 } 66 }
67 if (changed) 67 if (changed)
68 chip->model->update_dac_volume(chip); 68 chip->model.update_dac_volume(chip);
69 mutex_unlock(&chip->mutex); 69 mutex_unlock(&chip->mutex);
70 return changed; 70 return changed;
71} 71}
@@ -91,7 +91,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl,
91 changed = !value->value.integer.value[0] != chip->dac_mute; 91 changed = !value->value.integer.value[0] != chip->dac_mute;
92 if (changed) { 92 if (changed) {
93 chip->dac_mute = !value->value.integer.value[0]; 93 chip->dac_mute = !value->value.integer.value[0];
94 chip->model->update_dac_mute(chip); 94 chip->model.update_dac_mute(chip);
95 } 95 }
96 mutex_unlock(&chip->mutex); 96 mutex_unlock(&chip->mutex);
97 return changed; 97 return changed;
@@ -103,7 +103,7 @@ static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
103 "Front", "Front+Surround", "Front+Surround+Back" 103 "Front", "Front+Surround", "Front+Surround+Back"
104 }; 104 };
105 struct oxygen *chip = ctl->private_data; 105 struct oxygen *chip = ctl->private_data;
106 unsigned int count = 2 + (chip->model->dac_channels == 8); 106 unsigned int count = 2 + (chip->model.dac_channels == 8);
107 107
108 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 108 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
109 info->count = 1; 109 info->count = 1;
@@ -172,7 +172,7 @@ void oxygen_update_dac_routing(struct oxygen *chip)
172static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 172static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
173{ 173{
174 struct oxygen *chip = ctl->private_data; 174 struct oxygen *chip = ctl->private_data;
175 unsigned int count = 2 + (chip->model->dac_channels == 8); 175 unsigned int count = 2 + (chip->model.dac_channels == 8);
176 int changed; 176 int changed;
177 177
178 mutex_lock(&chip->mutex); 178 mutex_lock(&chip->mutex);
@@ -521,8 +521,8 @@ static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
521 value = oxygen_read_ac97(chip, 0, priv_idx); 521 value = oxygen_read_ac97(chip, 0, priv_idx);
522 if (!(value & 0x8000)) { 522 if (!(value & 0x8000)) {
523 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000); 523 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
524 if (chip->model->ac97_switch) 524 if (chip->model.ac97_switch)
525 chip->model->ac97_switch(chip, priv_idx, 0x8000); 525 chip->model.ac97_switch(chip, priv_idx, 0x8000);
526 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 526 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
527 &chip->controls[control]->id); 527 &chip->controls[control]->id);
528 } 528 }
@@ -549,8 +549,8 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
549 change = newreg != oldreg; 549 change = newreg != oldreg;
550 if (change) { 550 if (change) {
551 oxygen_write_ac97(chip, codec, index, newreg); 551 oxygen_write_ac97(chip, codec, index, newreg);
552 if (codec == 0 && chip->model->ac97_switch) 552 if (codec == 0 && chip->model.ac97_switch)
553 chip->model->ac97_switch(chip, index, newreg & 0x8000); 553 chip->model.ac97_switch(chip, index, newreg & 0x8000);
554 if (index == AC97_LINE) { 554 if (index == AC97_LINE) {
555 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, 555 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
556 newreg & 0x8000 ? 556 newreg & 0x8000 ?
@@ -939,16 +939,16 @@ static int add_controls(struct oxygen *chip,
939 939
940 for (i = 0; i < count; ++i) { 940 for (i = 0; i < count; ++i) {
941 template = controls[i]; 941 template = controls[i];
942 if (chip->model->control_filter) { 942 if (chip->model.control_filter) {
943 err = chip->model->control_filter(&template); 943 err = chip->model.control_filter(&template);
944 if (err < 0) 944 if (err < 0)
945 return err; 945 return err;
946 if (err == 1) 946 if (err == 1)
947 continue; 947 continue;
948 } 948 }
949 if (!strcmp(template.name, "Master Playback Volume") && 949 if (!strcmp(template.name, "Master Playback Volume") &&
950 chip->model->dac_tlv) { 950 chip->model.dac_tlv) {
951 template.tlv.p = chip->model->dac_tlv; 951 template.tlv.p = chip->model.dac_tlv;
952 template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; 952 template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
953 } 953 }
954 ctl = snd_ctl_new1(&template, chip); 954 ctl = snd_ctl_new1(&template, chip);
@@ -974,14 +974,14 @@ int oxygen_mixer_init(struct oxygen *chip)
974 err = add_controls(chip, controls, ARRAY_SIZE(controls)); 974 err = add_controls(chip, controls, ARRAY_SIZE(controls));
975 if (err < 0) 975 if (err < 0)
976 return err; 976 return err;
977 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) { 977 if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
978 err = add_controls(chip, spdif_input_controls, 978 err = add_controls(chip, spdif_input_controls,
979 ARRAY_SIZE(spdif_input_controls)); 979 ARRAY_SIZE(spdif_input_controls));
980 if (err < 0) 980 if (err < 0)
981 return err; 981 return err;
982 } 982 }
983 for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) { 983 for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) {
984 if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev)) 984 if (!(chip->model.pcm_dev_cfg & monitor_controls[i].pcm_dev))
985 continue; 985 continue;
986 err = add_controls(chip, monitor_controls[i].controls, 986 err = add_controls(chip, monitor_controls[i].controls,
987 ARRAY_SIZE(monitor_controls[i].controls)); 987 ARRAY_SIZE(monitor_controls[i].controls));
@@ -1000,5 +1000,5 @@ int oxygen_mixer_init(struct oxygen *chip)
1000 if (err < 0) 1000 if (err < 0)
1001 return err; 1001 return err;
1002 } 1002 }
1003 return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0; 1003 return chip->model.mixer_init ? chip->model.mixer_init(chip) : 0;
1004} 1004}
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index c4ad65a3406f..5e8071ac766f 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -129,7 +129,7 @@ static int oxygen_open(struct snd_pcm_substream *substream,
129 129
130 runtime->private_data = (void *)(uintptr_t)channel; 130 runtime->private_data = (void *)(uintptr_t)channel;
131 if (channel == PCM_B && chip->has_ac97_1 && 131 if (channel == PCM_B && chip->has_ac97_1 &&
132 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1)) 132 (chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1))
133 runtime->hw = oxygen_ac97_hardware; 133 runtime->hw = oxygen_ac97_hardware;
134 else 134 else
135 runtime->hw = *oxygen_hardware[channel]; 135 runtime->hw = *oxygen_hardware[channel];
@@ -140,11 +140,11 @@ static int oxygen_open(struct snd_pcm_substream *substream,
140 runtime->hw.rate_min = 44100; 140 runtime->hw.rate_min = 44100;
141 break; 141 break;
142 case PCM_MULTICH: 142 case PCM_MULTICH:
143 runtime->hw.channels_max = chip->model->dac_channels; 143 runtime->hw.channels_max = chip->model.dac_channels;
144 break; 144 break;
145 } 145 }
146 if (chip->model->pcm_hardware_filter) 146 if (chip->model.pcm_hardware_filter)
147 chip->model->pcm_hardware_filter(channel, &runtime->hw); 147 chip->model.pcm_hardware_filter(channel, &runtime->hw);
148 err = snd_pcm_hw_constraint_step(runtime, 0, 148 err = snd_pcm_hw_constraint_step(runtime, 0,
149 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); 149 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
150 if (err < 0) 150 if (err < 0)
@@ -355,7 +355,7 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
355 oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, 355 oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT,
356 oxygen_rate(hw_params) | 356 oxygen_rate(hw_params) |
357 oxygen_i2s_mclk(hw_params) | 357 oxygen_i2s_mclk(hw_params) |
358 chip->model->adc_i2s_format | 358 chip->model.adc_i2s_format |
359 oxygen_i2s_bits(hw_params), 359 oxygen_i2s_bits(hw_params),
360 OXYGEN_I2S_RATE_MASK | 360 OXYGEN_I2S_RATE_MASK |
361 OXYGEN_I2S_FORMAT_MASK | 361 OXYGEN_I2S_FORMAT_MASK |
@@ -364,7 +364,7 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
364 spin_unlock_irq(&chip->reg_lock); 364 spin_unlock_irq(&chip->reg_lock);
365 365
366 mutex_lock(&chip->mutex); 366 mutex_lock(&chip->mutex);
367 chip->model->set_adc_params(chip, hw_params); 367 chip->model.set_adc_params(chip, hw_params);
368 mutex_unlock(&chip->mutex); 368 mutex_unlock(&chip->mutex);
369 return 0; 369 return 0;
370} 370}
@@ -381,7 +381,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
381 return err; 381 return err;
382 382
383 is_ac97 = chip->has_ac97_1 && 383 is_ac97 = chip->has_ac97_1 &&
384 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1); 384 (chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
385 385
386 spin_lock_irq(&chip->reg_lock); 386 spin_lock_irq(&chip->reg_lock);
387 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 387 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
@@ -391,7 +391,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
391 oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, 391 oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT,
392 oxygen_rate(hw_params) | 392 oxygen_rate(hw_params) |
393 oxygen_i2s_mclk(hw_params) | 393 oxygen_i2s_mclk(hw_params) |
394 chip->model->adc_i2s_format | 394 chip->model.adc_i2s_format |
395 oxygen_i2s_bits(hw_params), 395 oxygen_i2s_bits(hw_params),
396 OXYGEN_I2S_RATE_MASK | 396 OXYGEN_I2S_RATE_MASK |
397 OXYGEN_I2S_FORMAT_MASK | 397 OXYGEN_I2S_FORMAT_MASK |
@@ -401,7 +401,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
401 401
402 if (!is_ac97) { 402 if (!is_ac97) {
403 mutex_lock(&chip->mutex); 403 mutex_lock(&chip->mutex);
404 chip->model->set_adc_params(chip, hw_params); 404 chip->model.set_adc_params(chip, hw_params);
405 mutex_unlock(&chip->mutex); 405 mutex_unlock(&chip->mutex);
406 } 406 }
407 return 0; 407 return 0;
@@ -468,7 +468,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
468 OXYGEN_MULTICH_FORMAT_MASK); 468 OXYGEN_MULTICH_FORMAT_MASK);
469 oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, 469 oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT,
470 oxygen_rate(hw_params) | 470 oxygen_rate(hw_params) |
471 chip->model->dac_i2s_format | 471 chip->model.dac_i2s_format |
472 oxygen_i2s_bits(hw_params), 472 oxygen_i2s_bits(hw_params),
473 OXYGEN_I2S_RATE_MASK | 473 OXYGEN_I2S_RATE_MASK |
474 OXYGEN_I2S_FORMAT_MASK | 474 OXYGEN_I2S_FORMAT_MASK |
@@ -478,7 +478,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
478 spin_unlock_irq(&chip->reg_lock); 478 spin_unlock_irq(&chip->reg_lock);
479 479
480 mutex_lock(&chip->mutex); 480 mutex_lock(&chip->mutex);
481 chip->model->set_dac_params(chip, hw_params); 481 chip->model.set_dac_params(chip, hw_params);
482 mutex_unlock(&chip->mutex); 482 mutex_unlock(&chip->mutex);
483 return 0; 483 return 0;
484} 484}
@@ -657,9 +657,9 @@ int oxygen_pcm_init(struct oxygen *chip)
657 int outs, ins; 657 int outs, ins;
658 int err; 658 int err;
659 659
660 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_0_TO_I2S); 660 outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_0_TO_I2S);
661 ins = !!(chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 | 661 ins = !!(chip->model.pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 |
662 CAPTURE_0_FROM_I2S_2)); 662 CAPTURE_0_FROM_I2S_2));
663 if (outs | ins) { 663 if (outs | ins) {
664 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm); 664 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm);
665 if (err < 0) 665 if (err < 0)
@@ -667,10 +667,10 @@ int oxygen_pcm_init(struct oxygen *chip)
667 if (outs) 667 if (outs)
668 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 668 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
669 &oxygen_multich_ops); 669 &oxygen_multich_ops);
670 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1) 670 if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
671 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 671 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
672 &oxygen_rec_a_ops); 672 &oxygen_rec_a_ops);
673 else if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_2) 673 else if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_2)
674 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 674 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
675 &oxygen_rec_b_ops); 675 &oxygen_rec_b_ops);
676 pcm->private_data = chip; 676 pcm->private_data = chip;
@@ -690,8 +690,8 @@ int oxygen_pcm_init(struct oxygen *chip)
690 BUFFER_BYTES_MAX); 690 BUFFER_BYTES_MAX);
691 } 691 }
692 692
693 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF); 693 outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
694 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF); 694 ins = !!(chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF);
695 if (outs | ins) { 695 if (outs | ins) {
696 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); 696 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm);
697 if (err < 0) 697 if (err < 0)
@@ -712,11 +712,11 @@ int oxygen_pcm_init(struct oxygen *chip)
712 } 712 }
713 713
714 if (chip->has_ac97_1) { 714 if (chip->has_ac97_1) {
715 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_2_TO_AC97_1); 715 outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_2_TO_AC97_1);
716 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1); 716 ins = !!(chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
717 } else { 717 } else {
718 outs = 0; 718 outs = 0;
719 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_I2S_2); 719 ins = !!(chip->model.pcm_dev_cfg & CAPTURE_2_FROM_I2S_2);
720 } 720 }
721 if (outs | ins) { 721 if (outs | ins) {
722 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", 722 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2",