summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/sdl.c
blob: eea10ad12c34d4c346e8c46ec078f307ce47e24b (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
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright © 2010 Thomas Martitz
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include <SDL_audio.h>
#include "config.h"
#include "audiohw.h"
#include "pcm_sampr.h"

/**
 * Audio Hardware api. Make them do nothing as we cannot properly simulate with
 * SDL. if we used DSP we would run code that doesn't actually run on the target
 **/

#ifdef HAVE_SW_VOLUME_CONTROL
#include "pcm_sw_volume.h"

void audiohw_set_volume(int vol_l, int vol_r)
{
    pcm_set_master_volume(vol_l, vol_r);
}

#else /* ndef HAVE_SW_VOLUME_CONTROL */

extern void pcm_set_mixer_volume(int);

void audiohw_set_volume(int volume)
{
#if CONFIG_CODEC == SWCODEC
#if !(CONFIG_PLATFORM & PLATFORM_MAEMO5)
    if (volume < VOLUME_MIN)
        volume = 0;
    else
        volume = SDL_MIX_MAXVOLUME * (volume - VOLUME_MIN + ONE_DB) /
                    (VOLUME_RANGE + ONE_DB);
#endif /* !(CONFIG_PLATFORM & PLATFORM_MAEMO5) */

    pcm_set_mixer_volume(volume);
#endif /* CONFIG_CODEC == SWCODEC */
    (void)volume;
}
#endif /* HAVE_SW_VOLUME_CONTROL */

/**
 * stubs here, for the simulator
 **/

#if defined(AUDIOHW_HAVE_PRESCALER)
void audiohw_set_prescaler(int value)
{
#ifdef HAVE_SW_VOLUME_CONTROL
    pcm_set_prescaler(value);
#endif
    (void)value;
}
#endif
#if defined(AUDIOHW_HAVE_BALANCE)
void audiohw_set_balance(int value)     { (void)value; }
#endif
#ifndef HAVE_SW_TONE_CONTROLS
#if defined(AUDIOHW_HAVE_BASS)
void audiohw_set_bass(int value)        { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_TREBLE)
void audiohw_set_treble(int value)      { (void)value; }
#endif
#endif /* HAVE_SW_TONE_CONTROLS */
#if CONFIG_CODEC != SWCODEC
void audiohw_set_channel(int value)     { (void)value; }
void audiohw_set_stereo_width(int value){ (void)value; }
#endif
#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
void audiohw_set_bass_cutoff(int value) { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
void audiohw_set_treble_cutoff(int value){ (void)value; }
#endif
/* EQ-based tone controls */
#if defined(AUDIOHW_HAVE_EQ)
void audiohw_set_eq_band_gain(unsigned int band, int value)
    { (void)band; (void)value; }
#endif
#if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
void audiohw_set_eq_band_frequency(unsigned int band, int value)
    { (void)band; (void)value; }
#endif
#if defined(AUDIOHW_HAVE_EQ_WIDTH)
void audiohw_set_eq_band_width(unsigned int band, int value)
    { (void)band; (void)value; }
#endif
#if defined(AUDIOHW_HAVE_DEPTH_3D)
void audiohw_set_depth_3d(int value)
    { (void)value; }
#endif
#if defined(AUDIOHW_HAVE_LINEOUT)
void audiohw_set_lineout_volume(int vol_l, int vol_r)
    { (void)vol_l; (void)vol_r; }
#endif

void audiohw_close(void) {}

#ifdef CONFIG_SAMPR_TYPES
unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate,
                                   unsigned int type)
    { return samplerate; (void)type; }
#endif /* CONFIG_SAMPR_TYPES */
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
int mas_codec_readreg(int reg)
{
    (void)reg;
    return 0;
}

int mas_codec_writereg(int reg, unsigned int val)
{
    (void)reg;
    (void)val;
    return 0;
}
int mas_writemem(int bank, int addr, const unsigned long* src, int len)
{
    (void)bank;
    (void)addr;
    (void)src;
    (void)len;
    return 0;
}
#endif