Skip to contentSkip to conversation

DT binding for sample format conversion

PATCH Superseded Sameer Pujar 2 participants 10 messages Aug 1, 2022 – Aug 4, 2022

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover DT binding for sample format conversion

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.

Changelog:
==========
v1->v2:
-------
* Move DAI params properties to a new schema and re-use this for simple-card and audio-graph-card.
* Use string type for DAI format binding as suggested by Krzysztof.

Sameer Pujar (3):
ASoC: dt-bindings: Add schema for common DAI params
ASoC: dt-bindings: Add sample format conversion
ASoC: simple-card-utils: Fixup DAI sample format

 .../bindings/sound/audio-graph-port.yaml           | 17 +++++-----
 .../devicetree/bindings/sound/audio-graph.yaml     |  9 ++---
 .../devicetree/bindings/sound/dai-params.yaml      | 38 ++++++++++++++++++++++
 .../devicetree/bindings/sound/simple-card.yaml     | 20 +++++-------
 include/sound/simple_card_utils.h                  |  1 +
 sound/soc/generic/simple-card-utils.c              | 34 +++++++++++++++++++
 6 files changed, 95 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/3 ASoC: dt-bindings: Add schema for common DAI params

The "convert-channels" and "convert-rate" bindings are provided for both simple-card and audio-graph-card. However these are separately defined in their respective schemas. For any new binding addition, which is common to both, there will be duplication.

Introduce a new schema to have common DAI params properties and these can be re-used in other schemas wherever applicable.

Cc Kuninori Morimoto <[email protected]>
---
 .../bindings/sound/audio-graph-port.yaml           | 13 ++++------
 .../devicetree/bindings/sound/audio-graph.yaml     |  7 +++---
 .../devicetree/bindings/sound/dai-params.yaml      | 28 ++++++++++++++++++++++
 .../devicetree/bindings/sound/simple-card.yaml     | 16 ++++---------
 4 files changed, 40 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml
Documentation/devicetree/bindings/sound/audio-graph-port.yaml +5 -8
index 5c36867..30a644d9 100644
@@ -19,11 +19,10 @@ properties:
     description: "device name prefix"
     $ref: /schemas/types.yaml#/definitions/string
   convert-rate:
-    description: CPU to Codec rate convert.
-    $ref: /schemas/types.yaml#/definitions/uint32
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
-    description: CPU to Codec rate channels.
-    $ref: /schemas/types.yaml#/definitions/uint32
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+
 patternProperties:
   "^endpoint(@[0-9a-f]+)?":
     $ref: /schemas/graph.yaml#/$defs/endpoint-base
@@ -65,11 +64,9 @@ patternProperties:
             - msb
             - lsb
       convert-rate:
-        description: CPU to Codec rate convert.
-        $ref: /schemas/types.yaml#/definitions/uint32
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
-        description: CPU to Codec rate channels.
-        $ref: /schemas/types.yaml#/definitions/uint32
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
 
       dai-tdm-slot-width-map:
         description: Mapping of sample widths to slot widths. For hardware
Documentation/devicetree/bindings/sound/audio-graph.yaml +3 -4
index 4b46794..a9cd52e 100644
@@ -27,11 +27,10 @@ properties:
     description: User specified audio sound widgets.
     $ref: /schemas/types.yaml#/definitions/non-unique-string-array
   convert-rate:
-    description: CPU to Codec rate convert.
-    $ref: /schemas/types.yaml#/definitions/uint32
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
-    description: CPU to Codec rate channels.
-    $ref: /schemas/types.yaml#/definitions/uint32
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+
   pa-gpios:
     maxItems: 1
   hp-det-gpio:
Documentation/devicetree/bindings/sound/dai-params.yaml new file +28 -0
new file mode 100644
index 0000000..aae60cb
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/dai-params.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Digital Audio Interface (DAI) Stream Parameters
+
+maintainers:
+  - Kuninori Morimoto <[email protected]>
+
+select: false
+
+properties:
+
+  dai-channels:
+    description: Number of audio channels used by DAI
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 32
+
+  dai-sample-rate:
+    description: Audio sample rate used by DAI
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 8000
+    maximum: 192000
+
+additionalProperties: true
Documentation/devicetree/bindings/sound/simple-card.yaml +4 -12
index b261d49..ab03a2b 100644
@@ -69,14 +69,6 @@ definitions:
       as amplifiers, to be added to the sound card.
     $ref: /schemas/types.yaml#/definitions/phandle-array
 
