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/midivar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: midivar.h,v 1.13 2022/03/21 19:22:40 miod Exp $       */
    2 
    3 /*
    4  * Copyright (c) 2003, 2004 Alexandre Ratchov
    5  *
    6  * Permission to use, copy, modify, and distribute this software for any
    7  * purpose with or without fee is hereby granted, provided that the above
    8  * copyright notice and this permission notice appear in all copies.
    9  *
   10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   17  */
   18 
   19 #ifndef _SYS_DEV_MIDIVAR_H_
   20 #define _SYS_DEV_MIDIVAR_H_
   21 
   22 #include <dev/midi_if.h>
   23 #include <sys/device.h>
   24 #include <sys/selinfo.h>
   25 #include <sys/proc.h>
   26 #include <sys/timeout.h>
   27 
   28 #define MIDI_RATE       3125    /* midi uart baud rate in bytes/second */
   29 
   30 /*
   31  * simple ring buffer
   32  */
   33 #define MIDIBUF_SIZE            (1 << 10)
   34 #define MIDIBUF_MASK            (MIDIBUF_SIZE - 1)
   35 
   36 struct midi_buffer {
   37         void         *softintr;         /* context to call selwakeup() */
   38         struct        selinfo sel;      /* to record & wakeup poll(2) */
   39         int           blocking;         /* read/write blocking */
   40         unsigned char data[MIDIBUF_SIZE]; 
   41         unsigned      start, used;
   42 };
   43 
   44 #define MIDIBUF_START(buf)      ((buf)->start)
   45 #define MIDIBUF_END(buf)        (((buf)->start + (buf)->used) & MIDIBUF_MASK)
   46 #define MIDIBUF_USED(buf)       ((buf)->used)
   47 #define MIDIBUF_AVAIL(buf)      (MIDIBUF_SIZE - (buf)->used)
   48 #define MIDIBUF_ISFULL(buf)     ((buf)->used >= MIDIBUF_SIZE)
   49 #define MIDIBUF_ISEMPTY(buf)    ((buf)->used == 0)
   50 #define MIDIBUF_WRITE(buf, byte)                                \
   51         do {                                                    \
   52                 (buf)->data[MIDIBUF_END(buf)] = (byte);         \
   53                 (buf)->used++;                                  \
   54         } while(0)
   55 #define MIDIBUF_READ(buf, byte)                                 \
   56         do {                                                    \
   57                 (byte) = (buf)->data[(buf)->start++];           \
   58                 (buf)->start &= MIDIBUF_MASK;                   \
   59                 (buf)->used--;                                  \
   60         } while(0)
   61 #define MIDIBUF_REMOVE(buf, count)                              \
   62         do {                                                    \
   63                 (buf)->start += (count);                        \
   64                 (buf)->start &= MIDIBUF_MASK;                   \
   65                 (buf)->used  -= (count);                        \
   66         } while(0)
   67 #define MIDIBUF_INIT(buf)                                       \
   68         do {                                                    \
   69                 (buf)->start = (buf)->used = 0;                 \
   70         } while(0)
   71         
   72 
   73 struct midi_softc {
   74         struct device       dev;
   75         const struct midi_hw_if *hw_if;
   76         void               *hw_hdl;
   77         int                 isbusy;             /* concerns only the output */
   78         int                 flags;              /* open flags */
   79         int                 props;              /* midi hw proprieties */
   80         struct timeout      timeo;
   81         struct midi_buffer  inbuf;
   82         struct midi_buffer  outbuf;
   83 };
   84 
   85 #endif /* _SYS_DEV_MIDIVAR_H_ */

Cache object: 6541837dfe5fbdebd6e6a126aa7e8438


[ 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.