diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-09-22 02:59:18 -0400 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2008-09-22 02:59:18 -0400 |
commit | 4bd0c3a690594b4037c3edc49e6475f1df13c59d (patch) | |
tree | 3f9f0985456cd9eb2033c8208aed33c1a0475c99 /sound/pci/oxygen | |
parent | 2f1b0ec715a1d804b53b45f2555527c27247d1e1 (diff) |
ALSA: oxygen: handle X-Meridian dynamically
Handle the differences between the X-Meridian and the other models in
the probe callback instead of using a second model structure.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r-- | sound/pci/oxygen/oxygen.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index cf05fd56bc77..043fe281358e 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -286,11 +286,27 @@ static void set_ak5385_params(struct oxygen *chip, | |||
286 | 286 | ||
287 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); | 287 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
288 | 288 | ||
289 | static int generic_probe(struct oxygen *chip, unsigned long driver_data) | ||
290 | { | ||
291 | if (driver_data == MODEL_MERIDIAN) { | ||
292 | chip->model.init = meridian_init; | ||
293 | chip->model.resume = ak4396_registers_init; | ||
294 | chip->model.set_adc_params = set_ak5385_params; | ||
295 | chip->model.pcm_dev_cfg = PLAYBACK_0_TO_I2S | | ||
296 | PLAYBACK_1_TO_SPDIF | | ||
297 | CAPTURE_0_FROM_I2S_2 | | ||
298 | CAPTURE_1_FROM_SPDIF; | ||
299 | chip->model.misc_flags = OXYGEN_MISC_MIDI; | ||
300 | } | ||
301 | return 0; | ||
302 | } | ||
303 | |||
289 | static const struct oxygen_model model_generic = { | 304 | static const struct oxygen_model model_generic = { |
290 | .shortname = "C-Media CMI8788", | 305 | .shortname = "C-Media CMI8788", |
291 | .longname = "C-Media Oxygen HD Audio", | 306 | .longname = "C-Media Oxygen HD Audio", |
292 | .chip = "CMI8788", | 307 | .chip = "CMI8788", |
293 | .owner = THIS_MODULE, | 308 | .owner = THIS_MODULE, |
309 | .probe = generic_probe, | ||
294 | .init = generic_init, | 310 | .init = generic_init, |
295 | .cleanup = generic_cleanup, | 311 | .cleanup = generic_cleanup, |
296 | .resume = generic_resume, | 312 | .resume = generic_resume, |
@@ -314,41 +330,11 @@ static const struct oxygen_model model_generic = { | |||
314 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 330 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
315 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 331 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
316 | }; | 332 | }; |
317 | static const struct oxygen_model model_meridian = { | ||
318 | .shortname = "C-Media CMI8788", | ||
319 | .longname = "C-Media Oxygen HD Audio", | ||
320 | .chip = "CMI8788", | ||
321 | .owner = THIS_MODULE, | ||
322 | .init = meridian_init, | ||
323 | .cleanup = generic_cleanup, | ||
324 | .resume = ak4396_registers_init, | ||
325 | .set_dac_params = set_ak4396_params, | ||
326 | .set_adc_params = set_ak5385_params, | ||
327 | .update_dac_volume = update_ak4396_volume, | ||
328 | .update_dac_mute = update_ak4396_mute, | ||
329 | .dac_tlv = ak4396_db_scale, | ||
330 | .model_data_size = sizeof(struct generic_data), | ||
331 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | ||
332 | PLAYBACK_1_TO_SPDIF | | ||
333 | PLAYBACK_2_TO_AC97_1 | | ||
334 | CAPTURE_0_FROM_I2S_2 | | ||
335 | CAPTURE_1_FROM_SPDIF | | ||
336 | CAPTURE_2_FROM_AC97_1, | ||
337 | .dac_channels = 8, | ||
338 | .dac_volume_min = 0, | ||
339 | .dac_volume_max = 255, | ||
340 | .misc_flags = OXYGEN_MISC_MIDI, | ||
341 | .function_flags = OXYGEN_FUNCTION_SPI | | ||
342 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | ||
343 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
344 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
345 | }; | ||
346 | 333 | ||
347 | static int __devinit generic_oxygen_probe(struct pci_dev *pci, | 334 | static int __devinit generic_oxygen_probe(struct pci_dev *pci, |
348 | const struct pci_device_id *pci_id) | 335 | const struct pci_device_id *pci_id) |
349 | { | 336 | { |
350 | static int dev; | 337 | static int dev; |
351 | int is_meridian; | ||
352 | int err; | 338 | int err; |
353 | 339 | ||
354 | if (dev >= SNDRV_CARDS) | 340 | if (dev >= SNDRV_CARDS) |
@@ -357,10 +343,8 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci, | |||
357 | ++dev; | 343 | ++dev; |
358 | return -ENOENT; | 344 | return -ENOENT; |
359 | } | 345 | } |
360 | is_meridian = pci_id->driver_data == MODEL_MERIDIAN; | ||
361 | err = oxygen_pci_probe(pci, index[dev], id[dev], | 346 | err = oxygen_pci_probe(pci, index[dev], id[dev], |
362 | is_meridian ? &model_meridian : &model_generic, | 347 | &model_generic, pci_id->driver_data); |
363 | 0); | ||
364 | if (err >= 0) | 348 | if (err >= 0) |
365 | ++dev; | 349 | ++dev; |
366 | return err; | 350 | return err; |