]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - drivers/sound/sound.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Samsung Electronics
4 * R. Chandrasekar <rcsekar@samsung.com>
10 void sound_create_square_wave(uint sample_rate
, unsigned short *data
, int size
,
11 uint freq
, uint channels
)
13 const unsigned short amplitude
= 16000; /* between 1 and 32767 */
14 const int period
= freq
? sample_rate
/ freq
: 0;
15 const int half
= period
/ 2;
19 /* Make sure we don't overflow our buffer */
26 for (i
= 0; size
&& i
< half
; i
++) {
28 for (j
= 0; j
< channels
; j
++)
31 for (i
= 0; size
&& i
< period
- half
; i
++) {
33 for (j
= 0; j
< channels
; j
++)