2011-06-29 06:37:04 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 by Michael Sevakis
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef PCM_MIXER_H
|
|
|
|
#define PCM_MIXER_H
|
|
|
|
|
2012-05-02 21:22:28 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2011-06-29 06:37:04 +00:00
|
|
|
/** Simple config **/
|
|
|
|
|
|
|
|
/* Length of PCM frames (always) */
|
|
|
|
#if CONFIG_CPU == PP5002
|
|
|
|
/* There's far less time to do mixing because HW FIFOs are short */
|
|
|
|
#define MIX_FRAME_SAMPLES 64
|
2020-09-04 19:55:11 +00:00
|
|
|
#elif (CONFIG_CPU == JZ4760B) || (CONFIG_CPU == JZ4732)
|
|
|
|
/* These MIPS32r1 targets have a very high interrupt latency, which
|
|
|
|
unfortunately causes a lot of audio underruns under even moderate load */
|
|
|
|
#define MIX_FRAME_SAMPLES 2048
|
iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization
- Separated iBasso devices from PLATFORM_ANDROID. These are now standlone
hosted targets. Most device specific code is in the
firmware/target/hosted/ibasso directory.
- No dependency on Android SDK, only the Android NDK is needed.
32 bit Android NDK and Android API Level 16.
- Separate implementation for each device where feasible.
Code cleanup
- Rewrite of existing code, from simple reformat to complete reimplementation.
- New backlight interface, seperating backlight from touchscreen.
- Rewrite of device button handler, removing unneeded code and fixing memory
leaks.
- New Debug messages interface logging to Android adb logcat (DEBUGF, panicf,
logf).
- Rewrite of lcd device handler, removing unneeded code and fixing memory leaks.
- Rewrite of audiohw device handler/pcm interface, removing unneeded code and
fixing memory leaks, enabling 44.1/48kHz pthreaded playback.
- Rewrite of power and powermng, proper shutdown, using batterylog results
(see http://gerrit.rockbox.org/r/#/c/1047/).
- Rewrite of configure (Android NDK) and device specific config.
- Rewrite of the Android NDK specific Makefile.
Misc
- All plugins/games/demos activated.
- Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa.
Includes
- http://gerrit.rockbox.org/r/#/c/993/
- http://gerrit.rockbox.org/r/#/c/1010/
- http://gerrit.rockbox.org/r/#/c/1035/
Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight
interface and new option for hold switch, touchscreen, physical button
interaction.
Rockbox needs the iBasso DX50/DX90 loader for startup, see
http://gerrit.rockbox.org/r/#/c/1099/
The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If
/mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit
gracefully and the loader will restart Rockbox on USB disconnect.
Tested on iBasso DX50.
Compiled (not tested) for iBasso DX90.
Compiled (not tested) for PLATFORM_ANDROID.
Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
2015-02-02 20:44:29 +00:00
|
|
|
#elif (CONFIG_PLATFORM & PLATFORM_MAEMO5) || defined(DX50) || defined(DX90)
|
2011-12-09 20:04:41 +00:00
|
|
|
/* Maemo 5 needs 2048 samples for decent performance.
|
|
|
|
Otherwise the locking overhead inside gstreamer costs too much */
|
iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization
- Separated iBasso devices from PLATFORM_ANDROID. These are now standlone
hosted targets. Most device specific code is in the
firmware/target/hosted/ibasso directory.
- No dependency on Android SDK, only the Android NDK is needed.
32 bit Android NDK and Android API Level 16.
- Separate implementation for each device where feasible.
Code cleanup
- Rewrite of existing code, from simple reformat to complete reimplementation.
- New backlight interface, seperating backlight from touchscreen.
- Rewrite of device button handler, removing unneeded code and fixing memory
leaks.
- New Debug messages interface logging to Android adb logcat (DEBUGF, panicf,
logf).
- Rewrite of lcd device handler, removing unneeded code and fixing memory leaks.
- Rewrite of audiohw device handler/pcm interface, removing unneeded code and
fixing memory leaks, enabling 44.1/48kHz pthreaded playback.
- Rewrite of power and powermng, proper shutdown, using batterylog results
(see http://gerrit.rockbox.org/r/#/c/1047/).
- Rewrite of configure (Android NDK) and device specific config.
- Rewrite of the Android NDK specific Makefile.
Misc
- All plugins/games/demos activated.
- Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa.
Includes
- http://gerrit.rockbox.org/r/#/c/993/
- http://gerrit.rockbox.org/r/#/c/1010/
- http://gerrit.rockbox.org/r/#/c/1035/
Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight
interface and new option for hold switch, touchscreen, physical button
interaction.
Rockbox needs the iBasso DX50/DX90 loader for startup, see
http://gerrit.rockbox.org/r/#/c/1099/
The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If
/mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit
gracefully and the loader will restart Rockbox on USB disconnect.
Tested on iBasso DX50.
Compiled (not tested) for iBasso DX90.
Compiled (not tested) for PLATFORM_ANDROID.
Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
2015-02-02 20:44:29 +00:00
|
|
|
/* iBasso Devices: Match Rockbox PCM buffer size to ALSA PCM buffer size
|
|
|
|
to minimize memory transfers. */
|
2011-12-09 20:04:41 +00:00
|
|
|
#define MIX_FRAME_SAMPLES 2048
|
2020-11-18 19:08:17 +00:00
|
|
|
#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
|
|
|
/* Hosted targets need larger buffers for decent performance due to
|
|
|
|
OS locking/scheduling overhead */
|
|
|
|
#define MIX_FRAME_SAMPLES 1024
|
iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization
- Separated iBasso devices from PLATFORM_ANDROID. These are now standlone
hosted targets. Most device specific code is in the
firmware/target/hosted/ibasso directory.
- No dependency on Android SDK, only the Android NDK is needed.
32 bit Android NDK and Android API Level 16.
- Separate implementation for each device where feasible.
Code cleanup
- Rewrite of existing code, from simple reformat to complete reimplementation.
- New backlight interface, seperating backlight from touchscreen.
- Rewrite of device button handler, removing unneeded code and fixing memory
leaks.
- New Debug messages interface logging to Android adb logcat (DEBUGF, panicf,
logf).
- Rewrite of lcd device handler, removing unneeded code and fixing memory leaks.
- Rewrite of audiohw device handler/pcm interface, removing unneeded code and
fixing memory leaks, enabling 44.1/48kHz pthreaded playback.
- Rewrite of power and powermng, proper shutdown, using batterylog results
(see http://gerrit.rockbox.org/r/#/c/1047/).
- Rewrite of configure (Android NDK) and device specific config.
- Rewrite of the Android NDK specific Makefile.
Misc
- All plugins/games/demos activated.
- Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa.
Includes
- http://gerrit.rockbox.org/r/#/c/993/
- http://gerrit.rockbox.org/r/#/c/1010/
- http://gerrit.rockbox.org/r/#/c/1035/
Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight
interface and new option for hold switch, touchscreen, physical button
interaction.
Rockbox needs the iBasso DX50/DX90 loader for startup, see
http://gerrit.rockbox.org/r/#/c/1099/
The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If
/mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit
gracefully and the loader will restart Rockbox on USB disconnect.
Tested on iBasso DX50.
Compiled (not tested) for iBasso DX90.
Compiled (not tested) for PLATFORM_ANDROID.
Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
2015-02-02 20:44:29 +00:00
|
|
|
#else
|
2011-06-29 06:37:04 +00:00
|
|
|
/* Assume HW DMA engine is available or sufficient latency exists in the
|
|
|
|
PCM pathway */
|
|
|
|
#define MIX_FRAME_SAMPLES 256
|
|
|
|
#endif
|
|
|
|
|
2012-05-05 02:00:44 +00:00
|
|
|
#if defined(CPU_COLDFIRE) || defined(CPU_PP)
|
2011-06-29 06:37:04 +00:00
|
|
|
/* For Coldfire, it's just faster
|
|
|
|
For PortalPlayer, this also avoids more expensive cache coherency */
|
2011-06-29 09:39:13 +00:00
|
|
|
#define DOWNMIX_BUF_IBSS IBSS_ATTR
|
2011-06-29 06:37:04 +00:00
|
|
|
#else
|
|
|
|
/* Otherwise can't DMA from IRAM, IRAM is pointless or worse */
|
|
|
|
#define DOWNMIX_BUF_IBSS
|
|
|
|
#endif
|
|
|
|
|
2011-06-29 09:39:13 +00:00
|
|
|
#if defined(CPU_COLDFIRE) || defined(CPU_PP)
|
|
|
|
#define MIXER_CALLBACK_ICODE ICODE_ATTR
|
|
|
|
#else
|
|
|
|
#define MIXER_CALLBACK_ICODE
|
|
|
|
#endif
|
|
|
|
|
2011-06-29 06:37:04 +00:00
|
|
|
|
|
|
|
/** Definitions **/
|
|
|
|
|
|
|
|
/* Channels are preassigned for simplicity */
|
|
|
|
enum pcm_mixer_channel
|
|
|
|
{
|
|
|
|
PCM_MIXER_CHAN_PLAYBACK = 0,
|
|
|
|
PCM_MIXER_CHAN_VOICE,
|
|
|
|
#ifndef HAVE_HARDWARE_BEEP
|
|
|
|
PCM_MIXER_CHAN_BEEP,
|
|
|
|
#endif
|
|
|
|
/* Add new channel indexes above this line */
|
|
|
|
PCM_MIXER_NUM_CHANNELS,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Channel playback states */
|
|
|
|
enum channel_status
|
|
|
|
{
|
|
|
|
CHANNEL_STOPPED = 0,
|
|
|
|
CHANNEL_PLAYING,
|
|
|
|
CHANNEL_PAUSED,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MIX_AMP_UNITY 0x00010000
|
|
|
|
#define MIX_AMP_MUTE 0x00000000
|
|
|
|
|
|
|
|
|
|
|
|
/** Public interfaces **/
|
|
|
|
|
|
|
|
/* Start playback on a channel */
|
|
|
|
void mixer_channel_play_data(enum pcm_mixer_channel channel,
|
|
|
|
pcm_play_callback_type get_more,
|
2012-02-23 13:14:46 +00:00
|
|
|
const void *start, size_t size);
|
2011-06-29 06:37:04 +00:00
|
|
|
|
|
|
|
/* Pause or resume a channel (when started) */
|
|
|
|
void mixer_channel_play_pause(enum pcm_mixer_channel channel, bool play);
|
|
|
|
|
|
|
|
/* Stop playback on a channel */
|
|
|
|
void mixer_channel_stop(enum pcm_mixer_channel channel);
|
|
|
|
|
|
|
|
/* Set channel's amplitude factor */
|
|
|
|
void mixer_channel_set_amplitude(enum pcm_mixer_channel channel,
|
|
|
|
unsigned int amplitude);
|
|
|
|
|
|
|
|
/* Return channel's playback status */
|
|
|
|
enum channel_status mixer_channel_status(enum pcm_mixer_channel channel);
|
|
|
|
|
|
|
|
/* Returns amount data remaining in channel before next callback */
|
|
|
|
size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel);
|
|
|
|
|
|
|
|
/* Return pointer to channel's playing audio data and the size remaining */
|
2012-12-02 06:09:44 +00:00
|
|
|
const void * mixer_channel_get_buffer(enum pcm_mixer_channel channel,
|
|
|
|
int *count);
|
2011-06-29 06:37:04 +00:00
|
|
|
|
2011-07-02 11:55:38 +00:00
|
|
|
/* Calculate peak values for channel */
|
|
|
|
void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel,
|
2012-05-03 00:53:07 +00:00
|
|
|
struct pcm_peaks *peaks);
|
2011-07-02 11:55:38 +00:00
|
|
|
|
2012-05-02 21:22:28 +00:00
|
|
|
/* Adjust channel pointer by a given offset to support movable buffers */
|
|
|
|
void mixer_adjust_channel_address(enum pcm_mixer_channel channel,
|
|
|
|
off_t offset);
|
|
|
|
|
2012-12-02 06:09:44 +00:00
|
|
|
/* Set a hook that is called upon getting a new source buffer for a channel
|
|
|
|
NOTE: Called for each buffer, not each mixer chunk */
|
|
|
|
typedef void (*chan_buffer_hook_fn_type)(const void *start, size_t size);
|
|
|
|
|
|
|
|
void mixer_channel_set_buffer_hook(enum pcm_mixer_channel channel,
|
|
|
|
chan_buffer_hook_fn_type fn);
|
|
|
|
|
2011-06-29 06:37:04 +00:00
|
|
|
/* Stop ALL channels and PCM and reset state */
|
|
|
|
void mixer_reset(void);
|
|
|
|
|
2013-05-23 17:58:51 +00:00
|
|
|
/* Set output samplerate */
|
|
|
|
void mixer_set_frequency(unsigned int samplerate);
|
|
|
|
|
|
|
|
/* Get output samplerate */
|
|
|
|
unsigned int mixer_get_frequency(void);
|
|
|
|
|
2011-06-29 06:37:04 +00:00
|
|
|
#endif /* PCM_MIXER_H */
|