Skip to content

Commit f3d9478

Browse files
jmbergJaroslav Kysela
authored andcommitted
[ALSA] snd-aoa: add snd-aoa
This large patch adds all of snd-aoa. Consisting of many modules, it currently replaces snd-powermac for all layout-id based machines and handles many more (for example new powerbooks and powermacs with digital output that previously couldn't be used at all). It also has support for all layout-IDs that Apple has (judging from their Info.plist file) but not all are tested. The driver currently has 2 known regressions over snd-powermac: * it doesn't handle powermac 7,2 and 7,3 * it doesn't have a DRC control on snapper-based machines I will fix those during the 2.6.18 development cycle. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 41f0cd3 commit f3d9478

35 files changed

Lines changed: 7009 additions & 1 deletion

sound/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ source "sound/pci/Kconfig"
5858

5959
source "sound/ppc/Kconfig"
6060

61+
source "sound/aoa/Kconfig"
62+
6163
source "sound/arm/Kconfig"
6264

6365
source "sound/mips/Kconfig"

sound/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
obj-$(CONFIG_SOUND) += soundcore.o
55
obj-$(CONFIG_SOUND_PRIME) += oss/
66
obj-$(CONFIG_DMASOUND) += oss/
7-
obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/
7+
obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ aoa/
88

99
ifeq ($(CONFIG_SND),y)
1010
obj-y += last.o

sound/aoa/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
menu "Apple Onboard Audio driver"
2+
depends on SND != n && PPC
3+
4+
config SND_AOA
5+
tristate "Apple Onboard Audio driver"
6+
depends on SOUND && SND_PCM
7+
---help---
8+
This option enables the new driver for the various
9+
Apple Onboard Audio components.
10+
11+
source "sound/aoa/fabrics/Kconfig"
12+
13+
source "sound/aoa/codecs/Kconfig"
14+
15+
source "sound/aoa/soundbus/Kconfig"
16+
17+
endmenu

sound/aoa/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
obj-$(CONFIG_SND_AOA) += core/
2+
obj-$(CONFIG_SND_AOA) += codecs/
3+
obj-$(CONFIG_SND_AOA) += fabrics/
4+
obj-$(CONFIG_SND_AOA_SOUNDBUS) += soundbus/

sound/aoa/aoa-gpio.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Apple Onboard Audio GPIO definitions
3+
*
4+
* Copyright 2006 Johannes Berg <[email protected]>
5+
*
6+
* GPL v2, can be found in COPYING.
7+
*/
8+
9+
#ifndef __AOA_GPIO_H
10+
#define __AOA_GPIO_H
11+
#include <linux/workqueue.h>
12+
#include <linux/mutex.h>
13+
#include <asm/prom.h>
14+
15+
typedef void (*notify_func_t)(void *data);
16+
17+
enum notify_type {
18+
AOA_NOTIFY_HEADPHONE,
19+
AOA_NOTIFY_LINE_IN,
20+
AOA_NOTIFY_LINE_OUT,
21+
};
22+
23+
struct gpio_runtime;
24+
struct gpio_methods {
25+
/* for initialisation/de-initialisation of the GPIO layer */
26+
void (*init)(struct gpio_runtime *rt);
27+
void (*exit)(struct gpio_runtime *rt);
28+
29+
/* turn off headphone, speakers, lineout */
30+
void (*all_amps_off)(struct gpio_runtime *rt);
31+
/* turn headphone, speakers, lineout back to previous setting */
32+
void (*all_amps_restore)(struct gpio_runtime *rt);
33+
34+
void (*set_headphone)(struct gpio_runtime *rt, int on);
35+
void (*set_speakers)(struct gpio_runtime *rt, int on);
36+
void (*set_lineout)(struct gpio_runtime *rt, int on);
37+
38+
int (*get_headphone)(struct gpio_runtime *rt);
39+
int (*get_speakers)(struct gpio_runtime *rt);
40+
int (*get_lineout)(struct gpio_runtime *rt);
41+
42+
void (*set_hw_reset)(struct gpio_runtime *rt, int on);
43+
44+
/* use this to be notified of any events. The notification
45+
* function is passed the data, and is called in process
46+
* context by the use of schedule_work.
47+
* The interface for it is that setting a function to NULL
48+
* removes it, and they return 0 if the operation succeeded,
49+
* and -EBUSY if the notification is already assigned by
50+
* someone else. */
51+
int (*set_notify)(struct gpio_runtime *rt,
52+
enum notify_type type,
53+
notify_func_t notify,
54+
void *data);
55+
/* returns 0 if not plugged in, 1 if plugged in
56+
* or a negative error code */
57+
int (*get_detect)(struct gpio_runtime *rt,
58+
enum notify_type type);
59+
};
60+
61+
struct gpio_notification {
62+
notify_func_t notify;
63+
void *data;
64+
void *gpio_private;
65+
struct work_struct work;
66+
struct mutex mutex;
67+
};
68+
69+
struct gpio_runtime {
70+
/* to be assigned by fabric */
71+
struct device_node *node;
72+
/* since everyone needs this pointer anyway... */
73+
struct gpio_methods *methods;
74+
/* to be used by the gpio implementation */
75+
int implementation_private;
76+
struct gpio_notification headphone_notify;
77+
struct gpio_notification line_in_notify;
78+
struct gpio_notification line_out_notify;
79+
};
80+
81+
#endif /* __AOA_GPIO_H */

sound/aoa/aoa.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Apple Onboard Audio definitions
3+
*
4+
* Copyright 2006 Johannes Berg <[email protected]>
5+
*
6+
* GPL v2, can be found in COPYING.
7+
*/
8+
9+
#ifndef __AOA_H
10+
#define __AOA_H
11+
#include <asm/prom.h>
12+
#include <linux/module.h>
13+
/* So apparently there's a reason for requiring driver.h to be included first! */
14+
#include <sound/driver.h>
15+
#include <sound/core.h>
16+
#include <sound/asound.h>
17+
#include <sound/control.h>
18+
#include "aoa-gpio.h"
19+
#include "soundbus/soundbus.h"
20+
21+
#define MAX_CODEC_NAME_LEN 32
22+
23+
struct aoa_codec {
24+
char name[MAX_CODEC_NAME_LEN];
25+
26+
struct module *owner;
27+
28+
/* called when the fabric wants to init this codec.
29+
* Do alsa card manipulations from here. */
30+
int (*init)(struct aoa_codec *codec);
31+
32+
/* called when the fabric is done with the codec.
33+
* The alsa card will be cleaned up so don't bother. */
34+
void (*exit)(struct aoa_codec *codec);
35+
36+
/* May be NULL, but can be used by the fabric.
37+
* Refcounting is the codec driver's responsibility */
38+
struct device_node *node;
39+
40+
/* assigned by fabric before init() is called, points
41+
* to the soundbus device. Cannot be NULL. */
42+
struct soundbus_dev *soundbus_dev;
43+
44+
/* assigned by the fabric before init() is called, points
45+
* to the fabric's gpio runtime record for the relevant
46+
* device. */
47+
struct gpio_runtime *gpio;
48+
49+
/* assigned by the fabric before init() is called, contains
50+
* a codec specific bitmask of what outputs and inputs are
51+
* actually connected */
52+
u32 connected;
53+
54+
/* data the fabric can associate with this structure */
55+
void *fabric_data;
56+
57+
/* private! */
58+
struct list_head list;
59+
struct aoa_fabric *fabric;
60+
};
61+
62+
/* return 0 on success */
63+
extern int
64+
aoa_codec_register(struct aoa_codec *codec);
65+
extern void
66+
aoa_codec_unregister(struct aoa_codec *codec);
67+
68+
#define MAX_LAYOUT_NAME_LEN 32
69+
70+
struct aoa_fabric {
71+
char name[MAX_LAYOUT_NAME_LEN];
72+
73+
struct module *owner;
74+
75+
/* once codecs register, they are passed here after.
76+
* They are of course not initialised, since the
77+
* fabric is responsible for initialising some fields
78+
* in the codec structure! */
79+
int (*found_codec)(struct aoa_codec *codec);
80+
/* called for each codec when it is removed,
81+
* also in the case that aoa_fabric_unregister
82+
* is called and all codecs are removed
83+
* from this fabric.
84+
* Also called if found_codec returned 0 but
85+
* the codec couldn't initialise. */
86+
void (*remove_codec)(struct aoa_codec *codec);
87+
/* If found_codec returned 0, and the codec
88+
* could be initialised, this is called. */
89+
void (*attached_codec)(struct aoa_codec *codec);
90+
};
91+
92+
/* return 0 on success, -EEXIST if another fabric is
93+
* registered, -EALREADY if the same fabric is registered.
94+
* Passing NULL can be used to test for the presence
95+
* of another fabric, if -EALREADY is returned there is
96+
* no other fabric present.
97+
* In the case that the function returns -EALREADY
98+
* and the fabric passed is not NULL, all codecs
99+
* that are not assigned yet are passed to the fabric
100+
* again for reconsideration. */
101+
extern int
102+
aoa_fabric_register(struct aoa_fabric *fabric);
103+
104+
/* it is vital to call this when the fabric exits!
105+
* When calling, the remove_codec will be called
106+
* for all codecs, unless it is NULL. */
107+
extern void
108+
aoa_fabric_unregister(struct aoa_fabric *fabric);
109+
110+
/* if for some reason you want to get rid of a codec
111+
* before the fabric is removed, use this.
112+
* Note that remove_codec is called for it! */
113+
extern void
114+
aoa_fabric_unlink_codec(struct aoa_codec *codec);
115+
116+
/* alsa help methods */
117+
struct aoa_card {
118+
struct snd_card *alsa_card;
119+
};
120+
121+
extern int aoa_snd_device_new(snd_device_type_t type,
122+
void * device_data, struct snd_device_ops * ops);
123+
extern struct snd_card *aoa_get_card(void);
124+
extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
125+
126+
/* GPIO stuff */
127+
extern struct gpio_methods *pmf_gpio_methods;
128+
extern struct gpio_methods *ftr_gpio_methods;
129+
/* extern struct gpio_methods *map_gpio_methods; */
130+
131+
#endif /* __AOA_H */

sound/aoa/codecs/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
config SND_AOA_ONYX
2+
tristate "support Onyx chip"
3+
depends on SND_AOA
4+
---help---
5+
This option enables support for the Onyx (pcm3052)
6+
codec chip found in the latest Apple machines
7+
(most of those with digital audio output).
8+
9+
#config SND_AOA_TOPAZ
10+
# tristate "support Topaz chips"
11+
# depends on SND_AOA
12+
# ---help---
13+
# This option enables support for the Topaz (CS84xx)
14+
# codec chips found in the latest Apple machines,
15+
# these chips do the digital input and output on
16+
# some PowerMacs.
17+
18+
config SND_AOA_TAS
19+
tristate "support TAS chips"
20+
depends on SND_AOA
21+
---help---
22+
This option enables support for the tas chips
23+
found in a lot of Apple Machines, especially
24+
iBooks and PowerBooks without digital.
25+
26+
config SND_AOA_TOONIE
27+
tristate "support Toonie chip"
28+
depends on SND_AOA
29+
---help---
30+
This option enables support for the toonie codec
31+
found in the Mac Mini. If you have a Mac Mini and
32+
want to hear sound, select this option.

sound/aoa/codecs/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
obj-$(CONFIG_SND_AOA_ONYX) += snd-aoa-codec-onyx.o
2+
obj-$(CONFIG_SND_AOA_TAS) += snd-aoa-codec-tas.o
3+
obj-$(CONFIG_SND_AOA_TOONIE) += snd-aoa-codec-toonie.o

0 commit comments

Comments
 (0)