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 #ifndef _ICE1712_H_ 12 #define _ICE1712_H_ 13 14 15 #include <PCI.h> 16 #include "hmulti_audio.h" 17 18 #define DRIVER_NAME "ice1712" 19 #define VERSION "0.4" 20 21 #define ICE1712_VENDOR_ID 0x1412 22 #define ICE1712_DEVICE_ID 0x1712 23 24 typedef enum product_t { 25 ICE1712_SUBDEVICE_DELTA1010 = 0x121430d6, 26 ICE1712_SUBDEVICE_DELTADIO2496 = 0x121431d6, 27 ICE1712_SUBDEVICE_DELTA66 = 0x121432d6, 28 ICE1712_SUBDEVICE_DELTA44 = 0x121433d6, 29 ICE1712_SUBDEVICE_AUDIOPHILE_2496 = 0x121434d6, 30 ICE1712_SUBDEVICE_DELTA410 = 0x121438d6, 31 ICE1712_SUBDEVICE_DELTA1010LT = 0x12143bd6, 32 ICE1712_SUBDEVICE_VX442 = 0x12143cd6, 33 } product_t; 34 35 #define NUM_CARDS 4 36 #define MAX_ADC 12 // + the output of the Digital mixer 37 #define MAX_DAC 10 38 #define SWAPPING_BUFFERS 2 39 #define SAMPLE_SIZE 4 40 #define MIN_BUFFER_FRAMES 64 41 #define MAX_BUFFER_FRAMES 2048 42 43 #define ICE1712_HARDWARE_VOLUME 10 44 #define ICE1712_MUTE_VALUE 0x7F 45 46 #define PLAYBACK_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_DAC * SAMPLE_SIZE) 47 #define RECORD_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_ADC * SAMPLE_SIZE) 48 49 #define PLAYBACK_BUFFER_TOTAL_SIZE (PLAYBACK_BUFFER_SIZE * SWAPPING_BUFFERS) 50 #define RECORD_BUFFER_TOTAL_SIZE (RECORD_BUFFER_SIZE * SWAPPING_BUFFERS) 51 52 #define SPDIF_LEFT 8 53 #define SPDIF_RIGHT 9 54 #define MIXER_OUT_LEFT 10 55 #define MIXER_OUT_RIGHT 11 56 57 #define SPDIF_OUT_PRESENT 1 58 #define SPDIF_IN_PRESENT 2 59 60 #define ICE1712_SAMPLERATE_96K 0x7 61 #define ICE1712_SAMPLERATE_48K 0x0 62 #define ICE1712_SAMPLERATE_88K2 0xB 63 #define ICE1712_SAMPLERATE_44K1 0x8 64 65 typedef struct _midi_dev { 66 struct _ice1712_ *card; 67 void *driver; 68 void *cookie; 69 int32 count; 70 char name[64]; 71 } midi_dev; 72 73 typedef struct _codecCommLines 74 { 75 uint8 clock; 76 uint8 data_in; 77 uint8 data_out; 78 uint8 cs_mask; //a Mask for removing all Chip select 79 uint8 reserved[4]; 80 } codecCommLines; 81 82 typedef struct channel_volume 83 { 84 float volume; 85 bool mute; 86 } channel_volume; 87 88 typedef struct ice1712_settings 89 { 90 channel_volume playback[ICE1712_HARDWARE_VOLUME]; 91 channel_volume record[ICE1712_HARDWARE_VOLUME]; 92 93 //General Settings 94 uint8 clock; //an index 95 uint8 bufferSize; //an index 96 uint8 debugMode; //an index for debugging 97 98 //S/PDif Settings 99 uint8 outFormat; //an index 100 uint8 emphasis; //an index 101 uint8 copyMode; //an index 102 103 //Output settings 104 uint8 output[5]; //an index 105 106 uint8 reserved[32]; 107 } ice1712_settings; 108 109 typedef struct ice1712_hconfig 110 { 111 int8 nb_ADC; //Mono Channel 112 int8 nb_DAC; //Mono Channel 113 int8 nb_MPU401; 114 int8 spdif; 115 } ice1712_hconfig; 116 117 typedef struct ice1712 118 { 119 uint32 irq; 120 pci_info info; 121 char name[128]; 122 123 midi_dev midi_interf[2]; 124 125 uint32 Controller; //PCI_10 126 uint32 DDMA; //PCI_14 127 uint32 DMA_Path; //PCI_18 128 uint32 Multi_Track; //PCI_1C 129 130 uint8 eeprom_data[32]; 131 132 product_t product; 133 134 //We hope all manufacturers will use same 135 //communication lines for speaking with codec 136 codecCommLines CommLines; 137 138 uint32 buffer; 139 bigtime_t played_time; 140 uint32 buffer_size; //in frames 141 uint32 frames_count; 142 143 //Output 144 area_id mem_id_pb; 145 void *phys_addr_pb, *log_addr_pb; 146 uint8 total_output_channels; 147 148 //Input 149 area_id mem_id_rec; 150 void *phys_addr_rec, *log_addr_rec; 151 uint8 total_input_channels; 152 153 sem_id buffer_ready_sem; 154 155 uint8 sampling_rate; //in the format of the register 156 uint32 lock_source; 157 158 ice1712_hconfig config; 159 ice1712_settings settings; 160 } ice1712; 161 162 status_t applySettings(ice1712 *card); 163 164 //For midi.c 165 extern int32 num_cards; 166 extern ice1712 cards[NUM_CARDS]; 167 168 //??????? 169 #define GPIO_SPDIF_STATUS 0x02 //Status 170 #define GPIO_SPDIF_CCLK 0x04 //data Clock 171 #define GPIO_SPDIF_DOUT 0x08 //data output 172 173 //For Delta 66 / Delta 44 174 #define DELTA66_DOUT 0x10 // data output 175 #define DELTA66_CLK 0x20 // clock 176 #define DELTA66_CODEC_CS_0 0x40 // AK4524 #0 177 #define DELTA66_CODEC_CS_1 0x80 // AK4524 #1 178 179 //For AudioPhile 2496 / Delta 410 180 #define AP2496_CLK 0x02 // clock 181 #define AP2496_DIN 0x04 // data input 182 #define AP2496_DOUT 0x08 // data output 183 #define AP2496_SPDIF_CS 0x10 // CS8427 chip select 184 #define AP2496_CODEC_CS 0x20 // AK4528 chip select 185 186 //For Delta 1010 LT 187 #define DELTA1010LT_CLK 0x02 // clock 188 #define DELTA1010LT_DIN 0x04 // data input 189 #define DELTA1010LT_DOUT 0x08 // data output 190 #define DELTA1010LT_CODEC_CS_0 0x00 // AK4524 #0 191 #define DELTA1010LT_CODEC_CS_1 0x10 // AK4524 #1 192 #define DELTA1010LT_CODEC_CS_2 0x20 // AK4524 #2 193 #define DELTA1010LT_CODEC_CS_3 0x30 // AK4524 #3 194 #define DELTA1010LT_SPDIF_CS 0x40 // CS8427 195 #define DELTA1010LT_CS_NONE 0x50 // All CS deselected 196 197 //For VX442 198 #define VX442_CLK 0x02 // clock 199 #define VX442_DIN 0x04 // data input 200 #define VX442_DOUT 0x08 // data output 201 #define VX442_SPDIF_CS 0x10 // CS8427 202 #define VX442_CODEC_CS_0 0x20 // ?? #0 203 #define VX442_CODEC_CS_1 0x40 // ?? #1 204 205 #define GPIO_I2C_DELAY 5 //Clock Delay for writing 206 //I2C data throw GPIO 207 208 //Register definition for the AK45xx codec (xx = 24 or 28) 209 #define AK45xx_CHIP_ADDRESS 0x02 //Chip address of the codec 210 #define AK45xx_RESET_REGISTER 0x01 211 #define AK45xx_CLOCK_FORMAT_REGISTER 0x02 212 //Other register are not defined cause they are not used, I'm very lazy... 213 214 //Register definition for the CS84xx codec (xx = 27) 215 #define CS84xx_CHIP_ADDRESS 0x10 //Chip address of the codec 216 #define CS84xx_CONTROL_1_PORT_REG 0x01 217 #define CS84xx_CONTROL_2_PORT_REG 0x02 218 #define CS84xx_DATA_FLOW_CONTROL_REG 0x03 219 #define CS84xx_CLOCK_SOURCE_REG 0x04 220 #define CS84xx_SERIAL_INPUT_FORMAT_REG 0x05 221 #define CS84xx_SERIAL_OUTPUT_FORMAT_REG 0x06 222 223 #define CS84xx_VERSION_AND_CHIP_ID 0x7F 224 //Other register are not defined cause they are not used, I'm very lazy... 225 226 227 /* A default switch for all suported product 228 switch (card->product) 229 { 230 case ICE1712_SUBDEVICE_DELTA1010 : 231 break; 232 case ICE1712_SUBDEVICE_DELTADIO2496 : 233 break; 234 case ICE1712_SUBDEVICE_DELTA66 : 235 break; 236 case ICE1712_SUBDEVICE_DELTA44 : 237 break; 238 case ICE1712_SUBDEVICE_AUDIOPHILE : 239 break; 240 case ICE1712_SUBDEVICE_DELTA410 : 241 break; 242 case ICE1712_SUBDEVICE_DELTA1010LT : 243 break; 244 case ICE1712_SUBDEVICE_VX442 : 245 break; 246 } 247 */ 248 249 //This map comes from ALSA sound drivers 250 #define E2PROM_MAP_SUBVENDOR_LOW 0x00 251 #define E2PROM_MAP_SUBVENDOR_HIGH 0x01 252 #define E2PROM_MAP_SUBDEVICE_LOW 0x02 253 #define E2PROM_MAP_SUBDEVICE_HIGH 0x03 254 #define E2PROM_MAP_SIZE 0x04 255 #define E2PROM_MAP_VERSION 0x05 256 #define E2PROM_MAP_CONFIG 0x06 257 #define E2PROM_MAP_ACL 0x07 258 #define E2PROM_MAP_I2S 0x08 259 #define E2PROM_MAP_SPDIF 0x09 260 #define E2PROM_MAP_GPIOMASK 0x0A 261 #define E2PROM_MAP_GPIOSTATE 0x0B 262 #define E2PROM_MAP_GPIODIR 0x0C 263 #define E2PROM_MAP_AC97MAIN 0x0D 264 #define E2PROM_MAP_AC97PCM 0x0F 265 #define E2PROM_MAP_AC97REC 0x11 266 #define E2PROM_MAP_AC97REC_SOURCE 0x13 267 #define E2PROM_MAP_DAC_ID 0x14 268 #define E2PROM_MAP_ADC_ID 0x18 269 #define E2PROM_MAP_EXTRA 0x1C 270 271 #endif 272