Skip to content
Snippets Groups Projects
Select Git revision
  • 521bd5e4d9e6eb7e3c76c615d650a2b5ad0f03f5
  • panfrost/ci default
  • jakob-v5.4-patch
  • jakob-v5.4
  • jakob-4.19
  • drm-misc-next-with-blob
  • v5.3-hack-boot/ci
  • v5.3/ci
  • v5.2/ci
  • boot-time-improvement
  • jakob-v4.8
  • jakob-v4.9
12 results

pcm_misc.c

Blame
  • pcm_misc.c 14.40 KiB
    /*
     *  PCM Interface - misc routines
     *  Copyright (c) 1998 by Jaroslav Kysela <perex@perex.cz>
     *
     *
     *   This library is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU Library General Public License as
     *   published by the Free Software Foundation; either version 2 of
     *   the License, or (at your option) any later version.
     *
     *   This program is distributed in the hope that it will be useful,
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *   GNU Library General Public License for more details.
     *
     *   You should have received a copy of the GNU Library General Public
     *   License along with this library; if not, write to the Free Software
     *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     *
     */
      
    #include <linux/time.h>
    #include <linux/export.h>
    #include <sound/core.h>
    #include <sound/pcm.h>
    #define SND_PCM_FORMAT_UNKNOWN (-1)
    
    /* NOTE: "signed" prefix must be given below since the default char is
     *       unsigned on some architectures!
     */
    struct pcm_format_data {
    	unsigned char width;	/* bit width */
    	unsigned char phys;	/* physical bit width */
    	signed char le;	/* 0 = big-endian, 1 = little-endian, -1 = others */
    	signed char signd;	/* 0 = unsigned, 1 = signed, -1 = others */
    	unsigned char silence[8];	/* silence data to fill */
    };
    
    /* we do lots of calculations on snd_pcm_format_t; shut up sparse */
    #define INT	__force int
    
    static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
    	[SNDRV_PCM_FORMAT_S8] = {
    		.width = 8, .phys = 8, .le = -1, .signd = 1,
    		.silence = {},
    	},
    	[SNDRV_PCM_FORMAT_U8] = {
    		.width = 8, .phys = 8, .le = -1, .signd = 0,
    		.silence = { 0x80 },
    	},
    	[SNDRV_PCM_FORMAT_S16_LE] = {
    		.width = 16, .phys = 16, .le = 1, .signd = 1,
    		.silence = {},
    	},
    	[SNDRV_PCM_FORMAT_S16_BE] = {
    		.width = 16, .phys = 16, .le = 0, .signd = 1,
    		.silence = {},
    	},
    	[SNDRV_PCM_FORMAT_U16_LE] = {
    		.width = 16, .phys = 16, .le = 1, .signd = 0,
    		.silence = { 0x00, 0x80 },
    	},
    	[SNDRV_PCM_FORMAT_U16_BE] = {
    		.width = 16, .phys = 16, .le = 0, .signd = 0,
    		.silence = { 0x80, 0x00 },
    	},
    	[SNDRV_PCM_FORMAT_S24_LE] = {
    		.width = 24, .phys = 32, .le = 1, .signd = 1,
    		.silence = {},
    	},