2023-01-18 13:37:16

by Astrid Rost

[permalink] [raw]
Subject: [PATCH v1 0/4] ASoC: simple-card-utils: jack for aux_devs

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 has the functions set_jack and
get_jack_supported_type counts as jack device.

Add a devicetree entry, in case not all input types are required.
simple-card,aux-jack-types:
Array of snd_jack_type to create jack-input-event for jack devices in
aux-devs. If the setting is 0, the supported type of the device is used.

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

.../bindings/sound/simple-card.yaml | 35 +++++++++++
include/sound/simple_card_utils.h | 3 +
include/sound/soc-component.h | 2 +
sound/soc/codecs/ts3a227e.c | 17 ++++-
sound/soc/generic/simple-card-utils.c | 63 +++++++++++++++++++
sound/soc/generic/simple-card.c | 4 ++
sound/soc/soc-component.c | 18 ++++++
7 files changed, 141 insertions(+), 1 deletion(-)

--
2.30.2


2023-01-18 13:37:47

by Astrid Rost

[permalink] [raw]
Subject: [PATCH v1 2/4] ASoC: simple-card-utils: create jack inputs for aux_devs

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 has the functions set_jack and
get_jack_supported_type counts as jack device.

Add a devicetree entry, in case not all input types are required.
simple-card,aux-jack-types:
Array of snd_jack_type to create jack-input-event for jack devices in
aux-devs. If the setting is 0, the supported type of the device is used.

