Commit 094c4302 authored by Vaibhav Agarwal's avatar Vaibhav Agarwal Committed by Greg Kroah-Hartman

greybus: audio: Add I2S_RX path related settings

Capture path related settings during startup, perpare &
hwparams were earlier missing.
Signed-off-by: default avatarVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: default avatarMark Greer <mgreer@animalcreek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 64a7e2cc
...@@ -72,16 +72,27 @@ static int gbaudio_module_disable(struct gbaudio_codec_info *codec, ...@@ -72,16 +72,27 @@ static int gbaudio_module_disable(struct gbaudio_codec_info *codec,
if (!data) { if (!data) {
dev_err(codec->dev, "%s:%s DATA connection missing\n", dev_err(codec->dev, "%s:%s DATA connection missing\n",
dai_name, module->name); dai_name, module->name);
mutex_unlock(&module->lock); ret = -ENODEV;
mutex_unlock(&codec->lock); goto func_exit;
return -ENODEV;
} }
if (codec_state > GBAUDIO_CODEC_HWPARAMS) { if (codec_state > GBAUDIO_CODEC_HWPARAMS) {
data_cport = data->connection->intf_cport_id; data_cport = data->connection->intf_cport_id;
ret = gb_audio_gb_deactivate_tx(module->mgmt_connection, switch(dir) {
case SNDRV_PCM_STREAM_CAPTURE:
ret = gb_audio_gb_deactivate_rx(
module->mgmt_connection,
data_cport); data_cport);
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = gb_audio_gb_deactivate_tx(
module->mgmt_connection,
data_cport);
break;
default:
ret = -EINVAL;
}
if (ret) { if (ret) {
dev_err(codec->dev, "deactivate_tx for %s failed:%d\n", dev_err(codec->dev, "deactivate for %s failed:%d\n",
module->name, ret); module->name, ret);
goto func_exit; goto func_exit;
} }
...@@ -90,9 +101,22 @@ static int gbaudio_module_disable(struct gbaudio_codec_info *codec, ...@@ -90,9 +101,22 @@ static int gbaudio_module_disable(struct gbaudio_codec_info *codec,
} }
if (codec_state > GBAUDIO_CODEC_SHUTDOWN) { if (codec_state > GBAUDIO_CODEC_SHUTDOWN) {
cportid = data->connection->hd_cport_id; cportid = data->connection->hd_cport_id;
ret = gb_audio_apbridgea_unregister_cport(data->connection, switch(dir) {
case SNDRV_PCM_STREAM_CAPTURE:
ret = gb_audio_apbridgea_unregister_cport(
data->connection,
i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_RX);
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = gb_audio_apbridgea_unregister_cport(
data->connection,
i2s_port, cportid, i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_TX); AUDIO_APBRIDGEA_DIRECTION_TX);
break;
default:
ret = -EINVAL;
}
if (ret) { if (ret) {
dev_err(codec->dev, "unregister_cport for %s failed:%d\n", dev_err(codec->dev, "unregister_cport for %s failed:%d\n",
module->name, ret); module->name, ret);
...@@ -148,18 +172,30 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec, ...@@ -148,18 +172,30 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec,
if (!data) { if (!data) {
dev_err(codec->dev, "%s:%s DATA connection missing\n", dev_err(codec->dev, "%s:%s DATA connection missing\n",
dai_name, module->name); dai_name, module->name);
mutex_unlock(&module->lock); ret = -ENODEV;
mutex_unlock(&codec->lock); goto func_exit;
return -ENODEV;
} }
/* register cport */ /* register cport */
if (module_state < codec_state) { if (module_state < codec_state) {
i2s_port = 0; /* fixed for now */ i2s_port = 0; /* fixed for now */
cportid = data->connection->hd_cport_id; cportid = data->connection->hd_cport_id;
ret = gb_audio_apbridgea_register_cport(data->connection, switch(dir) {
case SNDRV_PCM_STREAM_CAPTURE:
ret = gb_audio_apbridgea_register_cport(
data->connection,
i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_RX);
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = gb_audio_apbridgea_register_cport(
data->connection,
i2s_port, cportid, i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_TX); AUDIO_APBRIDGEA_DIRECTION_TX);
break;
default:
ret = -EINVAL;
}
if (ret) { if (ret) {
dev_err(codec->dev, "reg_cport for %s\n", module->name); dev_err(codec->dev, "reg_cport for %s\n", module->name);
goto func_exit; goto func_exit;
...@@ -186,10 +222,32 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec, ...@@ -186,10 +222,32 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec,
/* prepare */ /* prepare */
if (module_state < codec_state) { if (module_state < codec_state) {
data_cport = data->connection->intf_cport_id; data_cport = data->connection->intf_cport_id;
ret = gb_audio_gb_set_tx_data_size(module->mgmt_connection, switch(dir) {
case SNDRV_PCM_STREAM_CAPTURE:
ret = gb_audio_gb_set_rx_data_size(
module->mgmt_connection,
data_cport, 192); data_cport, 192);
if (ret) { if (ret) {
dev_err(codec->dev, "set_tx_data_size for %s\n", dev_err(codec->dev,
"set_rx_data_size for %s\n",
module->name);
goto func_exit;
}
ret = gb_audio_gb_activate_rx(module->mgmt_connection,
data_cport);
if (ret) {
dev_err(codec->dev, "activate_rx for %s\n",
module->name);
goto func_exit;
}
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = gb_audio_gb_set_tx_data_size(
module->mgmt_connection,
data_cport, 192);
if (ret) {
dev_err(codec->dev,
"set_tx_data_size for %s\n",
module->name); module->name);
goto func_exit; goto func_exit;
} }
...@@ -200,6 +258,12 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec, ...@@ -200,6 +258,12 @@ static int gbaudio_module_enable(struct gbaudio_codec_info *codec,
module->name); module->name);
goto func_exit; goto func_exit;
} }
break;
default:
dev_err(codec->dev, "Inavlid stream direction\n");
ret = -EINVAL;
goto func_exit;
}
module_state = GBAUDIO_CODEC_PREPARE; module_state = GBAUDIO_CODEC_PREPARE;
dev_dbg(codec->dev, "Dynamic prepare %s:%d DAI\n", dai_name, dev_dbg(codec->dev, "Dynamic prepare %s:%d DAI\n", dai_name,
data_cport); data_cport);
...@@ -217,7 +281,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec, ...@@ -217,7 +281,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
struct gbaudio_module_info *module, int enable) struct gbaudio_module_info *module, int enable)
{ {
int stream, ret = 0; int stream, ret = 0;
int pb_state; int pb_state, cap_state;
dev_dbg(module->dev, "Module update %s sequence\n", dev_dbg(module->dev, "Module update %s sequence\n",
enable ? "Enable":"Disable"); enable ? "Enable":"Disable");
...@@ -239,12 +303,16 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec, ...@@ -239,12 +303,16 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
SNDRV_PCM_STREAM_PLAYBACK); SNDRV_PCM_STREAM_PLAYBACK);
} }
/* TBD /* check if capture active */
* check if capture active cap_state = codec->stream[SNDRV_PCM_STREAM_CAPTURE].state;
* cap_state = codec->stream[SNDRV_PCM_STREAM_CAPTURE].state; if ((stream & GB_CAPTURE) && (cap_state > GBAUDIO_CODEC_SHUTDOWN)) {
* if ((stream & GB_CAPTURE) && (cap_state > GBAUDIO_CODEC_SHUTDOWN)) if (enable)
* ret = gbaudio_module_enable(codec, module,
*/ SNDRV_PCM_STREAM_CAPTURE);
else
ret = gbaudio_module_disable(codec, module,
SNDRV_PCM_STREAM_CAPTURE);
}
return ret; return ret;
} }
...@@ -291,9 +359,25 @@ static int gbcodec_startup(struct snd_pcm_substream *substream, ...@@ -291,9 +359,25 @@ static int gbcodec_startup(struct snd_pcm_substream *substream,
/* register cport */ /* register cport */
i2s_port = 0; /* fixed for now */ i2s_port = 0; /* fixed for now */
cportid = data->connection->hd_cport_id; cportid = data->connection->hd_cport_id;
ret = gb_audio_apbridgea_register_cport(data->connection, switch (substream->stream) {
case SNDRV_PCM_STREAM_CAPTURE:
ret = gb_audio_apbridgea_register_cport(
data->connection,
i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_RX);
break;
case SNDRV_PCM_STREAM_PLAYBACK:
ret = gb_audio_apbridgea_register_cport(
data->connection,
i2s_port, cportid, i2s_port, cportid,
AUDIO_APBRIDGEA_DIRECTION_TX); AUDIO_APBRIDGEA_DIRECTION_TX);
break;
default:
dev_err(dai->dev, "Inavlid stream\n");
mutex_unlock(&module->lock);
mutex_unlock(&codec->lock);
return -EINVAL;
}
dev_dbg(dai->dev, "Register %s:%d DAI, ret:%d\n", dai->name, dev_dbg(dai->dev, "Register %s:%d DAI, ret:%d\n", dai->name,
cportid, ret); cportid, ret);
state = GBAUDIO_CODEC_STARTUP; state = GBAUDIO_CODEC_STARTUP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment