aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-01-15 12:21:48 -0500
committerTakashi Iwai <tiwai@suse.de>2009-01-15 12:28:12 -0500
commit45e513b689b8b0a01ec2b01cc21816e4780d7ea6 (patch)
tree1c1b4657bf2065b076f08b98ff817e4a629a9c81 /sound
parent37a76bd4f1b716949fc38a6842e89f0ccb8384d0 (diff)
ALSA: snd-aoa: handle older machines
This patch changes snd-aoa to handle some older machines that are currently handled by snd-powermac. snd-aoa has a number of advantages though, notably it can autoload better and is generally a more modern driver. By hardcoding the accepted device-ids (last hunk of the patch) I'm trying to avoid regressions because this driver will otherwise load automatically and not let snd-powermac load. People who are unhappy with snd-powermac and have a device-id property in the device tree are encouraged to read this patch and make a patch to amend this as appropriate. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/aoa/fabrics/layout.c74
-rw-r--r--sound/aoa/soundbus/i2sbus/core.c22
2 files changed, 74 insertions, 22 deletions
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c
index ad60f5d10e82..d9b1d22a62c0 100644
--- a/sound/aoa/fabrics/layout.c
+++ b/sound/aoa/fabrics/layout.c
@@ -1,16 +1,14 @@
1/* 1/*
2 * Apple Onboard Audio driver -- layout fabric 2 * Apple Onboard Audio driver -- layout/machine id fabric
3 * 3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
5 * 5 *
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 * 7 *
8 * 8 *
9 * This fabric module looks for sound codecs 9 * This fabric module looks for sound codecs based on the
10 * based on the layout-id property in the device tree. 10 * layout-id or device-id property in the device tree.
11 *
12 */ 11 */
13
14#include <asm/prom.h> 12#include <asm/prom.h>
15#include <linux/list.h> 13#include <linux/list.h>
16#include <linux/module.h> 14#include <linux/module.h>
@@ -63,7 +61,7 @@ struct codec_connect_info {
63#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0) 61#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
64 62
65struct layout { 63struct layout {
66 unsigned int layout_id; 64 unsigned int layout_id, device_id;
67 struct codec_connect_info codecs[MAX_CODECS_PER_BUS]; 65 struct codec_connect_info codecs[MAX_CODECS_PER_BUS];
68 int flags; 66 int flags;
69 67
@@ -111,6 +109,10 @@ MODULE_ALIAS("sound-layout-96");
111MODULE_ALIAS("sound-layout-98"); 109MODULE_ALIAS("sound-layout-98");
112MODULE_ALIAS("sound-layout-100"); 110MODULE_ALIAS("sound-layout-100");
113 111
112MODULE_ALIAS("aoa-device-id-14");
113MODULE_ALIAS("aoa-device-id-22");
114MODULE_ALIAS("aoa-device-id-35");
115
114/* onyx with all but microphone connected */ 116/* onyx with all but microphone connected */
115static struct codec_connection onyx_connections_nomic[] = { 117static struct codec_connection onyx_connections_nomic[] = {
116 { 118 {
@@ -518,6 +520,27 @@ static struct layout layouts[] = {
518 .connections = onyx_connections_noheadphones, 520 .connections = onyx_connections_noheadphones,
519 }, 521 },
520 }, 522 },
523 /* PowerMac3,4 */
524 { .device_id = 14,
525 .codecs[0] = {
526 .name = "tas",
527 .connections = tas_connections_noline,
528 },
529 },
530 /* PowerMac3,6 */
531 { .device_id = 22,
532 .codecs[0] = {
533 .name = "tas",
534 .connections = tas_connections_all,
535 },
536 },
537 /* PowerBook5,2 */
538 { .device_id = 35,
539 .codecs[0] = {
540 .name = "tas",
541 .connections = tas_connections_all,
542 },
543 },
521 {} 544 {}
522}; 545};
523 546
@@ -526,7 +549,7 @@ static struct layout *find_layout_by_id(unsigned int id)
526 struct layout *l; 549 struct layout *l;
527 550
528 l = layouts; 551 l = layouts;
529 while (l->layout_id) { 552 while (l->codecs[0].name) {
530 if (l->layout_id == id) 553 if (l->layout_id == id)
531 return l; 554 return l;
532 l++; 555 l++;
@@ -534,6 +557,19 @@ static struct layout *find_layout_by_id(unsigned int id)
534 return NULL; 557 return NULL;
535} 558}
536 559
560static struct layout *find_layout_by_device(unsigned int id)
561{
562 struct layout *l;
563
564 l = layouts;
565 while (l->codecs[0].name) {
566 if (l->device_id == id)
567 return l;
568 l++;
569 }
570 return NULL;
571}
572
537static void use_layout(struct layout *l) 573static void use_layout(struct layout *l)
538{ 574{
539 int i; 575 int i;
@@ -938,8 +974,8 @@ static struct aoa_fabric layout_fabric = {
938static int aoa_fabric_layout_probe(struct soundbus_dev *sdev) 974static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
939{ 975{
940 struct device_node *sound = NULL; 976 struct device_node *sound = NULL;
941 const unsigned int *layout_id; 977 const unsigned int *id;
942 struct layout *layout; 978 struct layout *layout = NULL;
943 struct layout_dev *ldev = NULL; 979 struct layout_dev *ldev = NULL;
944 int err; 980 int err;
945 981
@@ -952,15 +988,18 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
952 if (sound->type && strcasecmp(sound->type, "soundchip") == 0) 988 if (sound->type && strcasecmp(sound->type, "soundchip") == 0)
953 break; 989 break;
954 } 990 }
955 if (!sound) return -ENODEV; 991 if (!sound)
992 return -ENODEV;
956 993
957 layout_id = of_get_property(sound, "layout-id", NULL); 994 id = of_get_property(sound, "layout-id", NULL);
958 if (!layout_id) 995 if (id) {
959 goto outnodev; 996 layout = find_layout_by_id(*id);
960 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n", 997 } else {
961 *layout_id); 998 id = of_get_property(sound, "device-id", NULL);
999 if (id)
1000 layout = find_layout_by_device(*id);
1001 }
962 1002
963 layout = find_layout_by_id(*layout_id);
964 if (!layout) { 1003 if (!layout) {
965 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n"); 1004 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");
966 goto outnodev; 1005 goto outnodev;
@@ -976,6 +1015,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
976 ldev->layout = layout; 1015 ldev->layout = layout;
977 ldev->gpio.node = sound->parent; 1016 ldev->gpio.node = sound->parent;
978 switch (layout->layout_id) { 1017 switch (layout->layout_id) {
1018 case 0: /* anything with device_id, not layout_id */
979 case 41: /* that unknown machine no one seems to have */ 1019 case 41: /* that unknown machine no one seems to have */
980 case 51: /* PowerBook5,4 */ 1020 case 51: /* PowerBook5,4 */
981 case 58: /* Mac Mini */ 1021 case 58: /* Mac Mini */
diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
index be468edf3ecb..418c84c99d69 100644
--- a/sound/aoa/soundbus/i2sbus/core.c
+++ b/sound/aoa/soundbus/i2sbus/core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * i2sbus driver 2 * i2sbus driver
3 * 3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
5 * 5 *
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 */ 7 */
@@ -186,13 +186,25 @@ static int i2sbus_add_dev(struct macio_dev *macio,
186 } 186 }
187 } 187 }
188 if (i == 1) { 188 if (i == 1) {
189 const u32 *layout_id = 189 const u32 *id = of_get_property(sound, "layout-id", NULL);
190 of_get_property(sound, "layout-id", NULL); 190
191 if (layout_id) { 191 if (id) {
192 layout = *layout_id; 192 layout = *id;
193 snprintf(dev->sound.modalias, 32, 193 snprintf(dev->sound.modalias, 32,
194 "sound-layout-%d", layout); 194 "sound-layout-%d", layout);
195 ok = 1; 195 ok = 1;
196 } else {
197 id = of_get_property(sound, "device-id", NULL);
198 /*
199 * We probably cannot handle all device-id machines,
200 * so restrict to those we do handle for now.
201 */
202 if (id && (*id == 22 || *id == 14 || *id == 35)) {
203 snprintf(dev->sound.modalias, 32,
204 "aoa-device-id-%d", *id);
205 ok = 1;
206 layout = -1;
207 }
196 } 208 }
197 } 209 }
198 /* for the time being, until we can handle non-layout-id 210 /* for the time being, until we can handle non-layout-id