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
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50
|
|
|
|
* Copyright (C) 2014 by Mario Basister: iBasso DX90 port
|
|
|
|
* Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features
|
|
|
|
* Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features
|
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "debug-ibasso.h"
|
|
|
|
#include "sysfs-ibasso.h"
|
|
|
|
|
|
|
|
|
|
|
|
static const char* SYSFS_PATHS[] =
|
|
|
|
{
|
|
|
|
/* SYSFS_DX50_CODEC_VOLUME */
|
|
|
|
"/dev/codec_volume",
|
|
|
|
|
|
|
|
/* SYSFS_HOLDKEY */
|
|
|
|
"/sys/class/axppower/holdkey",
|
|
|
|
|
|
|
|
/* SYSFS_DX90_ES9018_VOLUME */
|
|
|
|
"/sys/class/codec/es9018_volume",
|
|
|
|
|
2015-02-07 12:34:06 +00:00
|
|
|
/* SYSFS_ES9018_FILTER */
|
|
|
|
"/sys/class/codec/es9018_filter",
|
|
|
|
|
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
|
|
|
/* SYSFS_MUTE */
|
|
|
|
"/sys/class/codec/mute",
|
|
|
|
|
|
|
|
/* SYSFS_WM8740_MUTE */
|
|
|
|
"/sys/class/codec/wm8740_mute",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_CAPACITY */
|
|
|
|
"/sys/class/power_supply/battery/capacity",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_CURRENT_NOW */
|
|
|
|
"/sys/class/power_supply/battery/current_now",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_ENERGY_FULL_DESIGN */
|
|
|
|
"/sys/class/power_supply/battery/energy_full_design",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_HEALTH */
|
|
|
|
"/sys/class/power_supply/battery/health",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_MODEL_NAME */
|
|
|
|
"/sys/class/power_supply/battery/model_name",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_ONLINE */
|
|
|
|
"/sys/class/power_supply/battery/online",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_PRESENT */
|
|
|
|
"/sys/class/power_supply/battery/present",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_STATUS */
|
|
|
|
"/sys/class/power_supply/battery/status",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_TECHNOLOGY */
|
|
|
|
"/sys/class/power_supply/battery/technology",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_TEMP */
|
|
|
|
"/sys/class/power_supply/battery/temp",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_TYPE */
|
|
|
|
"/sys/class/power_supply/battery/type",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_VOLTAGE_MAX_DESIGN */
|
|
|
|
"/sys/class/power_supply/battery/voltage_max_design",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_VOLTAGE_MIN_DESIGN */
|
|
|
|
"/sys/class/power_supply/battery/voltage_min_design",
|
|
|
|
|
|
|
|
/* SYSFS_BATTERY_VOLTAGE_NOW */
|
|
|
|
"/sys/class/power_supply/battery/voltage_now",
|
|
|
|
|
|
|
|
/* SYSFS_USB_POWER_CURRENT_NOW */
|
|
|
|
"/sys/class/power_supply/usb/current_now",
|
|
|
|
|
|
|
|
/* SYSFS_USB_POWER_ONLINE */
|
|
|
|
"/sys/class/power_supply/usb/online",
|
|
|
|
|
|
|
|
/* SYSFS_USB_POWER_PRESENT */
|
|
|
|
"/sys/class/power_supply/usb/present",
|
|
|
|
|
|
|
|
/* SYSFS_USB_POWER_VOLTAGE_NOW */
|
|
|
|
"/sys/class/power_supply/usb/voltage_now",
|
|
|
|
|
|
|
|
/* SYSFS_BACKLIGHT_POWER */
|
|
|
|
"/sys/devices/platform/rk29_backlight/backlight/rk28_bl/bl_power",
|
|
|
|
|
|
|
|
/* SYSFS_BACKLIGHT_BRIGHTNESS */
|
|
|
|
"/sys/devices/platform/rk29_backlight/backlight/rk28_bl/brightness",
|
|
|
|
|
|
|
|
/* SYSFS_POWER_STATE */
|
|
|
|
"/sys/power/state",
|
|
|
|
|
|
|
|
/* SYSFS_POWER_WAKE_LOCK */
|
|
|
|
"/sys/power/wake_lock"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static FILE* open_read(const char* file_name)
|
|
|
|
{
|
|
|
|
FILE *f = fopen(file_name, "r");
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Can not open %s for reading.", __func__, file_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FILE* open_write(const char* file_name)
|
|
|
|
{
|
|
|
|
FILE *f = fopen(file_name, "w");
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Can not open %s for writing.", __func__, file_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_get_int(enum sys_fs_interface_id id, int* value)
|
|
|
|
{
|
|
|
|
*value = -1;
|
|
|
|
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_BATTERY_CAPACITY:
|
|
|
|
case SYSFS_BATTERY_CURRENT_NOW:
|
|
|
|
case SYSFS_BATTERY_ENERGY_FULL_DESIGN:
|
|
|
|
case SYSFS_BATTERY_ONLINE:
|
|
|
|
case SYSFS_BATTERY_PRESENT:
|
|
|
|
case SYSFS_BATTERY_TEMP:
|
|
|
|
case SYSFS_BATTERY_VOLTAGE_MAX_DESIGN:
|
|
|
|
case SYSFS_BATTERY_VOLTAGE_MIN_DESIGN:
|
|
|
|
case SYSFS_BATTERY_VOLTAGE_NOW:
|
|
|
|
case SYSFS_USB_POWER_CURRENT_NOW:
|
|
|
|
case SYSFS_USB_POWER_VOLTAGE_NOW:
|
|
|
|
case SYSFS_USB_POWER_ONLINE:
|
|
|
|
case SYSFS_USB_POWER_PRESENT:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s.", __func__, interface);*/
|
|
|
|
|
|
|
|
FILE *f = open_read(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fscanf(f, "%d", value) == EOF)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Read failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_set_int(enum sys_fs_interface_id id, int value)
|
|
|
|
{
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_BACKLIGHT_POWER:
|
|
|
|
case SYSFS_BACKLIGHT_BRIGHTNESS:
|
|
|
|
case SYSFS_DX50_CODEC_VOLUME:
|
|
|
|
case SYSFS_DX90_ES9018_VOLUME:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s, value: %d.", __func__, interface, value);*/
|
|
|
|
|
|
|
|
FILE *f = open_write(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fprintf(f, "%d", value) < 1)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Write failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_get_char(enum sys_fs_interface_id id, char* value)
|
|
|
|
{
|
|
|
|
*value = '\0';
|
|
|
|
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_HOLDKEY:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s.", __func__, interface);*/
|
|
|
|
|
|
|
|
FILE *f = open_read(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fscanf(f, "%c", value) == EOF)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Read failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_set_char(enum sys_fs_interface_id id, char value)
|
|
|
|
{
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_MUTE:
|
|
|
|
case SYSFS_WM8740_MUTE:
|
2015-02-07 12:34:06 +00:00
|
|
|
case SYSFS_ES9018_FILTER:
|
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
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s, value: %c.", __func__, interface, value);*/
|
|
|
|
|
|
|
|
FILE *f = open_write(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fprintf(f, "%c", value) < 1)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Write failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_get_string(enum sys_fs_interface_id id, char* value, int size)
|
|
|
|
{
|
|
|
|
value[0] = '\0';
|
|
|
|
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_BATTERY_STATUS:
|
|
|
|
case SYSFS_BATTERY_HEALTH:
|
|
|
|
case SYSFS_BATTERY_MODEL_NAME:
|
|
|
|
case SYSFS_BATTERY_TECHNOLOGY:
|
|
|
|
case SYSFS_BATTERY_TYPE:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s, size: %d.", __func__, interface, size);*/
|
|
|
|
|
|
|
|
FILE *f = open_read(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fgets(value, size, f) == NULL)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Read failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size_t length = strlen(value);
|
|
|
|
if((length > 0) && value[length - 1] == '\n')
|
|
|
|
{
|
|
|
|
value[length - 1] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool sysfs_set_string(enum sys_fs_interface_id id, char* value)
|
|
|
|
{
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case SYSFS_POWER_STATE:
|
|
|
|
case SYSFS_POWER_WAKE_LOCK:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Unknown interface id: %d.", __func__, id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* interface = SYSFS_PATHS[id];
|
|
|
|
|
|
|
|
/*DEBUGF("%s: interface: %s, value: %s.", __func__, interface, value);*/
|
|
|
|
|
|
|
|
FILE *f = open_write(interface);
|
|
|
|
if(f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
if(fprintf(f, "%s", value) < 1)
|
|
|
|
{
|
|
|
|
DEBUGF("ERROR %s: Write failed for %s.", __func__, interface);
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return success;
|
|
|
|
}
|