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/auconv.c

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 /*      $NetBSD: auconv.c,v 1.10 2002/03/15 14:55:03 kent Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
    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  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by the Computer Systems
   18  *      Engineering Group at Lawrence Berkeley Laboratory.
   19  * 4. Neither the name of the University nor of the Laboratory may be used
   20  *    to endorse or promote products derived from this software without
   21  *    specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  */
   36 
   37 #include <sys/cdefs.h>
   38 __KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.10 2002/03/15 14:55:03 kent Exp $");
   39 
   40 #include <sys/types.h>
   41 #include <sys/audioio.h>
   42 
   43 #include "auconv.h"
   44 
   45 void
   46 change_sign8(void *v, u_char *p, int cc)
   47 {
   48         while (--cc >= 0) {
   49                 *p ^= 0x80;
   50                 ++p;
   51         }
   52 }
   53 
   54 void
   55 change_sign16_le(void *v, u_char *p, int cc)
   56 {
   57         while ((cc -= 2) >= 0) {
   58                 p[1] ^= 0x80;
   59                 p += 2;
   60         }
   61 }
   62 
   63 void
   64 change_sign16_be(void *v, u_char *p, int cc)
   65 {
   66         while ((cc -= 2) >= 0) {
   67                 p[0] ^= 0x80;
   68                 p += 2;
   69         }
   70 }
   71 
   72 void
   73 swap_bytes(void *v, u_char *p, int cc)
   74 {
   75         u_char t;
   76 
   77         while ((cc -= 2) >= 0) {
   78                 t = p[0];
   79                 p[0] = p[1];
   80                 p[1] = t;
   81                 p += 2;
   82         }
   83 }
   84 
   85 void
   86 swap_bytes_change_sign16_le(void *v, u_char *p, int cc)
   87 {
   88         u_char t;
   89 
   90         while ((cc -= 2) >= 0) {
   91                 t = p[1];
   92                 p[1] = p[0] ^ 0x80;
   93                 p[0] = t;
   94                 p += 2;
   95         }
   96 }
   97 
   98 void
   99 swap_bytes_change_sign16_be(void *v, u_char *p, int cc)
  100 {
  101         u_char t;
  102 
  103         while ((cc -= 2) >= 0) {
  104                 t = p[0];
  105                 p[0] = p[1] ^ 0x80;
  106                 p[1] = t;
  107                 p += 2;
  108         }
  109 }
  110 
  111 void
  112 change_sign16_swap_bytes_le(void *v, u_char *p, int cc)
  113 {
  114         swap_bytes_change_sign16_be(v, p, cc);
  115 }
  116 
  117 void
  118 change_sign16_swap_bytes_be(void *v, u_char *p, int cc)
  119 {
  120         swap_bytes_change_sign16_le(v, p, cc);
  121 }
  122 
  123 void
  124 linear8_to_linear16_le(void *v, u_char *p, int cc)
  125 {
  126         u_char *q = p;
  127 
  128         p += cc;
  129         q += cc * 2;
  130         while (--cc >= 0) {
  131                 q -= 2;
  132                 q[1] = *--p;
  133                 q[0] = 0;
  134         }
  135 }
  136 
  137 void
  138 linear8_to_linear16_be(void *v, u_char *p, int cc)
  139 {
  140         u_char *q = p;
  141 
  142         p += cc;
  143         q += cc * 2;
  144         while (--cc >= 0) {
  145                 q -= 2;
  146                 q[0] = *--p;
  147                 q[1] = 0;
  148         }
  149 }
  150 
  151 void
  152 linear16_to_linear8_le(void *v, u_char *p, int cc)
  153 {
  154         u_char *q = p;
  155 
  156         while (--cc >= 0) {
  157                 *q++ = p[1];
  158                 p += 2;
  159         }
  160 }
  161 
  162 void
  163 linear16_to_linear8_be(void *v, u_char *p, int cc)
  164 {
  165         u_char *q = p;
  166 
  167         while (--cc >= 0) {
  168                 *q++ = p[0];
  169                 p += 2;
  170         }
  171 }
  172 
  173 void
  174 ulinear8_to_slinear16_le(void *v, u_char *p, int cc)
  175 {
  176         u_char *q = p;
  177 
  178         p += cc;
  179         q += cc * 2;
  180         while (--cc >= 0) {
  181                 q -= 2;
  182                 q[1] = *--p ^ 0x80;
  183                 q[0] = 0;
  184         }
  185 }
  186 
  187 void
  188 ulinear8_to_slinear16_be(void *v, u_char *p, int cc)
  189 {
  190         u_char *q = p;
  191 
  192         p += cc;
  193         q += cc * 2;
  194         while (--cc >= 0) {
  195                 q -= 2;
  196                 q[0] = *--p ^ 0x80;
  197                 q[1] = 0;
  198         }
  199 }
  200 
  201 void
  202 slinear16_to_ulinear8_le(void *v, u_char *p, int cc)
  203 {
  204         u_char *q = p;
  205 
  206         while (--cc >= 0) {
  207                 *q++ = p[1] ^ 0x80;
  208                 p += 2;
  209         }
  210 }
  211 
  212 void
  213 slinear16_to_ulinear8_be(void *v, u_char *p, int cc)
  214 {
  215         u_char *q = p;
  216 
  217         while (--cc >= 0) {
  218                 *q++ = p[0] ^ 0x80;
  219                 p += 2;
  220         }
  221 }

Cache object: 7ed55b5ca48f91858104bbe408822fa6


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