static struct gbaudio_codec_info *gbcodec;
static struct gbaudio_data_connection *
-find_data(struct gbaudio_module_info *module, const char *name)
+find_data(struct gbaudio_module_info *module, int id)
{
struct gbaudio_data_connection *data;
list_for_each_entry(data, &module->data_list, list) {
- if (name && !strncmp(data->name, name, NAME_SIZE))
+ if (id == data->id)
return data;
}
return NULL;
}
static int gbaudio_module_enable_tx(struct gbaudio_codec_info *codec,
- struct gbaudio_module_info *module)
+ struct gbaudio_module_info *module, int id)
{
int module_state, ret = 0;
uint16_t data_cport, i2s_port, cportid;
module_state = module->ctrlstate[SNDRV_PCM_STREAM_PLAYBACK];
/* find the dai */
- data = find_data(module, dai_name);
+ data = find_data(module, id);
if (!data) {
- dev_err(module->dev, "%s:DATA connection missing\n", dai_name);
+ dev_err(module->dev, "%d:DATA connection missing\n", id);
return -ENODEV;
}
return 0;
}
-static int gbaudio_module_disable_tx(struct gbaudio_codec_info *codec,
- struct gbaudio_module_info *module)
+static int gbaudio_module_disable_tx(struct gbaudio_module_info *module, int id)
{
int ret;
uint16_t data_cport, cportid, i2s_port;
int module_state;
struct gbaudio_data_connection *data;
- const char *dai_name;
- dai_name = codec->stream[SNDRV_PCM_STREAM_PLAYBACK].dai_name;
module_state = module->ctrlstate[SNDRV_PCM_STREAM_PLAYBACK];
if (module_state == GBAUDIO_CODEC_SHUTDOWN) {
}
/* find the dai */
- data = find_data(module, dai_name);
+ data = find_data(module, id);
if (!data) {
- dev_err(module->dev, "%s:DATA connection missing\n", dai_name);
+ dev_err(module->dev, "%d:DATA connection missing\n", id);
return -ENODEV;
}
"deactivate_tx failed:%d\n", ret);
return ret;
}
- dev_dbg(module->dev, "Dynamic deactivate %s:%d DAI\n", dai_name,
- data_cport);
+ dev_dbg(module->dev, "Dynamic deactivate %d DAI\n", data_cport);
module->ctrlstate[SNDRV_PCM_STREAM_PLAYBACK] =
GBAUDIO_CODEC_HWPARAMS;
}
ret);
return ret;
}
- dev_dbg(module->dev, "Dynamic Unregister %s:%d DAI\n", dai_name,
- cportid);
+ dev_dbg(module->dev, "Dynamic Unregister %d DAI\n", cportid);
module->ctrlstate[SNDRV_PCM_STREAM_PLAYBACK] =
GBAUDIO_CODEC_SHUTDOWN;
}
}
static int gbaudio_module_enable_rx(struct gbaudio_codec_info *codec,
- struct gbaudio_module_info *module)
+ struct gbaudio_module_info *module, int id)
{
int module_state, ret = 0;
uint16_t data_cport, i2s_port, cportid;
module_state = module->ctrlstate[SNDRV_PCM_STREAM_CAPTURE];
/* find the dai */
- data = find_data(module, dai_name);
+ data = find_data(module, id);
if (!data) {
- dev_err(module->dev, "%s:DATA connection missing\n", dai_name);
+ dev_err(module->dev, "%d:DATA connection missing\n", id);
return -ENODEV;
}
return 0;
}
-static int gbaudio_module_disable_rx(struct gbaudio_codec_info *codec,
- struct gbaudio_module_info *module)
+static int gbaudio_module_disable_rx(struct gbaudio_module_info *module, int id)
{
int ret;
uint16_t data_cport, cportid, i2s_port;
int module_state;
struct gbaudio_data_connection *data;
- const char *dai_name;
- dai_name = codec->stream[SNDRV_PCM_STREAM_CAPTURE].dai_name;
module_state = module->ctrlstate[SNDRV_PCM_STREAM_CAPTURE];
if (module_state == GBAUDIO_CODEC_SHUTDOWN) {
}
/* find the dai */
- data = find_data(module, dai_name);
+ data = find_data(module, id);
if (!data) {
- dev_err(module->dev, "%s:DATA connection missing\n", dai_name);
+ dev_err(module->dev, "%d:DATA connection missing\n", id);
return -ENODEV;
}
"deactivate_rx failed:%d\n", ret);
return ret;
}
- dev_dbg(module->dev, "Dynamic deactivate %s:%d DAI\n", dai_name,
- data_cport);
+ dev_dbg(module->dev, "Dynamic deactivate %d DAI\n", data_cport);
module->ctrlstate[SNDRV_PCM_STREAM_CAPTURE] =
GBAUDIO_CODEC_HWPARAMS;
}
ret);
return ret;
}
- dev_dbg(module->dev, "Dynamic Unregister %s:%d DAI\n", dai_name,
- cportid);
+ dev_dbg(module->dev, "Dynamic Unregister %d DAI\n", cportid);
module->ctrlstate[SNDRV_PCM_STREAM_CAPTURE] =
GBAUDIO_CODEC_SHUTDOWN;
}
struct snd_soc_dapm_widget *w,
struct gbaudio_module_info *module, int enable)
{
- int ret = 0;
- const char *w_name = w->name;
+ int dai_id, ret;
+ char intf_name[NAME_SIZE], dir[NAME_SIZE];
- dev_dbg(module->dev, "%s:Module update %s sequence\n", w_name,
+ dev_dbg(module->dev, "%s:Module update %s sequence\n", w->name,
enable ? "Enable":"Disable");
if ((w->id != snd_soc_dapm_aif_in) && (w->id != snd_soc_dapm_aif_out)){
- dev_dbg(codec->dev, "No action required for %s\n", w_name);
+ dev_dbg(codec->dev, "No action required for %s\n", w->name);
return 0;
}
+ /* parse dai_id from AIF widget's stream_name */
+ ret = sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir);
+ if (ret < 3) {
+ dev_err(codec->dev, "Error while parsing dai_id for %s\n",
+ w->name);
+ return -EINVAL;
+ }
+
mutex_lock(&codec->lock);
if (w->id == snd_soc_dapm_aif_in) {
if (enable)
- ret = gbaudio_module_enable_tx(codec, module);
+ ret = gbaudio_module_enable_tx(codec, module, dai_id);
else
- ret = gbaudio_module_disable_tx(codec, module);
+ ret = gbaudio_module_disable_tx(module, dai_id);
} else if (w->id == snd_soc_dapm_aif_out) {
if (enable)
- ret = gbaudio_module_enable_rx(codec, module);
+ ret = gbaudio_module_enable_rx(codec, module, dai_id);
else
- ret = gbaudio_module_disable_rx(codec, module);
+ ret = gbaudio_module_disable_rx(module, dai_id);
}
mutex_unlock(&codec->lock);
/* find the data connection */
list_for_each_entry(module, &codec->module_list, list) {
- data = find_data(module, dai->name);
+ data = find_data(module, dai->id);
if (data)
break;
}
list_for_each_entry(module, &codec->module_list, list) {
/* find the dai */
- data = find_data(module, dai->name);
+ data = find_data(module, dai->id);
if (data)
break;
}
list_for_each_entry(module, &codec->module_list, list) {
/* find the dai */
- data = find_data(module, dai->name);
+ data = find_data(module, dai->id);
if (data)
break;
}
dev_dbg(gbcodec->dev, "%s: removed, cleanup APBridge\n", module->name);
if (pb_state == GBAUDIO_CODEC_START) {
/* cleanup PB path, only APBridge specific */
- data = find_data(module, gbcodec->stream[0].dai_name);
+ data = find_data(module, 1);
if (!data) {
dev_err(gbcodec->dev, "%s: Missing data pointer\n",
__func__);
if (cap_state == GBAUDIO_CODEC_START) {
/* cleanup CAP path, only APBridge specific */
- data = find_data(module, gbcodec->stream[1].dai_name);
+ data = find_data(module, 1);
if (!data) {
dev_err(gbcodec->dev, "%s: Missing data pointer\n",
__func__);