Signed-off-by: Astrid Rost <[email protected]>
---
include/sound/simple_card_utils.h | 3 ++
sound/soc/generic/simple-card-utils.c | 63 +++++++++++++++++++++++++++
sound/soc/generic/simple-card.c | 4 ++
3 files changed, 70 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..668123549fbf 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -786,6 +786,69 @@ 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 device *dev = card->dev;
+ struct snd_soc_component *component;
+ char prop[128];
+ int found_jack_index = 0;
+ int num = 0;
+ int ret;
+
+ if (priv->aux_jacks)
+ return 0;
+
+ snprintf(prop, sizeof(prop), "%saux-jack-types", prefix);
+ num = of_property_count_u32_elems(dev->of_node, prop);
+ 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) {
+ if (found_jack_index >= num)
+ break;
+
+ if (component->driver->set_jack &&
+ component->driver->get_jack_supported_type) {
+ char id[128];
+ int type = 0;
+ struct snd_soc_jack *jack =
+ &(priv->aux_jacks[found_jack_index]);
+ int type_supp_mask =
+ snd_soc_component_get_jack_supported_type(
+ component);
+
+ ret = of_property_read_u32_index(
+ dev->of_node, prop, found_jack_index++, &type);
+ if (ret)
+ continue;
+
+ if (type)
+ type &= type_supp_mask; /* use only supported types */
+ else
+ type = type_supp_mask; /* use all supported types */
+
+ if (!type)
+ continue;
+
+ /* create jack */
+ 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

2023-01-18 13:53:25

by Astrid Rost

[permalink] [raw]
Subject: [PATCH v1 1/4] ASoC: soc-component: add get_jack_supported_type

Add function to return the supported jack type of snd_jack_types.
This allows a generic card driver to check whether the jack
type is valid or add all supported ones.

Signed-off-by: Astrid Rost <[email protected]>
---
include/sound/soc-component.h | 2 ++
sound/soc/soc-component.c | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index c26ffb033777..5aa43c323028 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_supported_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_supported_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..112da1647f10 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -256,6 +256,24 @@ int snd_soc_component_set_jack(struct snd_soc_component *component,
}
EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);

+/**
+ * snd_soc_component_get_jack_supported_type
+ * @component: COMPONENTs
+ *
+ * Returns the supported jack type of the component
+ */
+int snd_soc_component_get_jack_supported_type(
+ struct snd_soc_component *component)
+{
+ int ret = -ENOTSUPP;
+
+ if (component->driver->get_jack_supported_type)
+ ret = component->driver->get_jack_supported_type(component);
+
+ return soc_component_ret(component, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_get_jack_supported_type);
+
int snd_soc_component_module_get(struct snd_soc_component *component,
void *mark, int upon_open)
{
--
2.30.2

2023-01-18 13:54:22

by Astrid Rost

[permalink] [raw]
Subject: [PATCH v1 4/4] ASoC: dt-bindings: simple-card: create jack for aux_devs

Add simple-card,aux-jack-types:
Array of snd_jack_type to create jack-input-event for jack devices in
aux-devs. If the setting is 0, the supported type of the device is used.
A device which has the functions set_jack and get_jack_supported_type
counts as jack device.

Signed-off-by: Astrid Rost <[email protected]>
---
.../bindings/sound/simple-card.yaml | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
index ed19899bc94b..2635b1c04fc9 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.yaml
+++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
@@ -199,6 +199,13 @@ properties:
maxItems: 1
simple-audio-card,mic-det-gpio:
maxItems: 1
+ simple-audio-card,aux-jack-types:
+ $ref: "/schemas/types.yaml#/definitions/uint32-array"
+ description: |
+ Array of snd_jack_type to create jack-input-event for jack
+ devices in aux-devs. If the setting is 0, the supported
+ type of the device is used. A device which has the functions
+ set_jack and get_jack_supported_type counts as jack device.

patternProperties:
"^simple-audio-card,cpu(@[0-9a-f]+)?$":
@@ -498,3 +505,31 @@ examples:
};
};
};
+#--------------------
+# Add a headphone and a headset mic jack,
+# which use an auxiliary jack detector e.g. via i2c.
+# The events, which should be enabled are:
+# SND_JACK_HEADPHONE = 1
+# SND_JACK_MICROPHONE = 2
+#--------------------
+ - |
+ sound {
+ compatible = "simple-audio-card";
+ simple-audio-card,widgets =
+ "Headphone", "Headphone Jack",
+ "Headset Mic", "Headset Mic Jack";
+ simple-audio-card,routing =
+ "Headphone Jack", "HPLEFT",
+ "Headphone Jack", "HPRIGHT",
+ "LEFTIN", "Headset Mic",
+ "RIGHTIN", "Headset Mic";
+ simple-audio-card,aux-devs = <&hp_jack>, <&hs_mic_jack>;
+ simple-audio-card,aux-jack-types = <1 2>;
+ simple-audio-card,cpu {
+ sound-dai = <&ssi2>;
+ };
+ simple-audio-card,codec {
+ sound-dai = <&codec>;
+ clocks = <&clocks>;
+ };
+ };
--
2.30.2

2023-01-18 15:00:47

by Amadeusz Sławiński

[permalink] [raw]
Subject: Re: [PATCH v1 2/4] ASoC: simple-card-utils: create jack inputs for aux_devs

