ceareg.h revision 1.1.18.2 1 /* $NetBSD: ceareg.h,v 1.1.18.2 2017/12/03 11:37:01 jdolecek Exp $ */
2
3 /*
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill (at) invisible.ca>
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. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #ifndef _CEAREG_H
29 #define _CEAREG_H
30
31 /* short audio descriptor */
32 struct cea_sad {
33 uint8_t flags1;
34 uint8_t sample_rates;
35 uint8_t flags2;
36 } __packed;
37
38 #define CEA_AUDIO_FORMAT(desc) (((desc)->flags1 >> 3) & 0x0f)
39 #define CEA_AUDIO_FORMAT_LPCM 1
40 #define CEA_AUDIO_FORMAT_AC3 2
41 #define CEA_AUDIO_FORMAT_MPEG1_L12 3
42 #define CEA_AUDIO_FORMAT_MPEG1_L3 4
43 #define CEA_AUDIO_FORMAT_MPEG2 5
44 #define CEA_AUDIO_FORMAT_AAC 6
45 #define CEA_AUDIO_FORMAT_DTS 7
46 #define CEA_AUDIO_FORMAT_ATRAC 8
47 #define CEA_MAX_CHANNELS(desc) ((((desc)->flags1 >> 0) & 0x07) + 1)
48 #define CEA_SAMPLE_RATE(desc) ((desc)->sample_rates)
49 #define CEA_SAMPLE_RATE_192K 0x40
50 #define CEA_SAMPLE_RATE_176K 0x20
51 #define CEA_SAMPLE_RATE_96K 0x10
52 #define CEA_SAMPLE_RATE_88K 0x08
53 #define CEA_SAMPLE_RATE_48K 0x04
54 #define CEA_SAMPLE_RATE_44K 0x02
55 #define CEA_SAMPLE_RATE_32K 0x01
56 /* uncompressed */
57 #define CEA_PRECISION(desc) ((desc)->flags2 & 0x07)
58 #define CEA_PRECISION_24BIT 0x4
59 #define CEA_PRECISION_20BIT 0x2
60 #define CEA_PRECISION_16BIT 0x1
61 /* compressed */
62 #define CEA_MAX_BITRATE(desc) ((uint32_t)(desc)->flags2 * 8000)
63
64 #endif /* !_CEAREG_H */
65