-  convert-rate:
-    description: CPU to Codec rate convert.
-    $ref: /schemas/types.yaml#/definitions/uint32
-
-  convert-channels:
-    description: CPU to Codec rate channels.
-    $ref: /schemas/types.yaml#/definitions/uint32
-
   prefix:
     description: "device name prefix"
     $ref: /schemas/types.yaml#/definitions/string
@@ -188,9 +180,9 @@ properties:
   simple-audio-card,aux-devs:
     $ref: "#/definitions/aux-devs"
   simple-audio-card,convert-rate:
-    $ref: "#/definitions/convert-rate"
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   simple-audio-card,convert-channels:
-    $ref: "#/definitions/convert-channels"
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
   simple-audio-card,prefix:
     $ref: "#/definitions/prefix"
   simple-audio-card,pin-switches:
@@ -231,9 +223,9 @@ patternProperties:
       aux-devs:
         $ref: "#/definitions/aux-devs"
       convert-rate:
-        $ref: "#/definitions/convert-rate"
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
-        $ref: "#/definitions/convert-channels"
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
       prefix:
         $ref: "#/definitions/prefix"
       pin-switches:
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v2 1/3] ASoC: dt-bindings: Add schema for common DAI params

Quoted 10 lines · Sameer Pujar

The "convert-channels" and "convert-rate" bindings are provided for both simple-card and audio-graph-card. However these are separately defined in their respective schemas. For any new binding addition, which is common to both, there will be duplication.

Introduce a new schema to have common DAI params properties and these can be re-used in other schemas wherever applicable.

Cc Kuninori Morimoto <[email protected]>
Quoted 8 lines
---
 .../bindings/sound/audio-graph-port.yaml           | 13 ++++------
 .../devicetree/bindings/sound/audio-graph.yaml     |  7 +++---
 .../devicetree/bindings/sound/dai-params.yaml      | 28 ++++++++++++++++++++++
 .../devicetree/bindings/sound/simple-card.yaml     | 16 ++++---------
 4 files changed, 40 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
'description' is a required property
hint: A vendor boolean property can use "type: boolean"
Additional properties are not allowed ('$ref' was unexpected)
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property
hint: A vendor string property with exact values has an implicit type
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match 'types.yaml#/definitions/'
hint: A vendor property needs a $ref to types.yaml
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match '^#/(definitions|\\$defs)/'
hint: A vendor property can have a $ref to a a $defs schema
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix.
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-channels: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
'description' is a required property
hint: A vendor boolean property can use "type: boolean"
Additional properties are not allowed ('$ref' was unexpected)
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-channels: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property
hint: A vendor string property with exact values has an implicit type
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
'/schemas/sound/dai-params.yaml#/properties/dai-channels' does not match 'types.yaml#/definitions/'
hint: A vendor property needs a $ref to types.yaml
'/schemas/sound/dai-params.yaml#/properties/dai-channels' does not match '^#/(definitions|\\$defs)/'
hint: A vendor property can have a $ref to a a $defs schema
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix.
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
./Documentation/devicetree/bindings/sound/simple-card.yaml: Error in referenced schema matching $id: http://devicetree.org/schemas/sound/simple-card.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: ignoring, error in schema: properties: simple-audio-card,convert-channels /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.example.dtb: sound: simple-audio-card,widgets: b'Microphone\x00Microphone Jack\x00Headphone\x00Headphone Jack\x00Speaker\x00External Speaker\x00' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.example.dtb: sound: simple-audio-card,routing: b'MIC_IN\x00Microphone Jack\x00Headphone Jack\x00HP_OUT\x00External Speaker\x00LINE_OUT\x00' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-0/sound: failed to match any schema with compatible: ['simple-audio-card']
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-1/sound: failed to match any schema with compatible: ['simple-audio-card'] /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.example.dtb: sound: simple-audio-card,widgets: b'Headphone\x00Headphone Jack\x00' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-2/sound: failed to match any schema with compatible: ['simple-audio-card'] /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.example.dtb: sound: simple-audio-card,routing: b'ak4642 Playback\x00DAI0 Playback\x00DAI0 Capture\x00ak4642 Capture\x00' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-3/sound: failed to match any schema with compatible: ['simple-audio-card']
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-4/sound: failed to match any schema with compatible: ['simple-audio-card']
Documentation/devicetree/bindings/sound/simple-card.example.dtb:0:0: /example-5/sound: failed to match any schema with compatible: ['simple-audio-card']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#3 lore raw