On 1/18/2023 1:52 PM, 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 has the functions set_jack and
> get_jack_supported_type counts as jack device.
>
> Add a devicetree entry, in case not all input types are required.
> simple-card,aux-jack-types:
> Array of snd_jack_type to create jack-input-event for jack devices in
> aux-devs. If the setting is 0, the supported type of the device is used.
>
> Signed-off-by: Astrid Rost <[email protected]>
> ---
> include/sound/simple_card_utils.h | 3 ++
> sound/soc/generic/simple-card-utils.c | 63 +++++++++++++++++++++++++++
> sound/soc/generic/simple-card.c | 4 ++
> 3 files changed, 70 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..668123549fbf 100644
> --- a/sound/soc/generic/simple-card-utils.c
> +++ b/sound/soc/generic/simple-card-utils.c
> @@ -786,6 +786,69 @@ 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 device *dev = card->dev;
> + struct snd_soc_component *component;
> + char prop[128];
> + int found_jack_index = 0;
> + int num = 0;
> + int ret;
> +
> + if (priv->aux_jacks)
> + return 0;
> +
> + snprintf(prop, sizeof(prop), "%saux-jack-types", prefix);
> + num = of_property_count_u32_elems(dev->of_node, prop);
> + 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) {
> + if (found_jack_index >= num)
> + break;
> +
> + if (component->driver->set_jack &&
> + component->driver->get_jack_supported_type) {

This check is really weird, you are checking if callbacks exist at all,
which should be unnecessary as it duplicates the work oh
snd_soc_component_ functions. I would just try to call
snd_soc_component_get_jack_supported_type() directly and if it returns
-ENOTSUPP, just go to next iteration.
I guess your main problem is snd_soc_component_set_jack(), but you can
just call it with NULL jack to check if it returns -ENOTSUPP, but I
guess the overall asumption would be that if someone implements
.get_jack_supported_type, they also implemented .set_jack, so maybe it
is just unnecessary?

> + char id[128];
> + int type = 0;
> + struct snd_soc_jack *jack =
> + &(priv->aux_jacks[found_jack_index]);
> + int type_supp_mask =
> + snd_soc_component_get_jack_supported_type(
> + component);
> +
> + ret = of_property_read_u32_index(
> + dev->of_node, prop, found_jack_index++, &type);
> + if (ret)
> + continue;
> +
> + if (type)
> + type &= type_supp_mask; /* use only supported types */
> + else
> + type = type_supp_mask; /* use all supported types */
> +
> + if (!type)
> + continue;
> +
> + /* create jack */
> + 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;
> }
>

2023-01-18 15:07:41

by Astrid Rost

[permalink] [raw]
Subject: Re: [PATCH v1 2/4] ASoC: simple-card-utils: create jack inputs for aux_devs



On 1/18/23 14:39, Amadeusz Sławiński wrote:
> On 1/18/2023 1:52 PM, 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 has the functions set_jack and
>> get_jack_supported_type counts as jack device.
>>
>> Add a devicetree entry, in case not all input types are required.
>>   simple-card,aux-jack-types:
>> Array of snd_jack_type to create jack-input-event for jack devices in
>> aux-devs. If the setting is 0, the supported type of the device is used.
>>
>> Signed-off-by: Astrid Rost <[email protected]>
>> ---
>>   include/sound/simple_card_utils.h     |  3 ++
>>   sound/soc/generic/simple-card-utils.c | 63 +++++++++++++++++++++++++++
>>   sound/soc/generic/simple-card.c       |  4 ++
>>   3 files changed, 70 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..668123549fbf 100644
>> --- a/sound/soc/generic/simple-card-utils.c
>> +++ b/sound/soc/generic/simple-card-utils.c
>> @@ -786,6 +786,69 @@ 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 device *dev = card->dev;
>> +    struct snd_soc_component *component;
>> +    char prop[128];
>> +    int found_jack_index = 0;
>> +    int num = 0;
>> +    int ret;
>> +
>> +    if (priv->aux_jacks)
>> +        return 0;
>> +
>> +    snprintf(prop, sizeof(prop), "%saux-jack-types", prefix);
>> +    num = of_property_count_u32_elems(dev->of_node, prop);
>> +    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) {
>> +        if (found_jack_index >= num)
>> +            break;
>> +
>> +        if (component->driver->set_jack &&
>> +            component->driver->get_jack_supported_type) {
>
> This check is really weird, you are checking if callbacks exist at all,
> which should be unnecessary as it duplicates the work oh
> snd_soc_component_ functions. I would just try to call
> snd_soc_component_get_jack_supported_type() directly and if it returns
> -ENOTSUPP, just go to next iteration.
> I guess your main problem is snd_soc_component_set_jack(), but you can
> just call it with NULL jack to check if it returns -ENOTSUPP, but I
> guess the overall asumption would be that if someone implements
> .get_jack_supported_type, they also implemented .set_jack, so maybe it
> is just unnecessary?
>

Thank you!
Yes, it works fine without it. I will remove it.

>> +            char id[128];
>> +            int type = 0;
>> +            struct snd_soc_jack *jack =
>> +                &(priv->aux_jacks[found_jack_index]);
>> +            int type_supp_mask =
>> +                snd_soc_component_get_jack_supported_type(
>> +                    component);
>> +
>> +            ret = of_property_read_u32_index(
>> +                dev->of_node, prop, found_jack_index++, &type);
>> +            if (ret)
>> +                continue;
>> +
>> +            if (type)
>> +                type &= type_supp_mask; /* use only supported types */
>> +            else
>> +                type = type_supp_mask; /* use all supported types */
>> +
>> +            if (!type)
>> +                continue;
>> +
>> +            /* create jack */
>> +            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;
>>   }
>

2023-01-19 12:29:22

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] ASoC: dt-bindings: simple-card: create jack for aux_devs

