summaryrefslogtreecommitdiff
path: root/drivers/sound/sound.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-11-15 19:56:13 -0700
committerSimon Glass <sjg@chromium.org>2018-11-29 09:30:05 -0700
commit7d92b0609093a047ce4b113d77ccd3cc78325e8f (patch)
tree4afa25f53b27bf4f76cac7e0a80ef8bb1de36242 /drivers/sound/sound.c
parent03f11e87a86307903f40e74495936184063bab79 (diff)
downloadu-boot-7d92b0609093a047ce4b113d77ccd3cc78325e8f.tar.gz
sound: Add sample rate as a parameter for square wave
At present this value is hard-coded in the function that generates a square wave. Since sample rates vary between different hardware, it makes more sense to have this as a parameter. Update the function and its users. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/sound/sound.c')
-rw-r--r--drivers/sound/sound.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 6c1eb4c19c..4f0ad0d8f0 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -7,11 +7,11 @@
#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)
{
- const int sample = 48000;
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);