Lines Matching refs:dmap

138 	struct dma_buffparms *dmap = audio_devs[dev]->dmap_out;  in sync_output()  local
140 if (dmap->fragment_size <= 0) in sync_output()
142 dmap->flags |= DMA_POST; in sync_output()
146 if ((l = dmap->user_counter % dmap->fragment_size) > 0) in sync_output()
149 unsigned long offs = dmap->user_counter % dmap->bytes_in_use; in sync_output()
151 len = dmap->fragment_size - l; in sync_output()
152 memset(dmap->raw_buf + offs, dmap->neutral_byte, len); in sync_output()
160 p = dmap->qtail; in sync_output()
161 dmap->flags |= DMA_POST; in sync_output()
163 for (i = dmap->qlen + 1; i < dmap->nbufs; i++) in sync_output()
165 p = (p + 1) % dmap->nbufs; in sync_output()
166 if (((dmap->raw_buf + p * dmap->fragment_size) + dmap->fragment_size) > in sync_output()
167 (dmap->raw_buf + dmap->buffsize)) in sync_output()
170 memset(dmap->raw_buf + p * dmap->fragment_size, in sync_output()
171 dmap->neutral_byte, in sync_output()
172 dmap->fragment_size); in sync_output()
175 dmap->flags |= DMA_DIRTY; in sync_output()
383 struct dma_buffparms *dmap; in audio_ioctl() local
509 dmap = audio_devs[dev]->dmap_out; in audio_ioctl()
512 if (!(dmap->flags & DMA_ALLOC_DONE)) in audio_ioctl()
521 count = DMAbuf_get_buffer_pointer (dev, dmap, DMODE_OUTPUT); in audio_ioctl()
522 if (count < dmap->fragment_size && dmap->qhead != 0) in audio_ioctl()
523 count += dmap->bytes_in_use; /* Pointer wrap not handled yet */ in audio_ioctl()
524 count += dmap->byte_counter; in audio_ioctl()
527 count = dmap->user_counter - count; in audio_ioctl()
547 void reorganize_buffers(int dev, struct dma_buffparms *dmap, int recording) in reorganize_buffers() argument
563 dmap->neutral_byte = NEUTRAL8; in reorganize_buffers()
565 dmap->neutral_byte = NEUTRAL16; in reorganize_buffers()
578 dmap->data_rate = sz; in reorganize_buffers()
580 if (!dmap->needs_reorg) in reorganize_buffers()
582 dmap->needs_reorg = 0; in reorganize_buffers()
584 if (dmap->fragment_size == 0) in reorganize_buffers()
594 bsz = dmap->buffsize; in reorganize_buffers()
598 if (bsz == dmap->buffsize) in reorganize_buffers()
607 if (dmap->subdivision == 0) /* Not already set */ in reorganize_buffers()
609 dmap->subdivision = 4; /* Init to the default value */ in reorganize_buffers()
611 if ((bsz / dmap->subdivision) > 4096) in reorganize_buffers()
612 dmap->subdivision *= 2; in reorganize_buffers()
613 if ((bsz / dmap->subdivision) < 4096) in reorganize_buffers()
614 dmap->subdivision = 1; in reorganize_buffers()
616 bsz /= dmap->subdivision; in reorganize_buffers()
621 dmap->fragment_size = bsz; in reorganize_buffers()
629 if (dmap->fragment_size > (dmap->buffsize / 2)) in reorganize_buffers()
630 dmap->fragment_size = (dmap->buffsize / 2); in reorganize_buffers()
631 bsz = dmap->fragment_size; in reorganize_buffers()
645 n = dmap->buffsize / bsz; in reorganize_buffers()
648 if (n > dmap->max_fragments) in reorganize_buffers()
649 n = dmap->max_fragments; in reorganize_buffers()
656 dmap->nbufs = n; in reorganize_buffers()
657 dmap->bytes_in_use = n * bsz; in reorganize_buffers()
658 dmap->fragment_size = bsz; in reorganize_buffers()
659 dmap->max_byte_counter = (dmap->data_rate * 60 * 60) + in reorganize_buffers()
660 dmap->bytes_in_use; /* Approximately one hour */ in reorganize_buffers()
662 if (dmap->raw_buf) in reorganize_buffers()
664 memset(dmap->raw_buf, dmap->neutral_byte, dmap->bytes_in_use); in reorganize_buffers()
667 for (i = 0; i < dmap->nbufs; i++) in reorganize_buffers()
669 dmap->counts[i] = 0; in reorganize_buffers()
672 dmap->flags |= DMA_ALLOC_DONE | DMA_EMPTY; in reorganize_buffers()
675 static int dma_subdivide(int dev, struct dma_buffparms *dmap, int fact) in dma_subdivide() argument
679 fact = dmap->subdivision; in dma_subdivide()
684 if (dmap->subdivision != 0 || dmap->fragment_size) /* Too late to change */ in dma_subdivide()
693 dmap->subdivision = fact; in dma_subdivide()
697 static int dma_set_fragment(int dev, struct dma_buffparms *dmap, int fact) in dma_set_fragment() argument
704 if (dmap->subdivision != 0 || in dma_set_fragment()
705 dmap->fragment_size) /* Too late to change */ in dma_set_fragment()
735 dmap->fragment_size = (1 << bytes); in dma_set_fragment()
736 dmap->max_fragments = count; in dma_set_fragment()
738 if (dmap->fragment_size > dmap->buffsize) in dma_set_fragment()
739 dmap->fragment_size = dmap->buffsize; in dma_set_fragment()
741 if (dmap->fragment_size == dmap->buffsize && in dma_set_fragment()
743 dmap->fragment_size /= 2; /* Needs at least 2 buffers */ in dma_set_fragment()
745 dmap->subdivision = 1; /* Disable SNDCTL_DSP_SUBDIVIDE */ in dma_set_fragment()
753 struct dma_buffparms *dmap; in dma_ioctl() local
779 dmap = dmap_out; in dma_ioctl()
785 dmap = dmap_in; in dma_ioctl()
786 if (dmap->mapping_flags & DMA_MAP_MAPPED) in dma_ioctl()
788 if (!(dmap->flags & DMA_ALLOC_DONE)) in dma_ioctl()
789 reorganize_buffers(dev, dmap, (cmd == SNDCTL_DSP_GETISPACE)); in dma_ioctl()
790 info.fragstotal = dmap->nbufs; in dma_ioctl()
792 info.fragments = dmap->qlen; in dma_ioctl()
813 else if (info.fragments > dmap->nbufs) in dma_ioctl()
814 info.fragments = dmap->nbufs; in dma_ioctl()
816 info.fragsize = dmap->fragment_size; in dma_ioctl()
817 info.bytes = info.fragments * dmap->fragment_size; in dma_ioctl()
819 if (cmd == SNDCTL_DSP_GETISPACE && dmap->qlen) in dma_ioctl()
820 info.bytes -= dmap->counts[dmap->qhead]; in dma_ioctl()
823 info.fragments = info.bytes / dmap->fragment_size; in dma_ioctl()
824 info.bytes -= dmap->user_counter % dmap->fragment_size; in dma_ioctl()
951 dmap = dmap_out; in dma_ioctl()
959 dmap = dmap_in; in dma_ioctl()
960 ret = dmap->fragment_size; in dma_ioctl()