linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] DT binding for sample format conversion
@ 2022-07-27 14:26 Sameer Pujar
  2022-07-27 14:26 ` [PATCH 1/2] ASoC: dt-bindings: Add " Sameer Pujar
  2022-07-27 14:26 ` [PATCH 2/2] ASoC: simple-card-utils: Fixup DAI sample format Sameer Pujar
  0 siblings, 2 replies; 6+ messages in thread
From: Sameer Pujar @ 2022-07-27 14:26 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, krzysztof.kozlowski+dt, perex,
	tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel, Sameer Pujar

DT binding properties are available to fixup rate and channel
parameters of a DAI. This series extends this to sample format
conversion as well. With this now DAI PCM parameters (channels,
sample rate and sample format) can be fixed up as necessary
in an audio path.

Sameer Pujar (2):
  ASoC: dt-bindings: Add sample format conversion
  ASoC: simple-card-utils: Fixup DAI sample format

 .../devicetree/bindings/sound/audio-graph-port.yaml | 21 +++++++++++++++++++++
 .../devicetree/bindings/sound/audio-graph.yaml      | 11 +++++++++++
 .../devicetree/bindings/sound/simple-card.yaml      | 15 +++++++++++++++
 include/sound/simple_card_utils.h                   |  1 +
 sound/soc/generic/simple-card-utils.c               | 12 ++++++++++++
 5 files changed, 60 insertions(+)

-- 
2.7.4


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

* [PATCH 1/2] ASoC: dt-bindings: Add sample format conversion
  2022-07-27 14:26 [PATCH 0/2] DT binding for sample format conversion Sameer Pujar
@ 2022-07-27 14:26 ` Sameer Pujar
  2022-07-28 12:22   ` Krzysztof Kozlowski
  2022-07-27 14:26 ` [PATCH 2/2] ASoC: simple-card-utils: Fixup DAI sample format Sameer Pujar
  1 sibling, 1 reply; 6+ messages in thread
From: Sameer Pujar @ 2022-07-27 14:26 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, krzysztof.kozlowski+dt, perex,
	tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel, Sameer Pujar

Presently "convert-channels" and "convert-rate" DT bindings are available
for channel and rate fixups respectively.

Similarly add "convert-sample-format" binding to fixup DAI sample format
as well. This is added to simple-card and audio-graph based sound cards.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../devicetree/bindings/sound/audio-graph-port.yaml | 21 +++++++++++++++++++++
 .../devicetree/bindings/sound/audio-graph.yaml      | 11 +++++++++++
 .../devicetree/bindings/sound/simple-card.yaml      | 15 +++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 5c36867..d7491038 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -24,6 +24,17 @@ properties:
   convert-channels:
     description: CPU to Codec rate channels.
     $ref: /schemas/types.yaml#/definitions/uint32
+  convert-sample-format:
+    description: CPU to Codec sample format.
+      Value    Format
+        0        S8
+        2        S16_LE
+        6        S24_LE
+        10       S32_LE
+        32       S24_3LE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 2, 6, 10, 32]
+
 patternProperties:
   "^endpoint(@[0-9a-f]+)?":
     $ref: /schemas/graph.yaml#/$defs/endpoint-base
@@ -70,6 +81,16 @@ patternProperties:
       convert-channels:
         description: CPU to Codec rate channels.
         $ref: /schemas/types.yaml#/definitions/uint32
+      convert-sample-format:
+        description: CPU to Codec sample format.
+          Value    Format
+            0        S8
+            2        S16_LE
+            6        S24_LE
+            10       S32_LE
+            32       S24_3LE
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 2, 6, 10, 32]
 
       dai-tdm-slot-width-map:
         description: Mapping of sample widths to slot widths. For hardware
diff --git a/Documentation/devicetree/bindings/sound/audio-graph.yaml b/Documentation/devicetree/bindings/sound/audio-graph.yaml
index 4b46794..df8a994 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph.yaml
@@ -32,6 +32,17 @@ properties:
   convert-channels:
     description: CPU to Codec rate channels.
     $ref: /schemas/types.yaml#/definitions/uint32
+  convert-sample-format:
+    description: CPU to Codec sample format.
+      Value    Format
+        0        S8
+        2        S16_LE
+        6        S24_LE
+        10       S32_LE
+        32       S24_3LE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 2, 6, 10, 32]
+
   pa-gpios:
     maxItems: 1
   hp-det-gpio:
diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
index b261d49..6decd73 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.yaml
+++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
@@ -77,6 +77,17 @@ definitions:
     description: CPU to Codec rate channels.
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  convert-sample-format:
+    description: CPU to Codec sample format.
+      Value    Format
+        0        S8
+        2        S16_LE
+        6        S24_LE
+        10       S32_LE
+        32       S24_3LE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 2, 6, 10, 32]
+
   prefix:
     description: "device name prefix"
     $ref: /schemas/types.yaml#/definitions/string
@@ -191,6 +202,8 @@ properties:
     $ref: "#/definitions/convert-rate"
   simple-audio-card,convert-channels:
     $ref: "#/definitions/convert-channels"
+  simple-audio-card,convert-sample-format:
+    $ref: "#/definitions/convert-sample-format"
   simple-audio-card,prefix:
     $ref: "#/definitions/prefix"
   simple-audio-card,pin-switches:
@@ -234,6 +247,8 @@ patternProperties:
         $ref: "#/definitions/convert-rate"
       convert-channels:
         $ref: "#/definitions/convert-channels"
+      convert-sample-format:
+        $ref: "#/definitions/convert-sample-format"
       prefix:
         $ref: "#/definitions/prefix"
       pin-switches:
-- 
2.7.4


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

* [PATCH 2/2] ASoC: simple-card-utils: Fixup DAI sample format
  2022-07-27 14:26 [PATCH 0/2] DT binding for sample format conversion Sameer Pujar
  2022-07-27 14:26 ` [PATCH 1/2] ASoC: dt-bindings: Add " Sameer Pujar
