Repository navigation
codec_adapter: cadence: fix reset procedure + improve prepare #4263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -444,7 +444,26 @@ int cadence_codec_prepare(struct comp_dev *dev) | |
| ret); | ||
| goto free; | ||
| } | ||
|
|
||
| /* Check init done status. Note, it may happen that init_done flag will return | ||
| * false value, this is normal since some codec variants needs input in order to | ||
| * fully finish initialization. That's why at codec_adapter_copy() we call | ||
| * codec_init_process() base on result obtained below. | ||
| */ | ||
| #ifdef CONFIG_CADENCE_CODEC_WRAPPER | ||
| /* TODO: remove the "#ifdef CONFIG_CADENCE_CODEC_WRAPPER" once cadence fixes the bug | ||
| * in the init/prepare sequence. Basically below API_CALL shall return 1 for | ||
| * PCM streams and 0 for compress ones. As it turns out currently it returns 1 | ||
| * in both cases so in turn compress stream won't finish its prepare during first copy | ||
| * in codec_adapter_copy(). | ||
| */ | ||
| API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY, | ||
| &codec->cpd.init_done, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
| comp_err(dev, "cadence_codec_init_process() error %x: failed to get lib init status", | ||
| ret); | ||
| return ret; | ||
| } | ||
| #endif | ||
| comp_dbg(dev, "cadence_codec_prepare() done"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this will work.
This will fail because at cadence_codec_prepare() time there is no data in the input buffer. Does this work for Intel DAP codec?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbaluta but do you think
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrajwa yes. Here is what DAP VLLDP Programmers Guide says: Same for mp3, aac or any other cadence codec. That's why i added the cadence_codec_init_process() call inside the copy() function
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to clarify this with cadence, namely what is the correct way of performing the reset - this is nowhere defined. I noticed INIT_PROCESS does reset the parameters by DAP lib code inspection.
Yes it works for DAP
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, i see. It doesn't work for mp3 for example. It needs to have some input data in the buffers. Care to start a thread with Cadence support?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you, for the testing purposes call the codec API with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrajwa Ack. Will get back to you when get some time for testing.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrajwa I checked with your suggestion. But no luck. The init_done is still set at 1. I checked with Cadence support team and they confirm that this happens and might be a library bug. They will forward the problem to engineering. Anyhow, what is exactly our problem to fix with this reset procedure. I'm sorry I'm still after vacation and is hard for me to navigate through the sea of emails. Can you provide a simple description of the problem we are trying to solve. On another note, I'm having a problem with second cplay run. It's always get stuck. Anyhow, if I leave enough time between 1st run and 2nd run of cplay everything works (system runtime suspend/resume get into action). Cc: @paulstelian97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds like kernel runtime PM is rebooting FW and reseting the state ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgirdwood true. |
||
| return 0; | ||
| free: | ||
|
|
@@ -504,14 +523,22 @@ int cadence_codec_apply_config(struct comp_dev *dev) | |
| int cadence_codec_reset(struct comp_dev *dev) | ||
| { | ||
| int ret; | ||
| struct codec_data *codec = comp_get_codec(dev); | ||
| struct cadence_codec_data *cd = codec->private; | ||
|
|
||
| API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, | ||
| NULL, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
| comp_err(dev, "cadence_codec_init(): error %x: failed to reset to default values.", | ||
| ret); | ||
| /* Current CADENCE API doesn't support reset of codec's | ||
| * runtime parameters therefore we need to free all the resources | ||
| * and start over. | ||
| */ | ||
| codec_free_all_memory(dev); | ||
| ret = cadence_codec_init(dev); | ||
| if (ret) { | ||
| comp_err(dev, "cadence_codec_reset() error %x: could not re-initialize codec after reset", | ||
| ret); | ||
| } | ||
|
|
||
| ret = cadence_codec_prepare(dev); | ||
| if (ret) { | ||
| comp_err(dev, "cadence_codec_reset() error %x: could not re-prepare codec after reset", | ||
| ret); | ||
| } | ||
|
|
||
| return ret; | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note unrelated to this PR: I think it would be good to switch
API_CALL()toand then do explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh not a bad idea, but I don't see a draw back from the current implementation either. It is just a mater of taste. We all know that API_CALL is a macro.
Remember
spin_lock_irqsavein the Linux kernel?