struct snd_pcm_hw_params;
struct snd_kcontrol_new;
struct snd_rawmidi;
-struct oxygen_model;
-
-struct oxygen {
- unsigned long addr;
- spinlock_t reg_lock;
- struct mutex mutex;
- struct snd_card *card;
- struct pci_dev *pci;
- struct snd_rawmidi *midi;
- int irq;
- const struct oxygen_model *model;
- void *model_data;
- unsigned int interrupt_mask;
- u8 dac_volume[8];
- u8 dac_mute;
- u8 pcm_active;
- u8 pcm_running;
- u8 dac_routing;
- u8 spdif_playback_enable;
- u8 revision;
- u8 has_ac97_0;
- u8 has_ac97_1;
- u32 spdif_bits;
- u32 spdif_pcm_bits;
- struct snd_pcm_substream *streams[PCM_COUNT];
- struct snd_kcontrol *controls[CONTROL_COUNT];
- struct work_struct spdif_input_bits_work;
- struct work_struct gpio_work;
- wait_queue_head_t ac97_waitqueue;
- union {
- u8 _8[OXYGEN_IO_SIZE];
- __le16 _16[OXYGEN_IO_SIZE / 2];
- __le32 _32[OXYGEN_IO_SIZE / 4];
- } saved_registers;
- u16 saved_ac97_registers[2][0x40];
-};
+struct oxygen;
struct oxygen_model {
const char *shortname;
u16 adc_i2s_format;
};
+struct oxygen {
+ unsigned long addr;
+ spinlock_t reg_lock;
+ struct mutex mutex;
+ struct snd_card *card;
+ struct pci_dev *pci;
+ struct snd_rawmidi *midi;
+ int irq;
+ void *model_data;
+ unsigned int interrupt_mask;
+ u8 dac_volume[8];
+ u8 dac_mute;
+ u8 pcm_active;
+ u8 pcm_running;
+ u8 dac_routing;
+ u8 spdif_playback_enable;
+ u8 revision;
+ u8 has_ac97_0;
+ u8 has_ac97_1;
+ u32 spdif_bits;
+ u32 spdif_pcm_bits;
+ struct snd_pcm_substream *streams[PCM_COUNT];
+ struct snd_kcontrol *controls[CONTROL_COUNT];
+ struct work_struct spdif_input_bits_work;
+ struct work_struct gpio_work;
+ wait_queue_head_t ac97_waitqueue;
+ union {
+ u8 _8[OXYGEN_IO_SIZE];
+ __le16 _16[OXYGEN_IO_SIZE / 2];
+ __le32 _32[OXYGEN_IO_SIZE / 4];
+ } saved_registers;
+ u16 saved_ac97_registers[2][0x40];
+ struct oxygen_model model;
+};
+
/* oxygen_lib.c */
int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
{
struct oxygen *chip = container_of(work, struct oxygen, gpio_work);
- if (chip->model->gpio_changed)
- chip->model->gpio_changed(chip);
+ if (chip->model.gpio_changed)
+ chip->model.gpio_changed(chip);
}
#ifdef CONFIG_PROC_FS
chip->dac_routing = 1;
for (i = 0; i < 8; ++i)
- chip->dac_volume[i] = chip->model->dac_volume_min;
+ chip->dac_volume[i] = chip->model.dac_volume_min;
chip->dac_mute = 1;
chip->spdif_playback_enable = 1;
chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
oxygen_write8_masked(chip, OXYGEN_FUNCTION,
OXYGEN_FUNCTION_RESET_CODEC |
- chip->model->function_flags,
+ chip->model.function_flags,
OXYGEN_FUNCTION_RESET_CODEC |
OXYGEN_FUNCTION_2WIRE_SPI_MASK |
OXYGEN_FUNCTION_ENABLE_SPI_4_5);
OXYGEN_DMA_MULTICH_BURST_8);
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
oxygen_write8_masked(chip, OXYGEN_MISC,
- chip->model->misc_flags,
+ chip->model.misc_flags,
OXYGEN_MISC_WRITE_PCI_SUBID |
OXYGEN_MISC_REC_C_FROM_SPDIF |
OXYGEN_MISC_REC_B_FROM_AC97 |
(OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT));
oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2);
oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
- OXYGEN_RATE_48000 | chip->model->dac_i2s_format |
+ OXYGEN_RATE_48000 | chip->model.dac_i2s_format |
OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
- if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
+ if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
- OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
+ OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
else
oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
- if (chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 |
- CAPTURE_2_FROM_I2S_2))
+ if (chip->model.pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 |
+ CAPTURE_2_FROM_I2S_2))
oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
- OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
+ OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
else
oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_OUT_ENABLE |
OXYGEN_SPDIF_LOOPBACK);
- if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
+ if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
OXYGEN_SPDIF_SENSE_MASK |
OXYGEN_SPDIF_LOCK_MASK |
if (chip->irq >= 0)
free_irq(chip->irq, chip);
flush_scheduled_work();
- chip->model->cleanup(chip);
+ chip->model.cleanup(chip);
mutex_destroy(&chip->mutex);
pci_release_regions(chip->pci);
pci_disable_device(chip->pci);
chip->card = card;
chip->pci = pci;
chip->irq = -1;
- chip->model = model;
+ chip->model = *model;
chip->model_data = chip + 1;
spin_lock_init(&chip->reg_lock);
mutex_init(&chip->mutex);
card->private_free = oxygen_card_free;
oxygen_init(chip);
- model->init(chip);
+ chip->model.init(chip);
err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
- model->chip, chip);
+ chip->model.chip, chip);
if (err < 0) {
snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq);
goto err_card;
}
chip->irq = pci->irq;
- strcpy(card->driver, model->chip);
- strcpy(card->shortname, model->shortname);
+ strcpy(card->driver, chip->model.chip);
+ strcpy(card->shortname, chip->model.shortname);
sprintf(card->longname, "%s (rev %u) at %#lx, irq %i",
- model->longname, chip->revision, chip->addr, chip->irq);
- strcpy(card->mixername, model->chip);
- snd_component_add(card, model->chip);
+ chip->model.longname, chip->revision, chip->addr, chip->irq);
+ strcpy(card->mixername, chip->model.chip);
+ snd_component_add(card, chip->model.chip);
err = oxygen_pcm_init(chip);
if (err < 0)
if (err < 0)
goto err_card;
- if (model->misc_flags & OXYGEN_MISC_MIDI) {
+ if (chip->model.misc_flags & OXYGEN_MISC_MIDI) {
err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
chip->addr + OXYGEN_MPU401,
MPU401_INFO_INTEGRATED, 0, 0,
oxygen_proc_init(chip);
spin_lock_irq(&chip->reg_lock);
- if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
+ if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
if (chip->has_ac97_0 | chip->has_ac97_1)
chip->interrupt_mask |= OXYGEN_INT_AC97;
if (chip->streams[i])
snd_pcm_suspend(chip->streams[i]);
- if (chip->model->suspend)
- chip->model->suspend(chip);
+ if (chip->model.suspend)
+ chip->model.suspend(chip);
spin_lock_irq(&chip->reg_lock);
saved_interrupt_mask = chip->interrupt_mask;
if (chip->has_ac97_1)
oxygen_restore_ac97(chip, 1);
- if (chip->model->resume)
- chip->model->resume(chip);
+ if (chip->model.resume)
+ chip->model.resume(chip);
oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
struct oxygen *chip = ctl->private_data;
info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
- info->count = chip->model->dac_channels;
- info->value.integer.min = chip->model->dac_volume_min;
- info->value.integer.max = chip->model->dac_volume_max;
+ info->count = chip->model.dac_channels;
+ info->value.integer.min = chip->model.dac_volume_min;
+ info->value.integer.max = chip->model.dac_volume_max;
return 0;
}
unsigned int i;
mutex_lock(&chip->mutex);
- for (i = 0; i < chip->model->dac_channels; ++i)
+ for (i = 0; i < chip->model.dac_channels; ++i)
value->value.integer.value[i] = chip->dac_volume[i];
mutex_unlock(&chip->mutex);
return 0;
changed = 0;
mutex_lock(&chip->mutex);
- for (i = 0; i < chip->model->dac_channels; ++i)
+ for (i = 0; i < chip->model.dac_channels; ++i)
if (value->value.integer.value[i] != chip->dac_volume[i]) {
chip->dac_volume[i] = value->value.integer.value[i];
changed = 1;
}
if (changed)
- chip->model->update_dac_volume(chip);
+ chip->model.update_dac_volume(chip);
mutex_unlock(&chip->mutex);
return changed;
}
changed = !value->value.integer.value[0] != chip->dac_mute;
if (changed) {
chip->dac_mute = !value->value.integer.value[0];
- chip->model->update_dac_mute(chip);
+ chip->model.update_dac_mute(chip);
}
mutex_unlock(&chip->mutex);
return changed;
"Front", "Front+Surround", "Front+Surround+Back"
};
struct oxygen *chip = ctl->private_data;
- unsigned int count = 2 + (chip->model->dac_channels == 8);
+ unsigned int count = 2 + (chip->model.dac_channels == 8);
info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
info->count = 1;
static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
{
struct oxygen *chip = ctl->private_data;
- unsigned int count = 2 + (chip->model->dac_channels == 8);
+ unsigned int count = 2 + (chip->model.dac_channels == 8);
int changed;
mutex_lock(&chip->mutex);
value = oxygen_read_ac97(chip, 0, priv_idx);
if (!(value & 0x8000)) {
oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
- if (chip->model->ac97_switch)
- chip->model->ac97_switch(chip, priv_idx, 0x8000);
+ if (chip->model.ac97_switch)
+ chip->model.ac97_switch(chip, priv_idx, 0x8000);
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
&chip->controls[control]->id);
}
change = newreg != oldreg;
if (change) {
oxygen_write_ac97(chip, codec, index, newreg);
- if (codec == 0 && chip->model->ac97_switch)
- chip->model->ac97_switch(chip, index, newreg & 0x8000);
+ if (codec == 0 && chip->model.ac97_switch)
+ chip->model.ac97_switch(chip, index, newreg & 0x8000);
if (index == AC97_LINE) {
oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
newreg & 0x8000 ?
for (i = 0; i < count; ++i) {
template = controls[i];
- if (chip->model->control_filter) {
- err = chip->model->control_filter(&template);
+ if (chip->model.control_filter) {
+ err = chip->model.control_filter(&template);
if (err < 0)
return err;
if (err == 1)
continue;
}
if (!strcmp(template.name, "Master Playback Volume") &&
- chip->model->dac_tlv) {
- template.tlv.p = chip->model->dac_tlv;
+ chip->model.dac_tlv) {
+ template.tlv.p = chip->model.dac_tlv;
template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
}
ctl = snd_ctl_new1(&template, chip);
err = add_controls(chip, controls, ARRAY_SIZE(controls));
if (err < 0)
return err;
- if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
+ if (chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
err = add_controls(chip, spdif_input_controls,
ARRAY_SIZE(spdif_input_controls));
if (err < 0)
return err;
}
for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) {
- if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev))
+ if (!(chip->model.pcm_dev_cfg & monitor_controls[i].pcm_dev))
continue;
err = add_controls(chip, monitor_controls[i].controls,
ARRAY_SIZE(monitor_controls[i].controls));
if (err < 0)
return err;
}
- return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0;
+ return chip->model.mixer_init ? chip->model.mixer_init(chip) : 0;
}
runtime->private_data = (void *)(uintptr_t)channel;
if (channel == PCM_B && chip->has_ac97_1 &&
- (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1))
+ (chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1))
runtime->hw = oxygen_ac97_hardware;
else
runtime->hw = *oxygen_hardware[channel];
runtime->hw.rate_min = 44100;
break;
case PCM_MULTICH:
- runtime->hw.channels_max = chip->model->dac_channels;
+ runtime->hw.channels_max = chip->model.dac_channels;
break;
}
- if (chip->model->pcm_hardware_filter)
- chip->model->pcm_hardware_filter(channel, &runtime->hw);
+ if (chip->model.pcm_hardware_filter)
+ chip->model.pcm_hardware_filter(channel, &runtime->hw);
err = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
if (err < 0)
oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT,
oxygen_rate(hw_params) |
oxygen_i2s_mclk(hw_params) |
- chip->model->adc_i2s_format |
+ chip->model.adc_i2s_format |
oxygen_i2s_bits(hw_params),
OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK |
spin_unlock_irq(&chip->reg_lock);
mutex_lock(&chip->mutex);
- chip->model->set_adc_params(chip, hw_params);
+ chip->model.set_adc_params(chip, hw_params);
mutex_unlock(&chip->mutex);
return 0;
}
return err;
is_ac97 = chip->has_ac97_1 &&
- (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
+ (chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
spin_lock_irq(&chip->reg_lock);
oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT,
oxygen_rate(hw_params) |
oxygen_i2s_mclk(hw_params) |
- chip->model->adc_i2s_format |
+ chip->model.adc_i2s_format |
oxygen_i2s_bits(hw_params),
OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK |
if (!is_ac97) {
mutex_lock(&chip->mutex);
- chip->model->set_adc_params(chip, hw_params);
+ chip->model.set_adc_params(chip, hw_params);
mutex_unlock(&chip->mutex);
}
return 0;
OXYGEN_MULTICH_FORMAT_MASK);
oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT,
oxygen_rate(hw_params) |
- chip->model->dac_i2s_format |
+ chip->model.dac_i2s_format |
oxygen_i2s_bits(hw_params),
OXYGEN_I2S_RATE_MASK |
OXYGEN_I2S_FORMAT_MASK |
spin_unlock_irq(&chip->reg_lock);
mutex_lock(&chip->mutex);
- chip->model->set_dac_params(chip, hw_params);
+ chip->model.set_dac_params(chip, hw_params);
mutex_unlock(&chip->mutex);
return 0;
}
int outs, ins;
int err;
- outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_0_TO_I2S);
- ins = !!(chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 |
- CAPTURE_0_FROM_I2S_2));
+ outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_0_TO_I2S);
+ ins = !!(chip->model.pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 |
+ CAPTURE_0_FROM_I2S_2));
if (outs | ins) {
err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm);
if (err < 0)
if (outs)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&oxygen_multich_ops);
- if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
+ if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
&oxygen_rec_a_ops);
- else if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_2)
+ else if (chip->model.pcm_dev_cfg & CAPTURE_0_FROM_I2S_2)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
&oxygen_rec_b_ops);
pcm->private_data = chip;
BUFFER_BYTES_MAX);
}
- outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
- ins = !!(chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF);
+ outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
+ ins = !!(chip->model.pcm_dev_cfg & CAPTURE_1_FROM_SPDIF);
if (outs | ins) {
err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm);
if (err < 0)
}
if (chip->has_ac97_1) {
- outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_2_TO_AC97_1);
- ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
+ outs = !!(chip->model.pcm_dev_cfg & PLAYBACK_2_TO_AC97_1);
+ ins = !!(chip->model.pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
} else {
outs = 0;
- ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_I2S_2);
+ ins = !!(chip->model.pcm_dev_cfg & CAPTURE_2_FROM_I2S_2);
}
if (outs | ins) {
err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2",