dai_name = codec->stream[dir].dai_name;
- mutex_lock(&module->lock);
module_state = module->ctrlstate[dir];
if (module_state == GBAUDIO_CODEC_SHUTDOWN) {
dev_dbg(codec->dev, "%s: module already configured\n",
module->ctrlstate[dir] = GBAUDIO_CODEC_SHUTDOWN;
func_exit:
- mutex_unlock(&module->lock);
mutex_unlock(&codec->lock);
return ret;
}
rate = codec->stream[dir].rate;
sig_bits = codec->stream[dir].sig_bits;
- mutex_lock(&module->lock);
module_state = module->ctrlstate[dir];
if (module_state == codec_state) {
dev_dbg(codec->dev, "%s: module already configured\n",
func_exit:
module->ctrlstate[dir] = module_state;
- mutex_unlock(&module->lock);
mutex_unlock(&codec->lock);
return ret;
}
state = codec->stream[substream->stream].state;
list_for_each_entry(module, &codec->module_list, list) {
- mutex_lock(&module->lock);
- if (!module->is_connected) {
- mutex_unlock(&module->lock);
- continue;
- }
-
/* find the dai */
data = find_data(module, dai->name);
if (!data) {
dev_err(dai->dev, "%s:%s DATA connection missing\n",
dai->name, module->name);
- mutex_unlock(&module->lock);
continue;
}
break;
default:
dev_err(dai->dev, "Inavlid stream\n");
- mutex_unlock(&module->lock);
mutex_unlock(&codec->lock);
return -EINVAL;
}
state = GBAUDIO_CODEC_STARTUP;
module->ctrlstate[substream->stream] = state;
dev_dbg(dai->dev, "%s: state:%d\n", module->name, state);
- mutex_unlock(&module->lock);
}
codec->stream[substream->stream].state = state;
codec->stream[substream->stream].dai_name = dai->name;
state = codec->stream[substream->stream].state;
list_for_each_entry(module, &codec->module_list, list) {
- mutex_lock(&module->lock);
- if (!module->is_connected) {
- dev_err(dai->dev, "%s:%s module not connected\n",
- __func__, module->name);
- mutex_unlock(&module->lock);
- continue;
- }
/* find the dai */
data = find_data(module, dai->name);
if (!data) {
dev_err(dai->dev, "%s:%s DATA connection missing\n",
dai->name, module->name);
- mutex_unlock(&module->lock);
continue;
}
state = GBAUDIO_CODEC_SHUTDOWN;
module->ctrlstate[substream->stream] = state;
dev_dbg(dai->dev, "%s: state:%d\n", module->name, state);
- mutex_unlock(&module->lock);
}
codec->stream[substream->stream].state = state;
codec->stream[substream->stream].dai_name = NULL;
state = codec->stream[substream->stream].state;
list_for_each_entry(module, &codec->module_list, list) {
- mutex_lock(&module->lock);
- if (!module->is_connected) {
- dev_err(dai->dev, "%s:%s module not connected\n",
- __func__, module->name);
- ret = -ENODEV;
- mutex_unlock(&module->lock);
- continue;
- }
-
/* find the data connection */
data = find_data(module, dai->name);
if (!data) {
dev_err(dai->dev, "%s:%s DATA connection missing\n",
dai->name, module->name);
- mutex_unlock(&module->lock);
continue;
}
format, rate, channels, sig_bits);
if (ret) {
dev_err(dai->dev, "%d: Error during set_pcm\n", ret);
- mutex_unlock(&module->lock);
goto func_exit;
}
if (state < GBAUDIO_CODEC_HWPARAMS) {
if (ret) {
dev_err(dai->dev,
"%d: Error during set_config\n", ret);
- mutex_unlock(&module->lock);
goto func_exit;
}
}
state = GBAUDIO_CODEC_HWPARAMS;
module->ctrlstate[substream->stream] = state;
dev_dbg(dai->dev, "%s: state:%d\n", module->name, state);
- mutex_unlock(&module->lock);
}
codec->stream[substream->stream].state = state;
codec->stream[substream->stream].format = format;
state = codec->stream[substream->stream].state;
list_for_each_entry(module, &codec->module_list, list) {
- mutex_lock(&module->lock);
- if (!module->is_connected) {
- mutex_unlock(&module->lock);
- continue;
- }
-
/* find the dai */
data = find_data(module, dai->name);
if (!data) {
dev_err(dai->dev, "%s:%s DATA connection missing\n",
dai->name, module->name);
- mutex_unlock(&module->lock);
continue;
}
if (ret == -ENODEV)
continue;
if (ret) {
- mutex_unlock(&module->lock);
goto func_exit;
}
state = GBAUDIO_CODEC_PREPARE;
module->ctrlstate[substream->stream] = state;
dev_dbg(dai->dev, "%s: state:%d\n", module->name, state);
- mutex_unlock(&module->lock);
}
codec->stream[substream->stream].state = state;
}
list_for_each_entry(module, &codec->module_list, list) {
- mutex_lock(&module->lock);
- if (!module->is_connected) {
- mutex_unlock(&module->lock);
- continue;
- }
-
/* find the dai */
data = find_data(module, dai->name);
if (data)
dev_err(dai->dev, "%s:%s DATA connection missing\n",
dai->name, module->name);
ret = -ENODEV;
- mutex_unlock(&module->lock);
goto func_exit;
}
if (start && tx) {
if (ret)
dev_err(dai->dev, "%s:Error during %s stream:%d\n",
module->name, start ? "Start" : "Stop", ret);
- mutex_unlock(&module->lock);
func_exit:
mutex_unlock(&codec->lock);
down_write(&card->controls_rwsem);
mutex_lock(&gbcodec->lock);
dev_dbg(codec->dev, "Process Unregister %s module\n", module->name);
- mutex_lock(&module->lock);
#ifdef CONFIG_SND_JACK
/* free jack devices for this module from codec->jack_list */
gbaudio_codec_cleanup(module);
- module->is_connected = 0;
if (module->dapm_routes) {
dev_dbg(codec->dev, "Removing %d routes\n",
module->num_dapm_routes);
module->num_dapm_widgets);
}
- mutex_unlock(&module->lock);
-
list_del(&module->list);
dev_dbg(codec->dev, "Unregistered %s module\n", module->name);
dev_warn(module->dev, "Jack Event received: type: %u, event: %u\n",
req->jack_attribute, req->event);
- mutex_lock(&module->lock);
if (req->event == GB_AUDIO_JACK_EVENT_REMOVAL) {
module->jack_type = 0;
button_status = module->button_status;
module->button_status = 0;
- mutex_unlock(&module->lock);
if (button_status)
snd_soc_jack_report(&module->button_jack, 0,
GBCODEC_JACK_BUTTON_MASK);
module->jack_type, report);
module->jack_type = report;
- mutex_unlock(&module->lock);
snd_soc_jack_report(&module->headset_jack, report, GBCODEC_JACK_MASK);
return 0;
req->button_id, req->event);
/* currently supports 4 buttons only */
- mutex_lock(&module->lock);
if (!module->jack_type) {
dev_err(module->dev, "Jack not present. Bogus event!!\n");
- mutex_unlock(&module->lock);
return -EINVAL;
}
module->button_status = report;
- mutex_unlock(&module->lock);
-
snd_soc_jack_report(&module->button_jack, report,
GBCODEC_JACK_BUTTON_MASK);
return -ENOMEM;
gbmodule->num_data_connections = bundle->num_cports - 1;
- mutex_init(&gbmodule->lock);
INIT_LIST_HEAD(&gbmodule->data_list);
INIT_LIST_HEAD(&gbmodule->widget_list);
INIT_LIST_HEAD(&gbmodule->ctl_list);
if (ret)
goto disable_data_connection;
}
- gbmodule->is_connected = 1;
/* inform above layer for uevent */
dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);