aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ac97/ac97_codec.c
diff options
context:
space:
mode:
authorLiam Girdwood <liam.girdwood@wolfsonmicro.com>2005-07-29 10:13:36 -0400
committerJaroslav Kysela <perex@suse.cz>2005-08-30 02:43:26 -0400
commit0ca06a00e206b963587ac471e6d1c52bf33b9a18 (patch)
treed7f3ecf33bc0c46368ba5429373d0f00b5da1cf6 /sound/pci/ac97/ac97_codec.c
parent67ed4161f60d76b3b27efc085b36357a6a90768c (diff)
[ALSA] AC97 bus interface for ad-hoc drivers
AC97 Codec,PCI drivers I've made the review changes and as requested I've pasted the RFC by Nicolas below:- 'I would like to know what people think of the following patch. It allows for a codec on an AC97 bus to be shared with other drivers which are completely unrelated to audio. It registers a new bus type, and whenever a codec instance is created then a device for it is also registered with the driver model using that bus type. This allows, for example, to use the extra features of the UCB1400 like the touchscreen interface and the additional GPIOs and ADCs available on that chip for battery monitoring. I have a working UCB1400 touchscreen driver here that simply registers with the driver model happily working alongside with audio features using this.' Changes over RFC:- o Now matches codec name within codec group. o Added ac97_dev_release() to stop kernel complaining about no release method for device. o Added 'config SND_AC97_BUS' to sound/pci/Kconfig and moved 'config SND_AC97_CODEC' out with the PCI=n statement. o module is now called snd-ac97-bus Signed-off-by: Liam Girdwood <liam.girdwood@wolfsonmicro.com> Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ac97/ac97_codec.c')
-rw-r--r--sound/pci/ac97/ac97_codec.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index cbf790270c30..33dba10f03e8 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1813,6 +1813,39 @@ int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops,
1813 return 0; 1813 return 0;
1814} 1814}
1815 1815
1816/* stop no dev release warning */
1817static void ac97_device_release(struct device * dev)
1818{
1819}
1820
1821/* register ac97 codec to bus */
1822static int snd_ac97_dev_register(snd_device_t *device)
1823{
1824 ac97_t *ac97 = device->device_data;
1825 int err;
1826
1827 ac97->dev.bus = &ac97_bus_type;
1828 ac97->dev.parent = ac97->bus->card->dev;
1829 ac97->dev.platform_data = ac97;
1830 ac97->dev.release = ac97_device_release;
1831 strncpy(ac97->dev.bus_id, snd_ac97_get_short_name(ac97), BUS_ID_SIZE);
1832 if ((err = device_register(&ac97->dev)) < 0) {
1833 snd_printk(KERN_ERR "Can't register ac97 bus\n");
1834 ac97->dev.bus = NULL;
1835 return err;
1836 }
1837 return 0;
1838}
1839
1840/* unregister ac97 codec */
1841static int snd_ac97_dev_unregister(snd_device_t *device)
1842{
1843 ac97_t *ac97 = device->device_data;
1844 if (ac97->dev.bus)
1845 device_unregister(&ac97->dev);
1846 return snd_ac97_free(ac97);
1847}
1848
1816/* build_ops to do nothing */ 1849/* build_ops to do nothing */
1817static struct snd_ac97_build_ops null_build_ops; 1850static struct snd_ac97_build_ops null_build_ops;
1818 1851
@@ -1846,6 +1879,8 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97)
1846 const ac97_codec_id_t *pid; 1879 const ac97_codec_id_t *pid;
1847 static snd_device_ops_t ops = { 1880 static snd_device_ops_t ops = {
1848 .dev_free = snd_ac97_dev_free, 1881 .dev_free = snd_ac97_dev_free,
1882 .dev_register = snd_ac97_dev_register,
1883 .dev_unregister = snd_ac97_dev_unregister,
1849 }; 1884 };
1850 1885
1851 snd_assert(rac97 != NULL, return -EINVAL); 1886 snd_assert(rac97 != NULL, return -EINVAL);