@ 2022-07-27 14:26 ` Sameer Pujar
  1 sibling, 0 replies; 6+ messages in thread
From: Sameer Pujar @ 2022-07-27 14:26 UTC (permalink / raw)
  To: broonie, lgirdwood, robh+dt, krzysztof.kozlowski+dt, perex,
	tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel, Sameer Pujar

Parse "convert-sample-format" DT binding and fixup the sample format
as applicable. This is similar to the existing "convert-channels" and
"convert-rate" properties for channels and rate fixup respectively.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h     |  1 +
 sound/soc/generic/simple-card-utils.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index ab55f40..39ea57d 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -39,6 +39,7 @@ struct asoc_simple_dai {
 struct asoc_simple_data {
 	u32 convert_rate;
 	u32 convert_channels;
+	int convert_sample_format;
 };
 
 struct asoc_simple_jack {
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 4a29e31..6ce5102 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -22,6 +22,8 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data,
 						SNDRV_PCM_HW_PARAM_RATE);
 	struct snd_interval *channels = hw_param_interval(params,
 						SNDRV_PCM_HW_PARAM_CHANNELS);
+	struct snd_mask *mask = hw_param_mask(params,
+						SNDRV_PCM_HW_PARAM_FORMAT);
 
 	if (data->convert_rate)
 		rate->min =
@@ -30,6 +32,11 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data,
 	if (data->convert_channels)
 		channels->min =
 		channels->max = data->convert_channels;
+
+	if (data->convert_sample_format >= 0) {
+		snd_mask_none(mask);
+		snd_mask_set(mask, data->convert_sample_format);
+	}
 }
 EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup);
 
@@ -49,6 +56,11 @@ void asoc_simple_parse_convert(struct device_node *np,
 	/* channels transfer */
 	snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels");
 	of_property_read_u32(np, prop, &data->convert_channels);
+
+	/* convert sample format */
+	data->convert_sample_format = -EINVAL;
+	snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-sample-format");
+	of_property_read_u32(np, prop, &data->convert_sample_format);
 }
 EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
 
-- 
2.7.4


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

* Re: [PATCH 1/2] ASoC: dt-bindings: Add sample format conversion
  2022-07-27 14:26 ` [PATCH 1/2] ASoC: dt-bindings: Add " Sameer Pujar
