]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
dm: sandbox: Allow selection of sample rate and channels
authorSimon Glass <sjg@chromium.org>
Mon, 10 Dec 2018 17:37:50 +0000 (10:37 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 13 Dec 2018 23:37:09 +0000 (16:37 -0700)
At present these parameters are hard-coded in the sdl interface code.
Allow them to be specified by the driver instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/sdl.c
arch/sandbox/include/asm/sdl.h
drivers/sound/sandbox.c

index 47b706513e4c298c00f11250de1655842beb29eb..f668f5379a4d648dc0cba4586da8ec72e93e2252 100644 (file)
@@ -9,10 +9,6 @@
 #include <SDL/SDL.h>
 #include <asm/state.h>
 
-enum {
-       SAMPLE_RATE     = 22050,
-};
-
 /**
  * struct buf_info - a data buffer holding audio data
  *
@@ -285,7 +281,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len)
        }
 }
 
-int sandbox_sdl_sound_init(void)
+int sandbox_sdl_sound_init(int rate, int channels)
 {
        SDL_AudioSpec wanted;
        int i;
@@ -297,9 +293,9 @@ int sandbox_sdl_sound_init(void)
                return 0;
 
        /* Set the audio format */
-       wanted.freq = SAMPLE_RATE;
+       wanted.freq = rate;
        wanted.format = AUDIO_S16;
-       wanted.channels = 1;    /* 1 = mono, 2 = stereo */
+       wanted.channels = channels;
        wanted.samples = 1024;  /* Good low-latency value for callback */
        wanted.callback = sandbox_sdl_fill_audio;
        wanted.userdata = NULL;
index 2799a8bee0690ba1e0ceb4d6b6bbcd61216e1e90..1027b59e7326b8d99e5748ceb514e1dff4460452 100644 (file)
@@ -71,9 +71,11 @@ int sandbox_sdl_sound_stop(void);
 /**
  * sandbox_sdl_sound_init() - set up the sound system
  *
+ * @rate:      Sample rate to use
+ * @channels:  Number of channels to use (1=mono, 2=stereo)
  * @return 0 if OK, -ENODEV if no sound is available
  */
-int sandbox_sdl_sound_init(void);
+int sandbox_sdl_sound_init(int rate, int channels);
 
 #else
 static inline int sandbox_sdl_init_display(int width, int height,
@@ -112,7 +114,7 @@ static inline int sandbox_sdl_sound_stop(void)
        return -ENODEV;
 }
 
-static inline int sandbox_sdl_sound_init(void)
+int sandbox_sdl_sound_init(int rate, int channels)
 {
        return -ENODEV;
 }
index 089d830972731cfeb0555e3a74da4beda6eae24f..b0b07f3239ba86cb1a97bcd33499db3a2e86f6e5 100644 (file)
@@ -102,7 +102,7 @@ static int sandbox_i2s_probe(struct udevice *dev)
        uc_priv->id = 1;
 
        /* Ignore any error here - we'll just have no sound */
-       sandbox_sdl_sound_init();
+       sandbox_sdl_sound_init(uc_priv->samplingrate, uc_priv->channels);
 
        return 0;
 }