Lines Matching refs:dmap

44 static long dmabuf_timeout(struct dma_buffparms *dmap)  in dmabuf_timeout()  argument
48 tmout = (dmap->fragment_size * HZ) / dmap->data_rate; in dmabuf_timeout()
57 static int sound_alloc_dmap(struct dma_buffparms *dmap) in sound_alloc_dmap() argument
64 dmap->mapping_flags &= ~DMA_MAP_MAPPED; in sound_alloc_dmap()
66 if (dmap->raw_buf != NULL) in sound_alloc_dmap()
70 dma_pagesize = (dmap->dma < 4) ? (64 * 1024) : (128 * 1024); in sound_alloc_dmap()
79 dmap->raw_buf = NULL; in sound_alloc_dmap()
80 dmap->buffsize = dma_buffsize; in sound_alloc_dmap()
81 if (dmap->buffsize > dma_pagesize) in sound_alloc_dmap()
82 dmap->buffsize = dma_pagesize; in sound_alloc_dmap()
89 while (start_addr == NULL && dmap->buffsize > PAGE_SIZE) { in sound_alloc_dmap()
90 for (sz = 0, size = PAGE_SIZE; size < dmap->buffsize; sz++, size <<= 1); in sound_alloc_dmap()
91 dmap->buffsize = PAGE_SIZE * (1 << sz); in sound_alloc_dmap()
94 dmap->buffsize /= 2; in sound_alloc_dmap()
102 end_addr = start_addr + dmap->buffsize - 1; in sound_alloc_dmap()
111 …printk(KERN_ERR "sound: Got invalid address 0x%lx for %db DMA-buffer\n", (long) start_addr, dmap->… in sound_alloc_dmap()
115 dmap->raw_buf = start_addr; in sound_alloc_dmap()
116 dmap->raw_buf_phys = virt_to_bus(start_addr); in sound_alloc_dmap()
123 static void sound_free_dmap(struct dma_buffparms *dmap) in sound_free_dmap() argument
129 if (dmap->raw_buf == NULL) in sound_free_dmap()
131 if (dmap->mapping_flags & DMA_MAP_MAPPED) in sound_free_dmap()
133 for (sz = 0, size = PAGE_SIZE; size < dmap->buffsize; sz++, size <<= 1); in sound_free_dmap()
135 start_addr = (unsigned long) dmap->raw_buf; in sound_free_dmap()
136 end_addr = start_addr + dmap->buffsize; in sound_free_dmap()
141 free_pages((unsigned long) dmap->raw_buf, sz); in sound_free_dmap()
142 dmap->raw_buf = NULL; in sound_free_dmap()
148 static int sound_start_dma(struct dma_buffparms *dmap, unsigned long physaddr, int count, int dma_m… in sound_start_dma() argument
151 int chan = dmap->dma; in sound_start_dma()
167 static void dma_init_buffers(struct dma_buffparms *dmap) in dma_init_buffers() argument
169 dmap->qlen = dmap->qhead = dmap->qtail = dmap->user_counter = 0; in dma_init_buffers()
170 dmap->byte_counter = 0; in dma_init_buffers()
171 dmap->max_byte_counter = 8000 * 60 * 60; in dma_init_buffers()
172 dmap->bytes_in_use = dmap->buffsize; in dma_init_buffers()
174 dmap->dma_mode = DMODE_NONE; in dma_init_buffers()
175 dmap->mapping_flags = 0; in dma_init_buffers()
176 dmap->neutral_byte = 0x80; in dma_init_buffers()
177 dmap->data_rate = 8000; in dma_init_buffers()
178 dmap->cfrag = -1; in dma_init_buffers()
179 dmap->closing = 0; in dma_init_buffers()
180 dmap->nbufs = 1; in dma_init_buffers()
181 dmap->flags = DMA_BUSY; /* Other flags off */ in dma_init_buffers()
184 static int open_dmap(struct audio_operations *adev, int mode, struct dma_buffparms *dmap) in open_dmap() argument
188 if (dmap->flags & DMA_BUSY) in open_dmap()
190 if ((err = sound_alloc_dmap(dmap)) < 0) in open_dmap()
193 if (dmap->raw_buf == NULL) { in open_dmap()
197 if (dmap->dma >= 0 && sound_open_dma(dmap->dma, adev->name)) { in open_dmap()
198 printk(KERN_WARNING "Unable to grab(2) DMA%d for the audio driver\n", dmap->dma); in open_dmap()
201 dma_init_buffers(dmap); in open_dmap()
202 dmap->open_mode = mode; in open_dmap()
203 dmap->subdivision = dmap->underrun_count = 0; in open_dmap()
204 dmap->fragment_size = 0; in open_dmap()
205 dmap->max_fragments = 65536; /* Just a large value */ in open_dmap()
206 dmap->byte_counter = 0; in open_dmap()
207 dmap->max_byte_counter = 8000 * 60 * 60; in open_dmap()
208 dmap->applic_profile = APF_NORMAL; in open_dmap()
209 dmap->needs_reorg = 1; in open_dmap()
210 dmap->audio_callback = NULL; in open_dmap()
211 dmap->callback_parm = 0; in open_dmap()
215 static void close_dmap(struct audio_operations *adev, struct dma_buffparms *dmap) in close_dmap() argument
219 if (dmap->dma >= 0) { in close_dmap()
220 sound_close_dma(dmap->dma); in close_dmap()
222 disable_dma(dmap->dma); in close_dmap()
225 if (dmap->flags & DMA_BUSY) in close_dmap()
226 dmap->dma_mode = DMODE_NONE; in close_dmap()
227 dmap->flags &= ~DMA_BUSY; in close_dmap()
230 sound_free_dmap(dmap); in close_dmap()
336 struct dma_buffparms *dmap = adev->dmap_out; in dma_reset_output() local
338 if (!(dmap->flags & DMA_STARTED)) /* DMA is not active */ in dma_reset_output()
352 dmabuf_timeout(dmap)); in dma_reset_output()
365 clear_dma_ff(dmap->dma); in dma_reset_output()
366 disable_dma(dmap->dma); in dma_reset_output()
370 dmap->byte_counter = 0; in dma_reset_output()
372 dmap->qlen = dmap->qhead = dmap->qtail = dmap->user_counter = 0; in dma_reset_output()
379 struct dma_buffparms *dmap = adev->dmap_in; in dma_reset_input() local
390 dmap->qlen = dmap->qhead = dmap->qtail = dmap->user_counter = 0; in dma_reset_input()
391 dmap->byte_counter = 0; in dma_reset_input()
395 void DMAbuf_launch_output(int dev, struct dma_buffparms *dmap) in DMAbuf_launch_output() argument
401 dmap->dma_mode = DMODE_OUTPUT; in DMAbuf_launch_output()
403 if (!(dmap->flags & DMA_ACTIVE) || !(adev->flags & DMA_AUTOMODE) || (dmap->flags & DMA_NODMA)) { in DMAbuf_launch_output()
404 if (!(dmap->flags & DMA_STARTED)) { in DMAbuf_launch_output()
405 reorganize_buffers(dev, dmap, 0); in DMAbuf_launch_output()
406 if (adev->d->prepare_for_output(dev, dmap->fragment_size, dmap->nbufs)) in DMAbuf_launch_output()
408 if (!(dmap->flags & DMA_NODMA)) in DMAbuf_launch_output()
409 local_start_dma(adev, dmap->raw_buf_phys, dmap->bytes_in_use,DMA_MODE_WRITE); in DMAbuf_launch_output()
410 dmap->flags |= DMA_STARTED; in DMAbuf_launch_output()
412 if (dmap->counts[dmap->qhead] == 0) in DMAbuf_launch_output()
413 dmap->counts[dmap->qhead] = dmap->fragment_size; in DMAbuf_launch_output()
414 dmap->dma_mode = DMODE_OUTPUT; in DMAbuf_launch_output()
415 adev->d->output_block(dev, dmap->raw_buf_phys + dmap->qhead * dmap->fragment_size, in DMAbuf_launch_output()
416 dmap->counts[dmap->qhead], 1); in DMAbuf_launch_output()
420 dmap->flags |= DMA_ACTIVE; in DMAbuf_launch_output()
428 struct dma_buffparms *dmap; in DMAbuf_sync() local
434 dmap = adev->dmap_out; in DMAbuf_sync()
437 if (dmap->qlen > 0 && !(dmap->flags & DMA_ACTIVE)) in DMAbuf_sync()
438 DMAbuf_launch_output(dev, dmap); in DMAbuf_sync()
443 long t = dmabuf_timeout(dmap); in DMAbuf_sync()
466 dmabuf_timeout(dmap)); in DMAbuf_sync()
508 int DMAbuf_activate_recording(int dev, struct dma_buffparms *dmap) in DMAbuf_activate_recording() argument
517 if (dmap->dma_mode == DMODE_OUTPUT) { /* Direction change */ in DMAbuf_activate_recording()
520 dmap->dma_mode = DMODE_NONE; in DMAbuf_activate_recording()
522 if (!dmap->dma_mode) { in DMAbuf_activate_recording()
523 reorganize_buffers(dev, dmap, 1); in DMAbuf_activate_recording()
525 dmap->fragment_size, dmap->nbufs)) < 0) in DMAbuf_activate_recording()
527 dmap->dma_mode = DMODE_INPUT; in DMAbuf_activate_recording()
529 if (!(dmap->flags & DMA_ACTIVE)) { in DMAbuf_activate_recording()
530 if (dmap->needs_reorg) in DMAbuf_activate_recording()
531 reorganize_buffers(dev, dmap, 0); in DMAbuf_activate_recording()
532 local_start_dma(adev, dmap->raw_buf_phys, dmap->bytes_in_use, DMA_MODE_READ); in DMAbuf_activate_recording()
533 adev->d->start_input(dev, dmap->raw_buf_phys + dmap->qtail * dmap->fragment_size, in DMAbuf_activate_recording()
534 dmap->fragment_size, 0); in DMAbuf_activate_recording()
535 dmap->flags |= DMA_ACTIVE; in DMAbuf_activate_recording()
547 struct dma_buffparms *dmap = adev->dmap_in; in DMAbuf_getrdbuffer() local
552 if (dmap->needs_reorg) in DMAbuf_getrdbuffer()
553 reorganize_buffers(dev, dmap, 0); in DMAbuf_getrdbuffer()
560 } else while (dmap->qlen <= 0 && n++ < 10) { in DMAbuf_getrdbuffer()
566 if ((err = DMAbuf_activate_recording(dev, dmap)) < 0) { in DMAbuf_getrdbuffer()
577 timeout = dmabuf_timeout(dmap); in DMAbuf_getrdbuffer()
590 if (dmap->qlen <= 0) in DMAbuf_getrdbuffer()
592 *buf = &dmap->raw_buf[dmap->qhead * dmap->fragment_size + dmap->counts[dmap->qhead]]; in DMAbuf_getrdbuffer()
593 *len = dmap->fragment_size - dmap->counts[dmap->qhead]; in DMAbuf_getrdbuffer()
595 return dmap->qhead; in DMAbuf_getrdbuffer()
601 struct dma_buffparms *dmap = adev->dmap_in; in DMAbuf_rmchars() local
602 int p = dmap->counts[dmap->qhead] + c; in DMAbuf_rmchars()
604 if (dmap->mapping_flags & DMA_MAP_MAPPED) in DMAbuf_rmchars()
609 else if (dmap->qlen <= 0) in DMAbuf_rmchars()
611 else if (p >= dmap->fragment_size) { /* This buffer is completely empty */ in DMAbuf_rmchars()
612 dmap->counts[dmap->qhead] = 0; in DMAbuf_rmchars()
613 dmap->qlen--; in DMAbuf_rmchars()
614 dmap->qhead = (dmap->qhead + 1) % dmap->nbufs; in DMAbuf_rmchars()
616 else dmap->counts[dmap->qhead] = p; in DMAbuf_rmchars()
621 int DMAbuf_get_buffer_pointer(int dev, struct dma_buffparms *dmap, int direction) in DMAbuf_get_buffer_pointer() argument
634 if (!(dmap->flags & DMA_ACTIVE)) in DMAbuf_get_buffer_pointer()
637 int chan = dmap->dma; in DMAbuf_get_buffer_pointer()
643 disable_dma(dmap->dma); in DMAbuf_get_buffer_pointer()
647 pos = dmap->bytes_in_use - pos; in DMAbuf_get_buffer_pointer()
649 if (!(dmap->mapping_flags & DMA_MAP_MAPPED)) { in DMAbuf_get_buffer_pointer()
651 if (dmap->qhead == 0) in DMAbuf_get_buffer_pointer()
652 if (pos > dmap->fragment_size) in DMAbuf_get_buffer_pointer()
655 if (dmap->qtail == 0) in DMAbuf_get_buffer_pointer()
656 if (pos > dmap->fragment_size) in DMAbuf_get_buffer_pointer()
662 if (pos >= dmap->bytes_in_use) in DMAbuf_get_buffer_pointer()
666 enable_dma(dmap->dma); in DMAbuf_get_buffer_pointer()
706 struct dma_buffparms *dmap = adev->dmap_out; in DMAbuf_space_in_queue() local
707 int lim = dmap->nbufs; in DMAbuf_space_in_queue()
712 if (dmap->qlen >= lim) /* No space at all */ in DMAbuf_space_in_queue()
720 max = dmap->max_fragments; in DMAbuf_space_in_queue()
723 len = dmap->qlen; in DMAbuf_space_in_queue()
731 if (dmap->byte_counter % dmap->fragment_size) /* There is a partial fragment */ in DMAbuf_space_in_queue()
743 struct dma_buffparms *dmap = adev->dmap_out; in output_sleep() local
757 timeout = (adev->go && !(dmap->flags & DMA_NOTIMEOUT)); in output_sleep()
759 timeout_value = dmabuf_timeout(dmap); in output_sleep()
777 struct dma_buffparms *dmap = adev->dmap_out; in find_output_space() local
782 int occupied_bytes = (dmap->user_counter % dmap->fragment_size); in find_output_space()
784 *buf = dmap->raw_buf; in find_output_space()
791 active_offs = dmap->byte_counter + dmap->qhead * dmap->fragment_size; in find_output_space()
793 active_offs = DMAbuf_get_buffer_pointer(dev, dmap, DMODE_OUTPUT); in find_output_space()
795 if (active_offs < 0 || active_offs >= dmap->bytes_in_use) in find_output_space()
797 active_offs += dmap->byte_counter; in find_output_space()
800 offs = (dmap->user_counter % dmap->bytes_in_use) & ~SAMPLE_ROUNDUP; in find_output_space()
801 if (offs < 0 || offs >= dmap->bytes_in_use) { in find_output_space()
804 printk("Counter = %ld, bytes=%d\n", dmap->user_counter, dmap->bytes_in_use); in find_output_space()
807 *buf = dmap->raw_buf + offs; in find_output_space()
809 len = active_offs + dmap->bytes_in_use - dmap->user_counter; /* Number of unused bytes in buffer */ in find_output_space()
811 if ((offs + len) > dmap->bytes_in_use) in find_output_space()
812 len = dmap->bytes_in_use - offs; in find_output_space()
817 if (len > ((maxfrags * dmap->fragment_size) - occupied_bytes)) in find_output_space()
818 len = (maxfrags * dmap->fragment_size) - occupied_bytes; in find_output_space()
829 struct dma_buffparms *dmap = adev->dmap_out; in DMAbuf_getwrbuffer() local
831 if (dmap->needs_reorg) in DMAbuf_getwrbuffer()
832 reorganize_buffers(dev, dmap, 0); in DMAbuf_getwrbuffer()
834 if (dmap->mapping_flags & DMA_MAP_MAPPED) { in DMAbuf_getwrbuffer()
838 if (dmap->dma_mode == DMODE_INPUT) { /* Direction change */ in DMAbuf_getwrbuffer()
840 dmap->dma_mode = DMODE_NONE; in DMAbuf_getwrbuffer()
842 dmap->dma_mode = DMODE_OUTPUT; in DMAbuf_getwrbuffer()
860 struct dma_buffparms *dmap = adev->dmap_out; in DMAbuf_move_wrpointer() local
861 unsigned long ptr = (dmap->user_counter / dmap->fragment_size) * dmap->fragment_size; in DMAbuf_move_wrpointer()
863 int post = (dmap->flags & DMA_POST); in DMAbuf_move_wrpointer()
865 dmap->flags &= ~DMA_POST; in DMAbuf_move_wrpointer()
866 dmap->cfrag = -1; in DMAbuf_move_wrpointer()
867 dmap->user_counter += l; in DMAbuf_move_wrpointer()
868 dmap->flags |= DMA_DIRTY; in DMAbuf_move_wrpointer()
870 if (dmap->byte_counter >= dmap->max_byte_counter) { in DMAbuf_move_wrpointer()
872 long decr = dmap->byte_counter; in DMAbuf_move_wrpointer()
873 dmap->byte_counter = (dmap->byte_counter % dmap->bytes_in_use); in DMAbuf_move_wrpointer()
874 decr -= dmap->byte_counter; in DMAbuf_move_wrpointer()
875 dmap->user_counter -= decr; in DMAbuf_move_wrpointer()
877 end_ptr = (dmap->user_counter / dmap->fragment_size) * dmap->fragment_size; in DMAbuf_move_wrpointer()
879 p = (dmap->user_counter - 1) % dmap->bytes_in_use; in DMAbuf_move_wrpointer()
880 dmap->neutral_byte = dmap->raw_buf[p]; in DMAbuf_move_wrpointer()
884 dmap->counts[dmap->qtail] = dmap->fragment_size; in DMAbuf_move_wrpointer()
885 dmap->qtail = (dmap->qtail + 1) % dmap->nbufs; in DMAbuf_move_wrpointer()
886 dmap->qlen++; in DMAbuf_move_wrpointer()
887 ptr += dmap->fragment_size; in DMAbuf_move_wrpointer()
890 dmap->counts[dmap->qtail] = dmap->user_counter - ptr; in DMAbuf_move_wrpointer()
899 if (!(dmap->flags & DMA_ACTIVE)) in DMAbuf_move_wrpointer()
900 if (dmap->qlen > 1 || (dmap->qlen > 0 && (post || dmap->qlen >= dmap->nbufs - 1))) in DMAbuf_move_wrpointer()
901 DMAbuf_launch_output(dev, dmap); in DMAbuf_move_wrpointer()
908 struct dma_buffparms *dmap = (dma_mode == DMA_MODE_WRITE) ? adev->dmap_out : adev->dmap_in; in DMAbuf_start_dma() local
910 if (dmap->raw_buf == NULL) { in DMAbuf_start_dma()
912 printk("Device %d, chn=%s\n", dev, (dmap == adev->dmap_out) ? "out" : "in"); in DMAbuf_start_dma()
915 if (dmap->dma < 0) in DMAbuf_start_dma()
917 sound_start_dma(dmap, physaddr, count, dma_mode); in DMAbuf_start_dma()
923 struct dma_buffparms *dmap = (dma_mode == DMA_MODE_WRITE) ? adev->dmap_out : adev->dmap_in; in local_start_dma() local
925 if (dmap->raw_buf == NULL) { in local_start_dma()
927 printk(KERN_ERR "Device %s, chn=%s\n", adev->name, (dmap == adev->dmap_out) ? "out" : "in"); in local_start_dma()
930 if (dmap->flags & DMA_NODMA) in local_start_dma()
932 if (dmap->dma < 0) in local_start_dma()
934 sound_start_dma(dmap, dmap->raw_buf_phys, dmap->bytes_in_use, dma_mode | DMA_AUTOINIT); in local_start_dma()
935 dmap->flags |= DMA_STARTED; in local_start_dma()
939 static void finish_output_interrupt(int dev, struct dma_buffparms *dmap) in finish_output_interrupt() argument
943 if (dmap->audio_callback != NULL) in finish_output_interrupt()
944 dmap->audio_callback(dev, dmap->callback_parm); in finish_output_interrupt()
953 struct dma_buffparms *dmap = adev->dmap_out; in do_outputintr() local
956 if (dmap->raw_buf == NULL) { in do_outputintr()
960 if (dmap->mapping_flags & DMA_MAP_MAPPED) { /* Virtual memory mapped access */ in do_outputintr()
962 dmap->qhead = (dmap->qhead + 1) % dmap->nbufs; in do_outputintr()
963 if (dmap->qhead == 0) { /* Wrapped */ in do_outputintr()
964 dmap->byte_counter += dmap->bytes_in_use; in do_outputintr()
965 if (dmap->byte_counter >= dmap->max_byte_counter) { /* Overflow */ in do_outputintr()
966 long decr = dmap->byte_counter; in do_outputintr()
967 dmap->byte_counter = (dmap->byte_counter % dmap->bytes_in_use); in do_outputintr()
968 decr -= dmap->byte_counter; in do_outputintr()
969 dmap->user_counter -= decr; in do_outputintr()
972 dmap->qlen++; /* Yes increment it (don't decrement) */ in do_outputintr()
974 dmap->flags &= ~DMA_ACTIVE; in do_outputintr()
975 dmap->counts[dmap->qhead] = dmap->fragment_size; in do_outputintr()
976 DMAbuf_launch_output(dev, dmap); in do_outputintr()
977 finish_output_interrupt(dev, dmap); in do_outputintr()
983 dmap->qlen--; in do_outputintr()
984 this_fragment = dmap->qhead; in do_outputintr()
985 dmap->qhead = (dmap->qhead + 1) % dmap->nbufs; in do_outputintr()
987 if (dmap->qhead == 0) { /* Wrapped */ in do_outputintr()
988 dmap->byte_counter += dmap->bytes_in_use; in do_outputintr()
989 if (dmap->byte_counter >= dmap->max_byte_counter) { /* Overflow */ in do_outputintr()
990 long decr = dmap->byte_counter; in do_outputintr()
991 dmap->byte_counter = (dmap->byte_counter % dmap->bytes_in_use); in do_outputintr()
992 decr -= dmap->byte_counter; in do_outputintr()
993 dmap->user_counter -= decr; in do_outputintr()
997 dmap->flags &= ~DMA_ACTIVE; in do_outputintr()
1004 while (dmap->qlen <= -dmap->closing) { in do_outputintr()
1005 dmap->underrun_count++; in do_outputintr()
1006 dmap->qlen++; in do_outputintr()
1007 if ((dmap->flags & DMA_DIRTY) && dmap->applic_profile != APF_CPUINTENS) { in do_outputintr()
1008 dmap->flags &= ~DMA_DIRTY; in do_outputintr()
1012 dmap->user_counter += dmap->fragment_size; in do_outputintr()
1013 dmap->qtail = (dmap->qtail + 1) % dmap->nbufs; in do_outputintr()
1015 if (dmap->qlen > 0) in do_outputintr()
1016 DMAbuf_launch_output(dev, dmap); in do_outputintr()
1018 finish_output_interrupt(dev, dmap); in do_outputintr()
1025 struct dma_buffparms *dmap = adev->dmap_out; in DMAbuf_outputintr() local
1029 if (!(dmap->flags & DMA_NODMA)) { in DMAbuf_outputintr()
1030 int chan = dmap->dma, pos, n; in DMAbuf_outputintr()
1036 disable_dma(dmap->dma); in DMAbuf_outputintr()
1038 pos = dmap->bytes_in_use - get_dma_residue(chan); in DMAbuf_outputintr()
1040 enable_dma(dmap->dma); in DMAbuf_outputintr()
1043 pos = pos / dmap->fragment_size; /* Actual qhead */ in DMAbuf_outputintr()
1044 if (pos < 0 || pos >= dmap->nbufs) in DMAbuf_outputintr()
1047 while (dmap->qhead != pos && n++ < dmap->nbufs) in DMAbuf_outputintr()
1058 struct dma_buffparms *dmap = adev->dmap_in; in do_inputintr() local
1060 if (dmap->raw_buf == NULL) { in do_inputintr()
1064 if (dmap->mapping_flags & DMA_MAP_MAPPED) { in do_inputintr()
1065 dmap->qtail = (dmap->qtail + 1) % dmap->nbufs; in do_inputintr()
1066 if (dmap->qtail == 0) { /* Wrapped */ in do_inputintr()
1067 dmap->byte_counter += dmap->bytes_in_use; in do_inputintr()
1068 if (dmap->byte_counter >= dmap->max_byte_counter) { /* Overflow */ in do_inputintr()
1069 long decr = dmap->byte_counter; in do_inputintr()
1070 dmap->byte_counter = (dmap->byte_counter % dmap->bytes_in_use) + dmap->bytes_in_use; in do_inputintr()
1071 decr -= dmap->byte_counter; in do_inputintr()
1072 dmap->user_counter -= decr; in do_inputintr()
1075 dmap->qlen++; in do_inputintr()
1078 if (dmap->needs_reorg) in do_inputintr()
1079 reorganize_buffers(dev, dmap, 0); in do_inputintr()
1080 local_start_dma(adev, dmap->raw_buf_phys, dmap->bytes_in_use,DMA_MODE_READ); in do_inputintr()
1081 adev->d->start_input(dev, dmap->raw_buf_phys + dmap->qtail * dmap->fragment_size, in do_inputintr()
1082 dmap->fragment_size, 1); in do_inputintr()
1086 dmap->flags |= DMA_ACTIVE; in do_inputintr()
1087 } else if (dmap->qlen >= (dmap->nbufs - 1)) { in do_inputintr()
1089 dmap->underrun_count++; in do_inputintr()
1092 dmap->qhead = (dmap->qhead + 1) % dmap->nbufs; in do_inputintr()
1093 dmap->qtail = (dmap->qtail + 1) % dmap->nbufs; in do_inputintr()
1094 } else if (dmap->qlen >= 0 && dmap->qlen < dmap->nbufs) { in do_inputintr()
1095 dmap->qlen++; in do_inputintr()
1096 dmap->qtail = (dmap->qtail + 1) % dmap->nbufs; in do_inputintr()
1097 if (dmap->qtail == 0) { /* Wrapped */ in do_inputintr()
1098 dmap->byte_counter += dmap->bytes_in_use; in do_inputintr()
1099 if (dmap->byte_counter >= dmap->max_byte_counter) { /* Overflow */ in do_inputintr()
1100 long decr = dmap->byte_counter; in do_inputintr()
1101 dmap->byte_counter = (dmap->byte_counter % dmap->bytes_in_use) + dmap->bytes_in_use; in do_inputintr()
1102 decr -= dmap->byte_counter; in do_inputintr()
1103 dmap->user_counter -= decr; in do_inputintr()
1107 if (!(adev->flags & DMA_AUTOMODE) || (dmap->flags & DMA_NODMA)) { in do_inputintr()
1108 local_start_dma(adev, dmap->raw_buf_phys, dmap->bytes_in_use, DMA_MODE_READ); in do_inputintr()
1109 …adev->d->start_input(dev, dmap->raw_buf_phys + dmap->qtail * dmap->fragment_size, dmap->fragment_s… in do_inputintr()
1113 dmap->flags |= DMA_ACTIVE; in do_inputintr()
1114 if (dmap->qlen > 0) in do_inputintr()
1124 struct dma_buffparms *dmap = adev->dmap_in; in DMAbuf_inputintr() local
1130 if (!(dmap->flags & DMA_NODMA)) { in DMAbuf_inputintr()
1131 int chan = dmap->dma, pos, n; in DMAbuf_inputintr()
1136 disable_dma(dmap->dma); in DMAbuf_inputintr()
1138 pos = dmap->bytes_in_use - get_dma_residue(chan); in DMAbuf_inputintr()
1140 enable_dma(dmap->dma); in DMAbuf_inputintr()
1143 pos = pos / dmap->fragment_size; /* Actual qhead */ in DMAbuf_inputintr()
1144 if (pos < 0 || pos >= dmap->nbufs) in DMAbuf_inputintr()
1148 while (dmap->qtail != pos && ++n < dmap->nbufs) in DMAbuf_inputintr()
1228 struct dma_buffparms *dmap = adev->dmap_in; in poll_input() local
1232 if (dmap->mapping_flags & DMA_MAP_MAPPED) { in poll_input()
1233 if (dmap->qlen) in poll_input()
1237 if (dmap->dma_mode != DMODE_INPUT) { in poll_input()
1238 if (dmap->dma_mode == DMODE_NONE && in poll_input()
1240 !dmap->qlen && adev->go) { in poll_input()
1245 DMAbuf_activate_recording(dev, dmap); in poll_input()
1250 if (!dmap->qlen) in poll_input()
1258 struct dma_buffparms *dmap = adev->dmap_out; in poll_output() local
1262 if (dmap->mapping_flags & DMA_MAP_MAPPED) { in poll_output()
1263 if (dmap->qlen) in poll_output()
1267 if (dmap->dma_mode == DMODE_INPUT) in poll_output()
1269 if (dmap->dma_mode == DMODE_NONE) in poll_output()