本文整理汇总了C++中MM_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ MM_DBG函数的具体用法?C++ MM_DBG怎么用?C++ MM_DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MM_DBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msm_snddev_request_freq
int msm_snddev_request_freq(int *freq, u32 session_id,
u32 capability, u32 clnt_type)
{
int i = 0;
int rc = 0;
struct msm_snddev_info *info;
u32 set_freq;
u32 session_mask = 0;
u32 clnt_type_mask = 0;
MM_DBG(": clnt_type 0x%08x\n", clnt_type);
if ((clnt_type == AUDDEV_CLNT_VOC) && (session_id != 0))
return -EINVAL;
if ((clnt_type == AUDDEV_CLNT_DEC)
&& (session_id >= MAX_DEC_SESSIONS))
return -EINVAL;
if ((clnt_type == AUDDEV_CLNT_ENC)
&& (session_id >= MAX_ENC_SESSIONS))
return -EINVAL;
session_mask = ((0x1 << session_id)) << (8 * (clnt_type-1));
clnt_type_mask = (0xFF << (8 * (clnt_type-1)));
if (!(*freq == 8000) && !(*freq == 11025) &&
!(*freq == 12000) && !(*freq == 16000) &&
!(*freq == 22050) && !(*freq == 24000) &&
!(*freq == 32000) && !(*freq == 44100) &&
!(*freq == 48000))
return -EINVAL;
for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
info = audio_dev_ctrl.devs[i];
if ((info->sessions & session_mask)
&& (info->capability & capability)) {
rc = 0;
if ((info->sessions & ~clnt_type_mask)
&& ((*freq != 8000) && (*freq != 16000)
&& (*freq != 48000))) {
if (clnt_type == AUDDEV_CLNT_ENC) {
routing_info.enc_freq[session_id].freq
= 0;
return -EPERM;
} else if (clnt_type == AUDDEV_CLNT_DEC) {
routing_info.dec_freq[session_id].freq
= 0;
return -EPERM;
}
}
if (*freq == info->set_sample_rate) {
rc = info->set_sample_rate;
continue;
}
set_freq = MAX(*freq, info->set_sample_rate);
if (set_freq == info->set_sample_rate) {
rc = info->set_sample_rate;
*freq = info->set_sample_rate;
continue;
}
if (clnt_type == AUDDEV_CLNT_DEC) {
routing_info.dec_freq[session_id].evt = 1;
routing_info.dec_freq[session_id].freq
= set_freq;
} else if (clnt_type == AUDDEV_CLNT_ENC) {
routing_info.enc_freq[session_id].evt = 1;
routing_info.enc_freq[session_id].freq
= set_freq;
} else if (capability == SNDDEV_CAP_TX)
routing_info.voice_tx_sample_rate = set_freq;
rc = set_freq;
info->set_sample_rate = set_freq;
*freq = info->set_sample_rate;
if (info->opened) {
broadcast_event(AUDDEV_EVT_FREQ_CHG, i,
SESSION_IGNORE);
set_freq = info->dev_ops.set_freq(info,
set_freq);
broadcast_event(AUDDEV_EVT_DEV_RDY, i,
SESSION_IGNORE);
}
}
MM_DBG("info->set_sample_rate = %d\n", info->set_sample_rate);
MM_DBG("routing_info.enc_freq.freq = %d\n",
routing_info.enc_freq[session_id].freq);
}
return rc;
}
示例2: audio_prevent_sleep
static void audio_prevent_sleep(struct audio *audio)
{
MM_DBG("\n"); /* Macro prints the file name and function */
wake_lock(&audio->wakelock);
wake_lock(&audio->idlelock);
}
示例3: snddev_icodec_open_rx
static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec)
{
int trc, err;
int smps_mode = PMAPP_SMPS_MODE_VOTE_PWM;
struct msm_afe_config afe_config;
struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
struct lpa_codec_config lpa_config;
wake_lock(&drv->rx_idlelock);
if ((icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_MONO) ||
(icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_STEREO)) {
/* Vote PMAPP_SMPS_MODE_VOTE_PFM for headset */
smps_mode = PMAPP_SMPS_MODE_VOTE_PFM;
MM_DBG("snddev_icodec_open_rx: PMAPP_SMPS_MODE_VOTE_PFM \n");
} else
MM_DBG("snddev_icodec_open_rx: PMAPP_SMPS_MODE_VOTE_PWM \n");
/* Vote for SMPS mode*/
err = pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID,
PMAPP_VREG_S4, smps_mode);
if (err != 0)
MM_ERR("pmapp_smps_mode_vote error %d\n", err);
/* enable MI2S RX master block */
/* enable MI2S RX bit clock */
trc = clk_set_rate(drv->rx_mclk,
SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate));
if (IS_ERR_VALUE(trc))
goto error_invalid_freq;
clk_enable(drv->rx_mclk);
clk_enable(drv->rx_sclk);
/* clk_set_rate(drv->lpa_codec_clk, 1); */ /* Remove if use pcom */
clk_enable(drv->lpa_p_clk);
clk_enable(drv->lpa_codec_clk);
clk_enable(drv->lpa_core_clk);
/* Enable LPA sub system
*/
drv->lpa = lpa_get();
if (!drv->lpa)
goto error_lpa;
lpa_config.sample_rate = icodec->sample_rate;
lpa_config.sample_width = 16;
lpa_config.output_interface = LPA_OUTPUT_INTF_WB_CODEC;
lpa_config.num_channels = icodec->data->channel_mode;
lpa_cmd_codec_config(drv->lpa, &lpa_config);
/* Set audio interconnect reg to LPA */
audio_interct_codec(AUDIO_INTERCT_LPA);
/* Set MI2S */
mi2s_set_codec_output_path((icodec->data->channel_mode == 2 ?
MI2S_CHAN_STEREO : MI2S_CHAN_MONO_PACKED), WT_16_BIT);
if (icodec->data->voltage_on)
icodec->data->voltage_on();
/* Configure ADIE */
trc = adie_codec_open(icodec->data->profile, &icodec->adie_path);
if (IS_ERR_VALUE(trc))
goto error_adie;
/* OSR default to 256, can be changed for power optimization
* If OSR is to be changed, need clock API for setting the divider
*/
adie_codec_setpath(icodec->adie_path, icodec->sample_rate, 256);
/* Start AFE */
afe_config.sample_rate = icodec->sample_rate / 1000;
afe_config.channel_mode = icodec->data->channel_mode;
afe_config.volume = AFE_VOLUME_UNITY;
trc = afe_enable(AFE_HW_PATH_CODEC_RX, &afe_config);
if (IS_ERR_VALUE(trc))
goto error_afe;
lpa_cmd_enable_codec(drv->lpa, 1);
/* Enable ADIE */
adie_codec_proceed_stage(icodec->adie_path, ADIE_CODEC_DIGITAL_READY);
adie_codec_proceed_stage(icodec->adie_path,
ADIE_CODEC_DIGITAL_ANALOG_READY);
/* Enable power amplifier */
if (icodec->data->pamp_on)
icodec->data->pamp_on();
icodec->enabled = 1;
wake_unlock(&drv->rx_idlelock);
return 0;
error_afe:
adie_codec_close(icodec->adie_path);
icodec->adie_path = NULL;
error_adie:
lpa_put(drv->lpa);
error_lpa:
clk_disable(drv->lpa_p_clk);
clk_disable(drv->lpa_codec_clk);
clk_disable(drv->lpa_core_clk);
clk_disable(drv->rx_sclk);
clk_disable(drv->rx_mclk);
error_invalid_freq:
//.........这里部分代码省略.........
示例4: qcelp_in_listener
static void qcelp_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
void *private_data)
{
struct audio_in *audio = (struct audio_in *) private_data;
unsigned long flags;
MM_DBG("evt_id = 0x%8x\n", evt_id);
switch (evt_id) {
case AUDDEV_EVT_DEV_RDY: {
MM_DBG("AUDDEV_EVT_DEV_RDY\n");
spin_lock_irqsave(&audio->dev_lock, flags);
audio->dev_cnt++;
if (!audio->in_call)
audio->source |= (0x1 << evt_payload->routing_id);
spin_unlock_irqrestore(&audio->dev_lock, flags);
if ((audio->running == 1) && (audio->enabled == 1))
audqcelp_in_record_config(audio, 1);
break;
}
case AUDDEV_EVT_DEV_RLS: {
MM_DBG("AUDDEV_EVT_DEV_RLS\n");
spin_lock_irqsave(&audio->dev_lock, flags);
audio->dev_cnt--;
if (!audio->in_call)
audio->source &= ~(0x1 << evt_payload->routing_id);
spin_unlock_irqrestore(&audio->dev_lock, flags);
if ((!audio->running) || (!audio->enabled))
break;
/* Turn of as per source */
if (audio->source)
audqcelp_in_record_config(audio, 1);
else
/* Turn off all */
audqcelp_in_record_config(audio, 0);
break;
}
case AUDDEV_EVT_VOICE_STATE_CHG: {
MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
evt_payload->voice_state);
audio->voice_state = evt_payload->voice_state;
if (audio->in_call && audio->running) {
if (audio->voice_state == VOICE_STATE_INCALL)
audqcelp_in_record_config(audio, 1);
else if (audio->voice_state == VOICE_STATE_OFFCALL) {
audqcelp_in_record_config(audio, 0);
wake_up(&audio->wait);
}
}
break;
}
default:
MM_ERR("wrong event %d\n", evt_id);
break;
}
}
示例5: audqcelp_in_read
static ssize_t audqcelp_in_read(struct file *file,
char __user *buf,
size_t count, loff_t *pos)
{
struct audio_in *audio = file->private_data;
unsigned long flags;
const char __user *start = buf;
void *data;
uint32_t index;
uint32_t size;
int rc = 0;
mutex_lock(&audio->read_lock);
while (count > 0) {
rc = wait_event_interruptible(
#ifdef CONFIG_SH_AUDIO_DRIVER
audio->wait, (audio->in_count > 0) || audio->stopped || audio->readbreak
#else
audio->wait, (audio->in_count > 0) || audio->stopped
#endif /* CONFIG_SH_AUDIO_DRIVER */
|| (audio->in_call && audio->running &&
(audio->voice_state == VOICE_STATE_OFFCALL)));
if (rc < 0)
break;
#ifdef CONFIG_SH_AUDIO_DRIVER
if (audio->readbreak) {
rc = -EPERM;
audio->readbreak = 0;
break;
}
#endif /* CONFIG_SH_AUDIO_DRIVER */
if (!audio->in_count) {
if (audio->stopped) {
rc = 0;/* End of File */
break;
} else if (audio->in_call && audio->running &&
(audio->voice_state == VOICE_STATE_OFFCALL)) {
MM_DBG("Not Permitted Voice Terminated\n");
rc = -EPERM; /* Voice Call stopped */
break;
}
}
index = audio->in_tail;
data = (uint8_t *) audio->in[index].data;
size = audio->in[index].size;
if (count >= size) {
if (copy_to_user(buf, data, size)) {
rc = -EFAULT;
break;
}
spin_lock_irqsave(&audio->dsp_lock, flags);
if (index != audio->in_tail) {
/* overrun -- data is
* invalid and we need to retry */
spin_unlock_irqrestore(&audio->dsp_lock, flags);
continue;
}
audio->in[index].size = 0;
audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
audio->in_count--;
spin_unlock_irqrestore(&audio->dsp_lock, flags);
count -= size;
buf += size;
} else {
MM_ERR("short read\n");
break;
}
}
mutex_unlock(&audio->read_lock);
if (buf > start)
return buf - start;
return rc;
}
示例6: msm_reset_put
static int msm_reset_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
MM_DBG("Resetting all devices\n");
return msm_reset_all_device();
}
示例7: audamrnb_in_ioctl
/* ------------------- device --------------------- */
static long audamrnb_in_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
struct audio_in *audio = file->private_data;
int rc = 0;
if (cmd == AUDIO_GET_STATS) {
struct msm_audio_stats stats;
stats.byte_count = atomic_read(&audio->in_bytes);
stats.sample_count = atomic_read(&audio->in_samples);
if (copy_to_user((void *) arg, &stats, sizeof(stats)))
return -EFAULT;
return rc;
}
mutex_lock(&audio->lock);
switch (cmd) {
case AUDIO_START: {
uint32_t freq;
freq = 48000;
MM_DBG("AUDIO_START\n");
if (audio->in_call && (audio->voice_state !=
VOICE_STATE_INCALL)) {
rc = -EPERM;
break;
}
rc = msm_snddev_request_freq(&freq, audio->enc_id,
SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
MM_DBG("sample rate configured %d\n", freq);
if (rc < 0) {
MM_DBG(" Sample rate can not be set, return code %d\n",
rc);
msm_snddev_withdraw_freq(audio->enc_id,
SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
MM_DBG("msm_snddev_withdraw_freq\n");
break;
}
rc = audamrnb_in_enable(audio);
if (!rc) {
rc =
wait_event_interruptible_timeout(audio->wait_enable,
audio->running != 0, 1*HZ);
MM_DBG("state %d rc = %d\n", audio->running, rc);
if (audio->running == 0)
rc = -ENODEV;
else
rc = 0;
}
audio->stopped = 0;
break;
}
case AUDIO_STOP: {
rc = audamrnb_in_disable(audio);
rc = msm_snddev_withdraw_freq(audio->enc_id,
SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
MM_DBG("msm_snddev_withdraw_freq\n");
audio->stopped = 1;
break;
}
case AUDIO_FLUSH: {
if (audio->stopped) {
/* Make sure we're stopped and we wake any threads
* that might be blocked holding the read_lock.
* While audio->stopped read threads will always
* exit immediately.
*/
wake_up(&audio->wait);
mutex_lock(&audio->read_lock);
audamrnb_in_flush(audio);
mutex_unlock(&audio->read_lock);
}
break;
}
case AUDIO_SET_STREAM_CONFIG: {
struct msm_audio_stream_config cfg;
if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
rc = -EFAULT;
break;
}
/* Allow only single frame */
if (cfg.buffer_size != (FRAME_SIZE - 8))
rc = -EINVAL;
else
audio->buffer_size = cfg.buffer_size;
break;
}
case AUDIO_GET_STREAM_CONFIG: {
struct msm_audio_stream_config cfg;
memset(&cfg, 0, sizeof(cfg));
cfg.buffer_size = audio->buffer_size;
cfg.buffer_count = FRAME_NUM;
if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
rc = -EFAULT;
break;
}
case AUDIO_GET_AMRNB_ENC_CONFIG_V2: {
struct msm_audio_amrnb_enc_config_v2 cfg;
memset(&cfg, 0, sizeof(cfg));
//.........这里部分代码省略.........
示例8: __msm_adsp_write
int __msm_adsp_write(struct msm_adsp_module *module, unsigned dsp_queue_addr,
void *cmd_buf, size_t cmd_size)
{
uint32_t ctrl_word;
uint32_t dsp_q_addr;
uint32_t dsp_addr;
uint32_t cmd_id = 0;
int cnt = 0;
int ret_status = 0;
unsigned long flags;
struct adsp_info *info;
if (!module || !cmd_buf) {
MM_AUD_ERR("Called with NULL parameters\n");
return -EINVAL;
}
info = module->info;
spin_lock_irqsave(&adsp_write_lock, flags);
if (module->state != ADSP_STATE_ENABLED) {
spin_unlock_irqrestore(&adsp_write_lock, flags);
MM_AUD_INFO("module %s not enabled before write\n", module->name);
return -ENODEV;
}
if (adsp_validate_module(module->id)) {
spin_unlock_irqrestore(&adsp_write_lock, flags);
MM_AUD_ERR("module id validation failed %s %d\n",
module->name, module->id);
return -ENXIO;
}
if (dsp_queue_addr >= QDSP_MAX_NUM_QUEUES) {
spin_unlock_irqrestore(&adsp_write_lock, flags);
MM_AUD_ERR("Invalid Queue Index: %d\n", dsp_queue_addr);
return -ENXIO;
}
if (adsp_validate_queue(module->id, dsp_queue_addr, cmd_size)) {
spin_unlock_irqrestore(&adsp_write_lock, flags);
return -EINVAL;
}
dsp_q_addr = adsp_get_queue_offset(info, dsp_queue_addr);
dsp_q_addr &= ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M;
/* Poll until the ADSP is ready to accept a command.
* Wait for 100us, return error if it's not responding.
* If this returns an error, we need to disable ALL modules and
* then retry.
*/
while (((ctrl_word = readl(info->write_ctrl)) &
ADSP_RTOS_WRITE_CTRL_WORD_READY_M) !=
ADSP_RTOS_WRITE_CTRL_WORD_READY_V) {
if (cnt > 50) {
MM_AUD_ERR("timeout waiting for DSP write ready\n");
ret_status = -EIO;
BUG();
goto fail;
}
MM_DBG("waiting for DSP write ready\n");
udelay(2);
cnt++;
}
/* Set the mutex bits */
ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M);
ctrl_word |= ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V;
/* Clear the command bits */
ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_CMD_M);
/* Set the queue address bits */
ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M);
ctrl_word |= dsp_q_addr;
writel(ctrl_word, info->write_ctrl);
/* Generate an interrupt to the DSP. This notifies the DSP that
* we are about to send a command on this particular queue. The
* DSP will in response change its state.
*/
writel(1, info->send_irq);
/* Poll until the adsp responds to the interrupt; this does not
* generate an interrupt from the adsp. This should happen within
* 5ms.
*/
cnt = 0;
while ((readl(info->write_ctrl) &
ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M) ==
ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V) {
if (cnt > 2500) {
MM_AUD_ERR("timeout waiting for adsp ack\n");
ret_status = -EIO;
BUG();
goto fail;
}
udelay(2);
cnt++;
}
/* Read the ctrl word */
ctrl_word = readl(info->write_ctrl);
//.........这里部分代码省略.........
示例9: audpreproc_dsp_event
/* ------------------- dsp preproc event handler--------------------- */
static void audpreproc_dsp_event(void *data, unsigned id, void *msg)
{
struct audio_in *audio = data;
switch (id) {
case AUDPREPROC_ERROR_MSG: {
struct audpreproc_err_msg *err_msg = msg;
MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
err_msg->stream_id, err_msg->aud_preproc_err_idx);
/* Error case */
wake_up(&audio->wait_enable);
break;
}
case AUDPREPROC_CMD_CFG_DONE_MSG: {
MM_DBG("CMD_CFG_DONE_MSG \n");
break;
}
case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
0x%8x\n", enc_cfg_msg->stream_id,
enc_cfg_msg->rec_enc_type);
/* Encoder enable success */
if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) {
if(audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
MM_DBG("routing command\n");
audpreproc_cmd_cfg_routing_mode(audio);
} else {
audevrc_in_param_config(audio);
}
} else { /* Encoder disable success */
audio->running = 0;
if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
audevrc_in_record_config(audio, 0);
else
wake_up(&audio->wait_enable);
}
break;
}
case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG\n");
if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
audevrc_in_mem_config(audio);
else
audpcm_config(audio);
break;
}
case AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: {
struct audpreproc_cmd_routing_mode_done\
*routing_cfg_done_msg = msg;
if (routing_cfg_done_msg->configuration == 0) {
MM_INFO("routing configuration failed\n");
audio->running = 0;
} else
audevrc_in_param_config(audio);
break;
}
case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
wake_up(&audio->wait_enable);
break;
}
default:
MM_ERR("Unknown Event id %d\n", id);
}
}
示例10: snddev_ecodec_open_rx
static int snddev_ecodec_open_rx(struct snddev_ecodec_state *ecodec)
{
int rc = 0;
struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
struct msm_afe_config afe_config;
int ret = 0;
MM_DBG("snddev_ecodec_open_rx\n");
if (!drv->tx_active) {
/* request GPIO */
rc = aux_pcm_gpios_request();
if (rc) {
MM_ERR("GPIO enable failed\n");
goto done;
}
/* config clocks */
clk_enable(drv->lpa_core_clk);
/*if long sync is selected in aux PCM interface
ecodec clock is updated to work with 128KHz,
if short sync is selected ecodec clock is updated to
work with 2.048MHz frequency, actual clock output is
different than the SW configuration by factor of two*/
if (!(ecodec->data->conf_aux_codec_intf &
AUX_CODEC_CTL__AUX_CODEC_MODE__I2S_V)) {
if (ecodec->data->conf_aux_codec_intf &
AUX_CODEC_CTL__AUX_PCM_MODE__AUX_MASTER_V) {
MM_DBG("Update ecodec clock to 128 KHz, long "
"sync in master mode is selected\n");
ret = clk_set_rate(drv->ecodec_clk, 256000);
if (ret < 0)
MM_ERR("Error updating ecodec clock"
" to 128KHz\n");
} else if (ecodec->data->conf_aux_codec_intf &
AUX_CODEC_CTL__AUX_PCM_MODE__PRIM_SLAVE_V) {
MM_DBG("Update ecodec clock to 2 MHz, short"
" sync in slave mode is selected\n");
ret = clk_set_rate(drv->ecodec_clk, 4096000);
if (ret < 0)
MM_ERR("Error updating ecodec clock"
" to 2.048MHz\n");
} else {
MM_DBG("Update ecodec clock to 2 MHz, short"
" sync in master mode is selected\n");
ret = clk_set_rate(drv->ecodec_clk, 4096000);
if (ret < 0)
MM_ERR("Error updating ecodec clock"
" to 2.048MHz\n");
}
}
/* enable ecodec clk */
clk_enable(drv->ecodec_clk);
/* let ADSP confiure AUX PCM regs */
aux_codec_adsp_codec_ctl_en(ADSP_CTL);
/* let adsp configure pcm path */
aux_codec_pcm_path_ctl_en(ADSP_CTL);
/* choose ADSP_A */
audio_interct_aux_regsel(AUDIO_ADSP_A);
audio_interct_tpcm_source(AUDIO_ADSP_A);
audio_interct_rpcm_source(AUDIO_ADSP_A);
clk_disable(drv->lpa_core_clk);
/* send AUX_CODEC_CONFIG to AFE */
rc = afe_config_aux_codec(ecodec->data->conf_pcm_ctl_val,
ecodec->data->conf_aux_codec_intf,
ecodec->data->conf_data_format_padding_val);
if (IS_ERR_VALUE(rc))
goto error;
}
/* send CODEC CONFIG to AFE */
afe_config.sample_rate = ecodec->sample_rate / 1000;
afe_config.channel_mode = ecodec->data->channel_mode;
afe_config.volume = AFE_VOLUME_UNITY;
rc = afe_enable(AFE_HW_PATH_AUXPCM_RX, &afe_config);
if (IS_ERR_VALUE(rc)) {
if (!drv->tx_active) {
aux_pcm_gpios_free();
clk_disable(drv->ecodec_clk);
}
goto done;
}
ecodec->enabled = 1;
return 0;
error:
aux_pcm_gpios_free();
clk_disable(drv->ecodec_clk);
done:
return rc;
}
示例11: audamrnb_in_open
static int audamrnb_in_open(struct inode *inode, struct file *file)
{
struct audio_in *audio = &the_audio_amrnb_in;
int rc;
int encid;
int len = 0;
unsigned long ionflag = 0;
ion_phys_addr_t addr = 0;
struct ion_handle *handle = NULL;
struct ion_client *client = NULL;
mutex_lock(&audio->lock);
if (audio->opened) {
rc = -EBUSY;
goto done;
}
client = msm_ion_client_create(UINT_MAX, "Audio_AMR_In_Client");
if (IS_ERR_OR_NULL(client)) {
MM_ERR("Unable to create ION client\n");
rc = -ENOMEM;
goto client_create_error;
}
audio->client = client;
handle = ion_alloc(client, DMASZ, SZ_4K,
ION_HEAP(ION_AUDIO_HEAP_ID),0);
if (IS_ERR_OR_NULL(handle)) {
MM_ERR("Unable to create allocate O/P buffers\n");
rc = -ENOMEM;
goto buff_alloc_error;
}
audio->buff_handle = handle;
rc = ion_phys(client, handle, &addr, &len);
if (rc) {
MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
(unsigned int) addr, (unsigned int) len);
goto buff_get_phys_error;
} else {
MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
(unsigned int) addr, (unsigned int) len);
}
audio->phys = (int32_t)addr;
rc = ion_handle_get_flags(client, handle, &ionflag);
if (rc) {
MM_ERR("could not get flags for the handle\n");
goto buff_get_flags_error;
}
audio->map_v_read = ion_map_kernel(client, handle);
if (IS_ERR(audio->map_v_read)) {
MM_ERR("could not map write buffers\n");
rc = -ENOMEM;
goto buff_map_error;
}
audio->data = audio->map_v_read;
MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
audio->phys, (int)audio->data);
MM_DBG("Memory addr = 0x%8x phy addr = 0x%8x\n",\
(int) audio->data, (int) audio->phys);
if ((file->f_mode & FMODE_WRITE) &&
(file->f_mode & FMODE_READ)) {
rc = -EACCES;
MM_ERR("Non tunnel encoding is not supported\n");
goto buff_map_error;
} else if (!(file->f_mode & FMODE_WRITE) &&
(file->f_mode & FMODE_READ)) {
audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
MM_DBG("Opened for tunnel mode encoding\n");
} else {
rc = -EACCES;
goto buff_map_error;
}
/* Settings will be re-config at AUDIO_SET_CONFIG,
* but at least we need to have initial config
*/
audio->buffer_size = (FRAME_SIZE - 8);
audio->enc_type = ENC_TYPE_AMRNB | audio->mode;
audio->dtx_mode = -1;
audio->frame_format = 0;
audio->used_mode = 7; /* Bit Rate 12.2 kbps MR122 */
encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
&audio->queue_ids);
if (encid < 0) {
MM_ERR("No free encoder available\n");
rc = -ENODEV;
goto aenc_alloc_error;
}
audio->enc_id = encid;
rc = msm_adsp_get(audio->module_name, &audio->audrec,
&audrec_amrnb_adsp_ops, audio);
if (rc) {
//.........这里部分代码省略.........
示例12: broadcast_event
/* session id is 32 bit routing mask per device
* 0-7 for voice clients
* 8-15 for Decoder clients
* 16-23 for Encoder clients
* 24-31 Do not care
*/
void broadcast_event(u32 evt_id, u32 dev_id, u32 session_id)
{
int clnt_id = 0;
union auddev_evt_data *evt_payload;
struct msm_snd_evt_listner *callback;
struct msm_snddev_info *dev_info = NULL;
u32 session_mask = 0;
static int pending_sent;
MM_DBG(": evt_id = %d\n", evt_id);
if ((evt_id != AUDDEV_EVT_START_VOICE)
&& (evt_id != AUDDEV_EVT_END_VOICE)
&& (evt_id != AUDDEV_EVT_STREAM_VOL_CHG)) {
dev_info = audio_dev_ctrl_find_dev(dev_id);
if (IS_ERR(dev_info))
return;
}
if (event.cb != NULL)
callback = event.cb;
else
return;
mutex_lock(&session_lock);
evt_payload = kzalloc(sizeof(union auddev_evt_data),
GFP_KERNEL);
if (!evt_payload) {
MM_AUD_ERR("%s: fail to allocate memory\n", __func__);
return;
}
for (; ;) {
if (!(evt_id & callback->evt_id)) {
if (callback->cb_next == NULL)
break;
else {
callback = callback->cb_next;
continue;
}
}
clnt_id = callback->clnt_id;
memset(evt_payload, 0, sizeof(union auddev_evt_data));
if ((evt_id == AUDDEV_EVT_START_VOICE)
|| (evt_id == AUDDEV_EVT_END_VOICE))
goto skip_check;
if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL)
goto aud_cal;
session_mask = (0x1 << (clnt_id))
<< (8 * ((int)callback->clnt_type-1));
if (evt_id == AUDDEV_EVT_STREAM_VOL_CHG) {
MM_DBG("AUDDEV_EVT_STREAM_VOL_CHG\n");
goto volume_strm;
}
MM_DBG("dev_info->sessions = %08x\n", dev_info->sessions);
if ((!session_id && !(dev_info->sessions & session_mask)) ||
(session_id && ((dev_info->sessions & session_mask) !=
session_id))) {
if (callback->cb_next == NULL)
break;
else {
callback = callback->cb_next;
continue;
}
}
if (evt_id == AUDDEV_EVT_DEV_CHG_VOICE)
goto voc_events;
volume_strm:
if (callback->clnt_type == AUDDEV_CLNT_DEC) {
MM_DBG("AUDDEV_CLNT_DEC\n");
if (evt_id == AUDDEV_EVT_STREAM_VOL_CHG) {
MM_DBG("clnt_id = %d, session_id = 0x%8x\n",
clnt_id, session_id);
if (session_mask != session_id)
goto sent_dec;
else
evt_payload->session_vol =
msm_vol_ctl.volume;
} else if (evt_id == AUDDEV_EVT_FREQ_CHG) {
if (routing_info.dec_freq[clnt_id].evt) {
routing_info.dec_freq[clnt_id].evt
= 0;
goto sent_dec;
} else if (routing_info.dec_freq[clnt_id].freq
== dev_info->set_sample_rate)
goto sent_dec;
else {
//.........这里部分代码省略.........
示例13: audio_dev_ctrl_release
static int audio_dev_ctrl_release(struct inode *inode, struct file *file)
{
MM_DBG("release audio_dev_ctrl\n");
atomic_dec(&audio_dev_ctrl.opened);
return 0;
}
示例14: audio_dev_ctrl_ioctl
static int audio_dev_ctrl_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
int rc = 0;
struct audio_dev_ctrl_state *dev_ctrl = file->private_data;
mutex_lock(&session_lock);
switch (cmd) {
case AUDIO_GET_NUM_SND_DEVICE:
rc = put_user(dev_ctrl->num_dev, (uint32_t __user *) arg);
break;
case AUDIO_GET_SND_DEVICES:
rc = audio_dev_ctrl_get_devices(dev_ctrl, (void __user *) arg);
break;
case AUDIO_ENABLE_SND_DEVICE: {
struct msm_snddev_info *dev_info;
u32 dev_id;
if (get_user(dev_id, (u32 __user *) arg)) {
rc = -EFAULT;
break;
}
dev_info = audio_dev_ctrl_find_dev(dev_id);
if (IS_ERR(dev_info))
rc = PTR_ERR(dev_info);
else {
rc = dev_info->dev_ops.open(dev_info);
if (!rc)
dev_info->opened = 1;
wake_up(&audio_dev_ctrl.wait);
}
break;
}
case AUDIO_DISABLE_SND_DEVICE: {
struct msm_snddev_info *dev_info;
u32 dev_id;
if (get_user(dev_id, (u32 __user *) arg)) {
rc = -EFAULT;
break;
}
dev_info = audio_dev_ctrl_find_dev(dev_id);
if (IS_ERR(dev_info))
rc = PTR_ERR(dev_info);
else {
rc = dev_info->dev_ops.close(dev_info);
dev_info->opened = 0;
}
break;
}
case AUDIO_ROUTE_STREAM: {
struct msm_audio_route_config route_cfg;
struct msm_snddev_info *dev_info;
if (copy_from_user(&route_cfg, (void __user *) arg,
sizeof(struct msm_audio_route_config))) {
rc = -EFAULT;
break;
}
MM_DBG("%s: route cfg %d %d type\n", __func__,
route_cfg.dev_id, route_cfg.stream_type);
dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id);
if (IS_ERR(dev_info)) {
MM_AUD_ERR("%s: pass invalid dev_id\n", __func__);
rc = PTR_ERR(dev_info);
break;
}
switch (route_cfg.stream_type) {
case AUDIO_ROUTE_STREAM_VOICE_RX:
if (!(dev_info->capability & SNDDEV_CAP_RX) |
!(dev_info->capability & SNDDEV_CAP_VOICE)) {
rc = -EINVAL;
break;
}
dev_ctrl->voice_rx_dev = dev_info;
break;
case AUDIO_ROUTE_STREAM_VOICE_TX:
if (!(dev_info->capability & SNDDEV_CAP_TX) |
!(dev_info->capability & SNDDEV_CAP_VOICE)) {
rc = -EINVAL;
break;
}
dev_ctrl->voice_tx_dev = dev_info;
break;
}
break;
}
default:
rc = -EINVAL;
}
mutex_unlock(&session_lock);
return rc;
}
示例15: msm_voice_put
static int msm_voice_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int rc = 0;
uint32_t rx_dev_id;
uint32_t tx_dev_id;
struct msm_snddev_info *rx_dev_info;
struct msm_snddev_info *tx_dev_info;
int set = ucontrol->value.integer.value[2];
u32 session_mask;
if (!set)
return -EPERM;
/* Rx Device Routing */
rx_dev_id = ucontrol->value.integer.value[0];
rx_dev_info = audio_dev_ctrl_find_dev(rx_dev_id);
if (IS_ERR(rx_dev_info)) {
MM_ERR("pass invalid dev_id\n");
rc = PTR_ERR(rx_dev_info);
return rc;
}
if (!(rx_dev_info->capability & SNDDEV_CAP_RX)) {
MM_ERR("First Dev is supposed to be RX\n");
return -EFAULT;
}
MM_DBG("route cfg %d STREAM_VOICE_RX type\n",
rx_dev_id);
msm_set_voc_route(rx_dev_info, AUDIO_ROUTE_STREAM_VOICE_RX,
rx_dev_id);
session_mask = 0x1 << (8 * ((int)AUDDEV_CLNT_VOC-1));
broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, rx_dev_id, session_mask);
/* Tx Device Routing */
tx_dev_id = ucontrol->value.integer.value[1];
tx_dev_info = audio_dev_ctrl_find_dev(tx_dev_id);
if (IS_ERR(tx_dev_info)) {
MM_ERR("pass invalid dev_id\n");
rc = PTR_ERR(tx_dev_info);
return rc;
}
if (!(tx_dev_info->capability & SNDDEV_CAP_TX)) {
MM_ERR("Second Dev is supposed to be Tx\n");
return -EFAULT;
}
MM_DBG("route cfg %d %d type\n",
tx_dev_id, AUDIO_ROUTE_STREAM_VOICE_TX);
msm_set_voc_route(tx_dev_info, AUDIO_ROUTE_STREAM_VOICE_TX,
tx_dev_id);
broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, tx_dev_id, session_mask);
if (rx_dev_info->opened)
broadcast_event(AUDDEV_EVT_DEV_RDY, rx_dev_id, session_mask);
if (tx_dev_info->opened)
broadcast_event(AUDDEV_EVT_DEV_RDY, tx_dev_id, session_mask);
return rc;
}