New port: Anbernic RG Nano

A bit of context, this device is a clone of the FunKey-S with a different form factor, hardware is mostly identical, the relevant difference is it has audio out (via usb-c, adapter to 3.5mm is included), this is the reason why the FunKey-SDK is needed for bulding.

This port is based on the old SDL 1.2 code because the device doesn't have SDL2 support. Alongside what was supported in the SDL 1.2 builds this port supports battery level, charging status and backlight control.

Change-Id: I7fcb85be62748644b667c0efebabf59d6e9c5ade
This commit is contained in:
Hairo R. Carela 2025-07-14 23:04:37 -04:00 committed by Solomon Peachy
parent 9d3e286454
commit 48392bab94
94 changed files with 1517 additions and 29 deletions

View file

@ -0,0 +1,39 @@
/***************************************************************************
* __________ __ ___
* 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.
*
****************************************************************************/
#ifndef _BACKLIGHT_TARGET_H_
#define _BACKLIGHT_TARGET_H_
#include <stdbool.h>
/* See backlight.c */
bool backlight_hw_init(void);
void backlight_hw_on(void);
void backlight_hw_off(void);
void backlight_hw_brightness(int brightness);
#endif

View file

@ -0,0 +1,73 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2025 Hairo R. Carela
*
* 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.
*
***************************************************9*************************/
#include <stdio.h>
#include <SDL.h>
#include "button.h"
#include "button-target.h"
int key_to_button(int keyboard_key)
{
int new_btn = BUTTON_NONE;
switch (keyboard_key)
{
case SDLK_s:
new_btn = BUTTON_START;
break;
case SDLK_k:
new_btn = BUTTON_FN;
break;
case SDLK_a:
new_btn = BUTTON_A;
break;
case SDLK_b:
new_btn = BUTTON_B;
break;
case SDLK_x:
new_btn = BUTTON_X;
break;
case SDLK_y:
new_btn = BUTTON_Y;
break;
case SDLK_m:
new_btn = BUTTON_L;
break;
case SDLK_n:
new_btn = BUTTON_R;
break;
case SDLK_u:
new_btn = BUTTON_UP;
break;
case SDLK_d:
new_btn = BUTTON_DOWN;
break;
case SDLK_l:
new_btn = BUTTON_LEFT;
break;
case SDLK_r:
new_btn = BUTTON_RIGHT;
break;
default:
break;
}
return new_btn;
}

View file

@ -0,0 +1,47 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2025 Hairo R. Carela
*
* 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 _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
/* Main unit's buttons */
#define BUTTON_START 0x00000001
#define BUTTON_FN 0x00000002
#define BUTTON_A 0x00000004
#define BUTTON_B 0x00000008
#define BUTTON_X 0x00000010
#define BUTTON_Y 0x00000020
#define BUTTON_L 0x00000040
#define BUTTON_R 0x00000080
#define BUTTON_UP 0x00000100
#define BUTTON_DOWN 0x00000200
#define BUTTON_LEFT 0x00000400
#define BUTTON_RIGHT 0x00000800
#define BUTTON_MAIN 0x1FFF
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 10
int key_to_button(int keyboard_key);
#endif /* _BUTTON_TARGET_H_ */

View file

@ -0,0 +1,41 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2025 Hairo R. Carela
*
* 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 <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include "system.h"
#include "power-rgnano.h"
#include "power.h"
#include "panic.h"
#include "sysfs.h"
const char * const sysfs_bat_level =
"/sys/class/power_supply/axp20x-battery/capacity";
unsigned int rgnano_power_get_battery_capacity(void)
{
int battery_level;
sysfs_get_int(sysfs_bat_level, &battery_level);
return battery_level;
}

View file

@ -0,0 +1,27 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2025 Hairo R. Carela
*
* 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 _POWER_RGNANO_H_
#define _POWER_RGNANO_H_
#include <stdbool.h>
#include "config.h"
unsigned int rgnano_power_get_battery_capacity(void);
#endif /* _POWER_RGNANO_H_ */

View file

@ -0,0 +1,28 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2025 Hairo R. Carela
*
* 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 "powermgmt.h"
#include "power.h"
#include "power-rgnano.h"
int _battery_level(void)
{
return rgnano_power_get_battery_capacity();
}

View file

@ -0,0 +1,7 @@
#ifndef __SYSTEM_TARGET_H__
#define __SYSTEM_TARGET_H__
#include "../sdl/system-sdl.h"
#define NEED_GENERIC_BYTESWAPS
#endif /* __SYSTEM_TARGET_H__ */