linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs
@ 2023-01-23 13:59 Astrid Rost
  2023-01-23 13:59 ` [PATCH v3 1/3] ASoC: soc-component: add get_jack_type Astrid Rost
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Astrid Rost @ 2023-01-23 13:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Krzysztof Kozlowski
  Cc: kernel, alsa-devel, linux-kernel, Astrid Rost

Add a generic way to create jack inputs for auxiliary jack detection
drivers (e.g. via i2c, spi), which are not part of any real codec.
The simple-card can be used as combining card driver to add the jacks,
no new one is required.

Create a jack (for input-events) for jack devices in the auxiliary
device list (aux_devs). A device which returns a valid value on
get_jack_type counts as jack device; set_jack is required
to add the jack to the device.

v1 -> v2: Auxiliary jack drivers return the correct snd_jack_type with
 the function: get_jack_type.
- No devicetree changes in simple-card.
- soc-component: changed name to: get_jack_type.
- simple-jack-utils: updated algorithm to add jack devices.
   A device which returns a valid value on get_jack_type counts as jack
   device
- ts3a227e: added devicetree property jack-type, added NULL check for jack.

v2 -> v3:  ts3a227e: remove devictree property.

Astrid Rost (3):
  [PATCH v3 1/3] ASoC: soc-component: add get_jack_type
  [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs
  [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type

 include/sound/simple_card_utils.h     |  3 ++
 include/sound/soc-component.h         |  2 ++
 sound/soc/codecs/ts3a227e.c           | 20 ++++++++++-
 sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++++++
 sound/soc/generic/simple-card.c       |  4 +++
 sound/soc/soc-component.c             | 20 +++++++++++
 6 files changed, 97 insertions(+), 1 deletion(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/3] ASoC: soc-component: add get_jack_type
  2023-01-23 13:59 [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
@ 2023-01-23 13:59 ` Astrid Rost
  2023-01-23 13:59 ` [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Astrid Rost @ 2023-01-23 13:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Krzysztof Kozlowski, Jaroslav Kysela,
	Takashi Iwai
  Cc: kernel, alsa-devel, linux-kernel, Astrid Rost

Add function to return the jack type of snd_jack_types.
This allows a generic card driver to add a jack with the specified
type.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
---
 include/sound/soc-component.h |  2 ++
 sound/soc/soc-component.c     | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index c26ffb033777..3203d35bc8c1 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -98,6 +98,7 @@ struct snd_soc_component_driver {
 		       int source, unsigned int freq_in, unsigned int freq_out);
 	int (*set_jack)(struct snd_soc_component *component,
 			struct snd_soc_jack *jack,  void *data);
+	int (*get_jack_type)(struct snd_soc_component *component);
 
 	/* DT */
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
@@ -384,6 +385,7 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
 			      unsigned int freq_out);
 int snd_soc_component_set_jack(struct snd_soc_component *component,
 			       struct snd_soc_jack *jack, void *data);
+int snd_soc_component_get_jack_type(struct snd_soc_component *component);
 
 void snd_soc_component_seq_notifier(struct snd_soc_component *component,
 				    enum snd_soc_dapm_type type, int subseq);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index e12f8244242b..3cd6952212e1 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -256,6 +256,26 @@ int snd_soc_component_set_jack(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);
 
+/**
+ * snd_soc_component_get_jack_type
+ * @component: COMPONENTs
+ *
+ * Returns the jack type of the component
+ * This can either be the supported type or one read from
+ * devicetree with the property: jack-type.
+ */
+int snd_soc_component_get_jack_type(
+	struct snd_soc_component *component)
+{
+	int ret = -ENOTSUPP;
+
+	if (component->driver->get_jack_type)
+		ret = component->driver->get_jack_type(component);
+
+	return soc_component_ret(component, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_get_jack_type);
+
 int snd_soc_component_module_get(struct snd_soc_component *component,
 				 void *mark, int upon_open)
 {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs
  2023-01-23 13:59 [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
  2023-01-23 13:59 ` [PATCH v3 1/3] ASoC: soc-component: add get_jack_type Astrid Rost