Re: [PATCH v2 1/3] ASoC: dt-bindings: Add schema for common DAI params

Hi Rob, Krzysztof

Quoted 35 lines · Rob Herring
Quoted 10 lines · Sameer Pujar

The "convert-channels" and "convert-rate" bindings are provided for both simple-card and audio-graph-card. However these are separately defined in their respective schemas. For any new binding addition, which is common to both, there will be duplication.

Introduce a new schema to have common DAI params properties and these can be re-used in other schemas wherever applicable.

Cc Kuninori Morimoto <[email protected]>
Quoted 8 lines
---
  .../bindings/sound/audio-graph-port.yaml           | 13 ++++------
  .../devicetree/bindings/sound/audio-graph.yaml     |  7 +++---
  .../devicetree/bindings/sound/dai-params.yaml      | 28 ++++++++++++++++++++++
  .../devicetree/bindings/sound/simple-card.yaml     | 16 ++++---------
  4 files changed, 40 insertions(+), 24 deletions(-)

create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
'description' is a required property
hint: A vendor boolean property can use "type: boolean"
Additional properties are not allowed ('$ref' was unexpected)
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property

Quoted 8 lines

hint: A vendor string property with exact values has an implicit type
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match 'types.yaml#/definitions/'
hint: A vendor property needs a $ref to types.yaml
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match '^#/(definitions|\\$defs)/'
hint: A vendor property can have a $ref to a a $defs schema
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix. from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#

I am hitting this error if I use properties/definitions from another schema. If I define it locally, it works. I see there are examples where properties from different schema are used. But not able to understand why errors are seen in my case. Am I missing anything here?

maintainer
#4 lore raw

Re: [PATCH v2 1/3] ASoC: dt-bindings: Add schema for common DAI params

Quoted 47 lines · Sameer Pujar

Hi Rob, Krzysztof

Quoted 35 lines · Rob Herring
Quoted 10 lines · Sameer Pujar

The "convert-channels" and "convert-rate" bindings are provided for both simple-card and audio-graph-card. However these are separately defined in their respective schemas. For any new binding addition, which is common to both, there will be duplication.

Introduce a new schema to have common DAI params properties and these can be re-used in other schemas wherever applicable.

Cc Kuninori Morimoto <[email protected]>
Quoted 8 lines
---
  .../bindings/sound/audio-graph-port.yaml           | 13 ++++------
  .../devicetree/bindings/sound/audio-graph.yaml     |  7 +++---
  .../devicetree/bindings/sound/dai-params.yaml      | 28 ++++++++++++++++++++++
  .../devicetree/bindings/sound/simple-card.yaml     | 16 ++++---------
  4 files changed, 40 insertions(+), 24 deletions(-)

create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
'description' is a required property
hint: A vendor boolean property can use "type: boolean"
Additional properties are not allowed ('$ref' was unexpected)
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property

Quoted 8 lines

hint: A vendor string property with exact values has an implicit type
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match 'types.yaml#/definitions/'
hint: A vendor property needs a $ref to types.yaml
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match '^#/(definitions|\\$defs)/'
hint: A vendor property can have a $ref to a a $defs schema
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix. from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#

Quoted 4 lines

I am hitting this error if I use properties/definitions from another schema. If I define it locally, it works. I see there are examples where properties from different schema are used. But not able to understand why errors are seen in my case. Am I missing anything here?

You either need to use 'properties' with actual property names and reference that schema from the node level. Or you use '$defs' if you are going to have references from the (DT) property level. I think I'd just leave simple-card out of this and do the former.

#5 lore raw

Re: [PATCH v2 1/3] ASoC: dt-bindings: Add schema for common DAI params

Quoted 48 lines · Rob Herring
Quoted 47 lines · Sameer Pujar

Hi Rob, Krzysztof

Quoted 44 lines · Rob Herring
Quoted 10 lines · Sameer Pujar

The "convert-channels" and "convert-rate" bindings are provided for both simple-card and audio-graph-card. However these are separately defined in their respective schemas. For any new binding addition, which is common to both, there will be duplication.

Introduce a new schema to have common DAI params properties and these can be re-used in other schemas wherever applicable.

