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

TOMOYO Linux Cross Reference
Linux/sound/aoa/codecs/toonie.c

Version: ~ [ linux-5.6 ] ~ [ linux-5.5.13 ] ~ [ linux-5.4.28 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.113 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ 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.82 ] ~ [ 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-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ 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 driver for Toonie codec
  3  *
  4  * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
  5  *
  6  * GPL v2, can be found in COPYING.
  7  *
  8  *
  9  * This is a driver for the toonie codec chip. This chip is present
 10  * on the Mac Mini and is nothing but a DAC.
 11  */
 12 #include <linux/delay.h>
 13 #include <linux/module.h>
 14 #include <linux/slab.h>
 15 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
 16 MODULE_LICENSE("GPL");
 17 MODULE_DESCRIPTION("toonie codec driver for snd-aoa");
 18 
 19 #include "../aoa.h"
 20 #include "../soundbus/soundbus.h"
 21 
 22 
 23 #define PFX "snd-aoa-codec-toonie: "
 24 
 25 struct toonie {
 26         struct aoa_codec        codec;
 27 };
 28 #define codec_to_toonie(c) container_of(c, struct toonie, codec)
 29 
 30 static int toonie_dev_register(struct snd_device *dev)
 31 {
 32         return 0;
 33 }
 34 
 35 static struct snd_device_ops ops = {
 36         .dev_register = toonie_dev_register,
 37 };
 38 
 39 static struct transfer_info toonie_transfers[] = {
 40         /* This thing *only* has analog output,
 41          * the rates are taken from Info.plist
 42          * from Darwin. */
 43         {
 44                 .formats = SNDRV_PCM_FMTBIT_S16_BE |
 45                            SNDRV_PCM_FMTBIT_S24_BE,
 46                 .rates = SNDRV_PCM_RATE_32000 |
 47                          SNDRV_PCM_RATE_44100 |
 48                          SNDRV_PCM_RATE_48000 |
 49                          SNDRV_PCM_RATE_88200 |
 50                          SNDRV_PCM_RATE_96000,
 51         },
 52         {}
 53 };
 54 
 55 static int toonie_usable(struct codec_info_item *cii,
 56                          struct transfer_info *ti,
 57                          struct transfer_info *out)
 58 {
 59         return 1;
 60 }
 61 
 62 #ifdef CONFIG_PM
 63 static int toonie_suspend(struct codec_info_item *cii, pm_message_t state)
 64 {
 65         /* can we turn it off somehow? */
 66         return 0;
 67 }
 68 
 69 static int toonie_resume(struct codec_info_item *cii)
 70 {
 71         return 0;
 72 }
 73 #endif /* CONFIG_PM */
 74 
 75 static struct codec_info toonie_codec_info = {
 76         .transfers = toonie_transfers,
 77         .sysclock_factor = 256,
 78         .bus_factor = 64,
 79         .owner = THIS_MODULE,
 80         .usable = toonie_usable,
 81 #ifdef CONFIG_PM
 82         .suspend = toonie_suspend,
 83         .resume = toonie_resume,
 84 #endif
 85 };
 86 
 87 static int toonie_init_codec(struct aoa_codec *codec)
 88 {
 89         struct toonie *toonie = codec_to_toonie(codec);
 90 
 91         /* nothing connected? what a joke! */
 92         if (toonie->codec.connected != 1)
 93                 return -ENOTCONN;
 94 
 95         if (aoa_snd_device_new(SNDRV_DEV_LOWLEVEL, toonie, &ops)) {
 96                 printk(KERN_ERR PFX "failed to create toonie snd device!\n");
 97                 return -ENODEV;
 98         }
 99 
100         if (toonie->codec.soundbus_dev->attach_codec(toonie->codec.soundbus_dev,
101                                                      aoa_get_card(),
102                                                      &toonie_codec_info, toonie)) {
103                 printk(KERN_ERR PFX "error creating toonie pcm\n");
104                 snd_device_free(aoa_get_card(), toonie);
105                 return -ENODEV;
106         }
107 
108         return 0;
109 }
110 
111 static void toonie_exit_codec(struct aoa_codec *codec)
112 {
113         struct toonie *toonie = codec_to_toonie(codec);
114 
115         if (!toonie->codec.soundbus_dev) {
116                 printk(KERN_ERR PFX "toonie_exit_codec called without soundbus_dev!\n");
117                 return;
118         }
119         toonie->codec.soundbus_dev->detach_codec(toonie->codec.soundbus_dev, toonie);
120 }
121 
122 static struct toonie *toonie;
123 
124 static int __init toonie_init(void)
125 {
126         toonie = kzalloc(sizeof(struct toonie), GFP_KERNEL);
127 
128         if (!toonie)
129                 return -ENOMEM;
130 
131         strlcpy(toonie->codec.name, "toonie", sizeof(toonie->codec.name));
132         toonie->codec.owner = THIS_MODULE;
133         toonie->codec.init = toonie_init_codec;
134         toonie->codec.exit = toonie_exit_codec;
135 
136         if (aoa_codec_register(&toonie->codec)) {
137                 kfree(toonie);
138                 return -EINVAL;
139         }
140 
141         return 0;
142 }
143 
144 static void __exit toonie_exit(void)
145 {
146         aoa_codec_unregister(&toonie->codec);
147         kfree(toonie);
148 }
149 
150 module_init(toonie_init);
151 module_exit(toonie_exit);
152 

~ [ 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