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