Cc Kuninori Morimoto<[email protected]>
Quoted 8 lines
---
   .../bindings/sound/audio-graph-port.yaml           | 13 ++++------
   .../devicetree/bindings/sound/audio-graph.yaml     |  7 +++---
   .../devicetree/bindings/sound/dai-params.yaml      | 28 ++++++++++++++++++++++
   .../devicetree/bindings/sound/simple-card.yaml     | 16 ++++---------
   4 files changed, 40 insertions(+), 24 deletions(-)

create mode 100644 Documentation/devicetree/bindings/sound/dai-params.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'type' is a required property
hint: A vendor boolean property can use "type: boolean"
'description' is a required property
hint: A vendor boolean property can use "type: boolean"
Additional properties are not allowed ('$ref' was unexpected)
hint: A vendor boolean property can use "type: boolean"
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/simple-card.yaml: properties:simple-audio-card,convert-rate: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property
hint: A vendor string property with exact values has an implicit type
from schema $id:http://devicetree.org/meta-schemas/vendor-props.yaml#
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not
match 'types.yaml#/definitions/'
hint: A vendor property needs a $ref to types.yaml
'/schemas/sound/dai-params.yaml#/properties/dai-sample-rate' does not match '^#/(definitions|\\$defs)/'
hint: A vendor property can have a $ref to a a $defs schema
hint: Vendor specific properties must have a type and description unless they have a defined, common suffix.
from schema $id:http://devicetree.org/meta-schemas/vendor-props.yaml#

Quoted 8 lines
Quoted 4 lines

I am hitting this error if I use properties/definitions from another schema. If I define it locally, it works. I see there are examples where properties from different schema are used. But not able to understand why errors are seen in my case. Am I missing anything here?

You either need to use 'properties' with actual property names and reference that schema from the node level. Or you use '$defs' if you are going to have references from the (DT) property level. I think I'd just leave simple-card out of this and do the former.

Above errors are coming only from simple-card. The audio-graph related binding checks are clean. It seems having "," in the property name is causing errors for simple-card. Is this intentional?

Thanks Rob for inputs. I will leave simple-card out for now, but will use $defs. The reason is any other vendor schema can make use of these DAI defines. One such use I see is for (../sound/fsl,easrc.yaml for "fsl,asrc-rate").

#6 lore raw

PATCH v2 2/3 ASoC: dt-bindings: Add sample format conversion

In reply to 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.

Cc Kuninori Morimoto <[email protected]>
---
 Documentation/devicetree/bindings/sound/audio-graph-port.yaml |  4 ++++
 Documentation/devicetree/bindings/sound/audio-graph.yaml      |  2 ++
 Documentation/devicetree/bindings/sound/dai-params.yaml       | 10 ++++++++++
 Documentation/devicetree/bindings/sound/simple-card.yaml      |  4 ++++
 4 files changed, 20 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-port.yaml +4 -0
index 30a644d9..8e64192 100644
@@ -22,6 +22,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
 patternProperties:
   "^endpoint(@[0-9a-f]+)?":
@@ -67,6 +69,8 @@ patternProperties:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+      convert-sample-format:
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
       dai-tdm-slot-width-map:
         description: Mapping of sample widths to slot widths. For hardware
Documentation/devicetree/bindings/sound/audio-graph.yaml +2 -0
index a9cd52e..93ddd55 100644
@@ -30,6 +30,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
   pa-gpios:
     maxItems: 1
Documentation/devicetree/bindings/sound/dai-params.yaml +10 -0
index aae60cb..933957d 100644
@@ -19,6 +19,16 @@ properties:
     minimum: 1
     maximum: 32
 
+  dai-sample-format:
+    description: Audio sample format used by DAI
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - s8
+      - s16_le
+      - s24_le
+      - s24_3le
+      - s32_le
+
   dai-sample-rate:
     description: Audio sample rate used by DAI
     $ref: /schemas/types.yaml#/definitions/uint32
Documentation/devicetree/bindings/sound/simple-card.yaml +4 -0
index ab03a2b..ec21190 100644
@@ -183,6 +183,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   simple-audio-card,convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  simple-audio-card,convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
   simple-audio-card,prefix:
     $ref: "#/definitions/prefix"
   simple-audio-card,pin-switches:
@@ -226,6 +228,8 @@ patternProperties:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+      convert-sample-format:
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
       prefix:
         $ref: "#/definitions/prefix"
       pin-switches:
Signature · 1 line
2.7.4
maintainer
#7 lore raw

Re: [PATCH v2 2/3] ASoC: dt-bindings: Add sample format conversion

