Merge "msm: audio: qdsp6v2: Change AUDIO_SET_CONFIG ioctl implementation" into msm-3.0
diff --git a/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h b/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h
index 3965a75..562a305 100644
--- a/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h
+++ b/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h
@@ -13,7 +13,19 @@
#ifndef __MSM_HDMI_AUDIO_H
#define __MSM_HDMI_AUDIO_H
+enum hdmi_supported_sample_rates {
+ HDMI_SAMPLE_RATE_32KHZ,
+ HDMI_SAMPLE_RATE_44_1KHZ,
+ HDMI_SAMPLE_RATE_48KHZ,
+ HDMI_SAMPLE_RATE_88_2KHZ,
+ HDMI_SAMPLE_RATE_96KHZ,
+ HDMI_SAMPLE_RATE_176_4KHZ,
+ HDMI_SAMPLE_RATE_192KHZ
+};
+
int hdmi_audio_enable(bool on , u32 fifo_water_mark);
int hdmi_audio_packet_enable(bool on);
+void hdmi_msm_audio_sample_rate_reset(int rate);
+int hdmi_msm_audio_get_sample_rate(void);
#endif /* __MSM_HDMI_AUDIO_H*/
diff --git a/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c b/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c
index f978554..64344ef 100644
--- a/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c
+++ b/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c
@@ -184,13 +184,18 @@
rc = -EFAULT;
}
break;
- case AUDIO_SET_CONFIG:
+ case AUDIO_SET_CONFIG: {
+ /* Setting default rate as 48khz */
+ unsigned int cur_sample_rate =
+ HDMI_SAMPLE_RATE_48KHZ;
+ struct msm_audio_config config;
+
pr_debug("AUDIO_SET_CONFIG\n");
- if (copy_from_user(&lpa_if->dma_period_sz, (void *) arg,
- sizeof(unsigned int))) {
- pr_debug("%s:failed to copy from user\n", __func__);
+ if (copy_from_user(&config, (void *)arg, sizeof(config))) {
rc = -EFAULT;
+ break;
}
+ lpa_if->dma_period_sz = config.buffer_size;
if ((lpa_if->dma_period_sz * lpa_if->num_periods) >
DMA_ALLOC_BUF_SZ) {
pr_err("Dma buffer size greater than allocated size\n");
@@ -213,7 +218,40 @@
lpa_if->audio_buf[i].size = lpa_if->dma_period_sz;
lpa_if->audio_buf[i].used = 0;
}
+
+ pr_debug("Sample rate %d\n", config.sample_rate);
+ switch (config.sample_rate) {
+ case 48000:
+ cur_sample_rate = HDMI_SAMPLE_RATE_48KHZ;
+ break;
+ case 44100:
+ cur_sample_rate = HDMI_SAMPLE_RATE_44_1KHZ;
+ break;
+ case 32000:
+ cur_sample_rate = HDMI_SAMPLE_RATE_32KHZ;
+ break;
+ case 88200:
+ cur_sample_rate = HDMI_SAMPLE_RATE_88_2KHZ;
+ break;
+ case 96000:
+ cur_sample_rate = HDMI_SAMPLE_RATE_96KHZ;
+ break;
+ case 176400:
+ cur_sample_rate = HDMI_SAMPLE_RATE_176_4KHZ;
+ break;
+ case 192000:
+ cur_sample_rate = HDMI_SAMPLE_RATE_192KHZ;
+ break;
+ default:
+ cur_sample_rate = HDMI_SAMPLE_RATE_48KHZ;
+ }
+ if (cur_sample_rate != hdmi_msm_audio_get_sample_rate())
+ hdmi_msm_audio_sample_rate_reset(cur_sample_rate);
+ else
+ pr_debug("Previous sample rate and current"
+ "sample rate are same\n");
break;
+ }
default:
pr_err("UnKnown Ioctl\n");
rc = -EINVAL;