mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
ASoC: tegra-alt: clean APM methods and structures
- Combine read & write position into one method - Define & use separate macro for pin type - Use set_position for sending notifications from ADSP to CPU - Use set_eos for sending EOS reached from ADSP to CPU Change-Id: I7df817a8e82a3564380ce712fbab202f0bee9551 Signed-off-by: Viraj Karandikar <vkarandikar@nvidia.com> Reviewed-on: http://git-master/r/428915 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com> Reviewed-by: Stephen Holmes <sholmes@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
Sameer Pujar
parent
57466bf754
commit
ca169a7687
@@ -287,7 +287,11 @@ static int tegra210_adsp_init(struct tegra210_adsp *adsp)
|
|||||||
dev_err(adsp->dev, "Failed to load OS.");
|
dev_err(adsp->dev, "Failed to load OS.");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
nvadsp_os_start();
|
|
||||||
|
if (nvadsp_os_start()) {
|
||||||
|
dev_err(adsp->dev, "Failed to start OS");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load ADSP audio apps */
|
/* Load ADSP audio apps */
|
||||||
for (i = 0; i < ARRAY_SIZE(adsp_app_desc); i++) {
|
for (i = 0; i < ARRAY_SIZE(adsp_app_desc); i++) {
|
||||||
@@ -370,15 +374,11 @@ static int tegra210_adsp_send_connect_msg(struct tegra210_adsp_app *src,
|
|||||||
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_fx_connect_params_t);
|
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_fx_connect_params_t);
|
||||||
apm_msg.msg.call_params.size = sizeof(apm_fx_connect_params_t);
|
apm_msg.msg.call_params.size = sizeof(apm_fx_connect_params_t);
|
||||||
apm_msg.msg.call_params.method = nvfx_apm_method_fx_connect;
|
apm_msg.msg.call_params.method = nvfx_apm_method_fx_connect;
|
||||||
apm_msg.msg.fx_connect_params.plugin_src.pvoid =
|
apm_msg.msg.fx_connect_params.plugin_src.pvoid = IS_APM_IN(src->reg) ?
|
||||||
src->plugin->plugin.pvoid;
|
NULL : src->plugin->plugin.pvoid;
|
||||||
apm_msg.msg.fx_connect_params.port_src =
|
|
||||||
IS_APM(src->reg) ? NVFX_TYPE_IN_PORT : NVFX_TYPE_OUT_PORT;
|
|
||||||
apm_msg.msg.fx_connect_params.pin_src = 0;
|
apm_msg.msg.fx_connect_params.pin_src = 0;
|
||||||
apm_msg.msg.fx_connect_params.plugin_dst.pvoid =
|
apm_msg.msg.fx_connect_params.plugin_dst.pvoid = IS_APM_OUT(dst->reg) ?
|
||||||
dst->plugin->plugin.pvoid;
|
NULL : dst->plugin->plugin.pvoid;
|
||||||
apm_msg.msg.fx_connect_params.port_dst =
|
|
||||||
IS_APM(dst->reg) ? NVFX_TYPE_OUT_PORT : NVFX_TYPE_IN_PORT;
|
|
||||||
apm_msg.msg.fx_connect_params.pin_dst = 0;
|
apm_msg.msg.fx_connect_params.pin_dst = 0;
|
||||||
|
|
||||||
return tegra210_adsp_send_msg(src->apm, &apm_msg, flags);
|
return tegra210_adsp_send_msg(src->apm, &apm_msg, flags);
|
||||||
@@ -390,11 +390,11 @@ static int tegra210_adsp_send_io_buffer_msg(struct tegra210_adsp_app *app,
|
|||||||
{
|
{
|
||||||
apm_msg_t apm_msg;
|
apm_msg_t apm_msg;
|
||||||
|
|
||||||
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_set_io_buffer_params_t);
|
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_io_buffer_params_t);
|
||||||
apm_msg.msg.call_params.size = sizeof(apm_set_io_buffer_params_t);
|
apm_msg.msg.call_params.size = sizeof(apm_io_buffer_params_t);
|
||||||
apm_msg.msg.call_params.method = nvfx_apm_method_set_io_buffer;
|
apm_msg.msg.call_params.method = nvfx_apm_method_set_io_buffer;
|
||||||
apm_msg.msg.io_buffer_params.pin_type =
|
apm_msg.msg.io_buffer_params.pin_type = IS_APM_IN(app->reg) ?
|
||||||
IS_APM_IN(app->reg) ? NVFX_TYPE_IN_PORT : NVFX_TYPE_OUT_PORT;
|
NVFX_PIN_TYPE_INPUT : NVFX_PIN_TYPE_OUTPUT;
|
||||||
apm_msg.msg.io_buffer_params.pin_id = 0;
|
apm_msg.msg.io_buffer_params.pin_id = 0;
|
||||||
apm_msg.msg.io_buffer_params.addr = (variant_t)addr;
|
apm_msg.msg.io_buffer_params.addr = (variant_t)addr;
|
||||||
apm_msg.msg.io_buffer_params.size = size;
|
apm_msg.msg.io_buffer_params.size = size;
|
||||||
@@ -408,12 +408,12 @@ static int tegra210_adsp_send_period_size_msg(struct tegra210_adsp_app *app,
|
|||||||
apm_msg_t apm_msg;
|
apm_msg_t apm_msg;
|
||||||
|
|
||||||
apm_msg.msgq_msg.size =
|
apm_msg.msgq_msg.size =
|
||||||
MSGQ_MSG_SIZE(apm_set_notification_size_params_t);
|
MSGQ_MSG_SIZE(apm_notification_params_t);
|
||||||
apm_msg.msg.call_params.size =
|
apm_msg.msg.call_params.size =
|
||||||
sizeof(apm_set_notification_size_params_t);
|
sizeof(apm_notification_params_t);
|
||||||
apm_msg.msg.call_params.method = nvfx_apm_method_set_notification_size;
|
apm_msg.msg.call_params.method = nvfx_apm_method_set_notification_size;
|
||||||
apm_msg.msg.notification_params.pin_type =
|
apm_msg.msg.notification_params.pin_type = IS_APM_IN(app->reg) ?
|
||||||
IS_APM_IN(app->reg) ? NVFX_TYPE_IN_PORT : NVFX_TYPE_OUT_PORT;
|
NVFX_PIN_TYPE_INPUT : NVFX_PIN_TYPE_OUTPUT;
|
||||||
apm_msg.msg.notification_params.pin_id = 0;
|
apm_msg.msg.notification_params.pin_id = 0;
|
||||||
apm_msg.msg.notification_params.size = size;
|
apm_msg.msg.notification_params.size = size;
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ static int tegra210_adsp_send_state_msg(struct tegra210_adsp_app *app,
|
|||||||
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(nvfx_set_state_params_t);
|
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(nvfx_set_state_params_t);
|
||||||
apm_msg.msg.call_params.size = sizeof(nvfx_set_state_params_t);
|
apm_msg.msg.call_params.size = sizeof(nvfx_set_state_params_t);
|
||||||
apm_msg.msg.call_params.method = nvfx_method_set_state;
|
apm_msg.msg.call_params.method = nvfx_method_set_state;
|
||||||
apm_msg.msg.set_state_params.state = state;
|
apm_msg.msg.state_params.state = state;
|
||||||
|
|
||||||
return tegra210_adsp_send_msg(app->apm, &apm_msg, flags);
|
return tegra210_adsp_send_msg(app->apm, &apm_msg, flags);
|
||||||
}
|
}
|
||||||
@@ -470,23 +470,23 @@ static int tegra210_adsp_send_eos_msg(struct tegra210_adsp_app *app,
|
|||||||
{
|
{
|
||||||
apm_msg_t apm_msg;
|
apm_msg_t apm_msg;
|
||||||
|
|
||||||
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_set_eos_params_t);
|
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_eos_params_t);
|
||||||
apm_msg.msg.call_params.size = sizeof(apm_set_eos_params_t);
|
apm_msg.msg.call_params.size = sizeof(apm_eos_params_t);
|
||||||
apm_msg.msg.call_params.method = nvfx_apm_method_set_eos;
|
apm_msg.msg.call_params.method = nvfx_apm_method_set_eos;
|
||||||
|
|
||||||
return tegra210_adsp_send_msg(app->apm, &apm_msg, flags);
|
return tegra210_adsp_send_msg(app->apm, &apm_msg, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra210_adsp_write_pos_msg(struct tegra210_adsp_app *app,
|
static int tegra210_adsp_send_pos_msg(struct tegra210_adsp_app *app,
|
||||||
uint32_t pos, uint32_t flags)
|
uint32_t pos, uint32_t flags)
|
||||||
{
|
{
|
||||||
apm_msg_t apm_msg;
|
apm_msg_t apm_msg;
|
||||||
|
|
||||||
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_set_write_position_params_t);
|
apm_msg.msgq_msg.size = MSGQ_MSG_SIZE(apm_position_params_t);
|
||||||
apm_msg.msg.call_params.size = sizeof(apm_set_write_position_params_t);
|
apm_msg.msg.call_params.size = sizeof(apm_position_params_t);
|
||||||
apm_msg.msg.call_params.method = IS_APM_IN(app->reg) ?
|
apm_msg.msg.call_params.method = nvfx_apm_method_set_position;
|
||||||
nvfx_apm_method_set_write_position :
|
apm_msg.msg.position_params.pin_type = IS_APM_IN(app->reg) ?
|
||||||
nvfx_apm_method_set_read_position;
|
NVFX_PIN_TYPE_INPUT : NVFX_PIN_TYPE_OUTPUT;
|
||||||
apm_msg.msg.position_params.pin_id = 0;
|
apm_msg.msg.position_params.pin_id = 0;
|
||||||
apm_msg.msg.position_params.offset = pos;
|
apm_msg.msg.position_params.offset = pos;
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ static int tegra210_adsp_pcm_msg_handler(struct tegra210_adsp_app *app,
|
|||||||
struct tegra210_adsp_pcm_rtd *prtd = app->private_data;
|
struct tegra210_adsp_pcm_rtd *prtd = app->private_data;
|
||||||
|
|
||||||
switch (apm_msg->msg.call_params.method) {
|
switch (apm_msg->msg.call_params.method) {
|
||||||
case nvfx_apm_method_buffer_empty:
|
case nvfx_apm_method_set_position:
|
||||||
snd_pcm_period_elapsed(prtd->substream);
|
snd_pcm_period_elapsed(prtd->substream);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -707,10 +707,10 @@ static int tegra210_adsp_compr_msg_handler(struct tegra210_adsp_app *app,
|
|||||||
struct tegra210_adsp_compr_rtd *prtd = app->private_data;
|
struct tegra210_adsp_compr_rtd *prtd = app->private_data;
|
||||||
|
|
||||||
switch (apm_msg->msg.call_params.method) {
|
switch (apm_msg->msg.call_params.method) {
|
||||||
case nvfx_apm_method_buffer_empty:
|
case nvfx_apm_method_set_position:
|
||||||
snd_compr_fragment_elapsed(prtd->cstream);
|
snd_compr_fragment_elapsed(prtd->cstream);
|
||||||
break;
|
break;
|
||||||
case nvfx_apm_method_eos_reached: {
|
case nvfx_apm_method_set_eos: {
|
||||||
if (!prtd->is_draining) {
|
if (!prtd->is_draining) {
|
||||||
dev_warn(prtd->dev, "EOS reached before drain");
|
dev_warn(prtd->dev, "EOS reached before drain");
|
||||||
break;
|
break;
|
||||||
@@ -934,7 +934,7 @@ static int tegra210_adsp_compr_copy(struct snd_compr_stream *cstream,
|
|||||||
if (copy_from_user(prtd->buf.area, buf + copy, count - copy))
|
if (copy_from_user(prtd->buf.area, buf + copy, count - copy))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
tegra210_adsp_write_pos_msg(prtd->fe_apm,
|
tegra210_adsp_send_pos_msg(prtd->fe_apm,
|
||||||
(runtime->total_bytes_available + count) % runtime->buffer_size, 0);
|
(runtime->total_bytes_available + count) % runtime->buffer_size, 0);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@@ -1188,7 +1188,7 @@ static int tegra210_adsp_pcm_ack(struct snd_pcm_substream *substream)
|
|||||||
|
|
||||||
pos = frames_to_bytes(runtime,
|
pos = frames_to_bytes(runtime,
|
||||||
runtime->control->appl_ptr % runtime->buffer_size);
|
runtime->control->appl_ptr % runtime->buffer_size);
|
||||||
ret = tegra210_adsp_write_pos_msg(prtd->fe_apm, pos, 0);
|
ret = tegra210_adsp_send_pos_msg(prtd->fe_apm, pos, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(prtd->dev, "Failed to send write position.");
|
dev_err(prtd->dev, "Failed to send write position.");
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user