Internal routing management for ice1712 audio driver

* internal chip routing management.
* style cleanup.
This commit is contained in:
Jerome Leveque
2011-11-18 19:20:25 +01:00
committed by Jérôme Duval
parent 8a5fb91c07
commit 8519dc0f22
6 changed files with 232 additions and 159 deletions
@@ -9,6 +9,7 @@
* Distributed under the terms of the MIT license.
*/
#include <KernelExport.h>
#include <Drivers.h>
#include <Errors.h>
@@ -67,7 +68,8 @@ int32 api_version = B_CUR_DRIVER_API_VERSION;
//------------------------------------------------------
//------------------------------------------------------
status_t init_hardware(void)
status_t
init_hardware(void)
{
int ix = 0;
pci_info info;
@@ -137,6 +139,7 @@ ice1712_setup(ice1712 *ice)
int result, i;
status_t status = B_OK;
uint8 reg8 = 0;
uint16 mute;
ice->irq = ice->info.u.h0.interrupt_line;
ice->Controller = ice->info.u.h0.base_registers[0];
@@ -161,36 +164,36 @@ ice1712_setup(ice1712 *ice)
//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->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->eeprom_data[E2PROM_MAP_SUBDEVICE_LOW];
ice->product = ice->info.vendor_id << 16 | ice->info.device_id;
TRACE("Product ID : 0x%x\n", ice->product);
write_cci_uint8(ice, CCI_GPIO_WRITE_MASK,
ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
write_cci_uint8(ice, CCI_GPIO_DATA,
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
write_cci_uint8(ice, CCI_GPIO_DIRECTION_CONTROL,
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
TRACE("CCI_GPIO_WRITE_MASK : 0x%x\n",
ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
ice->eeprom_data[E2PROM_MAP_GPIOMASK]);
TRACE("CCI_GPIO_DATA : 0x%x\n",
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
ice->eeprom_data[E2PROM_MAP_GPIOSTATE]);
TRACE("CCI_GPIO_DIRECTION_CONTROL : 0x%x\n",
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
ice->eeprom_data[E2PROM_MAP_GPIODIR]);
//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]);
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]);
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]);
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]);
ice->info.function, 0x63, 1, ice->eeprom_data[E2PROM_MAP_SPDIF]);
TRACE("E2PROM_MAP_CONFIG : 0x%x\n", ice->eeprom_data[E2PROM_MAP_CONFIG]);
reg8 = ice->eeprom_data[E2PROM_MAP_CONFIG];
@@ -224,7 +227,7 @@ ice1712_setup(ice1712 *ice)
for (i = 0; i < ice->nb_MPU401; i++) {
sprintf(ice->midi_interf[i].name, "midi/ice1712/%ld/%d",
ice - cards + 1, i + 1);
ice - cards + 1, i + 1);
names[num_names++] = ice->midi_interf[i].name;
}
@@ -238,7 +241,7 @@ ice1712_setup(ice1712 *ice)
ice->CommLines.data_in = 0;
ice->CommLines.data_out = DELTA66_DOUT;
ice->CommLines.cs_mask = DELTA66_CLK | DELTA66_DOUT
| DELTA66_CODEC_CS_0 | DELTA66_CODEC_CS_1;
| DELTA66_CODEC_CS_0 | DELTA66_CODEC_CS_1;
break;
case ICE1712_SUBDEVICE_DELTA410 :
case ICE1712_SUBDEVICE_AUDIOPHILE_2496 :
@@ -247,7 +250,7 @@ ice1712_setup(ice1712 *ice)
ice->CommLines.data_in = AP2496_DIN;
ice->CommLines.data_out = AP2496_DOUT;
ice->CommLines.cs_mask = AP2496_CLK | AP2496_DIN
| AP2496_DOUT | AP2496_SPDIF_CS | AP2496_CODEC_CS;
| AP2496_DOUT | AP2496_SPDIF_CS | AP2496_CODEC_CS;
break;
case ICE1712_SUBDEVICE_DELTA1010 :
case ICE1712_SUBDEVICE_DELTA1010LT :
@@ -255,14 +258,14 @@ ice1712_setup(ice1712 *ice)
ice->CommLines.data_in = DELTA1010LT_DIN;
ice->CommLines.data_out = DELTA1010LT_DOUT;
ice->CommLines.cs_mask = DELTA1010LT_CLK | DELTA1010LT_DIN
| DELTA1010LT_DOUT | DELTA1010LT_CS_NONE;
| DELTA1010LT_DOUT | DELTA1010LT_CS_NONE;
break;
case ICE1712_SUBDEVICE_VX442 :
ice->CommLines.clock = VX442_CLK;
ice->CommLines.data_in = VX442_DIN;
ice->CommLines.data_out = VX442_DOUT;
ice->CommLines.cs_mask = VX442_SPDIF_CS | VX442_CODEC_CS_0
| VX442_CODEC_CS_1;
| VX442_CODEC_CS_1;
break;
}
@@ -325,9 +328,10 @@ ice1712_setup(ice1712 *ice)
//Set the rampe volume to a faster one
write_mt_uint16(ice, MT_VOLUME_CONTROL_RATE, 0x01);
//Digital Mixer To DAC 0 and SPDIF Out
write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0x0101);
// write_mt_uint16(ice, MT_ROUTING_CONTROL_SPDOUT, 0x0005);
//All Analog outputs from DMA
write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0x0000);
//All Digital output from DMA
write_mt_uint16(ice, MT_ROUTING_CONTROL_SPDOUT, 0x0000);
//Just to route all input to all output
// write_mt_uint16(ice, MT_ROUTING_CONTROL_PSDOUT, 0xAAAA);
@@ -338,12 +342,12 @@ ice1712_setup(ice1712 *ice)
// write_mt_uint32(ice, MT_CAPTURED_DATA, 0x76543280);
//Mute all input
/* for (i = 0; i < 20; i++)
{
mute = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8);
for (i = 0; i < 2 * MAX_HARDWARE_VOLUME; i++) {
write_mt_uint8(ice, MT_VOLUME_CONTROL_CHANNEL_INDEX, i);
write_mt_uint16(ice, MT_VOLUME_CONTROL_CHANNEL_INDEX, 0x7F7F);
write_mt_uint16(ice, MT_VOLUME_CONTROL_CHANNEL_INDEX, mute);
}
*/
//Unmask Interrupt
write_ccs_uint8(ice, CCS_CONTROL_STATUS, 0x41);
@@ -529,7 +533,7 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
case B_MULTI_GET_DESCRIPTION :
TRACE("B_MULTI_GET_DESCRIPTION\n");
return ice1712_get_description((ice1712 *)cookie,
(multi_description*)arg);
(multi_description*)arg);
case B_MULTI_GET_EVENT_INFO :
TRACE("B_MULTI_GET_EVENT_INFO\n");
return B_ERROR;
@@ -542,19 +546,19 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
case B_MULTI_GET_ENABLED_CHANNELS :
TRACE("B_MULTI_GET_ENABLED_CHANNELS\n");
return ice1712_get_enabled_channels((ice1712*)cookie,
(multi_channel_enable*)arg);
(multi_channel_enable*)arg);
case B_MULTI_SET_ENABLED_CHANNELS :
TRACE("B_MULTI_SET_ENABLED_CHANNELS\n");
return ice1712_set_enabled_channels((ice1712*)cookie,
(multi_channel_enable*)arg);
(multi_channel_enable*)arg);
case B_MULTI_GET_GLOBAL_FORMAT :
TRACE("B_MULTI_GET_GLOBAL_FORMAT\n");
return ice1712_get_global_format((ice1712*)cookie,
(multi_format_info *)arg);
(multi_format_info *)arg);
case B_MULTI_SET_GLOBAL_FORMAT :
TRACE("B_MULTI_SET_GLOBAL_FORMAT\n");
return ice1712_set_global_format((ice1712*)cookie,
(multi_format_info *)arg);
(multi_format_info *)arg);
case B_MULTI_GET_CHANNEL_FORMATS :
TRACE("B_MULTI_GET_CHANNEL_FORMATS\n");
return B_ERROR;
@@ -564,27 +568,27 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
case B_MULTI_GET_MIX :
TRACE("B_MULTI_GET_MIX\n");
return ice1712_get_mix((ice1712*)cookie,
(multi_mix_value_info *)arg);
(multi_mix_value_info *)arg);
case B_MULTI_SET_MIX :
TRACE("B_MULTI_SET_MIX\n");
return ice1712_set_mix((ice1712*)cookie,
(multi_mix_value_info *)arg);
(multi_mix_value_info *)arg);
case B_MULTI_LIST_MIX_CHANNELS :
TRACE("B_MULTI_LIST_MIX_CHANNELS\n");
return ice1712_list_mix_channels((ice1712*)cookie,
(multi_mix_channel_info *)arg);
(multi_mix_channel_info *)arg);
case B_MULTI_LIST_MIX_CONTROLS :
TRACE("B_MULTI_LIST_MIX_CONTROLS\n");
return ice1712_list_mix_controls((ice1712*)cookie,
(multi_mix_control_info *)arg);
(multi_mix_control_info *)arg);
case B_MULTI_LIST_MIX_CONNECTIONS :
TRACE("B_MULTI_LIST_MIX_CONNECTIONS\n");
return ice1712_list_mix_connections((ice1712*)cookie,
(multi_mix_connection_info *)arg);
(multi_mix_connection_info *)arg);
case B_MULTI_GET_BUFFERS :
TRACE("B_MULTI_GET_BUFFERS\n");
return ice1712_get_buffers((ice1712*)cookie,
(multi_buffer_list*)arg);
(multi_buffer_list*)arg);
case B_MULTI_SET_BUFFERS :
TRACE("B_MULTI_SET_BUFFERS\n");
return B_ERROR;
@@ -594,7 +598,7 @@ ice_1712_control(void *cookie, uint32 op, void *arg, size_t len)
case B_MULTI_BUFFER_EXCHANGE :
// TRACE("B_MULTI_BUFFER_EXCHANGE\n");
return ice1712_buffer_exchange((ice1712*)cookie,
(multi_buffer_info *)arg);
(multi_buffer_info *)arg);
case B_MULTI_BUFFER_FORCE_STOP :
TRACE("B_MULTI_BUFFER_FORCE_STOP\n");
return ice1712_buffer_force_stop((ice1712*)cookie);
@@ -635,7 +639,7 @@ ice_1712_read(void *cookie, off_t position, void *buf, size_t *num_bytes)
static status_t
ice_1712_write(void *cookie, off_t position, const void *buffer,
size_t *num_bytes)
size_t *num_bytes)
{
TRACE("===write()===\n");
*num_bytes = 0;
@@ -680,7 +684,7 @@ find_device(const char * name)
TRACE("ice1712: find_device(%s)\n", name);
for (ix=0; ix<num_cards; ix++) {
for (ix=0; ix < num_cards; ix++) {
/* if (!strcmp(cards[ix].midi.name, name)) {
return &midi_hooks;
@@ -696,13 +700,12 @@ find_device(const char * name)
//-----------------------------------------------------------------------------
#define ICE1712_MUTE_VALUE (0x7F)
status_t
applySettings(ice1712 *card)
{
int i;
uint16 val;
uint16 val, mt30 = 0;
uint32 mt34 = 0;
for (i = 0; i < MAX_HARDWARE_VOLUME; i++) {
//Select the channel
@@ -728,7 +731,7 @@ applySettings(ice1712 *card)
for (i = 0; i < MAX_HARDWARE_VOLUME; i++) {
//Select the channel
write_mt_uint8(card, MT_VOLUME_CONTROL_CHANNEL_INDEX,
i + MAX_HARDWARE_VOLUME);
i + MAX_HARDWARE_VOLUME);
if (card->settings.Record[i].Mute == true) {
val = (ICE1712_MUTE_VALUE << 0) | (ICE1712_MUTE_VALUE << 8);
@@ -747,7 +750,58 @@ applySettings(ice1712 *card)
TRACE_VV("Apply Settings %d : 0x%x\n", i, val);
}
//Output selection
//Analog output selection
for (i = 0; i < 4; i++) {
uint8 out = card->settings.Output[i];
if (out == 0) {
TRACE_VV("Output %d is haiku output\n", i);
//Nothing to do
} else if (out <= (card->nb_ADC / 2)) {
uint8 mt34_c;
out--;
TRACE_VV("Output %d is input %d\n", i, out);
mt34_c = (out * 2);
mt34_c |= (out * 2 + 1) << 4;
mt30 |= 0x0202 << (2*i);
mt30 |= mt34_c << (8*i);
} else if (out == ((card->nb_ADC / 2) + 1)
&& (card->spdif_config & YES_IN_NO_OUT) != 0) {
TRACE_VV("Output %d is digital input\n", i);
mt30 |= 0x0303 << (2*i);
mt34 |= 0x80 << (8*i);
} else {
TRACE_VV("Output %d is digital Mixer\n", i);
mt30 |= 0x0101;
}
}
write_mt_uint16(card, MT_ROUTING_CONTROL_PSDOUT, mt30);
write_mt_uint32(card, MT_CAPTURED_DATA, mt34);
//Digital output
if ((card->spdif_config & NO_IN_YES_OUT) != 0) {
uint16 mt32 = 0;
uint8 out = card->settings.Output[4];
if (out == 0) {
TRACE_VV("Digital output is haiku output\n");
//Nothing to do
} else if (out <= (card->nb_ADC / 2)) {
out--;
TRACE_VV("Digital output is input %d\n", out);
mt32 |= 0x0202;
mt32 |= (out * 2) << 8;
mt32 |= (out * 2 + 1) << 12;
} else if (out == ((card->nb_ADC / 2) + 1)
&& (card->spdif_config & YES_IN_NO_OUT) != 0) {
TRACE_VV("Digital output is digital input\n");
mt32 |= 0x800F;
} else {
TRACE_VV("Digital output is digital Mixer\n");
mt32 |= 0x0005;
}
write_mt_uint16(card, MT_ROUTING_CONTROL_SPDOUT, mt32);
}
return B_OK;
}
@@ -8,10 +8,10 @@
* All rights reserved
* Distributed under the terms of the MIT license.
*/
#ifndef _ICE1712_H_
#define _ICE1712_H_
#include <PCI.h>
#include "hmulti_audio.h"
@@ -41,6 +41,7 @@ typedef enum product_t {
#define MAX_BUFFER_FRAMES 2048
#define MAX_HARDWARE_VOLUME 10
#define ICE1712_MUTE_VALUE 0x7F
#define PLAYBACK_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_DAC * SAMPLE_SIZE)
#define RECORD_BUFFER_SIZE (MAX_BUFFER_FRAMES * MAX_ADC * SAMPLE_SIZE)
@@ -192,8 +192,8 @@ 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)
write_ds_channel_data(ice1712 *ice, uint8 channel, ds8_register index,
uint32 data)
{
uint8 ds8_channel_index = channel << 4 | index;
@@ -470,7 +470,7 @@ ak45xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, ((AK45xx_CHIP_ADDRESS & 0x03) << 6) | 0x20
| (reg_addr & 0x1F), tmp);
| (reg_addr & 0x1F), tmp);
write_gpio_byte(ice, data, tmp);
tmp |= chip_select;
@@ -512,7 +512,7 @@ cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select)
snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1,
tmp); //For writing the MAP
tmp); //For writing the MAP
write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment
tmp |= chip_select; //Deselect the chip
@@ -524,7 +524,7 @@ cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select)
snooze(GPIO_I2C_DELAY);
write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1 | 1,
tmp); //For writing the MAP
tmp); //For writing the MAP
data = read_gpio_byte(ice, tmp); //For reading
tmp |= chip_select; //Deselect the chip
@@ -63,7 +63,7 @@ typedef enum {
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);
ds8_register index, uint32 data);
//------------------------------------------------------
//------------------------------------------------------
//Address are [PCI_1C] + xx
+115 -99
View File
@@ -9,6 +9,7 @@
* Distributed under the terms of the MIT license.
*/
#include "ice1712_reg.h"
#include "io.h"
#include "multi.h"
@@ -24,6 +25,7 @@
#define MAX_CONTROL 32
static void
start_DMA(ice1712 *card)
{
@@ -32,9 +34,9 @@ start_DMA(ice1712 *card)
write_mt_uint8(card, MT_PROF_PB_CONTROL, 0);
write_mt_uint32(card, MT_PROF_PB_DMA_BASE_ADDRESS,
(uint32)card->phys_addr_pb);
(uint32)card->phys_addr_pb);
write_mt_uint16(card, MT_PROF_PB_DMA_COUNT_ADDRESS,
(size * SWAPPING_BUFFERS) - 1);
(size * SWAPPING_BUFFERS) - 1);
//We want interrupt only from playback
write_mt_uint16(card, MT_PROF_PB_DMA_TERM_COUNT, size - 1);
TRACE("SIZE DMA PLAYBACK %#x\n", size);
@@ -42,9 +44,9 @@ start_DMA(ice1712 *card)
size = card->buffer_size * MAX_ADC;
write_mt_uint32(card, MT_PROF_REC_DMA_BASE_ADDRESS,
(uint32)card->phys_addr_rec);
(uint32)card->phys_addr_rec);
write_mt_uint16(card, MT_PROF_REC_DMA_COUNT_ADDRESS,
(size * SWAPPING_BUFFERS) - 1);
(size * SWAPPING_BUFFERS) - 1);
//We do not want any interrupt from the record
write_mt_uint16(card, MT_PROF_REC_DMA_TERM_COUNT, 0);
TRACE("SIZE DMA RECORD %#x\n", size);
@@ -103,6 +105,7 @@ start_DMA(ice1712 *card)
write_mt_uint8(card, MT_PROF_PB_CONTROL, 5);
}
status_t
ice1712_get_description(ice1712 *card, multi_description *data)
{
@@ -150,11 +153,9 @@ ice1712_get_description(ice1712 *card, multi_description *data)
data->input_bus_channel_count = 0;
data->aux_bus_channel_count = 0;
size = data->output_channel_count +
data->input_channel_count +
data->output_bus_channel_count +
data->input_bus_channel_count +
data->aux_bus_channel_count;
size = data->output_channel_count + data->input_channel_count
+ data->output_bus_channel_count + data->input_bus_channel_count
+ data->aux_bus_channel_count;
TRACE_VV("request_channel_count = %ld\n", data->request_channel_count);
@@ -190,7 +191,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) == 0) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT;
| ((i & 1) == 0) ? B_CHANNEL_LEFT : B_CHANNEL_RIGHT;
data->channels[chan].connectors = 0;
chan++;
}
@@ -200,13 +201,13 @@ 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
| B_CHANNEL_LEFT;
| B_CHANNEL_LEFT;
data->channels[chan].connectors = 0;
chan++;
data->channels[chan].channel_id = chan;
data->channels[chan].kind = B_MULTI_INPUT_CHANNEL;
data->channels[chan].designations = B_CHANNEL_STEREO_BUS
| B_CHANNEL_RIGHT;
| B_CHANNEL_RIGHT;
data->channels[chan].connectors = 0;
chan++;
}
@@ -215,13 +216,13 @@ 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
| B_CHANNEL_LEFT;
| B_CHANNEL_LEFT;
data->channels[chan].connectors = 0;
chan++;
data->channels[chan].channel_id = chan;
data->channels[chan].kind = B_MULTI_INPUT_CHANNEL;
data->channels[chan].designations = B_CHANNEL_STEREO_BUS
| B_CHANNEL_RIGHT;
| B_CHANNEL_RIGHT;
data->channels[chan].connectors = 0;
chan++;
}
@@ -232,13 +233,14 @@ ice1712_get_description(ice1712 *card, multi_description *data)
TRACE("input_bus_channel_count = %ld\n", data->input_bus_channel_count);
data->output_rates = data->input_rates = AUTHORIZED_RATE;
data->min_cvsr_rate = data->max_cvsr_rate = 0;
data->min_cvsr_rate = 44100;
data->max_cvsr_rate = 96000;
data->output_formats = data->input_formats = AUTHORIZED_SAMPLE_SIZE;
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;
| B_MULTI_INTERFACE_RECORD;
data->start_latency = 0;
strcpy(data->control_panel,"");
@@ -360,6 +362,7 @@ ice1712_set_global_format(ice1712 *card, multi_format_info *data)
return B_OK;
}
static uint32
get_combo_cb(ice1712 *card, uint32 index)
{
@@ -392,6 +395,7 @@ get_combo_cb(ice1712 *card, uint32 index)
return value;
}
static void
set_combo_cb(ice1712 *card, uint32 index, uint32 value)
{
@@ -429,6 +433,7 @@ set_combo_cb(ice1712 *card, uint32 index, uint32 value)
}
}
static uint32
get_output_cb(ice1712 *card, uint32 index)
{
@@ -442,6 +447,7 @@ get_output_cb(ice1712 *card, uint32 index)
return value;
}
static void
set_output_cb(ice1712 *card, uint32 index, uint32 value)
{
@@ -451,6 +457,7 @@ set_output_cb(ice1712 *card, uint32 index, uint32 value)
TRACE_VV(" set_output_cb: %ld, %ld\n", index, value);
}
static void
get_volume_cb(ice1712 *card, multi_mix_value *mmv)
{
@@ -471,8 +478,8 @@ get_volume_cb(ice1712 *card, multi_mix_value *mmv)
switch (ICE1712_MULTI_GET_INDEX(mmv->id)) {
case 0: //Mute
mmv->u.enable = vol[chan].Mute | vol[chan + 1].Mute;
TRACE_VV(" Get mute %d for channel %d or %d\n",
mmv->u.enable, (int)chan, (int)chan + 1);
TRACE_VV("\tGet mute %d for channel %d or %d\n",
mmv->u.enable, (int)chan, (int)chan + 1);
break;
case 2: //Right channel
@@ -480,12 +487,13 @@ get_volume_cb(ice1712 *card, multi_mix_value *mmv)
//No break
case 1: //Left channel
mmv->u.gain = vol[chan].Volume;
TRACE_VV(" Get Volume %f for channel %d\n",
mmv->u.gain, (int)chan);
TRACE_VV("\tGet Volume %f for channel %d\n",
mmv->u.gain, (int)chan);
break;
}
}
static void
set_volume_cb(ice1712 *card, multi_mix_value *mmv)
{
@@ -507,8 +515,8 @@ set_volume_cb(ice1712 *card, multi_mix_value *mmv)
case 0: //Mute
vol[chan].Mute = mmv->u.enable;
vol[chan + 1].Mute = mmv->u.enable;
TRACE_VV(" Change mute to %d for channel %d and %d\n",
mmv->u.enable, (int)chan, (int)chan + 1);
TRACE_VV("\tChange mute to %d for channel %d and %d\n",
mmv->u.enable, (int)chan, (int)chan + 1);
break;
case 2: //Right channel
@@ -516,12 +524,13 @@ set_volume_cb(ice1712 *card, multi_mix_value *mmv)
//No break
case 1: //Left channel
vol[chan].Volume = mmv->u.gain;
TRACE_VV(" Change Volume to %f for channel %d\n",
mmv->u.gain, (int)chan);
TRACE_VV("\tChange Volume to %f for channel %d\n",
mmv->u.gain, (int)chan);
break;
}
}
status_t
ice1712_get_mix(ice1712 *card, multi_mix_value_info *data)
{
@@ -534,7 +543,7 @@ ice1712_get_mix(ice1712 *card, multi_mix_value_info *data)
switch (mmv->id & ICE1712_MULTI_CONTROL_TYPE_MASK) {
case ICE1712_MULTI_CONTROL_TYPE_COMBO:
mmv->u.mux = get_combo_cb(card,
ICE1712_MULTI_GET_CHANNEL(mmv->id));
ICE1712_MULTI_GET_CHANNEL(mmv->id));
break;
case ICE1712_MULTI_CONTROL_TYPE_VOLUME:
@@ -543,7 +552,7 @@ ice1712_get_mix(ice1712 *card, multi_mix_value_info *data)
case ICE1712_MULTI_CONTROL_TYPE_OUTPUT:
mmv->u.mux = get_output_cb(card,
ICE1712_MULTI_GET_CHANNEL(mmv->id));
ICE1712_MULTI_GET_CHANNEL(mmv->id));
break;
default:
@@ -555,6 +564,7 @@ ice1712_get_mix(ice1712 *card, multi_mix_value_info *data)
return B_OK;
}
status_t
ice1712_set_mix(ice1712 *card, multi_mix_value_info *data)
{
@@ -568,7 +578,7 @@ ice1712_set_mix(ice1712 *card, multi_mix_value_info *data)
switch (mmv->id & ICE1712_MULTI_CONTROL_TYPE_MASK) {
case ICE1712_MULTI_CONTROL_TYPE_COMBO:
set_combo_cb(card, ICE1712_MULTI_GET_CHANNEL(mmv->id),
mmv->u.mux);
mmv->u.mux);
break;
case ICE1712_MULTI_CONTROL_TYPE_VOLUME:
@@ -577,7 +587,7 @@ ice1712_set_mix(ice1712 *card, multi_mix_value_info *data)
case ICE1712_MULTI_CONTROL_TYPE_OUTPUT:
set_output_cb(card, ICE1712_MULTI_GET_CHANNEL(mmv->id),
mmv->u.mux);
mmv->u.mux);
break;
default:
@@ -592,7 +602,8 @@ ice1712_set_mix(ice1712 *card, multi_mix_value_info *data)
status_t
ice1712_list_mix_channels(ice1712 *card, multi_mix_channel_info *data)
{//Not Implemented
{
//Not Implemented
return B_OK;
}
@@ -682,6 +693,7 @@ static const char *string_list[] = {
static int32 nb_control_created;
//This will create a Tab
static int32
create_group_control(multi_mix_control **p_mmc, int32 index, int32 parent,
@@ -711,14 +723,15 @@ create_group_control(multi_mix_control **p_mmc, int32 index, int32 parent,
return group;
}
//This will create a Slider with a "Mute" CheckBox
static void
create_channel_control(multi_mix_control **p_mmc, int32 channel, int32 parent,
const char* name)
{
int32 id = ICE1712_MULTI_CONTROL_FIRSTID
+ ICE1712_MULTI_CONTROL_TYPE_VOLUME
+ ICE1712_MULTI_SET_CHANNEL(channel);
+ ICE1712_MULTI_CONTROL_TYPE_VOLUME
+ ICE1712_MULTI_SET_CHANNEL(channel);
multi_mix_control *mmc = *p_mmc;
multi_mix_control control;
@@ -762,13 +775,14 @@ create_channel_control(multi_mix_control **p_mmc, int32 channel, int32 parent,
(*p_mmc) = mmc;
}
static void
create_combo_control(multi_mix_control **p_mmc, const char *values[],
int32 parent, int32 nb_combo, const char *name)
{
int32 id = ICE1712_MULTI_CONTROL_FIRSTID
+ ICE1712_MULTI_CONTROL_TYPE_COMBO
+ ICE1712_MULTI_SET_CHANNEL(nb_combo);
+ ICE1712_MULTI_CONTROL_TYPE_COMBO
+ ICE1712_MULTI_SET_CHANNEL(nb_combo);
multi_mix_control *mmc = *p_mmc;
int32 parentControl, i;
@@ -799,15 +813,16 @@ create_combo_control(multi_mix_control **p_mmc, const char *values[],
(*p_mmc) = mmc;
}
//This will create all possible value for the output
//output 0 -> 3 (physical stereo output) 4 is the Digital
static void
create_output_choice(ice1712 *card, multi_mix_control **p_mmc,
int32 output, int32 parent)
int32 output, int32 parent)
{
int32 id = ICE1712_MULTI_CONTROL_FIRSTID
+ ICE1712_MULTI_CONTROL_TYPE_OUTPUT
+ ICE1712_MULTI_SET_CHANNEL(output);
+ ICE1712_MULTI_CONTROL_TYPE_OUTPUT
+ ICE1712_MULTI_SET_CHANNEL(output);
multi_mix_control *mmc = *p_mmc;
int32 parentControl, i;
@@ -871,6 +886,7 @@ create_output_choice(ice1712 *card, multi_mix_control **p_mmc,
(*p_mmc) = mmc;
}
status_t
ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *mmci)
{
@@ -887,27 +903,27 @@ ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *mmci)
//Setup tab
parentTab = create_group_control(&mmc, group++,
CONTROL_IS_MASTER, S_SETUP, NULL);
CONTROL_IS_MASTER, S_SETUP, NULL);
//General Settings
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[1]);
S_null, string_list[1]);
for (i = 0; SettingsGeneral[i] != NULL; i++) {
create_combo_control(&mmc, SettingsGeneral[i], parentTabColumn,
combo++, string_list[5 + i]);
combo++, string_list[5 + i]);
}
//Digital Settings
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[2]);
S_null, string_list[2]);
for (i = 0; SettingsDigital[i] != NULL; i++) {
create_combo_control(&mmc, SettingsDigital[i], parentTabColumn,
combo++, string_list[8 + i]);
combo++, string_list[8 + i]);
}
//Output Selection Settings
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[3]);
S_null, string_list[3]);
for (i = 0; i < card->nb_DAC; i += 2) {
create_output_choice(card, &mmc, i / 2, parentTabColumn);
}
@@ -919,34 +935,34 @@ ice1712_list_mix_controls(ice1712 *card, multi_mix_control_info *mmci)
//Internal Mixer Tab
//Output
parentTab = create_group_control(&mmc, group++, CONTROL_IS_MASTER,
S_null, string_list[4]);
S_null, string_list[4]);
for (i = 0; i < card->nb_DAC; i += 2) {
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[(i / 2) + 11]);
S_null, string_list[(i / 2) + 11]);
create_channel_control(&mmc, channel++, parentTabColumn, NULL);
}
if (card->spdif_config & NO_IN_YES_OUT) {
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[15]);
S_null, string_list[15]);
create_channel_control(&mmc, MAX_HARDWARE_VOLUME - 2,
parentTabColumn, NULL);
parentTabColumn, NULL);
}
//Input
channel = MAX_HARDWARE_VOLUME;
for (i = 0; i < card->nb_ADC; i += 2) {
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[(i / 2) + 17]);
S_null, string_list[(i / 2) + 17]);
create_channel_control(&mmc, channel++, parentTabColumn, NULL);
}
if (card->spdif_config & YES_IN_NO_OUT) {
parentTabColumn = create_group_control(&mmc, group++, parentTab,
S_null, string_list[21]);
S_null, string_list[21]);
create_channel_control(&mmc, 2 * MAX_HARDWARE_VOLUME - 2,
parentTabColumn, NULL);
parentTabColumn, NULL);
}
TRACE_VV("Return %ld control(s)\n", nb_control_created);
@@ -969,19 +985,19 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data)
{
int buff, chan_i = 0, chan_o = 0;
TRACE_VV("flags = %#x\n", (int)data->flags);
TRACE_VV("request_playback_buffers = %d\n",
(int)data->request_playback_buffers);
TRACE_VV("request_playback_channels = %d\n",
(int)data->request_playback_channels);
TRACE_VV("request_playback_buffer_size = %#x\n",
(int)data->request_playback_buffer_size);
TRACE_VV("request_record_buffers = %d\n",
(int)data->request_record_buffers);
TRACE_VV("request_record_channels = %d\n",
(int)data->request_record_channels);
TRACE_VV("request_record_buffer_size = %#x\n",
(int)data->request_record_buffer_size);
TRACE_VV("flags = %#lx\n", data->flags);
TRACE_VV("request_playback_buffers = %ld\n",
data->request_playback_buffers);
TRACE_VV("request_playback_channels = %ld\n",
data->request_playback_channels);
TRACE_VV("request_playback_buffer_size = %lx\n",
data->request_playback_buffer_size);
TRACE_VV("request_record_buffers = %ld\n",
data->request_record_buffers);
TRACE_VV("request_record_channels = %ld\n",
data->request_record_channels);
TRACE_VV("request_record_buffer_size = %lx\n",
data->request_record_buffer_size);
for (buff = 0; buff < SWAPPING_BUFFERS; buff++) {
uint32 stride_o = MAX_DAC * SAMPLE_SIZE;
@@ -993,26 +1009,26 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data)
for (chan_o = 0; chan_o < card->nb_DAC; chan_o++) {
//Analog STEREO output
data->playback_buffers[buff][chan_o].base = card->log_addr_pb
+ buf_o * buff + SAMPLE_SIZE * chan_o;
+ buf_o * buff + SAMPLE_SIZE * chan_o;
data->playback_buffers[buff][chan_o].stride = stride_o;
TRACE_VV("pb_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_o,
(int)data->playback_buffers[buff][chan_o].base);
TRACE_VV("pb_buffer[%ld][%ld] = %p\n", buff, chan_o,
data->playback_buffers[buff][chan_o].base);
}
if (card->spdif_config & NO_IN_YES_OUT) {
//SPDIF STEREO output
data->playback_buffers[buff][chan_o].base = card->log_addr_pb
+ buf_o * buff + SAMPLE_SIZE * SPDIF_LEFT;
+ buf_o * buff + SAMPLE_SIZE * SPDIF_LEFT;
data->playback_buffers[buff][chan_o].stride = stride_o;
TRACE_VV("pb_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_o,
(int)data->playback_buffers[buff][chan_o].base);
TRACE_VV("pb_buffer[%ld][%ld] = %p\n", buff, chan_o,
data->playback_buffers[buff][chan_o].base);
chan_o++;
data->playback_buffers[buff][chan_o].base = card->log_addr_pb
+ buf_o * buff + SAMPLE_SIZE * SPDIF_RIGHT;
+ buf_o * buff + SAMPLE_SIZE * SPDIF_RIGHT;
data->playback_buffers[buff][chan_o].stride = stride_o;
TRACE_VV("pb_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_o,
(int)data->playback_buffers[buff][chan_o].base);
TRACE_VV("pb_buffer[%ld][%ld] = %p\n", buff, chan_o,
data->playback_buffers[buff][chan_o].base);
chan_o++;
}
}
@@ -1021,42 +1037,42 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data)
for (chan_i = 0; chan_i < card->nb_ADC; chan_i++) {
//Analog STEREO input
data->record_buffers[buff][chan_i].base = card->log_addr_rec
+ buf_i * buff + SAMPLE_SIZE * chan_i;
+ buf_i * buff + SAMPLE_SIZE * chan_i;
data->record_buffers[buff][chan_i].stride = stride_i;
TRACE_VV("rec_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_i,
(int)data->record_buffers[buff][chan_i].base);
TRACE_VV("rec_buffer[%ld][%ld] = %p\n", buff, chan_i,
data->record_buffers[buff][chan_i].base);
}
if (card->spdif_config & YES_IN_NO_OUT) {
//SPDIF STEREO input
data->record_buffers[buff][chan_i].base = card->log_addr_rec
+ buf_i * buff + SAMPLE_SIZE * SPDIF_LEFT;
+ buf_i * buff + SAMPLE_SIZE * SPDIF_LEFT;
data->record_buffers[buff][chan_i].stride = stride_i;
TRACE_VV("rec_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_i,
(int)data->record_buffers[buff][chan_i].base);
TRACE_VV("rec_buffer[%ld][%ld] = %p\n", buff, chan_i,
data->record_buffers[buff][chan_i].base);
chan_i++;
data->record_buffers[buff][chan_i].base = card->log_addr_rec
+ buf_i * buff + SAMPLE_SIZE * SPDIF_RIGHT;
+ buf_i * buff + SAMPLE_SIZE * SPDIF_RIGHT;
data->record_buffers[buff][chan_i].stride = stride_i;
TRACE_VV("rec_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_i,
(int)data->record_buffers[buff][chan_i].base);
TRACE_VV("rec_buffer[%ld][%ld] = %p\n", buff, chan_i,
data->record_buffers[buff][chan_i].base);
chan_i++;
}
//The digital mixer output
data->record_buffers[buff][chan_i].base = card->log_addr_rec
+ buf_i * buff + SAMPLE_SIZE * MIXER_OUT_LEFT;
+ buf_i * buff + SAMPLE_SIZE * MIXER_OUT_LEFT;
data->record_buffers[buff][chan_i].stride = stride_i;
TRACE_VV("rec_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_i,
(int)data->record_buffers[buff][chan_i].base);
TRACE_VV("rec_buffer[%ld][%ld] = %p\n", buff, chan_i,
data->record_buffers[buff][chan_i].base);
chan_i++;
data->record_buffers[buff][chan_i].base = card->log_addr_rec
+ buf_i * buff + SAMPLE_SIZE * MIXER_OUT_RIGHT;
+ buf_i * buff + SAMPLE_SIZE * MIXER_OUT_RIGHT;
data->record_buffers[buff][chan_i].stride = stride_i;
TRACE_VV("rec_buffer[%d][%d] = %#x\n", (int)buff, (int)chan_i,
(int)data->record_buffers[buff][chan_i].base);
TRACE_VV("rec_buffer[%ld][%ld] = %p\n", buff, chan_i,
data->record_buffers[buff][chan_i].base);
chan_i++;
}
}
@@ -1065,22 +1081,20 @@ ice1712_get_buffers(ice1712 *card, multi_buffer_list *data)
data->return_playback_channels = card->total_output_channels;
data->return_playback_buffer_size = card->buffer_size;
TRACE("return_playback_buffers = %d\n",
(int)data->return_playback_buffers);
TRACE("return_playback_channels = %d\n",
(int)data->return_playback_channels);
TRACE("return_playback_buffer_size = %d\n",
(int)data->return_playback_buffer_size);
TRACE("return_playback_buffers = %ld\n", data->return_playback_buffers);
TRACE("return_playback_channels = %ld\n", data->return_playback_channels);
TRACE("return_playback_buffer_size = %ld\n",
data->return_playback_buffer_size);
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->buffer_size;
TRACE("return_record_buffers = %d\n",(int)data->return_record_buffers);
TRACE("return_record_channels = %d\n", (int)data->return_record_channels);
TRACE("return_record_buffer_size = %d\n",
(int)data->return_record_buffer_size);
TRACE("return_record_buffers = %ld\n", data->return_record_buffers);
TRACE("return_record_channels = %ld\n", data->return_record_channels);
TRACE("return_record_buffer_size = %ld\n",
data->return_record_buffer_size);
start_DMA(card);
@@ -1105,7 +1119,7 @@ ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data)
buffer_info.flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD;
if (acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT
| B_CAN_INTERRUPT, 50000) == B_TIMED_OUT) {
| B_CAN_INTERRUPT, 50000) == B_TIMED_OUT) {
TRACE("buffer_exchange timeout\n");
};
@@ -1115,13 +1129,15 @@ ice1712_buffer_exchange(ice1712 *card, multi_buffer_info *data)
buffer_info.played_real_time = card->played_time;
buffer_info.played_frames_count = card->frames_count;
buffer_info.playback_buffer_cycle = (card->buffer - 1)
% SWAPPING_BUFFERS; //Buffer played
% SWAPPING_BUFFERS; //Buffer played
buffer_info._reserved_0 = 0;
// Record buffers info
buffer_info.recorded_real_time = card->played_time;
buffer_info.recorded_frames_count = card->frames_count;
buffer_info.record_buffer_cycle = (card->buffer - 1)
% SWAPPING_BUFFERS; //Buffer filled
% SWAPPING_BUFFERS; //Buffer filled
buffer_info._reserved_1 = card->total_output_channels;
unlock(cpu_status);
@@ -31,14 +31,14 @@
#define ICE1712_MULTI_CONTROL_INDEX_MASK (0x00000FFF)
#define ICE1712_MULTI_SET_CHANNEL(_c_) ((_c_ << 20) & \
ICE1712_MULTI_CONTROL_CHANNEL_MASK)
ICE1712_MULTI_CONTROL_CHANNEL_MASK)
#define ICE1712_MULTI_GET_CHANNEL(_c_) ((_c_ & \
ICE1712_MULTI_CONTROL_CHANNEL_MASK) >> 20)
ICE1712_MULTI_CONTROL_CHANNEL_MASK) >> 20)
#define ICE1712_MULTI_SET_INDEX(_i_) (_i_ & \
ICE1712_MULTI_CONTROL_INDEX_MASK)
ICE1712_MULTI_CONTROL_INDEX_MASK)
#define ICE1712_MULTI_GET_INDEX(_i_) (_i_ & \
ICE1712_MULTI_CONTROL_INDEX_MASK)
ICE1712_MULTI_CONTROL_INDEX_MASK)
/*
#define ICE1712_MULTI_CONTROL_VOLUME_PB (0x00010000)
@@ -53,21 +53,23 @@
status_t ice1712_get_description(ice1712 *card, multi_description *data);
status_t ice1712_get_enabled_channels(ice1712 *card,
multi_channel_enable *data);
multi_channel_enable *data);
status_t ice1712_set_enabled_channels(ice1712 *card,
multi_channel_enable *data);
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 *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);
multi_mix_channel_info *data);
status_t ice1712_list_mix_controls(ice1712 *card,
multi_mix_control_info *data);
multi_mix_control_info *data);
status_t ice1712_list_mix_connections(ice1712 *card,
multi_mix_connection_info *data);
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);
status_t ice1712_buffer_force_stop(ice1712 *card);
#endif //_ICE1712_MULTI_H_