projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sound: tegra: Add a sound driver
[oweals/u-boot.git]
/
drivers
/
sound
/
sound.c
diff --git
a/drivers/sound/sound.c
b/drivers/sound/sound.c
index 9dda2dba822aa8bc0a4aaf504130f1bfaddfc530..dd3f9db4f7547da4b45491eb44e8dd906062e504 100644
(file)
--- a/
drivers/sound/sound.c
+++ b/
drivers/sound/sound.c
@@
-1,18
+1,17
@@
+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2012 Samsung Electronics
* R. Chandrasekar <rcsekar@samsung.com>
/*
* Copyright (C) 2012 Samsung Electronics
* R. Chandrasekar <rcsekar@samsung.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <sound.h>
*/
#include <common.h>
#include <sound.h>
-void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)
+void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
+ uint freq, uint channels)
{
{
- const int sample = 48000;
const unsigned short amplitude = 16000; /* between 1 and 32767 */
const unsigned short amplitude = 16000; /* between 1 and 32767 */
- const int period = freq ? sample / freq : 0;
+ const int period = freq ? sample
_rate
/ freq : 0;
const int half = period / 2;
assert(freq);
const int half = period / 2;
assert(freq);
@@
-22,16
+21,17
@@
void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)
size--;
while (size) {
size--;
while (size) {
- int i;
+ int i, j;
+
for (i = 0; size && i < half; i++) {
size -= 2;
for (i = 0; size && i < half; i++) {
size -= 2;
- *data++ = amplitude;
- *data++ = amplitude;
+ for (j = 0; j < channels; j++)
+
*data++ = amplitude;
}
for (i = 0; size && i < period - half; i++) {
size -= 2;
}
for (i = 0; size && i < period - half; i++) {
size -= 2;
- *data++ = -amplitude;
- *data++ = -amplitude;
+ for (j = 0; j < channels; j++)
+
*data++ = -amplitude;
}
}
}
}
}
}