From: Vaibhav Agarwal <vaibhav.sr@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alex Elder <elder@kernel.org>, Johan Hovold <johan@kernel.org>,
Mark Greer <mgreer@animalcreek.com>,
Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>
Cc: greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Vaibhav Agarwal <vaibhav.sr@gmail.com>
Subject: [PATCH v2 1/6] staging: greybus: audio: Update snd_jack FW usage as per new APIs
Date: Wed, 10 Jun 2020 22:58:25 +0530 [thread overview]
Message-ID: <48ba07c38dc72d272dda4d4d2c3fe3690ee71eb3.1591802243.git.vaibhav.sr@gmail.com> (raw)
In-Reply-To: <cover.1591802243.git.vaibhav.sr@gmail.com>
snd_soc_jack APIs are modified in recent kernel versions. This patch
updates the codec driver to resolve the compilation errors related to
jack framework.
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
---
drivers/staging/greybus/audio_codec.c | 54 +++++++++++++++++++++------
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index 08746c85dea6..5d3a5e6a8fe6 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -709,17 +709,26 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
};
static int gbaudio_init_jack(struct gbaudio_module_info *module,
- struct snd_soc_codec *codec)
+ struct snd_soc_card *card)
{
int ret;
+ struct snd_soc_jack_pin *headset, *button;
if (!module->jack_mask)
return 0;
snprintf(module->jack_name, NAME_SIZE, "GB %d Headset Jack",
module->dev_id);
- ret = snd_soc_jack_new(codec, module->jack_name, module->jack_mask,
- &module->headset_jack);
+
+ headset = devm_kzalloc(module->dev, sizeof(*headset), GFP_KERNEL);
+ if (!headset)
+ return -ENOMEM;
+
+ headset->pin = module->jack_name;
+ headset->mask = module->jack_mask;
+
+ ret = snd_soc_card_jack_new(card, module->jack_name, module->jack_mask,
+ &module->headset_jack, headset, 1);
if (ret) {
dev_err(module->dev, "Failed to create new jack\n");
return ret;
@@ -730,11 +739,21 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
snprintf(module->button_name, NAME_SIZE, "GB %d Button Jack",
module->dev_id);
- ret = snd_soc_jack_new(codec, module->button_name, module->button_mask,
- &module->button_jack);
+ button = devm_kzalloc(module->dev, sizeof(*button), GFP_KERNEL);
+ if (!button) {
+ ret = -ENOMEM;
+ goto free_headset;
+ }
+
+ button->pin = module->button_name;
+ button->mask = module->button_mask;
+
+ ret = snd_soc_card_jack_new(card, module->button_name,
+ module->button_mask, &module->button_jack,
+ button, 1);
if (ret) {
dev_err(module->dev, "Failed to create button jack\n");
- return ret;
+ goto free_headset;
}
/*
@@ -750,7 +769,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
KEY_MEDIA);
if (ret) {
dev_err(module->dev, "Failed to set BTN_0\n");
- return ret;
+ goto free_button;
}
}
@@ -759,7 +778,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
KEY_VOICECOMMAND);
if (ret) {
dev_err(module->dev, "Failed to set BTN_1\n");
- return ret;
+ goto free_button;
}
}
@@ -768,7 +787,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
KEY_VOLUMEUP);
if (ret) {
dev_err(module->dev, "Failed to set BTN_2\n");
- return ret;
+ goto free_button;
}
}
@@ -777,7 +796,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
KEY_VOLUMEDOWN);
if (ret) {
dev_err(module->dev, "Failed to set BTN_0\n");
- return ret;
+ goto free_button;
}
}
@@ -788,6 +807,16 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module,
*/
return 0;
+
+free_button:
+ snd_device_free(card->snd_card, module->button_jack.jack);
+ list_del(&module->button_jack.list);
+
+free_headset:
+ snd_device_free(card->snd_card, module->headset_jack.jack);
+ list_del(&module->headset_jack.list);
+
+ return ret;
}
int gbaudio_register_module(struct gbaudio_module_info *module)
@@ -815,7 +844,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
return -EINVAL;
}
- ret = gbaudio_init_jack(module, codec);
+ ret = gbaudio_init_jack(module, component->card);
if (ret) {
up_write(&card->controls_rwsem);
return ret;
@@ -942,7 +971,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
#ifdef CONFIG_SND_JACK
/* free jack devices for this module from codec->jack_list */
- list_for_each_entry_safe(jack, next_j, &codec->jack_list, list) {
+ list_for_each_entry_safe(jack, next_j, &component->card->jack_list,
+ list) {
if (jack == &module->headset_jack)
mask = GBCODEC_JACK_MASK;
else if (jack == &module->button_jack)
--
2.26.2
next prev parent reply other threads:[~2020-06-10 17:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 17:28 [PATCH v2 0/6] Enable Greybus Audio codec driver Vaibhav Agarwal
2020-06-10 17:28 ` Vaibhav Agarwal [this message]
2020-06-10 17:28 ` [PATCH v2 2/6] staging: greybus: audio: Maintain jack list within GB Audio module Vaibhav Agarwal
2020-06-10 17:28 ` [PATCH v2 3/6] staging: greybus: audio: Resolve compilation errors for GB codec module Vaibhav Agarwal
2020-06-10 17:28 ` [PATCH v2 4/6] staging: greybus: audio: Resolve compilation error in topology parser Vaibhav Agarwal
2020-06-10 17:45 ` Dan Carpenter
2020-06-10 18:36 ` Vaibhav Agarwal
2020-06-10 17:28 ` [PATCH v2 5/6] staging: greybus: audio: Add helper APIs for dynamic audio modules Vaibhav Agarwal
2020-06-10 17:28 ` [PATCH v2 6/6] staging: greybus: audio: Enable GB codec, audio module compilation Vaibhav Agarwal
2020-06-10 17:37 ` [PATCH v2 0/6] Enable Greybus Audio codec driver Mark Brown
2020-06-10 18:01 ` Alexandre Belloni
2020-06-11 8:41 ` Mark Brown
2020-06-10 18:23 ` Vaibhav Agarwal
2020-06-11 8:26 ` Mark Brown
2020-06-12 15:37 ` Vaibhav Agarwal
2020-06-12 16:06 ` Mark Brown
2020-06-10 17:51 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48ba07c38dc72d272dda4d4d2c3fe3690ee71eb3.1591802243.git.vaibhav.sr@gmail.com \
--to=vaibhav.sr@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgreer@animalcreek.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®