1 /*	$OpenBSD: pt2254a.h,v 1.1 2002/04/25 04:56:59 mickey Exp $	*/
2 /*
3  * Copyright (c) 2002 Vladimir Popov <jumbo@narod.ru>.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 /*
26  * Princeton Technology Corp.'s Electronic Volume Controller IC PT2254A
27  *  http://www.princeton.com.tw
28  *
29  *  PT2254A is an electronic volume controller IC utilizing CMOS Technology
30  *  specially designed for use in audio equipment. It has two built-in
31  *  channels making it highly suitable for mono and stereo sound applications.
32  *  Through the specially designated signals that are applied externally to
33  *  the data, clock and strobe input pins, PT2254A can control attenuation
34  *  and channel balance.
35  */
36 
37 #ifndef _PT2254A_H_
38 #define _PT2254A_H_
39 
40 #define PT2254A_MAX_ATTENUATION			68
41 #define PT2254A_ATTENUATION_STEPS		35
42 
43 #define PT2254A_REGISTER_LENGTH			18
44 
45 #define PT2254A_ATTENUATION_MAJOR_0dB		(1 << 0)
46 #define PT2254A_ATTENUATION_MAJOR_10dB		(1 << 1)
47 #define PT2254A_ATTENUATION_MAJOR_20dB		(1 << 2)
48 #define PT2254A_ATTENUATION_MAJOR_30dB		(1 << 3)
49 #define PT2254A_ATTENUATION_MAJOR_40dB		(1 << 4)
50 #define PT2254A_ATTENUATION_MAJOR_50dB		(1 << 5)
51 #define PT2254A_ATTENUATION_MAJOR_60dB		(1 << 6)
52 #define 	PT2254A_ATTENUATION_MAJOR(x)	(1 << x)
53 
54 #define PT2254A_ATTENUATION_MINOR_0dB		(1 << 7)
55 #define PT2254A_ATTENUATION_MINOR_2dB		(1 << 8
56 #define PT2254A_ATTENUATION_MINOR_4dB		(1 << 9)
57 #define PT2254A_ATTENUATION_MINOR_6dB		(1 << 10)
58 #define PT2254A_ATTENUATION_MINOR_8dB		(1 << 11)
59 #define 	PT2254A_ATTENUATION_MINOR(x)	(1 << (7 + x / 2))
60 
61 #define PT2254A_EMPTY_BIT			(0 << 12)
62 
63 #define PT2254A_BOTH_CHANNELS			(3 << 13)
64 #define PT2254A_LEFT_CHANNEL			(1 << 13)
65 #define PT2254A_RIGHT_CHANNEL			(1 << 14)
66 
67 #define PT2254A_ZERO_PADDING			(0 << 15)
68 
69 #define USE_CHANNEL				1
70 
71 u_int32_t	pt2254a_encode_volume(u_int8_t *, u_int8_t);
72 u_int32_t	pt2254a_compose_register(u_int32_t, u_int32_t, int, int);
73 
74 #endif /* _PT2254A_H_ */
75