@ 2022-07-28 12:22   ` Krzysztof Kozlowski
  2022-07-29  4:11     ` Sameer Pujar
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2022-07-28 12:22 UTC (permalink / raw)
  To: Sameer Pujar, broonie, lgirdwood, robh+dt,
	krzysztof.kozlowski+dt, perex, tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel

On 27/07/2022 16:26, Sameer Pujar wrote:
> Presently "convert-channels" and "convert-rate" DT bindings are available
> for channel and rate fixups respectively.
> 
> Similarly add "convert-sample-format" binding to fixup DAI sample format
> as well. This is added to simple-card and audio-graph based sound cards.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  .../devicetree/bindings/sound/audio-graph-port.yaml | 21 +++++++++++++++++++++
>  .../devicetree/bindings/sound/audio-graph.yaml      | 11 +++++++++++
>  .../devicetree/bindings/sound/simple-card.yaml      | 15 +++++++++++++++
>  3 files changed, 47 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> index 5c36867..d7491038 100644
> --- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> +++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> @@ -24,6 +24,17 @@ properties:
>    convert-channels:
>      description: CPU to Codec rate channels.
>      $ref: /schemas/types.yaml#/definitions/uint32

Missing blank line.

> +  convert-sample-format:
> +    description: CPU to Codec sample format.
> +      Value    Format
> +        0        S8
> +        2        S16_LE
> +        6        S24_LE
> +        10       S32_LE
> +        32       S24_3LE

Why some random set of integers? Just use string, must more descriptive
and you do not embed programming model to DT... unless there is some
reason for this approach?

> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 2, 6, 10, 32]
> +
>  patternProperties:
>    "^endpoint(@[0-9a-f]+)?":
>      $ref: /schemas/graph.yaml#/$defs/endpoint-base
> @@ -70,6 +81,16 @@ patternProperties:
>        convert-channels:
>          description: CPU to Codec rate channels.
>          $ref: /schemas/types.yaml#/definitions/uint32

Ditto

> +      convert-sample-format:
> +        description: CPU to Codec sample format.
> +          Value    Format
> +            0        S8
> +            2        S16_LE
> +            6        S24_LE
> +            10       S32_LE
> +            32       S24_3LE
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [0, 2, 6, 10, 32]

Ditto


>  
>        dai-tdm-slot-width-map:
>          description: Mapping of sample widths to slot widths. For hardware
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph.yaml b/Documentation/devicetree/bindings/sound/audio-graph.yaml
> index 4b46794..df8a994 100644
> --- a/Documentation/devicetree/bindings/sound/audio-graph.yaml
> +++ b/Documentation/devicetree/bindings/sound/audio-graph.yaml
> @@ -32,6 +32,17 @@ properties:
>    convert-channels:
>      description: CPU to Codec rate channels.
>      $ref: /schemas/types.yaml#/definitions/uint32

Ditto

> +  convert-sample-format:
> +    description: CPU to Codec sample format.
> +      Value    Format
> +        0        S8
> +        2        S16_LE
> +        6        S24_LE
> +        10       S32_LE
> +        32       S24_3LE

Ditto


> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 2, 6, 10, 32]
> +
>    pa-gpios:
>      maxItems: 1
>    hp-det-gpio:
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
> index b261d49..6decd73 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
> @@ -77,6 +77,17 @@ definitions:
>      description: CPU to Codec rate channels.
>      $ref: /schemas/types.yaml#/definitions/uint32
>  
> +  convert-sample-format:
> +    description: CPU to Codec sample format.
> +      Value    Format
> +        0        S8
> +        2        S16_LE
> +        6        S24_LE
> +        10       S32_LE
> +        32       S24_3LE
> +    $ref: /schemas/types.yaml#/definitions/uint32

Wait, you now put the same property in four different places. Don't you
have something which could be shared?



Best regards,
Krzysztof

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

* Re: [PATCH 1/2] ASoC: dt-bindings: Add sample format conversion
  2022-07-28 12:22   ` Krzysztof Kozlowski
@ 2022-07-29  4:11     ` Sameer Pujar
  2022-08-02  7:29       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 6+ messages in thread
From: Sameer Pujar @ 2022-07-29  4:11 UTC (permalink / raw)
  To: Krzysztof Kozlowski, broonie, lgirdwood, robh+dt,
	krzysztof.kozlowski+dt, perex, tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel


