Release 4.11 sound/pci/cs5535audio/cs5535audio_olpc.c
/*
* OLPC XO-1 additional sound features
*
* Copyright © 2006 Jaya Kumar <jayakumar.lkml@gmail.com>
* Copyright © 2007-2008 Andres Salomon <dilinger@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <sound/core.h>
#include <sound/info.h>
#include <sound/control.h>
#include <sound/ac97_codec.h>
#include <linux/gpio.h>
#include <asm/olpc.h>
#include "cs5535audio.h"
#define DRV_NAME "cs5535audio-olpc"
/*
* OLPC has an additional feature on top of the regular AD1888 codec features.
* It has an Analog Input mode that is switched into (after disabling the
* High Pass Filter) via GPIO. It is supported on B2 and later models.
*/
void olpc_analog_input(struct snd_ac97 *ac97, int on)
{
int err;
if (!machine_is_olpc())
return;
/* update the High Pass Filter (via AC97_AD_TEST2) */
err = snd_ac97_update_bits(ac97, AC97_AD_TEST2,
1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT);
if (err < 0) {
dev_err(ac97->bus->card->dev,
"setting High Pass Filter - %d\n", err);
return;
}
/* set Analog Input through GPIO */
gpio_set_value(OLPC_GPIO_MIC_AC, on);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 64 | 87.67% | 3 | 75.00% |
Takashi Iwai | 9 | 12.33% | 1 | 25.00% |
Total | 73 | 100.00% | 4 | 100.00% |
/*
* OLPC XO-1's V_REFOUT is a mic bias enable.
*/
void olpc_mic_bias(struct snd_ac97 *ac97, int on)
{
int err;
if (!machine_is_olpc())
return;
on = on ? 0 : 1;
err = snd_ac97_update_bits(ac97, AC97_AD_MISC,
1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT);
if (err < 0)
dev_err(ac97->bus->card->dev, "setting MIC Bias - %d\n", err);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 60 | 86.96% | 2 | 66.67% |
Takashi Iwai | 9 | 13.04% | 1 | 33.33% |
Total | 69 | 100.00% | 3 | 100.00% |
static int olpc_dc_info(struct snd_kcontrol *kctl,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jaya Kumar | 49 | 96.08% | 1 | 50.00% |
Andres Salomon | 2 | 3.92% | 1 | 50.00% |
Total | 51 | 100.00% | 2 | 100.00% |
static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
{
v->value.integer.value[0] = gpio_get_value(OLPC_GPIO_MIC_AC);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jaya Kumar | 27 | 77.14% | 1 | 25.00% |
Andres Salomon | 8 | 22.86% | 3 | 75.00% |
Total | 35 | 100.00% | 4 | 100.00% |
static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
{
struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
olpc_analog_input(cs5535au->ac97, v->value.integer.value[0]);
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jaya Kumar | 39 | 82.98% | 1 | 33.33% |
Andres Salomon | 8 | 17.02% | 2 | 66.67% |
Total | 47 | 100.00% | 3 | 100.00% |
static int olpc_mic_info(struct snd_kcontrol *kctl,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 51 | 100.00% | 1 | 100.00% |
Total | 51 | 100.00% | 1 | 100.00% |
static int olpc_mic_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
{
struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
struct snd_ac97 *ac97 = cs5535au->ac97;
int i;
i = (snd_ac97_read(ac97, AC97_AD_MISC) >> AC97_AD_VREFD_SHIFT) & 0x1;
v->value.integer.value[0] = i ? 0 : 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 73 | 100.00% | 1 | 100.00% |
Total | 73 | 100.00% | 1 | 100.00% |
static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
{
struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl);
olpc_mic_bias(cs5535au->ac97, v->value.integer.value[0]);
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 47 | 100.00% | 1 | 100.00% |
Total | 47 | 100.00% | 1 | 100.00% |
static struct snd_kcontrol_new olpc_cs5535audio_ctls[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "DC Mode Enable",
.info = olpc_dc_info,
.get = olpc_dc_get,
.put = olpc_dc_put,
.private_value = 0,
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "MIC Bias Enable",
.info = olpc_mic_info,
.get = olpc_mic_get,
.put = olpc_mic_put,
.private_value = 0,
},
};
void olpc_prequirks(struct snd_card *card,
struct snd_ac97_template *ac97)
{
if (!machine_is_olpc())
return;
/* invert EAPD if on an OLPC B3 or higher */
if (olpc_board_at_least(olpc_board_pre(0xb3)))
ac97->scaps |= AC97_SCAP_INV_EAPD;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 39 | 100.00% | 1 | 100.00% |
Total | 39 | 100.00% | 1 | 100.00% |
int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
{
struct snd_ctl_elem_id elem;
int i, err;
if (!machine_is_olpc())
return 0;
if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) {
dev_err(card->dev, "unable to allocate MIC GPIO\n");
return -EIO;
}
gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
/* drop the original AD1888 HPF control */
memset(&elem, 0, sizeof(elem));
elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
strlcpy(elem.name, "High Pass Filter Enable", sizeof(elem.name));
snd_ctl_remove_id(card, &elem);
/* drop the original V_REFOUT control */
memset(&elem, 0, sizeof(elem));
elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
strlcpy(elem.name, "V_REFOUT Enable", sizeof(elem.name));
snd_ctl_remove_id(card, &elem);
/* add the OLPC-specific controls */
for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) {
err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i],
ac97->private_data));
if (err < 0) {
gpio_free(OLPC_GPIO_MIC_AC);
return err;
}
}
/* turn off the mic by default */
olpc_mic_bias(ac97, 0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 171 | 78.44% | 4 | 50.00% |
Jaya Kumar | 29 | 13.30% | 1 | 12.50% |
Takashi Iwai | 9 | 4.13% | 2 | 25.00% |
Jordan Crouse | 9 | 4.13% | 1 | 12.50% |
Total | 218 | 100.00% | 8 | 100.00% |
void olpc_quirks_cleanup(void)
{
gpio_free(OLPC_GPIO_MIC_AC);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 12 | 100.00% | 1 | 100.00% |
Total | 12 | 100.00% | 1 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andres Salomon | 586 | 71.90% | 9 | 69.23% |
Jaya Kumar | 190 | 23.31% | 1 | 7.69% |
Takashi Iwai | 27 | 3.31% | 2 | 15.38% |
Jordan Crouse | 12 | 1.47% | 1 | 7.69% |
Bill Pemberton | | 0.00% | 0 | 0.00% |
Total | 815 | 100.00% | 13 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.