[alsa-devel] [PATCH] asihpi: Update from 4.04 to 4.06
This patch series updates asihpi driver from version 4.04 to 4.06
Major changes: - hpi6205 adapters no longer signal interrupts on message transfer, freeing the interrupt for use by streams. This requires matching DSP firmware. - rewrote alsa driver pcm stream timer function so it works better with small buffer sizes e.g. JACK. - update alsa control names to better conform to 'standard' style.
Minor changes: add low level volume mute control, allow adapters with duplicate hardware index jumpers to be discovered, fix playback start for non-mmap adapters.
Cosmetic changes: removal of many unused functions and data. removal of vestigial hpi subsys pointer from hpi functions. conversion of many defines to enums, various cleanups to comment text and some badly munged identifiers.
asihpi.c | 781 ++++++++--------- hpi.h | 1214 ++++++++++----------------- hpi6000.c | 299 +++--- hpi6205.c | 603 +++++-------- hpi6205.h | 7 hpi_internal.h | 1118 ++++++++++++------------- hpicmn.c | 480 ++++++---- hpicmn.h | 24 hpidebug.c | 157 --- hpidebug.h | 323 ------- hpidspcd.c | 37 hpidspcd.h | 2 hpifunc.c | 2498 ++++++++++++++++----------------------------------------- hpimsginit.c | 18 hpimsginit.h | 12 hpimsgx.c | 203 +--- hpioctl.c | 85 - hpios.h | 10 18 files changed, 2914 insertions(+), 4957 deletions(-)
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpidspcd.c | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/pci/asihpi/hpidspcd.c b/pci/asihpi/hpidspcd.c index 9b10d9a..f9958e9 100644 --- a/pci/asihpi/hpidspcd.c +++ b/pci/asihpi/hpidspcd.c @@ -71,47 +71,51 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, int err;
sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); - HPI_DEBUG_LOG(INFO, "requesting firmware for %s\n", fw_name);
err = request_firmware(&ps_firmware, fw_name, &ps_dsp_code->ps_dev->dev); + if (err != 0) { - HPI_DEBUG_LOG(ERROR, "%d, request_firmware failed for %s\n", - err, fw_name); + dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, + "%d, request_firmware failed for %s\n", err, + fw_name); goto error1; } if (ps_firmware->size < sizeof(header)) { - HPI_DEBUG_LOG(ERROR, "header size too small %s\n", fw_name); + dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, + "Header size too small %s\n", fw_name); goto error2; } memcpy(&header, ps_firmware->data, sizeof(header)); if (header.adapter != adapter) { - HPI_DEBUG_LOG(ERROR, "adapter type incorrect %4x != %4x\n", - header.adapter, adapter); + dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, + "Adapter type incorrect %4x != %4x\n", header.adapter, + adapter); goto error2; } if (header.size != ps_firmware->size) { - HPI_DEBUG_LOG(ERROR, "code size wrong %d != %ld\n", - header.size, (unsigned long)ps_firmware->size); + dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, + "Code size wrong %d != %ld\n", header.size, + (unsigned long)ps_firmware->size); goto error2; }
if (header.version / 10000 != HPI_VER_DECIMAL / 10000) { - HPI_DEBUG_LOG(ERROR, - "firmware major version mismatch " - "DSP image %d != driver %d\n", header.version, + dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, + "Firmware Major Version mismatch " + "DSP image %d != Driver %d\n", header.version, HPI_VER_DECIMAL); goto error2; }
if (header.version != HPI_VER_DECIMAL) { - HPI_DEBUG_LOG(WARNING, - "version mismatch DSP image %d != driver %d\n", + dev_printk(KERN_WARNING, &ps_dsp_code->ps_dev->dev, + "firmware: version mismatch DSP image %d != Driver %d\n", header.version, HPI_VER_DECIMAL); /* goto error2; still allow driver to load */ }
- HPI_DEBUG_LOG(INFO, "dsp code %s opened\n", fw_name); + HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); ps_dsp_code->ps_firmware = ps_firmware; ps_dsp_code->block_length = header.size / sizeof(u32); ps_dsp_code->word_count = sizeof(header) / sizeof(u32); @@ -148,7 +152,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code) short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword) { if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length) - return (HPI_ERROR_DSP_FILE_FORMAT); + return HPI_ERROR_DSP_FILE_FORMAT;
*pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code-> word_count];
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpimsginit.c | 18 ++---------------- 1 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/pci/asihpi/hpimsginit.c b/pci/asihpi/hpimsginit.c index 8e1d099..42f9182 100644 --- a/pci/asihpi/hpimsginit.c +++ b/pci/asihpi/hpimsginit.c @@ -32,21 +32,6 @@ static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT; static u16 gwSSX2_bypass;
/** \internal - * Used by ASIO driver to disable SSX2 for a single process - * \param phSubSys Pointer to HPI subsystem handle. - * \param wBypass New bypass setting 0 = off, nonzero = on - * \return Previous bypass setting. - */ -u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass) -{ - u16 old_value = gwSSX2_bypass; - - gwSSX2_bypass = bypass; - - return old_value; -} - -/** \internal * initialize the HPI message structure */ static void hpi_init_message(struct hpi_message *phm, u16 object, @@ -65,7 +50,8 @@ static void hpi_init_message(struct hpi_message *phm, u16 object, phm->object = object; phm->function = function; phm->version = 0; - /* Expect adapter index to be set by caller */ + phm->adapter_index = 0xFFFF; + /* Expect actual adapter index to be set by caller */ }
/** \internal
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Log HPI messages and responses in consistent numeric format, which can be post-processed to get strings.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpidebug.c | 157 +----------------------- pci/asihpi/hpidebug.h | 323 +++---------------------------------------------- 2 files changed, 25 insertions(+), 455 deletions(-)
diff --git a/pci/asihpi/hpidebug.c b/pci/asihpi/hpidebug.c index 949836e..4b81c80 100644 --- a/pci/asihpi/hpidebug.c +++ b/pci/asihpi/hpidebug.c @@ -45,161 +45,14 @@ int hpi_debug_level_get(void) return hpi_debug_level; }
-#ifdef HPIOS_DEBUG_PRINT -/* implies OS has no printf-like function */ -#include <stdarg.h> - -void hpi_debug_printf(char *fmt, ...) -{ - va_list arglist; - char buffer[128]; - - va_start(arglist, fmt); - - if (buffer[0]) - HPIOS_DEBUG_PRINT(buffer); - va_end(arglist); -} -#endif - -struct treenode { - void *array; - unsigned int num_elements; -}; - -#define make_treenode_from_array(nodename, array) \ -static void *tmp_strarray_##nodename[] = array; \ -static struct treenode nodename = { \ - &tmp_strarray_##nodename, \ - ARRAY_SIZE(tmp_strarray_##nodename) \ -}; - -#define get_treenode_elem(node_ptr, idx, type) \ - (&(*((type *)(node_ptr)->array)[idx])) - -make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS) - - make_treenode_from_array(hpi_subsys_strings, HPI_SUBSYS_STRINGS) - make_treenode_from_array(hpi_adapter_strings, HPI_ADAPTER_STRINGS) - make_treenode_from_array(hpi_istream_strings, HPI_ISTREAM_STRINGS) - make_treenode_from_array(hpi_ostream_strings, HPI_OSTREAM_STRINGS) - make_treenode_from_array(hpi_mixer_strings, HPI_MIXER_STRINGS) - make_treenode_from_array(hpi_node_strings, - { - "NODE is invalid object"}) - - make_treenode_from_array(hpi_control_strings, HPI_CONTROL_STRINGS) - make_treenode_from_array(hpi_nvmemory_strings, HPI_OBJ_STRINGS) - make_treenode_from_array(hpi_digitalio_strings, HPI_DIGITALIO_STRINGS) - make_treenode_from_array(hpi_watchdog_strings, HPI_WATCHDOG_STRINGS) - make_treenode_from_array(hpi_clock_strings, HPI_CLOCK_STRINGS) - make_treenode_from_array(hpi_profile_strings, HPI_PROFILE_STRINGS) - make_treenode_from_array(hpi_asyncevent_strings, HPI_ASYNCEVENT_STRINGS) -#define HPI_FUNCTION_STRINGS \ -{ \ - &hpi_subsys_strings,\ - &hpi_adapter_strings,\ - &hpi_ostream_strings,\ - &hpi_istream_strings,\ - &hpi_mixer_strings,\ - &hpi_node_strings,\ - &hpi_control_strings,\ - &hpi_nvmemory_strings,\ - &hpi_digitalio_strings,\ - &hpi_watchdog_strings,\ - &hpi_clock_strings,\ - &hpi_profile_strings,\ - &hpi_control_strings, \ - &hpi_asyncevent_strings \ -} - make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS) - - compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match); - -static char *hpi_function_string(unsigned int function) -{ - unsigned int object; - struct treenode *tmp; - - object = function / HPI_OBJ_FUNCTION_SPACING; - function = function - object * HPI_OBJ_FUNCTION_SPACING; - - if (object == 0 || object == HPI_OBJ_NODE - || object > hpi_function_strings.num_elements) - return "invalid object"; - - tmp = get_treenode_elem(&hpi_function_strings, object - 1, - struct treenode *); - - if (function == 0 || function > tmp->num_elements) - return "invalid function"; - - return get_treenode_elem(tmp, function - 1, char *); -} - void hpi_debug_message(struct hpi_message *phm, char *sz_fileline) { if (phm) { - if ((phm->object <= HPI_OBJ_MAXINDEX) && phm->object) { - u16 index = 0; - u16 attrib = 0; - int is_control = 0; - - index = phm->obj_index; - switch (phm->object) { - case HPI_OBJ_ADAPTER: - case HPI_OBJ_PROFILE: - break; - case HPI_OBJ_MIXER: - if (phm->function == - HPI_MIXER_GET_CONTROL_BY_INDEX) - index = phm->u.m.control_index; - break; - case HPI_OBJ_OSTREAM: - case HPI_OBJ_ISTREAM: - break; - - case HPI_OBJ_CONTROLEX: - case HPI_OBJ_CONTROL: - if (phm->version == 1) - attrib = HPI_CTL_ATTR(UNIVERSAL, 1); - else - attrib = phm->u.c.attribute; - is_control = 1; - break; - default: - break; - } - - if (is_control && (attrib & 0xFF00)) { - int control_type = (attrib & 0xFF00) >> 8; - int attr_index = HPI_CTL_ATTR_INDEX(attrib); - /* note the KERN facility level - is in szFileline already */ - printk("%s adapter %d %s " - "ctrl_index x%04x %s %d\n", - sz_fileline, phm->adapter_index, - hpi_function_string(phm->function), - index, - get_treenode_elem - (&hpi_control_type_strings, - control_type, char *), - attr_index); - - } else - printk("%s adapter %d %s " - "idx x%04x attr x%04x \n", - sz_fileline, phm->adapter_index, - hpi_function_string(phm->function), - index, attrib); - } else { - printk("adap=%d, invalid obj=%d, func=0x%x\n", - phm->adapter_index, phm->object, - phm->function); - } - } else - printk(KERN_ERR - "NULL message pointer to hpi_debug_message!\n"); + printk("HPI_MSG%d,%d,%d,%d,%d\n", phm->version, + phm->adapter_index, phm->obj_index, phm->function, + phm->u.c.attribute); + } + }
void hpi_debug_data(u16 *pdata, u32 len) diff --git a/pci/asihpi/hpidebug.h b/pci/asihpi/hpidebug.h index a2f0952..632d7d0 100644 --- a/pci/asihpi/hpidebug.h +++ b/pci/asihpi/hpidebug.h @@ -37,7 +37,7 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ #define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE
/* an OS can define an extra flag string that is appended to - the start of each message, eg see hpios_linux.h */ + the start of each message, eg see linux kernel hpios.h */
#ifdef SOURCEFILE_NAME #define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " " @@ -45,18 +45,11 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ #define FILE_LINE __FILE__ ":" __stringify(__LINE__) " " #endif
-#if defined(HPI_DEBUG) && defined(_WINDOWS) -#define HPI_DEBUGBREAK() debug_break() -#else -#define HPI_DEBUGBREAK() -#endif - #define HPI_DEBUG_ASSERT(expression) \ do { \ - if (!(expression)) {\ - printk(KERN_ERR FILE_LINE\ - "ASSERT " __stringify(expression));\ - HPI_DEBUGBREAK();\ + if (!(expression)) { \ + printk(KERN_ERR FILE_LINE \ + "ASSERT " __stringify(expression)); \ } \ } while (0)
@@ -78,28 +71,27 @@ void hpi_debug_message(struct hpi_message *phm, char *sz_fileline);
void hpi_debug_data(u16 *pdata, u32 len);
-#define HPI_DEBUG_DATA(pdata, len) \ - do { \ +#define HPI_DEBUG_DATA(pdata, len) \ + do { \ if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ hpi_debug_data(pdata, len); \ } while (0)
-#define HPI_DEBUG_MESSAGE(level, phm) \ - do { \ - if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ - hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \ - FILE_LINE __stringify(level));\ - } \ +#define HPI_DEBUG_MESSAGE(level, phm) \ + do { \ + if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ + hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \ + FILE_LINE __stringify(level)); \ + } \ } while (0)
-#define HPI_DEBUG_RESPONSE(phr) \ - do { \ - if ((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error))\ - HPI_DEBUG_LOG(ERROR, \ - "HPI response - error# %d\n", \ - phr->error); \ - else if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \ - HPI_DEBUG_LOG(VERBOSE, "HPI response OK\n");\ +#define HPI_DEBUG_RESPONSE(phr) \ + do { \ + if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error)) ||\ + (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)) \ + printk(KERN_DEBUG\ + "HPI_RES%d,%d,%d\n", \ + phr->version, phr->error, phr->specific_error); \ } while (0)
#ifndef compile_time_assert @@ -107,279 +99,4 @@ void hpi_debug_data(u16 *pdata, u32 len); typedef char msg[(cond) ? 1 : -1] #endif
- /* check that size is exactly some number */ -#define function_count_check(sym, size) \ - compile_time_assert((sym##_FUNCTION_COUNT) == (size),\ - strings_match_defs_##sym) - -/* These strings should be generated using a macro which defines - the corresponding symbol values. */ -#define HPI_OBJ_STRINGS \ -{ \ - "HPI_OBJ_SUBSYSTEM", \ - "HPI_OBJ_ADAPTER", \ - "HPI_OBJ_OSTREAM", \ - "HPI_OBJ_ISTREAM", \ - "HPI_OBJ_MIXER", \ - "HPI_OBJ_NODE", \ - "HPI_OBJ_CONTROL", \ - "HPI_OBJ_NVMEMORY", \ - "HPI_OBJ_DIGITALIO", \ - "HPI_OBJ_WATCHDOG", \ - "HPI_OBJ_CLOCK", \ - "HPI_OBJ_PROFILE", \ - "HPI_OBJ_CONTROLEX" \ -} - -#define HPI_SUBSYS_STRINGS \ -{ \ - "HPI_SUBSYS_OPEN", \ - "HPI_SUBSYS_GET_VERSION", \ - "HPI_SUBSYS_GET_INFO", \ - "HPI_SUBSYS_FIND_ADAPTERS", \ - "HPI_SUBSYS_CREATE_ADAPTER",\ - "HPI_SUBSYS_CLOSE", \ - "HPI_SUBSYS_DELETE_ADAPTER", \ - "HPI_SUBSYS_DRIVER_LOAD", \ - "HPI_SUBSYS_DRIVER_UNLOAD", \ - "HPI_SUBSYS_READ_PORT_8", \ - "HPI_SUBSYS_WRITE_PORT_8", \ - "HPI_SUBSYS_GET_NUM_ADAPTERS",\ - "HPI_SUBSYS_GET_ADAPTER", \ - "HPI_SUBSYS_SET_NETWORK_INTERFACE"\ -} -function_count_check(HPI_SUBSYS, 14); - -#define HPI_ADAPTER_STRINGS \ -{ \ - "HPI_ADAPTER_OPEN", \ - "HPI_ADAPTER_CLOSE", \ - "HPI_ADAPTER_GET_INFO", \ - "HPI_ADAPTER_GET_ASSERT", \ - "HPI_ADAPTER_TEST_ASSERT", \ - "HPI_ADAPTER_SET_MODE", \ - "HPI_ADAPTER_GET_MODE", \ - "HPI_ADAPTER_ENABLE_CAPABILITY",\ - "HPI_ADAPTER_SELFTEST", \ - "HPI_ADAPTER_FIND_OBJECT", \ - "HPI_ADAPTER_QUERY_FLASH", \ - "HPI_ADAPTER_START_FLASH", \ - "HPI_ADAPTER_PROGRAM_FLASH", \ - "HPI_ADAPTER_SET_PROPERTY", \ - "HPI_ADAPTER_GET_PROPERTY", \ - "HPI_ADAPTER_ENUM_PROPERTY", \ - "HPI_ADAPTER_MODULE_INFO", \ - "HPI_ADAPTER_DEBUG_READ" \ -} - -function_count_check(HPI_ADAPTER, 18); - -#define HPI_OSTREAM_STRINGS \ -{ \ - "HPI_OSTREAM_OPEN", \ - "HPI_OSTREAM_CLOSE", \ - "HPI_OSTREAM_WRITE", \ - "HPI_OSTREAM_START", \ - "HPI_OSTREAM_STOP", \ - "HPI_OSTREAM_RESET", \ - "HPI_OSTREAM_GET_INFO", \ - "HPI_OSTREAM_QUERY_FORMAT", \ - "HPI_OSTREAM_DATA", \ - "HPI_OSTREAM_SET_VELOCITY", \ - "HPI_OSTREAM_SET_PUNCHINOUT", \ - "HPI_OSTREAM_SINEGEN", \ - "HPI_OSTREAM_ANC_RESET", \ - "HPI_OSTREAM_ANC_GET_INFO", \ - "HPI_OSTREAM_ANC_READ", \ - "HPI_OSTREAM_SET_TIMESCALE",\ - "HPI_OSTREAM_SET_FORMAT", \ - "HPI_OSTREAM_HOSTBUFFER_ALLOC", \ - "HPI_OSTREAM_HOSTBUFFER_FREE", \ - "HPI_OSTREAM_GROUP_ADD",\ - "HPI_OSTREAM_GROUP_GETMAP", \ - "HPI_OSTREAM_GROUP_RESET", \ - "HPI_OSTREAM_HOSTBUFFER_GET_INFO", \ - "HPI_OSTREAM_WAIT_START", \ -} -function_count_check(HPI_OSTREAM, 24); - -#define HPI_ISTREAM_STRINGS \ -{ \ - "HPI_ISTREAM_OPEN", \ - "HPI_ISTREAM_CLOSE", \ - "HPI_ISTREAM_SET_FORMAT", \ - "HPI_ISTREAM_READ", \ - "HPI_ISTREAM_START", \ - "HPI_ISTREAM_STOP", \ - "HPI_ISTREAM_RESET", \ - "HPI_ISTREAM_GET_INFO", \ - "HPI_ISTREAM_QUERY_FORMAT", \ - "HPI_ISTREAM_ANC_RESET", \ - "HPI_ISTREAM_ANC_GET_INFO", \ - "HPI_ISTREAM_ANC_WRITE", \ - "HPI_ISTREAM_HOSTBUFFER_ALLOC",\ - "HPI_ISTREAM_HOSTBUFFER_FREE", \ - "HPI_ISTREAM_GROUP_ADD", \ - "HPI_ISTREAM_GROUP_GETMAP", \ - "HPI_ISTREAM_GROUP_RESET", \ - "HPI_ISTREAM_HOSTBUFFER_GET_INFO", \ - "HPI_ISTREAM_WAIT_START", \ -} -function_count_check(HPI_ISTREAM, 19); - -#define HPI_MIXER_STRINGS \ -{ \ - "HPI_MIXER_OPEN", \ - "HPI_MIXER_CLOSE", \ - "HPI_MIXER_GET_INFO", \ - "HPI_MIXER_GET_NODE_INFO", \ - "HPI_MIXER_GET_CONTROL", \ - "HPI_MIXER_SET_CONNECTION", \ - "HPI_MIXER_GET_CONNECTIONS", \ - "HPI_MIXER_GET_CONTROL_BY_INDEX", \ - "HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX", \ - "HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES", \ - "HPI_MIXER_STORE", \ -} -function_count_check(HPI_MIXER, 11); - -#define HPI_CONTROL_STRINGS \ -{ \ - "HPI_CONTROL_GET_INFO", \ - "HPI_CONTROL_GET_STATE", \ - "HPI_CONTROL_SET_STATE" \ -} -function_count_check(HPI_CONTROL, 3); - -#define HPI_NVMEMORY_STRINGS \ -{ \ - "HPI_NVMEMORY_OPEN", \ - "HPI_NVMEMORY_READ_BYTE", \ - "HPI_NVMEMORY_WRITE_BYTE" \ -} -function_count_check(HPI_NVMEMORY, 3); - -#define HPI_DIGITALIO_STRINGS \ -{ \ - "HPI_GPIO_OPEN", \ - "HPI_GPIO_READ_BIT", \ - "HPI_GPIO_WRITE_BIT", \ - "HPI_GPIO_READ_ALL", \ - "HPI_GPIO_WRITE_STATUS"\ -} -function_count_check(HPI_GPIO, 5); - -#define HPI_WATCHDOG_STRINGS \ -{ \ - "HPI_WATCHDOG_OPEN", \ - "HPI_WATCHDOG_SET_TIME", \ - "HPI_WATCHDOG_PING" \ -} - -#define HPI_CLOCK_STRINGS \ -{ \ - "HPI_CLOCK_OPEN", \ - "HPI_CLOCK_SET_TIME", \ - "HPI_CLOCK_GET_TIME" \ -} - -#define HPI_PROFILE_STRINGS \ -{ \ - "HPI_PROFILE_OPEN_ALL", \ - "HPI_PROFILE_START_ALL", \ - "HPI_PROFILE_STOP_ALL", \ - "HPI_PROFILE_GET", \ - "HPI_PROFILE_GET_IDLECOUNT", \ - "HPI_PROFILE_GET_NAME", \ - "HPI_PROFILE_GET_UTILIZATION" \ -} -function_count_check(HPI_PROFILE, 7); - -#define HPI_ASYNCEVENT_STRINGS \ -{ \ - "HPI_ASYNCEVENT_OPEN",\ - "HPI_ASYNCEVENT_CLOSE ",\ - "HPI_ASYNCEVENT_WAIT",\ - "HPI_ASYNCEVENT_GETCOUNT",\ - "HPI_ASYNCEVENT_GET",\ - "HPI_ASYNCEVENT_SENDEVENTS"\ -} -function_count_check(HPI_ASYNCEVENT, 6); - -#define HPI_CONTROL_TYPE_STRINGS \ -{ \ - "null control", \ - "HPI_CONTROL_CONNECTION", \ - "HPI_CONTROL_VOLUME", \ - "HPI_CONTROL_METER", \ - "HPI_CONTROL_MUTE", \ - "HPI_CONTROL_MULTIPLEXER", \ - "HPI_CONTROL_AESEBU_TRANSMITTER", \ - "HPI_CONTROL_AESEBU_RECEIVER", \ - "HPI_CONTROL_LEVEL", \ - "HPI_CONTROL_TUNER", \ - "HPI_CONTROL_ONOFFSWITCH", \ - "HPI_CONTROL_VOX", \ - "HPI_CONTROL_AES18_TRANSMITTER", \ - "HPI_CONTROL_AES18_RECEIVER", \ - "HPI_CONTROL_AES18_BLOCKGENERATOR", \ - "HPI_CONTROL_CHANNEL_MODE", \ - "HPI_CONTROL_BITSTREAM", \ - "HPI_CONTROL_SAMPLECLOCK", \ - "HPI_CONTROL_MICROPHONE", \ - "HPI_CONTROL_PARAMETRIC_EQ", \ - "HPI_CONTROL_COMPANDER", \ - "HPI_CONTROL_COBRANET", \ - "HPI_CONTROL_TONE_DETECT", \ - "HPI_CONTROL_SILENCE_DETECT", \ - "HPI_CONTROL_PAD", \ - "HPI_CONTROL_SRC" ,\ - "HPI_CONTROL_UNIVERSAL" \ -} - -compile_time_assert((HPI_CONTROL_LAST_INDEX + 1 == 27), - controltype_strings_match_defs); - -#define HPI_SOURCENODE_STRINGS \ -{ \ - "no source", \ - "HPI_SOURCENODE_OSTREAM", \ - "HPI_SOURCENODE_LINEIN", \ - "HPI_SOURCENODE_AESEBU_IN", \ - "HPI_SOURCENODE_TUNER", \ - "HPI_SOURCENODE_RF", \ - "HPI_SOURCENODE_CLOCK_SOURCE", \ - "HPI_SOURCENODE_RAW_BITSTREAM", \ - "HPI_SOURCENODE_MICROPHONE", \ - "HPI_SOURCENODE_COBRANET", \ - "HPI_SOURCENODE_ANALOG", \ - "HPI_SOURCENODE_ADAPTER" \ -} - -compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_NONE + 1) == - (12), sourcenode_strings_match_defs); - -#define HPI_DESTNODE_STRINGS \ -{ \ - "no destination", \ - "HPI_DESTNODE_ISTREAM", \ - "HPI_DESTNODE_LINEOUT", \ - "HPI_DESTNODE_AESEBU_OUT", \ - "HPI_DESTNODE_RF", \ - "HPI_DESTNODE_SPEAKER", \ - "HPI_DESTNODE_COBRANET", \ - "HPI_DESTNODE_ANALOG" \ -} -compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_NONE + 1) == (8), - destnode_strings_match_defs); - -#define HPI_CONTROL_CHANNEL_MODE_STRINGS \ -{ \ - "XXX HPI_CHANNEL_MODE_ERROR XXX", \ - "HPI_CHANNEL_MODE_NORMAL", \ - "HPI_CHANNEL_MODE_SWAP", \ - "HPI_CHANNEL_MODE_LEFT_ONLY", \ - "HPI_CHANNEL_MODE_RIGHT_ONLY" \ -} - -#endif /* _HPIDEBUG_H */ +#endif /* _HPIDEBUG_H_ */
From: Eliot Blennerhassett eblennerhassett@audioscience.com
All enum values numeric for easier finding, particularly error codes. Remove many unused declarations.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 262 +++++++----------------------------------------------- 1 files changed, 33 insertions(+), 229 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index 23399d0..4fb42c6 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -50,8 +50,8 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
/* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 4, 1) -#define HPI_VER_STRING "4.04.01" +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 14) +#define HPI_VER_STRING "4.05.14"
/* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) @@ -64,6 +64,7 @@ i.e 3.05.02 is a development version /******** HPI API DEFINITIONS *****/ /******************************************************************************/ /******************************************************************************/ + /*******************************************/ /** Audio format types \ingroup stream @@ -263,10 +264,10 @@ enum HPI_CONTROLS { HPI_CONTROL_MULTIPLEXER = 5, /**< multiplexer control. */
HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control. */ - HPI_CONTROL_AESEBUTX = HPI_CONTROL_AESEBU_TRANSMITTER, + HPI_CONTROL_AESEBUTX = 6, /* HPI_CONTROL_AESEBU_TRANSMITTER */
HPI_CONTROL_AESEBU_RECEIVER = 7, /**< AES/EBU receiver control. */ - HPI_CONTROL_AESEBURX = HPI_CONTROL_AESEBU_RECEIVER, + HPI_CONTROL_AESEBURX = 7, /* HPI_CONTROL_AESEBU_RECEIVER */
HPI_CONTROL_LEVEL = 8, /**< level/trim control - works in d_bu. */ HPI_CONTROL_TUNER = 9, /**< tuner control. */ @@ -281,7 +282,7 @@ enum HPI_CONTROLS { HPI_CONTROL_SAMPLECLOCK = 17, /**< sample clock control. */ HPI_CONTROL_MICROPHONE = 18, /**< microphone control. */ HPI_CONTROL_PARAMETRIC_EQ = 19, /**< parametric EQ control. */ - HPI_CONTROL_EQUALIZER = HPI_CONTROL_PARAMETRIC_EQ, + HPI_CONTROL_EQUALIZER = 19, /*HPI_CONTROL_PARAMETRIC_EQ */
HPI_CONTROL_COMPANDER = 20, /**< compander control. */ HPI_CONTROL_COBRANET = 21, /**< cobranet control. */ @@ -767,14 +768,6 @@ enum HPI_TUNER_MODE_VALUES { HPI_TUNER_MODE_RDS_RBDS = 2 /**< RDS - RBDS mode */ };
-/** Tuner Level settings -\ingroup tuner -*/ -enum HPI_TUNER_LEVEL { - HPI_TUNER_LEVEL_AVERAGE = 0, - HPI_TUNER_LEVEL_RAW = 1 -}; - /** Tuner Status Bits
These bitfield values are returned by a call to HPI_Tuner_GetStatus(). @@ -783,13 +776,13 @@ Multiple fields are returned from a single call. */ enum HPI_TUNER_STATUS_BITS { HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< video color is present. */ - HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */ - HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */ - HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */ - HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */ - HPI_TUNER_FM_STEREO = 0x2000, /**< tuner reports back FM stereo. */ - HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */ - HPI_TUNER_MULTIPROGRAM = 0x0400 /**< tuner reports multiple programs. */ + HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */ + HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */ + HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */ + HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */ + HPI_TUNER_MULTIPROGRAM = 0x0400, /**< tuner reports multiple programs. */ + HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */ + HPI_TUNER_FM_STEREO = 0x2000 /**< tuner reports back FM stereo. */ };
/** Channel Modes @@ -909,6 +902,8 @@ enum HPI_ERROR_CODES { HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL = 114, /** The returned response did not match the sent message */ HPI_ERROR_RESPONSE_MISMATCH = 115, + /** A control setting that should have been cached was not. */ + HPI_ERROR_CONTROL_CACHING = 116,
/** Too many adapters.*/ HPI_ERROR_TOO_MANY_ADAPTERS = 200, @@ -954,13 +949,13 @@ enum HPI_ERROR_CODES { HPI_ERROR_FLASH = 220,
/** Flash has bad checksum */ - HPI_ERROR_BAD_CHECKSUM = (HPI_ERROR_FLASH + 1), - HPI_ERROR_BAD_SEQUENCE = (HPI_ERROR_FLASH + 2), - HPI_ERROR_FLASH_ERASE = (HPI_ERROR_FLASH + 3), - HPI_ERROR_FLASH_PROGRAM = (HPI_ERROR_FLASH + 4), - HPI_ERROR_FLASH_VERIFY = (HPI_ERROR_FLASH + 5), - HPI_ERROR_FLASH_TYPE = (HPI_ERROR_FLASH + 6), - HPI_ERROR_FLASH_START = (HPI_ERROR_FLASH + 7), + HPI_ERROR_BAD_CHECKSUM = 221, + HPI_ERROR_BAD_SEQUENCE = 222, + HPI_ERROR_FLASH_ERASE = 223, + HPI_ERROR_FLASH_PROGRAM = 224, + HPI_ERROR_FLASH_VERIFY = 225, + HPI_ERROR_FLASH_TYPE = 226, + HPI_ERROR_FLASH_START = 227,
/** Reserved for OEMs. */ HPI_ERROR_RESERVED_1 = 290, @@ -1027,7 +1022,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_NVMEM_FAIL = 452,
/** I2C */ - HPI_ERROR_I2C_MISSING_ACK = HPI_ERROR_CONTROL_I2C_MISSING_ACK, + HPI_ERROR_I2C_MISSING_ACK = 405, /*HPI_ERROR_CONTROL_I2C_MISSING_ACK */ HPI_ERROR_I2C_BAD_ADR = 460,
/** Entity errors */ @@ -1035,6 +1030,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_ENTITY_ITEM_COUNT = 471, HPI_ERROR_ENTITY_TYPE_INVALID = 472, HPI_ERROR_ENTITY_ROLE_INVALID = 473, + HPI_ERROR_ENTITY_SIZE_MISMATCH = 474,
/* AES18 specific errors were 500..507 */
@@ -1045,10 +1041,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_MUTEX_TIMEOUT = 700,
/** errors from HPI backends have values >= this */ - HPI_ERROR_BACKEND_BASE = 900, - - /** indicates a cached u16 value is invalid. */ - HPI_ERROR_ILLEGAL_CACHE_VALUE = 0xffff + HPI_ERROR_BACKEND_BASE = 900 };
/** \defgroup maximums HPI maximum values @@ -1092,7 +1085,7 @@ struct hpi_format { /**< Stereo/JointStereo/Mono */ u16 mode_legacy; /**< Legacy ancillary mode or idle bit */ - u16 unused; /**< unused */ + u16 unused; /**< Unused */ u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */ }; @@ -1106,8 +1099,8 @@ struct hpi_anc_frame { */ struct hpi_async_event { u16 event_type; /**< type of event. \sa async_event */ - u16 sequence; /**< sequence number, allows lost event detection */ - u32 state; /**< new state */ + u16 sequence; /**< Sequence number, allows lost event detection */ + u32 state; /**< New state */ u32 h_object; /**< handle to the object returning the event. */ union { struct { @@ -1120,55 +1113,6 @@ struct hpi_async_event { } u; };
-/*/////////////////////////////////////////////////////////////////////////// */ -/* Public HPI Entity related definitions */ - -struct hpi_entity; - -enum e_entity_type { - entity_type_null, - entity_type_sequence, /* sequence of potentially heterogeneous TLV entities */ - - entity_type_reference, /* refers to a TLV entity or NULL */ - - entity_type_int, /* 32 bit */ - entity_type_float, /* ieee754 binary 32 bit encoding */ - entity_type_double, - - entity_type_cstring, - entity_type_octet, - entity_type_ip4_address, - entity_type_ip6_address, - entity_type_mac_address, - - LAST_ENTITY_TYPE -}; - -enum e_entity_role { - entity_role_null, - entity_role_value, - entity_role_classname, - - entity_role_units, - entity_role_flags, - entity_role_range, - - entity_role_mapping, - entity_role_enum, - - entity_role_instance_of, - entity_role_depends_on, - entity_role_member_of_group, - entity_role_value_constraint, - entity_role_parameter_port, - - entity_role_block, - entity_role_node_group, - entity_role_audio_port, - entity_role_clock_port, - LAST_ENTITY_ROLE -}; - /* skip host side function declarations for DSP compile and documentation extraction */
@@ -1191,34 +1135,19 @@ u16 hpi_stream_estimate_buffer_size(struct hpi_format *pF,
/*/////////// */ /* SUB SYSTEM */ -struct hpi_hsubsys *hpi_subsys_create(void - ); +struct hpi_hsubsys *hpi_subsys_create(void);
void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys);
-u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, - u32 *pversion); - u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, u32 *pversion_ex);
-u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion, - u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length); - -u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys, - u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length); - u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, int *pn_num_adapters);
u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator, u32 *padapter_index, u16 *pw_adapter_type);
-u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass); - -u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys, - const char *sz_interface); - /*///////// */ /* ADAPTER */
@@ -1244,13 +1173,10 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, u32 *padapter_mode);
-u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys, - u16 adapter_index, u16 *assert_present, char *psz_assert, - u16 *pw_line_number); - -u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys, - u16 adapter_index, u16 *assert_present, char *psz_assert, - u32 *pline_number, u16 *pw_assert_on_dsp); +u16 hpi_adapter_get_assert2(const struct hpi_hsubsys *ph_subsys, + u16 adapter_index, u16 *p_assert_count, char *psz_assert, + u32 *p_param1, u32 *p_param2, u32 *p_dsp_string_addr, + u16 *p_processor_id);
u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, u16 assert_id); @@ -1274,66 +1200,6 @@ u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, u16 index, u16 what_to_enumerate, u16 property_index, u32 *psetting); - -/*////////////// */ -/* NonVol Memory */ -u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, - u32 *ph_nv_memory, u16 *pw_size_in_bytes); - -u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys, - u32 h_nv_memory, u16 index, u16 *pw_data); - -u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys, - u32 h_nv_memory, u16 index, u16 data); - -/*////////////// */ -/* Digital I/O */ -u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, - u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits); - -u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, - u16 bit_index, u16 *pw_bit_data); - -u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, - u16 aw_all_bit_data[4] - ); - -u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, - u16 bit_index, u16 bit_data); - -u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio, - u16 aw_all_bit_data[4] - ); - -/**********************/ -/* Async Event Object */ -/**********************/ -u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys, - u16 adapter_index, u32 *ph_async); - -u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async); - -u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, - u16 maximum_events, struct hpi_async_event *p_events, - u16 *pw_number_returned); - -u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys, - u32 h_async, u16 *pw_count); - -u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async, - u16 maximum_events, struct hpi_async_event *p_events, - u16 *pw_number_returned); - -/*/////////// */ -/* WATCH-DOG */ -u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, - u32 *ph_watchdog); - -u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog, - u32 time_millisec); - -u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog); - /**************/ /* OUT STREAM */ /**************/ @@ -1957,68 +1823,6 @@ u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 hC, int *threshold); - -/******************************* - Universal control -*******************************/ -u16 hpi_entity_find_next(struct hpi_entity *container_entity, - enum e_entity_type type, enum e_entity_role role, int recursive_flag, - struct hpi_entity **current_match); - -u16 hpi_entity_copy_value_from(struct hpi_entity *entity, - enum e_entity_type type, size_t item_count, void *value_dst_p); - -u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type, - size_t *items, enum e_entity_role *role, void **value); - -u16 hpi_entity_alloc_and_pack(const enum e_entity_type type, - const size_t item_count, const enum e_entity_role role, void *value, - struct hpi_entity **entity); - -void hpi_entity_free(struct hpi_entity *entity); - -u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC, - struct hpi_entity **info); - -u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC, - struct hpi_entity **value); - -u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC, - struct hpi_entity *value); - -/*/////////// */ -/* DSP CLOCK */ -/*/////////// */ -u16 hpi_clock_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, - u32 *ph_dsp_clock); - -u16 hpi_clock_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, - u16 hour, u16 minute, u16 second, u16 milli_second); - -u16 hpi_clock_get_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock, - u16 *pw_hour, u16 *pw_minute, u16 *pw_second, u16 *pw_milli_second); - -/*/////////// */ -/* PROFILE */ -/*/////////// */ -u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys, - u16 adapter_index, u16 profile_index, u32 *ph_profile, - u16 *pw_max_profiles); - -u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile, - u16 index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count, - u32 *pmax_micro_seconds, u32 *pmin_micro_seconds); - -u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); - -u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile); - -u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile, - u16 index, char *sz_profile_name, u16 profile_name_length); - -u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys, - u32 h_profile, u32 *putilization); - /*//////////////////// */ /* UTILITY functions */
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Reported samples_played from card may be inaccurate, so don't use it. Update control names to be closer to alsa standard practice. Also fixed some accidentally lowercased strings.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/asihpi.c | 437 ++++++++++++++++++++++++-------------------------- 1 files changed, 210 insertions(+), 227 deletions(-)
diff --git a/pci/asihpi/asihpi.c b/pci/asihpi/asihpi.c index c80b0b8..8bcde19 100644 --- a/pci/asihpi/asihpi.c +++ b/pci/asihpi/asihpi.c @@ -21,6 +21,7 @@ * would appreciate it if you grant us the right to use those modifications * for any purpose including commercial applications. */ + /* >0: print Hw params, timer vars. >1: print stream write/copy sizes */ #define REALLY_VERBOSE_LOGGING 0
@@ -36,16 +37,19 @@ #define VPRINTK2(...) #endif
-#ifndef ASI_STYLE_NAMES -/* not sure how ALSA style name should look */ -#define ASI_STYLE_NAMES 1 -#endif - #include "hpi_internal.h" #include "hpimsginit.h" #include "hpioctl.h"
+#ifndef KERNEL_ALSA_BUILD +/* building in ALSA source tree */ +#include "adriver.h" +#else +/* building in kernel tree */ +#endif + #include <linux/pci.h> +#include <linux/version.h> #include <linux/init.h> #include <linux/jiffies.h> #include <linux/slab.h> @@ -85,11 +89,11 @@ MODULE_PARM_DESC(enable_hpi_hwdep,
/* identify driver */ #ifdef KERNEL_ALSA_BUILD -static char *build_info = "built using headers from kernel source"; +static char *build_info = "Built using headers from kernel source"; module_param(build_info, charp, S_IRUGO); MODULE_PARM_DESC(build_info, "built using headers from kernel source"); #else -static char *build_info = "built within ALSA source"; +static char *build_info = "Built within ALSA source"; module_param(build_info, charp, S_IRUGO); MODULE_PARM_DESC(build_info, "built within ALSA source"); #endif @@ -104,7 +108,7 @@ static struct hpi_hsubsys *ss; /* handle to HPI audio subsystem */
/* defaults */ #define PERIODS_MIN 2 -#define PERIOD_BYTES_MIN 2304 +#define PERIOD_BYTES_MIN 2048 #define BUFFER_BYTES_MAX (512 * 1024)
/*#define TIMER_MILLISECONDS 20 @@ -155,8 +159,9 @@ struct snd_card_asihpi_pcm { unsigned int pcm_size; unsigned int pcm_count; unsigned int bytes_per_sec; - unsigned int pcm_irq_pos; /* IRQ position */ - unsigned int pcm_buf_pos; /* position in buffer */ + unsigned int pcm_buf_host_rw_ofs; /* Host R/W pos */ + unsigned int pcm_buf_dma_ofs; /* DMA R/W offset in buffer */ + unsigned int pcm_buf_elapsed_dma_ofs; /* DMA R/W offset in buffer */ struct snd_pcm_substream *substream; u32 h_stream; struct hpi_format format; @@ -244,14 +249,16 @@ static inline u16 hpi_stream_get_info_ex( u32 *pauxiliary_data ) { + u16 e; if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM) - return hpi_outstream_get_info_ex(hS, h_stream, pw_state, + e = hpi_outstream_get_info_ex(hS, h_stream, pw_state, pbuffer_size, pdata_in_buffer, psample_count, pauxiliary_data); else - return hpi_instream_get_info_ex(hS, h_stream, pw_state, + e = hpi_instream_get_info_ex(hS, h_stream, pw_state, pbuffer_size, pdata_in_buffer, psample_count, pauxiliary_data); + return e; }
static inline u16 hpi_stream_group_add(struct hpi_hsubsys *hS, @@ -299,11 +306,11 @@ static void print_hwparams(struct snd_pcm_hw_params *p) { snd_printd("HWPARAMS \n"); snd_printd("samplerate %d \n", params_rate(p)); - snd_printd("channels %d \n", params_channels(p)); - snd_printd("format %d \n", params_format(p)); + snd_printd("Channels %d \n", params_channels(p)); + snd_printd("Format %d \n", params_format(p)); snd_printd("subformat %d \n", params_subformat(p)); - snd_printd("buffer bytes %d \n", params_buffer_bytes(p)); - snd_printd("period bytes %d \n", params_period_bytes(p)); + snd_printd("Buffer bytes %d \n", params_buffer_bytes(p)); + snd_printd("Period bytes %d \n", params_period_bytes(p)); snd_printd("access %d \n", params_access(p)); snd_printd("period_size %d \n", params_period_size(p)); snd_printd("periods %d \n", params_periods(p)); @@ -383,7 +390,7 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, HPI_CONTROL_SAMPLECLOCK, &h_control); if (err) { snd_printk(KERN_ERR - "no local sampleclock, err %d\n", err); + "No local sampleclock, err %d\n", err); }
for (idx = 0; idx < 100; idx++) { @@ -391,7 +398,7 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, h_control, idx, &sample_rate)) { if (!idx) snd_printk(KERN_ERR - "local rate query failed\n"); + "Local rate query failed\n");
break; } @@ -525,11 +532,27 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, bps=%d\n", dpcm->pcm_size, dpcm->pcm_count, bytes_per_sec);
- dpcm->pcm_irq_pos = 0; - dpcm->pcm_buf_pos = 0; return 0; }
+static int +snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_card_asihpi_pcm *dpcm = runtime->private_data; + if (dpcm->hpi_buffer_attached) + hpi_stream_host_buffer_detach(ss, dpcm->h_stream); + + snd_pcm_lib_free_pages(substream); + return 0; +} + +static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime) +{ + struct snd_card_asihpi_pcm *dpcm = runtime->private_data; + kfree(dpcm); +} + static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * substream) { @@ -537,9 +560,8 @@ static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * struct snd_card_asihpi_pcm *dpcm = runtime->private_data; int expiry;
- expiry = (dpcm->pcm_count * HZ / dpcm->bytes_per_sec); - /* wait longer the first time, for samples to propagate */ - expiry = max(expiry, 20); + expiry = HZ / 100;; //? (dpcm->pcm_count * HZ / dpcm->bytes_per_sec); + expiry = max(expiry, 1); /* don't let it be zero! */ dpcm->timer.expires = jiffies + expiry; dpcm->respawn_timer = 1; add_timer(&dpcm->timer); @@ -562,13 +584,13 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, struct snd_pcm_substream *s; u16 e;
- snd_printd("trigger %dstream %d\n", + snd_printd("Trigger %dstream %d\n", substream->stream, substream->number); switch (cmd) { case SNDRV_PCM_TRIGGER_START: snd_pcm_group_for_each_entry(s, substream) { - struct snd_card_asihpi_pcm *ds; - ds = s->runtime->private_data; + struct snd_pcm_runtime *runtime = s->runtime; + struct snd_card_asihpi_pcm *ds = runtime->private_data;
if (snd_pcm_substream_chip(s) != card) continue; @@ -576,17 +598,19 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, if ((s->stream == SNDRV_PCM_STREAM_PLAYBACK) && (card->support_mmap)) { /* How do I know how much valid data is present - * in buffer? Just guessing 2 periods, but if + * in buffer? Must be at least one period! + * Guessing 2 periods, but if * buffer is bigger it may contain even more * data?? */ - unsigned int preload = ds->pcm_count * 2; - VPRINTK2("preload %d\n", preload); + unsigned int preload = ds->pcm_count * 1; + VPRINTK2("Preload x%x\n", preload); hpi_handle_error(hpi_outstream_write_buf( ss, ds->h_stream, - &s->runtime->dma_area[0], + &runtime->dma_area[0], preload, &ds->format)); + ds->pcm_buf_host_rw_ofs = preload; }
if (card->support_grouping) { @@ -604,7 +628,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, } else break; } - snd_printd("start\n"); + snd_printd("Start\n"); /* start the master stream */ snd_card_asihpi_pcm_timer_start(substream); hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); @@ -627,7 +651,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, } else break; } - snd_printd("stop\n"); + snd_printd("Stop\n");
/* _prepare and _hwparams reset the stream */ hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); @@ -641,12 +665,12 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - snd_printd("pause release\n"); + snd_printd("Pause release\n"); hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream)); snd_card_asihpi_pcm_timer_start(substream); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - snd_printd("pause\n"); + snd_printd("Pause\n"); snd_card_asihpi_pcm_timer_stop(substream); hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream)); break; @@ -658,38 +682,20 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, return 0; }
-static int -snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - if (dpcm->hpi_buffer_attached) - hpi_stream_host_buffer_detach(ss, dpcm->h_stream); - - snd_pcm_lib_free_pages(substream); - return 0; -} - -static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime) -{ - struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - kfree(dpcm); -} - /*algorithm outline Without linking degenerates to getting single stream pos etc Without mmap 2nd loop degenerates to snd_pcm_period_elapsed */ /* -buf_pos=get_buf_pos(s); +pcm_buf_dma_ofs=get_buf_pos(s); for_each_linked_stream(s) { - buf_pos=get_buf_pos(s); - min_buf_pos = modulo_min(min_buf_pos, buf_pos, pcm_size) - new_data = min(new_data, calc_new_data(buf_pos,irq_pos) + pcm_buf_dma_ofs=get_buf_pos(s); + min_buf_pos = modulo_min(min_buf_pos, pcm_buf_dma_ofs, pcm_size) + new_data = min(new_data, calc_new_data(pcm_buf_dma_ofs,irq_pos) } timer.expires = jiffies + predict_next_period_ready(min_buf_pos); for_each_linked_stream(s) { - s->buf_pos = min_buf_pos; + s->pcm_buf_dma_ofs = min_buf_pos; if (new_data > pcm_count) { if (mmap) { irq_pos = (irq_pos + pcm_count) % pcm_size; @@ -728,11 +734,11 @@ static void snd_card_asihpi_timer_function(unsigned long data) struct snd_pcm_runtime *runtime; struct snd_pcm_substream *s; unsigned int newdata = 0; - unsigned int buf_pos, min_buf_pos = 0; + unsigned int pcm_buf_dma_ofs, min_buf_pos = 0; unsigned int remdata, xfercount, next_jiffies; int first = 1; u16 state; - u32 buffer_size, data_avail, samples_played, aux; + u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
/* find minimum newdata and buffer pos in group */ snd_pcm_group_for_each_entry(s, dpcm->substream) { @@ -744,35 +750,34 @@ static void snd_card_asihpi_timer_function(unsigned long data)
hpi_handle_error(hpi_stream_get_info_ex(ss, ds->h_stream, &state, - &buffer_size, &data_avail, - &samples_played, &aux)); + &buffer_size, &bytes_avail, + &samples_played, &on_card_bytes));
/* number of bytes in on-card buffer */ - runtime->delay = aux; + runtime->delay = on_card_bytes;
if (state == HPI_STATE_DRAINED) { snd_printd(KERN_WARNING "outstream %d drained\n", s->number); - snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); - return; + //snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); + //return; }
- if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { - buf_pos = frames_to_bytes(runtime, samples_played); - } else { - buf_pos = data_avail + ds->pcm_irq_pos; - } + if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) + pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; + else + pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs;
if (first) { /* can't statically init min when wrap is involved */ - min_buf_pos = buf_pos; - newdata = (buf_pos - ds->pcm_irq_pos) % ds->pcm_size; + min_buf_pos = pcm_buf_dma_ofs; + newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->pcm_size; first = 0; } else { min_buf_pos = - modulo_min(min_buf_pos, buf_pos, UINT_MAX+1L); + modulo_min(min_buf_pos, pcm_buf_dma_ofs, UINT_MAX+1L); newdata = min( - (buf_pos - ds->pcm_irq_pos) % ds->pcm_size, + (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->pcm_size, newdata); }
@@ -781,29 +786,40 @@ static void snd_card_asihpi_timer_function(unsigned long data) runtime->status->hw_ptr), (unsigned long)frames_to_bytes(runtime, runtime->control->appl_ptr)); + VPRINTK1("%d S=%d, irq=%04X, pos=x%04X, left=x%04X," " aux=x%04X space=x%04X\n", s->number, - state, ds->pcm_irq_pos, buf_pos, (int)data_avail, - (int)aux, buffer_size-data_avail); + state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, + (int)on_card_bytes, buffer_size-bytes_avail); } + pcm_buf_dma_ofs = min_buf_pos;
remdata = newdata % dpcm->pcm_count; xfercount = newdata - remdata; /* a multiple of pcm_count */ - next_jiffies = ((dpcm->pcm_count-remdata) * HZ / dpcm->bytes_per_sec)+1; - next_jiffies = max(next_jiffies, 2U * HZ / 1000U); + /* come back when on_card_bytes has decreased enough to allow + write to happen, or when data has been consumed to make another + period + */ + if (xfercount && (on_card_bytes > dpcm->pcm_count)) + next_jiffies = ((on_card_bytes - dpcm->pcm_count) * HZ / dpcm->bytes_per_sec); + else + next_jiffies = ((dpcm->pcm_count - remdata) * HZ / dpcm->bytes_per_sec); + + next_jiffies = max(next_jiffies, 1U); dpcm->timer.expires = jiffies + next_jiffies; - VPRINTK1("jif %d buf pos x%04X newdata x%04X xc x%04X\n", - next_jiffies, min_buf_pos, newdata, xfercount); + VPRINTK1("jif %d buf pos x%04X newdata x%04X xfer x%04X\n", + next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); +
snd_pcm_group_for_each_entry(s, dpcm->substream) { struct snd_card_asihpi_pcm *ds = s->runtime->private_data; - ds->pcm_buf_pos = min_buf_pos;
- if (xfercount) { + ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs; + + if (xfercount && (on_card_bytes <= ds->pcm_count)) { if (card->support_mmap) { - ds->pcm_irq_pos = ds->pcm_irq_pos + xfercount; if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { - VPRINTK2("write OS%d x%04x\n", + VPRINTK2("Write OS%d x%04x\n", s->number, ds->pcm_count); hpi_handle_error( @@ -814,15 +830,17 @@ static void snd_card_asihpi_timer_function(unsigned long data) xfercount, &ds->format)); } else { - VPRINTK2("read IS%d x%04x\n", + VPRINTK2("Read IS%d x%04x\n", s->number, - dpcm->pcm_count); + xfercount); hpi_handle_error( hpi_instream_read_buf( ss, ds->h_stream, NULL, xfercount)); } + ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount; } /* else R/W will be handled by read/write callbacks */ + ds->pcm_buf_elapsed_dma_ofs = pcm_buf_dma_ofs; snd_pcm_period_elapsed(s); } } @@ -848,9 +866,9 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * snd_printd(KERN_INFO "playback prepare %d\n", substream->number);
hpi_handle_error(hpi_outstream_reset(ss, dpcm->h_stream)); - dpcm->pcm_irq_pos = 0; - dpcm->pcm_buf_pos = 0; - + dpcm->pcm_buf_host_rw_ofs = 0; + dpcm->pcm_buf_dma_ofs = 0; + dpcm->pcm_buf_elapsed_dma_ofs = 0; return 0; }
@@ -861,27 +879,8 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) struct snd_card_asihpi_pcm *dpcm = runtime->private_data; snd_pcm_uframes_t ptr;
- u32 samples_played; - u16 err; - - if (!snd_pcm_stream_linked(substream)) { - /* NOTE, can use samples played for playback position here and - * in timer fn because it LAGS the actual read pointer, and is a - * better representation of actual playout position - */ - err = hpi_outstream_get_info_ex(ss, dpcm->h_stream, NULL, - NULL, NULL, - &samples_played, NULL); - hpi_handle_error(err); - - dpcm->pcm_buf_pos = frames_to_bytes(runtime, samples_played); - } - /* else must return most conservative value found in timer func - * by looping over all streams - */ - - ptr = bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size); - VPRINTK2("playback_pointer=%04ld\n", (unsigned long)ptr); + ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->pcm_size); + //VPRINTK2("playback_pointer=x%04lx\n", (unsigned long)ptr); return ptr; }
@@ -998,7 +997,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, card->update_interval_frames); snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - card->update_interval_frames * 4, UINT_MAX); + card->update_interval_frames * 2, UINT_MAX);
snd_pcm_set_sync(substream);
@@ -1039,6 +1038,8 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream, hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream, runtime->dma_area, len, &dpcm->format));
+ dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; + return 0; }
@@ -1091,13 +1092,13 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
- VPRINTK2("capture pointer %d=%d\n", - substream->number, dpcm->pcm_buf_pos); - /* NOTE Unlike playback can't use actual dwSamplesPlayed + VPRINTK2("Capture pointer %d=%d\n", + substream->number, dpcm->pcm_buf_dma_ofs); + /* NOTE Unlike playback can't use actual samples_played for the capture position, because those samples aren't yet in the local buffer available for reading. */ - return bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size); + return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->pcm_size); }
static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream, @@ -1112,10 +1113,11 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
hpi_handle_error(hpi_instream_reset(ss, dpcm->h_stream)); - dpcm->pcm_irq_pos = 0; - dpcm->pcm_buf_pos = 0; + dpcm->pcm_buf_host_rw_ofs = 0; + dpcm->pcm_buf_dma_ofs = 0; + dpcm->pcm_buf_elapsed_dma_ofs = 0;
- snd_printd("capture prepare %d\n", substream->number); + snd_printd("Capture Prepare %d\n", substream->number); return 0; }
@@ -1209,6 +1211,9 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID;
+ if (card->support_grouping) + snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_SYNC_START; + runtime->hw = snd_card_asihpi_capture;
if (card->support_mmap) @@ -1241,18 +1246,17 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream, { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_card_asihpi_pcm *dpcm = runtime->private_data; - u32 data_size; + u32 len;
- data_size = frames_to_bytes(runtime, count); + len = frames_to_bytes(runtime, count);
- VPRINTK2("capture copy%d %d bytes\n", substream->number, data_size); + VPRINTK2("Capture copy%d %d bytes\n", substream->number, len); hpi_handle_error(hpi_instream_read_buf(ss, dpcm->h_stream, - runtime->dma_area, data_size)); + runtime->dma_area, len));
- /* Used by capture_pointer */ - dpcm->pcm_irq_pos = dpcm->pcm_irq_pos + data_size; + dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len;
- if (copy_to_user(dst, runtime->dma_area, data_size)) + if (copy_to_user(dst, runtime->dma_area, len)) return -EFAULT;
return 0; @@ -1287,7 +1291,7 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, struct snd_pcm *pcm; int err;
- err = snd_pcm_new(asihpi->card, "asihpi PCM", device, + err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, asihpi->num_outstreams, asihpi->num_instreams, &pcm); if (err < 0) @@ -1307,7 +1311,7 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi,
pcm->private_data = asihpi; pcm->info_flags = 0; - strcpy(pcm->name, "asihpi PCM"); + strcpy(pcm->name, "Asihpi PCM");
/*? do we want to emulate MMAP for non-BBM cards? Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ @@ -1330,7 +1334,7 @@ struct hpi_control { char name[44]; /* copied to snd_ctl_elem_id.name[44]; */ };
-static char *asihpi_tuner_band_names[] = +static const char * const asihpi_tuner_band_names[] = { "invalid", "AM", @@ -1349,70 +1353,38 @@ compile_time_assert( (HPI_TUNER_BAND_LAST+1)), assert_tuner_band_names_size);
-#if ASI_STYLE_NAMES -static char *asihpi_src_names[] = +static const char * const asihpi_src_names[] = { "no source", - "outstream", - "line_in", - "aes_in", - "tuner", + "PCM", + "Line", + "Digital", + "Tuner", "RF", - "clock", - "bitstr", - "mic", - "cobranet", - "analog_in", - "adapter", + "Clock", + "Bitstream", + "Microphone", + "Cobranet", + "Analog", + "Adapter", }; -#else -static char *asihpi_src_names[] = -{ - "no source", - "PCM playback", - "line in", - "digital in", - "tuner", - "RF", - "clock", - "bitstream", - "mic", - "cobranet in", - "analog in", - "adapter", -}; -#endif
compile_time_assert( (ARRAY_SIZE(asihpi_src_names) == (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)), assert_src_names_size);
-#if ASI_STYLE_NAMES -static char *asihpi_dst_names[] = -{ - "no destination", - "instream", - "line_out", - "aes_out", - "RF", - "speaker" , - "cobranet", - "analog_out", -}; -#else -static char *asihpi_dst_names[] = +static const char * const asihpi_dst_names[] = { "no destination", - "PCM capture", - "line out", - "digital out", + "PCM", + "Line", + "Digital", "RF", - "speaker", - "cobranet out", - "analog out" + "Speaker", + "Cobranet Out", + "Analog" }; -#endif
compile_time_assert( (ARRAY_SIZE(asihpi_dst_names) == @@ -1438,30 +1410,43 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, struct hpi_control *hpi_ctl, char *name) { + char *dir = ""; memset(snd_control, 0, sizeof(*snd_control)); snd_control->name = hpi_ctl->name; snd_control->private_value = hpi_ctl->h_control; snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER; snd_control->index = 0;
+ if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM) + dir = "Capture "; /* On or towards a PCM capture destination*/ + else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && + (!hpi_ctl->dst_node_type)) + dir = "Capture "; /* On a source node that is not PCM playback */ + else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && + (hpi_ctl->dst_node_type)) + dir = "Monitor Playback "; /* Between an input and an output */ + else + dir = "Playback "; /* PCM Playback source, or output node */ + if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type) - sprintf(hpi_ctl->name, "%s%d to %s%d %s", + sprintf(hpi_ctl->name, "%s%d %s%d %s%s", asihpi_src_names[hpi_ctl->src_node_type], hpi_ctl->src_node_index, asihpi_dst_names[hpi_ctl->dst_node_type], hpi_ctl->dst_node_index, - name); + dir, name); else if (hpi_ctl->dst_node_type) { - sprintf(hpi_ctl->name, "%s%d %s", + sprintf(hpi_ctl->name, "%s %d %s%s", asihpi_dst_names[hpi_ctl->dst_node_type], hpi_ctl->dst_node_index, - name); + dir, name); } else { - sprintf(hpi_ctl->name, "%s%d %s", + sprintf(hpi_ctl->name, "%s %d %s%s", asihpi_src_names[hpi_ctl->src_node_type], hpi_ctl->src_node_index, - name); + dir, name); } + // printk(KERN_INFO "adding %s %d to %d ", hpi_ctl->name, hpi_ctl->src_node_type, hpi_ctl->dst_node_type); }
/*------------------------------------------------------------ @@ -1534,7 +1519,7 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
- asihpi_ctl_init(&snd_control, hpi_ctl, "volume"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ; snd_control.info = snd_asihpi_volume_info; @@ -1617,7 +1602,7 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, struct snd_kcontrol_new snd_control;
/* can't use 'volume' cos some nodes have volume as well */ - asihpi_ctl_init(&snd_control, hpi_ctl, "level"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Level"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ; snd_control.info = snd_asihpi_level_info; @@ -1633,7 +1618,7 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, ------------------------------------------------------------*/
/* AESEBU format */ -static char *asihpi_aesebu_format_names[] = +static const char * const asihpi_aesebu_format_names[] = { "N/A", "S/PDIF", @@ -1742,7 +1727,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
- asihpi_ctl_init(&snd_control, hpi_ctl, "format"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Format"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_aesebu_format_info; snd_control.get = snd_asihpi_aesebu_rx_format_get; @@ -1752,7 +1737,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, if (ctl_add(card, &snd_control, asihpi) < 0) return -EINVAL;
- asihpi_ctl_init(&snd_control, hpi_ctl, "status"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Status"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_aesebu_rxstatus_info; @@ -1780,7 +1765,7 @@ static int __devinit snd_asihpi_aesebu_tx_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
- asihpi_ctl_init(&snd_control, hpi_ctl, "format"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Format"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_aesebu_format_info; snd_control.get = snd_asihpi_aesebu_tx_format_get; @@ -2027,7 +2012,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
if (!hpi_tuner_get_gain(ss, hpi_ctl->h_control, NULL)) { - asihpi_ctl_init(&snd_control, hpi_ctl, "gain"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Gain"); snd_control.info = snd_asihpi_tuner_gain_info; snd_control.get = snd_asihpi_tuner_gain_get; snd_control.put = snd_asihpi_tuner_gain_put; @@ -2036,7 +2021,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, return -EINVAL; }
- asihpi_ctl_init(&snd_control, hpi_ctl, "band"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Band"); snd_control.info = snd_asihpi_tuner_band_info; snd_control.get = snd_asihpi_tuner_band_get; snd_control.put = snd_asihpi_tuner_band_put; @@ -2044,7 +2029,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, if (ctl_add(card, &snd_control, asihpi) < 0) return -EINVAL;
- asihpi_ctl_init(&snd_control, hpi_ctl, "freq"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Freq"); snd_control.info = snd_asihpi_tuner_freq_info; snd_control.get = snd_asihpi_tuner_freq_get; snd_control.put = snd_asihpi_tuner_freq_put; @@ -2120,7 +2105,7 @@ static int __devinit snd_asihpi_meter_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
- asihpi_ctl_init(&snd_control, hpi_ctl, "meter"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Meter"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_meter_info; @@ -2201,7 +2186,7 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol, } } snd_printd(KERN_WARNING - "control %x failed to match mux source %hu %hu\n", + "Control %x failed to match mux source %hu %hu\n", h_control, source_type, source_index); ucontrol->value.enumerated.item[0] = 0; return 0; @@ -2234,11 +2219,7 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
-#if ASI_STYLE_NAMES - asihpi_ctl_init(&snd_control, hpi_ctl, "multiplexer"); -#else - asihpi_ctl_init(&snd_control, hpi_ctl, "route"); -#endif + asihpi_ctl_init(&snd_control, hpi_ctl, "Route"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_mux_info; snd_control.get = snd_asihpi_mux_get; @@ -2254,33 +2235,38 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi, static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - static char *mode_names[HPI_CHANNEL_MODE_LAST] = { - "normal", "swap", - "from_left", "from_right", - "to_left", "to_right" + static const char * const mode_names[HPI_CHANNEL_MODE_LAST + 1] = { + "invalid", + "Normal", "Swap", + "From Left", "From Right", + "To Left", "To Right" };
u32 h_control = kcontrol->private_value; u16 mode; int i; + u16 mode_map[6]; + int valid_modes = 0;
/* HPI channel mode values can be from 1 to 6 Some adapters only support a contiguous subset */ for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++) - if (hpi_channel_mode_query_mode( - ss, h_control, i, &mode)) - break; + if (!hpi_channel_mode_query_mode( + ss, h_control, i, &mode)) { + mode_map[valid_modes] = mode; + valid_modes++; + }
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; - uinfo->value.enumerated.items = i; + uinfo->value.enumerated.items = valid_modes;
- if (uinfo->value.enumerated.item >= i) - uinfo->value.enumerated.item = i - 1; + if (uinfo->value.enumerated.item >= valid_modes) + uinfo->value.enumerated.item = valid_modes - 1;
strcpy(uinfo->value.enumerated.name, - mode_names[uinfo->value.enumerated.item]); + mode_names[mode_map[uinfo->value.enumerated.item]]);
return 0; } @@ -2319,7 +2305,7 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, struct snd_card *card = asihpi->card; struct snd_kcontrol_new snd_control;
- asihpi_ctl_init(&snd_control, hpi_ctl, "channel mode"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Mode"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; snd_control.info = snd_asihpi_cmode_info; snd_control.get = snd_asihpi_cmode_get; @@ -2331,15 +2317,12 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, /*------------------------------------------------------------ Sampleclock source controls ------------------------------------------------------------*/ - static char *sampleclock_sources[MAX_CLOCKSOURCES] = - { "N/A", "local PLL", "AES/EBU sync", "word external", "word header", - "SMPTE", "AES/EBU in1", "auto", "network", "invalid", - "prev module", - "AES/EBU in2", "AES/EBU in3", "AES/EBU in4", "AES/EBU in5", - "AES/EBU in6", "AES/EBU in7", "AES/EBU in8"}; - - +{ "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header", + "SMPTE", "Digital1", "Auto", "Network", "Invalid", + "Prev Module", + "Digital2", "Digital3", "Digital4", "Digital5", + "Digital6", "Digital7", "Digital8"};
static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -2528,7 +2511,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, } clkcache->count = i;
- asihpi_ctl_init(&snd_control, hpi_ctl, "source"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Source"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; snd_control.info = snd_asihpi_clksrc_info; snd_control.get = snd_asihpi_clksrc_get; @@ -2538,7 +2521,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi,
if (clkcache->has_local) { - asihpi_ctl_init(&snd_control, hpi_ctl, "local_rate"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Localrate"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ; snd_control.info = snd_asihpi_clklocal_info; snd_control.get = snd_asihpi_clklocal_get; @@ -2549,7 +2532,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, return -EINVAL; }
- asihpi_ctl_init(&snd_control, hpi_ctl, "rate"); + asihpi_ctl_init(&snd_control, hpi_ctl, "Rate"); snd_control.access = SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ; snd_control.info = snd_asihpi_clkrate_info; @@ -2571,7 +2554,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi)
if (snd_BUG_ON(!asihpi)) return -EINVAL; - strcpy(card->mixername, "asihpi mixer"); + strcpy(card->mixername, "Asihpi Mixer");
err = hpi_mixer_open(ss, asihpi->adapter_index, @@ -2597,7 +2580,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) if (err == HPI_ERROR_CONTROL_DISABLED) { if (mixer_dump) snd_printk(KERN_INFO - "disabled HPI control(%d)\n", + "Disabled HPI Control(%d)\n", idx); continue; } else @@ -2662,7 +2645,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) default: if (mixer_dump) snd_printk(KERN_INFO - "untranslated HPI control" + "Untranslated HPI Control" "(%d) %d %d %d %d %d\n", idx, hpi_ctl.control_type, @@ -2841,7 +2824,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, if (err < 0) return err; snd_printk(KERN_WARNING - "**** WARNING **** adapter index %d->ALSA index %d\n", + "**** WARNING **** Adapter index %d->ALSA index %d\n", hpi_card->index, card->number); }
@@ -2859,7 +2842,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, version = asihpi->version; snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d " "num_instreams=%d S/N=%d\n" - "hw version %c%d DSP code version %03d\n", + "Hw Version %c%d DSP code version %03d\n", asihpi->type, asihpi->adapter_index, asihpi->num_outstreams, asihpi->num_instreams, asihpi->serial_number,
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6000.c | 3 +++ pci/asihpi/hpi6205.c | 3 +++ pci/asihpi/hpicmn.c | 16 ++++++++++++---- pci/asihpi/hpicmn.h | 3 ++- 4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/pci/asihpi/hpi6000.c b/pci/asihpi/hpi6000.c index c85db49..c486af1 100644 --- a/pci/asihpi/hpi6000.c +++ b/pci/asihpi/hpi6000.c @@ -582,6 +582,9 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, pao->adapter_type, pao->index); pao->open = 0; /* upon creation the adapter is closed */
+ if (phw->p_cache) + phw->p_cache->adap_idx = pao->index; + return hpi_add_adapter(pao); }
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index b740edc..5ebf8f8 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -718,6 +718,9 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
pao->open = 0; /* upon creation the adapter is closed */
+ if (phw->p_cache) + phw->p_cache->adap_idx = pao->index; + HPI_DEBUG_LOG(INFO, "bootload DSP OK\n");
return hpi_add_adapter(pao); diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 793236e..85c2972 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -197,11 +197,18 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) &p_master_cache[byte_count];
if (!info->size_in32bit_words) { + if (i == 0) { + HPI_DEBUG_LOG(INFO, + "adap %d cache not ready?\n", + pC->adap_idx); + return 0; + } /* ? This is a severe error, the cache is probably corrupted. Minimum valid entry size is sizeof(struct hpi_control_cache_info) */ HPI_DEBUG_LOG(ERROR, - "zero size cache entry %d\n", i); + "adap %d zero size cache entry %d\n", + pC->adap_idx, i); break; }
@@ -231,12 +238,13 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
if (byte_count != pC->cache_size_in_bytes) HPI_DEBUG_LOG(WARNING, - "bytecount %d != cache size %d", byte_count, + "adap %d bytecount %d != cache size %d", + pC->adap_idx, byte_count, pC->cache_size_in_bytes); else HPI_DEBUG_LOG(DEBUG, - "cache good. bytecount == cache size = %d", - byte_count); + "adap %d cache good, bytecount == cache size = %d", + pC->adap_idx, byte_count);
pC->init = cached; } diff --git a/pci/asihpi/hpicmn.h b/pci/asihpi/hpicmn.h index e2f6f1f..2708c4d 100644 --- a/pci/asihpi/hpicmn.h +++ b/pci/asihpi/hpicmn.h @@ -33,8 +33,9 @@ struct hpi_adapter_obj { };
struct hpi_control_cache { - u32 init; /**< indicates whether the + u16 init; /**< indicates whether the structures are initialized */ + u16 adap_idx; u32 control_count; u32 cache_size_in_bytes; struct hpi_control_cache_info
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpimsginit.h | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/pci/asihpi/hpimsginit.h b/pci/asihpi/hpimsginit.h index 864ad02..bfd330d 100644 --- a/pci/asihpi/hpimsginit.h +++ b/pci/asihpi/hpimsginit.h @@ -21,11 +21,15 @@ (C) Copyright AudioScience Inc. 2007 *******************************************************************************/ /* Initialise response headers, or msg/response pairs. -Note that it is valid to just init a response e.g. when a lower level is preparing -a response to a message. -However, when sending a message, a matching response buffer always must be prepared +Note that it is valid to just init a response e.g. when a lower level is +preparing a response to a message. +However, when sending a message, a matching response buffer must always be +prepared. */
+#ifndef _HPIMSGINIT_H_ +#define _HPIMSGINIT_H_ + void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, u16 error);
@@ -38,3 +42,5 @@ void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size, struct hpi_response_header *phr, u16 res_size, u16 object, u16 function); + +#endif /* _HPIMSGINIT_H_ */
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6000.c | 3 ++- pci/asihpi/hpicmn.c | 31 +++++++++++++++++-------------- pci/asihpi/hpidebug.c | 2 +- pci/asihpi/hpidebug.h | 8 ++++---- 4 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/pci/asihpi/hpi6000.c b/pci/asihpi/hpi6000.c index c486af1..4346583 100644 --- a/pci/asihpi/hpi6000.c +++ b/pci/asihpi/hpi6000.c @@ -43,7 +43,8 @@ #define HPI_HIF_ERROR_MASK 0x4000
/* HPI6000 specific error codes */ -#define HPI6000_ERROR_BASE 900 /* not actually used anywhere */ +#define HPI6000_ERROR_BASE 900 /* not actually used anywhere */ + /* operational/messaging errors */ #define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 85c2972..8346aea 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -46,17 +46,19 @@ static struct hpi_adapters_list adapters; u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) { if (phr->type != HPI_TYPE_RESPONSE) { - HPI_DEBUG_LOG(ERROR, "header type %d invalid", phr->type); + HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", phr->type); return HPI_ERROR_INVALID_RESPONSE; }
if (phr->object != phm->object) { - HPI_DEBUG_LOG(ERROR, "header object %d invalid", phr->object); + HPI_DEBUG_LOG(ERROR, "header object %d invalid\n", + phr->object); return HPI_ERROR_INVALID_RESPONSE; }
if (phr->function != phm->function) { - HPI_DEBUG_LOG(ERROR, "header type %d invalid", phr->function); + HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", + phr->function); return HPI_ERROR_INVALID_RESPONSE; }
@@ -114,7 +116,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) struct hpi_adapter_obj *pao = NULL;
if (adapter_index >= HPI_MAX_ADAPTERS) { - HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d ", + HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d\n", adapter_index); return NULL; } @@ -203,9 +205,10 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) pC->adap_idx); return 0; } - /* ? This is a severe error, the cache is probably - corrupted. Minimum valid entry size is - sizeof(struct hpi_control_cache_info) */ + /* The cache is invalid. + * Minimum valid entry size is + * sizeof(struct hpi_control_cache_info) + */ HPI_DEBUG_LOG(ERROR, "adap %d zero size cache entry %d\n", pC->adap_idx, i); @@ -226,9 +229,10 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) info->control_index, info->control_type, info->size_in32bit_words);
- /* quit loop early if whole cache has been scanned. */ - /* pC->dwControlCount is the maximum possible entries, */ - /* but some may not be in the cache at all */ + /* quit loop early if whole cache has been scanned. + * dwControlCount is the maximum possible entries + * but some may be absent from the cache + */ if (byte_count >= pC->cache_size_in_bytes) break; /* have seen last control index */ @@ -238,15 +242,15 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
if (byte_count != pC->cache_size_in_bytes) HPI_DEBUG_LOG(WARNING, - "adap %d bytecount %d != cache size %d", + "adap %d bytecount %d != cache size %d\n", pC->adap_idx, byte_count, pC->cache_size_in_bytes); else HPI_DEBUG_LOG(DEBUG, - "adap %d cache good, bytecount == cache size = %d", + "adap %d cache good, bytecount == cache size = %d\n", pC->adap_idx, byte_count);
- pC->init = cached; + pC->init = (u16)cached; } return pC->init; } @@ -430,7 +434,6 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, case HPI_CONTROL_SILENCEDETECTOR: if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) { phr->u.c.param1 = pC->u.silence.state; - /*? phr->u.c.dwParam2 = pC->u.silence.dwCount; */ } else found = 0; break; diff --git a/pci/asihpi/hpidebug.c b/pci/asihpi/hpidebug.c index 4b81c80..b52baf6 100644 --- a/pci/asihpi/hpidebug.c +++ b/pci/asihpi/hpidebug.c @@ -48,7 +48,7 @@ int hpi_debug_level_get(void) void hpi_debug_message(struct hpi_message *phm, char *sz_fileline) { if (phm) { - printk("HPI_MSG%d,%d,%d,%d,%d\n", phm->version, + printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version, phm->adapter_index, phm->obj_index, phm->function, phm->u.c.attribute); } diff --git a/pci/asihpi/hpidebug.h b/pci/asihpi/hpidebug.h index 632d7d0..940f54c 100644 --- a/pci/asihpi/hpidebug.h +++ b/pci/asihpi/hpidebug.h @@ -80,17 +80,17 @@ void hpi_debug_data(u16 *pdata, u32 len); #define HPI_DEBUG_MESSAGE(level, phm) \ do { \ if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \ - hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \ + hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \ FILE_LINE __stringify(level)); \ } \ } while (0)
#define HPI_DEBUG_RESPONSE(phr) \ do { \ - if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error)) ||\ + if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && \ + (phr->error)) ||\ (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)) \ - printk(KERN_DEBUG\ - "HPI_RES%d,%d,%d\n", \ + printk(KERN_DEBUG "HPI_RES%d,%d,%d\n", \ phr->version, phr->error, phr->specific_error); \ } while (0)
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Some error codes had duplicate meanings. Just use one.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6205.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index 5ebf8f8..a3f650d 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -38,7 +38,7 @@
/*****************************************************************************/ /* HPI6205 specific error codes */ -#define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */ +#define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */
/* operational/messaging errors */ #define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015 @@ -293,7 +293,7 @@ static void outstream_message(struct hpi_adapter_obj *pao, {
if (phm->obj_index >= HPI_MAX_STREAMS) { - phr->error = HPI_ERROR_INVALID_STREAM; + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; HPI_DEBUG_LOG(WARNING, "Message referencing invalid stream %d " "on adapter index %d\n", phm->obj_index, @@ -337,7 +337,7 @@ static void instream_message(struct hpi_adapter_obj *pao, {
if (phm->obj_index >= HPI_MAX_STREAMS) { - phr->error = HPI_ERROR_INVALID_STREAM; + phr->error = HPI_ERROR_INVALID_OBJ_INDEX; HPI_DEBUG_LOG(WARNING, "Message referencing invalid stream %d " "on adapter index %d\n", phm->obj_index, @@ -864,6 +864,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, status->dSP_index = 0; status->host_index = status->dSP_index; status->size_in_bytes = phm->u.d.u.buffer.buffer_size; + status->auxiliary_data_available = 0;
hw_message(pao, phm, phr);
@@ -995,8 +996,8 @@ static void outstream_write(struct hpi_adapter_obj *pao, /* * This version relies on the DSP code triggering an OStream buffer * update immediately following a SET_FORMAT call. The host has - * already written data into the BBM buffer, but the DSP won't know about - * it until dwHostIndex is adjusted. + * already written data into the BBM buffer, but the DSP won't know + * about it until dwHostIndex is adjusted. */ if (phw->flag_outstream_just_reset[phm->obj_index]) { /* Format can only change after reset. Must tell DSP. */ @@ -1140,6 +1141,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, status->dSP_index = 0; status->host_index = status->dSP_index; status->size_in_bytes = phm->u.d.u.buffer.buffer_size; + status->auxiliary_data_available = 0;
hw_message(pao, phm, phr); if (phr->error @@ -1982,7 +1984,7 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, struct bus_master_interface *interface = phw->p_interface_buffer;
if (!p_data) - return HPI_ERROR_INVALID_DATA_TRANSFER; + return HPI_ERROR_INVALID_DATA_POINTER;
data_size &= ~3L; /* round data_size down to nearest 4 bytes */
@@ -2122,8 +2124,7 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
message_count++; if (phm->size > sizeof(interface->u)) { - /* really MESSAGE buffer too small */ - phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; + phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; phr->specific_error = sizeof(interface->u); phr->size = sizeof(struct hpi_response_header); HPI_DEBUG_LOG(ERROR,
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Create and use HPI_ERROR_DSP_COMMUNICATION _DSP_BOOTLOAD, rather than backend-specific error codes (now returned as data with the error).
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 43 +++++++++++++++++++------------------ pci/asihpi/hpi6000.c | 58 ++++++++++++++++++++++++++++++++----------------- pci/asihpi/hpi6205.c | 15 +++++++++++- 3 files changed, 73 insertions(+), 43 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index efed0c1..212a016 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -43,8 +43,8 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
/* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 17) -#define HPI_VER_STRING "4.05.17" +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 19) +#define HPI_VER_STRING "4.05.19"
/* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) @@ -433,11 +433,14 @@ return true.
/** Adapter mode commands
-Used in wQueryOrSet field of HPI_AdapterSetModeEx(). +Used in wQueryOrSet parameter of HPI_AdapterSetModeEx(). \ingroup adapter */ enum HPI_ADAPTER_MODE_CMDS { + /** Set the mode to the given parameter */ HPI_ADAPTER_MODE_SET = 0, + /** Return 0 or error depending whether mode is valid, + but don't set the mode */ HPI_ADAPTER_MODE_QUERY = 1 };
@@ -874,8 +877,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_OBJ_ALREADY_OPEN = 105, /** PCI, ISA resource not valid. */ HPI_ERROR_INVALID_RESOURCE = 106, - /* GetInfo call from SubSysFindAdapters failed. */ - /*HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107, */ + /* HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107 */ /** Default response was never updated with actual error code. */ HPI_ERROR_INVALID_RESPONSE = 108, /** wSize field of response was not updated, @@ -905,8 +907,7 @@ enum HPI_ERROR_CODES { */ HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL = 117,
- /* Too many adapters. */ - /* HPI_ERROR_TOO_MANY_ADAPTERS= 200, */ + /* HPI_ERROR_TOO_MANY_ADAPTERS= 200 */ /** Bad adpater. */ HPI_ERROR_BAD_ADAPTER = 201, /** Adapter number out of range or not set properly. */ @@ -915,15 +916,15 @@ enum HPI_ERROR_CODES { HPI_DUPLICATE_ADAPTER_NUMBER = 203, /** DSP code failed to bootload. (unused?) */ HPI_ERROR_DSP_BOOTLOAD = 204, - /** Adapter failed DSP code self test. (unused?) */ - HPI_ERROR_DSP_SELFTEST = 205, + /** Communication with DSP failed */ + HPI_ERROR_DSP_COMMUNICATION = 205, /** Couldn't find or open the DSP code file. */ HPI_ERROR_DSP_FILE_NOT_FOUND = 206, /** Internal DSP hardware error. */ HPI_ERROR_DSP_HARDWARE = 207, /** Could not allocate memory */ HPI_ERROR_MEMORY_ALLOC = 208, - /** Failed to correctly load/config PLD. (unused?) */ + /** Failed to correctly load/config PLD. (unused) */ HPI_ERROR_PLD_LOAD = 209, /** Unexpected end of file, block length too big etc. */ HPI_ERROR_DSP_FILE_FORMAT = 210, @@ -932,8 +933,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211, /** First DSP code section header not found in DSP file. */ HPI_ERROR_DSP_FILE_NO_HEADER = 212, - /* File read operation on DSP code file failed. */ - /*HPI_ERROR_DSP_FILE_READ_ERROR= 213, */ + /* HPI_ERROR_DSP_FILE_READ_ERROR= 213, */ /** DSP code for adapter family not found. */ HPI_ERROR_DSP_SECTION_NOT_FOUND = 214, /** Other OS specific error opening DSP file. */ @@ -943,8 +943,7 @@ enum HPI_ERROR_CODES { /** DSP code section header had size == 0. */ HPI_ERROR_DSP_FILE_NULL_HEADER = 217,
- /* Base number for flash errors. */ - /* HPI_ERROR_FLASH = 220, */ + /* HPI_ERROR_FLASH = 220, */
/** Flash has bad checksum */ HPI_ERROR_BAD_CHECKSUM = 221, @@ -958,8 +957,8 @@ enum HPI_ERROR_CODES { /** Reserved for OEMs. */ HPI_ERROR_RESERVED_1 = 290,
- /* Stream does not exist. */ - /*HPI_ERROR_INVALID_STREAM= 300, // use HPI_ERROR_INVALID_OBJ_INDEX */ + /* HPI_ERROR_INVALID_STREAM = 300, + use HPI_ERROR_INVALID_OBJ_INDEX */ /** Invalid compression format. */ HPI_ERROR_INVALID_FORMAT = 301, /** Invalid format samplerate */ @@ -970,10 +969,12 @@ enum HPI_ERROR_CODES { HPI_ERROR_INVALID_BITRATE = 304, /** Invalid datasize used for stream read/write. */ HPI_ERROR_INVALID_DATASIZE = 305, - /* Stream buffer is full during stream write. */ - /*HPI_ERROR_BUFFER_FULL = 306, // USE HPI_ERROR_INVALID_DATASIZE */ - /* Stream buffer is empty during stream read. */ - /*HPI_ERROR_BUFFER_EMPTY = 307, // USE HPI_ERROR_INVALID_DATASIZE */ + /* Stream buffer is full during stream write. + HPI_ERROR_BUFFER_FULL = 306, + Stream buffer is empty during stream read. + HPI_ERROR_BUFFER_EMPTY = 307, + Use HPI_ERROR_INVALID_DATASIZE + */ /** Null data pointer used for stream read/write. */ HPI_ERROR_INVALID_DATA_POINTER = 308, /** Packet ordering error for stream read/write. */ @@ -1010,6 +1011,7 @@ enum HPI_ERROR_CODES { HPI_ERROR_CONTROL_DISABLED = 404, /** I2C transaction failed due to a missing ACK. */ HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, + HPI_ERROR_I2C_MISSING_ACK = 405, /** Control is busy, or coming out of reset and cannot be accessed at this time. */ HPI_ERROR_CONTROL_NOT_READY = 407, @@ -1020,7 +1022,6 @@ enum HPI_ERROR_CODES { HPI_ERROR_NVMEM_FAIL = 452,
/** I2C */ - HPI_ERROR_I2C_MISSING_ACK = 405, /*HPI_ERROR_CONTROL_I2C_MISSING_ACK */ HPI_ERROR_I2C_BAD_ADR = 460,
/** Entity errors */ diff --git a/pci/asihpi/hpi6000.c b/pci/asihpi/hpi6000.c index 4346583..9a05672 100644 --- a/pci/asihpi/hpi6000.c +++ b/pci/asihpi/hpi6000.c @@ -237,10 +237,19 @@ static void control_message(struct hpi_adapter_obj *pao, switch (phm->function) { case HPI_CONTROL_GET_STATE: if (pao->has_control_cache) { - phr->error = hpi6000_update_control_cache(pao, phm); - - if (phr->error) + u16 err; + err = hpi6000_update_control_cache(pao, phm); + + if (err) { + if (err >= HPI_ERROR_BACKEND_BASE) { + phr->error = + HPI_ERROR_CONTROL_CACHING; + phr->specific_error = err; + } else { + phr->error = err; + } break; + }
if (hpi_check_control_cache(((struct hpi_hw_obj *) pao->priv)->p_cache, phm, @@ -405,7 +414,7 @@ static void subsys_create_adapter(struct hpi_message *phm, struct hpi_adapter_obj ao; struct hpi_adapter_obj *pao; u32 os_error_code; - short error = 0; + u16 err = 0; u32 dsp_index = 0;
HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n"); @@ -422,10 +431,16 @@ static void subsys_create_adapter(struct hpi_message *phm, /* create the adapter object based on the resource information */ ao.pci = *phm->u.s.resource.r.pci;
- error = create_adapter_obj(&ao, &os_error_code); - if (error) { + err = create_adapter_obj(&ao, &os_error_code); + if (err) { delete_adapter_obj(&ao); - phr->error = error; + if (err >= HPI_ERROR_BACKEND_BASE) { + phr->error = HPI_ERROR_DSP_BOOTLOAD; + phr->specific_error = err; + } else { + phr->error = err; + } + phr->u.s.data = os_error_code; return; } @@ -434,7 +449,7 @@ static void subsys_create_adapter(struct hpi_message *phm, if (!pao) { /* We just added this adapter, why can't we find it!? */ HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n"); - phr->error = 950; + phr->error = HPI_ERROR_BAD_ADAPTER; return; }
@@ -1763,17 +1778,11 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, hpios_dsplock_lock(pao); error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr);
- /* maybe an error response */ - if (error) { - /* something failed in the HPI/DSP interface */ - phr->error = error; - /* just the header of the response is valid */ - phr->size = sizeof(struct hpi_response_header); + if (error) /* something failed in the HPI/DSP interface */ goto err; - }
- if (phr->error != 0) /* something failed in the DSP */ - goto err; + if (phr->error) /* something failed in the DSP */ + goto out;
switch (phm->function) { case HPI_OSTREAM_WRITE: @@ -1796,10 +1805,19 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, } }
- if (error) - phr->error = error; - err: + if (error) { + if (error >= HPI_ERROR_BACKEND_BASE) { + phr->error = HPI_ERROR_DSP_COMMUNICATION; + phr->specific_error = error; + } else { + phr->error = error; + } + + /* just the header of the response is valid */ + phr->size = sizeof(struct hpi_response_header); + } +out: hpios_dsplock_unlock(pao); return; } diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index a3f650d..5fe535b 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -478,7 +478,12 @@ static void subsys_create_adapter(struct hpi_message *phm, err = create_adapter_obj(&ao, &os_error_code); if (err) { delete_adapter_obj(&ao); - phr->error = err; + if (err >= HPI_ERROR_BACKEND_BASE) { + phr->error = HPI_ERROR_DSP_BOOTLOAD; + phr->specific_error = err; + } else { + phr->error = err; + } phr->u.s.data = os_error_code; return; } @@ -2242,7 +2247,13 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, /* maybe an error response */ if (err) { /* something failed in the HPI/DSP interface */ - phr->error = err; + if (err >= HPI_ERROR_BACKEND_BASE) { + phr->error = HPI_ERROR_DSP_COMMUNICATION; + phr->specific_error = err; + } else { + phr->error = err; + } + pao->dsp_crashed++;
/* just the header of the response is valid */
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Remove unused function. Simplify hpi_alloc_control_cache. Remove useless assignment to struct subsequently freed.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpicmn.c | 42 +++++++++--------------------------------- pci/asihpi/hpicmn.h | 15 +++++++-------- 2 files changed, 16 insertions(+), 41 deletions(-)
diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 8346aea..4d696ab 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -156,7 +156,7 @@ static void subsys_get_adapter(struct hpi_message *phm, /* find the nCount'th nonzero adapter in array */ for (index = 0; index < HPI_MAX_ADAPTERS; index++) { if (adapters.adapter[index].adapter_type) { - if (count == 0) + if (!count) break; count--; } @@ -199,7 +199,7 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) &p_master_cache[byte_count];
if (!info->size_in32bit_words) { - if (i == 0) { + if (!i) { HPI_DEBUG_LOG(INFO, "adap %d cache not ready?\n", pC->adap_idx); @@ -279,28 +279,6 @@ static short find_control(u16 control_index, return 1; }
-/** Used by the kernel driver to figure out if a buffer needs mapping. - */ -short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, - struct hpi_message *phm, void **p, unsigned int *pN) -{ - *pN = 0; - *p = NULL; - if ((phm->function == HPI_CONTROL_GET_STATE) - && (phm->object == HPI_OBJ_CONTROLEX) - ) { - struct hpi_control_cache_info *pI; - - if (!find_control(phm->obj_index, p_cache, &pI)) { - HPI_DEBUG_LOG(VERBOSE, - "HPICMN find_control() failed for adap %d\n", - phm->adapter_index); - return 0; - } - } - return 0; -} - /* allow unified treatment of several string fields within struct */ #define HPICMN_PAD_OFS_AND_SIZE(m) {\ offsetof(struct hpi_control_cache_pad, m), \ @@ -612,24 +590,24 @@ void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache, } }
-struct hpi_control_cache *hpi_alloc_control_cache(const u32 - number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer) +struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count, + const u32 size_in_bytes, u8 *p_dsp_control_buffer) { struct hpi_control_cache *p_cache = kmalloc(sizeof(*p_cache), GFP_KERNEL); if (!p_cache) return NULL; + p_cache->p_info = - kmalloc(sizeof(*p_cache->p_info) * number_of_controls, - GFP_KERNEL); + kmalloc(sizeof(*p_cache->p_info) * control_count, GFP_KERNEL); if (!p_cache->p_info) { kfree(p_cache); return NULL; } + memset(p_cache->p_info, 0, sizeof(*p_cache->p_info) * control_count); p_cache->cache_size_in_bytes = size_in_bytes; - p_cache->control_count = number_of_controls; - p_cache->p_cache = - (struct hpi_control_cache_single *)pDSP_control_buffer; + p_cache->control_count = control_count; + p_cache->p_cache = p_dsp_control_buffer; p_cache->init = 0; return p_cache; } @@ -638,8 +616,6 @@ void hpi_free_control_cache(struct hpi_control_cache *p_cache) { if (p_cache) { kfree(p_cache->p_info); - p_cache->p_info = NULL; - p_cache->init = 0; kfree(p_cache); } } diff --git a/pci/asihpi/hpicmn.h b/pci/asihpi/hpicmn.h index 2708c4d..6db1e0b 100644 --- a/pci/asihpi/hpicmn.h +++ b/pci/asihpi/hpicmn.h @@ -33,15 +33,15 @@ struct hpi_adapter_obj { };
struct hpi_control_cache { - u16 init; /**< indicates whether the - structures are initialized */ + /** indicates whether the structures are initialized */ + u16 init; u16 adap_idx; u32 control_count; u32 cache_size_in_bytes; - struct hpi_control_cache_info - **p_info; /**< pointer to allocated memory of - lookup pointers. */ - u8 *p_cache; /**< pointer to DSP's control cache. */ + /** pointer to allocated memory of lookup pointers. */ + struct hpi_control_cache_info **p_info; + /** pointer to DSP's control cache. */ + u8 *p_cache; };
struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); @@ -57,6 +57,5 @@ void hpi_free_control_cache(struct hpi_control_cache *p_cache);
void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC, struct hpi_message *phm, struct hpi_response *phr); + u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr); -short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache, - struct hpi_message *phm, void **p, unsigned int *pN);
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Interrupt flag used for message handshake will be required for stream interrupts, so conditionally compiled code without HPI6205_NO_HSR_POLL defined can never be used; removing it.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6205.c | 101 -------------------------------------------------- pci/asihpi/hpi6205.h | 3 - 2 files changed, 0 insertions(+), 104 deletions(-)
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index 5fe535b..cbf79a9 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -527,10 +527,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, struct hpi_hw_obj *phw = pao->priv; struct bus_master_interface *interface; u32 phys_addr; -#ifndef HPI6205_NO_HSR_POLL - u32 time_out = HPI6205_TIMEOUT; - u32 temp1; -#endif int i; u16 err;
@@ -584,27 +580,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao,
interface = phw->p_interface_buffer;
-#ifndef HPI6205_NO_HSR_POLL - /* wait for first interrupt indicating the DSP init is done */ - time_out = HPI6205_TIMEOUT * 10; - temp1 = 0; - while (((temp1 & C6205_HSR_INTSRC) == 0) && --time_out) - temp1 = ioread32(phw->prHSR); - - if (temp1 & C6205_HSR_INTSRC) - HPI_DEBUG_LOG(INFO, - "Interrupt confirming DSP code running OK\n"); - else { - HPI_DEBUG_LOG(ERROR, - "Timed out waiting for interrupt " - "confirming DSP code running\n"); - return HPI6205_ERROR_6205_NO_IRQ; - } - - /* reset the interrupt */ - iowrite32(C6205_HSR_INTSRC, phw->prHSR); -#endif - /* make sure the DSP has started ok */ if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); @@ -1982,9 +1957,6 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, struct hpi_hw_obj *phw = pao->priv; u32 data_transferred = 0; u16 err = 0; -#ifndef HPI6205_NO_HSR_POLL - u32 time_out; -#endif u32 temp2; struct bus_master_interface *interface = phw->p_interface_buffer;
@@ -2009,14 +1981,10 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
interface->transfer_size_in_bytes = this_copy;
-#ifdef HPI6205_NO_HSR_POLL /* DSP must change this back to nOperation */ interface->dsp_ack = H620_HIF_IDLE; -#endif - send_dsp_command(phw, operation);
-#ifdef HPI6205_NO_HSR_POLL temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT); HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", HPI6205_TIMEOUT - temp2, this_copy); @@ -2029,40 +1997,6 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data,
break; } -#else - /* spin waiting on the result */ - time_out = HPI6205_TIMEOUT; - temp2 = 0; - while ((temp2 == 0) && time_out--) { - /* give 16k bus mastering transfer time to happen */ - /*(16k / 132Mbytes/s = 122usec) */ - hpios_delay_micro_seconds(20); - temp2 = ioread32(phw->prHSR); - temp2 &= C6205_HSR_INTSRC; - } - HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", - HPI6205_TIMEOUT - time_out, this_copy); - if (temp2 == C6205_HSR_INTSRC) { - HPI_DEBUG_LOG(VERBOSE, - "Interrupt from HIF <data> OK\n"); - /* - if(interface->dwDspAck != nOperation) { - HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d, - expected %d \n", - interface->dwDspAck,nOperation); - } - */ - } -/* need to handle this differently... */ - else { - HPI_DEBUG_LOG(ERROR, - "Interrupt from HIF <data> BAD\n"); - err = HPI_ERROR_DSP_HARDWARE; - } - - /* reset the interrupt from the DSP */ - iowrite32(C6205_HSR_INTSRC, phw->prHSR); -#endif if (operation == H620_HIF_GET_DATA) memcpy(&p_data[data_transferred], (void *)&interface->u.b_data[0], this_copy); @@ -2119,9 +2053,6 @@ static unsigned int message_count; static u16 message_response_sequence(struct hpi_adapter_obj *pao, struct hpi_message *phm, struct hpi_response *phr) { -#ifndef HPI6205_NO_HSR_POLL - u32 temp2; -#endif u32 time_out, time_out2; struct hpi_hw_obj *phw = pao->priv; struct bus_master_interface *interface = phw->p_interface_buffer; @@ -2164,38 +2095,6 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao, /* spin waiting on HIF interrupt flag (end of msg process) */ time_out = HPI6205_TIMEOUT;
-#ifndef HPI6205_NO_HSR_POLL - temp2 = 0; - while ((temp2 == 0) && --time_out) { - temp2 = ioread32(phw->prHSR); - temp2 &= C6205_HSR_INTSRC; - hpios_delay_micro_seconds(1); - } - if (temp2 == C6205_HSR_INTSRC) { - rmb(); /* ensure we see latest value for dsp_ack */ - if ((interface->dsp_ack != H620_HIF_GET_RESP)) { - HPI_DEBUG_LOG(DEBUG, - "(%u)interface->dsp_ack(0x%x) != " - "H620_HIF_GET_RESP, t=%u\n", message_count, - interface->dsp_ack, - HPI6205_TIMEOUT - time_out); - } else { - HPI_DEBUG_LOG(VERBOSE, - "(%u)int with GET_RESP after %u\n", - message_count, HPI6205_TIMEOUT - time_out); - } - - } else { - /* can we do anything else in response to the error ? */ - HPI_DEBUG_LOG(ERROR, - "Interrupt from HIF module BAD (function %x)\n", - phm->function); - } - - /* reset the interrupt from the DSP */ - iowrite32(C6205_HSR_INTSRC, phw->prHSR); -#endif - /* read the result */ if (time_out) { if (interface->u.response_buffer.size <= phr->size) diff --git a/pci/asihpi/hpi6205.h b/pci/asihpi/hpi6205.h index e00edb0..df2f02c 100644 --- a/pci/asihpi/hpi6205.h +++ b/pci/asihpi/hpi6205.h @@ -25,9 +25,6 @@ Copyright AudioScience, Inc., 2003 #ifndef _HPI6205_H_ #define _HPI6205_H_
-/* transitional conditional compile shared between host and DSP */ -/* #define HPI6205_NO_HSR_POLL */ - #include "hpi_internal.h"
/***********************************************************
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 23 +++++++---------- pci/asihpi/hpi6205.c | 59 ++++++++++++++++++++++++++++++++++++++++++++- pci/asihpi/hpi_internal.h | 17 +++++++----- pci/asihpi/hpicmn.h | 1 + pci/asihpi/hpidspcd.h | 2 +- pci/asihpi/hpimsgx.c | 2 +- 6 files changed, 80 insertions(+), 24 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index 212a016..bef90d4 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -957,8 +957,7 @@ enum HPI_ERROR_CODES { /** Reserved for OEMs. */ HPI_ERROR_RESERVED_1 = 290,
- /* HPI_ERROR_INVALID_STREAM = 300, - use HPI_ERROR_INVALID_OBJ_INDEX */ + /* HPI_ERROR_INVALID_STREAM = 300 use HPI_ERROR_INVALID_OBJ_INDEX */ /** Invalid compression format. */ HPI_ERROR_INVALID_FORMAT = 301, /** Invalid format samplerate */ @@ -969,12 +968,8 @@ enum HPI_ERROR_CODES { HPI_ERROR_INVALID_BITRATE = 304, /** Invalid datasize used for stream read/write. */ HPI_ERROR_INVALID_DATASIZE = 305, - /* Stream buffer is full during stream write. - HPI_ERROR_BUFFER_FULL = 306, - Stream buffer is empty during stream read. - HPI_ERROR_BUFFER_EMPTY = 307, - Use HPI_ERROR_INVALID_DATASIZE - */ + /* HPI_ERROR_BUFFER_FULL = 306 use HPI_ERROR_INVALID_DATASIZE */ + /* HPI_ERROR_BUFFER_EMPTY = 307 use HPI_ERROR_INVALID_DATASIZE */ /** Null data pointer used for stream read/write. */ HPI_ERROR_INVALID_DATA_POINTER = 308, /** Packet ordering error for stream read/write. */ @@ -1098,16 +1093,16 @@ struct hpi_anc_frame { */ struct hpi_async_event { u16 event_type; /**< type of event. \sa async_event */ - u16 sequence; /**< Sequence number, allows lost event detection */ - u32 state; /**< New state */ - u32 h_object; /**< handle to the object returning the event. */ + u16 sequence; /**< Sequence number, allows lost event detection */ + u32 state; /**< New state */ + u32 h_object; /**< handle to the object returning the event. */ union { struct { u16 index; /**< GPIO bit index. */ } gpio; struct { u16 node_index; /**< what node is the control on ? */ - u16 node_type; /**< what type of node is the control on ? */ + u16 node_type; /**< what type of node is the control on ? */ } control; } u; }; @@ -1635,8 +1630,8 @@ u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address);
u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address);
-u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *pmAC_MS_bs, - u32 *pmAC_LS_bs); +u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs, + u32 *p_mac_lsbs);
/*************************/ /* Tone Detector control */ diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index cbf79a9..eefe459 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -752,6 +752,9 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao) }
/*****************************************************************************/ +/* Adapter functions */ + +/*****************************************************************************/ /* OutStream Host buffer functions */
/** Allocate or attach buffer for busmastering @@ -1781,12 +1784,66 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) BAR1 via BootLoader_WriteMem32) */ boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL, 0x000034A8); + + /* EMIF CE0 setup - 2Mx32 Sync DRAM + 31..28 Wr setup + 27..22 Wr strobe + 21..20 Wr hold + 19..16 Rd setup + 15..14 - + 13..8 Rd strobe + 7..4 MTYPE 0011 Sync DRAM 32bits + 3 Wr hold MSB + 2..0 Rd hold + */ boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0, 0x00000030); + + /* EMIF SDRAM Extension + 0x00 + 31-21 0000b 0000b 000b + 20 WR2RD = 2cycles-1 = 1b + + 19-18 WR2DEAC = 3cycle-1 = 10b + 17 WR2WR = 2cycle-1 = 1b + 16-15 R2WDQM = 4cycle-1 = 11b + 14-12 RD2WR = 6cycles-1 = 101b + + 11-10 RD2DEAC = 4cycle-1 = 11b + 9 RD2RD = 2cycle-1 = 1b + 8-7 THZP = 3cycle-1 = 10b + 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns) + 4 TRRD = 2cycle = 0b (tRRD = 14ns) + 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns) + 1 CAS latency = 3cyc = 1b + (for Micron 2M32-7 operating at 100MHz) + */ boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT, 0x001BDF29); + + /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank) + 31 - 0b - + 30 SDBSZ 1b 4 bank + 29..28 SDRSZ 00b 11 row address pins + + 27..26 SDCSZ 01b 8 column address pins + 25 RFEN 1b refersh enabled + 24 INIT 1b init SDRAM! + + 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1 + + 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1 + + 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6 + + 11..0 - 0000b 0000b 0000b + */ boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL, - 0x47117000); + 0x47116000); + + /* SDRAM refresh timing + Need 4,096 refresh cycles every 64ms = 15.625us = 1562cycles of 100MHz = 0x61A + */ boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMTIMING, 0x00000410);
diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index a99aa9a..9f003a4 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -553,12 +553,10 @@ struct hpi_resource { /** Format info used inside struct hpi_message Not the same as public API struct hpi_format */ struct hpi_msg_format { - u32 sample_rate; - /**< 11025, 32000, 44100 ... */ - u32 bit_rate; /**< for MPEG */ - u32 attributes; - /**< Stereo/JointStereo/Mono */ - u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ + u32 sample_rate; /**< 11025, 32000, 44100 etc. */ + u32 bit_rate; /**< for MPEG */ + u32 attributes; /**< stereo/joint_stereo/mono */ + u16 channels; /**< 1,2..., (or ancillary mode or idle bit */ u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */ };
@@ -593,7 +591,7 @@ struct hpi_data_compat32 { struct hpi_buffer { /** placehoder for backward compatability (see dwBufferSize) */ struct hpi_msg_format reserved; - u32 command; /**< HPI_BUFFER_CMD_xxx*/ + u32 command; /**< HPI_BUFFER_CMD_xxx*/ u32 pci_address; /**< PCI physical address of buffer for DSP DMA */ u32 buffer_size; /**< must line up with data_size of HPI_DATA*/ }; @@ -1125,6 +1123,11 @@ struct hpi_message { sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \ }
+/* +Note that the wSpecificError error field should be inspected and potentially +reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is +returned in wError. +*/ struct hpi_response_header { u16 size; u8 type; /* HPI_TYPE_RESPONSE */ diff --git a/pci/asihpi/hpicmn.h b/pci/asihpi/hpicmn.h index 6db1e0b..590f0b6 100644 --- a/pci/asihpi/hpicmn.h +++ b/pci/asihpi/hpicmn.h @@ -45,6 +45,7 @@ struct hpi_control_cache { };
struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index); + u16 hpi_add_adapter(struct hpi_adapter_obj *pao);
void hpi_delete_adapter(struct hpi_adapter_obj *pao); diff --git a/pci/asihpi/hpidspcd.h b/pci/asihpi/hpidspcd.h index d7c2403..65f0ca7 100644 --- a/pci/asihpi/hpidspcd.h +++ b/pci/asihpi/hpidspcd.h @@ -87,7 +87,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code); */ short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, /**< DSP code descriptor */ - u32 *pword /**< where to store the read word */ + u32 *pword /**< Where to store the read word */ );
/** Get a block of dsp code into an internal buffer, and provide a pointer to diff --git a/pci/asihpi/hpimsgx.c b/pci/asihpi/hpimsgx.c index b4e7d9a..bcbdf30 100644 --- a/pci/asihpi/hpimsgx.c +++ b/pci/asihpi/hpimsgx.c @@ -230,7 +230,7 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
break; default: - /* Must explicitly send subsys messages to individual backends */ + /* Must explicitly handle every subsys message in this switch */ hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function, HPI_ERROR_INVALID_FUNC); break;
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6000.c | 3 +-- pci/asihpi/hpi6205.c | 3 +-- pci/asihpi/hpi_internal.h | 7 ++++--- pci/asihpi/hpicmn.c | 5 ++--- pci/asihpi/hpifunc.c | 3 ++- pci/asihpi/hpioctl.c | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/pci/asihpi/hpi6000.c b/pci/asihpi/hpi6000.c index 9a05672..3e3c2ef 100644 --- a/pci/asihpi/hpi6000.c +++ b/pci/asihpi/hpi6000.c @@ -458,9 +458,8 @@ static void subsys_create_adapter(struct hpi_message *phm, phw->ado[dsp_index].pa_parent_adapter = pao; }
- phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; + phr->u.s.adapter_type = ao.adapter_type; phr->u.s.adapter_index = ao.index; - phr->u.s.num_adapters++; phr->error = 0; }
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index eefe459..971c593 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -488,9 +488,8 @@ static void subsys_create_adapter(struct hpi_message *phm, return; }
- phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type; + phr->u.s.adapter_type = ao.adapter_type; phr->u.s.adapter_index = ao.index; - phr->u.s.num_adapters++; phr->error = 0; }
diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index 9f003a4..10de7e0 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -626,10 +626,11 @@ struct hpi_subsys_msg {
struct hpi_subsys_res { u32 version; - u32 data; /* used to return extended version */ - u16 num_adapters; /* number of adapters */ + u32 data; /* extended version */ + u16 num_adapters; u16 adapter_index; - u16 aw_adapter_list[HPI_MAX_ADAPTERS]; + u16 adapter_type; + u16 pad16; };
union hpi_adapterx_msg { diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 4d696ab..e0a08f6 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -164,11 +164,10 @@ static void subsys_get_adapter(struct hpi_message *phm,
if (index < HPI_MAX_ADAPTERS) { phr->u.s.adapter_index = adapters.adapter[index].index; - phr->u.s.aw_adapter_list[0] = - adapters.adapter[index].adapter_type; + phr->u.s.adapter_type = adapters.adapter[index].adapter_type; } else { phr->u.s.adapter_index = 0; - phr->u.s.aw_adapter_list[0] = 0; + phr->u.s.adapter_type = 0; phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; } } diff --git a/pci/asihpi/hpifunc.c b/pci/asihpi/hpifunc.c index 28e98dd..53924e4 100644 --- a/pci/asihpi/hpifunc.c +++ b/pci/asihpi/hpifunc.c @@ -153,7 +153,8 @@ u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index, hm.obj_index = (u16)iterator; hpi_send_recv(&hm, &hr); *padapter_index = (int)hr.u.s.adapter_index; - *pw_adapter_type = hr.u.s.aw_adapter_list[0]; + *pw_adapter_type = hr.u.s.adapter_type; + return hr.error; }
diff --git a/pci/asihpi/hpioctl.c b/pci/asihpi/hpioctl.c index 4bd3278..0ea9aae 100644 --- a/pci/asihpi/hpioctl.c +++ b/pci/asihpi/hpioctl.c @@ -389,7 +389,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, }
adapter.index = hr.u.s.adapter_index; - adapter.type = hr.u.s.aw_adapter_list[adapter.index]; + adapter.type = hr.u.s.adapter_type; hm.adapter_index = adapter.index;
err = hpi_adapter_open(adapter.index);
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/asihpi.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/pci/asihpi/asihpi.c b/pci/asihpi/asihpi.c index e456c2e..b2c0c8a 100644 --- a/pci/asihpi/asihpi.c +++ b/pci/asihpi/asihpi.c @@ -2847,9 +2847,11 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, hpi_card->index, card->number); }
+ snd_card_set_dev(card, &pci_dev->dev); + asihpi = (struct snd_card_asihpi *) card->private_data; asihpi->card = card; - asihpi->pci = hpi_card->pci; + asihpi->pci = pci_dev; asihpi->adapter_index = hpi_card->index; hpi_handle_error(hpi_adapter_get_info( asihpi->adapter_index,
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 9 +++++++++ pci/asihpi/hpi_internal.h | 17 ++++++++++++++++- pci/asihpi/hpicmn.c | 20 +++++++++++++++++++- pci/asihpi/hpifunc.c | 10 ++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index bef90d4..5ac978d 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -645,6 +645,11 @@ enum HPI_SWITCH_STATES { */ #define HPI_GAIN_OFF (-100 * HPI_UNITS_PER_dB)
+/** channel mask specifying all channels +\ingroup volume +*/ +#define HPI_BITMASK_ALL_CHANNELS (0xFFFFFFFF) + /** value returned for no signal \ingroup meter */ @@ -1312,6 +1317,10 @@ u16 hpi_volume_get_gain(u32 h_control, short an_gain0_01dB_out[HPI_MAX_CHANNELS] );
+u16 hpi_volume_set_mute(u32 h_control, u32 mute); + +u16 hpi_volume_get_mute(u32 h_control, u32 *mute); + #define hpi_volume_get_range hpi_volume_query_range u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB); diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index 10de7e0..9908160 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -114,6 +114,18 @@ enum HPI_SUBSYS_OPTIONS { HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262 };
+/** Volume flags +*/ +enum HPI_VOLUME_FLAGS { + /** Set if the volume control is muted */ + HPI_VOLUME_FLAG_MUTED = (1 << 0), + /** Set if the volume control has a mute function */ + HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1), + /** Set if volume control can do autofading */ + HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2) + /* Note Flags >= (1<<8) are for DSP internal use only */ +}; + /******************************************* CONTROL ATTRIBUTES ****/ /* (in order of control type ID */
@@ -139,6 +151,8 @@ enum HPI_CONTROL_ATTRIBUTES {
HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1), HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2), + HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3), + HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4), HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6), HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
@@ -1389,7 +1403,8 @@ struct hpi_control_cache_info { struct hpi_control_cache_vol { struct hpi_control_cache_info i; short an_log[2]; - char temp_padding[4]; + unsigned short flags; + char padding[2]; };
struct hpi_control_cache_meter { diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index e0a08f6..4b3f476 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -347,8 +347,21 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, if (phm->u.c.attribute == HPI_VOLUME_GAIN) { phr->u.c.an_log_value[0] = pC->u.vol.an_log[0]; phr->u.c.an_log_value[1] = pC->u.vol.an_log[1]; - } else + } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) { + if (pC->u.vol.flags & HPI_VOLUME_FLAG_HAS_MUTE) { + if (pC->u.vol.flags & HPI_VOLUME_FLAG_MUTED) + phr->u.c.param1 = + HPI_BITMASK_ALL_CHANNELS; + else + phr->u.c.param1 = 0; + } else { + phr->error = + HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; + phr->u.c.param1 = 0; + } + } else { found = 0; + } break; case HPI_CONTROL_MULTIPLEXER: if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) { @@ -544,6 +557,11 @@ void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache, if (phm->u.c.attribute == HPI_VOLUME_GAIN) { pC->u.vol.an_log[0] = phr->u.c.an_log_value[0]; pC->u.vol.an_log[1] = phr->u.c.an_log_value[1]; + } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) { + if (phm->u.c.param1) + pC->u.vol.flags |= HPI_VOLUME_FLAG_MUTED; + else + pC->u.vol.flags &= ~HPI_VOLUME_FLAG_MUTED; } break; case HPI_CONTROL_MULTIPLEXER: diff --git a/pci/asihpi/hpifunc.c b/pci/asihpi/hpifunc.c index 53924e4..b79eba1 100644 --- a/pci/asihpi/hpifunc.c +++ b/pci/asihpi/hpifunc.c @@ -2888,6 +2888,16 @@ u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS] &an_log_gain[0], &an_log_gain[1]); }
+u16 hpi_volume_set_mute(u32 h_control, u32 mute) +{ + return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0); +} + +u16 hpi_volume_get_mute(u32 h_control, u32 *mute) +{ + return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute); +} + u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB) {
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpicmn.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/pci/asihpi/hpicmn.c b/pci/asihpi/hpicmn.c index 4b3f476..3e9c5c2 100644 --- a/pci/asihpi/hpicmn.c +++ b/pci/asihpi/hpicmn.c @@ -78,8 +78,18 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao) }
if (adapters.adapter[pao->index].adapter_type) { - { - retval = HPI_DUPLICATE_ADAPTER_NUMBER; + int a; + for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { + if (!adapters.adapter[a].adapter_type) { + HPI_DEBUG_LOG(WARNING, + "ASI%X duplicate index %d moved to %d\n", + pao->adapter_type, pao->index, a); + pao->index = a; + break; + } + } + if (a < 0) { + retval = HPI_ERROR_DUPLICATE_ADAPTER_NUMBER; goto unlock; } }
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6205.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index 971c593..377e56f 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -1290,33 +1290,36 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, struct hpi_hw_obj *phw = pao->priv; struct dsp_code dsp_code; u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; - u16 firmware_id = pao->pci.pci_dev->subsystem_device; u32 temp; int dsp = 0, i = 0; u16 err = 0;
boot_code_id[0] = HPI_ADAPTER_ASI(0x6205);
- /* special cases where firmware_id != subsys ID */ - switch (firmware_id) { + boot_code_id[1] = pao->pci.pci_dev->subsystem_device; + boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(boot_code_id[1]); + + /* fix up cases where bootcode id[1] != subsys id */ + switch (boot_code_id[1]) { case HPI_ADAPTER_FAMILY_ASI(0x5000): - boot_code_id[0] = firmware_id; - firmware_id = 0; + boot_code_id[0] = boot_code_id[1]; + boot_code_id[1] = 0; break; case HPI_ADAPTER_FAMILY_ASI(0x5300): case HPI_ADAPTER_FAMILY_ASI(0x5400): case HPI_ADAPTER_FAMILY_ASI(0x6300): - firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6400); + boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6400); break; case HPI_ADAPTER_FAMILY_ASI(0x5600): case HPI_ADAPTER_FAMILY_ASI(0x6500): - firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6600); + boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6600); break; case HPI_ADAPTER_FAMILY_ASI(0x8800): - firmware_id = HPI_ADAPTER_FAMILY_ASI(0x8900); + boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x8900); + break; + default: break; } - boot_code_id[1] = firmware_id;
/* reset DSP by writing a 1 to the WARMRESET bit */ temp = C6205_HDCR_WARMRESET;
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi6205.c | 37 +--------------- pci/asihpi/hpi_internal.h | 4 -- pci/asihpi/hpifunc.c | 106 --------------------------------------------- 3 files changed, 1 insertions(+), 146 deletions(-)
diff --git a/pci/asihpi/hpi6205.c b/pci/asihpi/hpi6205.c index 377e56f..33136cb 100644 --- a/pci/asihpi/hpi6205.c +++ b/pci/asihpi/hpi6205.c @@ -127,9 +127,6 @@ struct hpi_hw_obj { u32 outstream_host_buffer_size[HPI_MAX_STREAMS];
struct consistent_dma_area h_control_cache; - struct consistent_dma_area h_async_event_buffer; -/* struct hpi_control_cache_single *pControlCache; */ - struct hpi_async_event *p_async_event_buffer; struct hpi_control_cache *p_cache; };
@@ -625,34 +622,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, pao->has_control_cache = 0; } } - /* allocate bus mastering async buffer and tell the DSP about it */ - if (interface->async_buffer.b.size) { - err = hpios_locked_mem_alloc(&phw->h_async_event_buffer, - interface->async_buffer.b.size * - sizeof(struct hpi_async_event), pao->pci.pci_dev); - if (!err) - err = hpios_locked_mem_get_virt_addr - (&phw->h_async_event_buffer, (void *) - &phw->p_async_event_buffer); - if (!err) - memset((void *)phw->p_async_event_buffer, 0, - interface->async_buffer.b.size * - sizeof(struct hpi_async_event)); - if (!err) { - err = hpios_locked_mem_get_phys_addr - (&phw->h_async_event_buffer, &phys_addr); - interface->async_buffer.physical_address32 = - phys_addr; - } - if (err) { - if (hpios_locked_mem_valid(&phw-> - h_async_event_buffer)) { - hpios_locked_mem_free - (&phw->h_async_event_buffer); - phw->p_async_event_buffer = NULL; - } - } - } send_dsp_command(phw, H620_HIF_IDLE);
{ @@ -716,11 +685,6 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao)
phw = pao->priv;
- if (hpios_locked_mem_valid(&phw->h_async_event_buffer)) { - hpios_locked_mem_free(&phw->h_async_event_buffer); - phw->p_async_event_buffer = NULL; - } - if (hpios_locked_mem_valid(&phw->h_control_cache)) { hpios_locked_mem_free(&phw->h_control_cache); hpi_free_control_cache(phw->p_cache); @@ -1126,6 +1090,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, status->auxiliary_data_available = 0;
hw_message(pao, phm, phr); + if (phr->error && hpios_locked_mem_valid(&phw-> instream_host_buffers[phm->obj_index])) { diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index 9908160..06a8779 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -1541,10 +1541,6 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, /* main HPI entry point */ void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);
-/* UDP message */ -void hpi_send_recvUDP(struct hpi_message *phm, struct hpi_response *phr, - const unsigned int timeout); - /* used in PnP OS/driver */ u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource, u16 *pw_adapter_index); diff --git a/pci/asihpi/hpifunc.c b/pci/asihpi/hpifunc.c index b79eba1..3aa1f09 100644 --- a/pci/asihpi/hpifunc.c +++ b/pci/asihpi/hpifunc.c @@ -263,112 +263,6 @@ u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index, return hr.error; }
-u16 hpi_adapter_get_assert2(u16 adapter_index, u16 *p_assert_count, - char *psz_assert, u32 *p_param1, u32 *p_param2, - u32 *p_dsp_string_addr, u16 *p_processor_id) -{ - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, - HPI_ADAPTER_GET_ASSERT); - hm.adapter_index = adapter_index; - - hpi_send_recv(&hm, &hr); - - *p_assert_count = 0; - - if (!hr.error) { - *p_assert_count = hr.u.ax.assert.count; - - if (*p_assert_count) { - *p_param1 = hr.u.ax.assert.p1; - *p_param2 = hr.u.ax.assert.p2; - *p_processor_id = hr.u.ax.assert.dsp_index; - *p_dsp_string_addr = hr.u.ax.assert.dsp_msg_addr; - memcpy(psz_assert, hr.u.ax.assert.sz_message, - HPI_STRING_LEN); - } else { - *psz_assert = 0; - } - } - return hr.error; -} - -u16 hpi_adapter_test_assert(u16 adapter_index, u16 assert_id) -{ - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, - HPI_ADAPTER_TEST_ASSERT); - hm.adapter_index = adapter_index; - hm.u.ax.test_assert.value = assert_id; - - hpi_send_recv(&hm, &hr); - - return hr.error; -} - -u16 hpi_adapter_enable_capability(u16 adapter_index, u16 capability, u32 key) -{ -#if 1 - return HPI_ERROR_UNIMPLEMENTED; -#else - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, - HPI_ADAPTER_ENABLE_CAPABILITY); - hm.adapter_index = adapter_index; - hm.u.ax.enable_cap.cap = capability; - hm.u.ax.enable_cap.key = key; - - hpi_send_recv(&hm, &hr); - - return hr.error; -#endif -} - -u16 hpi_adapter_self_test(u16 adapter_index) -{ - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, - HPI_ADAPTER_SELFTEST); - hm.adapter_index = adapter_index; - hpi_send_recv(&hm, &hr); - return hr.error; -} - -u16 hpi_adapter_debug_read(u16 adapter_index, u32 dsp_address, char *p_buffer, - int *count_bytes) -{ - struct hpi_msg_adapter_debug_read hm; - struct hpi_res_adapter_debug_read hr; - - hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr), - HPI_OBJ_ADAPTER, HPI_ADAPTER_DEBUG_READ); - - hm.h.adapter_index = adapter_index; - hm.dsp_address = dsp_address; - - if (*count_bytes > (int)sizeof(hr.bytes)) - *count_bytes = (int)sizeof(hr.bytes); - - hm.count_bytes = *count_bytes; - - hpi_send_recvV1(&hm.h, &hr.h); - - if (!hr.h.error) { - int res_bytes = hr.h.size - sizeof(hr.h); - if (res_bytes > *count_bytes) - res_bytes = *count_bytes; - *count_bytes = res_bytes; - memcpy(p_buffer, &hr.bytes, res_bytes); - } else - *count_bytes = 0; - - return hr.h.error; -} - u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1, u16 parameter2) {
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpifunc.c | 143 ++++++++++++++++++++++++++------------------------ 1 files changed, 75 insertions(+), 68 deletions(-)
diff --git a/pci/asihpi/hpifunc.c b/pci/asihpi/hpifunc.c index 3aa1f09..c38fc94 100644 --- a/pci/asihpi/hpifunc.c +++ b/pci/asihpi/hpifunc.c @@ -310,7 +310,7 @@ u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index, u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, u32 sample_rate, u32 bit_rate, u32 attributes) { - u16 error = 0; + u16 err = 0; struct hpi_msg_format fmt;
switch (channels) { @@ -322,8 +322,8 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, case 16: break; default: - error = HPI_ERROR_INVALID_CHANNELS; - return error; + err = HPI_ERROR_INVALID_CHANNELS; + return err; } fmt.channels = channels;
@@ -346,17 +346,17 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, case HPI_FORMAT_OEM2: break; default: - error = HPI_ERROR_INVALID_FORMAT; - return error; + err = HPI_ERROR_INVALID_FORMAT; + return err; } fmt.format = format;
if (sample_rate < 8000L) { - error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; + err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; sample_rate = 8000L; } if (sample_rate > 200000L) { - error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; + err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE; sample_rate = 200000L; } fmt.sample_rate = sample_rate; @@ -387,10 +387,10 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, if ((channels == 1) && (attributes != HPI_MPEG_MODE_DEFAULT)) { attributes = HPI_MPEG_MODE_DEFAULT; - error = HPI_ERROR_INVALID_FORMAT; + err = HPI_ERROR_INVALID_FORMAT; } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) { attributes = HPI_MPEG_MODE_DEFAULT; - error = HPI_ERROR_INVALID_FORMAT; + err = HPI_ERROR_INVALID_FORMAT; } fmt.attributes = attributes; break; @@ -399,7 +399,7 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, }
hpi_msg_to_format(p_format, &fmt); - return error; + return err; }
u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, @@ -1567,13 +1567,13 @@ u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index, u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data) { u32 error_data = 0; - u16 error = 0; + u16 err = 0;
- error = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS, + err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS, &error_data); if (pw_error_data) *pw_error_data = (u16)error_data; - return error; + return err; }
u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate) @@ -1680,11 +1680,11 @@ u16 hpi_channel_mode_set(u32 h_control, u16 mode) u16 hpi_channel_mode_get(u32 h_control, u16 *mode) { u32 mode32 = 0; - u16 error = hpi_control_param1_get(h_control, + u16 err = hpi_control_param1_get(h_control, HPI_CHANNEL_MODE_MODE, &mode32); if (mode) *mode = (u16)mode32; - return error; + return err; }
u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count, @@ -1785,9 +1785,9 @@ u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address) { u32 byte_count; u32 iP; - u16 error; + u16 err;
- error = hpi_cobranet_hmi_read(h_control, + err = hpi_cobranet_hmi_read(h_control, HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, (u8 *)&iP);
@@ -1795,26 +1795,26 @@ u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address) ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
- if (error) + if (err) *pdw_ip_address = 0;
- return error; + return err;
}
u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address) { u32 iP; - u16 error; + u16 err;
iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address & 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >> 8) | ((dw_ip_address & 0x000000ff) << 8);
- error = hpi_cobranet_hmi_write(h_control, + err = hpi_cobranet_hmi_write(h_control, HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
- return error; + return err;
}
@@ -1822,8 +1822,8 @@ u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address) { u32 byte_count; u32 iP; - u16 error; - error = hpi_cobranet_hmi_read(h_control, + u16 err; + err = hpi_cobranet_hmi_read(h_control, HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count, (u8 *)&iP);
@@ -1831,55 +1831,62 @@ u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address) ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP & 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
- if (error) + if (err) *pdw_ip_address = 0;
- return error; + return err;
}
u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address) { u32 iP; - u16 error; + u16 err;
iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address & 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >> 8) | ((dw_ip_address & 0x000000ff) << 8);
- error = hpi_cobranet_hmi_write(h_control, + err = hpi_cobranet_hmi_write(h_control, HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
- return error; + return err;
}
-u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *pmAC_MS_bs, - u32 *pmAC_LS_bs) +u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs, + u32 *p_mac_lsbs) { u32 byte_count; - u16 error; - u32 mAC; + u16 err; + u32 mac;
- error = hpi_cobranet_hmi_read(h_control, + err = hpi_cobranet_hmi_read(h_control, HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, - (u8 *)&mAC); - *pmAC_MS_bs = - ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC - & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); - error += hpi_cobranet_hmi_read(h_control, - HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count, - (u8 *)&mAC); - *pmAC_LS_bs = - ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC - & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8); - - if (error) { - *pmAC_MS_bs = 0; - *pmAC_LS_bs = 0; + (u8 *)&mac); + + if (!err) { + *p_mac_msbs = + ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8) + | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) << + 8); + + err = hpi_cobranet_hmi_read(h_control, + HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, + &byte_count, (u8 *)&mac); }
- return error; + if (!err) { + *p_mac_lsbs = + ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8) + | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) << + 8); + } else { + *p_mac_msbs = 0; + *p_mac_lsbs = 0; + } + + return err; }
u16 hpi_compander_set_enable(u32 h_control, u32 enable) @@ -2158,14 +2165,14 @@ u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type, u16 *source_node_index) { u32 node, index; - u16 error = hpi_control_param2_get(h_control, + u16 err = hpi_control_param2_get(h_control, HPI_MULTIPLEXER_SOURCE, &node, &index); if (source_node_type) *source_node_type = (u16)node; if (source_node_index) *source_node_index = (u16)index; - return error; + return err; }
u16 hpi_multiplexer_query_source(u32 h_control, u16 index, @@ -2304,14 +2311,14 @@ u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source) { - u16 error = 0; + u16 err = 0; u32 source = 0; - error = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE, + err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE, &source); - if (!error) + if (!err) if (pw_source) *pw_source = (u16)source; - return error; + return err; }
u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index, @@ -2334,14 +2341,14 @@ u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index) { - u16 error = 0; + u16 err = 0; u32 source_index = 0; - error = hpi_control_param1_get(h_control, - HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index); - if (!error) + err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX, + &source_index); + if (!err) if (pw_source_index) *pw_source_index = (u16)source_index; - return error; + return err; }
u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index, @@ -2362,26 +2369,26 @@ u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate) { - u16 error = 0; + u16 err = 0; u32 sample_rate = 0; - error = hpi_control_param1_get(h_control, + err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate); - if (!error) + if (!err) if (psample_rate) *psample_rate = sample_rate; - return error; + return err; }
u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate) { - u16 error = 0; + u16 err = 0; u32 sample_rate = 0; - error = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE, + err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate); - if (!error) + if (!err) if (psample_rate) *psample_rate = sample_rate; - return error; + return err; }
u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 19 ++++++++++++++++++- pci/asihpi/hpi_internal.h | 25 +++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index 5ac978d..ec19df5 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -324,6 +324,15 @@ to enable SSX2 stream mapping within the kernel level of the driver. */ HPI_ADAPTER_PROPERTY_SSX2_SETTING = 4,
+/** Enables/disables PCI(e) IRQ. +A setting of 0 indicates that no interrupts are being generated. A DSP boot +this property is set to 0. Setting to a non-zero value specifies the number +of frames of audio that should be processed between interrupts. This property +should be set to multiple of the mixer interval as read back from the +HPI_ADAPTER_PROPERTY_INTERVAL property. +*/ + HPI_ADAPTER_PROPERTY_IRQ_RATE = 5, + /** Base number for readonly properties */ HPI_ADAPTER_PROPERTY_READONLYBASE = 256,
@@ -428,7 +437,13 @@ return value is true (1) or false (0). If the current adapter mode is MONO SSX2 is disabled, even though this property will return true. */ - HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271 + HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271, +/** Readonly supports PCI(e) IRQ. +Indicates that the adapter in it's current mode supports interrupts +across the host bus. Note, this does not imply that interrupts are +enabled. Instead it indicates that they can be enabled. +*/ + HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272 };
/** Adapter mode commands @@ -998,6 +1013,8 @@ enum HPI_ERROR_CODES { HPI_ERROR_NO_INTERADAPTER_GROUPS = 314, /** Streams on different DSPs cannot be grouped. */ HPI_ERROR_NO_INTERDSP_GROUPS = 315, + /** Stream wait cancelled before threshold reached. */ + HPI_ERROR_WAIT_CANCELLED = 316,
/** Invalid mixer node for this adapter. */ HPI_ERROR_INVALID_NODE = 400, diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index 06a8779..ca5b844 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -432,7 +432,9 @@ enum HPI_FUNCTION_IDS { HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16), HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17), HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18), -#define HPI_ADAPTER_FUNCTION_COUNT 18 + HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19), + HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20), +#define HPI_ADAPTER_FUNCTION_COUNT 20
HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1), HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2), @@ -458,7 +460,8 @@ enum HPI_FUNCTION_IDS { HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22), HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23), HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24), -#define HPI_OSTREAM_FUNCTION_COUNT 24 + HPI_OSTREAM_WAIT = HPI_FUNC_ID(OSTREAM, 25), +#define HPI_OSTREAM_FUNCTION_COUNT 25
HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1), HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2), @@ -479,7 +482,8 @@ enum HPI_FUNCTION_IDS { HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17), HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18), HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19), -#define HPI_ISTREAM_FUNCTION_COUNT 19 + HPI_ISTREAM_WAIT = HPI_FUNC_ID(ISTREAM, 20), +#define HPI_ISTREAM_FUNCTION_COUNT 20
/* NOTE: GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */ @@ -494,7 +498,8 @@ enum HPI_FUNCTION_IDS { HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9), HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10), HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11), -#define HPI_MIXER_FUNCTION_COUNT 11 + HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12), +#define HPI_MIXER_FUNCTION_COUNT 12
HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1), HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2), @@ -693,6 +698,9 @@ union hpi_adapterx_msg { u32 pad32; u16 value; } test_assert; + struct { + u32 yes; + } irq_query; };
struct hpi_adapter_res { @@ -731,6 +739,9 @@ union hpi_adapterx_res { u32 length; u32 version; } query_flash; + struct { + u32 yes; + } irq_query; };
struct hpi_stream_msg { @@ -742,6 +753,7 @@ struct hpi_stream_msg { u32 time_scale; struct hpi_buffer buffer; struct hpi_streamid stream; + u32 threshold_bytes; } u; };
@@ -828,6 +840,11 @@ union hpi_mixerx_res { u32 p_data; /* pointer to data array */ u16 more_to_do; /* indicates if there is more to do */ } gcabi; + struct { + u32 total_controls; /* count of controls in the mixer */ + u32 cache_controls; /* count of controls in the cac */ + u32 cache_bytes; /* size of cache */ + } cache_info; };
struct hpi_control_msg {
From: Eliot Blennerhassett eblennerhassett@audioscience.com
HPI version 4.05.32 Tweak HPI error code for backward compatibility. Add BUILD to build-related defines.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 25 +++++++++++++++++-------- pci/asihpi/hpi_internal.h | 7 +++---- pci/asihpi/hpios.h | 6 ++---- 3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index ec19df5..dec1c30 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -43,14 +43,15 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
/* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 19) -#define HPI_VER_STRING "4.05.19" +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 32) +#define HPI_VER_STRING "4.05.32"
/* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0)
#include <linux/types.h> -#define HPI_EXCLUDE_DEPRECATED +#define HPI_BUILD_EXCLUDE_DEPRECATED +#define HPI_BUILD_KERNEL_MODE
/******************************************************************************/ /******** HPI API DEFINITIONS *****/ @@ -933,11 +934,9 @@ enum HPI_ERROR_CODES { /** Adapter number out of range or not set properly. */ HPI_ERROR_BAD_ADAPTER_NUMBER = 202, /** 2 adapters with the same adapter number. */ - HPI_DUPLICATE_ADAPTER_NUMBER = 203, + HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203, /** DSP code failed to bootload. (unused?) */ HPI_ERROR_DSP_BOOTLOAD = 204, - /** Communication with DSP failed */ - HPI_ERROR_DSP_COMMUNICATION = 205, /** Couldn't find or open the DSP code file. */ HPI_ERROR_DSP_FILE_NOT_FOUND = 206, /** Internal DSP hardware error. */ @@ -1056,8 +1055,18 @@ enum HPI_ERROR_CODES { /** hpioct32.c can't obtain mutex */ HPI_ERROR_MUTEX_TIMEOUT = 700,
- /** errors from HPI backends have values >= this */ - HPI_ERROR_BACKEND_BASE = 900 + /** Backend errors used to be greater than this. + \deprecated Now, all backends return only errors defined here in hpi.h + */ + HPI_ERROR_BACKEND_BASE = 900, + + /** Communication with DSP failed */ + HPI_ERROR_DSP_COMMUNICATION = 900 + /* Note that the dsp communication error is set to this value so that + it remains compatible with any software that expects such errors + to be backend errors i.e. >= 900. + Do not define any new error codes with values > 900. + */ };
/** \defgroup maximums HPI maximum values diff --git a/pci/asihpi/hpi_internal.h b/pci/asihpi/hpi_internal.h index ca5b844..af678be 100644 --- a/pci/asihpi/hpi_internal.h +++ b/pci/asihpi/hpi_internal.h @@ -309,8 +309,8 @@ enum HPI_CONTROL_ATTRIBUTES {
#define HPI_ETHERNET_UDP_PORT (44600) /*!< UDP messaging port */
-/** Base network time out is set to 100 milli-seconds. */ -#define HPI_ETHERNET_TIMEOUT_MS (100) +/** Default network timeout in milli-seconds. */ +#define HPI_ETHERNET_TIMEOUT_MS 500
/** Locked memory buffer alloc/free phases */ enum HPI_BUFFER_CMDS { @@ -389,8 +389,7 @@ enum HPI_OBJECT_TYPES { };
#define HPI_OBJ_FUNCTION_SPACING 0x100 -#define HPI_FUNC_ID(obj, index) \ - (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + index) +#define HPI_FUNC_ID(obj, i) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + i)
#define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
diff --git a/pci/asihpi/hpios.h b/pci/asihpi/hpios.h index 90879b1..03273e7 100644 --- a/pci/asihpi/hpios.h +++ b/pci/asihpi/hpios.h @@ -27,9 +27,7 @@ HPI Operating System Specific macros for Linux Kernel driver #define HPI_OS_LINUX_KERNEL
#define HPI_OS_DEFINED -#define HPI_KERNEL_MODE - -#define HPI_REASSIGN_DUPLICATE_ADAPTER_IDX +#define HPI_BUILD_KERNEL_MODE
#include <linux/io.h> #include <asm/system.h> @@ -142,7 +140,7 @@ static inline void cond_unlock(struct hpios_spinlock *l) #define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock)
#ifdef CONFIG_SND_DEBUG -#define HPI_DEBUG +#define HPI_BUILD_DEBUG #endif
#define HPI_ALIST_LOCKING
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpioctl.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pci/asihpi/hpioctl.c b/pci/asihpi/hpioctl.c index 0ea9aae..26186be 100644 --- a/pci/asihpi/hpioctl.c +++ b/pci/asihpi/hpioctl.c @@ -449,10 +449,8 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) } }
- if (pa->p_buffer) { - pa->buffer_size = 0; + if (pa->p_buffer) vfree(pa->p_buffer); - }
pci_set_drvdata(pci_dev, NULL); if (1) @@ -461,6 +459,8 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) pci_dev->vendor, pci_dev->device, pci_dev->subsystem_vendor, pci_dev->subsystem_device, pci_dev->devfn, pa->index); + + memset(pa, 0, sizeof(*pa)); }
void __init asihpi_init(void)
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Difference in major.minor between driver and firmware is an error now. Release version mismatch give a warning.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpidspcd.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/pci/asihpi/hpidspcd.c b/pci/asihpi/hpidspcd.c index f9958e9..fb311d8 100644 --- a/pci/asihpi/hpidspcd.c +++ b/pci/asihpi/hpidspcd.c @@ -100,9 +100,9 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, goto error2; }
- if (header.version / 10000 != HPI_VER_DECIMAL / 10000) { + if (header.version / 100 != HPI_VER_DECIMAL / 100) { dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev, - "Firmware Major Version mismatch " + "Incompatible firmware version " "DSP image %d != Driver %d\n", header.version, HPI_VER_DECIMAL); goto error2; @@ -110,9 +110,8 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code,
if (header.version != HPI_VER_DECIMAL) { dev_printk(KERN_WARNING, &ps_dsp_code->ps_dev->dev, - "firmware: version mismatch DSP image %d != Driver %d\n", + "Firmware: release version mismatch DSP image %d != Driver %d\n", header.version, HPI_VER_DECIMAL); - /* goto error2; still allow driver to load */ }
HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/asihpi.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/pci/asihpi/asihpi.c b/pci/asihpi/asihpi.c index b2c0c8a..c0ae94f 100644 --- a/pci/asihpi/asihpi.c +++ b/pci/asihpi/asihpi.c @@ -632,7 +632,8 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, VPRINTK1(KERN_INFO "start\n"); /* start the master stream */ snd_card_asihpi_pcm_timer_start(substream); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || + !card->support_mmap) hpi_handle_error(hpi_stream_start(dpcm->h_stream)); break;
From: Eliot Blennerhassett eblennerhassett@audioscience.com
Firmware version check depends on hpi version. Update so correct firmware is accepted.
Signed-off-by: Eliot Blennerhassett eblennerhassett@audioscience.com --- pci/asihpi/hpi.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pci/asihpi/hpi.h b/pci/asihpi/hpi.h index dec1c30..6fc025c 100644 --- a/pci/asihpi/hpi.h +++ b/pci/asihpi/hpi.h @@ -43,8 +43,8 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
/* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 32) -#define HPI_VER_STRING "4.05.32" +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 6, 0) +#define HPI_VER_STRING "4.06.00"
/* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0)
At Thu, 10 Feb 2011 17:25:53 +1300, linux@audioscience.com wrote:
This patch series updates asihpi driver from version 4.04 to 4.06
Major changes:
- hpi6205 adapters no longer signal interrupts on message
transfer, freeing the interrupt for use by streams. This requires matching DSP firmware.
- rewrote alsa driver pcm stream timer function so it works better with
small buffer sizes e.g. JACK.
- update alsa control names to better conform to 'standard' style.
Minor changes: add low level volume mute control, allow adapters with duplicate hardware index jumpers to be discovered, fix playback start for non-mmap adapters.
Cosmetic changes: removal of many unused functions and data. removal of vestigial hpi subsys pointer from hpi functions. conversion of many defines to enums, various cleanups to comment text and some badly munged identifiers.
Thanks for the patches. Many of them include nice cleanups indeed.
One problem was that you added the inclusion of adriver.h with strange ifdefs. This should be removed in the kernel code. (And adriver.h is anyway included first in alsa-driver build tree, so it's unnecessary to add something there.) I corrected it manually, but applied the rest as is.
Takashi
asihpi.c | 781 ++++++++--------- hpi.h | 1214 ++++++++++----------------- hpi6000.c | 299 +++--- hpi6205.c | 603 +++++-------- hpi6205.h | 7 hpi_internal.h | 1118 ++++++++++++------------- hpicmn.c | 480 ++++++---- hpicmn.h | 24 hpidebug.c | 157 --- hpidebug.h | 323 ------- hpidspcd.c | 37 hpidspcd.h | 2 hpifunc.c | 2498 ++++++++++++++++----------------------------------------- hpimsginit.c | 18 hpimsginit.h | 12 hpimsgx.c | 203 +--- hpioctl.c | 85 - hpios.h | 10 18 files changed, 2914 insertions(+), 4957 deletions(-)
On 11/02/11 06:52, Takashi Iwai wrote:
At Thu, 10 Feb 2011 17:25:53 +1300, linux@audioscience.com wrote:
This patch series updates asihpi driver from version 4.04 to 4.06
Thanks for the patches. Many of them include nice cleanups indeed.
Thanks Takashi.
Please also update alsa-firmware/asihpi with the contents of:
http://audioscience.com/internet/download/drivers/released/v4/06/00/asihpi-f...
This update is necessary for driver and dsp firmware to function correctly together.
One problem was that you added the inclusion of adriver.h with strange ifdefs. This should be removed in the kernel code. (And adriver.h is anyway included first in alsa-driver build tree, so it's unnecessary to add something there.) I corrected it manually, but applied the rest as is.
Thanks.
I can wipe the sweat from my brow now. (It took me quite some time to generate the git commits from our internal VCS history, and I really hoped I wouldn't have to revise the patches!)
-- Eliot
participants (3)
-
Eliot Blennerhassett
-
linux@audioscience.com
-
Takashi Iwai