@ 2023-01-23 13:59 ` Astrid Rost
  2023-01-27 12:19   ` Mark Brown
  2023-01-23 13:59 ` [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type Astrid Rost
  2023-01-28 10:48 ` [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Astrid Rost @ 2023-01-23 13:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Krzysztof Kozlowski, Jaroslav Kysela,
	Takashi Iwai
  Cc: kernel, alsa-devel, linux-kernel, Astrid Rost

Add a generic way to create jack inputs for auxiliary jack detection
drivers (e.g. via i2c, spi), which are not part of any real codec.
The simple-card can be used as combining card driver to add the jacks,
no new one is required.

Create a jack (for input-events) for jack devices in the auxiliary
device list (aux_devs). A device which returns a valid value on
get_jack_type counts as jack device; set_jack is required
to add the jack to the device.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
---
 include/sound/simple_card_utils.h     |  3 ++
 sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++++++
 sound/soc/generic/simple-card.c       |  4 +++
 3 files changed, 56 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 38590f1ae9ee..a3f3f3aa9e6e 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -69,6 +69,7 @@ struct asoc_simple_priv {
 	} *dai_props;
 	struct asoc_simple_jack hp_jack;
 	struct asoc_simple_jack mic_jack;
+	struct snd_soc_jack *aux_jacks;
 	struct snd_soc_dai_link *dai_link;
 	struct asoc_simple_dai *dais;
 	struct snd_soc_dai_link_component *dlcs;
@@ -187,6 +188,8 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card,
 int asoc_simple_init_jack(struct snd_soc_card *card,
 			       struct asoc_simple_jack *sjack,
 			       int is_hp, char *prefix, char *pin);
+int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv,
+				char *prefix);
 int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 			       struct link_info *li);
 int asoc_simple_remove(struct platform_device *pdev);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index e35becce9635..56552a616f21 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -786,6 +786,55 @@ int asoc_simple_init_jack(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_init_jack);
 
