The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/sound/pcm/buffer.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD: head/sys/dev/sound/pcm/buffer.h 326255 2017-11-27 14:52:40Z pfg $
   29  */
   30 
   31 #define SND_DMA(b) (sndbuf_getflags((b)) & SNDBUF_F_DMA)
   32 #define SNDBUF_LOCKASSERT(b)
   33 
   34 #define SNDBUF_F_DMA            0x00000001
   35 #define SNDBUF_F_XRUN           0x00000002
   36 #define SNDBUF_F_RUNNING        0x00000004
   37 #define SNDBUF_F_MANAGED        0x00000008
   38 
   39 #define SNDBUF_NAMELEN  48
   40 
   41 struct snd_dbuf {
   42         device_t dev;
   43         u_int8_t *buf, *tmpbuf;
   44         u_int8_t *shadbuf; /**< shadow buffer used w/ S_D_SILENCE/SKIP */
   45         volatile int sl; /**< shadbuf ready length in # of bytes */
   46         unsigned int bufsize, maxsize, allocsize;
   47         volatile int dl; /* transfer size */
   48         volatile int rp; /* pointers to the ready area */
   49         volatile int rl; /* length of ready area */
   50         volatile int hp;
   51         volatile u_int64_t total, prev_total;
   52         int dmachan, dir;       /* dma channel */
   53         u_int32_t fmt, spd, bps, align;
   54         unsigned int blksz, blkcnt;
   55         int xrun;
   56         u_int32_t flags;
   57         bus_dmamap_t dmamap;
   58         bus_dma_tag_t dmatag;
   59         bus_addr_t buf_addr;
   60         int dmaflags;
   61         struct selinfo sel;
   62         struct pcm_channel *channel;
   63         char name[SNDBUF_NAMELEN];
   64 };
   65 
   66 struct snd_dbuf *sndbuf_create(device_t dev, char *drv, char *desc, struct pcm_channel *channel);
   67 void sndbuf_destroy(struct snd_dbuf *b);
   68 
   69 void sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what);
   70 
   71 int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size);
   72 int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size);
   73 void sndbuf_free(struct snd_dbuf *b);
   74 int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
   75 int sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
   76 void sndbuf_reset(struct snd_dbuf *b);
   77 void sndbuf_clear(struct snd_dbuf *b, unsigned int length);
   78 void sndbuf_fillsilence(struct snd_dbuf *b);
   79 void sndbuf_fillsilence_rl(struct snd_dbuf *b, u_int rl);
   80 void sndbuf_softreset(struct snd_dbuf *b);
   81 void sndbuf_clearshadow(struct snd_dbuf *b);
   82 
   83 u_int32_t sndbuf_getfmt(struct snd_dbuf *b);
   84 int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt);
   85 unsigned int sndbuf_getspd(struct snd_dbuf *b);
   86 void sndbuf_setspd(struct snd_dbuf *b, unsigned int spd);
   87 unsigned int sndbuf_getbps(struct snd_dbuf *b);
   88 
   89 bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf);
   90 
   91 void *sndbuf_getbuf(struct snd_dbuf *b);
   92 void *sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs);
   93 unsigned int sndbuf_getsize(struct snd_dbuf *b);
   94 unsigned int sndbuf_getmaxsize(struct snd_dbuf *b);
   95 unsigned int sndbuf_getallocsize(struct snd_dbuf *b);
   96 unsigned int sndbuf_getalign(struct snd_dbuf *b);
   97 unsigned int sndbuf_getblkcnt(struct snd_dbuf *b);
   98 void sndbuf_setblkcnt(struct snd_dbuf *b, unsigned int blkcnt);
   99 unsigned int sndbuf_getblksz(struct snd_dbuf *b);
  100 void sndbuf_setblksz(struct snd_dbuf *b, unsigned int blksz);
  101 unsigned int sndbuf_runsz(struct snd_dbuf *b);
  102 void sndbuf_setrun(struct snd_dbuf *b, int go);
  103 struct selinfo *sndbuf_getsel(struct snd_dbuf *b);
  104 
  105 unsigned int sndbuf_getxrun(struct snd_dbuf *b);
  106 void sndbuf_setxrun(struct snd_dbuf *b, unsigned int xrun);
  107 unsigned int sndbuf_gethwptr(struct snd_dbuf *b);
  108 void sndbuf_sethwptr(struct snd_dbuf *b, unsigned int ptr);
  109 unsigned int sndbuf_getfree(struct snd_dbuf *b);
  110 unsigned int sndbuf_getfreeptr(struct snd_dbuf *b);
  111 unsigned int sndbuf_getready(struct snd_dbuf *b);
  112 unsigned int sndbuf_getreadyptr(struct snd_dbuf *b);
  113 u_int64_t sndbuf_getblocks(struct snd_dbuf *b);
  114 u_int64_t sndbuf_getprevblocks(struct snd_dbuf *b);
  115 u_int64_t sndbuf_gettotal(struct snd_dbuf *b);
  116 u_int64_t sndbuf_getprevtotal(struct snd_dbuf *b);
  117 unsigned int sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to);
  118 u_int8_t sndbuf_zerodata(u_int32_t fmt);
  119 void sndbuf_updateprevtotal(struct snd_dbuf *b);
  120 
  121 int sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count);
  122 int sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count);
  123 int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count);
  124 
  125 u_int32_t sndbuf_getflags(struct snd_dbuf *b);
  126 void sndbuf_setflags(struct snd_dbuf *b, u_int32_t flags, int on);
  127 
  128 int sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq);
  129 int sndbuf_dmasetdir(struct snd_dbuf *b, int dir);
  130 void sndbuf_dma(struct snd_dbuf *b, int go);
  131 int sndbuf_dmaptr(struct snd_dbuf *b);
  132 void sndbuf_dmabounce(struct snd_dbuf *b);
  133 
  134 #ifdef OSSV4_EXPERIMENT
  135 void sndbuf_getpeaks(struct snd_dbuf *b, int *lp, int *rp);
  136 #endif
  137 
  138 static inline u_int32_t
  139 snd_xbytes(u_int32_t v, u_int32_t from, u_int32_t to)
  140 {
  141 
  142         if (from == to)
  143                 return (v);
  144         if (from == 0)
  145                 return (0);
  146         return ((u_int64_t)v * to / from);
  147 }

Cache object: 35539d3f195c9019443f6ef76a5e0df6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.