xref: /haiku/src/add-ons/kernel/drivers/audio/ice1712/io.h (revision 1b6bc2675fe3691538c8764ab016593f3b06ca53)
1 /*
2  * ice1712 BeOS/Haiku Driver for VIA - VT1712 Multi Channel Audio Controller
3  *
4  * Copyright (c) 2002, Jerome Duval		(jerome.duval@free.fr)
5  * Copyright (c) 2003, Marcus Overhagen	(marcus@overhagen.de)
6  * Copyright (c) 2007, Jerome Leveque	(leveque.jerome@neuf.fr)
7  *
8  * All rights reserved
9  * Distributed under the terms of the MIT license.
10  */
11 
12 #ifndef _IO_H_
13 #define _IO_H_
14 
15 #include "ice1712.h"
16 
17 #include <SupportDefs.h>
18 
19 //------------------------------------------------------
20 //------------------------------------------------------
21 //Address are [PCI_10] + xx
22 uint8	read_ccs_uint8(ice1712 *ice,	int8 regno);
23 uint16	read_ccs_uint16(ice1712 *ice,	int8 regno);
24 uint32	read_ccs_uint32(ice1712 *ice,	int8 regno);
25 
26 void	write_ccs_uint8(ice1712 *ice,	int8 regno,	uint8 value);
27 void	write_ccs_uint16(ice1712 *ice,	int8 regno,	uint16 value);
28 void	write_ccs_uint32(ice1712 *ice,	int8 regno,	uint32 value);
29 //------------------------------------------------------
30 //------------------------------------------------------
31 uint8	read_cci_uint8(ice1712 *ice,	int8 index);
32 void	write_cci_uint8(ice1712 *ice,	int8 index,	uint8 value);
33 //------------------------------------------------------
34 //------------------------------------------------------
35 //Address are [PCI_14] + xx
36 uint8	read_ddma_uint8(ice1712 *ice,	int8 regno);
37 uint16	read_ddma_uint16(ice1712 *ice,	int8 regno);
38 uint32	read_ddma_uint32(ice1712 *ice,	int8 regno);
39 
40 void	write_ddma_uint8(ice1712 *ice,	int8 regno,	uint8 value);
41 void	write_ddma_uint16(ice1712 *ice,	int8 regno,	uint16 value);
42 void	write_ddma_uint32(ice1712 *ice,	int8 regno,	uint32 value);
43 //------------------------------------------------------
44 //------------------------------------------------------
45 //Address are [PCI_18] + x
46 uint8	read_ds_uint8(ice1712 *ice,		int8 regno);
47 uint16	read_ds_uint16(ice1712 *ice,	int8 regno);
48 uint32	read_ds_uint32(ice1712 *ice,	int8 regno);
49 
50 void	write_ds_uint8(ice1712 *ice,	int8 regno,	uint8 value);
51 void	write_ds_uint16(ice1712 *ice,	int8 regno,	uint16 value);
52 void	write_ds_uint32(ice1712 *ice,	int8 regno,	uint32 value);
53 
54 typedef enum {
55 	DS8_REGISTER_BUFFER_0_BASE_ADDRESS = 0,
56 	DS8_REGISTER_BUFFER_0_BASE_COUNT,
57 	DS8_REGISTER_BUFFER_1_BASE_ADDRESS,
58 	DS8_REGISTER_BUFFER_1_BASE_COUNT,
59 	DS8_REGISTER_CONTROL_AND_STATUS,
60 	DS8_REGISTER_SAMPLING_RATE,
61 	DS8_REGISTER_LEFT_RIGHT_VOLUME,
62 } ds8_register;
63 
64 uint32	read_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index);
65 void	write_ds_channel_data(ice1712 *ice, uint8 channel,
66 			ds8_register index, uint32 data);
67 //------------------------------------------------------
68 //------------------------------------------------------
69 //Address are [PCI_1C] + xx
70 uint8	read_mt_uint8(ice1712 *ice,		int8 regno);
71 uint16	read_mt_uint16(ice1712 *ice,	int8 regno);
72 uint32	read_mt_uint32(ice1712 *ice,	int8 regno);
73 
74 void	write_mt_uint8(ice1712 *ice,	int8 regno,	uint8 value);
75 void	write_mt_uint16(ice1712 *ice,	int8 regno,	uint16 value);
76 void	write_mt_uint32(ice1712 *ice,	int8 regno,	uint32 value);
77 //------------------------------------------------------
78 //------------------------------------------------------
79 
80 int16	read_i2c(ice1712 *ice, uint8 dev_addr, uint8 byte_addr);
81 //return -1 if error else return an uint8
82 
83 int16	write_i2c(ice1712 *ice, uint8 dev_addr, uint8 byte_addr, uint8 value);
84 //return -1 if error else return 0
85 
86 //------------------------------------------------------
87 
88 int16 read_eeprom(ice1712 *ice, uint8 eeprom[32]);
89 
90 //------------------------------------------------------
91 
92 void codec_write(ice1712 *ice, uint8 reg_addr, uint8 data);
93 void spdif_write(ice1712 *ice, uint8 reg_addr, uint8 data);
94 void codec_write_mult(ice1712 *ice, uint8 reg_addr, uint8 datas[], uint8 size);
95 void spdif_write_mult(ice1712 *ice, uint8 reg_addr, uint8 datas[], uint8 size);
96 
97 uint8 codec_read(ice1712 *ice, uint8 reg_addr);
98 uint8 spdif_read(ice1712 *ice, uint8 reg_addr);
99 uint8 codec_read_mult(ice1712 *ice, uint8 reg_addr, uint8 datas[], uint8 size);
100 uint8 spdif_read_mult(ice1712 *ice, uint8 reg_addr, uint8 datas[], uint8 size);
101 
102 //------------------------------------------------------
103 
104 uint8	read_gpio(ice1712 *ice);
105 //return -1 if error else return an uint8
106 
107 void	write_gpio(ice1712 *ice, uint8 value);
108 
109 #endif
110