mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 05:35:02 -05:00
ibasso: Use generic hosted sysfs accessors
This keeps the enumerated list of sysfs parameters. Change-Id: Ia63549809490eba02b3f75b3d2f95745636e01a9
This commit is contained in:
parent
d65bfff876
commit
7ffdf50ba5
11 changed files with 21 additions and 353 deletions
|
|
@ -2063,6 +2063,7 @@ target/hosted/ibasso/pcm-ibasso.c
|
||||||
target/hosted/ibasso/power-ibasso.c
|
target/hosted/ibasso/power-ibasso.c
|
||||||
target/hosted/ibasso/powermgmt-ibasso.c
|
target/hosted/ibasso/powermgmt-ibasso.c
|
||||||
target/hosted/ibasso/sysfs-ibasso.c
|
target/hosted/ibasso/sysfs-ibasso.c
|
||||||
|
target/hosted/sysfs.c
|
||||||
target/hosted/ibasso/system-ibasso.c
|
target/hosted/ibasso/system-ibasso.c
|
||||||
target/hosted/ibasso/usb-ibasso.c
|
target/hosted/ibasso/usb-ibasso.c
|
||||||
target/hosted/ibasso/vold-ibasso.c
|
target/hosted/ibasso/vold-ibasso.c
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ bool backlight_hw_init(void)
|
||||||
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/bl_power
|
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/bl_power
|
||||||
0: backlight on
|
0: backlight on
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_int(SYSFS_BACKLIGHT_POWER, 0))
|
if(! sysfs_set_int(sysfs_paths[SYSFS_BACKLIGHT_POWER], 0))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not enable backlight.", __func__);
|
DEBUGF("ERROR %s: Can not enable backlight.", __func__);
|
||||||
panicf("ERROR %s: Can not enable backlight.", __func__);
|
panicf("ERROR %s: Can not enable backlight.", __func__);
|
||||||
|
|
@ -79,7 +79,7 @@ void backlight_hw_off(void)
|
||||||
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/bl_power
|
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/bl_power
|
||||||
1: backlight off
|
1: backlight off
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_int(SYSFS_BACKLIGHT_POWER, 1))
|
if(! sysfs_set_int(sysfs_paths[SYSFS_BACKLIGHT_POWER], 1))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not disable backlight.", __func__);
|
DEBUGF("ERROR %s: Can not disable backlight.", __func__);
|
||||||
return;
|
return;
|
||||||
|
|
@ -124,7 +124,7 @@ void backlight_hw_brightness(int brightness)
|
||||||
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/max_brightness
|
/sys/devices/platform/rk29_backlight/backlight/rk28_bl/max_brightness
|
||||||
0 ... 255
|
0 ... 255
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_int(SYSFS_BACKLIGHT_BRIGHTNESS, _current_brightness))
|
if(! sysfs_set_int(sysfs_paths[SYSFS_BACKLIGHT_BRIGHTNESS], _current_brightness))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set brightness.", __func__);
|
DEBUGF("ERROR %s: Can not set brightness.", __func__);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ static bool _hold = false;
|
||||||
bool button_hold(void)
|
bool button_hold(void)
|
||||||
{
|
{
|
||||||
char hold_state;
|
char hold_state;
|
||||||
if(! sysfs_get_char(SYSFS_HOLDKEY, &hold_state))
|
if(! sysfs_get_char(sysfs_paths[SYSFS_HOLDKEY], &hold_state))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not get hold switch state.", __func__);
|
DEBUGF("ERROR %s: Can not get hold switch state.", __func__);
|
||||||
hold_state = HOLD_SWITCH_BIT;
|
hold_state = HOLD_SWITCH_BIT;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ void audiohw_set_volume(int volume)
|
||||||
/dev/codec_volume
|
/dev/codec_volume
|
||||||
0 ... 255
|
0 ... 255
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_int(SYSFS_DX50_CODEC_VOLUME, volume_adjusted))
|
if(! sysfs_set_int(sysfs_paths[SYSFS_DX50_CODEC_VOLUME], volume_adjusted))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set volume.", __func__);
|
DEBUGF("ERROR %s: Can not set volume.", __func__);
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@ void audiohw_set_filter_roll_off(int val)
|
||||||
{
|
{
|
||||||
DEBUGF("DEBUG %s: val: %d", __func__, val);
|
DEBUGF("DEBUG %s: val: %d", __func__, val);
|
||||||
|
|
||||||
if(! sysfs_set_char(SYSFS_ES9018_FILTER, (char) val))
|
if(! sysfs_set_char(sysfs_paths[SYSFS_ES9018_FILTER], (char) val))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set roll off filter.", __func__);
|
DEBUGF("ERROR %s: Can not set roll off filter.", __func__);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void audiohw_set_volume(int volume)
|
||||||
/sys/class/codec/es9018_volume
|
/sys/class/codec/es9018_volume
|
||||||
0 ... 255
|
0 ... 255
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_int(SYSFS_DX90_ES9018_VOLUME, volume_adjusted))
|
if(! sysfs_set_int(sysfs_paths[SYSFS_DX90_ES9018_VOLUME], volume_adjusted))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set volume.", __func__);
|
DEBUGF("ERROR %s: Can not set volume.", __func__);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ void lcd_enable(bool on)
|
||||||
/sys/power/state
|
/sys/power/state
|
||||||
on: Cancel suspend.
|
on: Cancel suspend.
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_string(SYSFS_POWER_STATE, "on"))
|
if(! sysfs_set_string(sysfs_paths[SYSFS_POWER_STATE], "on"))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set power state.", __func__);
|
DEBUGF("ERROR %s: Can not set power state.", __func__);
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +192,7 @@ void lcd_sleep(void)
|
||||||
/sys/power/state
|
/sys/power/state
|
||||||
mem: Suspend to RAM.
|
mem: Suspend to RAM.
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_string(SYSFS_POWER_STATE, "mem"))
|
if(! sysfs_set_string(sysfs_paths[SYSFS_POWER_STATE], "mem"))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set power state.", __func__);
|
DEBUGF("ERROR %s: Can not set power state.", __func__);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
|
||||||
|
|
||||||
DX90?
|
DX90?
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_char(SYSFS_MUTE, 'B'))
|
if(! sysfs_set_char(sysfs_paths[SYSFS_MUTE], 'B'))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Could not unmute.", __func__);
|
DEBUGF("ERROR %s: Could not unmute.", __func__);
|
||||||
panicf("ERROR %s: Could not unmute.", __func__);
|
panicf("ERROR %s: Could not unmute.", __func__);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ int _battery_voltage(void)
|
||||||
/*TRACE;*/
|
/*TRACE;*/
|
||||||
|
|
||||||
if( (_battery_present == -1)
|
if( (_battery_present == -1)
|
||||||
&& (! sysfs_get_int(SYSFS_BATTERY_PRESENT, &_battery_present)))
|
&& (! sysfs_get_int(sysfs_paths[SYSFS_BATTERY_PRESENT], &_battery_present)))
|
||||||
{
|
{
|
||||||
/* This check is only done once at startup. */
|
/* This check is only done once at startup. */
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ int _battery_voltage(void)
|
||||||
/sys/class/power_supply/battery/voltage_now
|
/sys/class/power_supply/battery/voltage_now
|
||||||
Voltage in microvolt.
|
Voltage in microvolt.
|
||||||
*/
|
*/
|
||||||
if(! sysfs_get_int(SYSFS_BATTERY_VOLTAGE_NOW, &val))
|
if(! sysfs_get_int(sysfs_paths[SYSFS_BATTERY_VOLTAGE_NOW], &val))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not get current battery voltage.", __func__);
|
DEBUGF("ERROR %s: Can not get current battery voltage.", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -103,7 +103,7 @@ int _battery_voltage(void)
|
||||||
/sys/class/power_supply/usb/voltage_now
|
/sys/class/power_supply/usb/voltage_now
|
||||||
Voltage in microvolt.
|
Voltage in microvolt.
|
||||||
*/
|
*/
|
||||||
if(! sysfs_get_int(SYSFS_USB_POWER_VOLTAGE_NOW, &val))
|
if(! sysfs_get_int(sysfs_paths[SYSFS_USB_POWER_VOLTAGE_NOW], &val))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not get current USB voltage.", __func__);
|
DEBUGF("ERROR %s: Can not get current USB voltage.", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -125,7 +125,7 @@ bool charging_state(void)
|
||||||
{
|
{
|
||||||
if ((current_tick - last_tick) > HZ/2 ) {
|
if ((current_tick - last_tick) > HZ/2 ) {
|
||||||
char buf[12] = {0};
|
char buf[12] = {0};
|
||||||
sysfs_get_string(SYSFS_BATTERY_STATUS, buf, sizeof(buf));
|
sysfs_get_string(sysfs_paths[SYSFS_BATTERY_STATUS], buf, sizeof(buf));
|
||||||
|
|
||||||
last_tick = current_tick;
|
last_tick = current_tick;
|
||||||
last_power = (strncmp(buf, "Charging", 8) == 0);
|
last_power = (strncmp(buf, "Charging", 8) == 0);
|
||||||
|
|
@ -136,7 +136,7 @@ bool charging_state(void)
|
||||||
unsigned int power_input_status(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
int present = 0;
|
int present = 0;
|
||||||
sysfs_get_int(SYSFS_USB_POWER_ONLINE, &present);
|
sysfs_get_int(sysfs_paths[SYSFS_USB_POWER_ONLINE], &present);
|
||||||
|
|
||||||
return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
|
return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@
|
||||||
#include "debug-ibasso.h"
|
#include "debug-ibasso.h"
|
||||||
#include "sysfs-ibasso.h"
|
#include "sysfs-ibasso.h"
|
||||||
|
|
||||||
|
const char* const sysfs_paths[] =
|
||||||
static const char* const SYSFS_PATHS[] =
|
|
||||||
{
|
{
|
||||||
/* SYSFS_DX50_CODEC_VOLUME */
|
/* SYSFS_DX50_CODEC_VOLUME */
|
||||||
"/dev/codec_volume",
|
"/dev/codec_volume",
|
||||||
|
|
@ -118,291 +117,3 @@ static const char* const SYSFS_PATHS[] =
|
||||||
/* SYSFS_POWER_WAKE_LOCK */
|
/* SYSFS_POWER_WAKE_LOCK */
|
||||||
"/sys/power/wake_lock"
|
"/sys/power/wake_lock"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static FILE* open_read(const char* file_name)
|
|
||||||
{
|
|
||||||
FILE *f = fopen(file_name, "re");
|
|
||||||
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, "we");
|
|
||||||
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:
|
|
||||||
case SYSFS_ES9018_FILTER:
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,7 @@
|
||||||
#ifndef _SYSFS_IBASSO_H_
|
#ifndef _SYSFS_IBASSO_H_
|
||||||
#define _SYSFS_IBASSO_H_
|
#define _SYSFS_IBASSO_H_
|
||||||
|
|
||||||
|
#include "sysfs.h"
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys FS path identifiers.
|
Sys FS path identifiers.
|
||||||
|
|
@ -65,48 +63,6 @@ enum sys_fs_interface_id
|
||||||
SYSFS_POWER_WAKE_LOCK
|
SYSFS_POWER_WAKE_LOCK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const char* const sysfs_paths[];
|
||||||
/*
|
|
||||||
Read a integer value from the sys fs interface given by id.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_get_int(enum sys_fs_interface_id id, int* value);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Write a integer value to the sys fs interface given by id.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_set_int(enum sys_fs_interface_id id, int value);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Read a char value from the sys fs interface given by id.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_get_char(enum sys_fs_interface_id id, char* value);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Write a char value to the sys fs interface given by id.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_set_char(enum sys_fs_interface_id id, char value);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Read a single line of text from the sys fs interface given by id.
|
|
||||||
A newline will be discarded.
|
|
||||||
size: The size of value.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_get_string(enum sys_fs_interface_id id, char* value, int size);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Write text to the sys fs interface given by id.
|
|
||||||
Returns true on success, false else.
|
|
||||||
*/
|
|
||||||
bool sysfs_set_string(enum sys_fs_interface_id id, char* value);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ void system_init(void)
|
||||||
Prevent device from deep sleeping, which will interrupt playback.
|
Prevent device from deep sleeping, which will interrupt playback.
|
||||||
/sys/power/wake_lock
|
/sys/power/wake_lock
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_string(SYSFS_POWER_WAKE_LOCK, "rockbox"))
|
if(! sysfs_set_string(sysfs_paths[SYSFS_POWER_WAKE_LOCK], "rockbox"))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set suspend blocker.", __func__);
|
DEBUGF("ERROR %s: Can not set suspend blocker.", __func__);
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +66,7 @@ void system_init(void)
|
||||||
Prevent device to mute, which will cause tinyalsa pcm_writes to fail.
|
Prevent device to mute, which will cause tinyalsa pcm_writes to fail.
|
||||||
/sys/class/codec/wm8740_mute
|
/sys/class/codec/wm8740_mute
|
||||||
*/
|
*/
|
||||||
if(! sysfs_set_char(SYSFS_WM8740_MUTE, 0))
|
if(! sysfs_set_char(sysfs_paths[SYSFS_WM8740_MUTE], 0))
|
||||||
{
|
{
|
||||||
DEBUGF("ERROR %s: Can not set WM8740 lock.", __func__);
|
DEBUGF("ERROR %s: Can not set WM8740 lock.", __func__);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue