ice1712: Add settings file features and fix coding rules
This commit is contained in:
parent
5e9105aa28
commit
fc581f23c9
@ -18,6 +18,7 @@
|
|||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <midi_driver.h>
|
#include <midi_driver.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <drivers/driver_settings.h>
|
||||||
|
|
||||||
#include "ice1712.h"
|
#include "ice1712.h"
|
||||||
#include "ice1712_reg.h"
|
#include "ice1712_reg.h"
|
||||||
@ -26,21 +27,15 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
//------------------------------------------------------
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
status_t init_hardware(void);
|
status_t init_hardware(void);
|
||||||
status_t init_driver(void);
|
status_t init_driver(void);
|
||||||
void uninit_driver(void);
|
void uninit_driver(void);
|
||||||
const char **publish_devices(void);
|
const char **publish_devices(void);
|
||||||
device_hooks *find_device(const char *);
|
device_hooks *find_device(const char *);
|
||||||
|
status_t load_settings(ice1712 *card);
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
int32 ice_1712_int(void *arg);
|
int32 ice_1712_int(void *arg);
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
pci_module_info *pci;
|
pci_module_info *pci;
|
||||||
generic_mpu401_module *mpu401;
|
generic_mpu401_module *mpu401;
|
||||||
|
|
||||||
@ -48,25 +43,10 @@ int32 num_cards = 0;
|
|||||||
ice1712 cards[NUM_CARDS];
|
ice1712 cards[NUM_CARDS];
|
||||||
int32 num_names = 0;
|
int32 num_names = 0;
|
||||||
char *names[NUM_CARDS*20+1];
|
char *names[NUM_CARDS*20+1];
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
|
|
||||||
#define HMULTI_AUDIO_DEV_PATH "audio/hmulti/ice1712"
|
#define HMULTI_AUDIO_DEV_PATH "audio/hmulti/ice1712"
|
||||||
//#define HMULTI_AUDIO_DEV_PATH "audio/multi/ice1712"
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
//void republish_devices(void);
|
|
||||||
|
|
||||||
//extern image_id load_kernel_addon(const char *path);
|
|
||||||
//extern status_t unload_kernel_addon(image_id imid);
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
init_hardware(void)
|
init_hardware(void)
|
||||||
@ -348,7 +328,7 @@ ice1712_setup(ice1712 *ice)
|
|||||||
ice->sampling_rate = 0x08;
|
ice->sampling_rate = 0x08;
|
||||||
ice->buffer = 0;
|
ice->buffer = 0;
|
||||||
ice->frames_count = 0;
|
ice->frames_count = 0;
|
||||||
ice->buffer_size = MAX_BUFFER_FRAMES;
|
ice->buffer_size = ice->settings.bufferSize;
|
||||||
|
|
||||||
ice->total_output_channels = ice->config.nb_DAC;
|
ice->total_output_channels = ice->config.nb_DAC;
|
||||||
if (ice->config.spdif & SPDIF_OUT_PRESENT)
|
if (ice->config.spdif & SPDIF_OUT_PRESENT)
|
||||||
@ -440,6 +420,9 @@ init_driver(void)
|
|||||||
cards[num_cards].info.function, strerror(err));
|
cards[num_cards].info.function, strerror(err));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_settings(&cards[num_cards]);
|
||||||
|
|
||||||
if (ice1712_setup(&cards[num_cards]) != B_OK) {
|
if (ice1712_setup(&cards[num_cards]) != B_OK) {
|
||||||
//Vendor_ID and Device_ID has been modified
|
//Vendor_ID and Device_ID has been modified
|
||||||
TRACE("Setup of ice1712 %d failed\n", (int)(num_cards + 1));
|
TRACE("Setup of ice1712 %d failed\n", (int)(num_cards + 1));
|
||||||
@ -502,7 +485,6 @@ uninit_driver(void)
|
|||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
const char **
|
const char **
|
||||||
publish_devices(void)
|
publish_devices(void)
|
||||||
@ -732,10 +714,39 @@ find_device(const char * name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
status_t
|
||||||
|
load_settings(ice1712 *card)
|
||||||
|
{
|
||||||
|
// get driver settings
|
||||||
|
void *settings_handle = load_driver_settings("ice1712.settings");
|
||||||
|
|
||||||
|
//Use a large enough value for modern computer
|
||||||
|
card->settings.bufferSize = 512;
|
||||||
|
|
||||||
|
if (settings_handle != NULL) {
|
||||||
|
const char *item;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
item = get_driver_parameter(settings_handle, "buffer_size",
|
||||||
|
"512", "512");
|
||||||
|
if (item) {
|
||||||
|
uint32 value = strtoul(item, &end, 0);
|
||||||
|
if ((*end == '\0')
|
||||||
|
&& (value >= MIN_BUFFER_FRAMES)
|
||||||
|
&& (value <= MAX_BUFFER_FRAMES)) {
|
||||||
|
card->settings.bufferSize = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unload_driver_settings(settings_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
applySettings(ice1712 *card)
|
apply_settings(ice1712 *card)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint16 val, mt30 = 0;
|
uint16 val, mt30 = 0;
|
||||||
@ -810,7 +821,7 @@ applySettings(ice1712 *card)
|
|||||||
}
|
}
|
||||||
write_mt_uint16(card, MT_ROUTING_CONTROL_PSDOUT, mt30);
|
write_mt_uint16(card, MT_ROUTING_CONTROL_PSDOUT, mt30);
|
||||||
write_mt_uint32(card, MT_CAPTURED_DATA, mt34);
|
write_mt_uint32(card, MT_CAPTURED_DATA, mt34);
|
||||||
|
|
||||||
//Digital output
|
//Digital output
|
||||||
if ((card->config.spdif & SPDIF_OUT_PRESENT) != 0) {
|
if ((card->config.spdif & SPDIF_OUT_PRESENT) != 0) {
|
||||||
uint16 mt32 = 0;
|
uint16 mt32 = 0;
|
||||||
@ -836,6 +847,6 @@ applySettings(ice1712 *card)
|
|||||||
write_mt_uint16(card, MT_ROUTING_CONTROL_SPDOUT, mt32);
|
write_mt_uint16(card, MT_ROUTING_CONTROL_SPDOUT, mt32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "hmulti_audio.h"
|
#include "hmulti_audio.h"
|
||||||
|
|
||||||
#define DRIVER_NAME "ice1712"
|
#define DRIVER_NAME "ice1712"
|
||||||
#define VERSION "0.4"
|
#define VERSION "0.5"
|
||||||
|
|
||||||
#define ICE1712_VENDOR_ID 0x1412
|
#define ICE1712_VENDOR_ID 0x1412
|
||||||
#define ICE1712_DEVICE_ID 0x1712
|
#define ICE1712_DEVICE_ID 0x1712
|
||||||
@ -104,10 +104,10 @@ typedef struct ice1712_settings
|
|||||||
channel_volume playback[ICE1712_HARDWARE_VOLUME];
|
channel_volume playback[ICE1712_HARDWARE_VOLUME];
|
||||||
channel_volume record[ICE1712_HARDWARE_VOLUME];
|
channel_volume record[ICE1712_HARDWARE_VOLUME];
|
||||||
|
|
||||||
|
uint32 bufferSize;
|
||||||
|
|
||||||
//General Settings
|
//General Settings
|
||||||
uint8 clock; //an index
|
uint8 clock; //an index
|
||||||
uint8 bufferSize; //an index
|
|
||||||
uint8 debugMode; //an index for debugging
|
|
||||||
|
|
||||||
//S/PDif Settings
|
//S/PDif Settings
|
||||||
uint8 outFormat; //an index
|
uint8 outFormat; //an index
|
||||||
@ -173,7 +173,7 @@ typedef struct ice1712
|
|||||||
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;
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
#Ice1712 settings file
|
||||||
|
buffer_size 128
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#define AUTHORIZED_RATE (B_SR_SAME_AS_INPUT | B_SR_96000 \
|
#define AUTHORIZED_RATE (B_SR_SAME_AS_INPUT | B_SR_96000 \
|
||||||
| B_SR_88200 | B_SR_48000 | B_SR_44100)
|
| B_SR_88200 | B_SR_48000 | B_SR_44100)
|
||||||
#define AUTHORIZED_SAMPLE_SIZE (B_FMT_32BIT)
|
#define AUTHORIZED_SAMPLE_SIZE (B_FMT_24BIT)
|
||||||
|
|
||||||
#define MAX_CONTROL 32
|
#define MAX_CONTROL 32
|
||||||
|
|
||||||
@ -381,18 +381,14 @@ get_combo_cb(ice1712 *card, uint32 index)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
value = card->settings.bufferSize;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
value = card->settings.outFormat;
|
value = card->settings.outFormat;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 2:
|
||||||
value = card->settings.emphasis;
|
value = card->settings.emphasis;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 3:
|
||||||
value = card->settings.copyMode;
|
value = card->settings.copyMode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -413,25 +409,16 @@ set_combo_cb(ice1712 *card, uint32 index, uint32 value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (value < 6) {
|
|
||||||
card->settings.bufferSize = value;
|
|
||||||
// card->buffer_size = 64 * (1 << value);
|
|
||||||
// ice1712_buffer_force_stop(card);
|
|
||||||
// start_DMA(card);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if (value < 2)
|
if (value < 2)
|
||||||
card->settings.outFormat = value;
|
card->settings.outFormat = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 2:
|
||||||
if (value < 3)
|
if (value < 3)
|
||||||
card->settings.emphasis = value;
|
card->settings.emphasis = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 3:
|
||||||
if (value < 3)
|
if (value < 3)
|
||||||
card->settings.copyMode = value;
|
card->settings.copyMode = value;
|
||||||
break;
|
break;
|
||||||
@ -601,7 +588,7 @@ ice1712_set_mix(ice1712 *card, multi_mix_value_info *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return applySettings(card);
|
return apply_settings(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -618,16 +605,6 @@ static const char *Clock[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *BufferSize[] = {
|
|
||||||
"64",
|
|
||||||
"128",
|
|
||||||
"256",
|
|
||||||
"512",
|
|
||||||
"1024",
|
|
||||||
"2048",
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *DigitalFormat[] = {
|
static const char *DigitalFormat[] = {
|
||||||
"Consumer",
|
"Consumer",
|
||||||
"Professional",
|
"Professional",
|
||||||
@ -650,7 +627,6 @@ static const char *DigitalCopyMode[] = {
|
|||||||
|
|
||||||
static const char **SettingsGeneral[] = {
|
static const char **SettingsGeneral[] = {
|
||||||
Clock,
|
Clock,
|
||||||
BufferSize,
|
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -671,8 +647,8 @@ static const char *string_list[] = {
|
|||||||
|
|
||||||
//General settings
|
//General settings
|
||||||
"Master clock",
|
"Master clock",
|
||||||
"Buffer size",
|
"reserved_0",
|
||||||
"Debug",
|
"reserved_1",
|
||||||
|
|
||||||
//Digital settings
|
//Digital settings
|
||||||
"Output format",
|
"Output format",
|
||||||
|
Loading…
Reference in New Issue
Block a user