1/*
2 * BSD LICENSE
3 *
4 * tinycompress utility functions
5 * Copyright (c) 2011-2013, Intel Corporation
6 * All rights reserved.
7 *
8 * Author: Vinod Koul <vinod.koul@intel.com>
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * Neither the name of Intel Corporation nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * LGPL LICENSE
35 *
36 * tinycompress utility functions
37 * Copyright (c) 2011-2013, Intel Corporation
38 *
39 * This program is free software; you can redistribute it and/or modify it
40 * under the terms and conditions of the GNU Lesser General Public License,
41 * version 2.1, as published by the Free Software Foundation.
42 *
43 * This program is distributed in the hope it will be useful, but WITHOUT
44 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
46 * License for more details.
47 *
48 * You should have received a copy of the GNU Lesser General Public License
49 * along with this program; if not, write to
50 * the Free Software Foundation, Inc.,
51 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
52 */
53#include <stdio.h>
54#include <stdlib.h>
55#include <stdbool.h>
56#include <linux/types.h>
57#include <sys/time.h>
58#define __force
59#define __bitwise
60#define __user
61#include "tinycompress/tinycompress.h"
62
63
64unsigned int compress_get_alsa_rate(unsigned int rate)
65{
66	switch (rate) {
67	case 5512:
68		return SNDRV_PCM_RATE_5512;
69	case 8000:
70		return SNDRV_PCM_RATE_8000;
71	case 11025:
72		return SNDRV_PCM_RATE_11025;
73	case 16000:
74		return SNDRV_PCM_RATE_16000;
75	case 22050:
76		return SNDRV_PCM_RATE_22050;
77	case 32000:
78		return SNDRV_PCM_RATE_32000;
79	case 44100:
80		return SNDRV_PCM_RATE_44100;
81	case 48000:
82		return SNDRV_PCM_RATE_48000;
83	case 64000:
84		return SNDRV_PCM_RATE_64000;
85	case 88200:
86		return SNDRV_PCM_RATE_88200;
87	case 96000:
88		return SNDRV_PCM_RATE_96000;
89	case 176400:
90		return SNDRV_PCM_RATE_176400;
91	case 192000:
92		return SNDRV_PCM_RATE_192000;
93	default:
94		return 0;
95	}
96}
97