diff options
-rw-r--r-- | sound/pci/oxygen/oxygen.c | 20 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen.h | 3 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_lib.c | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index 35b2601..af6e802 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c @@ -157,6 +157,10 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids); #define WM8785_PWRDNL 0x010 #define WM8785_TDM_MASK 0x1c0 +struct generic_data { + u8 ak4396_ctl2; +}; + static void ak4396_write(struct oxygen *chip, unsigned int codec, u8 reg, u8 value) { @@ -184,14 +188,15 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) static void ak4396_init(struct oxygen *chip) { + struct generic_data *data = chip->model_data; unsigned int i; - chip->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; + data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; for (i = 0; i < 4; ++i) { ak4396_write(chip, i, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); ak4396_write(chip, i, - AK4396_CONTROL_2, chip->ak4396_ctl2); + AK4396_CONTROL_2, data->ak4396_ctl2); ak4396_write(chip, i, AK4396_CONTROL_3, AK4396_PCM); ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); @@ -235,17 +240,18 @@ static void generic_cleanup(struct oxygen *chip) static void set_ak4396_params(struct oxygen *chip, struct snd_pcm_hw_params *params) { + struct generic_data *data = chip->model_data; unsigned int i; u8 value; - value = chip->ak4396_ctl2 & ~AK4396_DFS_MASK; + value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; if (params_rate(params) <= 54000) value |= AK4396_DFS_NORMAL; else if (params_rate(params) < 120000) value |= AK4396_DFS_DOUBLE; else value |= AK4396_DFS_QUAD; - chip->ak4396_ctl2 = value; + data->ak4396_ctl2 = value; for (i = 0; i < 4; ++i) { ak4396_write(chip, i, AK4396_CONTROL_1, AK4396_DIF_24_MSB); @@ -270,12 +276,14 @@ static void update_ak4396_volume(struct oxygen *chip) static void update_ak4396_mute(struct oxygen *chip) { + struct generic_data *data = chip->model_data; unsigned int i; u8 value; - value = chip->ak4396_ctl2 & ~AK4396_SMUTE; + value = data->ak4396_ctl2 & ~AK4396_SMUTE; if (chip->dac_mute) value |= AK4396_SMUTE; + data->ak4396_ctl2 = value; for (i = 0; i < 4; ++i) ak4396_write(chip, i, AK4396_CONTROL_2, value); } @@ -341,6 +349,7 @@ static const struct oxygen_model model_generic = { .set_adc_params = set_wm8785_params, .update_dac_volume = update_ak4396_volume, .update_dac_mute = update_ak4396_mute, + .model_data_size = sizeof(struct generic_data), .used_channels = OXYGEN_CHANNEL_A | OXYGEN_CHANNEL_C | OXYGEN_CHANNEL_SPDIF | @@ -362,6 +371,7 @@ static const struct oxygen_model model_meridian = { .set_adc_params = set_ak5385_params, .update_dac_volume = update_ak4396_volume, .update_dac_mute = update_ak4396_mute, + .model_data_size = sizeof(struct generic_data), .used_channels = OXYGEN_CHANNEL_B | OXYGEN_CHANNEL_C | OXYGEN_CHANNEL_SPDIF | diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 4f4a56a..4894dbd 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h @@ -49,6 +49,7 @@ struct oxygen { 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; @@ -56,7 +57,6 @@ struct oxygen { u8 pcm_running; u8 dac_routing; u8 spdif_playback_enable; - u8 ak4396_ctl2; u8 revision; u8 has_ac97_0; u8 has_ac97_1; @@ -84,6 +84,7 @@ struct oxygen_model { struct snd_pcm_hw_params *params); void (*update_dac_volume)(struct oxygen *chip); void (*update_dac_mute)(struct oxygen *chip); + size_t model_data_size; u8 used_channels; u8 function_flags; u16 dac_i2s_format; diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index aceb1f9..0927e04 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -320,7 +320,8 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id, struct oxygen *chip; int err; - card = snd_card_new(index, id, model->owner, sizeof *chip); + card = snd_card_new(index, id, model->owner, + sizeof *chip + model->model_data_size); if (!card) return -ENOMEM; @@ -329,6 +330,7 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id, chip->pci = pci; chip->irq = -1; chip->model = model; + chip->model_data = chip + 1; spin_lock_init(&chip->reg_lock); mutex_init(&chip->mutex); INIT_WORK(&chip->spdif_input_bits_work, |