mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 19:56:18 +00:00
Merge branch 'topic/aoa' into for-linus
This commit is contained in:
commit
ff4fc3656e
4 changed files with 99 additions and 23 deletions
|
@ -34,10 +34,12 @@ struct gpio_methods {
|
||||||
void (*set_headphone)(struct gpio_runtime *rt, int on);
|
void (*set_headphone)(struct gpio_runtime *rt, int on);
|
||||||
void (*set_speakers)(struct gpio_runtime *rt, int on);
|
void (*set_speakers)(struct gpio_runtime *rt, int on);
|
||||||
void (*set_lineout)(struct gpio_runtime *rt, int on);
|
void (*set_lineout)(struct gpio_runtime *rt, int on);
|
||||||
|
void (*set_master)(struct gpio_runtime *rt, int on);
|
||||||
|
|
||||||
int (*get_headphone)(struct gpio_runtime *rt);
|
int (*get_headphone)(struct gpio_runtime *rt);
|
||||||
int (*get_speakers)(struct gpio_runtime *rt);
|
int (*get_speakers)(struct gpio_runtime *rt);
|
||||||
int (*get_lineout)(struct gpio_runtime *rt);
|
int (*get_lineout)(struct gpio_runtime *rt);
|
||||||
|
int (*get_master)(struct gpio_runtime *rt);
|
||||||
|
|
||||||
void (*set_hw_reset)(struct gpio_runtime *rt, int on);
|
void (*set_hw_reset)(struct gpio_runtime *rt, int on);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include "../aoa.h"
|
#include "../aoa.h"
|
||||||
|
|
||||||
/* TODO: these are 20 global variables
|
/* TODO: these are lots of global variables
|
||||||
* that aren't used on most machines...
|
* that aren't used on most machines...
|
||||||
* Move them into a dynamically allocated
|
* Move them into a dynamically allocated
|
||||||
* structure and use that.
|
* structure and use that.
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
/* these are the GPIO numbers (register addresses as offsets into
|
/* these are the GPIO numbers (register addresses as offsets into
|
||||||
* the GPIO space) */
|
* the GPIO space) */
|
||||||
static int headphone_mute_gpio;
|
static int headphone_mute_gpio;
|
||||||
|
static int master_mute_gpio;
|
||||||
static int amp_mute_gpio;
|
static int amp_mute_gpio;
|
||||||
static int lineout_mute_gpio;
|
static int lineout_mute_gpio;
|
||||||
static int hw_reset_gpio;
|
static int hw_reset_gpio;
|
||||||
|
@ -32,6 +33,7 @@ static int linein_detect_gpio;
|
||||||
|
|
||||||
/* see the SWITCH_GPIO macro */
|
/* see the SWITCH_GPIO macro */
|
||||||
static int headphone_mute_gpio_activestate;
|
static int headphone_mute_gpio_activestate;
|
||||||
|
static int master_mute_gpio_activestate;
|
||||||
static int amp_mute_gpio_activestate;
|
static int amp_mute_gpio_activestate;
|
||||||
static int lineout_mute_gpio_activestate;
|
static int lineout_mute_gpio_activestate;
|
||||||
static int hw_reset_gpio_activestate;
|
static int hw_reset_gpio_activestate;
|
||||||
|
@ -156,6 +158,7 @@ static int ftr_gpio_get_##name(struct gpio_runtime *rt) \
|
||||||
FTR_GPIO(headphone, 0);
|
FTR_GPIO(headphone, 0);
|
||||||
FTR_GPIO(amp, 1);
|
FTR_GPIO(amp, 1);
|
||||||
FTR_GPIO(lineout, 2);
|
FTR_GPIO(lineout, 2);
|
||||||
|
FTR_GPIO(master, 3);
|
||||||
|
|
||||||
static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
|
static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +175,8 @@ static void ftr_gpio_set_hw_reset(struct gpio_runtime *rt, int on)
|
||||||
hw_reset_gpio, v);
|
hw_reset_gpio, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct gpio_methods methods;
|
||||||
|
|
||||||
static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)
|
static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)
|
||||||
{
|
{
|
||||||
int saved;
|
int saved;
|
||||||
|
@ -181,6 +186,8 @@ static void ftr_gpio_all_amps_off(struct gpio_runtime *rt)
|
||||||
ftr_gpio_set_headphone(rt, 0);
|
ftr_gpio_set_headphone(rt, 0);
|
||||||
ftr_gpio_set_amp(rt, 0);
|
ftr_gpio_set_amp(rt, 0);
|
||||||
ftr_gpio_set_lineout(rt, 0);
|
ftr_gpio_set_lineout(rt, 0);
|
||||||
|
if (methods.set_master)
|
||||||
|
ftr_gpio_set_master(rt, 0);
|
||||||
rt->implementation_private = saved;
|
rt->implementation_private = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +200,8 @@ static void ftr_gpio_all_amps_restore(struct gpio_runtime *rt)
|
||||||
ftr_gpio_set_headphone(rt, (s>>0)&1);
|
ftr_gpio_set_headphone(rt, (s>>0)&1);
|
||||||
ftr_gpio_set_amp(rt, (s>>1)&1);
|
ftr_gpio_set_amp(rt, (s>>1)&1);
|
||||||
ftr_gpio_set_lineout(rt, (s>>2)&1);
|
ftr_gpio_set_lineout(rt, (s>>2)&1);
|
||||||
|
if (methods.set_master)
|
||||||
|
ftr_gpio_set_master(rt, (s>>3)&1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ftr_handle_notify(struct work_struct *work)
|
static void ftr_handle_notify(struct work_struct *work)
|
||||||
|
@ -231,6 +240,12 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
|
||||||
get_gpio("hw-reset", "audio-hw-reset",
|
get_gpio("hw-reset", "audio-hw-reset",
|
||||||
&hw_reset_gpio,
|
&hw_reset_gpio,
|
||||||
&hw_reset_gpio_activestate);
|
&hw_reset_gpio_activestate);
|
||||||
|
if (get_gpio("master-mute", NULL,
|
||||||
|
&master_mute_gpio,
|
||||||
|
&master_mute_gpio_activestate)) {
|
||||||
|
methods.set_master = ftr_gpio_set_master;
|
||||||
|
methods.get_master = ftr_gpio_get_master;
|
||||||
|
}
|
||||||
|
|
||||||
headphone_detect_node = get_gpio("headphone-detect", NULL,
|
headphone_detect_node = get_gpio("headphone-detect", NULL,
|
||||||
&headphone_detect_gpio,
|
&headphone_detect_gpio,
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
/*
|
/*
|
||||||
* Apple Onboard Audio driver -- layout fabric
|
* Apple Onboard Audio driver -- layout/machine id fabric
|
||||||
*
|
*
|
||||||
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
* Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
|
||||||
*
|
*
|
||||||
* GPL v2, can be found in COPYING.
|
* GPL v2, can be found in COPYING.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This fabric module looks for sound codecs
|
* This fabric module looks for sound codecs based on the
|
||||||
* based on the layout-id property in the device tree.
|
* layout-id or device-id property in the device tree.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm/prom.h>
|
#include <asm/prom.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
@ -63,7 +61,7 @@ struct codec_connect_info {
|
||||||
#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
|
#define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
|
||||||
|
|
||||||
struct layout {
|
struct layout {
|
||||||
unsigned int layout_id;
|
unsigned int layout_id, device_id;
|
||||||
struct codec_connect_info codecs[MAX_CODECS_PER_BUS];
|
struct codec_connect_info codecs[MAX_CODECS_PER_BUS];
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
@ -111,6 +109,10 @@ MODULE_ALIAS("sound-layout-96");
|
||||||
MODULE_ALIAS("sound-layout-98");
|
MODULE_ALIAS("sound-layout-98");
|
||||||
MODULE_ALIAS("sound-layout-100");
|
MODULE_ALIAS("sound-layout-100");
|
||||||
|
|
||||||
|
MODULE_ALIAS("aoa-device-id-14");
|
||||||
|
MODULE_ALIAS("aoa-device-id-22");
|
||||||
|
MODULE_ALIAS("aoa-device-id-35");
|
||||||
|
|
||||||
/* onyx with all but microphone connected */
|
/* onyx with all but microphone connected */
|
||||||
static struct codec_connection onyx_connections_nomic[] = {
|
static struct codec_connection onyx_connections_nomic[] = {
|
||||||
{
|
{
|
||||||
|
@ -518,6 +520,27 @@ static struct layout layouts[] = {
|
||||||
.connections = onyx_connections_noheadphones,
|
.connections = onyx_connections_noheadphones,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
/* PowerMac3,4 */
|
||||||
|
{ .device_id = 14,
|
||||||
|
.codecs[0] = {
|
||||||
|
.name = "tas",
|
||||||
|
.connections = tas_connections_noline,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* PowerMac3,6 */
|
||||||
|
{ .device_id = 22,
|
||||||
|
.codecs[0] = {
|
||||||
|
.name = "tas",
|
||||||
|
.connections = tas_connections_all,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* PowerBook5,2 */
|
||||||
|
{ .device_id = 35,
|
||||||
|
.codecs[0] = {
|
||||||
|
.name = "tas",
|
||||||
|
.connections = tas_connections_all,
|
||||||
|
},
|
||||||
|
},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -526,7 +549,7 @@ static struct layout *find_layout_by_id(unsigned int id)
|
||||||
struct layout *l;
|
struct layout *l;
|
||||||
|
|
||||||
l = layouts;
|
l = layouts;
|
||||||
while (l->layout_id) {
|
while (l->codecs[0].name) {
|
||||||
if (l->layout_id == id)
|
if (l->layout_id == id)
|
||||||
return l;
|
return l;
|
||||||
l++;
|
l++;
|
||||||
|
@ -534,6 +557,19 @@ static struct layout *find_layout_by_id(unsigned int id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct layout *find_layout_by_device(unsigned int id)
|
||||||
|
{
|
||||||
|
struct layout *l;
|
||||||
|
|
||||||
|
l = layouts;
|
||||||
|
while (l->codecs[0].name) {
|
||||||
|
if (l->device_id == id)
|
||||||
|
return l;
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void use_layout(struct layout *l)
|
static void use_layout(struct layout *l)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -564,6 +600,7 @@ struct layout_dev {
|
||||||
struct snd_kcontrol *headphone_ctrl;
|
struct snd_kcontrol *headphone_ctrl;
|
||||||
struct snd_kcontrol *lineout_ctrl;
|
struct snd_kcontrol *lineout_ctrl;
|
||||||
struct snd_kcontrol *speaker_ctrl;
|
struct snd_kcontrol *speaker_ctrl;
|
||||||
|
struct snd_kcontrol *master_ctrl;
|
||||||
struct snd_kcontrol *headphone_detected_ctrl;
|
struct snd_kcontrol *headphone_detected_ctrl;
|
||||||
struct snd_kcontrol *lineout_detected_ctrl;
|
struct snd_kcontrol *lineout_detected_ctrl;
|
||||||
|
|
||||||
|
@ -615,6 +652,7 @@ static struct snd_kcontrol_new n##_ctl = { \
|
||||||
AMP_CONTROL(headphone, "Headphone Switch");
|
AMP_CONTROL(headphone, "Headphone Switch");
|
||||||
AMP_CONTROL(speakers, "Speakers Switch");
|
AMP_CONTROL(speakers, "Speakers Switch");
|
||||||
AMP_CONTROL(lineout, "Line-Out Switch");
|
AMP_CONTROL(lineout, "Line-Out Switch");
|
||||||
|
AMP_CONTROL(master, "Master Switch");
|
||||||
|
|
||||||
static int detect_choice_get(struct snd_kcontrol *kcontrol,
|
static int detect_choice_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
|
@ -855,6 +893,11 @@ static void layout_attached_codec(struct aoa_codec *codec)
|
||||||
lineout = codec->gpio->methods->get_detect(codec->gpio,
|
lineout = codec->gpio->methods->get_detect(codec->gpio,
|
||||||
AOA_NOTIFY_LINE_OUT);
|
AOA_NOTIFY_LINE_OUT);
|
||||||
|
|
||||||
|
if (codec->gpio->methods->set_master) {
|
||||||
|
ctl = snd_ctl_new1(&master_ctl, codec->gpio);
|
||||||
|
ldev->master_ctrl = ctl;
|
||||||
|
aoa_snd_ctl_add(ctl);
|
||||||
|
}
|
||||||
while (cc->connected) {
|
while (cc->connected) {
|
||||||
if (cc->connected & CC_SPEAKERS) {
|
if (cc->connected & CC_SPEAKERS) {
|
||||||
if (headphones <= 0 && lineout <= 0)
|
if (headphones <= 0 && lineout <= 0)
|
||||||
|
@ -938,8 +981,8 @@ static struct aoa_fabric layout_fabric = {
|
||||||
static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
|
static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
|
||||||
{
|
{
|
||||||
struct device_node *sound = NULL;
|
struct device_node *sound = NULL;
|
||||||
const unsigned int *layout_id;
|
const unsigned int *id;
|
||||||
struct layout *layout;
|
struct layout *layout = NULL;
|
||||||
struct layout_dev *ldev = NULL;
|
struct layout_dev *ldev = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -952,15 +995,18 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
|
||||||
if (sound->type && strcasecmp(sound->type, "soundchip") == 0)
|
if (sound->type && strcasecmp(sound->type, "soundchip") == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!sound) return -ENODEV;
|
if (!sound)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
layout_id = of_get_property(sound, "layout-id", NULL);
|
id = of_get_property(sound, "layout-id", NULL);
|
||||||
if (!layout_id)
|
if (id) {
|
||||||
goto outnodev;
|
layout = find_layout_by_id(*id);
|
||||||
printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n",
|
} else {
|
||||||
*layout_id);
|
id = of_get_property(sound, "device-id", NULL);
|
||||||
|
if (id)
|
||||||
|
layout = find_layout_by_device(*id);
|
||||||
|
}
|
||||||
|
|
||||||
layout = find_layout_by_id(*layout_id);
|
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");
|
printk(KERN_ERR "snd-aoa-fabric-layout: unknown layout\n");
|
||||||
goto outnodev;
|
goto outnodev;
|
||||||
|
@ -976,6 +1022,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
|
||||||
ldev->layout = layout;
|
ldev->layout = layout;
|
||||||
ldev->gpio.node = sound->parent;
|
ldev->gpio.node = sound->parent;
|
||||||
switch (layout->layout_id) {
|
switch (layout->layout_id) {
|
||||||
|
case 0: /* anything with device_id, not layout_id */
|
||||||
case 41: /* that unknown machine no one seems to have */
|
case 41: /* that unknown machine no one seems to have */
|
||||||
case 51: /* PowerBook5,4 */
|
case 51: /* PowerBook5,4 */
|
||||||
case 58: /* Mac Mini */
|
case 58: /* Mac Mini */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* i2sbus driver
|
* i2sbus driver
|
||||||
*
|
*
|
||||||
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
* Copyright 2006-2008 Johannes Berg <johannes@sipsolutions.net>
|
||||||
*
|
*
|
||||||
* GPL v2, can be found in COPYING.
|
* GPL v2, can be found in COPYING.
|
||||||
*/
|
*/
|
||||||
|
@ -186,13 +186,25 @@ static int i2sbus_add_dev(struct macio_dev *macio,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
const u32 *layout_id =
|
const u32 *id = of_get_property(sound, "layout-id", NULL);
|
||||||
of_get_property(sound, "layout-id", NULL);
|
|
||||||
if (layout_id) {
|
if (id) {
|
||||||
layout = *layout_id;
|
layout = *id;
|
||||||
snprintf(dev->sound.modalias, 32,
|
snprintf(dev->sound.modalias, 32,
|
||||||
"sound-layout-%d", layout);
|
"sound-layout-%d", layout);
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
} else {
|
||||||
|
id = of_get_property(sound, "device-id", NULL);
|
||||||
|
/*
|
||||||
|
* We probably cannot handle all device-id machines,
|
||||||
|
* so restrict to those we do handle for now.
|
||||||
|
*/
|
||||||
|
if (id && (*id == 22 || *id == 14 || *id == 35)) {
|
||||||
|
snprintf(dev->sound.modalias, 32,
|
||||||
|
"aoa-device-id-%d", *id);
|
||||||
|
ok = 1;
|
||||||
|
layout = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* for the time being, until we can handle non-layout-id
|
/* for the time being, until we can handle non-layout-id
|
||||||
|
|
Loading…
Reference in a new issue