Quoted 5 lines · 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.

Do you have users for both cases?

Quoted 37 lines
Cc Kuninori Morimoto <[email protected]>
---
 Documentation/devicetree/bindings/sound/audio-graph-port.yaml |  4 ++++
 Documentation/devicetree/bindings/sound/audio-graph.yaml      |  2 ++
 Documentation/devicetree/bindings/sound/dai-params.yaml       | 10 ++++++++++
 Documentation/devicetree/bindings/sound/simple-card.yaml      |  4 ++++
 4 files changed, 20 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-port.yaml +4 -0
index 30a644d9..8e64192 100644
@@ -22,6 +22,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
 patternProperties:
   "^endpoint(@[0-9a-f]+)?":
@@ -67,6 +69,8 @@ patternProperties:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+      convert-sample-format:
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
       dai-tdm-slot-width-map:
         description: Mapping of sample widths to slot widths. For hardware
Documentation/devicetree/bindings/sound/audio-graph.yaml +0 -0
index a9cd52e..93ddd55 100644

Documentation/devicetree/bindings/sound/audio-graph.yaml properties: · line 34

Quoted 5 lines
Documentation/devicetree/bindings/sound/audio-graph.yaml +2 -0
@@ -30,6 +30,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"

Can someone explain why we need these properties defined in 3 different locations? That's not a great pattern to continue.

Quoted 29 lines
Documentation/devicetree/bindings/sound/audio-graph.yaml +0 -0
   pa-gpios:
     maxItems: 1
Documentation/devicetree/bindings/sound/dai-params.yaml +10 -0
index aae60cb..933957d 100644
@@ -19,6 +19,16 @@ properties:
     minimum: 1
     maximum: 32
 
+  dai-sample-format:
+    description: Audio sample format used by DAI
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - s8
+      - s16_le
+      - s24_le
+      - s24_3le
+      - s32_le
+
   dai-sample-rate:
     description: Audio sample rate used by DAI
     $ref: /schemas/types.yaml#/definitions/uint32
Documentation/devicetree/bindings/sound/simple-card.yaml +0 -0
index ab03a2b..ec21190 100644

Documentation/devicetree/bindings/sound/simple-card.yaml properties: · line 186

Quoted 4 lines
Documentation/devicetree/bindings/sound/simple-card.yaml +1 -0
@@ -183,6 +183,8 @@ properties:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
   simple-audio-card,convert-channels:
     $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  simple-audio-card,convert-sample-format:

Don't add more properties with 'simple-audio-card,' prefix. That's not a pattern we want to be consistent with...

Quoted 17 lines
Documentation/devicetree/bindings/sound/simple-card.yaml +3 -0
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
   simple-audio-card,prefix:
     $ref: "#/definitions/prefix"
   simple-audio-card,pin-switches:
@@ -226,6 +228,8 @@ patternProperties:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
       convert-channels:
         $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+      convert-sample-format:
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
       prefix:
         $ref: "#/definitions/prefix"
       pin-switches:
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH v2 2/3] ASoC: dt-bindings: Add sample format conversion

Quoted 7 lines · Rob Herring
Quoted 5 lines · 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.

Do you have users for both cases?

I don't plan to use simple-card. Just added for consistency. Will drop this.

It would be required for audio-graph.

Quoted 30 lines
Quoted 30 lines
Cc Kuninori Morimoto<[email protected]>
---
  Documentation/devicetree/bindings/sound/audio-graph-port.yaml |  4 ++++
  Documentation/devicetree/bindings/sound/audio-graph.yaml      |  2 ++
  Documentation/devicetree/bindings/sound/dai-params.yaml       | 10 ++++++++++
  Documentation/devicetree/bindings/sound/simple-card.yaml      |  4 ++++
  4 files changed, 20 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-port.yaml +4 -0
index 30a644d9..8e64192 100644
@@ -22,6 +22,8 @@ properties:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
    convert-channels:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
  patternProperties:
    "^endpoint(@[0-9a-f]+)?":
@@ -67,6 +69,8 @@ patternProperties:
          $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
        convert-channels:
          $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+      convert-sample-format:
+        $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"
 
Quoted 14 lines

Documentation/devicetree/bindings/sound/audio-graph.yaml properties: · line 34

Quoted 12 lines
Documentation/devicetree/bindings/sound/audio-graph-port.yaml +0 -0
        dai-tdm-slot-width-map:
          description: Mapping of sample widths to slot widths. For hardware
