Patch from Jérôme Leveque: Work in progress: code cleanup (includes dos newlines and 80 chars by line)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41778 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2011-05-27 18:59:25 +00:00
parent d61187a1f3
commit 3cd099e2d4
10 changed files with 1824 additions and 1549 deletions
@@ -11,8 +11,6 @@
#ifndef _DEBUG_ICE1712_H_ #ifndef _DEBUG_ICE1712_H_
#define _DEBUG_ICE1712_H_ #define _DEBUG_ICE1712_H_
#include <Debug.h>
#ifdef TRACE #ifdef TRACE
# undef TRACE # undef TRACE
#endif #endif
@@ -24,6 +22,11 @@
# define TRACE(a...) ; # define TRACE(a...) ;
#endif #endif
#define ICE1712_VERY_VERBOSE 0 //#define ICE1712_VERY_VERBOSE
#ifdef ICE1712_VERY_VERBOSE
# define TRACE_VV(a...) dprintf("\33[34mice1712:\33[0m " a)
#else
# define TRACE_VV(a...) ;
#endif
#endif // _DEBUG_ICE1712_H_ #endif // _DEBUG_ICE1712_H_
@@ -18,13 +18,13 @@
#include <midi_driver.h> #include <midi_driver.h>
#include <string.h> #include <string.h>
#include "debug.h"
#include "ice1712.h" #include "ice1712.h"
#include "ice1712_reg.h" #include "ice1712_reg.h"
#include "io.h" #include "io.h"
#include "multi.h" #include "multi.h"
#include "util.h" #include "util.h"
#include "debug.h"
//------------------------------------------------------ //------------------------------------------------------
//------------------------------------------------------ //------------------------------------------------------
@@ -65,10 +65,6 @@ int32 api_version = B_CUR_DRIVER_API_VERSION;
//extern status_t unload_kernel_addon(image_id imid); //extern status_t unload_kernel_addon(image_id imid);
//------------------------------------------------------ //------------------------------------------------------
static status_t load_settings(ice1712 *ice);
static status_t save_settings(ice1712 *ice);
//------------------------------------------------------ //------------------------------------------------------
status_t init_hardware(void) status_t init_hardware(void)
@@ -164,27 +160,39 @@ ice1712_setup(ice1712 *ice)
write_ccs_uint8(ice, CCS_SERR_SHADOW, 0x01); write_ccs_uint8(ice, CCS_SERR_SHADOW, 0x01);
//Write all configurations register from EEProm //Write all configurations register from EEProm
ice->info.device_id = ice->eeprom_data[E2PROM_MAP_SUBVENDOR_HIGH] << 8 | ice->eeprom_data[E2PROM_MAP_SUBVENDOR_LOW]; ice->info.device_id = ice->eeprom_data[E2PROM_MAP_SUBVENDOR_HIGH] << 8
ice->info.vendor_id = ice->eeprom_data[E2PROM_MAP_SUBDEVICE_HIGH] << 8 | ice->eeprom_data[E2PROM_MAP_SUBDEVICE_LOW]; | ice->eeprom_data[E2PROM_MAP_SUBVENDOR_LOW];
ice->info.vendor_id = ice->eeprom_data[E2PROM_MAP_SUBDEVICE_HIGH] << 8
| ice->eeprom_data[E2PROM_MAP_SUBDEVICE_LOW];
ice->product = ice->info.vendor_id << 16 | ice->info.device_id; ice->product = ice->info.vendor_id << 16 | ice->info.device_id;
TRACE("Product ID : 0x%x\n", ice->product); TRACE("Product ID : 0x%x\n", ice->product);
write_cci_uint8(ice, CCI_GPIO_WRITE_MASK, ice->eeprom_data[E2PROM_MAP_GPIOMASK]); write_cci_uint8(ice, CCI_GPIO_WRITE_MASK,
write_cci_uint8(ice, CCI_GPIO_DATA, ice->eeprom_data[E2PROM_MAP_GPIOSTATE]); ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
write_cci_uint8(ice, CCI_GPIO_DIRECTION_CONTROL, ice->eeprom_data[E2PROM_MAP_GPIODIR]); write_cci_uint8(ice, CCI_GPIO_DATA,
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
write_cci_uint8(ice, CCI_GPIO_DIRECTION_CONTROL,
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
TRACE("CCI_GPIO_WRITE_MASK : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIOMASK]); TRACE("CCI_GPIO_WRITE_MASK : 0x%x\n",
TRACE("CCI_GPIO_DATA : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIOSTATE]); ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
TRACE("CCI_GPIO_DIRECTION_CONTROL : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIODIR]); TRACE("CCI_GPIO_DATA : 0x%x\n",
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
TRACE("CCI_GPIO_DIRECTION_CONTROL : 0x%x\n",
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
//Write Configuration in the PCI configuration Register //Write Configuration in the PCI configuration Register
(pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x60, 1, ice->eeprom_data[E2PROM_MAP_CONFIG]); (pci->write_pci_config)(ice->info.bus, ice->info.device,
(pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x61, 1, ice->eeprom_data[E2PROM_MAP_ACL]); ice->info.function, 0x60, 1, ice->eeprom_data[E2PROM_MAP_CONFIG]);
(pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x62, 1, ice->eeprom_data[E2PROM_MAP_I2S]); (pci->write_pci_config)(ice->info.bus, ice->info.device,
(pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x63, 1, ice->eeprom_data[E2PROM_MAP_SPDIF]); ice->info.function, 0x61, 1, ice->eeprom_data[E2PROM_MAP_ACL]);
(pci->write_pci_config)(ice->info.bus, ice->info.device,
ice->info.function, 0x62, 1, ice->eeprom_data[E2PROM_MAP_I2S]);
(pci->write_pci_config)(ice->info.bus, ice->info.device,
ice->info.function, 0x63, 1, ice->eeprom_data[E2PROM_MAP_SPDIF]);
TRACE("E2PROM_MAP_CONFIG : 0x%x\n", ice->eeprom_data[E2PROM_MAP_CONFIG]); TRACE("E2PROM_MAP_CONFIG : 0x%x\n", ice->eeprom_data[E2PROM_MAP_CONFIG]);
reg8 = ice->eeprom_data[E2PROM_MAP_CONFIG]; reg8 = ice->eeprom_data[E2PROM_MAP_CONFIG];
//Bits signification for E2PROM_MAP_CONFIG Byte //Bits signification for E2PROM_MAP_CONFIG Byte
// //
@@ -215,7 +223,8 @@ ice1712_setup(ice1712 *ice)
ice->nb_MPU401 = (reg8 & 0x1) + 1; ice->nb_MPU401 = (reg8 & 0x1) + 1;
for (i = 0; i < ice->nb_MPU401; i++) { for (i = 0; i < ice->nb_MPU401; i++) {
sprintf(ice->midi_interf[i].name, "midi/ice1712/%ld/%d", ice - cards + 1, i + 1); sprintf(ice->midi_interf[i].name, "midi/ice1712/%ld/%d",
ice - cards + 1, i + 1);
names[num_names++] = ice->midi_interf[i].name; names[num_names++] = ice->midi_interf[i].name;
} }
@@ -225,31 +234,35 @@ ice1712_setup(ice1712 *ice)
switch (ice->product) { switch (ice->product) {
case ICE1712_SUBDEVICE_DELTA66 : case ICE1712_SUBDEVICE_DELTA66 :
case ICE1712_SUBDEVICE_DELTA44 : case ICE1712_SUBDEVICE_DELTA44 :
ice->commlines.clock = DELTA66_CLK; ice->CommLines.clock = DELTA66_CLK;
ice->commlines.data_in = 0; ice->CommLines.data_in = 0;
ice->commlines.data_out = DELTA66_DOUT; ice->CommLines.data_out = DELTA66_DOUT;
ice->commlines.cs_mask = DELTA66_CLK | DELTA66_DOUT | DELTA66_CODEC_CS_0 | DELTA66_CODEC_CS_1; ice->CommLines.cs_mask = DELTA66_CLK | DELTA66_DOUT
| DELTA66_CODEC_CS_0 | DELTA66_CODEC_CS_1;
break; break;
case ICE1712_SUBDEVICE_DELTA410 : case ICE1712_SUBDEVICE_DELTA410 :
case ICE1712_SUBDEVICE_AUDIOPHILE_2496 : case ICE1712_SUBDEVICE_AUDIOPHILE_2496 :
case ICE1712_SUBDEVICE_DELTADIO2496 : case ICE1712_SUBDEVICE_DELTADIO2496 :
ice->commlines.clock = AP2496_CLK; ice->CommLines.clock = AP2496_CLK;
ice->commlines.data_in = AP2496_DIN; ice->CommLines.data_in = AP2496_DIN;
ice->commlines.data_out = AP2496_DOUT; ice->CommLines.data_out = AP2496_DOUT;
ice->commlines.cs_mask = AP2496_CLK | AP2496_DIN | AP2496_DOUT | AP2496_SPDIF_CS | AP2496_CODEC_CS; ice->CommLines.cs_mask = AP2496_CLK | AP2496_DIN
| AP2496_DOUT | AP2496_SPDIF_CS | AP2496_CODEC_CS;
break; break;
case ICE1712_SUBDEVICE_DELTA1010 : case ICE1712_SUBDEVICE_DELTA1010 :
case ICE1712_SUBDEVICE_DELTA1010LT : case ICE1712_SUBDEVICE_DELTA1010LT :
ice->commlines.clock = DELTA1010LT_CLK; ice->CommLines.clock = DELTA1010LT_CLK;
ice->commlines.data_in = DELTA1010LT_DIN; ice->CommLines.data_in = DELTA1010LT_DIN;
ice->commlines.data_out = DELTA1010LT_DOUT; ice->CommLines.data_out = DELTA1010LT_DOUT;
ice->commlines.cs_mask = DELTA1010LT_CLK | DELTA1010LT_DIN | DELTA1010LT_DOUT | DELTA1010LT_CS_NONE; ice->CommLines.cs_mask = DELTA1010LT_CLK | DELTA1010LT_DIN
| DELTA1010LT_DOUT | DELTA1010LT_CS_NONE;
break; break;
case ICE1712_SUBDEVICE_VX442 : case ICE1712_SUBDEVICE_VX442 :
ice->commlines.clock = VX442_CLK; ice->CommLines.clock = VX442_CLK;
ice->commlines.data_in = VX442_DIN; ice->CommLines.data_in = VX442_DIN;
ice->commlines.data_out = VX442_DOUT; ice->CommLines.data_out = VX442_DOUT;
ice->commlines.cs_mask = VX442_SPDIF_CS | VX442_CODEC_CS_0 | VX442_CODEC_CS_1; ice->CommLines.cs_mask = VX442_SPDIF_CS | VX442_CODEC_CS_0
| VX442_CODEC_CS_1;
break; break;
} }
@@ -291,8 +304,6 @@ ice1712_setup(ice1712 *ice)
memset(ice->log_addr_pb, 0, PLAYBACK_BUFFER_TOTAL_SIZE); memset(ice->log_addr_pb, 0, PLAYBACK_BUFFER_TOTAL_SIZE);
memset(ice->log_addr_rec, 0, RECORD_BUFFER_TOTAL_SIZE); memset(ice->log_addr_rec, 0, RECORD_BUFFER_TOTAL_SIZE);
load_settings(ice);
ice->sampling_rate = 0x08; ice->sampling_rate = 0x08;
ice->buffer = 0; ice->buffer = 0;
ice->frames_count = 0; ice->frames_count = 0;
@@ -307,15 +318,15 @@ ice1712_setup(ice1712 *ice)
ice->total_input_channels += 2; ice->total_input_channels += 2;
//Write bits in the GPIO //Write bits in the GPIO
write_cci_uint8(ice, CCI_GPIO_WRITE_MASK, ~(ice->commlines.cs_mask)); write_cci_uint8(ice, CCI_GPIO_WRITE_MASK, ~(ice->CommLines.cs_mask));
//Deselect CS //Deselect CS
write_cci_uint8(ice, CCI_GPIO_DATA, ice->commlines.cs_mask); write_cci_uint8(ice, CCI_GPIO_DATA, ice->CommLines.cs_mask);
//Set the rampe volume to a faster one //Set the rampe volume to a faster one
write_mt_uint16(ice, MT_VOLUME_CONTROL_RATE, 0x01); write_mt_uint16(ice, MT_VOLUME_CONTROL_RATE, 0x01);
//Digital Mixer To DAC 0 and SPDIF Out //Digital Mixer To DAC 0 and SPDIF Out
// write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0x0101); write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0x0101);
// write_mt_uint16(ice, MT_ROUTING_CONTROL_SPDOUT, 0x0005); // write_mt_uint16(ice, MT_ROUTING_CONTROL_SPDOUT, 0x0005);
//Just to route all input to all output //Just to route all input to all output
@@ -432,8 +443,6 @@ ice_1712_shutdown(ice1712 *ice)
delete_area(ice->mem_id_rec); delete_area(ice->mem_id_rec);
codec_write(ice, AK45xx_RESET_REGISTER, 0x00); codec_write(ice, AK45xx_RESET_REGISTER, 0x00);
save_settings(ice);
} }
@@ -519,7 +528,8 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
switch (op) { switch (op) {
case B_MULTI_GET_DESCRIPTION : case B_MULTI_GET_DESCRIPTION :
TRACE("B_MULTI_GET_DESCRIPTION\n"); TRACE("B_MULTI_GET_DESCRIPTION\n");
return ice1712_get_description((ice1712 *)cookie, (multi_description*)arg); return ice1712_get_description((ice1712 *)cookie,
(multi_description*)arg);
case B_MULTI_GET_EVENT_INFO : case B_MULTI_GET_EVENT_INFO :
TRACE("B_MULTI_GET_EVENT_INFO\n"); TRACE("B_MULTI_GET_EVENT_INFO\n");
return B_ERROR; return B_ERROR;
@@ -531,16 +541,20 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
return B_ERROR; return B_ERROR;
case B_MULTI_GET_ENABLED_CHANNELS : case B_MULTI_GET_ENABLED_CHANNELS :
TRACE("B_MULTI_GET_ENABLED_CHANNELS\n"); TRACE("B_MULTI_GET_ENABLED_CHANNELS\n");
return ice1712_get_enabled_channels((ice1712*)cookie, (multi_channel_enable*)arg); return ice1712_get_enabled_channels((ice1712*)cookie,
(multi_channel_enable*)arg);
case B_MULTI_SET_ENABLED_CHANNELS : case B_MULTI_SET_ENABLED_CHANNELS :
TRACE("B_MULTI_SET_ENABLED_CHANNELS\n"); TRACE("B_MULTI_SET_ENABLED_CHANNELS\n");
return ice1712_set_enabled_channels((ice1712*)cookie, (multi_channel_enable*)arg); return ice1712_set_enabled_channels((ice1712*)cookie,
(multi_channel_enable*)arg);
case B_MULTI_GET_GLOBAL_FORMAT : case B_MULTI_GET_GLOBAL_FORMAT :
TRACE("B_MULTI_GET_GLOBAL_FORMAT\n"); TRACE("B_MULTI_GET_GLOBAL_FORMAT\n");
return ice1712_get_global_format((ice1712*)cookie, (multi_format_info *)arg); return ice1712_get_global_format((ice1712*)cookie,
(multi_format_info *)arg);
case B_MULTI_SET_GLOBAL_FORMAT : case B_MULTI_SET_GLOBAL_FORMAT :
TRACE("B_MULTI_SET_GLOBAL_FORMAT\n"); TRACE("B_MULTI_SET_GLOBAL_FORMAT\n");
return ice1712_set_global_format((ice1712*)cookie, (multi_format_info *)arg); return ice1712_set_global_format((ice1712*)cookie,
(multi_format_info *)arg);
case B_MULTI_GET_CHANNEL_FORMATS : case B_MULTI_GET_CHANNEL_FORMATS :
TRACE("B_MULTI_GET_CHANNEL_FORMATS\n"); TRACE("B_MULTI_GET_CHANNEL_FORMATS\n");
return B_ERROR; return B_ERROR;
@@ -549,22 +563,28 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
return B_ERROR; return B_ERROR;
case B_MULTI_GET_MIX : case B_MULTI_GET_MIX :
TRACE("B_MULTI_GET_MIX\n"); TRACE("B_MULTI_GET_MIX\n");
return ice1712_get_mix((ice1712*)cookie, (multi_mix_value_info *)arg); return ice1712_get_mix((ice1712*)cookie,
(multi_mix_value_info *)arg);
case B_MULTI_SET_MIX : case B_MULTI_SET_MIX :
TRACE("B_MULTI_SET_MIX\n"); TRACE("B_MULTI_SET_MIX\n");
return ice1712_set_mix((ice1712*)cookie, (multi_mix_value_info *)arg); return ice1712_set_mix((ice1712*)cookie,
(multi_mix_value_info *)arg);
case B_MULTI_LIST_MIX_CHANNELS : case B_MULTI_LIST_MIX_CHANNELS :
TRACE("B_MULTI_LIST_MIX_CHANNELS\n"); TRACE("B_MULTI_LIST_MIX_CHANNELS\n");
return ice1712_list_mix_channels((ice1712*)cookie, (multi_mix_channel_info *)arg); return ice1712_list_mix_channels((ice1712*)cookie,
(multi_mix_channel_info *)arg);
case B_MULTI_LIST_MIX_CONTROLS : case B_MULTI_LIST_MIX_CONTROLS :
TRACE("B_MULTI_LIST_MIX_CONTROLS\n"); TRACE("B_MULTI_LIST_MIX_CONTROLS\n");
return ice1712_list_mix_controls((ice1712*)cookie, (multi_mix_control_info *)arg); return ice1712_list_mix_controls((ice1712*)cookie,
(multi_mix_control_info *)arg);
case B_MULTI_LIST_MIX_CONNECTIONS : case B_MULTI_LIST_MIX_CONNECTIONS :
TRACE("B_MULTI_LIST_MIX_CONNECTIONS\n"); TRACE("B_MULTI_LIST_MIX_CONNECTIONS\n");
return ice1712_list_mix_connections((ice1712*)cookie, (multi_mix_connection_info *)arg); return ice1712_list_mix_connections((ice1712*)cookie,
(multi_mix_connection_info *)arg);
case B_MULTI_GET_BUFFERS : case B_MULTI_GET_BUFFERS :
TRACE("B_MULTI_GET_BUFFERS\n"); TRACE("B_MULTI_GET_BUFFERS\n");
return ice1712_get_buffers((ice1712*)cookie, (multi_buffer_list*)arg); return ice1712_get_buffers((ice1712*)cookie,
(multi_buffer_list*)arg);
case B_MULTI_SET_BUFFERS : case B_MULTI_SET_BUFFERS :
TRACE("B_MULTI_SET_BUFFERS\n"); TRACE("B_MULTI_SET_BUFFERS\n");
return B_ERROR; return B_ERROR;
@@ -573,7 +593,8 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
return B_ERROR; return B_ERROR;
case B_MULTI_BUFFER_EXCHANGE : case B_MULTI_BUFFER_EXCHANGE :
// TRACE("B_MULTI_BUFFER_EXCHANGE\n"); // TRACE("B_MULTI_BUFFER_EXCHANGE\n");
return ice1712_buffer_exchange((ice1712*)cookie, (multi_buffer_info *)arg); return ice1712_buffer_exchange((ice1712*)cookie,
(multi_buffer_info *)arg);
case B_MULTI_BUFFER_FORCE_STOP : case B_MULTI_BUFFER_FORCE_STOP :
TRACE("B_MULTI_BUFFER_FORCE_STOP\n"); TRACE("B_MULTI_BUFFER_FORCE_STOP\n");
return ice1712_buffer_force_stop((ice1712*)cookie); return ice1712_buffer_force_stop((ice1712*)cookie);
@@ -613,7 +634,8 @@ ice_1712_read(void *cookie, off_t position, void *buf, size_t *num_bytes)
static status_t static status_t
ice_1712_write(void *cookie, off_t position, const void *buffer, size_t *num_bytes) ice_1712_write(void *cookie, off_t position, const void *buffer,
size_t *num_bytes)
{ {
TRACE("===write()===\n"); TRACE("===write()===\n");
*num_bytes = 0; *num_bytes = 0;
@@ -674,57 +696,22 @@ find_device(const char * name)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
status_t
load_settings(ice1712 *ice)
{
int i;
for (i = 0; i < 10; i++) {
ice->settings.playback[i].volume = -10.5;
ice->settings.playback[i].mute = false;
}
for (i = 0; i < 10; i++) {
ice->settings.record[i].volume = -10.5;
ice->settings.record[i].mute = false;
}
ice->settings.clock = 0;
ice->settings.sample_rate = 3;
ice->settings.buffer_size = 3;
ice->settings.debug_mode = 0;
//S/PDIF Settings
ice->settings.out_format = 0;
ice->settings.emphasis = 0;
ice->settings.copy_mode = 0;
return apply_settings(ice);
}
status_t
save_settings(ice1712 *ice)
{
return B_OK;
}
#define ICE1712_MUTE_VALUE (0x7F) #define ICE1712_MUTE_VALUE (0x7F)
status_t status_t
apply_settings(ice1712 *card) applySettings(ice1712 *card)
{ {
int i; int i;
uint16 val; uint16 val;
for (i = 0; i < 10; i++) { for (i = 0; i < MAX_HARDWARE_VOLUME; i++) {
//Select the channel //Select the channel
write_mt_uint8(card, MT_VOLUME_CONTROL_CHANNEL_INDEX, i); write_mt_uint8(card, MT_VOLUME_CONTROL_CHANNEL_INDEX, i);
if (card->settings.playback[i].mute) { if (card->settings.Playback[i].Mute == true) {
val = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8); val = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8);
} else { } else {
unsigned char volume = card->settings.playback[i].volume / -1.5; unsigned char volume = card->settings.Playback[i].Volume / -1.5;
if (i & 1) {//a right channel if (i & 1) {//a right channel
val = ICE1712_MUTE_VALUE << 0; //Mute left volume val = ICE1712_MUTE_VALUE << 0; //Mute left volume
val |= volume << 8; val |= volume << 8;
@@ -735,18 +722,18 @@ apply_settings(ice1712 *card)
} }
write_mt_uint16(card, MT_LR_VOLUME_CONTROL, val); write_mt_uint16(card, MT_LR_VOLUME_CONTROL, val);
if (ICE1712_VERY_VERBOSE) TRACE_VV("Apply Settings %d : 0x%x\n", i, val);
TRACE("Apply Settings %d : 0x%x\n", i, val);
} }
for (i = 0; i < 10; i++) { for (i = 0; i < MAX_HARDWARE_VOLUME; i++) {
//Select the channel //Select the channel
write_mt_uint8(card, MT_VOLUME_CONTROL_CHANNEL_INDEX, i + 10); write_mt_uint8(card, MT_VOLUME_CONTROL_CHANNEL_INDEX,
i + MAX_HARDWARE_VOLUME);
if (card->settings.record[i].mute == true) { if (card->settings.Record[i].Mute == true) {
val = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8); val = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8);
} else { } else {
unsigned char volume = card->settings.record[i].volume / -1.5; unsigned char volume = card->settings.Record[i].Volume / -1.5;
if (i & 1) {//a right channel if (i & 1) {//a right channel
val = ICE1712_MUTE_VALUE << 0; //Mute left volume val = ICE1712_MUTE_VALUE << 0; //Mute left volume
val |= volume << 8; val |= volume << 8;
@@ -757,9 +744,10 @@ apply_settings(ice1712 *card)
} }
write_mt_uint16(card, MT_LR_VOLUME_CONTROL, val); write_mt_uint16(card, MT_LR_VOLUME_CONTROL, val);
TRACE_VV("Apply Settings %d : 0x%x\n", i, val);
} }
//Output selection
return B_OK; return B_OK;
} }
@@ -13,6 +13,7 @@
#define _ICE1712_H_ #define _ICE1712_H_
#include <PCI.h> #include <PCI.h>
#include "hmulti_audio.h"
#define DRIVER_NAME "ice1712" #define DRIVER_NAME "ice1712"
#define VERSION "0.4" #define VERSION "0.4"
@@ -36,9 +37,11 @@ typedef enum product_t {
#define MAX_DAC 10 #define MAX_DAC 10
#define SWAPPING_BUFFERS 2 #define SWAPPING_BUFFERS 2
#define SAMPLE_SIZE 4 #define SAMPLE_SIZE 4
#define MIN_BUFFER_FRAMES 256 #define MIN_BUFFER_FRAMES 64
#define MAX_BUFFER_FRAMES 2048 #define MAX_BUFFER_FRAMES 2048
#define MAX_HARDWARE_VOLUME 10
#define PLAYBACK_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_DAC * SAMPLE_SIZE) #define PLAYBACK_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_DAC * SAMPLE_SIZE)
#define RECORD_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_ADC * SAMPLE_SIZE) #define RECORD_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_ADC * SAMPLE_SIZE)
@@ -50,7 +53,6 @@ typedef enum product_t {
#define MIXER_OUT_LEFT 10 #define MIXER_OUT_LEFT 10
#define MIXER_OUT_RIGHT 11 #define MIXER_OUT_RIGHT 11
typedef enum { typedef enum {
NO_IN_NO_OUT = 0, NO_IN_NO_OUT = 0,
NO_IN_YES_OUT = 1, NO_IN_YES_OUT = 1,
@@ -58,7 +60,6 @@ typedef enum {
YES_IN_YES_OUT = 3, YES_IN_YES_OUT = 3,
} _spdif_config_ ; } _spdif_config_ ;
typedef struct _midi_dev { typedef struct _midi_dev {
struct _ice1712_ *card; struct _ice1712_ *card;
void *driver; void *driver;
@@ -67,43 +68,41 @@ typedef struct _midi_dev {
char name[64]; char name[64];
} midi_dev; } midi_dev;
typedef struct _codecCommLines
typedef struct _codec_commlines
{ {
uint8 clock; uint8 clock;
uint8 data_in; uint8 data_in;
uint8 data_out; uint8 data_out;
uint8 cs_mask; //a Mask for removing all Chip select uint8 cs_mask; //a Mask for removing all Chip select
uint8 reserved[4]; uint8 reserved[4];
} codec_comm_lines; } codecCommLines;
typedef struct ChannelVolume
typedef struct channel_volume
{ {
float volume; float Volume;
bool mute; bool Mute;
} channel_volume; } ChannelVolume;
typedef struct Ice1712_Settings
typedef struct ice1712_settings
{ {
channel_volume playback[10]; //Can't change the volume of the digital mixer ChannelVolume Playback[MAX_HARDWARE_VOLUME];
channel_volume record[10]; ChannelVolume Record[MAX_HARDWARE_VOLUME];
//General Settings //General Settings
uint8 clock; //an index uint8 Clock; //an index
uint8 sample_rate; //an index uint8 BufferSize; //an index
uint8 buffer_size; //an index uint8 DebugMode; //an index for debugging
uint8 debug_mode; //an index for debugging
//S/PDif Settings //S/PDif Settings
uint8 out_format; //an index uint8 OutFormat; //an index
uint8 emphasis; //an index uint8 Emphasis; //an index
uint8 copy_mode; //an index uint8 CopyMode; //an index
uint8 reserved[32]; //Output settings
} ice1712_settings; uint8 Output[5]; //an index
uint8 Reserved[32];
} Ice1712_Settings;
typedef struct ice1712 typedef struct ice1712
{ {
@@ -127,8 +126,9 @@ typedef struct ice1712
product_t product; product_t product;
//We hope all manufacturers will use same communication lines for speaking with codec //We hope all manufacturers will use same
codec_comm_lines commlines; //communication lines for speaking with codec
codecCommLines CommLines;
uint32 buffer; uint32 buffer;
bigtime_t played_time; bigtime_t played_time;
@@ -150,12 +150,10 @@ typedef struct ice1712
uint8 sampling_rate; //in the format of the register uint8 sampling_rate; //in the format of the register
uint32 lock_source; uint32 lock_source;
ice1712_settings settings; Ice1712_Settings settings;
} ice1712; } ice1712;
status_t applySettings(ice1712 *card);
status_t apply_settings(ice1712 *card);
//For midi.c //For midi.c
extern int32 num_cards; extern int32 num_cards;
@@ -198,7 +196,8 @@ extern ice1712 cards[NUM_CARDS];
#define VX442_CODEC_CS_0 0x20 // ?? #0 #define VX442_CODEC_CS_0 0x20 // ?? #0
#define VX442_CODEC_CS_1 0x40 // ?? #1 #define VX442_CODEC_CS_1 0x40 // ?? #1
#define GPIO_I2C_DELAY 5 //Clock Delay for writing I2C data throw GPIO #define GPIO_I2C_DELAY 5 //Clock Delay for writing
//I2C data throw GPIO
//Register definition for the AK45xx codec (xx = 24 or 28) //Register definition for the AK45xx codec (xx = 24 or 28)
#define AK45xx_CHIP_ADDRESS 0x02 //Chip address of the codec #define AK45xx_CHIP_ADDRESS 0x02 //Chip address of the codec
+21 -23
View File
@@ -192,7 +192,8 @@ read_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index)
void void
write_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index, uint32 data) write_ds_channel_data(ice1712 *ice, uint8 channel,
ds8_register index, uint32 data)
{ {
uint8 ds8_channel_index = channel << 4 | index; uint8 ds8_channel_index = channel << 4 | index;
@@ -225,7 +226,6 @@ read_mt_uint32(ice1712 *ice, int8 regno)
return pci->read_io_32(ice->Multi_Track + regno); return pci->read_io_32(ice->Multi_Track + regno);
}; };
void void
write_mt_uint8(ice1712 *ice, int8 regno, uint8 value) write_mt_uint8(ice1712 *ice, int8 regno, uint8 value)
{ {
@@ -357,7 +357,7 @@ spdif_write(ice1712 *ice, uint8 reg_addr, uint8 data)
uint8 uint8
codec_read(ice1712 *ice, uint8 reg_addr) codec_read(ice1712 *ice, uint8 reg_addr)
{ {
uint8 val = 0xff; uint8 val = 0xFF;
switch (ice->product) { switch (ice->product) {
case ICE1712_SUBDEVICE_DELTA66: case ICE1712_SUBDEVICE_DELTA66:
case ICE1712_SUBDEVICE_DELTA44: case ICE1712_SUBDEVICE_DELTA44:
@@ -384,7 +384,7 @@ codec_read(ice1712 *ice, uint8 reg_addr)
uint8 uint8
spdif_read(ice1712 *ice, uint8 reg_addr) spdif_read(ice1712 *ice, uint8 reg_addr)
{ {
uint8 val = 0xff; uint8 val = 0xFF;
switch (ice->product) { switch (ice->product) {
case ICE1712_SUBDEVICE_DELTA1010: case ICE1712_SUBDEVICE_DELTA1010:
break; break;
@@ -410,7 +410,6 @@ spdif_read(ice1712 *ice, uint8 reg_addr)
return val; return val;
} }
void void
write_gpio_byte(ice1712 *ice, uint8 data, uint8 gpio_data) write_gpio_byte(ice1712 *ice, uint8 data, uint8 gpio_data)
{ {
@@ -418,23 +417,22 @@ write_gpio_byte(ice1712 *ice, uint8 data, uint8 gpio_data)
for (i = 7; i >= 0; i--) { for (i = 7; i >= 0; i--) {
// drop clock and data bits // drop clock and data bits
gpio_data &= ~(ice->commlines.clock | ice->commlines.data_out); gpio_data &= ~(ice->CommLines.clock | ice->CommLines.data_out);
// set data bit if needed // set data bit if needed
if (data & (1 << i)) if (data & (1 << i))
gpio_data |= ice->commlines.data_out; gpio_data |= ice->CommLines.data_out;
write_gpio(ice, gpio_data); write_gpio(ice, gpio_data);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
// raise clock // raise clock
gpio_data |= ice->commlines.clock; gpio_data |= ice->CommLines.clock;
write_gpio(ice, gpio_data); write_gpio(ice, gpio_data);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
} }
} }
uint8 uint8
read_gpio_byte(ice1712 *ice, uint8 gpio_data) read_gpio_byte(ice1712 *ice, uint8 gpio_data)
{ {
@@ -443,14 +441,14 @@ read_gpio_byte(ice1712 *ice, uint8 gpio_data)
for (i = 7; i >= 0; i--) { for (i = 7; i >= 0; i--) {
// drop clock // drop clock
gpio_data &= ~(ice->commlines.clock); gpio_data &= ~(ice->CommLines.clock);
write_gpio(ice, gpio_data); write_gpio(ice, gpio_data);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
if (read_gpio(ice) & ice->commlines.data_in) if (read_gpio(ice) & ice->CommLines.data_in)
data |= 1 << i; data |= 1 << i;
gpio_data |= ice->commlines.clock; gpio_data |= ice->CommLines.clock;
write_gpio(ice, gpio_data); write_gpio(ice, gpio_data);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
@@ -459,20 +457,20 @@ read_gpio_byte(ice1712 *ice, uint8 gpio_data)
return data; return data;
} }
void void
ak45xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select) ak45xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
{ {
uint8 tmp; uint8 tmp;
tmp = read_gpio(ice); tmp = read_gpio(ice);
tmp |= ice->commlines.cs_mask; tmp |= ice->CommLines.cs_mask;
tmp &= ~(chip_select); tmp &= ~(chip_select);
write_gpio(ice, tmp); write_gpio(ice, tmp);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, ((AK45xx_CHIP_ADDRESS & 0x03) << 6) | 0x20 | (reg_addr & 0x1f), tmp); write_gpio_byte(ice, ((AK45xx_CHIP_ADDRESS & 0x03) << 6) | 0x20
| (reg_addr & 0x1F), tmp);
write_gpio_byte(ice, data, tmp); write_gpio_byte(ice, data, tmp);
tmp |= chip_select; tmp |= chip_select;
@@ -480,21 +478,20 @@ ak45xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
} }
void void
cs84xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select) cs84xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
{ {
uint8 tmp; uint8 tmp;
tmp = read_gpio(ice); tmp = read_gpio(ice);
tmp |= ice->commlines.cs_mask; tmp |= ice->CommLines.cs_mask;
tmp &= ~(chip_select); tmp &= ~(chip_select);
write_gpio(ice, tmp); write_gpio(ice, tmp);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7f) << 1, tmp); write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1, tmp);
write_gpio_byte(ice, reg_addr & 0x7f, tmp); //Do not Increment write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment
write_gpio_byte(ice, data, tmp); write_gpio_byte(ice, data, tmp);
tmp |= chip_select; tmp |= chip_select;
@@ -502,20 +499,20 @@ cs84xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
} }
uint8 uint8
cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select) cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select)
{ {
uint8 tmp, data; uint8 tmp, data;
tmp = read_gpio(ice); tmp = read_gpio(ice);
tmp |= ice->commlines.cs_mask; tmp |= ice->CommLines.cs_mask;
tmp &= ~(chip_select); tmp &= ~(chip_select);
write_gpio(ice, tmp); write_gpio(ice, tmp);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7f) << 1, tmp); //For writing the MAP write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1,
tmp); //For writing the MAP
write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment
tmp |= chip_select; //Deselect the chip tmp |= chip_select; //Deselect the chip
@@ -526,7 +523,8 @@ cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select)
write_gpio(ice, tmp); write_gpio(ice, tmp);
snooze(GPIO_I2C_DELAY); snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7f) << 1 | 1, tmp); //For writing the MAP write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1 | 1,
tmp); //For writing the MAP
data = read_gpio_byte(ice, tmp); //For reading data = read_gpio_byte(ice, tmp); //For reading
tmp |= chip_select; //Deselect the chip tmp |= chip_select; //Deselect the chip
@@ -62,7 +62,8 @@ typedef enum {
} ds8_register; } ds8_register;
uint32 read_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index); uint32 read_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index);
void write_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index, uint32 data); void write_ds_channel_data(ice1712 *ice, uint8 channel,
ds8_register index, uint32 data);
//------------------------------------------------------ //------------------------------------------------------
//------------------------------------------------------ //------------------------------------------------------
//Address are [PCI_1C] + xx //Address are [PCI_1C] + xx
@@ -74,8 +74,8 @@ static status_t midi_close(void *cookie);
static status_t midi_free(void *cookie); static status_t midi_free(void *cookie);
static status_t midi_control(void *cookie, uint32 op, void *data, size_t len); static status_t midi_control(void *cookie, uint32 op, void *data, size_t len);
static status_t midi_read(void *cookie, off_t pos, void *data, size_t *len); static status_t midi_read(void *cookie, off_t pos, void *data, size_t *len);
static status_t midi_write(void *cookie, off_t pos, const void *data, size_t *len); static status_t midi_write(void *cookie, off_t pos, const void *data,
size_t *len);
device_hooks midi_hooks = { device_hooks midi_hooks = {
&midi_open, &midi_open,
@@ -90,7 +90,6 @@ device_hooks midi_hooks = {
NULL /* writev */ NULL /* writev */
}; };
static status_t midi_open(const char * name, uint32 flags, void ** cookie) static status_t midi_open(const char * name, uint32 flags, void ** cookie)
{ {
int i, ix, used_midi = -1; int i, ix, used_midi = -1;
@@ -112,8 +111,10 @@ static status_t midi_open(const char * name, uint32 flags, void ** cookie)
return ENODEV; return ENODEV;
} }
TRACE("mpu401: %p open(): %p driver: %p\n", mpu401, mpu401->open_hook, cards[ix].midi_interf[used_midi].driver); TRACE("mpu401: %p open(): %p driver: %p\n", mpu401,
ret = (*mpu401->open_hook)(cards[ix].midi_interf[used_midi].driver, flags, cookie); mpu401->open_hook, cards[ix].midi_interf[used_midi].driver);
ret = (*mpu401->open_hook)(cards[ix].midi_interf[used_midi].driver,
flags, cookie);
if (ret >= B_OK) { if (ret >= B_OK) {
cards[ix].midi_interf[used_midi].cookie = *cookie; cards[ix].midi_interf[used_midi].cookie = *cookie;
atomic_add(&cards[ix].midi_interf[used_midi].count, 1); atomic_add(&cards[ix].midi_interf[used_midi].count, 1);
@@ -164,7 +165,8 @@ static status_t midi_read(void * cookie, off_t pos, void * ptr, size_t * nread)
} }
static status_t midi_write(void * cookie, off_t pos, const void * ptr, size_t * nwritten) static status_t midi_write(void * cookie, off_t pos, const void * ptr,
size_t * nwritten)
{ {
return (*mpu401->write_hook)(cookie, pos, ptr, nwritten); return (*mpu401->write_hook)(cookie, pos, ptr, nwritten);
} }
File diff suppressed because it is too large Load Diff
@@ -16,26 +16,56 @@
#include <hmulti_audio.h> #include <hmulti_audio.h>
#define ICE1712_MULTI_CONTROL_FIRSTID (0x08000000) #define ICE1712_MULTI_CONTROL_FIRSTID (0x80000000)
#define ICE1712_MULTI_CONTROL_TYPE_MASK (0x70000000)
#define ICE1712_MULTI_CONTROL_TYPE_COMBO (0x10000000)
#define ICE1712_MULTI_CONTROL_TYPE_VOLUME (0x20000000)
#define ICE1712_MULTI_CONTROL_TYPE_OUTPUT (0x30000000)
#define ICE1712_MULTI_CONTROL_TYPE_OTHER4 (0x40000000)
#define ICE1712_MULTI_CONTROL_TYPE_OTHER5 (0x50000000)
#define ICE1712_MULTI_CONTROL_TYPE_OTHER6 (0x60000000)
#define ICE1712_MULTI_CONTROL_TYPE_OTHER7 (0x70000000)
#define ICE1712_MULTI_CONTROL_CHANNEL_MASK (0x0FF00000)
#define ICE1712_MULTI_CONTROL_INDEX_MASK (0x00000FFF)
#define ICE1712_MULTI_SET_CHANNEL(_c_) ((_c_ << 20) & \
ICE1712_MULTI_CONTROL_CHANNEL_MASK)
#define ICE1712_MULTI_GET_CHANNEL(_c_) ((_c_ & \
ICE1712_MULTI_CONTROL_CHANNEL_MASK) >> 20)
#define ICE1712_MULTI_SET_INDEX(_i_) (_i_ & \
ICE1712_MULTI_CONTROL_INDEX_MASK)
#define ICE1712_MULTI_GET_INDEX(_i_) (_i_ & \
ICE1712_MULTI_CONTROL_INDEX_MASK)
/*
#define ICE1712_MULTI_CONTROL_VOLUME_PB (0x00010000) #define ICE1712_MULTI_CONTROL_VOLUME_PB (0x00010000)
#define ICE1712_MULTI_CONTROL_VOLUME_REC (0x00020000) #define ICE1712_MULTI_CONTROL_VOLUME_REC (0x00020000)
#define ICE1712_MULTI_CONTROL_MUTE (0x00040000) #define ICE1712_MULTI_CONTROL_MUTE (0x00040000)
#define ICE1712_MULTI_CONTROL_MUX (0x00080000) #define ICE1712_MULTI_CONTROL_MUX (0x00080000)
#define ICE1712_MULTI_CONTROL_MASK (0x00FF0000) #define ICE1712_MULTI_CONTROL_MASK (0x00FF0000)
#define ICE1712_MULTI_CONTROL_CHANNEL_MASK (0x000000FF) #define ICE1712_MULTI_CONTROL_CHANNEL_MASK (0x000000FF)
*/
#define CONTROL_IS_MASTER (0) #define CONTROL_IS_MASTER (0)
status_t ice1712_get_description(ice1712 *card, multi_description *data); status_t ice1712_get_description(ice1712 *card, multi_description *data);
status_t ice1712_get_enabled_channels(ice1712 *card, multi_channel_enable *data); status_t ice1712_get_enabled_channels(ice1712 *card,
status_t ice1712_set_enabled_channels(ice1712 *card, multi_channel_enable *data); multi_channel_enable *data);
status_t ice1712_set_enabled_channels(ice1712 *card,
multi_channel_enable *data);
status_t ice1712_get_global_format(ice1712 *card, multi_format_info *data); status_t ice1712_get_global_format(ice1712 *card, multi_format_info *data);
status_t ice1712_set_global_format(ice1712 *card, multi_format_info *data); status_t ice1712_set_global_format(ice1712 *card, multi_format_info *data);
status_t ice1712_get_mix(ice1712 *card, multi_mix_value_info *data); status_t ice1712_get_mix(ice1712 *card, multi_mix_value_info *data);
status_t ice1712_set_mix(ice1712 *card, multi_mix_value_info *data); status_t ice1712_set_mix(ice1712 *card, multi_mix_value_info *data);
status_t ice1712_list_mix_channels(ice1712 *card, multi_mix_channel_info *data); status_t ice1712_list_mix_channels(ice1712 *card,
status_t ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *data); multi_mix_channel_info *data);
status_t ice1712_list_mix_connections(ice1712 *card, multi_mix_connection_info *data); status_t ice1712_list_mix_controls(ice1712 *card,
multi_mix_control_info *data);
status_t ice1712_list_mix_connections(ice1712 *card,
multi_mix_connection_info *data);
status_t ice1712_get_buffers(ice1712 *card, multi_buffer_list *data); status_t ice1712_get_buffers(ice1712 *card, multi_buffer_list *data);
status_t ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data); status_t ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data);
status_t ice1712_buffer_force_stop(ice1712 *card); status_t ice1712_buffer_force_stop(ice1712 *card);
@@ -76,7 +76,8 @@ alloc_mem(void **phy, void **log, size_t size, const char *name)
*log = logadr; *log = logadr;
if (phy) if (phy)
*phy = (void*)(addr_t)pe.address; *phy = (void*)(addr_t)pe.address;
TRACE("area = %d, size = %#08X, log = %#08X, phy = %#08X\n", (int)areaid, (int)size, (int)logadr, (int)pe.address); TRACE("area = %d, size = %#08X, log = %#08X, phy = %#08X\n",
(int)areaid, (int)size, (int)logadr, (int)pe.address);
return areaid; return areaid;
} }