Merge tag 'v3.10.56' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / core / pcm_lib.c
index 41b3dfe68698985e2d5f7e85a4e8411cb6a6371e..0a774923a6976babd0550f6b99e2d298982b67f0 100644 (file)
@@ -365,13 +365,17 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
                if (delta > new_hw_ptr) {
                        /* check for double acknowledged interrupts */
                        hdelta = curr_jiffies - runtime->hw_ptr_jiffies;
-                       if (hdelta > runtime->hw_ptr_buffer_jiffies/2) {
+                       //MTK modify+++
+                       //if (hdelta > runtime->hw_ptr_buffer_jiffies/2) {  //Alsa origin
+                       if (hdelta > runtime->hw_ptr_buffer_jiffies*3/4) {  //MTK modified
+                       //MTK modify---
                                hw_base += runtime->buffer_size;
                                if (hw_base >= runtime->boundary) {
                                        hw_base = 0;
                                        crossed_boundary++;
                                }
                                new_hw_ptr = hw_base + pos;
+                               printk("%s, overflow? new_hw_ptr=%ld, hw_base=%ld\n",__FUNCTION__,new_hw_ptr,hw_base);
                                goto __delta;
                        }
                }
@@ -1782,14 +1786,16 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
 {
        struct snd_pcm_hw_params *params = arg;
        snd_pcm_format_t format;
-       int channels, width;
+       int channels;
+       ssize_t frame_size;
 
        params->fifo_size = substream->runtime->hw.fifo_size;
        if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) {
                format = params_format(params);
                channels = params_channels(params);
-               width = snd_pcm_format_physical_width(format);
-               params->fifo_size /= width * channels;
+               frame_size = snd_pcm_format_size(format, channels);
+               if (frame_size > 0)
+                       params->fifo_size /= (unsigned)frame_size;
        }
        return 0;
 }
@@ -1885,7 +1891,7 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
        if (runtime->no_period_wakeup)
                wait_time = MAX_SCHEDULE_TIMEOUT;
        else {
-               wait_time = 10;
+               wait_time = 3/*10*/;//Modified by MTK
                if (runtime->rate) {
                        long t = runtime->period_size * 2 / runtime->rate;
                        wait_time = max(t, wait_time);
@@ -1936,6 +1942,8 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
                case SNDRV_PCM_STATE_DISCONNECTED:
                        err = -EBADFD;
                        goto _endloop;
+               case SNDRV_PCM_STATE_PAUSED:
+                       continue;
                }
                if (!tout) {
                        snd_printd("%s write error (DMA or IRQ trouble?)\n",