Repository navigation
[DNM (for v1.8-rc2) ] CA: cadence: update stream params during config apply #4008
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 |
|---|---|---|
|
|
@@ -144,11 +144,75 @@ int cadence_codec_init(struct comp_dev *dev) | |
| obj_size); | ||
| } | ||
|
|
||
| /* Assign stream params IDs */ | ||
| switch (api_id) { | ||
| #ifdef CONFIG_CADENCE_CODEC_AAC_DEC | ||
| case CADENCE_CODEC_AAC_DEC_ID: | ||
| cd->sample_rate_id = XA_AACDEC_CONFIG_PARAM_AAC_SAMPLERATE; | ||
| cd->sample_width_id = XA_AACDEC_CONFIG_PARAM_PCM_WDSZ; | ||
| cd->channels_id = XA_AACDEC_CONFIG_PARAM_NUM_CHANNELS; | ||
| break; | ||
| #endif | ||
| #ifdef CONFIG_CADENCE_CODEC_MP3_DEC | ||
| case CADENCE_CODEC_MP3_DEC_ID: | ||
| cd->sample_rate_id = XA_MP3DEC_CONFIG_PARAM_SAMP_FREQ; | ||
| cd->sample_width_id = XA_MP3DEC_CONFIG_PARAM_PCM_WDSZ; | ||
| cd->channels_id = XA_MP3DEC_CONFIG_PARAM_NUM_CHANNELS; | ||
| break; | ||
| #endif | ||
| default: | ||
| cd->sample_rate_id = CADENCE_SAMPLE_RATE_ID; | ||
| cd->sample_width_id = CADENCE_SAMPLE_WIDTH_ID; | ||
| cd->channels_id = CADENCE_CHANNELS_COUNT_ID; | ||
| break; | ||
| } | ||
|
|
||
| comp_dbg(dev, "cadence_codec_init() done"); | ||
| out: | ||
| return ret; | ||
| } | ||
|
|
||
| static int update_stream_params(struct comp_dev *dev) | ||
| { | ||
| int ret = 0; | ||
|
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. IIRC |
||
| struct comp_data *ca_data = comp_get_drvdata(dev); | ||
| struct codec_data *codec = comp_get_codec(dev); | ||
| struct cadence_codec_data *cd = codec->private; | ||
| struct sof_ipc_stream_params *stream = &ca_data->stream_params; | ||
| /* copy stream params localy to ensure container size is correct */ | ||
| uint32_t sample_width = (stream->frame_fmt == SOF_IPC_FRAME_S16_LE) ? 0x10 : 0x20; | ||
|
mrajwa marked this conversation as resolved.
Outdated
|
||
| uint32_t sample_rate = stream->rate; | ||
| uint32_t channels = stream->channels; | ||
|
|
||
| comp_err(dev, "update_stream_params() start"); | ||
|
|
||
|
mrajwa marked this conversation as resolved.
Outdated
|
||
| /* update stream parameters */ | ||
| /* sample rate */ | ||
| API_CALL(cd, XA_API_CMD_SET_CONFIG_PARAM, cd->sample_rate_id, | ||
| &sample_rate, ret); | ||
|
paulstelian97 marked this conversation as resolved.
Outdated
|
||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "update_stream_params(): failed to set sample rate."); | ||
| goto err; | ||
| } | ||
| /* sample width */ | ||
| API_CALL(cd, XA_API_CMD_SET_CONFIG_PARAM, cd->sample_width_id, | ||
| &sample_width, ret); | ||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "update_stream_params(): failed to set sample width."); | ||
| goto err; | ||
| } | ||
|
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. Here only print a warning if there is an error but do not return err from this function. |
||
| /* number of channels */ | ||
| API_CALL(cd, XA_API_CMD_SET_CONFIG_PARAM, cd->channels_id, | ||
| &channels, ret); | ||
| if (LIB_IS_FATAL_ERROR(ret)) { | ||
| comp_err(dev, "update_stream_params(): failed to set channel count."); | ||
| goto err; | ||
| } | ||
| err: | ||
| comp_err(dev, "update_stream_params() done, returned %d", ret); | ||
| return ret; | ||
| } | ||
|
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. If we get here I think we should
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, I have just updated, I think this new way of handling update_stream_params() will cover fatal & non-fatal cases.
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. @dbaluta is this resolved, sorry I cant tell from the diff. |
||
|
|
||
| static int apply_config(struct comp_dev *dev, enum codec_cfg_type type) | ||
| { | ||
| int ret = 0; | ||
|
|
@@ -405,6 +469,13 @@ int cadence_codec_prepare(struct comp_dev *dev) | |
| */ | ||
| codec->s_cfg.avail = false; | ||
|
|
||
| /* Update codec config with stream parameters */ | ||
| ret = update_stream_params(dev); | ||
| if (ret) { | ||
| comp_err(dev, "cadence_codec_prepare() error %x: failed to update stream params", | ||
| ret); | ||
| goto err; | ||
| } | ||
| /* Allocate memory for the codec */ | ||
| API_CALL(cd, XA_API_CMD_GET_MEMTABS_SIZE, 0, &mem_tabs_size, ret); | ||
| if (ret != LIB_NO_ERROR) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,13 +36,24 @@ struct cadence_api { | |
| xa_codec_func_t *api; | ||
| }; | ||
|
|
||
| enum default_stream_params_ids { | ||
| CADENCE_SAMPLE_RATE_ID = 0x01, | ||
| CADENCE_SAMPLE_WIDTH_ID = 0x02, | ||
| CADENCE_CHANNELS_COUNT_ID = 0x04 | ||
|
dbaluta marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
|
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. Here we need a semicolon: |
||
| struct cadence_codec_data { | ||
| char name[LIB_NAME_MAX_LEN]; | ||
| void *self; | ||
| xa_codec_func_t *api; | ||
| void *mem_tabs; | ||
| uint32_t sample_width_id; | ||
| uint32_t sample_rate_id; | ||
| uint32_t channels_id; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| /*****************************************************************************/ | ||
|
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. remove the new lines from here. Also, add the following changes: I will add a PR with these changes later if you want. |
||
| /* Cadence interfaces */ | ||
| /*****************************************************************************/ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.