mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
rgnano: Sleep timer and idle poweroff support
Actually power off the handheld with the sleep timer and idle poweroff functions instead of closing rockbox. This commit also moves setting system volume to max from the launch script to system-sdl.c so it works when running rockbox via instant play. Change-Id: I174b67c6abef451faa05f4a8f52b8d9eeed98a22
This commit is contained in:
parent
5ecb5832e1
commit
c9e16e4888
6 changed files with 38 additions and 28 deletions
|
@ -80,27 +80,32 @@ void ip_reset_values(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ip_power_off(void)
|
||||
{
|
||||
/* Stop the powerdown countdown */
|
||||
system("powerdown handle");
|
||||
|
||||
/* Write the instant_play file */
|
||||
char buf[60];
|
||||
size_t nbytes;
|
||||
int fd;
|
||||
|
||||
fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640);
|
||||
|
||||
strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n");
|
||||
nbytes = strlen(buf);
|
||||
write(fd, buf, nbytes);
|
||||
|
||||
close(fd);
|
||||
|
||||
/* Powerdown the handheld after writting the file */
|
||||
system("powerdown now");
|
||||
}
|
||||
|
||||
void ip_handle_sigusr1(int sig)
|
||||
{
|
||||
if (sig == SIGUSR1)
|
||||
{
|
||||
/* Stop the powerdown countdown */
|
||||
system("powerdown handle");
|
||||
|
||||
/* Write the instant_play file */
|
||||
char buf[60];
|
||||
size_t nbytes;
|
||||
int fd;
|
||||
|
||||
fd = open("/mnt/instant_play", O_WRONLY | O_CREAT, 0640);
|
||||
|
||||
strcpy(buf, "'/opk/rockbox' &\npid record $!\nwait $!\npid erase\n");
|
||||
nbytes = strlen(buf);
|
||||
write(fd, buf, nbytes);
|
||||
|
||||
close(fd);
|
||||
|
||||
/* Powerdown the handheld after writting the file */
|
||||
system("powerdown now");
|
||||
ip_power_off();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef _INSTANT_PLAY_H_
|
||||
#define _INSTANT_PLAY_H_
|
||||
|
||||
void ip_handle_sigusr1(int sig);
|
||||
void ip_reset_values(void);
|
||||
void ip_power_off(void);
|
||||
void ip_handle_sigusr1(int sig);
|
||||
#endif /* _INSTANT_PLAY_H_ */
|
||||
|
|
|
@ -586,16 +586,18 @@ static void button_event(int key, bool pressed)
|
|||
return;
|
||||
#endif
|
||||
#endif
|
||||
#if (CONFIG_PLATFORM & PLATFORM_PANDORA) || defined(RG_NANO)
|
||||
#ifdef RG_NANO
|
||||
case SDLK_q:
|
||||
#else
|
||||
#if (CONFIG_PLATFORM & PLATFORM_PANDORA)
|
||||
case SDLK_LCTRL:
|
||||
#endif
|
||||
/* Will post SDL_USEREVENT in shutdown_hw() if successful. */
|
||||
sys_poweroff();
|
||||
break;
|
||||
#endif
|
||||
#ifdef RG_NANO
|
||||
case SDLK_q:
|
||||
/* Use reboot to exit without shutting down */
|
||||
sys_reboot();
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_BUTTON_HOLD
|
||||
case SDLK_h:
|
||||
if(pressed)
|
||||
|
|
|
@ -202,6 +202,7 @@ void power_off(void)
|
|||
#if defined(RG_NANO) && !defined(SIMULATOR)
|
||||
/* Reset volume/brightness to the values before launching rockbox */
|
||||
ip_reset_values();
|
||||
ip_power_off();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDL_THREADS
|
||||
|
@ -252,6 +253,9 @@ void system_init(void)
|
|||
#endif
|
||||
|
||||
#if defined(RG_NANO) && !defined(SIMULATOR)
|
||||
/* Set system volume to max with amixer */
|
||||
system("amixer -q sset 'Headphone' 63 unmute");
|
||||
|
||||
/* Instant play handling */
|
||||
struct sigaction ip_sa;
|
||||
ip_sa.sa_handler = ip_handle_sigusr1;
|
||||
|
@ -305,6 +309,8 @@ void system_reboot(void)
|
|||
#if defined(RG_NANO) && !defined(SIMULATOR)
|
||||
/* Reset volume/brightness to the values before launching rockbox */
|
||||
ip_reset_values();
|
||||
SDL_Quit();
|
||||
exit(EXIT_SUCCESS);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDL_THREADS
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# .cfg file created by rockbox c145f41658-250621 - http://www.rockbox.org
|
||||
|
||||
idle poweroff: 0
|
||||
font: /FunKey/.rockbox/fonts/16-GNU-Unifont.fnt
|
||||
database scan paths: /Music
|
||||
qs top: brightness
|
||||
|
|
|
@ -39,9 +39,6 @@ if [ ! -f $CFGFILE ]; then
|
|||
cp ./config.cfg $CFGFILE
|
||||
fi
|
||||
|
||||
# Set volume to max with amixer so it's not permanent
|
||||
amixer -q sset 'Headphone' 63 unmute
|
||||
|
||||
# Need to send SIGUSR1 to the rockbox process for instant play support
|
||||
trap _send_sigusr1 SIGUSR1
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue