Developer World
Spresense SDK Library v3.3.0-375c679
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#define AL_COMM_MESSAGE_USER (5)
63
64#define AL_COMM_MSGTYPE_NONE (0)
65#define AL_COMM_MSGTYPE_ASYNC (1)
66#define AL_COMM_MSGTYPE_SYNC (2)
67#define AL_COMM_MSGTYPE_RESP (3)
68
69#define AL_COMM_MSGCODESYS_NONE (0)
70#define AL_COMM_MSGCODESYS_STOP (1)
71#define AL_COMM_MSGCODESYS_PAUSE (2)
72#define AL_COMM_MSGCODESYS_PLAY (3)
73#define AL_COMM_MSGCODESYS_BOOT (4)
74#define AL_COMM_MSGCODESYS_TERM (5)
75#define AL_COMM_MSGCODESYS_PARAM (6)
76#define AL_COMM_MSGCODESYS_ERR (7)
77#define AL_COMM_MSGCODESYS_DBG (8)
78
79#define AL_COMM_MSGCODEINST_NONE (0)
80#define AL_COMM_MSGCODEINST_START (1)
81#define AL_COMM_MSGCODEINST_STOP (2)
82#define AL_COMM_MSGCODEINST_DONE (3)
83#define AL_COMM_MSGCODEINST_GAIN (4)
84#define AL_COMM_MSGCODEINST_INFO (5)
85
86#define AL_COMM_MSGCODEMEM_NONE (0)
87#define AL_COMM_MSGCODEMEM_INJECT (1)
88#define AL_COMM_MSGCODEMEM_RELEASE (2)
89
90#define AL_COMM_MSGCODEERR_OK (0)
91#define AL_COMM_MSGCODEERR_TOOSHORT (1)
92#define AL_COMM_MSGCODEERR_ILLIGALFRAME (2)
93#define AL_COMM_MSGCODEERR_NOFRAME (3)
94#define AL_COMM_MSGCODEERR_UNKNOWN (4)
95#define AL_COMM_MSGCODEERR_INVALIDADDR (5)
96#define AL_COMM_MSGCODEERR_OVFLOW (6)
97#define AL_COMM_MSGCODEERR_INVALIDINST (7)
98#define AL_COMM_MSGCODEERR_MULTIFRAME (8)
99#define AL_COMM_MSGCODEERR_UNSUPFRAME (9)
100#define AL_COMM_MSGCODEERR_INVALIDSTATE (10)
101
102#define AL_COMM_ERR_SUCCESS (0)
103#define AL_COMM_ERR_WORKERINIT (-1)
104#define AL_COMM_ERR_WORKERASSIGN (-2)
105#define AL_COMM_ERR_SENDMQCREATE (-3)
106#define AL_COMM_ERR_SENDMQBIND (-4)
107#define AL_COMM_ERR_RECVMQCREATE (-5)
108#define AL_COMM_ERR_EXECWORKER (-6)
109
110#define AL_WORKER_TYPE_MP3DEC (1)
111
112#define AL_WORKER_VERSION_0 (0)
113#define AL_WORKER_VERSION_1 (1)
114#define AL_WORKER_VERSION_2 (2)
115
116#define AL_MP3DECWORKER_VERSION AL_WORKER_VERSION_2
117
118#define AL_COMM_NO_MSG (0xffffffff)
119
120#define AL_MSGBUF_DEPTH_POW (4)
121#define AL_MSGBUF_DEPTH (1 << AL_MSGBUF_DEPTH_POW)
122
123#define AL_COMM_MSGGRP(h) ((h)->grp)
124#define AL_COMM_MSGTYPE(h) ((h)->type)
125#define AL_COMM_MSGCODE(h) ((h)->code)
126#define AL_COMM_MSGOPT(h) ((h)->opt)
127
128/****************************************************************************
129 * Public Types
130 ****************************************************************************/
131
133{
134 struct
135 {
136 unsigned char grp;
137 unsigned char type;
138 unsigned char code;
139 unsigned char opt;
140 };
141 uint32_t u32;
142};
144
146{
147 struct
148 {
149 unsigned char *addr;
150 unsigned int size;
151 int eof;
152#ifdef __linux__
153 unsigned char body[4096];
154#endif
155 };
156 struct
157 {
158 int chs;
159 int hz;
160 int mode;
161 };
162 struct
163 {
164 int dec_chs;
165 int dec_hz;
166 int dec_layer;
167 int dec_kbps;
168 };
169 int errcode;
170 float gain;
171 int usr[4];
172};
174
176{
179};
180typedef struct al_msg_s al_msg_t;
181
183{
184#ifdef __linux__
185 int dmy;
186#else
187#ifndef BUILD_TGT_ASMPWORKER
188 mptask_t wtask;
189 bool is_spk;
190#endif
191 mpmq_t mqsend;
192 struct al_msg_s msg[AL_MSGBUF_DEPTH];
193 int msg_index;
194#endif
195};
196typedef struct al_wtask_s al_wtask_t;
197
198/****************************************************************************
199 * Public Function Prototypes
200 ****************************************************************************/
201
202#ifdef __cplusplus
203extern "C" {
204#endif /* __cplusplus */
205
206void *alworker_addr_convert(void *a);
207int initialize_alworker(al_wtask_t *inst, const char *dspfname, bool is_spk);
208al_comm_msghdr_t al_receive_message(al_wtask_t *inst,
209 al_comm_msgopt_t *opt, int block);
210al_comm_msghdr_t al_receive_messageto(al_wtask_t *inst,
211 al_comm_msgopt_t *opt, int ms);
212int al_send_message(al_wtask_t *inst,
214int finalize_alworker(al_wtask_t *inst);
215
216#ifdef __cplusplus
217}
218#endif /* __cplusplus */
219
220#endif /* __AUDIOLITE_INCLUDE_ALWORKER_COMM_H */
Definition: alworker_comm.h:176
Definition: alworker_comm.h:183
Definition: mpmq.h:77
Definition: mptask.h:248
Definition: alworker_comm.h:133
Definition: alworker_comm.h:146