summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/fsl_dsp_xaf_api.h
blob: 7b2dfa48977dc2e130a1bff5c34848c0d67b56ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT)*/
/*
 * Xtensa Audio Framework API for communication with DSP
 *
 * Copyright (C) 2017 Cadence Design Systems, Inc.
 * Copyright 2018 NXP
 */
#ifndef FSL_DSP_XAF_API_H
#define FSL_DSP_XAF_API_H

#include "fsl_dsp_library_load.h"

/* ...size of auxiliary pool for communication with DSP */
#define XA_AUX_POOL_SIZE	32

/* ...length of auxiliary pool messages */
#define XA_AUX_POOL_MSG_LENGTH	128

/* ...number of max input buffers */
#define INBUF_SIZE	4096
/* ...buffer size of the buffer shared between A core and DSP. Use large */
/* ...to let A core suspend longer time to save power.*/
#define INBUF_SIZE_LPA	(128*1024)
/* ...ping-pong buffer locate in DRAM for PCM LPA. */
#define INBUF_SIZE_LPA_PCM	(8*1024*1024)
#define OUTBUF_SIZE	16384

struct xaf_pipeline;

struct xaf_info_s {
	u32 opcode;
	void *buf;
	u32 length;
	u32 ret;
};

struct xaf_comp {
	struct xaf_comp *next;

	struct xaf_pipeline *pipeline;
	struct xf_handle handle;

	const char *dec_id;
	int comp_type;

	struct xf_pool *inpool;
	struct xf_pool *outpool;
	void *inptr;
	void *outptr;

	struct lib_info codec_lib;
	struct lib_info codec_wrap_lib;

	int active; /* component fully initialized */
};

struct xaf_pipeline {
	struct xaf_comp *comp_chain;

	u32 input_eos;
	u32 output_eos;
};

int xaf_comp_create(struct xf_client *client, struct xf_proxy *p_proxy,
		    struct xaf_comp *p_comp, int comp_type);
int xaf_comp_delete(struct xf_client *client, struct xaf_comp *p_comp);
int xaf_comp_flush(struct xf_client *client, struct xaf_comp *p_comp);

int xaf_comp_set_config(struct xf_client *client,struct xaf_comp *p_comp,
			u32 num_param, void *p_param);
int xaf_comp_get_config(struct xf_client *client,struct xaf_comp *p_comp,
			u32 num_param, void *p_param);

int xaf_comp_add(struct xaf_pipeline *p_pipe, struct xaf_comp *p_comp);
int xaf_comp_process(struct xf_client *client, struct xaf_comp *p_comp,
		     void *p_buf, u32 length, u32 flag);
int xaf_comp_get_status(struct xaf_comp *p_comp, struct xaf_info_s *p_info);
int xaf_comp_get_msg_count(struct xaf_comp *p_comp);

int xaf_connect(struct xf_client *client,struct xaf_comp *p_src,
		struct xaf_comp *p_dest, u32 num_buf, u32 buf_length);
int xaf_disconnect(struct xf_client *client,struct xaf_comp *p_comp);

int xaf_pipeline_create(struct xaf_pipeline *p_pipe);
int xaf_pipeline_delete(struct xaf_pipeline *p_pipe);

int xaf_pipeline_send_eos(struct xaf_pipeline *p_pipe);

/* ...port routing command */
struct __attribute__((__packed__)) xf_route_port_msg {
	/* ...source port specification */
	u32 src;
	/* ...destination port specification */
	u32 dst;
	/* ...number of buffers to allocate */
	u32 alloc_number;
	/* ...length of buffer to allocate */
	u32 alloc_size;
	/* ...alignment restriction for a buffer */
	u32 alloc_align;
};

/* ...port unrouting command */
struct __attribute__((__packed__)) xf_unroute_port_msg {
	/* ...source port specification */
	u32 src;
	/* ...destination port specification */
	u32 dst;
};

/* ...check if non-zero value is a power-of-two */
#define xf_is_power_of_two(v)       (((v) & ((v) - 1)) == 0)


/*******************************************************************************
 * bascial message
 ******************************************************************************/
typedef union DATA {
	u32                 value;

	struct {
		u32 size;
		u32 channel_table[10];
	} chan_map_tab;

	struct {
		u32 samplerate;
		u32 width;
		u32 depth;
		u32 channels;
		u32 endian;
		u32 interleave;
		u32 layout[12];
		u32 chan_pos_set;  // indicate if channel position is set outside or use codec default
	} outputFormat;
} data_t;

/* ...component initialization parameter */
struct __attribute__((__packed__)) xf_set_param_msg {
	/* ...index of parameter passed to SET_CONFIG_PARAM call */
	u32 id;
	/* ...value of parameter */
	data_t mixData;
};

/* ...message body (command/response) */
struct __attribute__((__packed__)) xf_get_param_msg {
	/* ...array of parameters requested */
	u32 id;
	/* ...array of parameters values */
	data_t mixData;
};

/* ...renderer-specific configuration parameters */
enum xa_config_param_renderer {
	XA_RENDERER_CONFIG_PARAM_CB             = 0,
	XA_RENDERER_CONFIG_PARAM_STATE          = 1,
	XA_RENDERER_CONFIG_PARAM_PCM_WIDTH      = 2,
	XA_RENDERER_CONFIG_PARAM_CHANNELS       = 3,
	XA_RENDERER_CONFIG_PARAM_SAMPLE_RATE    = 4,
	XA_RENDERER_CONFIG_PARAM_FRAME_SIZE     = 5,
	XA_RENDERER_CONFIG_PARAM_CONSUMED       = 6,
	XA_RENDERER_CONFIG_PARAM_NUM            = 7,
};

/* pcm codec configuration parameters */
enum xa_config_param_pcm {
	XA_PCM_CONFIG_PARAM_SAMPLE_RATE         = 0, /* not supported */
	XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH        = 1,
	XA_PCM_CONFIG_PARAM_IN_CHANNELS         = 2, /* not supported */
	XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH       = 3, /* not supported */
	XA_PCM_CONFIG_PARAM_OUT_CHANNELS        = 4, /* not supported */
	XA_PCM_CONFIG_PARAM_CHANROUTING         = 5, /* not supported */
	XA_PCM_CONFIG_PARAM_FUNC_PRINT          = 13, /* not supported */
	XA_PCM_CONFIG_PARAM_NUM                 = 14, /* not supported */
};

#endif /* FSL_DSP_XAF_API_H */