Documentation/devicetree/bindings/sound/audio-graph.yaml +2 -0
index a9cd52e..93ddd55 100644
@@ -30,6 +30,8 @@ properties:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
    convert-channels:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  convert-sample-format:
+    $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-format"

Can someone explain why we need these properties defined in 3 different locations? That's not a great pattern to continue.

The properties are defined at sound card, port and endpoint node level. I guess the idea is to selectively apply a configuration to a group of endpoints/ports or just specific endpoint. Morimoto-san can comment if there are other reasons to do so.

Quoted 26 lines
Quoted 26 lines
Documentation/devicetree/bindings/sound/audio-graph.yaml +0 -0
    pa-gpios:
      maxItems: 1
Documentation/devicetree/bindings/sound/dai-params.yaml +10 -0
index aae60cb..933957d 100644
@@ -19,6 +19,16 @@ properties:
      minimum: 1
      maximum: 32
 
+  dai-sample-format:
+    description: Audio sample format used by DAI
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - s8
+      - s16_le
+      - s24_le
+      - s24_3le
+      - s32_le
+
    dai-sample-rate:
      description: Audio sample rate used by DAI
      $ref: /schemas/types.yaml#/definitions/uint32
Documentation/devicetree/bindings/sound/simple-card.yaml +0 -1
index ab03a2b..ec21190 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.yaml
Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-card.yaml properties: · line 186

Quoted 6 lines

+++ b/Documentation/devicetree/bindings/sound/simple-card.yaml

Documentation/devicetree/bindings/sound/simple-card.yaml +1 -0
@@ -183,6 +183,8 @@ properties:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-sample-rate"
    simple-audio-card,convert-channels:
      $ref: "/schemas/sound/dai-params.yaml#/properties/dai-channels"
+  simple-audio-card,convert-sample-format:

Don't add more properties with 'simple-audio-card,' prefix. That's not a pattern we want to be consistent with...

Will drop this in next revision.

#9 lore raw

PATCH v2 3/3 ASoC: simple-card-utils: Fixup DAI sample format

In reply to 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.

Cc Kuninori Morimoto <[email protected]>
---
 include/sound/simple_card_utils.h     |  1 +
 sound/soc/generic/simple-card-utils.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
include/sound/simple_card_utils.h +1 -0
index ab55f40..a0b827f 100644
@@ -39,6 +39,7 @@ struct asoc_simple_dai {
 struct asoc_simple_data {
 	u32 convert_rate;
 	u32 convert_channels;
+	const char *convert_sample_format;
 };
 
 struct asoc_simple_jack {
sound/soc/generic/simple-card-utils.c +34 -0
index 4a29e31..1b201dd 100644
@@ -15,6 +15,33 @@
 #include <sound/pcm_params.h>
 #include <sound/simple_card_utils.h>
 
+static void asoc_simple_fixup_sample_fmt(struct asoc_simple_data *data,
+					 struct snd_pcm_hw_params *params)
+{
+	int i;
+	struct snd_mask *mask = hw_param_mask(params,
+					      SNDRV_PCM_HW_PARAM_FORMAT);
+	struct {
+		char *fmt;
+		u32 val;
+	} of_sample_fmt_table[] = {
+		{ "s8",		SNDRV_PCM_FORMAT_S8},
+		{ "s16_le",	SNDRV_PCM_FORMAT_S16_LE},
+		{ "s24_le",	SNDRV_PCM_FORMAT_S24_LE},
+		{ "s24_3le",	SNDRV_PCM_FORMAT_S24_3LE},
+		{ "s32_le",	SNDRV_PCM_FORMAT_S32_LE},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) {
+		if (!strcmp(data->convert_sample_format,
+			    of_sample_fmt_table[i].fmt)) {
+			snd_mask_none(mask);
+			snd_mask_set(mask, of_sample_fmt_table[i].val);
+			break;
+		}
+	}
+}
+
 void asoc_simple_convert_fixup(struct asoc_simple_data *data,
 			       struct snd_pcm_hw_params *params)
 {
@@ -30,6 +57,9 @@ 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)
+		asoc_simple_fixup_sample_fmt(data, params);
 }
 EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup);
 
@@ -49,6 +79,10 @@ 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 */
+	snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-sample-format");
+	of_property_read_string(np, prop, &data->convert_sample_format);
 }
 EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
 
Signature · 1 line
2.7.4