+int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, char *prefix)
+{
+	struct snd_soc_card *card = simple_priv_to_card(priv);
+	struct snd_soc_component *component;
+	int found_jack_index = 0;
+	int type = 0;
+	int num = 0;
+	int ret;
+
+	if (priv->aux_jacks)
+		return 0;
+
+	for_each_card_auxs(card, component) {
+		type = snd_soc_component_get_jack_type(component);
+		if (type > 0)
+			num++;
+	}
+	if (num < 1)
+		return 0;
+
+	priv->aux_jacks = devm_kcalloc(card->dev, num,
+				       sizeof(struct snd_soc_jack), GFP_KERNEL);
+	if (!priv->aux_jacks)
+		return -ENOMEM;
+
+	for_each_card_auxs(card, component) {
+		char id[128];
+		struct snd_soc_jack *jack;
+
+		if (found_jack_index >= num)
+			break;
+
+		type = snd_soc_component_get_jack_type(component);
+		if (type <= 0)
+			continue;
+
+		/* create jack */
+		jack = &(priv->aux_jacks[found_jack_index++]);
+		snprintf(id, sizeof(id), "%s-jack", component->name);
+		ret = snd_soc_card_jack_new(card, id, type, jack);
+		if (ret)
+			continue;
+
+		(void)snd_soc_component_set_jack(component, jack, NULL);
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_init_aux_jacks);
+
 int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 			  struct link_info *li)
 {
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index feb55b66239b..e98932c16754 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -623,6 +623,10 @@ static int simple_soc_probe(struct snd_soc_card *card)
 	if (ret < 0)
 		return ret;
 
+	ret = asoc_simple_init_aux_jacks(priv, PREFIX);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type
  2023-01-23 13:59 [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
  2023-01-23 13:59 ` [PATCH v3 1/3] ASoC: soc-component: add get_jack_type Astrid Rost
  2023-01-23 13:59 ` [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
@ 2023-01-23 13:59 ` Astrid Rost
  2023-01-28 10:48 ` [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Astrid Rost @ 2023-01-23 13:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Krzysztof Kozlowski, Jaroslav Kysela,
	Takashi Iwai
  Cc: kernel, alsa-devel, linux-kernel, Astrid Rost

Add set_jack and get_jack_type to allow simple-card-utils to add
a jack for it.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
---
 sound/soc/codecs/ts3a227e.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 2305a472d132..5282112c7d8d 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -258,7 +258,25 @@ int ts3a227e_enable_jack_detect(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(ts3a227e_enable_jack_detect);
 
-static struct snd_soc_component_driver ts3a227e_soc_driver;
+static int ts3a227e_set_jack(struct snd_soc_component *component,
+			     struct snd_soc_jack *jack, void *data)
+{
+	if (jack == NULL)
+		return -EINVAL;
+
+	return ts3a227e_enable_jack_detect(component, jack);
+}
+
+static int ts3a227e_get_jack_type(struct snd_soc_component *component)
+{
+	return SND_JACK_HEADSET;
+}
+
+static const struct snd_soc_component_driver ts3a227e_soc_driver = {
+	.name = "ti,ts3a227e",
+	.set_jack = ts3a227e_set_jack,
+	.get_jack_type = ts3a227e_get_jack_type,
+};
 
 static const struct regmap_config ts3a227e_regmap_config = {
 	.val_bits = 8,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs
  2023-01-23 13:59 ` [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
@ 2023-01-27 12:19   ` Mark Brown
  2023-01-30  9:39     ` Astrid Rost
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2023-01-27 12:19 UTC (permalink / raw)
  To: Astrid Rost
  Cc: Liam Girdwood, Krzysztof Kozlowski, Jaroslav Kysela,
	Takashi Iwai, kernel, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

On Mon, Jan 23, 2023 at 02:59:12PM +0100, Astrid Rost wrote:
> Add a generic way to create jack inputs for auxiliary jack detection
> drivers (e.g. via i2c, spi), which are not part of any real codec.
> The simple-card can be used as combining card driver to add the jacks,
> no new one is required.
> 
> Create a jack (for input-events) for jack devices in the auxiliary
> device list (aux_devs). A device which returns a valid value on
> get_jack_type counts as jack device; set_jack is required
> to add the jack to the device.
> 
> Signed-off-by: Astrid Rost <astrid.rost@axis.com>
> ---
>  include/sound/simple_card_utils.h     |  3 ++
>  sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++++++
>  sound/soc/generic/simple-card.c       |  4 +++
>  3 files changed, 56 insertions(+)

Given that everyone is really supposed to be using the
audio-graph cards for new systems this should be hooked up there
too.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs
  2023-01-23 13:59 [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
                   ` (2 preceding siblings ...)
  2023-01-23 13:59 ` [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type Astrid Rost
@ 2023-01-28 10:48 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2023-01-28 10:48 UTC (permalink / raw)
  To: Liam Girdwood, Krzysztof Kozlowski, Astrid Rost
  Cc: kernel, alsa-devel, linux-kernel

On Mon, 23 Jan 2023 14:59:10 +0100, Astrid Rost wrote:
> Add a generic way to create jack inputs for auxiliary jack detection
> drivers (e.g. via i2c, spi), which are not part of any real codec.
> The simple-card can be used as combining card driver to add the jacks,
> no new one is required.
> 
> Create a jack (for input-events) for jack devices in the auxiliary
> device list (aux_devs). A device which returns a valid value on
> get_jack_type counts as jack device; set_jack is required
> to add the jack to the device.
> 
> [...]

Applied to

   broonie/sound.git for-next

Thanks!

[1/3] ASoC: soc-component: add get_jack_type
      commit: df55122ba0955951a85ef3ffb19f0dcb0ad3ffbb
[2/3] ASoC: simple-card-utils: create jack inputs for aux_devs
      commit: 9b271207ac83db362fac757d367923bde57dce86
[3/3] ASoC: ts3a227e: add set_jack and get_jack_type
      commit: 087b9dda8658052a33031ef82a8d8ef77a7c94ea

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs
  2023-01-27 12:19   ` Mark Brown
@ 2023-01-30  9:39     ` Astrid Rost
  0 siblings, 0 replies; 7+ messages in thread
From: Astrid Rost @ 2023-01-30  9:39 UTC (permalink / raw)
  To: Mark Brown, Astrid Rost
  Cc: Liam Girdwood, Krzysztof Kozlowski, Jaroslav Kysela,
	Takashi Iwai, kernel, alsa-devel, linux-kernel



On 1/27/23 13:19, Mark Brown wrote:
> On Mon, Jan 23, 2023 at 02:59:12PM +0100, Astrid Rost wrote:
>> Add a generic way to create jack inputs for auxiliary jack detection
>> drivers (e.g. via i2c, spi), which are not part of any real codec.
>> The simple-card can be used as combining card driver to add the jacks,
>> no new one is required.
>>
>> Create a jack (for input-events) for jack devices in the auxiliary
>> device list (aux_devs). A device which returns a valid value on
>> get_jack_type counts as jack device; set_jack is required
>> to add the jack to the device.
>>
>> Signed-off-by: Astrid Rost <astrid.rost@axis.com>
>> ---
>>   include/sound/simple_card_utils.h     |  3 ++
>>   sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++++++
>>   sound/soc/generic/simple-card.c       |  4 +++
>>   3 files changed, 56 insertions(+)
> 
> Given that everyone is really supposed to be using the
> audio-graph cards for new systems this should be hooked up there
> too.

Hello,

Yes auxiliary devices are very useful, e.g. for GPIO. I can make a patch
for audio-graph-card.c  to add it.

Best Regards

Astrid



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-30  9:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 13:59 [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
2023-01-23 13:59 ` [PATCH v3 1/3] ASoC: soc-component: add get_jack_type Astrid Rost
2023-01-23 13:59 ` [PATCH v3 2/3] ASoC: simple-card-utils: create jack inputs for aux_devs Astrid Rost
2023-01-27 12:19   ` Mark Brown
2023-01-30  9:39     ` Astrid Rost
2023-01-23 13:59 ` [PATCH v3 3/3] ASoC: ts3a227e: add set_jack and get_jack_type Astrid Rost
2023-01-28 10:48 ` [PATCH v3 0/3] ASoC: simple-card-utils: create jack inputs for aux_devs Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).