Lines Matching refs:db
537 struct dmabuf* db = &s->dma_adc; in stop_adc() local
541 if (db->stopped) in stop_adc()
554 db->stopped = 1; in stop_adc()
561 struct dmabuf* db = &s->dma_dac; in stop_dac() local
565 if (db->stopped) in stop_dac()
578 db->stopped = 1; in stop_dac()
585 struct dmabuf* db = &s->dma_dac; in start_dac() local
590 if (!db->stopped) in start_dac()
596 buf1 = virt_to_bus(db->nextOut); in start_dac()
597 buf2 = buf1 + db->fragsize; in start_dac()
598 if (buf2 >= db->dmaaddr + db->dmasize) in start_dac()
599 buf2 -= db->dmasize; in start_dac()
603 db->curBufPtr = IT_AC_PCB1STA; in start_dac()
613 db->stopped = 0; in start_dac()
620 struct dmabuf* db = &s->dma_adc; in start_adc() local
625 if (!db->stopped) in start_adc()
631 buf1 = virt_to_bus(db->nextIn); in start_adc()
632 buf2 = buf1 + db->fragsize; in start_adc()
633 if (buf2 >= db->dmaaddr + db->dmasize) in start_adc()
634 buf2 -= db->dmasize; in start_adc()
638 db->curBufPtr = IT_AC_CAPB1STA; in start_adc()
648 db->stopped = 0; in start_adc()
658 static inline void dealloc_dmabuf(struct it8172_state *s, struct dmabuf *db) in dealloc_dmabuf() argument
662 if (db->rawbuf) { in dealloc_dmabuf()
664 pend = virt_to_page(db->rawbuf + in dealloc_dmabuf()
665 (PAGE_SIZE << db->buforder) - 1); in dealloc_dmabuf()
666 for (page = virt_to_page(db->rawbuf); page <= pend; page++) in dealloc_dmabuf()
668 pci_free_consistent(s->dev, PAGE_SIZE << db->buforder, in dealloc_dmabuf()
669 db->rawbuf, db->dmaaddr); in dealloc_dmabuf()
671 db->rawbuf = db->nextIn = db->nextOut = NULL; in dealloc_dmabuf()
672 db->mapped = db->ready = 0; in dealloc_dmabuf()
675 static int prog_dmabuf(struct it8172_state *s, struct dmabuf *db, in prog_dmabuf() argument
683 if (!db->rawbuf) { in prog_dmabuf()
684 db->ready = db->mapped = 0; in prog_dmabuf()
687 if ((db->rawbuf = in prog_dmabuf()
690 &db->dmaaddr))) in prog_dmabuf()
692 if (!db->rawbuf) in prog_dmabuf()
694 db->buforder = order; in prog_dmabuf()
697 pend = virt_to_page(db->rawbuf + in prog_dmabuf()
698 (PAGE_SIZE << db->buforder) - 1); in prog_dmabuf()
699 for (page = virt_to_page(db->rawbuf); page <= pend; page++) in prog_dmabuf()
703 db->count = 0; in prog_dmabuf()
704 db->nextIn = db->nextOut = db->rawbuf; in prog_dmabuf()
707 bufs = PAGE_SIZE << db->buforder; in prog_dmabuf()
708 if (db->ossfragshift) { in prog_dmabuf()
709 if ((1000 << db->ossfragshift) < bytepersec) in prog_dmabuf()
710 db->fragshift = ld2(bytepersec/1000); in prog_dmabuf()
712 db->fragshift = db->ossfragshift; in prog_dmabuf()
714 db->fragshift = ld2(bytepersec/100/(db->subdivision ? in prog_dmabuf()
715 db->subdivision : 1)); in prog_dmabuf()
716 if (db->fragshift < 3) in prog_dmabuf()
717 db->fragshift = 3; in prog_dmabuf()
719 db->numfrag = bufs >> db->fragshift; in prog_dmabuf()
720 while (db->numfrag < 4 && db->fragshift > 3) { in prog_dmabuf()
721 db->fragshift--; in prog_dmabuf()
722 db->numfrag = bufs >> db->fragshift; in prog_dmabuf()
724 db->fragsize = 1 << db->fragshift; in prog_dmabuf()
725 if (db->ossmaxfrags >= 4 && db->ossmaxfrags < db->numfrag) in prog_dmabuf()
726 db->numfrag = db->ossmaxfrags; in prog_dmabuf()
727 db->fragsamples = db->fragsize >> sample_shift[fmt]; in prog_dmabuf()
728 db->dmasize = db->numfrag << db->fragshift; in prog_dmabuf()
729 memset(db->rawbuf, (fmt & (CC_DF>>CC_FMT_BIT)) ? 0 : 0x80, bufs); in prog_dmabuf()
733 rate, db->fragsize, db->numfrag, db->dmasize); in prog_dmabuf()
737 outw(db->fragsize, s->io+reg+2); in prog_dmabuf()
738 db->ready = 1; in prog_dmabuf()
1050 static int copy_dmabuf_user(struct dmabuf *db, char* userbuf, in copy_dmabuf_user() argument
1053 char* bufptr = to_user ? db->nextOut : db->nextIn; in copy_dmabuf_user()
1054 char* bufend = db->rawbuf + db->dmasize; in copy_dmabuf_user()
1061 if (copy_to_user(userbuf + partial, db->rawbuf, in copy_dmabuf_user()
1067 if (copy_from_user(db->rawbuf, in copy_dmabuf_user()
1090 struct dmabuf *db = &s->dma_adc; in it8172_read() local
1097 if (db->mapped) in it8172_read()
1107 if (db->stopped) in it8172_read()
1109 avail = db->count; in it8172_read()
1117 interruptible_sleep_on(&db->wait); in it8172_read()
1127 if ((cnt = copy_dmabuf_user(db, buffer, count > avail ? in it8172_read()
1135 db->count -= cnt; in it8172_read()
1138 db->nextOut += cnt; in it8172_read()
1139 if (db->nextOut >= db->rawbuf + db->dmasize) in it8172_read()
1140 db->nextOut -= db->dmasize; in it8172_read()
1157 remainder = db->count % db->fragsize; in it8172_read()
1159 db->nextOut += remainder; in it8172_read()
1160 if (db->nextOut >= db->rawbuf + db->dmasize) in it8172_read()
1161 db->nextOut -= db->dmasize; in it8172_read()
1162 db->count -= remainder; in it8172_read()
1173 struct dmabuf *db = &s->dma_dac; in it8172_write() local
1180 if (db->mapped) in it8172_write()
1190 avail = db->dmasize - db->count; in it8172_write()
1198 interruptible_sleep_on(&db->wait); in it8172_write()
1208 if ((cnt = copy_dmabuf_user(db, (char*)buffer, in it8172_write()
1217 db->count += cnt; in it8172_write()
1218 if (db->stopped) in it8172_write()
1222 db->nextIn += cnt; in it8172_write()
1223 if (db->nextIn >= db->rawbuf + db->dmasize) in it8172_write()
1224 db->nextIn -= db->dmasize; in it8172_write()
1241 remainder = db->count % db->fragsize; in it8172_write()
1243 int fill_cnt = db->fragsize - remainder; in it8172_write()
1244 memset(db->nextIn, 0, fill_cnt); in it8172_write()
1245 db->nextIn += fill_cnt; in it8172_write()
1246 if (db->nextIn >= db->rawbuf + db->dmasize) in it8172_write()
1247 db->nextIn -= db->dmasize; in it8172_write()
1248 db->count += fill_cnt; in it8172_write()
1296 struct dmabuf *db; in it8172_mmap() local
1301 db = &s->dma_dac; in it8172_mmap()
1303 db = &s->dma_adc; in it8172_mmap()
1313 if (size > (PAGE_SIZE << db->buforder)) { in it8172_mmap()
1317 if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), in it8172_mmap()
1322 db->mapped = 1; in it8172_mmap()