diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-21 08:51:55 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 17:30:08 +0100 |
commit | 7ef37cd95494a0a9be425c4d75f21ee8d2807b5a (patch) | |
tree | 8c1ed7c6fab7c787ec98815be44417256a09d81e | |
parent | 3b94253bc9c950d2038a2db4f9c804b50f82001a (diff) | |
download | linux-3.10-7ef37cd95494a0a9be425c4d75f21ee8d2807b5a.tar.gz linux-3.10-7ef37cd95494a0a9be425c4d75f21ee8d2807b5a.tar.bz2 linux-3.10-7ef37cd95494a0a9be425c4d75f21ee8d2807b5a.zip |
[ALSA] oxygen: move model-specific data out of common header
Instead of having model-specific fields in the common struct oxygen, put
them into a private structure that is allocated together with the card
structure.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-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 35b26014925..af6e8026cb1 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 4f4a56a95ca..4894dbd2812 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 aceb1f9e0f3..0927e042377 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, |