• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* ...number of max input buffers */
25 #define XAF_MAX_INBUFS                      2
26 #define XAF_INBUF_SIZE                      8192
27 
28 typedef enum {
29     XAF_DECODER         = 0,
30     XAF_ENCODER         = 1,
31     XAF_MIXER           = 2,
32     XAF_PRE_PROC        = 3,
33     XAF_POST_PROC       = 4,
34 } xaf_comp_type;
35 
36 typedef enum {
37     XAF_STARTING        = 0,
38     XAF_INIT_DONE       = 1,
39     XAF_NEED_INPUT      = 2,
40     XAF_OUTPUT_READY    = 3,
41     XAF_EXEC_DONE       = 4,
42 } xaf_comp_status;
43 
44 typedef enum {
45     XAF_START_FLAG          = 1,
46     XAF_EXEC_FLAG           = 2,
47     XAF_INPUT_OVER_FLAG     = 3,
48     XAF_INPUT_READY_FLAG    = 4,
49     XAF_NEED_OUTPUT_FLAG    = 5,
50 } xaf_comp_flag;
51 
52 typedef enum {
53     XAF_NO_ERROR        =  0,
54     XAF_PTR_ERROR       = -1,
55     XAF_INVALID_VALUE   = -2,
56     XAF_ROUTING_ERROR   = -3,
57     /*XAF_XOS_ERROR       = -4,*/
58     XAF_API_ERR         = -5,
59 } XAF_ERR_CODE;
60 
61 typedef enum {
62     XAF_MEM_ID_DEV  = 0,
63     XAF_MEM_ID_COMP = 1,
64 } XAF_MEM_ID;
65 
66 /* structure for component memory sizes */
67 typedef struct xaf_mem_size_s{
68     u32 persist;
69     u32 scratch;
70     u32 input;
71     u32 output;
72 }xaf_mem_size_t;
73 
74 /* structure for host-side utility handles */
75 typedef struct xaf_ap_utils_s{
76   int            xf_cfg_remote_ipc_pool_size;
77   xaf_mem_size_t mem_size;
78 }xaf_ap_utils_t;
79 
80 typedef struct xaf_format_s {
81     u32             sample_rate;
82     u32             channels;
83     u32             pcm_width;
84     u32             input_length;
85     u32             output_length;
86 } xaf_format_t;
87 
88 #ifndef XAF_HOSTLESS
89 typedef struct xaf_info_s {
90     void *          buf;
91     u32             length;
92 } xaf_info_t;
93 #endif
94 
95 XAF_ERR_CODE xaf_adev_open(void **pp_adev, s32 audio_frmwk_buf_size, s32 audio_comp_buf_size, xaf_mem_malloc_fxn_t mm_malloc, xaf_mem_free_fxn_t mm_free);
96 XAF_ERR_CODE xaf_adev_close(void *adev_ptr, xaf_comp_flag flag);
97 
98 XAF_ERR_CODE xaf_comp_create(void* p_adev, void **p_comp, xf_id_t comp_id, u32 ninbuf, u32 noutbuf, void *pp_inbuf[], xaf_comp_type comp_type);
99 XAF_ERR_CODE xaf_comp_delete(void* p_comp);
100 XAF_ERR_CODE xaf_comp_set_config(void *p_comp, s32 num_param, s32 *p_param);
101 XAF_ERR_CODE xaf_comp_get_config(void *p_comp, s32 num_param, s32 *p_param);
102 XAF_ERR_CODE xaf_comp_process(void *p_adev, void *p_comp, void *p_buf, u32 length, xaf_comp_flag flag);
103 XAF_ERR_CODE xaf_connect(void *p_src, void *p_dest, s32 num_buf);
104 
105 /* Not available in this version yet.
106 XAF_ERR_CODE xaf_disconnect(xaf_comp_t *p_comp);
107 */
108 
109 XAF_ERR_CODE xaf_comp_get_status(void *p_adev, void *p_comp, xaf_comp_status *p_status, xaf_info_t *p_info);
110 
111 /* ...check null pointer */
112 #define XAF_CHK_PTR(ptr)                                     \
113 ({                                                          \
114     int __ret;                                              \
115                                                             \
116     if ((__ret = (int)(ptr)) == 0)                          \
117     {                                                       \
118         TRACE(ERROR, _x("Null pointer error: %d"), __ret);  \
119         return XAF_PTR_ERROR;                               \
120     }                                                       \
121     __ret;                                                  \
122 })
123 
124 /* ...check range */
125 #define XAF_CHK_RANGE(val, min, max)                         \
126 ({                                                          \
127     int __ret = val;                                        \
128                                                             \
129     if ((__ret < (int)min) || (__ret > (int)max))           \
130     {                                                       \
131         TRACE(ERROR, _x("Invalid value: %d"), __ret);       \
132         return XAF_INVALID_VALUE;                           \
133     }                                                       \
134     __ret;                                                  \
135 })
136 
137 
138 
139 
140