Lines Matching refs:wport
1511 vwsnd_port_t wport;
1623 vwsnd_port_t *wport)
1625 vwsnd_port_t *aport = rport ? rport : wport;
1629 DBGEV("(devc=0x%p, rport=0x%p, wport=0x%p)\n", devc, rport, wport);
1687 if (wport) {
1690 wport->hwbuf_max = aport->hwbuf_size - DMACHUNK_SIZE;
1691 if (wport->hwbuf_max > total_bytes)
1692 wport->hwbuf_max = total_bytes;
1693 hwfrags = wport->hwbuf_max >> aport->hw_fragshift;
1698 wport->swbuf_size = swfrags * aport->hw_fragsize;
1701 wport->hwbuf_max, wport->swbuf_size);
1720 if (rport && wport) {
1722 ASSERT(wport->swbuf == NULL);
1724 wport->swbuf = vmalloc(aport->swbuf_size + PAGE_SIZE);
1725 if (!wport->swbuf) {
1730 wport->sample_size = rport->sample_size;
1731 wport->zero_word = rport->zero_word;
1732 wport->frame_size = rport->frame_size;
1733 wport->hw_fragshift = rport->hw_fragshift;
1734 wport->hw_fragsize = rport->hw_fragsize;
1735 wport->hw_fragcount = rport->hw_fragcount;
1736 wport->swbuf_size = rport->swbuf_size;
1737 wport->hwbuf_max = rport->hwbuf_max;
1738 wport->swb_u_idx = rport->swb_u_idx;
1739 wport->swb_i_idx = rport->swb_i_idx;
1740 wport->byte_count = rport->byte_count;
1767 if (wport) {
1768 if (wport->hwbuf_max > wport->swbuf_size)
1769 wport->hwbuf_max = wport->swbuf_size;
1770 wport->flags &= ~ERFLOWN;
1771 wport->swb_u_avail = wport->swbuf_size;
1772 wport->swb_i_avail = 0;
1773 wport->swstate = SW_RUN;
1774 li_setup_dma(&wport->chan,
1777 wport->hwbuf_paddr,
1779 wport->hw_fragshift,
1780 wport->sw_channels,
1781 wport->sample_size);
1783 wport->sw_framerate,
1784 wport->sw_samplefmt,
1785 wport->sw_channels);
1823 else /* aport == &devc->wport) */
1838 vwsnd_port_t *wport)
1840 DBGEV("(devc=0x%p, rport=0x%p, wport=0x%p)\n", devc, rport, wport);
1846 if (wport && wport->swbuf) {
1847 DBGPV("shutting down wport\n");
1848 pcm_shutdown_port(devc, wport, WRITE_INTR_MASK);
1878 static void pcm_copy_out(vwsnd_port_t *wport, int swidx, int hwidx, int nb)
1880 char *src = wport->swbuf + swidx;
1881 char *dst = wport->hwbuf + hwidx;
1882 int fmt = wport->sw_samplefmt;
1885 ASSERT(wport->hwbuf != NULL);
1886 ASSERT(wport->swbuf != NULL);
1888 ASSERT(swidx >= 0 && swidx + nb <= wport->swbuf_size);
1889 ASSERT(hwidx >= 0 && hwidx + nb <= wport->hwbuf_size);
1907 * holds wport->lock. The longer part releases wport->lock, but sets
1908 * wport->flags & HW_BUSY. Afterward, it reacquires wport->lock, and
1922 vwsnd_port_t *wport = &devc->wport;
1923 const int hwmax = wport->hwbuf_max;
1924 const int hwsize = wport->hwbuf_size;
1925 const int swsize = wport->swbuf_size;
1926 const int fragsize = wport->hw_fragsize;
1930 spin_lock_irqsave(&wport->lock, iflags);
1932 wport->flags |= ERFLOWN;
1933 (void) __swb_inc_u(wport, nb);
1934 if (wport->flags & HW_BUSY) {
1935 spin_unlock_irqrestore(&wport->lock, iflags);
1939 if (wport->flags & DISABLED) {
1940 spin_unlock_irqrestore(&wport->lock, iflags);
1944 wport->flags |= HW_BUSY;
1947 vwsnd_port_hwstate_t hwstate = wport->hwstate;
1948 vwsnd_port_swstate_t swstate = wport->swstate;
1952 hwptr = li_read_hwptr(&wport->chan);
1953 swptr = li_read_swptr(&wport->chan);
1956 sw_avail = wport->swb_i_avail & -fragsize;
1958 if (wport->flags & ERFLOWN) {
1959 wport->flags &= ~ERFLOWN;
1965 (wport->flags & ERFLOWN))) {
1968 li_deactivate_dma(&wport->chan);
1969 wport->hwstate = HW_STOPPED;
1971 wake_up(&wport->queue);
1976 spin_unlock_irqrestore(&wport->lock, iflags);
1984 swidx = wport->swb_i_idx;
2003 pcm_copy_out(wport, swidx, swptr, nb);
2004 li_write_swptr(&wport->chan, (swptr + nb) % hwsize);
2005 spin_lock_irqsave(&wport->lock, iflags);
2008 li_activate_dma(&wport->chan);
2009 wport->hwstate = HW_RUNNING;
2010 li_read_USTMSC(&wport->chan, &ustmsc);
2011 ASSERT(wport->byte_count % wport->frame_size == 0);
2012 wport->MSC_offset = ustmsc.msc - wport->byte_count / wport->frame_size;
2014 __swb_inc_i(wport, nb);
2015 wport->byte_count += nb;
2016 wport->frag_count += nb / fragsize;
2018 wake_up(&wport->queue);
2020 wport->flags &= ~HW_BUSY;
2021 spin_unlock_irqrestore(&wport->lock, iflags);
2142 vwsnd_port_t *wport = &devc->wport;
2144 DBGPV("swstate = %d\n", wport->swstate);
2145 if (wport->swstate == SW_RUN) {
2146 int idx = wport->swb_u_idx;
2147 int end = (idx + wport->hw_fragsize - 1)
2148 >> wport->hw_fragshift
2149 << wport->hw_fragshift;
2153 memset(wport->swbuf + idx,
2154 (char) wport->zero_word,
2156 wport->swstate = SW_DRAIN;
2170 vwsnd_port_t *wport = &devc->wport;
2176 add_wait_queue(&wport->queue, &wait);
2179 spin_lock_irqsave(&wport->lock, flags);
2181 hwstate = wport->hwstate;
2183 spin_unlock_irqrestore(&wport->lock, flags);
2189 remove_wait_queue(&wport->queue, &wait);
2190 DBGPV("swstate = %d, hwstate = %d\n", wport->swstate, wport->hwstate);
2247 vwsnd_port_t *wport = (file->f_mode & FMODE_WRITE) ?
2248 &devc->wport : NULL;
2249 ret = pcm_setup(devc, rport, wport);
2314 vwsnd_port_t *wport = ((file->f_mode & FMODE_WRITE) ?
2315 &devc->wport : NULL);
2321 if (!wport)
2324 if (wport->swbuf == NULL) {
2327 ret = pcm_setup(devc, rport, wport);
2336 add_wait_queue(&wport->queue, &wait);
2337 while ((nb = swb_inc_u(wport, 0)) == 0) {
2339 if (wport->flags & DISABLED ||
2342 remove_wait_queue(&wport->queue, &wait);
2348 remove_wait_queue(&wport->queue, &wait);
2353 remove_wait_queue(&wport->queue, &wait);
2358 if (copy_from_user(wport->swbuf + wport->swb_u_idx, buffer, nb))
2390 vwsnd_port_t *wport = (file->f_mode & FMODE_WRITE) ?
2391 &devc->wport : NULL;
2396 ASSERT(rport || wport);
2402 if (wport) {
2403 poll_wait(file, &wport->queue, wait);
2404 if (wport->swbuf == NULL || swb_inc_u(wport, 0))
2419 vwsnd_port_t *wport = (file->f_mode & FMODE_WRITE) ?
2420 &devc->wport : NULL;
2421 vwsnd_port_t *aport = rport ? rport : wport;
2474 if (wport)
2475 wport->sw_framerate = ival;
2490 if (wport)
2491 wport->sw_channels = ival + 1;
2504 if (wport)
2505 wport->sw_channels = ival;
2509 ival = pcm_setup(devc, rport, wport);
2542 DBGPV("rport = 0x%p, wport = 0x%p\n", rport, wport);
2547 if (wport) {
2548 wport->sw_fragshift = sw_fragshift;
2549 wport->sw_fragcount = sw_fragcount;
2583 if (wport)
2584 wport->sw_subdivshift = subdivshift;
2606 if (wport)
2607 wport->sw_samplefmt = ival;
2618 if (!wport)
2620 ival = pcm_setup(devc, rport, wport);
2623 ival = swb_inc_u(wport, 0);
2624 buf_info.fragments = ival >> wport->sw_fragshift;
2625 buf_info.fragstotal = wport->sw_fragcount;
2626 buf_info.fragsize = 1 << wport->sw_fragshift;
2639 ival = pcm_setup(devc, rport, wport);
2668 if (wport && wport->swbuf) {
2669 wport->swstate = SW_INITIAL;
2673 pcm_shutdown(devc, rport, wport);
2678 if (wport) {
2682 pcm_shutdown(devc, rport, wport);
2687 if (!wport)
2718 if (!wport)
2720 spin_lock_irqsave(&wport->lock, flags);
2723 if (wport->hwstate == HW_RUNNING) {
2724 ASSERT(wport->swstate == SW_RUN);
2725 li_read_USTMSC(&wport->chan, &ustmsc);
2726 info.bytes = ustmsc.msc - wport->MSC_offset;
2727 info.bytes *= wport->frame_size;
2729 info.bytes = wport->byte_count;
2731 info.blocks = wport->frag_count;
2733 wport->frag_count = 0;
2735 spin_unlock_irqrestore(&wport->lock, flags);
2742 if (!wport)
2744 spin_lock_irqsave(&wport->lock, flags);
2746 int fsize = wport->frame_size;
2747 ival = wport->swb_i_avail / fsize;
2748 if (wport->hwstate == HW_RUNNING) {
2753 hwsize = wport->hwbuf_size;
2754 swptr = li_read_swptr(&wport->chan);
2755 li_read_USTMSC(&wport->chan, &ustmsc);
2756 hwframes = ustmsc.msc - wport->MSC_offset;
2763 spin_unlock_irqrestore(&wport->lock, flags);
2797 if (wport) {
2798 spin_lock_irqsave(&wport->lock, flags);
2800 if (!(wport->flags & DISABLED))
2803 spin_unlock_irqrestore(&wport->lock, flags);
2818 (wport && !(ival & PCM_ENABLE_OUTPUT))) &&
2836 pcm_setup(devc, rport, wport);
2841 if (wport) {
2843 spin_lock_irqsave(&wport->lock, flags);
2845 pflags = wport->flags;
2847 wport->flags &= ~DISABLED;
2849 wport->flags |= DISABLED;
2851 spin_unlock_irqrestore(&wport->lock, flags);
2853 if (wport->swstate == SW_RUN)
2965 devc->wport.swstate = SW_INITIAL;
2966 devc->wport.flags = 0;
2967 devc->wport.sw_channels = 1;
2968 devc->wport.sw_samplefmt = sw_samplefmt;
2969 devc->wport.sw_framerate = 8000;
2970 devc->wport.sw_fragshift = DEFAULT_FRAGSHIFT;
2971 devc->wport.sw_fragcount = DEFAULT_FRAGCOUNT;
2972 devc->wport.sw_subdivshift = DEFAULT_SUBDIVSHIFT;
2973 devc->wport.byte_count = 0;
2974 devc->wport.frag_count = 0;
2992 vwsnd_port_t *wport = NULL, *rport = NULL;
3003 wport = &devc->wport;
3007 pcm_shutdown(devc, rport, wport);
3010 if (wport)
3011 wport->swstate = SW_OFF;
3176 if (devc->rport.swbuf || devc->wport.swbuf)
3326 devc->wport.hwbuf_size = HWBUF_SIZE;
3327 devc->wport.hwbuf_vaddr = __get_free_pages(GFP_KERNEL, HWBUF_ORDER);
3328 if (!devc->wport.hwbuf_vaddr)
3330 devc->wport.hwbuf = (void *) devc->wport.hwbuf_vaddr;
3331 devc->wport.hwbuf_paddr = virt_to_phys(devc->wport.hwbuf);
3332 DBGP("wport hwbuf = 0x%p\n", devc->wport.hwbuf);
3380 spin_lock_init(&devc->wport.lock);
3381 init_waitqueue_head(&devc->wport.queue);
3382 devc->wport.swstate = SW_OFF;
3383 devc->wport.hwstate = HW_STOPPED;
3384 devc->wport.flags = 0;
3385 devc->wport.swbuf = NULL;
3401 free_pages(devc->wport.hwbuf_vaddr, HWBUF_ORDER);
3433 free_pages(devc->wport.hwbuf_vaddr, HWBUF_ORDER);