On 18/01/2023 13:52, Astrid Rost wrote:
> Add simple-card,aux-jack-types:
> Array of snd_jack_type to create jack-input-event for jack devices in
> aux-devs. If the setting is 0, the supported type of the device is used.
> A device which has the functions set_jack and get_jack_supported_type
> counts as jack device.

How a device can have "set_jack"? Isn't this part of code? Are you sure
you describe here hardware, not Linux driver behavior?

>
> Signed-off-by: Astrid Rost <[email protected]>
> ---
> .../bindings/sound/simple-card.yaml | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
> index ed19899bc94b..2635b1c04fc9 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
> @@ -199,6 +199,13 @@ properties:
> maxItems: 1
> simple-audio-card,mic-det-gpio:
> maxItems: 1
> + simple-audio-card,aux-jack-types:
> + $ref: "/schemas/types.yaml#/definitions/uint32-array"

Drop quotes.

> + description: |
> + Array of snd_jack_type to create jack-input-event for jack
> + devices in aux-devs. If the setting is 0, the supported
> + type of the device is used. A device which has the functions
> + set_jack and get_jack_supported_type counts as jack device.

Same problems.

Additionally, if this is a type of aux-dev, then maybe it should be just
added as argument to aux-dev?

>
> patternProperties:
> "^simple-audio-card,cpu(@[0-9a-f]+)?$":
> @@ -498,3 +505,31 @@ examples:
> };
> };
> };
> +#--------------------
> +# Add a headphone and a headset mic jack,
> +# which use an auxiliary jack detector e.g. via i2c.
> +# The events, which should be enabled are:
> +# SND_JACK_HEADPHONE = 1
> +# SND_JACK_MICROPHONE = 2
> +#--------------------

No new examples, integrate it into some existing one.

> + sound {
> + compatible = "simple-audio-card";
> + simple-audio-card,widgets =
> + "Headphone", "Headphone Jack",
> + "Headset Mic", "Headset Mic Jack";
> + simple-audio-card,routing =
> + "Headphone Jack", "HPLEFT",
> + "Headphone Jack", "HPRIGHT",
> + "LEFTIN", "Headset Mic",
> + "RIGHTIN", "Headset Mic";
> + simple-audio-card,aux-devs = <&hp_jack>, <&hs_mic_jack>;
> + simple-audio-card,aux-jack-types = <1 2>;
> + simple-audio-card,cpu {
> + sound-dai = <&ssi2>;
> + };
> + simple-audio-card,codec {
> + sound-dai = <&codec>;
> + clocks = <&clocks>;
> + };
> + };

Best regards,
Krzysztof

2023-01-19 16:28:37

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] ASoC: dt-bindings: simple-card: create jack for aux_devs

On Wed, Jan 18, 2023 at 01:52:26PM +0100, Astrid Rost wrote:
> Add simple-card,aux-jack-types:
> Array of snd_jack_type to create jack-input-event for jack devices in
> aux-devs. If the setting is 0, the supported type of the device is used.
> A device which has the functions set_jack and get_jack_supported_type
> counts as jack device.
>
> Signed-off-by: Astrid Rost <[email protected]>
> ---
> .../bindings/sound/simple-card.yaml | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
> index ed19899bc94b..2635b1c04fc9 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
> @@ -199,6 +199,13 @@ properties:
> maxItems: 1
> simple-audio-card,mic-det-gpio:
> maxItems: 1
> + simple-audio-card,aux-jack-types:

