Developer World
Spresense SDK Library v3.2.0-ebc0364
alworker_comm.h
1/****************************************************************************
2 * modules/include/audiolite/alworker_comm.h
3 *
4 * Copyright 2023 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36#ifndef __AUDIOLITE_INCLUDE_ALWORKER_COMM_H
37#define __AUDIOLITE_INCLUDE_ALWORKER_COMM_H
38
39/****************************************************************************
40 * Included Files
41 ****************************************************************************/
42
43#include <stdint.h>
44#include <stdbool.h>
45
46#ifndef __linux__
47#include <asmp/mpmq.h>
48#ifndef BUILD_TGT_ASMPWORKER
49# include <asmp/mptask.h>
50#endif
51#endif
52
53/****************************************************************************
54 * Pre-processor Definitions
55 ****************************************************************************/
56
57#define AL_COMM_MESSAGE_NONE (0)
58#define AL_COMM_MESSAGE_SYS (1)
59#define AL_COMM_MESSAGE_FMEM (2)
60#define AL_COMM_MESSAGE_OMEM (3)
61#define AL_COMM_MESSAGE_INST (4)
62
63#define AL_COMM_MSGTYPE_NONE (0)
64#define AL_COMM_MSGTYPE_ASYNC (1)
65#define AL_COMM_MSGTYPE_SYNC (2)
66
67#define AL_COMM_MSGCODESYS_NONE (0)
68#define AL_COMM_MSGCODESYS_STOP (1)
69#define AL_COMM_MSGCODESYS_PAUSE (2)
70#define AL_COMM_MSGCODESYS_PLAY (3)
71#define AL_COMM_MSGCODESYS_BOOT (4)
72#define AL_COMM_MSGCODESYS_TERM (5)
73#define AL_COMM_MSGCODESYS_PARAM (6)
74#define AL_COMM_MSGCODESYS_ERR (7)
75#define AL_COMM_MSGCODESYS_DBG (8)
76
77#define AL_COMM_MSGCODEINST_NONE (0)
78#define AL_COMM_MSGCODEINST_START (1)
79#define AL_COMM_MSGCODEINST_STOP (2)
80#define AL_COMM_MSGCODEINST_DONE (3)
81#define AL_COMM_MSGCODEINST_GAIN (4)
82#define AL_COMM_MSGCODEINST_INFO (5)
83
84#define AL_COMM_MSGCODEMEM_NONE (0)
85#define AL_COMM_MSGCODEMEM_INJECT (1)
86#define AL_COMM_MSGCODEMEM_RELEASE (2)
87
88#define AL_COMM_MSGCODEERR_OK (0)
89#define AL_COMM_MSGCODEERR_TOOSHORT (1)
90#define AL_COMM_MSGCODEERR_ILLIGALFRAME (2)
91#define AL_COMM_MSGCODEERR_NOFRAME (3)
92#define AL_COMM_MSGCODEERR_UNKNOWN (4)
93#define AL_COMM_MSGCODEERR_INVALIDADDR (5)
94#define AL_COMM_MSGCODEERR_OVFLOW (6)
95#define AL_COMM_MSGCODEERR_INVALIDINST (7)
96#define AL_COMM_MSGCODEERR_MULTIFRAME (8)
97#define AL_COMM_MSGCODEERR_UNSUPFRAME (9)
98
99#define AL_COMM_ERR_SUCCESS (0)
100#define AL_COMM_ERR_WORKERINIT (-1)
101#define AL_COMM_ERR_WORKERASSIGN (-2)
102#define AL_COMM_ERR_SENDMQCREATE (-3)
103#define AL_COMM_ERR_SENDMQBIND (-4)
104#define AL_COMM_ERR_RECVMQCREATE (-5)
105#define AL_COMM_ERR_EXECWORKER (-6)
106
107#define AL_WORKER_TYPE_MP3DEC (1)
108
109#define AL_WORKER_VERSION_0 (0)
110#define AL_WORKER_VERSION_1 (1)
111
112#define AL_MP3DECWORKER_VERSION AL_WORKER_VERSION_1
113
114#define AL_COMM_NO_MSG (0xffffffff)
115
116#define AL_MSGBUF_DEPTH_POW (4)
117#define AL_MSGBUF_DEPTH (1 << AL_MSGBUF_DEPTH_POW)
118
119/****************************************************************************
120 * Public Types
121 ****************************************************************************/
122
124{
125 struct
126 {
127 unsigned char grp;
128 unsigned char type;
129 unsigned char code;
130 unsigned char opt;
131 };
132 uint32_t u32;
133};
135
137{
138 struct
139 {
140 unsigned char *addr;
141 unsigned int size;
142 int eof;
143#ifdef __linux__
144 unsigned char body[4096];
145#endif
146 };
147 struct
148 {
149 int chs;
150 int hz;
151 int mode;
152 };
153 struct
154 {
155 int dec_chs;
156 int dec_hz;
157 int dec_layer;
158 int dec_kbps;
159 };
160 int errcode;
161 float gain;
162};
164
166{
169};
170typedef struct al_msg_s al_msg_t;
171
173{
174#ifdef __linux__
175 int dmy;
176#else
177#ifndef BUILD_TGT_ASMPWORKER
178 mptask_t wtask;
179 bool is_spk;
180#endif
181 mpmq_t mqsend;
182 struct al_msg_s msg[AL_MSGBUF_DEPTH];
183 int msg_index;
184#endif
185};
186typedef struct al_wtask_s al_wtask_t;
187
188/****************************************************************************
189 * Public Function Prototypes
190 ****************************************************************************/
191
192#ifdef __cplusplus
193extern "C" {
194#endif /* __cplusplus */
195
196void *alworker_addr_convert(void *a);
197int initialize_alworker(al_wtask_t *inst, const char *dspfname, bool is_spk);
198al_comm_msghdr_t al_receive_message(al_wtask_t *inst,
199 al_comm_msgopt_t *opt, int block);
200al_comm_msghdr_t al_receive_messageto(al_wtask_t *inst,
201 al_comm_msgopt_t *opt, int ms);
202int al_send_message(al_wtask_t *inst,
204int finalize_alworker(al_wtask_t *inst);
205
206#ifdef __cplusplus
207}
208#endif /* __cplusplus */
209
210#endif /* __AUDIOLITE_INCLUDE_ALWORKER_COMM_H */
Definition: alworker_comm.h:166
Definition: alworker_comm.h:173
Definition: mpmq.h:77
Definition: mptask.h:248
Definition: alworker_comm.h:124
Definition: alworker_comm.h:137