~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/aoa/core/alsa.c

Version: ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Apple Onboard Audio Alsa helpers
  3  *
  4  * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
  5  *
  6  * GPL v2, can be found in COPYING.
  7  */
  8 #include <linux/module.h>
  9 #include "alsa.h"
 10 
 11 static int index = -1;
 12 module_param(index, int, 0444);
 13 MODULE_PARM_DESC(index, "index for AOA sound card.");
 14 
 15 static struct aoa_card *aoa_card;
 16 
 17 int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
 18 {
 19         struct snd_card *alsa_card;
 20         int err;
 21 
 22         if (aoa_card)
 23                 /* cannot be EEXIST due to usage in aoa_fabric_register */
 24                 return -EBUSY;
 25 
 26         err = snd_card_new(dev, index, name, mod, sizeof(struct aoa_card),
 27                            &alsa_card);
 28         if (err < 0)
 29                 return err;
 30         aoa_card = alsa_card->private_data;
 31         aoa_card->alsa_card = alsa_card;
 32         strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
 33         strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
 34         strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname));
 35         strlcpy(alsa_card->mixername, name, sizeof(alsa_card->mixername));
 36         err = snd_card_register(aoa_card->alsa_card);
 37         if (err < 0) {
 38                 printk(KERN_ERR "snd-aoa: couldn't register alsa card\n");
 39                 snd_card_free(aoa_card->alsa_card);
 40                 aoa_card = NULL;
 41                 return err;
 42         }
 43         return 0;
 44 }
 45 
 46 struct snd_card *aoa_get_card(void)
 47 {
 48         if (aoa_card)
 49                 return aoa_card->alsa_card;
 50         return NULL;
 51 }
 52 EXPORT_SYMBOL_GPL(aoa_get_card);
 53 
 54 void aoa_alsa_cleanup(void)
 55 {
 56         if (aoa_card) {
 57                 snd_card_free(aoa_card->alsa_card);
 58                 aoa_card = NULL;
 59         }
 60 }
 61 
 62 int aoa_snd_device_new(enum snd_device_type type,
 63                        void * device_data, struct snd_device_ops * ops)
 64 {
 65         struct snd_card *card = aoa_get_card();
 66         int err;
 67 
 68         if (!card) return -ENOMEM;
 69 
 70         err = snd_device_new(card, type, device_data, ops);
 71         if (err) {
 72                 printk(KERN_ERR "snd-aoa: failed to create snd device (%d)\n", err);
 73                 return err;
 74         }
 75         err = snd_device_register(card, device_data);
 76         if (err) {
 77                 printk(KERN_ERR "snd-aoa: failed to register "
 78                                 "snd device (%d)\n", err);
 79                 printk(KERN_ERR "snd-aoa: have you forgotten the "
 80                                 "dev_register callback?\n");
 81                 snd_device_free(card, device_data);
 82         }
 83         return err;
 84 }
 85 EXPORT_SYMBOL_GPL(aoa_snd_device_new);
 86 
 87 int aoa_snd_ctl_add(struct snd_kcontrol* control)
 88 {
 89         int err;
 90 
 91         if (!aoa_card) return -ENODEV;
 92 
 93         err = snd_ctl_add(aoa_card->alsa_card, control);
 94         if (err)
 95                 printk(KERN_ERR "snd-aoa: failed to add alsa control (%d)\n",
 96                        err);
 97         return err;
 98 }
 99 EXPORT_SYMBOL_GPL(aoa_snd_ctl_add);
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp