diff options
author | Eliot Blennerhassett <eblennerhassett@audioscience.com> | 2011-02-09 23:26:05 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-02-10 12:49:27 -0500 |
commit | 0a00044d26489c1907b9e8b3e633e6b9a6d2200e (patch) | |
tree | 463ea7d845a63493c81971e7cbc2e7235b213bda /sound/pci/asihpi | |
parent | ba94455c29c383713c360537b6323e3bd4c76434 (diff) |
ALSA: asihpi - Reduce number of error codes returned to upper layers.
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r-- | sound/pci/asihpi/hpi.h | 43 | ||||
-rw-r--r-- | sound/pci/asihpi/hpi6000.c | 58 | ||||
-rw-r--r-- | sound/pci/asihpi/hpi6205.c | 15 |
3 files changed, 73 insertions, 43 deletions
diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h index efed0c166bf3..212a016d857b 100644 --- a/sound/pci/asihpi/hpi.h +++ b/sound/pci/asihpi/hpi.h | |||
@@ -43,8 +43,8 @@ i.e 3.05.02 is a development version | |||
43 | #define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) | 43 | #define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) |
44 | 44 | ||
45 | /* Use single digits for versions less that 10 to avoid octal. */ | 45 | /* Use single digits for versions less that 10 to avoid octal. */ |
46 | #define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 17) | 46 | #define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 5, 19) |
47 | #define HPI_VER_STRING "4.05.17" | 47 | #define HPI_VER_STRING "4.05.19" |
48 | 48 | ||
49 | /* Library version as documented in hpi-api-versions.txt */ | 49 | /* Library version as documented in hpi-api-versions.txt */ |
50 | #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) | 50 | #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) |
@@ -433,11 +433,14 @@ return true. | |||
433 | 433 | ||
434 | /** Adapter mode commands | 434 | /** Adapter mode commands |
435 | 435 | ||
436 | Used in wQueryOrSet field of HPI_AdapterSetModeEx(). | 436 | Used in wQueryOrSet parameter of HPI_AdapterSetModeEx(). |
437 | \ingroup adapter | 437 | \ingroup adapter |
438 | */ | 438 | */ |
439 | enum HPI_ADAPTER_MODE_CMDS { | 439 | enum HPI_ADAPTER_MODE_CMDS { |
440 | /** Set the mode to the given parameter */ | ||
440 | HPI_ADAPTER_MODE_SET = 0, | 441 | HPI_ADAPTER_MODE_SET = 0, |
442 | /** Return 0 or error depending whether mode is valid, | ||
443 | but don't set the mode */ | ||
441 | HPI_ADAPTER_MODE_QUERY = 1 | 444 | HPI_ADAPTER_MODE_QUERY = 1 |
442 | }; | 445 | }; |
443 | 446 | ||
@@ -874,8 +877,7 @@ enum HPI_ERROR_CODES { | |||
874 | HPI_ERROR_OBJ_ALREADY_OPEN = 105, | 877 | HPI_ERROR_OBJ_ALREADY_OPEN = 105, |
875 | /** PCI, ISA resource not valid. */ | 878 | /** PCI, ISA resource not valid. */ |
876 | HPI_ERROR_INVALID_RESOURCE = 106, | 879 | HPI_ERROR_INVALID_RESOURCE = 106, |
877 | /* GetInfo call from SubSysFindAdapters failed. */ | 880 | /* HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107 */ |
878 | /*HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107, */ | ||
879 | /** Default response was never updated with actual error code. */ | 881 | /** Default response was never updated with actual error code. */ |
880 | HPI_ERROR_INVALID_RESPONSE = 108, | 882 | HPI_ERROR_INVALID_RESPONSE = 108, |
881 | /** wSize field of response was not updated, | 883 | /** wSize field of response was not updated, |
@@ -905,8 +907,7 @@ enum HPI_ERROR_CODES { | |||
905 | */ | 907 | */ |
906 | HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL = 117, | 908 | HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL = 117, |
907 | 909 | ||
908 | /* Too many adapters. */ | 910 | /* HPI_ERROR_TOO_MANY_ADAPTERS= 200 */ |
909 | /* HPI_ERROR_TOO_MANY_ADAPTERS= 200, */ | ||
910 | /** Bad adpater. */ | 911 | /** Bad adpater. */ |
911 | HPI_ERROR_BAD_ADAPTER = 201, | 912 | HPI_ERROR_BAD_ADAPTER = 201, |
912 | /** Adapter number out of range or not set properly. */ | 913 | /** Adapter number out of range or not set properly. */ |
@@ -915,15 +916,15 @@ enum HPI_ERROR_CODES { | |||
915 | HPI_DUPLICATE_ADAPTER_NUMBER = 203, | 916 | HPI_DUPLICATE_ADAPTER_NUMBER = 203, |
916 | /** DSP code failed to bootload. (unused?) */ | 917 | /** DSP code failed to bootload. (unused?) */ |
917 | HPI_ERROR_DSP_BOOTLOAD = 204, | 918 | HPI_ERROR_DSP_BOOTLOAD = 204, |
918 | /** Adapter failed DSP code self test. (unused?) */ | 919 | /** Communication with DSP failed */ |
919 | HPI_ERROR_DSP_SELFTEST = 205, | 920 | HPI_ERROR_DSP_COMMUNICATION = 205, |
920 | /** Couldn't find or open the DSP code file. */ | 921 | /** Couldn't find or open the DSP code file. */ |
921 | HPI_ERROR_DSP_FILE_NOT_FOUND = 206, | 922 | HPI_ERROR_DSP_FILE_NOT_FOUND = 206, |
922 | /** Internal DSP hardware error. */ | 923 | /** Internal DSP hardware error. */ |
923 | HPI_ERROR_DSP_HARDWARE = 207, | 924 | HPI_ERROR_DSP_HARDWARE = 207, |
924 | /** Could not allocate memory */ | 925 | /** Could not allocate memory */ |
925 | HPI_ERROR_MEMORY_ALLOC = 208, | 926 | HPI_ERROR_MEMORY_ALLOC = 208, |
926 | /** Failed to correctly load/config PLD. (unused?) */ | 927 | /** Failed to correctly load/config PLD. (unused) */ |
927 | HPI_ERROR_PLD_LOAD = 209, | 928 | HPI_ERROR_PLD_LOAD = 209, |
928 | /** Unexpected end of file, block length too big etc. */ | 929 | /** Unexpected end of file, block length too big etc. */ |
929 | HPI_ERROR_DSP_FILE_FORMAT = 210, | 930 | HPI_ERROR_DSP_FILE_FORMAT = 210, |
@@ -932,8 +933,7 @@ enum HPI_ERROR_CODES { | |||
932 | HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211, | 933 | HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211, |
933 | /** First DSP code section header not found in DSP file. */ | 934 | /** First DSP code section header not found in DSP file. */ |
934 | HPI_ERROR_DSP_FILE_NO_HEADER = 212, | 935 | HPI_ERROR_DSP_FILE_NO_HEADER = 212, |
935 | /* File read operation on DSP code file failed. */ | 936 | /* HPI_ERROR_DSP_FILE_READ_ERROR= 213, */ |
936 | /*HPI_ERROR_DSP_FILE_READ_ERROR= 213, */ | ||
937 | /** DSP code for adapter family not found. */ | 937 | /** DSP code for adapter family not found. */ |
938 | HPI_ERROR_DSP_SECTION_NOT_FOUND = 214, | 938 | HPI_ERROR_DSP_SECTION_NOT_FOUND = 214, |
939 | /** Other OS specific error opening DSP file. */ | 939 | /** Other OS specific error opening DSP file. */ |
@@ -943,8 +943,7 @@ enum HPI_ERROR_CODES { | |||
943 | /** DSP code section header had size == 0. */ | 943 | /** DSP code section header had size == 0. */ |
944 | HPI_ERROR_DSP_FILE_NULL_HEADER = 217, | 944 | HPI_ERROR_DSP_FILE_NULL_HEADER = 217, |
945 | 945 | ||
946 | /* Base number for flash errors. */ | 946 | /* HPI_ERROR_FLASH = 220, */ |
947 | /* HPI_ERROR_FLASH = 220, */ | ||
948 | 947 | ||
949 | /** Flash has bad checksum */ | 948 | /** Flash has bad checksum */ |
950 | HPI_ERROR_BAD_CHECKSUM = 221, | 949 | HPI_ERROR_BAD_CHECKSUM = 221, |
@@ -958,8 +957,8 @@ enum HPI_ERROR_CODES { | |||
958 | /** Reserved for OEMs. */ | 957 | /** Reserved for OEMs. */ |
959 | HPI_ERROR_RESERVED_1 = 290, | 958 | HPI_ERROR_RESERVED_1 = 290, |
960 | 959 | ||
961 | /* Stream does not exist. */ | 960 | /* HPI_ERROR_INVALID_STREAM = 300, |
962 | /*HPI_ERROR_INVALID_STREAM= 300, // use HPI_ERROR_INVALID_OBJ_INDEX */ | 961 | use HPI_ERROR_INVALID_OBJ_INDEX */ |
963 | /** Invalid compression format. */ | 962 | /** Invalid compression format. */ |
964 | HPI_ERROR_INVALID_FORMAT = 301, | 963 | HPI_ERROR_INVALID_FORMAT = 301, |
965 | /** Invalid format samplerate */ | 964 | /** Invalid format samplerate */ |
@@ -970,10 +969,12 @@ enum HPI_ERROR_CODES { | |||
970 | HPI_ERROR_INVALID_BITRATE = 304, | 969 | HPI_ERROR_INVALID_BITRATE = 304, |
971 | /** Invalid datasize used for stream read/write. */ | 970 | /** Invalid datasize used for stream read/write. */ |
972 | HPI_ERROR_INVALID_DATASIZE = 305, | 971 | HPI_ERROR_INVALID_DATASIZE = 305, |
973 | /* Stream buffer is full during stream write. */ | 972 | /* Stream buffer is full during stream write. |
974 | /*HPI_ERROR_BUFFER_FULL = 306, // USE HPI_ERROR_INVALID_DATASIZE */ | 973 | HPI_ERROR_BUFFER_FULL = 306, |
975 | /* Stream buffer is empty during stream read. */ | 974 | Stream buffer is empty during stream read. |
976 | /*HPI_ERROR_BUFFER_EMPTY = 307, // USE HPI_ERROR_INVALID_DATASIZE */ | 975 | HPI_ERROR_BUFFER_EMPTY = 307, |
976 | Use HPI_ERROR_INVALID_DATASIZE | ||
977 | */ | ||
977 | /** Null data pointer used for stream read/write. */ | 978 | /** Null data pointer used for stream read/write. */ |
978 | HPI_ERROR_INVALID_DATA_POINTER = 308, | 979 | HPI_ERROR_INVALID_DATA_POINTER = 308, |
979 | /** Packet ordering error for stream read/write. */ | 980 | /** Packet ordering error for stream read/write. */ |
@@ -1010,6 +1011,7 @@ enum HPI_ERROR_CODES { | |||
1010 | HPI_ERROR_CONTROL_DISABLED = 404, | 1011 | HPI_ERROR_CONTROL_DISABLED = 404, |
1011 | /** I2C transaction failed due to a missing ACK. */ | 1012 | /** I2C transaction failed due to a missing ACK. */ |
1012 | HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, | 1013 | HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, |
1014 | HPI_ERROR_I2C_MISSING_ACK = 405, | ||
1013 | /** Control is busy, or coming out of | 1015 | /** Control is busy, or coming out of |
1014 | reset and cannot be accessed at this time. */ | 1016 | reset and cannot be accessed at this time. */ |
1015 | HPI_ERROR_CONTROL_NOT_READY = 407, | 1017 | HPI_ERROR_CONTROL_NOT_READY = 407, |
@@ -1020,7 +1022,6 @@ enum HPI_ERROR_CODES { | |||
1020 | HPI_ERROR_NVMEM_FAIL = 452, | 1022 | HPI_ERROR_NVMEM_FAIL = 452, |
1021 | 1023 | ||
1022 | /** I2C */ | 1024 | /** I2C */ |
1023 | HPI_ERROR_I2C_MISSING_ACK = 405, /*HPI_ERROR_CONTROL_I2C_MISSING_ACK */ | ||
1024 | HPI_ERROR_I2C_BAD_ADR = 460, | 1025 | HPI_ERROR_I2C_BAD_ADR = 460, |
1025 | 1026 | ||
1026 | /** Entity errors */ | 1027 | /** Entity errors */ |
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c index 43465832a910..9a05672e2302 100644 --- a/sound/pci/asihpi/hpi6000.c +++ b/sound/pci/asihpi/hpi6000.c | |||
@@ -237,10 +237,19 @@ static void control_message(struct hpi_adapter_obj *pao, | |||
237 | switch (phm->function) { | 237 | switch (phm->function) { |
238 | case HPI_CONTROL_GET_STATE: | 238 | case HPI_CONTROL_GET_STATE: |
239 | if (pao->has_control_cache) { | 239 | if (pao->has_control_cache) { |
240 | phr->error = hpi6000_update_control_cache(pao, phm); | 240 | u16 err; |
241 | 241 | err = hpi6000_update_control_cache(pao, phm); | |
242 | if (phr->error) | 242 | |
243 | if (err) { | ||
244 | if (err >= HPI_ERROR_BACKEND_BASE) { | ||
245 | phr->error = | ||
246 | HPI_ERROR_CONTROL_CACHING; | ||
247 | phr->specific_error = err; | ||
248 | } else { | ||
249 | phr->error = err; | ||
250 | } | ||
243 | break; | 251 | break; |
252 | } | ||
244 | 253 | ||
245 | if (hpi_check_control_cache(((struct hpi_hw_obj *) | 254 | if (hpi_check_control_cache(((struct hpi_hw_obj *) |
246 | pao->priv)->p_cache, phm, | 255 | pao->priv)->p_cache, phm, |
@@ -405,7 +414,7 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
405 | struct hpi_adapter_obj ao; | 414 | struct hpi_adapter_obj ao; |
406 | struct hpi_adapter_obj *pao; | 415 | struct hpi_adapter_obj *pao; |
407 | u32 os_error_code; | 416 | u32 os_error_code; |
408 | short error = 0; | 417 | u16 err = 0; |
409 | u32 dsp_index = 0; | 418 | u32 dsp_index = 0; |
410 | 419 | ||
411 | HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n"); | 420 | HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n"); |
@@ -422,10 +431,16 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
422 | /* create the adapter object based on the resource information */ | 431 | /* create the adapter object based on the resource information */ |
423 | ao.pci = *phm->u.s.resource.r.pci; | 432 | ao.pci = *phm->u.s.resource.r.pci; |
424 | 433 | ||
425 | error = create_adapter_obj(&ao, &os_error_code); | 434 | err = create_adapter_obj(&ao, &os_error_code); |
426 | if (error) { | 435 | if (err) { |
427 | delete_adapter_obj(&ao); | 436 | delete_adapter_obj(&ao); |
428 | phr->error = error; | 437 | if (err >= HPI_ERROR_BACKEND_BASE) { |
438 | phr->error = HPI_ERROR_DSP_BOOTLOAD; | ||
439 | phr->specific_error = err; | ||
440 | } else { | ||
441 | phr->error = err; | ||
442 | } | ||
443 | |||
429 | phr->u.s.data = os_error_code; | 444 | phr->u.s.data = os_error_code; |
430 | return; | 445 | return; |
431 | } | 446 | } |
@@ -434,7 +449,7 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
434 | if (!pao) { | 449 | if (!pao) { |
435 | /* We just added this adapter, why can't we find it!? */ | 450 | /* We just added this adapter, why can't we find it!? */ |
436 | HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n"); | 451 | HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n"); |
437 | phr->error = 950; | 452 | phr->error = HPI_ERROR_BAD_ADAPTER; |
438 | return; | 453 | return; |
439 | } | 454 | } |
440 | 455 | ||
@@ -1763,17 +1778,11 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, | |||
1763 | hpios_dsplock_lock(pao); | 1778 | hpios_dsplock_lock(pao); |
1764 | error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr); | 1779 | error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr); |
1765 | 1780 | ||
1766 | /* maybe an error response */ | 1781 | if (error) /* something failed in the HPI/DSP interface */ |
1767 | if (error) { | ||
1768 | /* something failed in the HPI/DSP interface */ | ||
1769 | phr->error = error; | ||
1770 | /* just the header of the response is valid */ | ||
1771 | phr->size = sizeof(struct hpi_response_header); | ||
1772 | goto err; | 1782 | goto err; |
1773 | } | ||
1774 | 1783 | ||
1775 | if (phr->error != 0) /* something failed in the DSP */ | 1784 | if (phr->error) /* something failed in the DSP */ |
1776 | goto err; | 1785 | goto out; |
1777 | 1786 | ||
1778 | switch (phm->function) { | 1787 | switch (phm->function) { |
1779 | case HPI_OSTREAM_WRITE: | 1788 | case HPI_OSTREAM_WRITE: |
@@ -1796,10 +1805,19 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, | |||
1796 | } | 1805 | } |
1797 | } | 1806 | } |
1798 | 1807 | ||
1799 | if (error) | ||
1800 | phr->error = error; | ||
1801 | |||
1802 | err: | 1808 | err: |
1809 | if (error) { | ||
1810 | if (error >= HPI_ERROR_BACKEND_BASE) { | ||
1811 | phr->error = HPI_ERROR_DSP_COMMUNICATION; | ||
1812 | phr->specific_error = error; | ||
1813 | } else { | ||
1814 | phr->error = error; | ||
1815 | } | ||
1816 | |||
1817 | /* just the header of the response is valid */ | ||
1818 | phr->size = sizeof(struct hpi_response_header); | ||
1819 | } | ||
1820 | out: | ||
1803 | hpios_dsplock_unlock(pao); | 1821 | hpios_dsplock_unlock(pao); |
1804 | return; | 1822 | return; |
1805 | } | 1823 | } |
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index a3f650d8b94f..5fe535b1b096 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c | |||
@@ -478,7 +478,12 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
478 | err = create_adapter_obj(&ao, &os_error_code); | 478 | err = create_adapter_obj(&ao, &os_error_code); |
479 | if (err) { | 479 | if (err) { |
480 | delete_adapter_obj(&ao); | 480 | delete_adapter_obj(&ao); |
481 | phr->error = err; | 481 | if (err >= HPI_ERROR_BACKEND_BASE) { |
482 | phr->error = HPI_ERROR_DSP_BOOTLOAD; | ||
483 | phr->specific_error = err; | ||
484 | } else { | ||
485 | phr->error = err; | ||
486 | } | ||
482 | phr->u.s.data = os_error_code; | 487 | phr->u.s.data = os_error_code; |
483 | return; | 488 | return; |
484 | } | 489 | } |
@@ -2242,7 +2247,13 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, | |||
2242 | /* maybe an error response */ | 2247 | /* maybe an error response */ |
2243 | if (err) { | 2248 | if (err) { |
2244 | /* something failed in the HPI/DSP interface */ | 2249 | /* something failed in the HPI/DSP interface */ |
2245 | phr->error = err; | 2250 | if (err >= HPI_ERROR_BACKEND_BASE) { |
2251 | phr->error = HPI_ERROR_DSP_COMMUNICATION; | ||
2252 | phr->specific_error = err; | ||
2253 | } else { | ||
2254 | phr->error = err; | ||
2255 | } | ||
2256 | |||
2246 | pao->dsp_crashed++; | 2257 | pao->dsp_crashed++; |
2247 | 2258 | ||
2248 | /* just the header of the response is valid */ | 2259 | /* just the header of the response is valid */ |