From 751232fbe0ece02ffc952880ececd925159ec9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 12 Jan 2008 17:05:13 +0000 Subject: [PATCH] update from Jerome Leveque git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23444 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/audio/ice1712/Jamfile | 1 - .../kernel/drivers/audio/ice1712/ice1712.c | 116 +++++++++------- .../kernel/drivers/audio/ice1712/ice1712.h | 28 +++- src/add-ons/kernel/drivers/audio/ice1712/io.c | 1 + .../kernel/drivers/audio/ice1712/multi.c | 130 ++++++++++++++---- .../kernel/drivers/audio/ice1712/multi.h | 7 +- 6 files changed, 203 insertions(+), 80 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/ice1712/Jamfile b/src/add-ons/kernel/drivers/audio/ice1712/Jamfile index b432abf8da..8162afe617 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/Jamfile +++ b/src/add-ons/kernel/drivers/audio/ice1712/Jamfile @@ -13,4 +13,3 @@ KernelAddon ice1712 : util.c ; - diff --git a/src/add-ons/kernel/drivers/audio/ice1712/ice1712.c b/src/add-ons/kernel/drivers/audio/ice1712/ice1712.c index 359e4e1cd6..dea0bb571e 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/ice1712.c +++ b/src/add-ons/kernel/drivers/audio/ice1712/ice1712.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "debug.h" #include "ice1712.h" @@ -25,7 +24,6 @@ #include "io.h" #include "midi_driver.h" #include "multi.h" -#include "multi_audio.h" #include "util.h" @@ -57,7 +55,8 @@ char *names[NUM_CARDS*20+1]; int32 api_version = B_CUR_DRIVER_API_VERSION; -#define MODULE_TEST_PATH "audio/hmulti/ice1712" +#define HMULTI_AUDIO_DEV_PATH "audio/hmulti/ice1712" +//#define HMULTI_AUDIO_DEV_PATH "audio/multi/ice1712" //------------------------------------------------------ //------------------------------------------------------ @@ -139,7 +138,6 @@ ice1712_setup(ice1712 *ice) { int result, i; long result_l = 0; - uint8 eeprom_data[32]; uint8 reg8 = 0; ice->irq = ice->info.u.h0.interrupt_line; @@ -154,51 +152,74 @@ ice1712_setup(ice1712 *ice) write_ccs_uint8(ice, CCS_CONTROL_STATUS, 0x01); snooze(200000); - result = read_eeprom(ice, eeprom_data); + result = read_eeprom(ice, ice->eeprom_data); - TRACE_ICE(("EEprom -> ")); +/* TRACE_ICE(("EEprom -> ")); for (i = 0; i < 32; i++) TRACE_ICE(("%x, ", eeprom_data[i])); - TRACE_ICE(("<- EEprom\n")); + TRACE_ICE(("<- EEprom\n"));*/ write_ccs_uint8(ice, CCS_SERR_SHADOW, 0x01); //Write all configurations register from EEProm - - //Write enable SVID -// (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x42, 2, 0x86); - //Change SVID - ice->info.device_id = eeprom_data[1] << 8 | eeprom_data[0]; - ice->info.vendor_id = eeprom_data[3] << 8 | eeprom_data[2]; + ice->info.device_id = ice->eeprom_data[E2PROM_MAP_SUBVENDOR_HIGH] << 8 | 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; -// (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x2C, 4, ice->product); - - //Write Disable SVID -// (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x42, 2, 0x06); - TRACE_ICE(("Product ID : 0x%x\n", ice->product)); - (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x60, 1, eeprom_data[6]); - (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x61, 1, eeprom_data[7]); - (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x62, 1, eeprom_data[8]); - (pci->write_pci_config)(ice->info.bus, ice->info.device, ice->info.function, 0x63, 1, eeprom_data[9]); + write_cci_uint8(ice, CCI_GPIO_WRITE_MASK, ice->eeprom_data[E2PROM_MAP_GPIOMASK]); + 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]); - write_cci_uint8(ice, CCI_GPIO_WRITE_MASK, eeprom_data[10]); - write_cci_uint8(ice, CCI_GPIO_DATA, eeprom_data[11]); - write_cci_uint8(ice, CCI_GPIO_DIRECTION_CONTROL, eeprom_data[12]); - write_cci_uint8(ice, CCI_CONS_POWER_DOWN, eeprom_data[13]); - write_cci_uint8(ice, CCI_MULTI_POWER_DOWN, eeprom_data[14]); + TRACE_ICE(("CCI_GPIO_WRITE_MASK : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIOMASK])); + TRACE_ICE(("CCI_GPIO_DATA : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIOSTATE])); + TRACE_ICE(("CCI_GPIO_DIRECTION_CONTROL : 0x%x\n", ice->eeprom_data[E2PROM_MAP_GPIODIR])); - ice->nb_MPU401 = ((eeprom_data[6] & 0x20) >> 5) + 1; - ice->nb_ADC = (((eeprom_data[6] & 0x0C) >> 2) + 1 ) * 2; - ice->nb_DAC = ((eeprom_data[6] & 0x03) + 1) * 2; - ice->spdif_config = eeprom_data[9] & 0x03; + //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, 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_ICE(("E2PROM_MAP_CONFIG : 0x%x\n", ice->eeprom_data[E2PROM_MAP_CONFIG])); + reg8 = ice->eeprom_data[E2PROM_MAP_CONFIG]; + //Bits signification for E2PROM_MAP_CONFIG Byte + // + // 8 7 6 5 4 3 2 1 0 + // |-D-|-C-|---B---|---A--- + // + // D : MPU401 number minus 1 + // C : AC'97 + // B : Stereo ADC number minus 1 (=> 1 to 4) + // A : Stereo DAC number minus 1 (=> 1 to 4) + + ice->nb_DAC = ((reg8 & 0x03) + 1) * 2; + reg8 >>= 2; + ice->nb_ADC = ((reg8 & 0x03) + 1) * 2; + reg8 >>= 2; + + if ((reg8 & 0x01) != 0) {//Consumer AC'97 Exist + TRACE_ICE(("Consumer AC'97 does exist\n")); + //For now do nothing +/* write_ccs_uint8(ice, CCS_CONS_AC97_COMMAND_STATUS, 0x40); + snooze(10000); + write_ccs_uint8(ice, CCS_CONS_AC97_COMMAND_STATUS, 0x00); + snooze(20000); +*/ } else { + TRACE_ICE(("Consumer AC'97 does NOT exist\n")); + } + reg8 >>= 1; + ice->nb_MPU401 = (reg8 & 0x1) + 1; + for (i = 0; i < ice->nb_MPU401; i++) { sprintf(ice->midi_interf[i].name, "midi/ice1712/%ld/%d", ice - cards + 1, i + 1); names[num_names++] = ice->midi_interf[i].name; } - + + TRACE_ICE(("E2PROM_MAP_SPDIF : 0x%x\n", ice->eeprom_data[E2PROM_MAP_SPDIF])); + ice->spdif_config = ice->eeprom_data[E2PROM_MAP_SPDIF]; + switch (ice->product) { case ICE1712_SUBDEVICE_DELTA66 : @@ -223,20 +244,10 @@ ice1712_setup(ice1712 *ice) break; } - sprintf(ice->name, "%s/%ld", MODULE_TEST_PATH, ice - cards + 1); + sprintf(ice->name, "%s/%ld", HMULTI_AUDIO_DEV_PATH, ice - cards + 1); names[num_names++] = ice->name; names[num_names] = NULL; - - if ((eeprom_data[6] & 0x10) == 0) {//Consumer AC'97 Exist - TRACE_ICE(("Consumer AC'97 does exist\n")); - write_ccs_uint8(ice, CCS_CONS_AC97_COMMAND_STATUS, 0x40); - snooze(10000); - write_ccs_uint8(ice, CCS_CONS_AC97_COMMAND_STATUS, 0x00); - snooze(20000); - } else { - TRACE_ICE(("Consumer AC'97 does NOT exist\n")); - } - + ice->buffer_ready_sem = create_sem(0, "Buffer Exchange"); // TRACE_ICE(("installing interrupt : %0x\n", ice->irq)); @@ -275,10 +286,21 @@ ice1712_setup(ice1712 *ice) //Deselect CS write_cci_uint8(ice, CCI_GPIO_DATA, ice->gpio_cs_mask); - //Just to route input to output -// write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0x0101); -// write_mt_uint32(ice, MT_CAPTURED_DATA, 0x0000); + //Just to route all input to all output +// write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0xAAAA); +// write_mt_uint32(ice, MT_CAPTURED_DATA, 0x76543210); + //Just to route SPDIF Input to DAC 0 +// write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0xAAAF); +// write_mt_uint32(ice, MT_CAPTURED_DATA, 0x76543280); + + //Mute all input +/* for (i = 0; i < 20; i++) + { + write_mt_uint8(ice, MT_VOLUME_CONTROL_CHANNEL_INDEX, i); + write_mt_uint16(ice, MT_VOLUME_CONTROL_CHANNEL_INDEX, 0x7F7F); + } +*/ //Unmask Interrupt write_ccs_uint8(ice, CCS_CONTROL_STATUS, 0x41); diff --git a/src/add-ons/kernel/drivers/audio/ice1712/ice1712.h b/src/add-ons/kernel/drivers/audio/ice1712/ice1712.h index 6a85a4c7d0..f1acd61949 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/ice1712.h +++ b/src/add-ons/kernel/drivers/audio/ice1712/ice1712.h @@ -13,6 +13,7 @@ #define _ICE1712_H_ #include +#include "hmulti_audio.h" #define DRIVER_NAME "ice1712" #define VERSION "0.3" @@ -87,6 +88,8 @@ typedef struct _ice1712_ uint32 DMA_Path; //PCI_18 uint32 Multi_Track; //PCI_1C + uint8 eeprom_data[32]; + int8 nb_ADC; //Mono Channel int8 nb_DAC; //Mono Channel _spdif_config_ spdif_config; @@ -117,6 +120,7 @@ typedef struct _ice1712_ sem_id buffer_ready_sem; uint8 sampling_rate; //in the format of the register + uint32 lock_source; } ice1712; @@ -124,7 +128,7 @@ extern int32 num_cards; extern ice1712 cards[NUM_CARDS]; //??????? -#define GPIO_SPDIF_STATUS 0x02 //Status +#define GPIO_SPDIF_STATUS 0x02 //Status #define GPIO_SPDIF_CCLK 0x04 //data Clock #define GPIO_SPDIF_DOUT 0x08 //data output @@ -213,4 +217,26 @@ extern ice1712 cards[NUM_CARDS]; } */ +//This map come from ALSA sound drivers +#define E2PROM_MAP_SUBVENDOR_LOW 0x00 +#define E2PROM_MAP_SUBVENDOR_HIGH 0x01 +#define E2PROM_MAP_SUBDEVICE_LOW 0x02 +#define E2PROM_MAP_SUBDEVICE_HIGH 0x03 +#define E2PROM_MAP_SIZE 0x04 +#define E2PROM_MAP_VERSION 0x05 +#define E2PROM_MAP_CONFIG 0x06 +#define E2PROM_MAP_ACL 0x07 +#define E2PROM_MAP_I2S 0x08 +#define E2PROM_MAP_SPDIF 0x09 +#define E2PROM_MAP_GPIOMASK 0x0A +#define E2PROM_MAP_GPIOSTATE 0x0B +#define E2PROM_MAP_GPIODIR 0x0C +#define E2PROM_MAP_AC97MAIN 0x0D +#define E2PROM_MAP_AC97PCM 0x0F +#define E2PROM_MAP_AC97REC 0x11 +#define E2PROM_MAP_AC97REC_SOURCE 0x13 +#define E2PROM_MAP_DAC_ID 0x14 +#define E2PROM_MAP_ADC_ID 0x18 +#define E2PROM_MAP_EXTRA 0x1C + #endif diff --git a/src/add-ons/kernel/drivers/audio/ice1712/io.c b/src/add-ons/kernel/drivers/audio/ice1712/io.c index ad755598fc..8470a0a060 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/io.c +++ b/src/add-ons/kernel/drivers/audio/ice1712/io.c @@ -438,6 +438,7 @@ cs84xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select) // drop clock and Data tmp &= ~(ice->digital_codec.clock | ice->digital_codec.data_out); + tmp |= ice->gpio_cs_mask; write_gpio(ice, tmp); snooze(CS84xx_DELAY); diff --git a/src/add-ons/kernel/drivers/audio/ice1712/multi.c b/src/add-ons/kernel/drivers/audio/ice1712/multi.c index 1fef6607d1..1216adf765 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/multi.c +++ b/src/add-ons/kernel/drivers/audio/ice1712/multi.c @@ -17,8 +17,8 @@ #include -#define AUTORIZED_RATE (B_SR_96000 | B_SR_88200 | B_SR_48000 | B_SR_44100) -#define AUTORIZED_SAMPLE_SIZE (B_FMT_24BIT) +#define AUTORIZED_RATE (B_SR_SAME_AS_INPUT | B_SR_IS_GLOBAL | B_SR_96000 | B_SR_88200 | B_SR_48000 | B_SR_44100) +#define AUTORIZED_SAMPLE_SIZE (B_FMT_32BIT) static void start_DMA(ice1712 *card) @@ -30,7 +30,7 @@ start_DMA(ice1712 *card) write_mt_uint32(card, MT_PROF_PB_DMA_BASE_ADDRESS, (uint32)card->phys_addr_pb); write_mt_uint16(card, MT_PROF_PB_DMA_COUNT_ADDRESS, (size * SWAPPING_BUFFERS) - 1); //We want interrupt only from playback - write_mt_uint16(card, MT_PROF_PB_DMA_TERM_COUNT, size - 1/*0*/); + write_mt_uint16(card, MT_PROF_PB_DMA_TERM_COUNT, size - 1); TRACE_ICE(("SIZE DMA PLAYBACK %#x\n", size)); size = card->input_buffer_size * MAX_ADC; @@ -38,7 +38,7 @@ start_DMA(ice1712 *card) write_mt_uint32(card, MT_PROF_REC_DMA_BASE_ADDRESS, (uint32)card->phys_addr_rec); write_mt_uint16(card, MT_PROF_REC_DMA_COUNT_ADDRESS, (size * SWAPPING_BUFFERS) - 1); //We do not want any interrupt from the record - write_mt_uint16(card, MT_PROF_REC_DMA_TERM_COUNT, /*size - 1*/0); + write_mt_uint16(card, MT_PROF_REC_DMA_TERM_COUNT, 0); TRACE_ICE(("SIZE DMA RECORD %#x\n", size)); //Enable output AND Input from Analog CODEC @@ -75,7 +75,7 @@ start_DMA(ice1712 *card) case ICE1712_SUBDEVICE_AUDIOPHILE_2496 : spdif_write(card, CS84xx_SERIAL_INPUT_FORMAT_REG, 0x85); spdif_write(card, CS84xx_SERIAL_OUTPUT_FORMAT_REG, 0x85); - spdif_write(card, CS84xx_SERIAL_OUTPUT_FORMAT_REG, 0x41); +// spdif_write(card, CS84xx_SERIAL_OUTPUT_FORMAT_REG, 0x41); break; case ICE1712_SUBDEVICE_DELTA410 : break; @@ -91,11 +91,10 @@ start_DMA(ice1712 *card) break; } - card->buffer = 0; + card->buffer = 1; write_mt_uint8(card, MT_PROF_PB_CONTROL, 5); } - status_t ice1712_get_description(ice1712 *card, multi_description *data) { @@ -136,7 +135,7 @@ ice1712_get_description(ice1712 *card, multi_description *data) break; } - strncpy(data->vendor_info, "Jerome Leveque", 32); + strncpy(data->vendor_info, "J. H Leveque", 32); data->output_channel_count = card->total_output_channels; data->input_channel_count = card->total_input_channels; @@ -144,6 +143,7 @@ ice1712_get_description(ice1712 *card, multi_description *data) data->input_bus_channel_count = 0; data->aux_bus_channel_count = 0; + TRACE_ICE(("request_channel_count = %d\n", data->request_channel_count)); if (data->request_channel_count >= (card->total_output_channels + card->total_input_channels)) { for (i = 0; i < card->nb_DAC; i++) { @@ -151,7 +151,7 @@ ice1712_get_description(ice1712 *card, multi_description *data) data->channels[chan].channel_id = chan; data->channels[chan].kind = B_MULTI_OUTPUT_CHANNEL; data->channels[chan].designations = B_CHANNEL_STEREO_BUS | \ - (i & 1) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT; + ((i & 1) == 0) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT; data->channels[chan].connectors = 0; chan++; } @@ -175,7 +175,7 @@ ice1712_get_description(ice1712 *card, multi_description *data) data->channels[chan].channel_id = chan; data->channels[chan].kind = B_MULTI_INPUT_CHANNEL; data->channels[chan].designations = B_CHANNEL_STEREO_BUS | \ - (i & 1) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT; + ((i & 1) == 0) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT; data->channels[chan].connectors = 0; chan++; } @@ -217,7 +217,7 @@ ice1712_get_description(ice1712 *card, multi_description *data) data->max_cvsr_rate = 96000; data->output_formats = data->input_formats = AUTORIZED_SAMPLE_SIZE; - data->lock_sources = B_MULTI_LOCK_INTERNAL /*| B_MULTI_LOCK_SPDIF*/; + data->lock_sources = B_MULTI_LOCK_INTERNAL | B_MULTI_LOCK_SPDIF; data->timecode_sources = 0; data->interface_flags = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD; data->start_latency = 0; @@ -262,6 +262,8 @@ ice1712_set_enabled_channels(ice1712 *card, multi_channel_enable *data) else write_mt_uint8(card, MT_SAMPLING_RATE_SELECT, card->sampling_rate); + card->lock_source = data->lock_source; + return B_OK; } @@ -310,7 +312,8 @@ ice1712_set_global_format(ice1712 *card, multi_format_info *data) TRACE_ICE(("Input Sampling Rate = %#x\n", data->input.rate)); TRACE_ICE(("Output Sampling Rate = %#x\n", data->output.rate)); - if (data->input.rate == data->output.rate) { + if ((data->input.rate == data->output.rate) && + (card->lock_source == B_MULTI_LOCK_INTERNAL)) { switch (data->input.rate) { case B_SR_96000 : @@ -335,14 +338,14 @@ ice1712_set_global_format(ice1712 *card, multi_format_info *data) status_t -ice1712_get_mix(ice1712 *card, multi_mix_value_info *MMVI) +ice1712_get_mix(ice1712 *card, multi_mix_value_info *data) {//Not Implemented return B_ERROR; } status_t -ice1712_set_mix(ice1712 *card, multi_mix_value_info *MMVI) +ice1712_set_mix(ice1712 *card, multi_mix_value_info *data) {//Not Implemented return B_ERROR; } @@ -355,10 +358,70 @@ ice1712_list_mix_channels(ice1712 *card, multi_mix_channel_info *data) } -status_t -ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *MMCI) -{//Not Implemented - return B_ERROR; +#define MULTI_AUDIO_BASE_ID 1024 +#define MULTI_AUDIO_MASTER_ID 0 + +#ifndef B_MULTI_MIX_GROUP +#define B_MULTI_MIX_GROUP 10 +#endif + +#ifndef S_null +#define S_null 10 +#endif + +#ifndef S_STEREO_MIX +#define S_STEREO_MIX 10 +#endif + +static int32 +create_group_control(multi_mix_control *multi, int32 idx, int32 parent, int32 string, const char* name) +{ + multi->id = MULTI_AUDIO_BASE_ID + idx; + multi->master = parent; + multi->flags = B_MULTI_MIX_GROUP; + multi->master = MULTI_AUDIO_MASTER_ID; +// multi->string = string; + + if (name != NULL) + strcpy(multi->name, name); + + return multi->id; +} + +static int32 +create_slider_control(multi_mix_control *multi, int32 idx, int32 parent, int32 string, const char* name) +{ + multi->id = MULTI_AUDIO_BASE_ID + idx; + multi->master = parent; + multi->flags = B_MULTI_MIX_GAIN; + multi->master = MULTI_AUDIO_MASTER_ID + 1; +// multi->string = string; + + multi->u.gain.min_gain = -144.0; + multi->u.gain.max_gain = 0.0; + multi->u.gain.granularity = 1.5; + + if (name != NULL) + strcpy(multi->name, name); + + return multi->id; +} + + +status_t +ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *data) +{ + int32 parent; + + TRACE_ICE(("count = %d\n", data->control_count)); + parent = create_group_control (data->controls + 0, 0, 0, S_null, "Playback"); + create_slider_control (data->controls + 1, 1, parent, S_STEREO_MIX, "Master Output"); + + parent = create_group_control (data->controls + 2, 2, 0, S_null, "Record"); + create_slider_control (data->controls + 3, 3, parent, S_STEREO_MIX, "Master Input"); + data->control_count = 4; + + return B_OK; } @@ -382,13 +445,13 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data) TRACE_ICE(("request_record_channels = %#x\n", data->request_record_channels)); TRACE_ICE(("request_record_buffer_size = %#x\n", data->request_record_buffer_size)); - // MIN_BUFFER_FRAMES <= requested value are <= MAX_BUFFER_FRAMES + // MIN_BUFFER_FRAMES <= requested value <= MAX_BUFFER_FRAMES card->output_buffer_size = data->request_playback_buffer_size <= MAX_BUFFER_FRAMES ? \ data->request_playback_buffer_size >= MIN_BUFFER_FRAMES ? \ data->request_playback_buffer_size : MIN_BUFFER_FRAMES \ : MAX_BUFFER_FRAMES; - // MIN_BUFFER_FRAMES <= requested value are <= MAX_BUFFER_FRAMES + // MIN_BUFFER_FRAMES <= requested value <= MAX_BUFFER_FRAMES card->input_buffer_size = data->request_record_buffer_size <= MAX_BUFFER_FRAMES ? \ data->request_record_buffer_size >= MIN_BUFFER_FRAMES ? \ data->request_record_buffer_size : MIN_BUFFER_FRAMES \ @@ -490,6 +553,7 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data) data->return_record_buffers = SWAPPING_BUFFERS; data->return_record_channels = card->total_input_channels; + data->return_record_channels = chan_i; data->return_record_buffer_size = card->input_buffer_size; TRACE_ICE(("return_record_buffers = %#x\n", data->return_record_buffers)); @@ -521,12 +585,12 @@ ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data) // do playback data->played_real_time = card->played_time; data->played_frames_count += card->output_buffer_size; - data->playback_buffer_cycle = (card->buffer - 1) & 0x1; //Buffer TO fill + data->playback_buffer_cycle = (card->buffer/* - 1*/) & 0x1; //Buffer TO fill // do record data->recorded_real_time = card->played_time; data->recorded_frames_count += card->input_buffer_size; - data->record_buffer_cycle = (card->buffer - 1) & 0x1; //Buffer filled + data->record_buffer_cycle = (card->buffer/* - 1*/) & 0x1; //Buffer filled data->flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD; @@ -552,12 +616,16 @@ ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data) case B_TIMED_OUT : TRACE_ICE(("B_TIMED_OUT\n")); start_DMA(card); + cpu_status = lock(); - data->record_buffer_cycle = 0; - data->playback_buffer_cycle = 1; - data->played_frames_count += card->output_buffer_size; - data->recorded_frames_count += card->input_buffer_size; + data->played_real_time = card->played_time; + data->playback_buffer_cycle = 0; + data->played_frames_count += card->output_buffer_size; + + data->recorded_real_time = card->played_time; + data->record_buffer_cycle = 0; + data->recorded_frames_count += card->input_buffer_size; data->flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD; unlock(cpu_status); @@ -568,12 +636,20 @@ ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data) break; } +/* if ((card->buffer % 500) == 0) + { + uint8 reg8, reg8_dir; + reg8 = read_gpio(card); + reg8_dir = read_cci_uint8(card, CCI_GPIO_DIRECTION_CONTROL); + TRACE_ICE(("B_NO_ERROR buffer = %d : GPIO = %d (%d)\n", card->buffer, reg8, reg8_dir)); + } +*/ return B_OK; } status_t ice1712_buffer_force_stop(ice1712 *card) { -// write_mt_uint8(card, MT_PROF_PB_CONTROL, 0); + write_mt_uint8(card, MT_PROF_PB_CONTROL, 0); return B_OK; } diff --git a/src/add-ons/kernel/drivers/audio/ice1712/multi.h b/src/add-ons/kernel/drivers/audio/ice1712/multi.h index b8c6d9bbe8..e24b1557d6 100644 --- a/src/add-ons/kernel/drivers/audio/ice1712/multi.h +++ b/src/add-ons/kernel/drivers/audio/ice1712/multi.h @@ -9,7 +9,6 @@ * Distributed under the terms of the MIT license. */ -#include "multi_audio.h" #include "ice1712.h" status_t ice1712_get_description(ice1712 *card, multi_description *data); @@ -17,10 +16,10 @@ status_t ice1712_get_enabled_channels(ice1712 *card, 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_set_global_format(ice1712 *card, multi_format_info *data); -status_t ice1712_get_mix(ice1712 *card, multi_mix_value_info *MMVI); -status_t ice1712_set_mix(ice1712 *card, multi_mix_value_info *MMVI); +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_list_mix_channels(ice1712 *card, multi_mix_channel_info *data); -status_t ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *MMCI); +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_buffer_exchange(ice1712 *card, multi_buffer_info *data);