2 * Apple Onboard Audio Alsa helpers
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
6 * GPL v2, can be found in COPYING.
8 #include <linux/module.h>
11 static int index = -1;
12 module_param(index, int, 0444);
13 MODULE_PARM_DESC(index, "index for AOA sound card.");
15 static struct aoa_card *aoa_card;
17 int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
19 struct snd_card *alsa_card;
23 /* cannot be EEXIST due to usage in aoa_fabric_register */
26 err = snd_card_create(index, name, mod, sizeof(struct aoa_card),
30 aoa_card = alsa_card->private_data;
31 aoa_card->alsa_card = alsa_card;
33 strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
34 strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
35 strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname));
36 strlcpy(alsa_card->mixername, name, sizeof(alsa_card->mixername));
37 err = snd_card_register(aoa_card->alsa_card);
39 printk(KERN_ERR "snd-aoa: couldn't register alsa card\n");
40 snd_card_free(aoa_card->alsa_card);
47 struct snd_card *aoa_get_card(void)
50 return aoa_card->alsa_card;
53 EXPORT_SYMBOL_GPL(aoa_get_card);
55 void aoa_alsa_cleanup(void)
58 snd_card_free(aoa_card->alsa_card);
63 int aoa_snd_device_new(snd_device_type_t type,
64 void * device_data, struct snd_device_ops * ops)
66 struct snd_card *card = aoa_get_card();
69 if (!card) return -ENOMEM;
71 err = snd_device_new(card, type, device_data, ops);
73 printk(KERN_ERR "snd-aoa: failed to create snd device (%d)\n", err);
76 err = snd_device_register(card, device_data);
78 printk(KERN_ERR "snd-aoa: failed to register "
79 "snd device (%d)\n", err);
80 printk(KERN_ERR "snd-aoa: have you forgotten the "
81 "dev_register callback?\n");
82 snd_device_free(card, device_data);
86 EXPORT_SYMBOL_GPL(aoa_snd_device_new);
88 int aoa_snd_ctl_add(struct snd_kcontrol* control)
92 if (!aoa_card) return -ENODEV;
94 err = snd_ctl_add(aoa_card->alsa_card, control);
96 printk(KERN_ERR "snd-aoa: failed to add alsa control (%d)\n",
100 EXPORT_SYMBOL_GPL(aoa_snd_ctl_add);