On 28-07-2022 17:52, Krzysztof Kozlowski wrote:
> On 27/07/2022 16:26, Sameer Pujar wrote:
>> Presently "convert-channels" and "convert-rate" DT bindings are available
>> for channel and rate fixups respectively.
>>
>> Similarly add "convert-sample-format" binding to fixup DAI sample format
>> as well. This is added to simple-card and audio-graph based sound cards.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> ---
>>   .../devicetree/bindings/sound/audio-graph-port.yaml | 21 +++++++++++++++++++++
>>   .../devicetree/bindings/sound/audio-graph.yaml      | 11 +++++++++++
>>   .../devicetree/bindings/sound/simple-card.yaml      | 15 +++++++++++++++
>>   3 files changed, 47 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
>> index 5c36867..d7491038 100644
>> --- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
>> +++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
>> @@ -24,6 +24,17 @@ properties:
>>     convert-channels:
>>       description: CPU to Codec rate channels.
>>       $ref: /schemas/types.yaml#/definitions/uint32
> Missing blank line.

will fix.

>
>> +  convert-sample-format:
>> +    description: CPU to Codec sample format.
>> +      Value    Format
>> +        0        S8
>> +        2        S16_LE
>> +        6        S24_LE
>> +        10       S32_LE
>> +        32       S24_3LE
> Why some random set of integers? Just use string, must more descriptive
> and you do not embed programming model to DT... unless there is some
> reason for this approach?

I referenced it from similar usage in fsl,easrc.yaml for binding 
"fsl,asrc-format" and driver can directly use it. However agree with 
above and let me use strings here.


[...]


> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
> index b261d49..6decd73 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
> @@ -77,6 +77,17 @@ definitions:
>       description: CPU to Codec rate channels.
>       $ref: /schemas/types.yaml#/definitions/uint32
>
> +  convert-sample-format:
> +    description: CPU to Codec sample format.
> +      Value    Format
> +        0        S8
> +        2        S16_LE
> +        6        S24_LE
> +        10       S32_LE
> +        32       S24_3LE
> +    $ref: /schemas/types.yaml#/definitions/uint32
> Wait, you now put the same property in four different places. Don't you
> have something which could be shared?
>
There is no shared schema between simple-card.yaml and others. I will 
have to create a new doc to share these definitions.


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

* Re: [PATCH 1/2] ASoC: dt-bindings: Add sample format conversion
  2022-07-29  4:11     ` Sameer Pujar
@ 2022-08-02  7:29       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2022-08-02  7:29 UTC (permalink / raw)
  To: Sameer Pujar, broonie, lgirdwood, robh+dt,
	krzysztof.kozlowski+dt, perex, tiwai, kuninori.morimoto.gx
  Cc: alsa-devel, devicetree, linux-kernel

On 29/07/2022 06:11, Sameer Pujar wrote:

>> diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
>> index b261d49..6decd73 100644
>> --- a/Documentation/devicetree/bindings/sound/simple-card.yaml
>> +++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
>> @@ -77,6 +77,17 @@ definitions:
>>       description: CPU to Codec rate channels.
>>       $ref: /schemas/types.yaml#/definitions/uint32
>>
>> +  convert-sample-format:
>> +    description: CPU to Codec sample format.
>> +      Value    Format
>> +        0        S8
>> +        2        S16_LE
>> +        6        S24_LE
>> +        10       S32_LE
>> +        32       S24_3LE
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> Wait, you now put the same property in four different places. Don't you
>> have something which could be shared?
>>
> There is no shared schema between simple-card.yaml and others. I will 
> have to create a new doc to share these definitions.

OK


Best regards,
Krzysztof

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

end of thread, other threads:[~2022-08-02  7:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 14:26 [PATCH 0/2] DT binding for sample format conversion Sameer Pujar
2022-07-27 14:26 ` [PATCH 1/2] ASoC: dt-bindings: Add " Sameer Pujar
2022-07-28 12:22   ` Krzysztof Kozlowski
2022-07-29  4:11     ` Sameer Pujar
2022-08-02  7:29       ` Krzysztof Kozlowski
2022-07-27 14:26 ` [PATCH 2/2] ASoC: simple-card-utils: Fixup DAI sample format Sameer Pujar

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).