Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756573Ab3G2OSS (ORCPT ); Mon, 29 Jul 2013 10:18:18 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41853 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755824Ab3G2OSQ (ORCPT ); Mon, 29 Jul 2013 10:18:16 -0400 Date: Mon, 29 Jul 2013 16:19:43 +0200 Message-ID: From: Takashi Iwai To: "Felipe F. Tonello" Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Mark Brown , David Henningsson , Wang Xingchao , Jaroslav Kysela Subject: Re: [PATCH v2 1/3] ALSA: Added jack detection kcontrol support In-Reply-To: <1374878713-11922-2-git-send-email-eu@felipetonello.com> References: <1374878713-11922-1-git-send-email-eu@felipetonello.com> <1374878713-11922-2-git-send-email-eu@felipetonello.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5789 Lines: 189 At Fri, 26 Jul 2013 15:45:11 -0700, Felipe F. Tonello wrote: > > From: "Felipe F. Tonello" > > This patch adds jack support for alsa kcontrol. > > This support is necessary since the new kcontrol is used by user-space > daemons, such as PulseAudio(>=2.0), to do jack detection.) > > Signed-off-by: Felipe F. Tonello This patch breaks the build. Takashi > --- > include/sound/jack.h | 6 ++++-- > sound/core/Kconfig | 1 + > sound/core/ctljack.c | 3 ++- > sound/core/jack.c | 29 +++++++++++++++++++++++++++-- > 4 files changed, 34 insertions(+), 5 deletions(-) > > diff --git a/include/sound/jack.h b/include/sound/jack.h > index 5891657..dc62b74 100644 > --- a/include/sound/jack.h > +++ b/include/sound/jack.h > @@ -26,6 +26,7 @@ > #include > > struct input_dev; > +struct snd_kcontrol; > > /** > * Jack types which can be reported. These values are used as a > @@ -58,6 +59,7 @@ enum snd_jack_types { > > struct snd_jack { > struct input_dev *input_dev; > + struct snd_kcontrol *kctl; > int registered; > int type; > const char *id; > @@ -70,7 +72,7 @@ struct snd_jack { > #ifdef CONFIG_SND_JACK > > int snd_jack_new(struct snd_card *card, const char *id, int type, > - struct snd_jack **jack); > + int idx, struct snd_jack **jack); > void snd_jack_set_parent(struct snd_jack *jack, struct device *parent); > int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, > int keytype); > @@ -80,7 +82,7 @@ void snd_jack_report(struct snd_jack *jack, int status); > #else > > static inline int snd_jack_new(struct snd_card *card, const char *id, int type, > - struct snd_jack **jack) > + int idx, struct snd_jack **jack) > { > return 0; > } > diff --git a/sound/core/Kconfig b/sound/core/Kconfig > index c0c2f57..8167615 100644 > --- a/sound/core/Kconfig > +++ b/sound/core/Kconfig > @@ -20,6 +20,7 @@ config SND_COMPRESS_OFFLOAD > # to avoid having to force INPUT on. > config SND_JACK > bool > + select SND_KCTL_JACK > > config SND_SEQUENCER > tristate "Sequencer support" > diff --git a/sound/core/ctljack.c b/sound/core/ctljack.c > index e4b38fb..59aa6d0 100644 > --- a/sound/core/ctljack.c > +++ b/sound/core/ctljack.c > @@ -38,7 +38,8 @@ snd_kctl_jack_new(const char *name, int idx, void *private_data) > kctl = snd_ctl_new1(&jack_detect_kctl, private_data); > if (!kctl) > return NULL; > - snprintf(kctl->id.name, sizeof(kctl->id.name), "%s Jack", name); > + > + strlcpy(kctl->id.name, name, sizeof(kctl->id.name)); > kctl->id.index = idx; > kctl->private_value = 0; > return kctl; > diff --git a/sound/core/jack.c b/sound/core/jack.c > index b35fe73..b2757b1 100644 > --- a/sound/core/jack.c > +++ b/sound/core/jack.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { > SW_HEADPHONE_INSERT, > @@ -48,6 +49,7 @@ static int snd_jack_dev_free(struct snd_device *device) > else > input_free_device(jack->input_dev); > > + snd_ctl_remove(device->card, jack->kctl); > kfree(jack->id); > kfree(jack); > > @@ -85,26 +87,36 @@ static int snd_jack_dev_register(struct snd_device *device) > if (err == 0) > jack->registered = 1; > > + /* We don't need to free the control, it's freed by snd_ctl_add itself > + if an error occur */ > + err = snd_ctl_add(card, jack->kctl); > + > return err; > } > > /** > * snd_jack_new - Create a new jack > * @card: the card instance > - * @id: an identifying string for this jack > + * @id: an identifying string for this jack, " Jack" is appended to the > + * string > * @type: a bitmask of enum snd_jack_type values that can be detected by > * this jack > + * @idx: index of this control item > * @jjack: Used to provide the allocated jack object to the caller. > * > * Creates a new jack object. > * > + * This function creates a Jack Kcontrol, which is exported to user space via > + * ALSA Controls. > + * > * Return: Zero if successful, or a negative error code on failure. > * On success @jjack will be initialised. > */ > int snd_jack_new(struct snd_card *card, const char *id, int type, > - struct snd_jack **jjack) > + int idx, struct snd_jack **jjack) > { > struct snd_jack *jack; > + struct snd_kcontrol *kctl; > int err; > int i; > static struct snd_device_ops ops = { > @@ -117,6 +129,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, > return -ENOMEM; > > jack->id = kstrdup(id, GFP_KERNEL); > + sprintf((char *)jack->id, "%s Jack", jack->id); > > jack->input_dev = input_allocate_device(); > if (jack->input_dev == NULL) { > @@ -137,6 +150,15 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, > if (err < 0) > goto fail_input; > > + /* card is the private_data */ > + kctl = snd_kctl_jack_new(jack->id, idx, card); > + if (!kctl) { > + err = -ENOMEM; > + goto fail_input; > + } > + > + jack->kctl = kctl; > + > *jjack = jack; > > return 0; > @@ -239,6 +261,9 @@ void snd_jack_report(struct snd_jack *jack, int status) > } > > input_sync(jack->input_dev); > + > + /* Update ALSA KControl interface */ > + snd_kctl_jack_report((struct snd_card *)jack->kctl->private_data, jack->kctl, !!status); > } > EXPORT_SYMBOL(snd_jack_report); > > -- > 1.8.1.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/