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 /******************************************************************************* 24 * xa-mixer-api.h 25 * 26 * Mixer component API 27 * 28 ******************************************************************************/ 29 30 #ifndef __XA_MIXER_API_H__ 31 #define __XA_MIXER_API_H__ 32 33 /******************************************************************************* 34 * Includes 35 ******************************************************************************/ 36 37 #include "xa_type_def.h" 38 #include "xa_error_standards.h" 39 #include "xa_apicmd_standards.h" 40 #include "xa_memory_standards.h" 41 42 /******************************************************************************* 43 * Constants definitions 44 ******************************************************************************/ 45 46 /* ...mixer-specific configuration parameters */ 47 enum xa_config_param_mixer { 48 XA_MIXER_CONFIG_PARAM_INPUT_TRACKS = 0, 49 XA_MIXER_CONFIG_PARAM_PCM_WIDTH = 1, 50 XA_MIXER_CONFIG_PARAM_CHANNELS = 2, 51 XA_MIXER_CONFIG_PARAM_SAMPLE_RATE = 4, 52 XA_MIXER_CONFIG_PARAM_FRAME_SIZE = 5, 53 XA_MIXER_CONFIG_PARAM_BUFFER_SIZE = 6, 54 XA_MIXER_CONFIG_PARAM_VOLUME = 7, 55 XA_MIXER_CONFIG_PARAM_NUM = 8 56 }; 57 58 /* ...component identifier (informative) */ 59 #define XA_CODEC_MIXER 1 60 61 /* ...global limitation - maximal mixer track number */ 62 #define XA_MIXER_MAX_TRACK_NUMBER 4 63 64 /* ...volume representation */ 65 #define __XA_MIXER_VOLUME(v) \ 66 ({ u32 __v = (u32)((v) * (1 << 12)); (__v > 0xFFFF ? __v = 0xFFFF : 0); (u16)__v; }) 67 68 /* ...mixer volume setting command encoding */ 69 #define XA_MIXER_VOLUME(track, channel, volume) \ 70 (__XA_MIXER_VOLUME(volume) | ((track) << 16) | ((channel) << 20)) 71 72 /******************************************************************************* 73 * Class 0: API Errors 74 ******************************************************************************/ 75 76 #define XA_MIXER_API_NONFATAL(e) \ 77 XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_MIXER, (e)) 78 79 #define XA_MIXER_API_FATAL(e) \ 80 XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_MIXER, (e)) 81 82 enum xa_error_nonfatal_api_mixer { 83 XA_MIXER_API_NONFATAL_MAX = XA_MIXER_API_NONFATAL(0) 84 }; 85 86 enum xa_error_fatal_api_mixer { 87 XA_MIXER_API_FATAL_MAX = XA_MIXER_API_FATAL(0) 88 }; 89 90 /******************************************************************************* 91 * Class 1: Configuration Errors 92 ******************************************************************************/ 93 94 #define XA_MIXER_CONFIG_NONFATAL(e) \ 95 XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_MIXER, (e)) 96 97 #define XA_MIXER_CONFIG_FATAL(e) \ 98 XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_MIXER, (e)) 99 100 enum xa_error_nonfatal_config_mixer { 101 XA_MIXER_CONFIG_NONFATAL_RANGE = XA_MIXER_CONFIG_NONFATAL(0), 102 XA_MIXER_CONFIG_NONFATAL_STATE = XA_MIXER_CONFIG_NONFATAL(1), 103 XA_MIXER_CONFIG_NONFATAL_MAX = XA_MIXER_CONFIG_NONFATAL(2) 104 }; 105 106 enum xa_error_fatal_config_mixer { 107 XA_MIXER_CONFIG_FATAL_RANGE = XA_MIXER_CONFIG_FATAL(0), 108 XA_MIXER_CONFIG_FATAL_TRACK_STATE = XA_MIXER_CONFIG_FATAL(0 + XA_MIXER_CONFIG_NONFATAL_MAX), 109 XA_MIXER_CONFIG_FATAL_MAX = XA_MIXER_CONFIG_FATAL(1) 110 }; 111 112 /******************************************************************************* 113 * Class 2: Execution Class Errors 114 ******************************************************************************/ 115 116 #define XA_MIXER_EXEC_NONFATAL(e) \ 117 XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_MIXER, (e)) 118 119 #define XA_MIXER_EXEC_FATAL(e) \ 120 XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_MIXER, (e)) 121 122 enum xa_error_nonfatal_execute_mixer { 123 XA_MIXER_EXEC_NONFATAL_STATE = XA_MIXER_EXEC_NONFATAL(0), 124 XA_MIXER_EXEC_NONFATAL_NO_DATA = XA_MIXER_EXEC_NONFATAL(1), 125 XA_MIXER_EXEC_NONFATAL_INPUT = XA_MIXER_EXEC_NONFATAL(2), 126 XA_MIXER_EXEC_NONFATAL_OUTPUT = XA_MIXER_EXEC_NONFATAL(3), 127 XA_MIXER_EXEC_NONFATAL_MAX = XA_MIXER_EXEC_NONFATAL(4) 128 }; 129 130 enum xa_error_fatal_execute_mixer { 131 XA_MIXER_EXEC_FATAL_STATE = XA_MIXER_EXEC_FATAL(0), 132 XA_MIXER_EXEC_FATAL_INPUT = XA_MIXER_EXEC_FATAL(1), 133 XA_MIXER_EXEC_FATAL_OUTPUT = XA_MIXER_EXEC_FATAL(2), 134 XA_MIXER_EXEC_FATAL_MAX = XA_MIXER_EXEC_FATAL(3) 135 }; 136 137 /******************************************************************************* 138 * API function definition (tbd) 139 ******************************************************************************/ 140 141 #if defined(USE_DLL) && defined(_WIN32) 142 #define DLL_SHARED __declspec(dllimport) 143 #elif defined (_WINDLL) 144 #define DLL_SHARED __declspec(dllexport) 145 #else 146 #define DLL_SHARED 147 #endif 148 149 #if defined(__cplusplus) 150 extern "C" { 151 #endif /* __cplusplus */ 152 DLL_SHARED xa_codec_func_t xa_mixer; 153 #if defined(__cplusplus) 154 } 155 #endif /* __cplusplus */ 156 157 #endif /* __XA_MIXER_API_H__ */ 158