···3434 void (*set_headphone)(struct gpio_runtime *rt, int on);3535 void (*set_speakers)(struct gpio_runtime *rt, int on);3636 void (*set_lineout)(struct gpio_runtime *rt, int on);3737+ void (*set_master)(struct gpio_runtime *rt, int on);37383839 int (*get_headphone)(struct gpio_runtime *rt);3940 int (*get_speakers)(struct gpio_runtime *rt);4041 int (*get_lineout)(struct gpio_runtime *rt);4242+ int (*get_master)(struct gpio_runtime *rt);41434244 void (*set_hw_reset)(struct gpio_runtime *rt, int on);4345
+16-1
sound/aoa/core/gpio-feature.c
···1414#include <linux/interrupt.h>1515#include "../aoa.h"16161717-/* TODO: these are 20 global variables1717+/* TODO: these are lots of global variables1818 * that aren't used on most machines...1919 * Move them into a dynamically allocated2020 * structure and use that.···2323/* these are the GPIO numbers (register addresses as offsets into2424 * the GPIO space) */2525static int headphone_mute_gpio;2626+static int master_mute_gpio;2627static int amp_mute_gpio;2728static int lineout_mute_gpio;2829static int hw_reset_gpio;···33323433/* see the SWITCH_GPIO macro */3534static int headphone_mute_gpio_activestate;3535+static int master_mute_gpio_activestate;3636static int amp_mute_gpio_activestate;3737static int lineout_mute_gpio_activestate;3838static int hw_reset_gpio_activestate;···158156FTR_GPIO(headphone, 0);159157FTR_GPIO(amp, 1);160158FTR_GPIO(lineout, 2);159159+FTR_GPIO(master, 3);161160162161static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)163162{···175172 hw_reset_gpio, v);176173}177174175175+static struct gpio_methods methods;176176+178177static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)179178{180179 int saved;···186181 ftr_gpio_set_headphone(rt, 0);187182 ftr_gpio_set_amp(rt, 0);188183 ftr_gpio_set_lineout(rt, 0);184184+ if (methods.set_master)185185+ ftr_gpio_set_master(rt, 0);189186 rt->implementation_private = saved;190187}191188···200193 ftr_gpio_set_headphone(rt, (s>>0)&1);201194 ftr_gpio_set_amp(rt, (s>>1)&1);202195 ftr_gpio_set_lineout(rt, (s>>2)&1);196196+ if (methods.set_master)197197+ ftr_gpio_set_master(rt, (s>>3)&1);203198}204199205200static void ftr_handle_notify(struct work_struct *work)···240231 get_gpio("hw-reset", "audio-hw-reset",241232 &hw_reset_gpio,242233 &hw_reset_gpio_activestate);234234+ if (get_gpio("master-mute", NULL,235235+ &master_mute_gpio,236236+ &master_mute_gpio_activestate)) {237237+ methods.set_master = ftr_gpio_set_master;238238+ methods.get_master = ftr_gpio_get_master;239239+ }243240244241 headphone_detect_node = get_gpio("headphone-detect", NULL,245242 &headphone_detect_gpio,
+64-17
sound/aoa/fabrics/layout.c
···11/*22- * Apple Onboard Audio driver -- layout fabric22+ * Apple Onboard Audio driver -- layout/machine id fabric33 *44- * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>44+ * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>55 *66 * GPL v2, can be found in COPYING.77 *88 *99- * This fabric module looks for sound codecs1010- * based on the layout-id property in the device tree.1111- *99+ * This fabric module looks for sound codecs based on the1010+ * layout-id or device-id property in the device tree.1211 */1313-1412#include <asm/prom.h>1513#include <linux/list.h>1614#include <linux/module.h>···6163#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)62646365struct layout {6464- unsigned int layout_id;6666+ unsigned int layout_id, device_id;6567 struct codec_connect_info codecs[MAX_CODECS_PER_BUS];6668 int flags;6769···108110MODULE_ALIAS("sound-layout-96");109111MODULE_ALIAS("sound-layout-98");110112MODULE_ALIAS("sound-layout-100");113113+114114+MODULE_ALIAS("aoa-device-id-14");115115+MODULE_ALIAS("aoa-device-id-22");116116+MODULE_ALIAS("aoa-device-id-35");111117112118/* onyx with all but microphone connected */113119static struct codec_connection onyx_connections_nomic[] = {···520518 .connections = onyx_connections_noheadphones,521519 },522520 },521521+ /* PowerMac3,4 */522522+ { .device_id = 14,523523+ .codecs[0] = {524524+ .name = "tas",525525+ .connections = tas_connections_noline,526526+ },527527+ },528528+ /* PowerMac3,6 */529529+ { .device_id = 22,530530+ .codecs[0] = {531531+ .name = "tas",532532+ .connections = tas_connections_all,533533+ },534534+ },535535+ /* PowerBook5,2 */536536+ { .device_id = 35,537537+ .codecs[0] = {538538+ .name = "tas",539539+ .connections = tas_connections_all,540540+ },541541+ },523542 {}524543};525544···549526 struct layout *l;550527551528 l = layouts;552552- while (l->layout_id) {529529+ while (l->codecs[0].name) {553530 if (l->layout_id == id)531531+ return l;532532+ l++;533533+ }534534+ return NULL;535535+}536536+537537+static struct layout *find_layout_by_device(unsigned int id)538538+{539539+ struct layout *l;540540+541541+ l = layouts;542542+ while (l->codecs[0].name) {543543+ if (l->device_id == id)554544 return l;555545 l++;556546 }···600564 struct snd_kcontrol *headphone_ctrl;601565 struct snd_kcontrol *lineout_ctrl;602566 struct snd_kcontrol *speaker_ctrl;567567+ struct snd_kcontrol *master_ctrl;603568 struct snd_kcontrol *headphone_detected_ctrl;604569 struct snd_kcontrol *lineout_detected_ctrl;605570···652615AMP_CONTROL(headphone, "Headphone Switch");653616AMP_CONTROL(speakers, "Speakers Switch");654617AMP_CONTROL(lineout, "Line-Out Switch");618618+AMP_CONTROL(master, "Master Switch");655619656620static int detect_choice_get(struct snd_kcontrol *kcontrol,657621 struct snd_ctl_elem_value *ucontrol)···893855 lineout = codec->gpio->methods->get_detect(codec->gpio,894856 AOA_NOTIFY_LINE_OUT);895857858858+ if (codec->gpio->methods->set_master) {859859+ ctl = snd_ctl_new1(&master_ctl, codec->gpio);860860+ ldev->master_ctrl = ctl;861861+ aoa_snd_ctl_add(ctl);862862+ }896863 while (cc->connected) {897864 if (cc->connected & CC_SPEAKERS) {898865 if (headphones <= 0 && lineout <= 0)···981938static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)982939{983940 struct device_node *sound = NULL;984984- const unsigned int *layout_id;985985- struct layout *layout;941941+ const unsigned int *id;942942+ struct layout *layout = NULL;986943 struct layout_dev *ldev = NULL;987944 int err;988945···995952 if (sound->type && strcasecmp(sound->type, "soundchip") == 0)996953 break;997954 }998998- if (!sound) return -ENODEV;955955+ if (!sound)956956+ return -ENODEV;99995710001000- layout_id = of_get_property(sound, "layout-id", NULL);10011001- if (!layout_id)10021002- goto outnodev;10031003- printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n",10041004- *layout_id);958958+ id = of_get_property(sound, "layout-id", NULL);959959+ if (id) {960960+ layout = find_layout_by_id(*id);961961+ } else {962962+ id = of_get_property(sound, "device-id", NULL);963963+ if (id)964964+ layout = find_layout_by_device(*id);965965+ }100596610061006- layout = find_layout_by_id(*layout_id);1007967 if (!layout) {1008968 printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");1009969 goto outnodev;···1022976 ldev->layout = layout;1023977 ldev->gpio.node = sound->parent;1024978 switch (layout->layout_id) {979979+ case 0: /* anything with device_id, not layout_id */1025980 case 41: /* that unknown machine no one seems to have */1026981 case 51: /* PowerBook5,4 */1027982 case 58: /* Mac Mini */
+17-5
sound/aoa/soundbus/i2sbus/core.c
···11/*22 * i2sbus driver33 *44- * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>44+ * Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>55 *66 * GPL v2, can be found in COPYING.77 */···186186 }187187 }188188 if (i == 1) {189189- const u32 *layout_id =190190- of_get_property(sound, "layout-id", NULL);191191- if (layout_id) {192192- layout = *layout_id;189189+ const u32 *id = of_get_property(sound, "layout-id", NULL);190190+191191+ if (id) {192192+ layout = *id;193193 snprintf(dev->sound.modalias, 32,194194 "sound-layout-%d", layout);195195 ok = 1;196196+ } else {197197+ id = of_get_property(sound, "device-id", NULL);198198+ /*199199+ * We probably cannot handle all device-id machines,200200+ * so restrict to those we do handle for now.201201+ */202202+ if (id && (*id == 22 || *id == 14 || *id == 35)) {203203+ snprintf(dev->sound.modalias, 32,204204+ "aoa-device-id-%d", *id);205205+ ok = 1;206206+ layout = -1;207207+ }196208 }197209 }198210 /* for the time being, until we can handle non-layout-id