1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 
5 #ifndef AUDIO_RTOS_H
6 #define AUDIO_RTOS_H
7 
8 #include <stdio.h>
9 #include <stdbool.h>
10 #include "audio_drv.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef void* pcm_stream_handler_t;
17 
18 typedef enum {
19     PCM_STREAM_IN = 0,
20     PCM_STREAM_OUT = 1,
21 } pcm_stream_dir_t;
22 
23 typedef enum {
24     /** Signed, 8-bit */
25     PCM_STREAM_FORMAT_S8 = 1,
26     /** Signed 16-bit, little endian */
27     PCM_STREAM_FORMAT_S16_LE = 0,
28     /** Signed, 16-bit, big endian */
29     PCM_STREAM_FORMAT_S16_BE = 2,
30     /** Signed, 24-bit (32-bit in memory), little endian */
31     PCM_STREAM_FORMAT_S24_LE,
32     /** Signed, 24-bit (32-bit in memory), big endian */
33     PCM_STREAM_FORMAT_S24_BE,
34     /** Signed, 24-bit, little endian */
35     PCM_STREAM_FORMAT_S24_3LE,
36     /** Signed, 24-bit, big endian */
37     PCM_STREAM_FORMAT_S24_3BE,
38     /** Signed, 32-bit, little endian */
39     PCM_STREAM_FORMAT_S32_LE,
40     /** Signed, 32-bit, big endian */
41     PCM_STREAM_FORMAT_S32_BE,
42     /** Max of the enumeration list, not an actual format. */
43     PCM_STREAM_FORMAT_MAX
44 } pcm_stream_format_t;
45 
46 typedef struct {
47     pcm_stream_handler_t (*open)(int mode, int sampleRate, int channels, int format, aos_hdl_t *event_hdl);
48     int (*start)(pcm_stream_handler_t hdl);
49     int (*write)(pcm_stream_handler_t hdl, void *buf, unsigned int len);
50     int (*read)(pcm_stream_handler_t hdl, void *buf, unsigned int len);
51     int (*pause)(pcm_stream_handler_t hdl, int enable);
52     int (*stop)(pcm_stream_handler_t hdl);
53     int (*close)(pcm_stream_handler_t hdl);
54     int (*recover)(pcm_stream_handler_t hdl);
55     int (*suspend)(pcm_stream_handler_t hdl);
56     int (*resume)(pcm_stream_handler_t hdl);
57 } pcm_stream_ops_t;
58 
59 typedef struct {
60     pcm_stream_dir_t mode;
61     audio_hw_params_t params;
62     audio_sw_params_t swParams;
63     bool isOpenState;
64     pcm_stream_ops_t *ops;
65     pcm_stream_handler_t hdl;
66     void *parent_data;
67 } native_pcm_device_t;
68 
69 int audio_native_card_register(int rec_num, int spk_num, pcm_stream_ops_t *ops, const struct audio_kcontrol_new *controls, int controls_num);
70 
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* AUDIO_RTOS_H */