diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-21 02:51:55 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:30:08 -0500 |
commit | 7ef37cd95494a0a9be425c4d75f21ee8d2807b5a (patch) | |
tree | 8c1ed7c6fab7c787ec98815be44417256a09d81e /sound/pci/oxygen | |
parent | 3b94253bc9c950d2038a2db4f9c804b50f82001a (diff) |
[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>
Diffstat (limited to 'sound/pci/oxygen')
-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 35b26014925f..af6e8026cb17 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -157,6 +157,10 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids); | |||
157 | #define WM8785_PWRDNL 0x010 | 157 | #define WM8785_PWRDNL 0x010 |
158 | #define WM8785_TDM_MASK 0x1c0 | 158 | #define WM8785_TDM_MASK 0x1c0 |
159 | 159 | ||
160 | struct generic_data { | ||
161 | u8 ak4396_ctl2; | ||
162 | }; | ||
163 | |||
160 | static void ak4396_write(struct oxygen *chip, unsigned int codec, | 164 | static void ak4396_write(struct oxygen *chip, unsigned int codec, |
161 | u8 reg, u8 value) | 165 | u8 reg, u8 value) |
162 | { | 166 | { |
@@ -184,14 +188,15 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) | |||
184 | 188 | ||
185 | static void ak4396_init(struct oxygen *chip) | 189 | static void ak4396_init(struct oxygen *chip) |
186 | { | 190 | { |
191 | struct generic_data *data = chip->model_data; | ||
187 | unsigned int i; | 192 | unsigned int i; |
188 | 193 | ||
189 | chip->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; | 194 | data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; |
190 | for (i = 0; i < 4; ++i) { | 195 | for (i = 0; i < 4; ++i) { |
191 | ak4396_write(chip, i, | 196 | ak4396_write(chip, i, |
192 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); | 197 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
193 | ak4396_write(chip, i, | 198 | ak4396_write(chip, i, |
194 | AK4396_CONTROL_2, chip->ak4396_ctl2); | 199 | AK4396_CONTROL_2, data->ak4396_ctl2); |
195 | ak4396_write(chip, i, | 200 | ak4396_write(chip, i, |
196 | AK4396_CONTROL_3, AK4396_PCM); | 201 | AK4396_CONTROL_3, AK4396_PCM); |
197 | ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); | 202 | ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); |
@@ -235,17 +240,18 @@ static void generic_cleanup(struct oxygen *chip) | |||
235 | static void set_ak4396_params(struct oxygen *chip, | 240 | static void set_ak4396_params(struct oxygen *chip, |
236 | struct snd_pcm_hw_params *params) | 241 | struct snd_pcm_hw_params *params) |
237 | { | 242 | { |
243 | struct generic_data *data = chip->model_data; | ||
238 | unsigned int i; | 244 | unsigned int i; |
239 | u8 value; | 245 | u8 value; |
240 | 246 | ||
241 | value = chip->ak4396_ctl2 & ~AK4396_DFS_MASK; | 247 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; |
242 | if (params_rate(params) <= 54000) | 248 | if (params_rate(params) <= 54000) |
243 | value |= AK4396_DFS_NORMAL; | 249 | value |= AK4396_DFS_NORMAL; |
244 | else if (params_rate(params) < 120000) | 250 | else if (params_rate(params) < 120000) |
245 | value |= AK4396_DFS_DOUBLE; | 251 | value |= AK4396_DFS_DOUBLE; |
246 | else | 252 | else |
247 | value |= AK4396_DFS_QUAD; | 253 | value |= AK4396_DFS_QUAD; |
248 | chip->ak4396_ctl2 = value; | 254 | data->ak4396_ctl2 = value; |
249 | for (i = 0; i < 4; ++i) { | 255 | for (i = 0; i < 4; ++i) { |
250 | ak4396_write(chip, i, | 256 | ak4396_write(chip, i, |
251 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); | 257 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); |
@@ -270,12 +276,14 @@ static void update_ak4396_volume(struct oxygen *chip) | |||
270 | 276 | ||
271 | static void update_ak4396_mute(struct oxygen *chip) | 277 | static void update_ak4396_mute(struct oxygen *chip) |
272 | { | 278 | { |
279 | struct generic_data *data = chip->model_data; | ||
273 | unsigned int i; | 280 | unsigned int i; |
274 | u8 value; | 281 | u8 value; |
275 | 282 | ||
276 | value = chip->ak4396_ctl2 & ~AK4396_SMUTE; | 283 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; |
277 | if (chip->dac_mute) | 284 | if (chip->dac_mute) |
278 | value |= AK4396_SMUTE; | 285 | value |= AK4396_SMUTE; |
286 | data->ak4396_ctl2 = value; | ||
279 | for (i = 0; i < 4; ++i) | 287 | for (i = 0; i < 4; ++i) |
280 | ak4396_write(chip, i, AK4396_CONTROL_2, value); | 288 | ak4396_write(chip, i, AK4396_CONTROL_2, value); |
281 | } | 289 | } |
@@ -341,6 +349,7 @@ static const struct oxygen_model model_generic = { | |||
341 | .set_adc_params = set_wm8785_params, | 349 | .set_adc_params = set_wm8785_params, |
342 | .update_dac_volume = update_ak4396_volume, | 350 | .update_dac_volume = update_ak4396_volume, |
343 | .update_dac_mute = update_ak4396_mute, | 351 | .update_dac_mute = update_ak4396_mute, |
352 | .model_data_size = sizeof(struct generic_data), | ||
344 | .used_channels = OXYGEN_CHANNEL_A | | 353 | .used_channels = OXYGEN_CHANNEL_A | |
345 | OXYGEN_CHANNEL_C | | 354 | OXYGEN_CHANNEL_C | |
346 | OXYGEN_CHANNEL_SPDIF | | 355 | OXYGEN_CHANNEL_SPDIF | |
@@ -362,6 +371,7 @@ static const struct oxygen_model model_meridian = { | |||
362 | .set_adc_params = set_ak5385_params, | 371 | .set_adc_params = set_ak5385_params, |
363 | .update_dac_volume = update_ak4396_volume, | 372 | .update_dac_volume = update_ak4396_volume, |
364 | .update_dac_mute = update_ak4396_mute, | 373 | .update_dac_mute = update_ak4396_mute, |
374 | .model_data_size = sizeof(struct generic_data), | ||
365 | .used_channels = OXYGEN_CHANNEL_B | | 375 | .used_channels = OXYGEN_CHANNEL_B | |
366 | OXYGEN_CHANNEL_C | | 376 | OXYGEN_CHANNEL_C | |
367 | OXYGEN_CHANNEL_SPDIF | | 377 | OXYGEN_CHANNEL_SPDIF | |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 4f4a56a95ca2..4894dbd28126 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h | |||
@@ -49,6 +49,7 @@ struct oxygen { | |||
49 | struct snd_rawmidi *midi; | 49 | struct snd_rawmidi *midi; |
50 | int irq; | 50 | int irq; |
51 | const struct oxygen_model *model; | 51 | const struct oxygen_model *model; |
52 | void *model_data; | ||
52 | unsigned int interrupt_mask; | 53 | unsigned int interrupt_mask; |
53 | u8 dac_volume[8]; | 54 | u8 dac_volume[8]; |
54 | u8 dac_mute; | 55 | u8 dac_mute; |
@@ -56,7 +57,6 @@ struct oxygen { | |||
56 | u8 pcm_running; | 57 | u8 pcm_running; |
57 | u8 dac_routing; | 58 | u8 dac_routing; |
58 | u8 spdif_playback_enable; | 59 | u8 spdif_playback_enable; |
59 | u8 ak4396_ctl2; | ||
60 | u8 revision; | 60 | u8 revision; |
61 | u8 has_ac97_0; | 61 | u8 has_ac97_0; |
62 | u8 has_ac97_1; | 62 | u8 has_ac97_1; |
@@ -84,6 +84,7 @@ struct oxygen_model { | |||
84 | struct snd_pcm_hw_params *params); | 84 | struct snd_pcm_hw_params *params); |
85 | void (*update_dac_volume)(struct oxygen *chip); | 85 | void (*update_dac_volume)(struct oxygen *chip); |
86 | void (*update_dac_mute)(struct oxygen *chip); | 86 | void (*update_dac_mute)(struct oxygen *chip); |
87 | size_t model_data_size; | ||
87 | u8 used_channels; | 88 | u8 used_channels; |
88 | u8 function_flags; | 89 | u8 function_flags; |
89 | u16 dac_i2s_format; | 90 | u16 dac_i2s_format; |
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index aceb1f9e0f35..0927e0423777 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, | |||
320 | struct oxygen *chip; | 320 | struct oxygen *chip; |
321 | int err; | 321 | int err; |
322 | 322 | ||
323 | card = snd_card_new(index, id, model->owner, sizeof *chip); | 323 | card = snd_card_new(index, id, model->owner, |
324 | sizeof *chip + model->model_data_size); | ||
324 | if (!card) | 325 | if (!card) |
325 | return -ENOMEM; | 326 | return -ENOMEM; |
326 | 327 | ||
@@ -329,6 +330,7 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
329 | chip->pci = pci; | 330 | chip->pci = pci; |
330 | chip->irq = -1; | 331 | chip->irq = -1; |
331 | chip->model = model; | 332 | chip->model = model; |
333 | chip->model_data = chip + 1; | ||
332 | spin_lock_init(&chip->reg_lock); | 334 | spin_lock_init(&chip->reg_lock); |
333 | mutex_init(&chip->mutex); | 335 | mutex_init(&chip->mutex); |
334 | INIT_WORK(&chip->spdif_input_bits_work, | 336 | INIT_WORK(&chip->spdif_input_bits_work, |