static int snddev_icodec_set_freq(struct msm_snddev_info *dev_info, u32 rate) { int rc; struct snddev_icodec_state *icodec; if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; if (adie_codec_freq_supported(icodec->data->profile, rate) != 0) { pr_err("%s: adie_codec_freq_supported() failed\n", __func__); rc = -EINVAL; goto error; } else { if (snddev_icodec_check_freq(rate) != 0) { pr_err("%s: check_freq failed\n", __func__); rc = -EINVAL; goto error; } else icodec->sample_rate = rate; } if (icodec->enabled) { snddev_icodec_close(dev_info); snddev_icodec_open(dev_info); } return icodec->sample_rate; error: return rc; }
static int snddev_icodec_set_freq(struct msm_snddev_info *dev_info, u32 rate) { int rc; struct snddev_icodec_state *icodec; MM_AUD_INFO("%s +++, rate: %d", __func__, rate); if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; if (support_adie) { if (adie_codec_freq_supported(icodec->data->profile, rate) != 0) { rc = -EINVAL; MM_AUD_INFO("%s fail_1", __func__); goto error; } else { if (snddev_icodec_check_freq(rate) != 0) { rc = -EINVAL; MM_AUD_INFO("%s fail_2", __func__); goto error; } else icodec->sample_rate = rate; } } else { if (snddev_icodec_check_freq(rate) != 0) { rc = -EINVAL; MM_AUD_INFO("%s fail_3", __func__); goto error; } else icodec->sample_rate = rate; } if (icodec->enabled) { snddev_icodec_close(dev_info); snddev_icodec_open(dev_info); } MM_AUD_INFO("%s ---, sample_rate: %d", __func__, icodec->sample_rate); return icodec->sample_rate; error: MM_AUD_INFO("%s err, rc: %d", __func__, rc); return rc; }
static int snddev_icodec_open(struct msm_snddev_info *dev_info) { int rc = 0; struct snddev_icodec_state *icodec; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; if (icodec->data->capability & SNDDEV_CAP_RX) { mutex_lock(&drv->rx_lock); if (drv->rx_active) { mutex_unlock(&drv->rx_lock); rc = -EBUSY; goto error; } rc = snddev_icodec_open_rx(icodec); if (!IS_ERR_VALUE(rc)) { drv->rx_active = 1; if ((icodec->data->dev_vol_type & ( SNDDEV_DEV_VOL_DIGITAL | SNDDEV_DEV_VOL_ANALOG))) rc = snddev_icodec_set_device_volume_impl( dev_info, dev_info->dev_volume); if (IS_ERR_VALUE(rc)) { MM_ERR("Failed to set device volume" " impl for rx device\n"); snddev_icodec_close(dev_info); mutex_unlock(&drv->rx_lock); goto error; } } mutex_unlock(&drv->rx_lock); } else { mutex_lock(&drv->tx_lock); if (drv->tx_active) { mutex_unlock(&drv->tx_lock); rc = -EBUSY; goto error; } rc = snddev_icodec_open_tx(icodec); if (!IS_ERR_VALUE(rc)) { drv->tx_active = 1; if ((icodec->data->dev_vol_type & ( SNDDEV_DEV_VOL_DIGITAL | SNDDEV_DEV_VOL_ANALOG))) rc = snddev_icodec_set_device_volume_impl( dev_info, dev_info->dev_volume); if (IS_ERR_VALUE(rc)) { MM_ERR("Failed to set device volume" " impl for tx device\n"); snddev_icodec_close(dev_info); mutex_unlock(&drv->tx_lock); goto error; } } mutex_unlock(&drv->tx_lock); } error: return rc; }
static int snddev_icodec_open(struct msm_snddev_info *dev_info) { int rc = 0; struct snddev_icodec_state *icodec; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; if (!dev_info) { rc = -EINVAL; goto error; } icodec = dev_info->private_data; if (icodec->data->capability & SNDDEV_CAP_RX) { mutex_lock(&drv->rx_lock); if (drv->rx_active) { mutex_unlock(&drv->rx_lock); rc = -EBUSY; goto error; } rc = snddev_icodec_open_rx(icodec); if (!IS_ERR_VALUE(rc)) { drv->rx_active = 1; if ((icodec->data->dev_vol_type & ( SNDDEV_DEV_VOL_DIGITAL | SNDDEV_DEV_VOL_ANALOG))) #if 1//def CONFIG_MACH_APACHE { /*As per QC's suggestion for SR 623568 , return value of snddev_icodec_set_device_volume_impl * is ignored, which was causing device open failure*/ if ( snddev_icodec_set_device_volume_impl(dev_info, dev_info->dev_volume) < 0 ) printk(" snddev_icodec_set_device_volume_impl returns error\n"); } #else rc = snddev_icodec_set_device_volume_impl( dev_info, dev_info->dev_volume); if (IS_ERR_VALUE(rc)) { MM_ERR("Failed to set device volume" " impl for rx device\n"); snddev_icodec_close(dev_info); mutex_unlock(&drv->rx_lock); goto error; } #endif } mutex_unlock(&drv->rx_lock); } else { mutex_lock(&drv->tx_lock); if (drv->tx_active) { mutex_unlock(&drv->tx_lock); rc = -EBUSY; goto error; } rc = snddev_icodec_open_tx(icodec); if (!IS_ERR_VALUE(rc)) { drv->tx_active = 1; if ((icodec->data->dev_vol_type & ( SNDDEV_DEV_VOL_DIGITAL | SNDDEV_DEV_VOL_ANALOG))) #if 1//def CONFIG_MACH_APACHE { if ( snddev_icodec_set_device_volume_impl(dev_info, dev_info->dev_volume) < 0 ) printk(" snddev_icodec_set_device_volume_impl returns error\n"); } #else rc = snddev_icodec_set_device_volume_impl( dev_info, dev_info->dev_volume); if (IS_ERR_VALUE(rc)) { MM_ERR("Failed to set device volume" " impl for tx device\n"); snddev_icodec_close(dev_info); mutex_unlock(&drv->tx_lock); goto error; } #endif } mutex_unlock(&drv->tx_lock); } error: return rc; }