Drop 'simple-audio-card,'. That way we can reuse this for the
not-simple cases.

I'm pretty sure we have some vendor specific properties for this
already. Use those for inspiration and to create something which could
replace them.

> + $ref: "/schemas/types.yaml#/definitions/uint32-array"
> + description: |
> + Array of snd_jack_type to create jack-input-event for jack
> + devices in aux-devs. If the setting is 0, the supported
> + type of the device is used. A device which has the functions
> + set_jack and get_jack_supported_type counts as jack device.

Sounds like Linux details. How does BSD use this property?

Rob

2023-01-19 16:44:04

by Astrid Rost

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] ASoC: dt-bindings: simple-card: create jack for aux_devs

Hello,

Thank you! Yes this makes things much easier. I will fix it.

Astrid

On 1/19/23 12:18, Krzysztof Kozlowski wrote:
> On 18/01/2023 13:52, Astrid Rost wrote:
>> Add simple-card,aux-jack-types:
>> Array of snd_jack_type to create jack-input-event for jack devices in
>> aux-devs. If the setting is 0, the supported type of the device is used.
>> A device which has the functions set_jack and get_jack_supported_type
>> counts as jack device.
>
> How a device can have "set_jack"? Isn't this part of code? Are you sure
> you describe here hardware, not Linux driver behavior?
>
>>
>> Signed-off-by: Astrid Rost <[email protected]>
>> ---
>> .../bindings/sound/simple-card.yaml | 35 +++++++++++++++++++
>> 1 file changed, 35 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
>> index ed19899bc94b..2635b1c04fc9 100644
>> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
>> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
>> @@ -199,6 +199,13 @@ properties:
>> maxItems: 1
>> simple-audio-card,mic-det-gpio:
>> maxItems: 1
>> + simple-audio-card,aux-jack-types:
>> + $ref: "/schemas/types.yaml#/definitions/uint32-array"
>
> Drop quotes.
>
>> + description: |
>> + Array of snd_jack_type to create jack-input-event for jack
>> + devices in aux-devs. If the setting is 0, the supported
>> + type of the device is used. A device which has the functions
>> + set_jack and get_jack_supported_type counts as jack device.
>
> Same problems.
>
> Additionally, if this is a type of aux-dev, then maybe it should be just
> added as argument to aux-dev?
>
>>
>> patternProperties:
>> "^simple-audio-card,cpu(@[0-9a-f]+)?$":
>> @@ -498,3 +505,31 @@ examples:
>> };
>> };
>> };
>> +#--------------------
>> +# Add a headphone and a headset mic jack,
>> +# which use an auxiliary jack detector e.g. via i2c.
>> +# The events, which should be enabled are:
>> +# SND_JACK_HEADPHONE = 1
>> +# SND_JACK_MICROPHONE = 2
>> +#--------------------
>
> No new examples, integrate it into some existing one.
>
>> + sound {
>> + compatible = "simple-audio-card";
>> + simple-audio-card,widgets =
>> + "Headphone", "Headphone Jack",
>> + "Headset Mic", "Headset Mic Jack";
>> + simple-audio-card,routing =
>> + "Headphone Jack", "HPLEFT",
>> + "Headphone Jack", "HPRIGHT",
>> + "LEFTIN", "Headset Mic",
>> + "RIGHTIN", "Headset Mic";
>> + simple-audio-card,aux-devs = <&hp_jack>, <&hs_mic_jack>;
>> + simple-audio-card,aux-jack-types = <1 2>;
>> + simple-audio-card,cpu {
>> + sound-dai = <&ssi2>;
>> + };
>> + simple-audio-card,codec {
>> + sound-dai = <&codec>;
>> + clocks = <&clocks>;
>> + };
>> + };
>
> Best regards,
> Krzysztof
>