]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - sound/hda/hdac_stream.c
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux.git] / sound / hda / hdac_stream.c
index 682ed39f79b015a3982b6e149ff3bf1c0d3632b6..a314b03b4a4cb1696d87ee57d5f5ed8d21eecb26 100644 (file)
@@ -590,7 +590,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_timecounter_init);
 /**
  * snd_hdac_stream_sync_trigger - turn on/off stream sync register
  * @azx_dev: HD-audio core stream (master stream)
+ * @set: true = set, false = clear
  * @streams: bit flags of streams to sync
+ * @reg: the stream sync register address
  */
 void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set,
                                  unsigned int streams, unsigned int reg)
@@ -629,20 +631,27 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
                nwait = 0;
                i = 0;
                list_for_each_entry(s, &bus->stream_list, list) {
-                       if (streams & (1 << i)) {
-                               if (start) {
-                                       /* check FIFO gets ready */
-                                       if (!(snd_hdac_stream_readb(s, SD_STS) &
-                                             SD_STS_FIFO_READY))
-                                               nwait++;
-                               } else {
-                                       /* check RUN bit is cleared */
-                                       if (snd_hdac_stream_readb(s, SD_CTL) &
-                                           SD_CTL_DMA_START)
-                                               nwait++;
+                       if (!(streams & (1 << i++)))
+                               continue;
+
+                       if (start) {
+                               /* check FIFO gets ready */
+                               if (!(snd_hdac_stream_readb(s, SD_STS) &
+                                     SD_STS_FIFO_READY))
+                                       nwait++;
+                       } else {
+                               /* check RUN bit is cleared */
+                               if (snd_hdac_stream_readb(s, SD_CTL) &
+                                   SD_CTL_DMA_START) {
+                                       nwait++;
+                                       /*
+                                        * Perform stream reset if DMA RUN
+                                        * bit not cleared within given timeout
+                                        */
+                                       if (timeout == 1)
+                                               snd_hdac_stream_reset(s);
                                }
                        }
-                       i++;
                }
                if (!nwait)
                        break;