simple-card: Add samplerate and samplewidth constraints
Subsystems (4)
cover simple-card: Add samplerate and samplewidth constraints
These constraints help to sort out the format and samplerate combinations that do not properly work on a specific HW.
Jyri Sarha (2):
ASoC: simple-card: Remove trailing whitespace
ASoC: simple-card: Add support for samplerate and samplewidth
constraints
.../devicetree/bindings/sound/simple-card.txt | 6 ++ sound/soc/generic/simple-card.c | 89 +++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-)
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 ASoC: simple-card: Remove trailing whitespace
--- sound/soc/generic/simple-card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/generic/simple-card.c +1 -1
@@ -50,7 +50,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream) ret =clk_prepare_enable (dai_props->cpu_dai.clk);if (ret)return ret; - + ret =clk_prepare_enable (dai_props->codec_dai.clk);if (ret)clk_disable_unprepare (dai_props->cpu_dai.clk);
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): c7817be105a96bcbf71202c5497982f59a45a8eb.1425303942.git.jsarha-l0cyMroinI0@public.gmane.org
Mark Brown
AppliedRe: [PATCH 1/2] ASoC: simple-card: Remove trailing whitespace
Quoted 1 line · Jyri Sarha
Signed-off-by Jyri Sarha <[email protected]>
Applied, thanks.
PATCH 2/2 ASoC: simple-card: Add support for samplerate and samplewidth constraints
In reply to a message not in the archiveAdd DT properties to dailink for setting samplerate and samplewidth constraints. The DT binding document has been updated.
--- .../devicetree/bindings/sound/simple-card.txt | 6 ++ sound/soc/generic/simple-card.c | 87 ++++++++++++++++++++++ 2 files changed, 93 insertions(+)
Documentation/devicetree/bindings/sound/simple-card.txt +6 -0
@@ -44,6 +44,10 @@ Required dai-link subnodes: Optional dai-link subnode properties: +- samplewidth-constraints : List of integers describing supported + sample widths in number of bits. +- rate-constraints : List of integers describing supported + sample samplerates in Hz. - format : CPU/CODEC common audio format. "i2s", "right_j", "left_j" , "dsp_a" "dsp_b", "ac97", "pdm", "msb", "lsb"
@@ -97,6 +101,8 @@ sound { "MIC_IN", "Microphone Jack", "Headphone Jack", "HP_OUT", "External Speaker", "LINE_OUT"; + simple-audio-card,samplewidth-constraints = <16 24 32>; + simple-audio-card,samplerate-constraints = <22050 44100 88200>; simple-audio-card,cpu { sound-dai = <&sh_fsi2 0>;
sound/soc/generic/simple-card.c +87 -0
129 lines not on this page · raw message
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 9d01aa0d0bf48d8b41d5086a7e6c9ec08c2b9c48.1425303942.git.jsarha-l0cyMroinI0@public.gmane.org
Re: [alsa-devel] [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Hi Jyri,
Documentation/devicetree/bindings/sound/simple-card.txt Required dai-link subnodes: · line 48
Quoted 5 lines · Jyri Sarha
Optional dai-link subnode properties:
+- samplewidth-constraints : List of integers describing supported
Documentation/devicetree/bindings/sound/simple-card.txt +1
-0+ sample widths in number of bits.
There are quite a few platforms where the number of bits for valid audio bits differs from the number of bits per slot, e.g. 24 bits with 25 bit slots, or 24 bits in 32 bit slots. How would this be represented? This concept is present for the TDM case but not the simple one. -Pierre
Documentation/devicetree/bindings/sound/simple-card.txt Required dai-link subnodes: · line 52
Quoted 4 lines
+- rate-constraints : List of integers describing supported
Documentation/devicetree/bindings/sound/simple-card.txt +1
-0+ sample samplerates in Hz. - format : CPU/CODEC common audio format. "i2s", "right_j", "left_j" , "dsp_a"
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 6 lines · Pierre-Louis Bossart
Hi Jyri,
Quoted 3 lines · Jyri Sarha
Optional dai-link subnode properties:
Quoted 8 lines
Quoted 2 lines
+- samplewidth-constraints : List of integers describing supported + sample widths in number of bits.There are quite a few platforms where the number of bits for valid audio bits differs from the number of bits per slot, e.g. 24 bits with 25 bit slots, or 24 bits in 32 bit slots. How would this be represented? This concept is present for the TDM case but not the simple one. -Pierre
As these are dai-link level properties the idea is to set constraints to sample-width on the digital audio link, usually i2s. That is why the constraint is set based on sample-width and not physical width.
The number if significant bits in the sample-word should in a normal case be a property of the codec, if such a property is needed. On the other hand the limits for the physical layout in the system memory are usually set by the platform driver (= DMA HW), so such a property should - in a normal case - go to cpu-dai node. Since these cases can usually be associated to either end of the link, there should be no need for such properties in the machine driver.
I am not sure what you have in mind with the TDM case. In some cases a similar constraint property for number of channels could help.
Best regards,
Jyri
Quoted 6 lines
Quoted 5 lines
+- rate-constraints : List of integers describing supported + sample samplerates in Hz. - format : CPU/CODEC common audio format. "i2s", "right_j", "left_j" , "dsp_a"
Re: [alsa-devel] [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
In reply to a message not in the archiveQuoted 2 lines · Jyri Sarha
Add DT properties to dailink for setting samplerate and samplewidth constraints. The DT binding document has been updated.
Can you include a description why this is needed and how and when it is supposed to be used? --
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 6 lines · Lars-Peter Clausen
Quoted 2 lines · Jyri Sarha
Add DT properties to dailink for setting samplerate and samplewidth constraints. The DT binding document has been updated.
Can you include a description why this is needed and how and when it is supposed to be used?
Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks. With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.
The McASP driver could try to set the constraints automatically. However, since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such compromises automatically does not usually work that well.
In our case these properties could of course be added to McASP driver, but then again I would expect that there is a wider need for this kind of functionality. And it may not always be clear if either end of the link alone is responsible for less than perfect operation.
Best regards,
Jyri
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [alsa-devel] [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 10 lines · Jyri Sarha
Quoted 2 lines · Lars-Peter Clausen
Can you include a description why this is needed and how and when it is supposed to be used?
Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------
Not entirely...
Quoted 9 lines
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks. With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.
The McASP driver could try to set the constraints automatically. However, since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such compromises automatically does not usually work that well.
...this is more the point. Perhaps the constraints language needs improvement here?
Quoted 4 lines
In our case these properties could of course be added to McASP driver, but then again I would expect that there is a wider need for this kind of functionality. And it may not always be clear if either end of the link alone is responsible for less than perfect operation.
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [alsa-devel] [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 19 lines · Mark Brown
Quoted 10 lines · Jyri Sarha
Quoted 2 lines · Lars-Peter Clausen
Can you include a description why this is needed and how and when it is supposed to be used?
Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------Not entirely...
Quoted 4 lines
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks. With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.
Quoted 8 lines
Quoted 4 lines
The McASP driver could try to set the constraints automatically. However, since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such compromises automatically does not usually work that well.
...this is more the point. Perhaps the constraints language needs improvement here?
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
Quoted 11 lines
Quoted 4 lines
In our case these properties could of course be added to McASP driver, but then again I would expect that there is a wider need for this kind of functionality. And it may not always be clear if either end of the link alone is responsible for less than perfect operation.
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
I agree with that. However, the simple-card binding goes already now quite a bit beyond just describing the hardware. The binding for instance decides the configuration that is going to be used over the dai-link. These constraints could be seen as an extension to that configuration.
I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for each setup.
But about this patch. Should I just give it up, or would you be willing to apply it if I improve the description more and add a warning against using these properties to work around driver bugs to the binding document?
Best regards,
Jyri
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 25 lines · Jyri Sarha
Quoted 24 lines · Mark Brown
Quoted 10 lines · Jyri Sarha
Quoted 2 lines · Lars-Peter Clausen
Can you include a description why this is needed and how and when it is supposed to be used?
Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------Not entirely...
Quoted 9 lines
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks. With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.
The McASP driver could try to set the constraints automatically. However, since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such compromises automatically does not usually work that well.
Quoted 7 lines
Quoted 3 lines
...this is more the point. Perhaps the constraints language needs improvement here?
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
Restricting the available sample formats based on the sample rate and vice versa is possible with the current constraint framework. Take a look at what Peter Rosin recently did to the pcm512x driver. Your restrictions sound very similar to what he did.
Quoted 18 lines
Quoted 6 lines
Quoted 5 lines
In our case these properties could of course be added to McASP driver, but then again I would expect that there is a wider need for this kind of functionality. And it may not always be clear if either end of the link alone is responsible for less than perfect operation.
Quoted 6 lines
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
I agree with that. However, the simple-card binding goes already now quite a bit beyond just describing the hardware. The binding for instance decides the configuration that is going to be used over the dai-link. These constraints could be seen as an extension to that configuration.
Quoted 7 lines
I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for each setup.
But about this patch. Should I just give it up, or would you be willing to apply it if I improve the description more and add a warning against using these properties to work around driver bugs to the binding document?
Well, your description is basically saying that you want to use this to work around a driver bug, so...
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 33 lines · Lars-Peter Clausen
Quoted 32 lines · Jyri Sarha
Quoted 30 lines · Mark Brown
Quoted 11 lines · Jyri Sarha
Quoted 3 lines · Lars-Peter Clausen
Can you include a description why this is needed and how and when it is
supposed to be used?Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------Not entirely...
Quoted 11 lines
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks.
With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.The McASP driver could try to set the constraints automatically. However,
since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such compromises automatically does not usually work that well....this is more the point. Perhaps the constraints language needs improvement here?
Quoted 9 lines
Quoted 3 lines
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
Restricting the available sample formats based on the sample rate and vice versa is possible with the current constraint framework. Take a look at what Peter Rosin recently did to the pcm512x driver. Your restrictions sound very similar to what he did.
Interesting. It indeed looks like the rule functionality could do what I want. I'll look into than. Thanks!
Quoted 25 lines
Quoted 25 lines
Quoted 7 lines
Quoted 6 lines
In our case these properties could of course be added to McASP driver, but
then again I would expect that there is a wider need for this kind of functionality. And it may not always be clear if either end of the link alone is responsible for less than perfect operation.Quoted 6 lines
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
I agree with that. However, the simple-card binding goes already now quite a
bit beyond just describing the hardware. The binding for instance decides the configuration that is going to be used over the dai-link. These constraints could be seen as an extension to that configuration.I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for
each setup.
Quoted 8 lines
Quoted 5 lines
But about this patch. Should I just give it up, or would you be willing to
apply it if I improve the description more and add a warning against using
these properties to work around driver bugs to the binding document?Well, your description is basically saying that you want to use this to work around a driver bug, so...
Calling missing feature a bug is a bit harsh, but now that it seems there is a better to deal with this, I'll look into that.
Best regards,
Jyri
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 39 lines · Jyri Sarha
Quoted 38 lines · Lars-Peter Clausen
Quoted 36 lines · Jyri Sarha
Quoted 28 lines · Mark Brown
Quoted 11 lines · Jyri Sarha
Quoted 3 lines · Lars-Peter Clausen
Can you include a description why this is needed and how and when it is
supposed to be used?Would this addition do:
------------------------------------------------------------
These constraints help to disable the sample-format and sample-rate combinations that do not properly work on a specific HW.
------------------------------------------------------------Not entirely...
Quoted 6 lines
The reason why we need these is coming from limitations in McASP clock generation. With a simple divider one can only produce certain bit-clocks.
With those bit-clocks we can only play/capture some sample-rate and sample-width combinations accurately.Quoted 6 lines
The McASP driver could try to set the constraints automatically. However,
since the constraint code can not select sample-width and sample-rate combinations there is a compromise to be made between them. Making such
compromises automatically does not usually work that well.Quoted 3 lines
...this is more the point. Perhaps the constraints language needs improvement here?
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
Quoted 9 lines
Quoted 5 lines
Restricting the available sample formats based on the sample rate and vice versa is possible with the current constraint framework. Take a look at what Peter Rosin recently did to the pcm512x driver. Your restrictions sound very similar to what he did.
Interesting. It indeed looks like the rule functionality could do what I want. I'll look into than. Thanks!
I went ahead and implemented in mcasp driver a similar rule to the one already found from pcm512x. The rule indeed forbids the sample-rate and fame-size combinations that can not be played accurately.
However, once a user tries to play a bad sample-rate and fame-size combination, aplay greets him with:
aplay: pcm_params.c:170: snd1_pcm_hw_param_get_min: Assertion `!snd_interval_empty(i)' failed.
And even worse, playing to plughw gives the same error. So in practice the rule is pretty useless. The user is in the same situation as before: His use-case does not work and he has no idea why.
I guess in the long run the ideal solution would making the user-space behave better in such a situation, but for now I thing a human selected constraints are the only proper way to solve the problem.
Putting the constraints into dts may not be the most elegant choice, so I look into adding a new compatible match for each new card and hard code the DAI-link configurations for each match in the code instead of dts.
I'll send the rule patch too (as soon as I have it cleaned it up) as it does hurt to have it, even if it is not enough to make all the configurations properly usable.
Best regards,
Jyri
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
In reply to Jyri SarhaQuoted 8 lines · Jyri Sarha
Quoted 2 lines · Mark Brown
...this is more the point. Perhaps the constraints language needs improvement here?
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
It's probably worth putting together a description of the constraint and asking people like Takashi who understand the code - ideally it'd be easy to implement but I suspect you're right about timescales.
Quoted 11 lines
Quoted 5 lines
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
I agree with that. However, the simple-card binding goes already now quite a bit beyond just describing the hardware. The binding for instance decides the configuration that is going to be used over the dai-link. These constraints could be seen as an extension to that configuration.
Quoted 7 lines
I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for each setup.
But about this patch. Should I just give it up, or would you be willing to apply it if I improve the description more and add a warning against using these properties to work around driver bugs to the binding document?
I'm not totally against the idea so it's worth continuing. Just not happy either but computer.
It just occurred to me that we may be able to sidestep the issue by calling them "suggested rates/widths" so the implementation can ignore them later. That's a *tiny* bit gross but does sidestep the ABI issues.
Re: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 6 lines · Mark Brown
Quoted 4 lines · Jyri Sarha
Quoted 2 lines · Mark Brown
...this is more the point. Perhaps the constraints language needs improvement here?
Quoted 8 lines
Quoted 3 lines
Improving constraint functionality would certainly help, however the way that code works is beyond my understanding and I do not believe such an improvement would be coming from anybody else any time soon either.
It's probably worth putting together a description of the constraint and asking people like Takashi who understand the code - ideally it'd be easy to implement but I suspect you're right about timescales.
Now that Lars-Peter pointed me to the right direction, it seems there is a proper way to deal with issue after all.
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
The trouble with this sort of interface is that it's a quick and dirty way for people to bodge around things rather than actually fixing them properly. Of course sometimes fixing things properly is really hard and that means we want a temporary bodge but having to put them in DT is really unfortunate.
Quoted 9 lines
Quoted 8 lines
I agree with that. However, the simple-card binding goes already now quite a bit beyond just describing the hardware. The binding for instance decides the configuration that is going to be used over the dai-link. These constraints could be seen as an extension to that configuration.
I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for each setup.
Continuing this tought. I wonder if it would be better to introduce a new compatible match for each new card, with some clever way to manage the accumulating matches in the code, and hard code DAI-link configurations for each match. This way the old configurations would not be carved to stone in the old dtbs.
Quoted 11 lines
Quoted 3 lines
But about this patch. Should I just give it up, or would you be willing to apply it if I improve the description more and add a warning against using these properties to work around driver bugs to the binding document?
I'm not totally against the idea so it's worth continuing. Just not happy either but computer.
It just occurred to me that we may be able to sidestep the issue by calling them "suggested rates/widths" so the implementation can ignore them later. That's a *tiny* bit gross but does sidestep the ABI issues.
As there is a proper way to deal with this, I'll look into that first. However, if there still is a need for these properties I am happy to finish the patch.
Best regards,
Jyri
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: simple-card: Add support for samplerate and samplewidth constraints
Quoted 11 lines · Jyri Sarha
Quoted 3 lines · Mark Brown
Quoted 3 lines
I am wondering if there would be some better way to select the dai-link configuration than writing it to DT or creating a custom machine driver for each setup.
Continuing this tought. I wonder if it would be better to introduce a new compatible match for each new card, with some clever way to manage the accumulating matches in the code, and hard code DAI-link configurations for each match. This way the old configurations would not be carved to stone in the old dtbs.
I would prefer that, yes - if only for override capability.
Quoted 3 lines
As there is a proper way to deal with this, I'll look into that first. However, if there still is a need for these properties I am happy to finish the patch.
OK, a proper fix is of course better. Might be worth looking at tooling to make it easier to find/use but IIRC there's not a lot doing there.