summaryrefslogtreecommitdiff
path: root/sound/soc/omap/abe/abe_ext.c
blob: 21f05d6c4fa2217b73bc1c011b7bc99b0807f7c4 (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
 * ALSA SoC OMAP ABE driver
 *
 * Author:	Laurent Le Faucheur <l-le-faucheur@ti.com>
 *		Liam Girdwood <lrg@slimlogic.co.uk>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */
#include "abe_main.h"
#define ENABLE_DEFAULT_PLAYERS 0
/**
 * abe_default_irq_pingpong_player
 *
 * generates data for the cache-flush buffer MODE 16+16
 */
void abe_default_irq_pingpong_player(void)
{
#if ENABLE_DEFAULT_PLAYERS
#define N_SAMPLES_MAX ((int)(1024))	/* ping-pong access to MM_DL at 48kHz Mono with 20ms packet sizes */
	static s32 idx;
	u32 i, dst, n_samples, n_bytes;
	s32 temp[N_SAMPLES_MAX], audio_sample;
#define DATA_SIZE 20		/* t = [0:N-1]/N; x = round(16383*sin(2*pi*t)) */
	const s32 audio_pattern[DATA_SIZE] = {
		0, 5063, 9630, 13254, 15581, 16383, 15581, 13254, 9630,
		5063, 0, -5063, -9630, -13254, -15581, -16383, -15581,
		-13254, -9630, -5063
	};
#if 0
#define DATA_SIZE 8
	const s32 audio_pattern[DATA_SIZE] = {
		0, 11585, 16384, 11585, 0, -11586, -16384, -11586
	};
#define DATA_SIZE 12
	const s32 audio_pattern[DATA_SIZE] = {
		0, 8191, 14188, 16383, 14188, 8191, 0,
		-8192, -14188, -16383, -14188, -8192
	};
	const s32 audio_pattern[8] = {
		16383, 16383, 16383, 16383, -16384, -16384, -16384, -16384
	};
#endif
	/* read the address of the Pong buffer */
	abe_read_next_ping_pong_buffer(MM_DL_PORT, &dst, &n_bytes);
	/* each stereo sample weights 4 bytes (format 16|16) */
	n_samples = n_bytes / 4;
	/* generate a test pattern */
	for (i = 0; i < n_samples; i++) {
		audio_sample = audio_pattern[idx];
		idx = (idx >= (DATA_SIZE - 1)) ? 0 : (idx + 1);
		/* format 16|16 */
		temp[i] = ((audio_sample << 16) + audio_sample);
	}
	/* copy the pattern (flush it) to DMEM pointer update
	 * not necessary here because the buffer size do not
	 * change from one ping to the other pong
	 */
	abe_block_copy(COPY_FROM_HOST_TO_ABE, ABE_DMEM, dst,
		       (u32 *) &(temp[0]), n_bytes);
	abe_set_ping_pong_buffer(MM_DL_PORT, n_bytes);
#endif
}
/**
 * abe_default_irq_pingpong_player_32bits
 *
 * generates data for the cache-flush buffer  MODE 32 BITS
 * Return value:
 * None.
 */
void abe_default_irq_pingpong_player_32bits(void)
{
#if ENABLE_DEFAULT_PLAYERS
	/* ping-pong access to MM_DL at 48kHz Mono with 20ms packet sizes */
	static s32 idx;
	u32 i, dst, n_samples, n_bytes;
	s32 temp[N_SAMPLES_MAX], audio_sample;
#define DATA_SIZE 20		/*  t = [0:N-1]/N; x = round(16383*sin(2*pi*t)) */
	const s32 audio_pattern[DATA_SIZE] = {
		0, 5063, 9630, 13254, 15581, 16383, 15581, 13254,
		9630, 5063, 0, -5063, -9630, -13254, -15581, -16383,
		-15581, -13254, -9630, -5063
	};
	/* read the address of the Pong buffer */
	abe_read_next_ping_pong_buffer(MM_DL_PORT, &dst, &n_bytes);
	/* each stereo sample weights 8 bytes (format 32|32) */
	n_samples = n_bytes / 8;
	/* generate a test pattern */
	for (i = 0; i < n_samples; i++) {
		/* circular addressing */
		audio_sample = audio_pattern[idx];
		idx = (idx >= (DATA_SIZE - 1)) ? 0 : (idx + 1);
		temp[i * 2 + 0] = (audio_sample << 16);
		temp[i * 2 + 1] = (audio_sample << 16);
	}
	abe_set_ping_pong_buffer(MM_DL_PORT, 0);
	/* copy the pattern (flush it) to DMEM pointer update
	 * not necessary here because the buffer size do not
	 * change from one ping to the other pong
	 */
	abe_block_copy(COPY_FROM_HOST_TO_ABE, ABE_DMEM, dst,
		       (u32 *) &(temp[0]), n_bytes);
	abe_set_ping_pong_buffer(MM_DL_PORT, n_bytes);
#endif
}
/**
 * abe_rshifted16_irq_pingpong_player_32bits
 *
 * generates data for the cache-flush buffer  MODE 32 BITS
 * Return value:
 * None.
 */
void abe_rshifted16_irq_pingpong_player_32bits(void)
{
#if ENABLE_DEFAULT_PLAYERS
	/* ping-pong access to MM_DL at 48kHz Mono with 20ms packet sizes */
	static s32 idx;
	u32 i, dst, n_samples, n_bytes;
	s32 temp[N_SAMPLES_MAX], audio_sample;
#define DATA_SIZE 20		/*  t = [0:N-1]/N; x = round(16383*sin(2*pi*t)) */
	const s32 audio_pattern[DATA_SIZE] = {
		0, 5063, 9630, 13254, 15581, 16383, 15581, 13254,
		9630, 5063, 0, -5063, -9630, -13254, -15581, -16383,
		-15581, -13254, -9630, -5063
	};
	/* read the address of the Pong buffer */
	abe_read_next_ping_pong_buffer(MM_DL_PORT, &dst, &n_bytes);
	/* each stereo sample weights 8 bytes (format 32|32) */
	n_samples = n_bytes / 8;
	/* generate a test pattern */
	for (i = 0; i < n_samples; i++) {
		/* circular addressing */
		audio_sample = audio_pattern[idx];
		idx = (idx >= (DATA_SIZE - 1)) ? 0 : (idx + 1);
		temp[i * 2 + 0] = audio_sample;
		temp[i * 2 + 1] = audio_sample;
	}
	abe_set_ping_pong_buffer(MM_DL_PORT, 0);
	/* copy the pattern (flush it) to DMEM pointer update
	 * not necessary here because the buffer size do not
	 * change from one ping to the other pong
	 */
	abe_block_copy(COPY_FROM_HOST_TO_ABE, ABE_DMEM, dst,
		       (u32 *) &(temp[0]), n_bytes);
	abe_set_ping_pong_buffer(MM_DL_PORT, n_bytes);
#endif
}
/**
 * abe_1616_irq_pingpong_player_1616bits
 *
 * generates data for the cache-flush buffer  MODE 16+16 BITS
 * Return value:
 * None.
 */
void abe_1616_irq_pingpong_player_1616bits(void)
{
#if ENABLE_DEFAULT_PLAYERS
	/* ping-pong access to MM_DL at 48kHz Mono with 20ms packet sizes */
	static s32 idx;
	u32 i, dst, n_samples, n_bytes;
	s32 temp[N_SAMPLES_MAX], audio_sample;
#define DATA_SIZE 20		/*  t = [0:N-1]/N; x = round(16383*sin(2*pi*t)) */
	const s32 audio_pattern[DATA_SIZE] = {
		0, 5063, 9630, 13254, 15581, 16383, 15581, 13254,
		9630, 5063, 0, -5063, -9630, -13254, -15581, -16383,
		-15581, -13254, -9630, -5063
	};
	/* read the address of the Pong buffer */
	abe_read_next_ping_pong_buffer(MM_DL_PORT, &dst, &n_bytes);
	/* each stereo sample weights 4 bytes (format 16+16) */
	n_samples = n_bytes / 4;
	/* generate a test pattern */
	for (i = 0; i < n_samples; i++) {
		/* circular addressing */
		audio_sample = audio_pattern[idx];
		idx = (idx >= (DATA_SIZE - 1)) ? 0 : (idx + 1);
		temp[i] = (audio_sample << 16) | (audio_sample & 0x0000FFFF);
	}
	abe_set_ping_pong_buffer(MM_DL_PORT, 0);
	/* copy the pattern (flush it) to DMEM pointer update
	 * not necessary here because the buffer size do not
	 * change from one ping to the other pong
	 */
	abe_block_copy(COPY_FROM_HOST_TO_ABE, ABE_DMEM, dst,
		       (u32 *) &(temp[0]), n_bytes);
	abe_set_ping_pong_buffer(MM_DL_PORT, n_bytes);
#endif
}
/**
 * abe_default_irq_aps_adaptation
 *
 * updates the APS filter and gain
 */
void abe_default_irq_aps_adaptation(void)
{
}
/**
 * abe_read_sys_clock
 * @time: pointer to the system clock
 *
 * returns the current time indication for the LOG
 */
void abe_read_sys_clock(u32 *time)
{
	static u32 clock;
	*time = clock;
	clock++;
}
/**
 * abe_aps_tuning
 *
 * Tune APS parameters
 *
 */
void abe_aps_tuning(void)
{
}