You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently if a component source buffer underruns or a component sink buffier overruns the pipeline will enter an XRUN status and attempt recovery. This is desired in most pipelines but some topologies need to support use cases where we expect buffers to underrun or overrun.
Host ---> Proc----> Selector0 --> Buf0 ---- > DAI Playback
|
v
Buf1
|
v
Host <---------------Selector1 <----- Buf2 <----- Echo Ref DAI
In the example above we two host PCMs that can be independently started/stopped thereby causing buf1 to either underrun or overrun (and stop the pipelines). Buf1 should be permmitted to underrun or overrun without invoking pipeline XRUN logic and should over write oldest data (for overrun) and readback 0s (for underrun).
Describe the solution you'd like
Add two new topology token for buffers.
Firmware should process these tokens and if set for a buffer will not invoke pipeline XRUN status.
If buffer overflows, it should overwrite oldest data.
If buffer underruns, it should read back 0s.
@lgirdwood
It will also be required in smart amp topology (#1896). I don't know whether somebody is working on it right now. If not, I can assign myself to it.
@lgirdwood Regarding implementation details for the underrun case, I can think of 2 ways of approaching the subject:
Minimal changes, mostly focused around components' copy functions (check underrun-related flag in buffer, read as much as buffer has, fill in the zeros as needed)
Far-fetched changes regarding buffer read management, so that underrun would be transparent to the components, by utilizing behaviour similar to std fread()
Now, the first approach is much easier to develop and doesn't involve any big changes to the buffer API, but it comes with quite a heavy drawback - every component has to implement buffer underrun separately. The second approach is the exact opposite.
If you have any suggestions on how to approach this, how to improve on any of the above ideas, or if you have a different one of your own, then please point me in the right direction.
@tlauda yes, hooking into the buffer API is probably the best way forward. i.e.
/* acquires lock for bytes to read - buffer will 0 bytes here if we underrun AND underrun flag is true */buffer_rlock(buffer, bytes, flags);
/* acquires lock for bytes to write - buffer wont XRUN here if we overrun AND overrun flag is true */buffer_wlock(buffer, bytes, flags);
@lgirdwood What should xrun-permitted buffers report when asked for avail/free data? (uint32_t)-1 seems 'most reasonable', but it doesn't feel comfortable, please clarify that for me.
If such buffer reported actual avail/free, client component would prevent xrunning in the first place, so such buffers need to alter their reports somehow.
How would the data itself be extracted from the buffers now? Until now it was simply by requesting a pointer for each sample from the buffer but now I feel like this approach may not work properly. Did I miss a PR which changes this logic?
/* acquires lock for bytes to read - buffer will 0 bytes here if we underrun AND underrun flag is true */buffer_rlock(buffer, bytes, flags);
/* acquires lock for bytes to write - buffer wont XRUN here if we overrun AND overrun flag is true */buffer_wlock(buffer, bytes, flags);
Meaning, that data (zeros) will be superimposed onto the buffer, and following logic - retrieving data pointer and reading is exactly the same.
Activity
lgirdwood commentedon Mar 3, 2020
Needed for #2407 and #2462
lgirdwood commentedon Mar 3, 2020
@akloniex @sebcarlucci fyi.
bkokoszx commentedon Mar 4, 2020
@lgirdwood
It will also be required in smart amp topology (#1896). I don't know whether somebody is working on it right now. If not, I can assign myself to it.
lgirdwood commentedon Mar 4, 2020
@bkokoszx can you have a chat with @akloniex - also needed for echo ref
[-][FEATURE] Allow componnets/buffers to XRUN[/-][+][FEATURE] Allow components/buffers to XRUN[/+]akloniex commentedon Mar 16, 2020
@lgirdwood Regarding implementation details for the underrun case, I can think of 2 ways of approaching the subject:
Now, the first approach is much easier to develop and doesn't involve any big changes to the buffer API, but it comes with quite a heavy drawback - every component has to implement buffer underrun separately. The second approach is the exact opposite.
If you have any suggestions on how to approach this, how to improve on any of the above ideas, or if you have a different one of your own, then please point me in the right direction.
lbetlej commentedon Mar 17, 2020
@lgirdwood @akloniex @tlauda could you follow up on idea regarding buffer reader API ?
tlauda commentedon Mar 17, 2020
@lgirdwood Is this mechanism in some way related to the improved buffer locking API you've mentioned here #2545 (comment)?
lgirdwood commentedon Mar 18, 2020
@tlauda yes, hooking into the buffer API is probably the best way forward. i.e.
akloniex commentedon Mar 26, 2020
@lgirdwood What should xrun-permitted buffers report when asked for avail/free data?
(uint32_t)-1seems 'most reasonable', but it doesn't feel comfortable, please clarify that for me.If such buffer reported actual avail/free, client component would prevent xrunning in the first place, so such buffers need to alter their reports somehow.
lgirdwood commentedon Mar 27, 2020
@akloniex I think it's appropriate to say that these buffers will report they have buffer_size free and buffer_size avail.
lgirdwood commentedon Mar 27, 2020
@akloniex in fact we probably want to be more logical here with rules.
This way we should not block existing users.
paulstelian97 commentedon Mar 27, 2020
How would the data itself be extracted from the buffers now? Until now it was simply by requesting a pointer for each sample from the buffer but now I feel like this approach may not work properly. Did I miss a PR which changes this logic?
lgirdwood commentedon Mar 27, 2020
It will us the same approach as the DMA trace buffer, i.e. oldest data is discarded
akloniex commentedon Mar 27, 2020
@paulstelian97 @lgirdwood wrote how this situation will be handled, few comments above:
Meaning, that data (zeros) will be superimposed onto the buffer, and following logic - retrieving data pointer and reading is exactly the same.
paulstelian97 commentedon Mar 27, 2020
So the buffer is modified accordingly. Okay.
cujomalainey commentedon Jul 31, 2020
This has been completed correct?
lgirdwood commentedon Aug 4, 2020
@akloniex @juimonen is this now completed ?
lgirdwood commentedon Aug 18, 2020
@bkokoszx @slawblauciak @ktrzcinx can we close this now ? I think all the parts are merged now ?
ktrzcinx commentedon Aug 18, 2020
I'have already use it, so I think it's ready
bkokoszx commentedon Aug 18, 2020
@lgirdwood
I think we can close this via #2745