mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
Merge branch 'topic/jack' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-tegra
This commit is contained in:
commit
c77dc2c203
31 changed files with 167 additions and 231 deletions
|
@ -450,8 +450,10 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_dai *dai);
|
||||
|
||||
/* Jack reporting */
|
||||
int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
|
||||
struct snd_soc_jack *jack);
|
||||
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
|
||||
struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
|
||||
unsigned int num_pins);
|
||||
|
||||
void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
|
||||
int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
|
||||
struct snd_soc_jack_pin *pins);
|
||||
|
@ -659,7 +661,7 @@ struct snd_soc_jack_gpio {
|
|||
struct snd_soc_jack {
|
||||
struct mutex mutex;
|
||||
struct snd_jack *jack;
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_card *card;
|
||||
struct list_head pins;
|
||||
int status;
|
||||
struct blocking_notifier_head notifier;
|
||||
|
|
|
@ -783,19 +783,21 @@ static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec)
|
|||
snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
|
||||
}
|
||||
|
||||
static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack)
|
||||
static int sn95031_get_headset_state(struct snd_soc_codec *codec,
|
||||
struct snd_soc_jack *mfld_jack)
|
||||
{
|
||||
int micbias = sn95031_get_mic_bias(mfld_jack->codec);
|
||||
int micbias = sn95031_get_mic_bias(codec);
|
||||
|
||||
int jack_type = snd_soc_jack_get_type(mfld_jack, micbias);
|
||||
|
||||
pr_debug("jack type detected = %d\n", jack_type);
|
||||
if (jack_type == SND_JACK_HEADSET)
|
||||
sn95031_enable_jack_btn(mfld_jack->codec);
|
||||
sn95031_enable_jack_btn(codec);
|
||||
return jack_type;
|
||||
}
|
||||
|
||||
void sn95031_jack_detection(struct mfld_jack_data *jack_data)
|
||||
void sn95031_jack_detection(struct snd_soc_codec *codec,
|
||||
struct mfld_jack_data *jack_data)
|
||||
{
|
||||
unsigned int status;
|
||||
unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET;
|
||||
|
@ -809,11 +811,11 @@ void sn95031_jack_detection(struct mfld_jack_data *jack_data)
|
|||
status = SND_JACK_HEADSET | SND_JACK_BTN_1;
|
||||
} else if (jack_data->intr_id & 0x4) {
|
||||
pr_debug("headset or headphones inserted\n");
|
||||
status = sn95031_get_headset_state(jack_data->mfld_jack);
|
||||
status = sn95031_get_headset_state(codec, jack_data->mfld_jack);
|
||||
} else if (jack_data->intr_id & 0x8) {
|
||||
pr_debug("headset or headphones removed\n");
|
||||
status = 0;
|
||||
sn95031_disable_jack_btn(jack_data->mfld_jack->codec);
|
||||
sn95031_disable_jack_btn(codec);
|
||||
} else {
|
||||
pr_err("unidentified interrupt\n");
|
||||
return;
|
||||
|
|
|
@ -127,6 +127,7 @@ struct mfld_jack_data {
|
|||
struct snd_soc_jack *mfld_jack;
|
||||
};
|
||||
|
||||
extern void sn95031_jack_detection(struct mfld_jack_data *jack_data);
|
||||
extern void sn95031_jack_detection(struct snd_soc_codec *codec,
|
||||
struct mfld_jack_data *jack_data);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,9 +53,9 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
/* Headphone jack detection */
|
||||
if (gpio_is_valid(data->jack_gpio)) {
|
||||
ret = snd_soc_jack_new(rtd->codec, "Headphone",
|
||||
SND_JACK_HEADPHONE | SND_JACK_BTN_0,
|
||||
&headset_jack);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headphone",
|
||||
SND_JACK_HEADPHONE | SND_JACK_BTN_0,
|
||||
&headset_jack, NULL, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -205,16 +205,14 @@ static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd)
|
|||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
|
||||
/* Headphone jack detection */
|
||||
snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, &hp_jack);
|
||||
snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
|
||||
hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE,
|
||||
&hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
|
||||
wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE);
|
||||
|
||||
/* Microphone jack detection */
|
||||
snd_soc_jack_new(codec, "Microphone",
|
||||
SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack);
|
||||
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
|
||||
mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Microphone",
|
||||
SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack,
|
||||
mic_jack_pins, ARRAY_SIZE(mic_jack_pins));
|
||||
wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE,
|
||||
SND_JACK_BTN_0);
|
||||
|
||||
|
|
|
@ -176,11 +176,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
|||
return ret;
|
||||
|
||||
if (gpio_is_valid(priv->gpio_hp_det)) {
|
||||
snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE,
|
||||
&simple_card_hp_jack);
|
||||
snd_soc_jack_add_pins(&simple_card_hp_jack,
|
||||
ARRAY_SIZE(simple_card_hp_jack_pins),
|
||||
simple_card_hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphones",
|
||||
SND_JACK_HEADPHONE,
|
||||
&simple_card_hp_jack,
|
||||
simple_card_hp_jack_pins,
|
||||
ARRAY_SIZE(simple_card_hp_jack_pins));
|
||||
|
||||
simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
|
||||
simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert;
|
||||
|
@ -189,11 +189,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
|||
}
|
||||
|
||||
if (gpio_is_valid(priv->gpio_mic_det)) {
|
||||
snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&simple_card_mic_jack);
|
||||
snd_soc_jack_add_pins(&simple_card_mic_jack,
|
||||
ARRAY_SIZE(simple_card_mic_jack_pins),
|
||||
simple_card_mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Mic Jack",
|
||||
SND_JACK_MICROPHONE,
|
||||
&simple_card_mic_jack,
|
||||
simple_card_mic_jack_pins,
|
||||
ARRAY_SIZE(simple_card_mic_jack_pins));
|
||||
simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
|
||||
simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert;
|
||||
snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
|
||||
|
|
|
@ -80,15 +80,9 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
int ret = 0;
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&broadwell_headset,
|
||||
ARRAY_SIZE(broadwell_headset_pins),
|
||||
broadwell_headset_pins);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset",
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset,
|
||||
broadwell_headset_pins, ARRAY_SIZE(broadwell_headset_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -84,7 +84,6 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = {
|
|||
static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_codec *codec = runtime->codec;
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_jack *jack = &drv->jack;
|
||||
|
@ -100,13 +99,9 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
|
|||
}
|
||||
|
||||
/* Enable jack detection */
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_LINEOUT | SND_JACK_HEADSET, jack);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(jack, ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
ret = snd_soc_card_jack_new(runtime->card, "Headset",
|
||||
SND_JACK_LINEOUT | SND_JACK_HEADSET, jack,
|
||||
hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -169,17 +169,17 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE,
|
||||
&ctx->hp_jack);
|
||||
ret = snd_soc_card_jack_new(runtime->card, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &ctx->hp_jack,
|
||||
NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(runtime->dev, "HP jack creation failed %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Mic Jack",
|
||||
SND_JACK_MICROPHONE,
|
||||
&ctx->mic_jack);
|
||||
ret = snd_soc_card_jack_new(runtime->card, "Mic Jack",
|
||||
SND_JACK_MICROPHONE, &ctx->mic_jack,
|
||||
NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(runtime->dev, "Mic jack creation failed %d\n", ret);
|
||||
return ret;
|
||||
|
|
|
@ -228,10 +228,13 @@ static void mfld_jack_check(unsigned int intr_status)
|
|||
{
|
||||
struct mfld_jack_data jack_data;
|
||||
|
||||
if (!mfld_codec)
|
||||
return;
|
||||
|
||||
jack_data.mfld_jack = &mfld_jack;
|
||||
jack_data.intr_id = intr_status;
|
||||
|
||||
sn95031_jack_detection(&jack_data);
|
||||
sn95031_jack_detection(mfld_codec, &jack_data);
|
||||
/* TODO: add american headset detection post gpiolib support */
|
||||
}
|
||||
|
||||
|
@ -240,8 +243,6 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
|
|||
struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
|
||||
int ret_val;
|
||||
|
||||
mfld_codec = runtime->codec;
|
||||
|
||||
/* default is earpiece pin, userspace sets it explcitly */
|
||||
snd_soc_dapm_disable_pin(dapm, "Headphones");
|
||||
/* default is lineout NC, userspace sets it explcitly */
|
||||
|
@ -254,20 +255,15 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
|
|||
snd_soc_dapm_disable_pin(dapm, "LINEINR");
|
||||
|
||||
/* Headset and button jack detection */
|
||||
ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack",
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0 |
|
||||
SND_JACK_BTN_1, &mfld_jack);
|
||||
ret_val = snd_soc_card_jack_new(runtime->card,
|
||||
"Intel(R) MID Audio Jack", SND_JACK_HEADSET |
|
||||
SND_JACK_BTN_0 | SND_JACK_BTN_1, &mfld_jack,
|
||||
mfld_jack_pins, ARRAY_SIZE(mfld_jack_pins));
|
||||
if (ret_val) {
|
||||
pr_err("jack creation failed\n");
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
ret_val = snd_soc_jack_add_pins(&mfld_jack,
|
||||
ARRAY_SIZE(mfld_jack_pins), mfld_jack_pins);
|
||||
if (ret_val) {
|
||||
pr_err("adding jack pins failed\n");
|
||||
return ret_val;
|
||||
}
|
||||
ret_val = snd_soc_jack_add_zones(&mfld_jack,
|
||||
ARRAY_SIZE(mfld_zones), mfld_zones);
|
||||
if (ret_val) {
|
||||
|
@ -275,6 +271,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
mfld_codec = runtime->codec;
|
||||
|
||||
/* we want to check if anything is inserted at boot,
|
||||
* so send a fake event to codec and it will read adc
|
||||
* to find if anything is there or not */
|
||||
|
@ -359,8 +357,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data)
|
|||
{
|
||||
struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data;
|
||||
|
||||
if (mfld_jack.codec == NULL)
|
||||
return IRQ_HANDLED;
|
||||
mfld_jack_check(mc_drv_ctx->interrupt_status);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
|
|
@ -479,8 +479,8 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
/* Add hook switch - can be used to control the codec from userspace
|
||||
* even if line discipline fails */
|
||||
ret = snd_soc_jack_new(rtd->codec, "hook_switch",
|
||||
SND_JACK_HEADSET, &ams_delta_hook_switch);
|
||||
ret = snd_soc_card_jack_new(card, "hook_switch", SND_JACK_HEADSET,
|
||||
&ams_delta_hook_switch, NULL, 0);
|
||||
if (ret)
|
||||
dev_warn(card->dev,
|
||||
"Failed to allocate resources for hook switch, "
|
||||
|
|
|
@ -182,17 +182,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
/* Headset jack detection only if it is supported */
|
||||
if (priv->jack_detection) {
|
||||
ret = snd_soc_jack_new(codec, "Headset Jack",
|
||||
SND_JACK_HEADSET, &hs_jack);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
|
||||
SND_JACK_HEADSET, &hs_jack,
|
||||
hs_jack_pins,
|
||||
ARRAY_SIZE(hs_jack_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_route dmic_audio_map[] = {
|
||||
|
|
|
@ -170,14 +170,10 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
|
|||
if (priv->jack_detect > 0) {
|
||||
hs_jack_gpios[0].gpio = priv->jack_detect;
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
|
||||
&priv->hs_jack);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&priv->hs_jack,
|
||||
ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
|
||||
SND_JACK_HEADSET, &priv->hs_jack,
|
||||
hs_jack_pins,
|
||||
ARRAY_SIZE(hs_jack_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -311,9 +311,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
|
|||
}
|
||||
|
||||
/* AV jack detection */
|
||||
err = snd_soc_jack_new(codec, "AV Jack",
|
||||
SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
|
||||
&rx51_av_jack);
|
||||
err = snd_soc_card_jack_new(rtd->card, "AV Jack",
|
||||
SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
|
||||
&rx51_av_jack, NULL, 0);
|
||||
if (err) {
|
||||
dev_err(card->dev, "Failed to add AV Jack\n");
|
||||
return err;
|
||||
|
|
|
@ -126,17 +126,12 @@ static const struct snd_soc_dapm_route hx4700_audio_map[] = {
|
|||
*/
|
||||
static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
int err;
|
||||
|
||||
/* Jack detection API stuff */
|
||||
err = snd_soc_jack_new(codec, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &hs_jack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pin),
|
||||
hs_jack_pin);
|
||||
err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &hs_jack, hs_jack_pin,
|
||||
ARRAY_SIZE(hs_jack_pin));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -75,17 +75,12 @@ static struct snd_soc_card palm27x_asoc;
|
|||
|
||||
static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
int err;
|
||||
|
||||
/* Jack detection API stuff */
|
||||
err = snd_soc_jack_new(codec, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &hs_jack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &hs_jack, hs_jack_pins,
|
||||
ARRAY_SIZE(hs_jack_pins));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -78,15 +78,12 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
|
|||
struct snd_soc_codec *codec = rtd->codec;
|
||||
|
||||
/* Headset jack detection */
|
||||
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE
|
||||
| SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
|
||||
&hs_jack);
|
||||
snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE,
|
||||
&mic_jack);
|
||||
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
|
||||
mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
|
||||
SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
|
||||
&hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
|
||||
snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE,
|
||||
&mic_jack, mic_jack_pins,
|
||||
ARRAY_SIZE(mic_jack_pins));
|
||||
|
||||
/* headphone, microphone detection & headset short detection */
|
||||
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
|
||||
|
|
|
@ -143,13 +143,9 @@ static int z2_wm8750_init(struct snd_soc_pcm_runtime *rtd)
|
|||
snd_soc_dapm_disable_pin(dapm, "MONO1");
|
||||
|
||||
/* Jack detection API stuff */
|
||||
ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
|
||||
&hs_jack);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
|
||||
hs_jack_pins);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
|
||||
&hs_jack, hs_jack_pins,
|
||||
ARRAY_SIZE(hs_jack_pins));
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
|
|
|
@ -162,13 +162,8 @@ static struct platform_device *s3c24xx_snd_device;
|
|||
|
||||
static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
|
||||
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&hp_jack);
|
||||
|
||||
snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
|
||||
hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
|
||||
|
||||
snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
|
||||
hp_jack_gpios);
|
||||
|
|
|
@ -260,12 +260,12 @@ static int littlemill_late_probe(struct snd_soc_card *card)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_HEADSET | SND_JACK_MECHANICAL |
|
||||
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
||||
SND_JACK_BTN_2 | SND_JACK_BTN_3 |
|
||||
SND_JACK_BTN_4 | SND_JACK_BTN_5,
|
||||
&littlemill_headset);
|
||||
ret = snd_soc_card_jack_new(card, "Headset",
|
||||
SND_JACK_HEADSET | SND_JACK_MECHANICAL |
|
||||
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
||||
SND_JACK_BTN_2 | SND_JACK_BTN_3 |
|
||||
SND_JACK_BTN_4 | SND_JACK_BTN_5,
|
||||
&littlemill_headset, NULL, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -56,16 +56,10 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_LINEOUT | SND_JACK_HEADSET |
|
||||
SND_JACK_BTN_0,
|
||||
&lowland_headset);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&lowland_headset,
|
||||
ARRAY_SIZE(lowland_headset_pins),
|
||||
lowland_headset_pins);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0,
|
||||
&lowland_headset, lowland_headset_pins,
|
||||
ARRAY_SIZE(lowland_headset_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -211,13 +211,8 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
|
||||
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&hp_jack);
|
||||
|
||||
snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
|
||||
hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
|
||||
|
||||
snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
|
||||
hp_jack_gpios);
|
||||
|
|
|
@ -151,13 +151,10 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd)
|
|||
snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
|
||||
|
||||
/* Headphone jack detection */
|
||||
err = snd_soc_jack_new(codec, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &smartq_jack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = snd_soc_jack_add_pins(&smartq_jack, ARRAY_SIZE(smartq_jack_pins),
|
||||
smartq_jack_pins);
|
||||
err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &smartq_jack,
|
||||
smartq_jack_pins,
|
||||
ARRAY_SIZE(smartq_jack_pins));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
@ -153,16 +153,10 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
|
|||
pr_err("Failed to request HP_SEL GPIO: %d\n", ret);
|
||||
gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_LINEOUT | SND_JACK_HEADSET |
|
||||
SND_JACK_BTN_0,
|
||||
&speyside_headset);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&speyside_headset,
|
||||
ARRAY_SIZE(speyside_headset_pins),
|
||||
speyside_headset_pins);
|
||||
ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0,
|
||||
&speyside_headset, speyside_headset_pins,
|
||||
ARRAY_SIZE(speyside_headset_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -179,15 +179,10 @@ static int tobermory_late_probe(struct snd_soc_card *card)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_new(codec, "Headset",
|
||||
SND_JACK_HEADSET | SND_JACK_BTN_0,
|
||||
&tobermory_headset);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_jack_add_pins(&tobermory_headset,
|
||||
ARRAY_SIZE(tobermory_headset_pins),
|
||||
tobermory_headset_pins);
|
||||
ret = snd_soc_card_jack_new(card, "Headset", SND_JACK_HEADSET |
|
||||
SND_JACK_BTN_0, &tobermory_headset,
|
||||
tobermory_headset_pins,
|
||||
ARRAY_SIZE(tobermory_headset_pins));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -22,30 +22,42 @@
|
|||
#include <trace/events/asoc.h>
|
||||
|
||||
/**
|
||||
* snd_soc_jack_new - Create a new jack
|
||||
* @codec: ASoC codec
|
||||
* snd_soc_card_jack_new - Create a new jack
|
||||
* @card: ASoC card
|
||||
* @id: an identifying string for this jack
|
||||
* @type: a bitmask of enum snd_jack_type values that can be detected by
|
||||
* this jack
|
||||
* @jack: structure to use for the jack
|
||||
* @pins: Array of jack pins to be added to the jack or NULL
|
||||
* @num_pins: Number of elements in the @pins array
|
||||
*
|
||||
* Creates a new jack object.
|
||||
*
|
||||
* Returns zero if successful, or a negative error code on failure.
|
||||
* On success jack will be initialised.
|
||||
*/
|
||||
int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
|
||||
struct snd_soc_jack *jack)
|
||||
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
|
||||
struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
|
||||
unsigned int num_pins)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_init(&jack->mutex);
|
||||
jack->codec = codec;
|
||||
jack->card = card;
|
||||
INIT_LIST_HEAD(&jack->pins);
|
||||
INIT_LIST_HEAD(&jack->jack_zones);
|
||||
BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
|
||||
|
||||
return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack);
|
||||
ret = snd_jack_new(card->snd_card, id, type, &jack->jack);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (num_pins)
|
||||
return snd_soc_jack_add_pins(jack, num_pins, pins);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_jack_new);
|
||||
EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);
|
||||
|
||||
/**
|
||||
* snd_soc_jack_report - Report the current status for a jack
|
||||
|
@ -63,7 +75,6 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new);
|
|||
*/
|
||||
void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
|
||||
{
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_dapm_context *dapm;
|
||||
struct snd_soc_jack_pin *pin;
|
||||
unsigned int sync = 0;
|
||||
|
@ -74,8 +85,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
|
|||
if (!jack)
|
||||
return;
|
||||
|
||||
codec = jack->codec;
|
||||
dapm = &codec->dapm;
|
||||
dapm = &jack->card->dapm;
|
||||
|
||||
mutex_lock(&jack->mutex);
|
||||
|
||||
|
@ -175,12 +185,12 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!pins[i].pin) {
|
||||
dev_err(jack->codec->dev, "ASoC: No name for pin %d\n",
|
||||
dev_err(jack->card->dev, "ASoC: No name for pin %d\n",
|
||||
i);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!pins[i].mask) {
|
||||
dev_err(jack->codec->dev, "ASoC: No mask for pin %d"
|
||||
dev_err(jack->card->dev, "ASoC: No mask for pin %d"
|
||||
" (%s)\n", i, pins[i].pin);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -260,7 +270,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
|
|||
static irqreturn_t gpio_handler(int irq, void *data)
|
||||
{
|
||||
struct snd_soc_jack_gpio *gpio = data;
|
||||
struct device *dev = gpio->jack->codec->component.card->dev;
|
||||
struct device *dev = gpio->jack->card->dev;
|
||||
|
||||
trace_snd_soc_jack_irq(gpio->name);
|
||||
|
||||
|
@ -299,7 +309,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!gpios[i].name) {
|
||||
dev_err(jack->codec->dev,
|
||||
dev_err(jack->card->dev,
|
||||
"ASoC: No name for gpio at index %d\n", i);
|
||||
ret = -EINVAL;
|
||||
goto undo;
|
||||
|
@ -320,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
|||
} else {
|
||||
/* legacy GPIO number */
|
||||
if (!gpio_is_valid(gpios[i].gpio)) {
|
||||
dev_err(jack->codec->dev,
|
||||
dev_err(jack->card->dev,
|
||||
"ASoC: Invalid gpio %d\n",
|
||||
gpios[i].gpio);
|
||||
ret = -EINVAL;
|
||||
|
@ -350,7 +360,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
|||
if (gpios[i].wake) {
|
||||
ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1);
|
||||
if (ret != 0)
|
||||
dev_err(jack->codec->dev,
|
||||
dev_err(jack->card->dev,
|
||||
"ASoC: Failed to mark GPIO at index %d as wake source: %d\n",
|
||||
i, ret);
|
||||
}
|
||||
|
|
|
@ -106,11 +106,10 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
|||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card);
|
||||
|
||||
snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
|
||||
&tegra_alc5632_hs_jack);
|
||||
snd_soc_jack_add_pins(&tegra_alc5632_hs_jack,
|
||||
ARRAY_SIZE(tegra_alc5632_hs_jack_pins),
|
||||
tegra_alc5632_hs_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
|
||||
&tegra_alc5632_hs_jack,
|
||||
tegra_alc5632_hs_jack_pins,
|
||||
ARRAY_SIZE(tegra_alc5632_hs_jack_pins));
|
||||
|
||||
if (gpio_is_valid(machine->gpio_hp_det)) {
|
||||
tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det;
|
||||
|
|
|
@ -145,16 +145,14 @@ static const struct snd_kcontrol_new tegra_max98090_controls[] = {
|
|||
|
||||
static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card);
|
||||
|
||||
if (gpio_is_valid(machine->gpio_hp_det)) {
|
||||
snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE,
|
||||
&tegra_max98090_hp_jack);
|
||||
snd_soc_jack_add_pins(&tegra_max98090_hp_jack,
|
||||
ARRAY_SIZE(tegra_max98090_hp_jack_pins),
|
||||
tegra_max98090_hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphones",
|
||||
SND_JACK_HEADPHONE,
|
||||
&tegra_max98090_hp_jack,
|
||||
tegra_max98090_hp_jack_pins,
|
||||
ARRAY_SIZE(tegra_max98090_hp_jack_pins));
|
||||
|
||||
tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
|
||||
snd_soc_jack_add_gpios(&tegra_max98090_hp_jack,
|
||||
|
@ -163,11 +161,11 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
|||
}
|
||||
|
||||
if (gpio_is_valid(machine->gpio_mic_det)) {
|
||||
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&tegra_max98090_mic_jack);
|
||||
snd_soc_jack_add_pins(&tegra_max98090_mic_jack,
|
||||
ARRAY_SIZE(tegra_max98090_mic_jack_pins),
|
||||
tegra_max98090_mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Mic Jack",
|
||||
SND_JACK_MICROPHONE,
|
||||
&tegra_max98090_mic_jack,
|
||||
tegra_max98090_mic_jack_pins,
|
||||
ARRAY_SIZE(tegra_max98090_mic_jack_pins));
|
||||
|
||||
tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det;
|
||||
snd_soc_jack_add_gpios(&tegra_max98090_mic_jack,
|
||||
|
|
|
@ -108,15 +108,11 @@ static const struct snd_kcontrol_new tegra_rt5640_controls[] = {
|
|||
|
||||
static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card);
|
||||
|
||||
snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE,
|
||||
&tegra_rt5640_hp_jack);
|
||||
snd_soc_jack_add_pins(&tegra_rt5640_hp_jack,
|
||||
ARRAY_SIZE(tegra_rt5640_hp_jack_pins),
|
||||
tegra_rt5640_hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE,
|
||||
&tegra_rt5640_hp_jack, tegra_rt5640_hp_jack_pins,
|
||||
ARRAY_SIZE(tegra_rt5640_hp_jack_pins));
|
||||
|
||||
if (gpio_is_valid(machine->gpio_hp_det)) {
|
||||
tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det;
|
||||
|
|
|
@ -146,10 +146,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
|||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card);
|
||||
|
||||
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&tegra_rt5677_hp_jack);
|
||||
snd_soc_jack_add_pins(&tegra_rt5677_hp_jack, 1,
|
||||
&tegra_rt5677_hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&tegra_rt5677_hp_jack,
|
||||
&tegra_rt5677_hp_jack_pins, 1);
|
||||
|
||||
if (gpio_is_valid(machine->gpio_hp_det)) {
|
||||
tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det;
|
||||
|
@ -158,10 +157,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
|
|||
}
|
||||
|
||||
|
||||
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&tegra_rt5677_mic_jack);
|
||||
snd_soc_jack_add_pins(&tegra_rt5677_mic_jack, 1,
|
||||
&tegra_rt5677_mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&tegra_rt5677_mic_jack,
|
||||
&tegra_rt5677_mic_jack_pins, 1);
|
||||
|
||||
if (gpio_is_valid(machine->gpio_mic_present)) {
|
||||
tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present;
|
||||
|
|
|
@ -177,21 +177,19 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
if (gpio_is_valid(machine->gpio_hp_det)) {
|
||||
tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det;
|
||||
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
|
||||
&tegra_wm8903_hp_jack);
|
||||
snd_soc_jack_add_pins(&tegra_wm8903_hp_jack,
|
||||
ARRAY_SIZE(tegra_wm8903_hp_jack_pins),
|
||||
tegra_wm8903_hp_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Headphone Jack",
|
||||
SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack,
|
||||
tegra_wm8903_hp_jack_pins,
|
||||
ARRAY_SIZE(tegra_wm8903_hp_jack_pins));
|
||||
snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
|
||||
1,
|
||||
&tegra_wm8903_hp_jack_gpio);
|
||||
}
|
||||
|
||||
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&tegra_wm8903_mic_jack);
|
||||
snd_soc_jack_add_pins(&tegra_wm8903_mic_jack,
|
||||
ARRAY_SIZE(tegra_wm8903_mic_jack_pins),
|
||||
tegra_wm8903_mic_jack_pins);
|
||||
snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
|
||||
&tegra_wm8903_mic_jack,
|
||||
tegra_wm8903_mic_jack_pins,
|
||||
ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
|
||||
wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
|
||||
0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue