Lines Matching refs:dmap
139 struct dma_buffparms *dmap = audio_devs[dev]->dmap_out; in sync_output() local
141 if (dmap->fragment_size <= 0) in sync_output()
143 dmap->flags |= DMA_POST; in sync_output()
147 if ((l = dmap->user_counter % dmap->fragment_size) > 0) in sync_output()
150 unsigned long offs = dmap->user_counter % dmap->bytes_in_use; in sync_output()
152 len = dmap->fragment_size - l; in sync_output()
153 memset(dmap->raw_buf + offs, dmap->neutral_byte, len); in sync_output()
161 p = dmap->qtail; in sync_output()
162 dmap->flags |= DMA_POST; in sync_output()
164 for (i = dmap->qlen + 1; i < dmap->nbufs; i++) in sync_output()
166 p = (p + 1) % dmap->nbufs; in sync_output()
167 if (((dmap->raw_buf + p * dmap->fragment_size) + dmap->fragment_size) > in sync_output()
168 (dmap->raw_buf + dmap->buffsize)) in sync_output()
171 memset(dmap->raw_buf + p * dmap->fragment_size, in sync_output()
172 dmap->neutral_byte, in sync_output()
173 dmap->fragment_size); in sync_output()
176 dmap->flags |= DMA_DIRTY; in sync_output()
372 struct dma_buffparms *dmap; in audio_ioctl() local
501 dmap = audio_devs[dev]->dmap_out; in audio_ioctl()
504 if (!(dmap->flags & DMA_ALLOC_DONE)) in audio_ioctl()
510 spin_lock_irqsave(&dmap->lock,flags); in audio_ioctl()
512 count = DMAbuf_get_buffer_pointer (dev, dmap, DMODE_OUTPUT); in audio_ioctl()
513 if (count < dmap->fragment_size && dmap->qhead != 0) in audio_ioctl()
514 count += dmap->bytes_in_use; /* Pointer wrap not handled yet */ in audio_ioctl()
515 count += dmap->byte_counter; in audio_ioctl()
518 count = dmap->user_counter - count; in audio_ioctl()
521 spin_unlock_irqrestore(&dmap->lock,flags); in audio_ioctl()
538 void reorganize_buffers(int dev, struct dma_buffparms *dmap, int recording) in reorganize_buffers() argument
554 dmap->neutral_byte = NEUTRAL8; in reorganize_buffers()
556 dmap->neutral_byte = NEUTRAL16; in reorganize_buffers()
569 dmap->data_rate = sz; in reorganize_buffers()
571 if (!dmap->needs_reorg) in reorganize_buffers()
573 dmap->needs_reorg = 0; in reorganize_buffers()
575 if (dmap->fragment_size == 0) in reorganize_buffers()
585 bsz = dmap->buffsize; in reorganize_buffers()
589 if (bsz == dmap->buffsize) in reorganize_buffers()
598 if (dmap->subdivision == 0) /* Not already set */ in reorganize_buffers()
600 dmap->subdivision = 4; /* Init to the default value */ in reorganize_buffers()
602 if ((bsz / dmap->subdivision) > 4096) in reorganize_buffers()
603 dmap->subdivision *= 2; in reorganize_buffers()
604 if ((bsz / dmap->subdivision) < 4096) in reorganize_buffers()
605 dmap->subdivision = 1; in reorganize_buffers()
607 bsz /= dmap->subdivision; in reorganize_buffers()
612 dmap->fragment_size = bsz; in reorganize_buffers()
620 if (dmap->fragment_size > (dmap->buffsize / 2)) in reorganize_buffers()
621 dmap->fragment_size = (dmap->buffsize / 2); in reorganize_buffers()
622 bsz = dmap->fragment_size; in reorganize_buffers()
636 n = dmap->buffsize / bsz; in reorganize_buffers()
639 if (n > dmap->max_fragments) in reorganize_buffers()
640 n = dmap->max_fragments; in reorganize_buffers()
647 dmap->nbufs = n; in reorganize_buffers()
648 dmap->bytes_in_use = n * bsz; in reorganize_buffers()
649 dmap->fragment_size = bsz; in reorganize_buffers()
650 dmap->max_byte_counter = (dmap->data_rate * 60 * 60) + in reorganize_buffers()
651 dmap->bytes_in_use; /* Approximately one hour */ in reorganize_buffers()
653 if (dmap->raw_buf) in reorganize_buffers()
655 memset(dmap->raw_buf, dmap->neutral_byte, dmap->bytes_in_use); in reorganize_buffers()
658 for (i = 0; i < dmap->nbufs; i++) in reorganize_buffers()
660 dmap->counts[i] = 0; in reorganize_buffers()
663 dmap->flags |= DMA_ALLOC_DONE | DMA_EMPTY; in reorganize_buffers()
666 static int dma_subdivide(int dev, struct dma_buffparms *dmap, int fact) in dma_subdivide() argument
670 fact = dmap->subdivision; in dma_subdivide()
675 if (dmap->subdivision != 0 || dmap->fragment_size) /* Too late to change */ in dma_subdivide()
684 dmap->subdivision = fact; in dma_subdivide()
688 static int dma_set_fragment(int dev, struct dma_buffparms *dmap, int fact) in dma_set_fragment() argument
695 if (dmap->subdivision != 0 || in dma_set_fragment()
696 dmap->fragment_size) /* Too late to change */ in dma_set_fragment()
726 dmap->fragment_size = (1 << bytes); in dma_set_fragment()
727 dmap->max_fragments = count; in dma_set_fragment()
729 if (dmap->fragment_size > dmap->buffsize) in dma_set_fragment()
730 dmap->fragment_size = dmap->buffsize; in dma_set_fragment()
732 if (dmap->fragment_size == dmap->buffsize && in dma_set_fragment()
734 dmap->fragment_size /= 2; /* Needs at least 2 buffers */ in dma_set_fragment()
736 dmap->subdivision = 1; /* Disable SNDCTL_DSP_SUBDIVIDE */ in dma_set_fragment()
744 struct dma_buffparms *dmap; in dma_ioctl() local
770 dmap = dmap_out; in dma_ioctl()
776 dmap = dmap_in; in dma_ioctl()
777 if (dmap->mapping_flags & DMA_MAP_MAPPED) in dma_ioctl()
779 if (!(dmap->flags & DMA_ALLOC_DONE)) in dma_ioctl()
780 reorganize_buffers(dev, dmap, (cmd == SNDCTL_DSP_GETISPACE)); in dma_ioctl()
781 info.fragstotal = dmap->nbufs; in dma_ioctl()
783 info.fragments = dmap->qlen; in dma_ioctl()
804 else if (info.fragments > dmap->nbufs) in dma_ioctl()
805 info.fragments = dmap->nbufs; in dma_ioctl()
807 info.fragsize = dmap->fragment_size; in dma_ioctl()
808 info.bytes = info.fragments * dmap->fragment_size; in dma_ioctl()
810 if (cmd == SNDCTL_DSP_GETISPACE && dmap->qlen) in dma_ioctl()
811 info.bytes -= dmap->counts[dmap->qhead]; in dma_ioctl()
814 info.fragments = info.bytes / dmap->fragment_size; in dma_ioctl()
815 info.bytes -= dmap->user_counter % dmap->fragment_size; in dma_ioctl()
949 dmap = dmap_out; in dma_ioctl()
957 dmap = dmap_in; in dma_ioctl()
958 ret = dmap->fragment_size; in dma_ioctl()