Niranjan Yadla | cee816e | 2018-04-19 12:03:47 -0700 | [diff] [blame^] | 1 | /******************************************************************************* |
| 2 | * Copyright (C) 2018 Cadence Design Systems, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to use this Software with Cadence processor cores only and |
| 7 | * not with any other processors and platforms, subject to |
| 8 | * the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included |
| 11 | * in all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 14 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 15 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 18 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 19 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 | |
| 21 | ******************************************************************************/ |
| 22 | |
| 23 | #ifndef __XA_MIXER_API_H__ |
| 24 | #define __XA_MIXER_API_H__ |
| 25 | |
| 26 | /******************************************************************************* |
| 27 | * Includes |
| 28 | ******************************************************************************/ |
| 29 | |
| 30 | /* ...generic commands */ |
| 31 | #include "xa_apicmd_standards.h" |
| 32 | |
| 33 | /* ...generic error codes */ |
| 34 | #include "xa_error_standards.h" |
| 35 | |
| 36 | /* ...common types */ |
| 37 | #include "xa_type_def.h" |
| 38 | |
| 39 | /******************************************************************************* |
| 40 | * Constants definitions |
| 41 | ******************************************************************************/ |
| 42 | |
| 43 | /* ...mixer-specific configuration parameters */ |
| 44 | enum xa_config_param_mixer { |
| 45 | XA_MIXER_CONFIG_PARAM_INPUT_TRACKS = 0, |
| 46 | XA_MIXER_CONFIG_PARAM_PCM_WIDTH = 1, |
| 47 | XA_MIXER_CONFIG_PARAM_CHANNELS = 2, |
| 48 | XA_MIXER_CONFIG_PARAM_SAMPLE_RATE = 4, |
| 49 | XA_MIXER_CONFIG_PARAM_FRAME_SIZE = 5, |
| 50 | XA_MIXER_CONFIG_PARAM_BUFFER_SIZE = 6, |
| 51 | XA_MIXER_CONFIG_PARAM_VOLUME = 7, |
| 52 | XA_MIXER_CONFIG_PARAM_NUM = 8 |
| 53 | }; |
| 54 | |
| 55 | /* ...component identifier (informative) */ |
| 56 | #define XA_CODEC_MIXER 1 |
| 57 | |
| 58 | /* ...global limitation - maximal mixer track number */ |
| 59 | #define XA_MIXER_MAX_TRACK_NUMBER 4 |
| 60 | |
| 61 | /* ...volume representation */ |
| 62 | #define __XA_MIXER_VOLUME(v) \ |
| 63 | ({ u32 __v = (u32)((v) * (1 << 12)); (__v > 0xFFFF ? __v = 0xFFFF : 0); (u16)__v; }) |
| 64 | |
| 65 | /* ...mixer volume setting command encoding */ |
| 66 | #define XA_MIXER_VOLUME(track, channel, volume) \ |
| 67 | (__XA_MIXER_VOLUME(volume) | ((track) << 16) | ((channel) << 20)) |
| 68 | |
| 69 | /******************************************************************************* |
| 70 | * Class 0: API Errors |
| 71 | ******************************************************************************/ |
| 72 | |
| 73 | #define XA_MIXER_API_NONFATAL(e) \ |
| 74 | XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_MIXER, (e)) |
| 75 | |
| 76 | #define XA_MIXER_API_FATAL(e) \ |
| 77 | XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_MIXER, (e)) |
| 78 | |
| 79 | enum xa_error_nonfatal_api_mixer { |
| 80 | XA_MIXER_API_NONFATAL_MAX = XA_MIXER_API_NONFATAL(0) |
| 81 | }; |
| 82 | |
| 83 | enum xa_error_fatal_api_mixer { |
| 84 | XA_MIXER_API_FATAL_MAX = XA_MIXER_API_FATAL(0) |
| 85 | }; |
| 86 | |
| 87 | /******************************************************************************* |
| 88 | * Class 1: Configuration Errors |
| 89 | ******************************************************************************/ |
| 90 | |
| 91 | #define XA_MIXER_CONFIG_NONFATAL(e) \ |
| 92 | XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_MIXER, (e)) |
| 93 | |
| 94 | #define XA_MIXER_CONFIG_FATAL(e) \ |
| 95 | XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_MIXER, (e)) |
| 96 | |
| 97 | enum xa_error_nonfatal_config_mixer { |
| 98 | XA_MIXER_CONFIG_NONFATAL_RANGE = XA_MIXER_CONFIG_NONFATAL(0), |
| 99 | XA_MIXER_CONFIG_NONFATAL_STATE = XA_MIXER_CONFIG_NONFATAL(1), |
| 100 | XA_MIXER_CONFIG_NONFATAL_MAX = XA_MIXER_CONFIG_NONFATAL(2) |
| 101 | }; |
| 102 | |
| 103 | enum xa_error_fatal_config_mixer { |
| 104 | XA_MIXER_CONFIG_FATAL_RANGE = XA_MIXER_CONFIG_FATAL(0), |
| 105 | XA_MIXER_CONFIG_FATAL_TRACK_STATE = XA_MIXER_CONFIG_FATAL(0 + XA_MIXER_CONFIG_NONFATAL_MAX), |
| 106 | XA_MIXER_CONFIG_FATAL_MAX = XA_MIXER_CONFIG_FATAL(1) |
| 107 | }; |
| 108 | |
| 109 | /******************************************************************************* |
| 110 | * Class 2: Execution Class Errors |
| 111 | ******************************************************************************/ |
| 112 | |
| 113 | #define XA_MIXER_EXEC_NONFATAL(e) \ |
| 114 | XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_MIXER, (e)) |
| 115 | |
| 116 | #define XA_MIXER_EXEC_FATAL(e) \ |
| 117 | XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_MIXER, (e)) |
| 118 | |
| 119 | enum xa_error_nonfatal_execute_mixer { |
| 120 | XA_MIXER_EXEC_NONFATAL_STATE = XA_MIXER_EXEC_NONFATAL(0), |
| 121 | XA_MIXER_EXEC_NONFATAL_NO_DATA = XA_MIXER_EXEC_NONFATAL(1), |
| 122 | XA_MIXER_EXEC_NONFATAL_INPUT = XA_MIXER_EXEC_NONFATAL(2), |
| 123 | XA_MIXER_EXEC_NONFATAL_OUTPUT = XA_MIXER_EXEC_NONFATAL(3), |
| 124 | XA_MIXER_EXEC_NONFATAL_MAX = XA_MIXER_EXEC_NONFATAL(4) |
| 125 | }; |
| 126 | |
| 127 | enum xa_error_fatal_execute_mixer { |
| 128 | XA_MIXER_EXEC_FATAL_STATE = XA_MIXER_EXEC_FATAL(0), |
| 129 | XA_MIXER_EXEC_FATAL_INPUT = XA_MIXER_EXEC_FATAL(1), |
| 130 | XA_MIXER_EXEC_FATAL_OUTPUT = XA_MIXER_EXEC_FATAL(2), |
| 131 | XA_MIXER_EXEC_FATAL_MAX = XA_MIXER_EXEC_FATAL(3) |
| 132 | }; |
| 133 | |
| 134 | /******************************************************************************* |
| 135 | * API function definition (tbd) |
| 136 | ******************************************************************************/ |
| 137 | |
| 138 | #if defined(USE_DLL) && defined(_WIN32) |
| 139 | #define DLL_SHARED __declspec(dllimport) |
| 140 | #elif defined (_WINDLL) |
| 141 | #define DLL_SHARED __declspec(dllexport) |
| 142 | #else |
| 143 | #define DLL_SHARED |
| 144 | #endif |
| 145 | |
| 146 | #if defined(__cplusplus) |
| 147 | extern "C" { |
| 148 | #endif /* __cplusplus */ |
| 149 | DLL_SHARED xa_codec_func_t xa_mixer; |
| 150 | #if defined(__cplusplus) |
| 151 | } |
| 152 | #endif /* __cplusplus */ |
| 153 | |
| 154 | #endif /* __XA_MIXER_API_H__ */ |