WIP hosted port to the Surfans F28

* Only bootloader builds
 * Plugins disabled
 * No keymaps to anything else
 * No simulator
 * Touchscreen not wired up yet
 * Audio still untested

Bugs:

 * rotary encoder does nothing in bootloader
   (might be bootloader bug, might be something else)

Other stuff pulled in:

 * Unify all of the (identical!) hibyos makefiles
 * Rename the "bootloader" to more generic name

Change-Id: I6d8a3b58de726db8e89cf193c90960a070a575c2
This commit is contained in:
Solomon Peachy 2025-05-01 21:58:50 -04:00
parent 3270daf2c4
commit 82f3d0c18f
27 changed files with 730 additions and 127 deletions

View file

@ -46,7 +46,7 @@ toolsicon.130x130x16.bmp
hibyicon.70x70x16.bmp hibyicon.70x70x16.bmp
rockboxicon.70x70x16.bmp rockboxicon.70x70x16.bmp
toolsicon.70x70x16.bmp toolsicon.70x70x16.bmp
#elif (defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(EROS_Q)) #elif (defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(EROS_Q) || defined(SURFANS_F28))
hibyicon.130x130x16.bmp hibyicon.130x130x16.bmp
rockboxicon.130x130x16.bmp rockboxicon.130x130x16.bmp
toolsicon.130x130x16.bmp toolsicon.130x130x16.bmp

View file

@ -182,7 +182,7 @@ depth_3d
#endif #endif
/* This should be AUDIOHW_HAVE_FILTER_ROLL_OFF but that is only defined later */ /* This should be AUDIOHW_HAVE_FILTER_ROLL_OFF but that is only defined later */
#if defined(DX50) || defined(HAVE_DF1704_CODEC) || defined(HAVE_PCM1792_CODEC) || defined(HAVE_CS4398) || defined(HAVE_WM8740) || defined(HAVE_ES9018)|| defined(HAVE_EROS_QN_CODEC) || defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_AK4376) || defined(HAVE_ES9218) #if defined(DX50) || defined(HAVE_DF1704_CODEC) || defined(HAVE_PCM1792_CODEC) || defined(HAVE_CS4398) || defined(HAVE_WM8740) || defined(HAVE_ES9018)|| defined(HAVE_EROS_QN_CODEC) || defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_AK4376) || defined(HAVE_ES9218) || defined(HAVE_SURFANS_LINUX_CODEC)
filter_roll_off filter_roll_off
#endif #endif

View file

@ -77,7 +77,7 @@ mpio_hd200_hd300.c
#elif defined(SONY_NWZ_LINUX) #elif defined(SONY_NWZ_LINUX)
nwz_linux.c nwz_linux.c
#elif defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX) #elif defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX)
rocker_linux.c hibyos_linux.c
#elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \ #elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \
|| defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \ || defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \
|| defined(IHIFI760) || defined(IHIFI960) || defined(IHIFI800) \ || defined(IHIFI760) || defined(IHIFI960) || defined(IHIFI800) \

View file

@ -90,6 +90,15 @@
#define BUTTON_DOWN BUTTON_SCROLL_FWD #define BUTTON_DOWN BUTTON_SCROLL_FWD
#define BUTTON_SELECT BUTTON_PLAY #define BUTTON_SELECT BUTTON_PLAY
#include "bitmaps/hibyicon.h" #include "bitmaps/hibyicon.h"
#elif defined(SURFANS_F28)
#define ICON_WIDTH 130
#define ICON_HEIGHT 130
#define ICON_NAME bm_hibyicon
#define OF_NAME "HIBY PLAYER"
#define BUTTON_UP BUTTON_PREV
#define BUTTON_DOWN BUTTON_NEXT
#define BUTTON_SELECT BUTTON_PLAY
#include "bitmaps/hibyicon.h"
#else #else
#error "must define ICON_WIDTH/HEIGHT" #error "must define ICON_WIDTH/HEIGHT"
#endif #endif

View file

@ -151,6 +151,13 @@ target/hosted/agptek/power-agptek.c
target/hosted/agptek/powermgmt-agptek.c target/hosted/agptek/powermgmt-agptek.c
#endif #endif
#if defined(SURFANS_F28) && !defined(SIMULATOR)
target/hosted/surfans/button-f28.c
target/hosted/surfans/debug-f28.c
target/hosted/surfans/power-f28.c
target/hosted/surfans/powermgmt-f28.c
#endif
#if (defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(SIMULATOR) #if (defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(SIMULATOR)
target/hosted/xduoo/button-xduoo.c target/hosted/xduoo/button-xduoo.c
target/hosted/xduoo/debug-xduoo.c target/hosted/xduoo/debug-xduoo.c
@ -543,6 +550,8 @@ target/hosted/alsa-controls.c
target/hosted/pcm-alsa.c target/hosted/pcm-alsa.c
#elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR) #elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR)
drivers/audio/rocker_codec.c drivers/audio/rocker_codec.c
#elif defined(HAVE_SURFANS_LINUX_CODEC) && !defined(SIMULATOR)
drivers/audio/surfanslinux_codec.c
#elif defined(HAVE_XDUOO_LINUX_CODEC) && !defined(SIMULATOR) #elif defined(HAVE_XDUOO_LINUX_CODEC) && !defined(SIMULATOR)
drivers/audio/xduoolinux_codec.c drivers/audio/xduoolinux_codec.c
#elif defined(HAVE_FIIO_LINUX_CODEC) && !defined(SIMULATOR) #elif defined(HAVE_FIIO_LINUX_CODEC) && !defined(SIMULATOR)

View file

@ -0,0 +1,200 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
*
* Copyright (c) 2018 Marcin Bukat
* Copyright (c) 2025 Solomon Peachy
*
* 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.
*
****************************************************************************/
//#define LOGF_ENABLE
#include "config.h"
#include "audio.h"
#include "audiohw.h"
#include "button.h"
#include "system.h"
#include "kernel.h"
#include "panic.h"
#include "sysfs.h"
#include "alsa-controls.h"
#include "pcm-alsa.h"
#include "logf.h"
/*
f28:
**** List of PLAYBACK Hardware Devices ****
card 0: tyinx1 [tyin_x1], device 0: tyin_x1-es9018_k2m-i2s es9018_k2m-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: tyinx1 [tyin_x1], device 1: tyin_x1-es9018_k2m-pcm es9018_k2m-hifi-1 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: saspdif [sa_spdif], device 0: SA SPDIF Dummy spdif dump dai-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
Mixer controls:
numid=3,iface=MIXER,name='ES9018_K2M Digital Filter'
; type=INTEGER,access=rw------,values=1,min=0,max=4,step=0
: values=0
numid=5,iface=MIXER,name='Hardware Mute'
; type=BOOLEAN,access=rw------,values=1
: values=off
numid=1,iface=MIXER,name='Left Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=255,step=0
: values=0
numid=4,iface=MIXER,name='Output Port Switch'
; type=INTEGER,access=rw------,values=1,min=0,max=5,step=0
: values=0
numid=2,iface=MIXER,name='Right Playback Volume'
; type=INTEGER,access=rw------,values=1,min=0,max=255,step=0
: values=0
numid=6,iface=MIXER,name='isDSD'
; type=BOOLEAN,access=rw------,values=1
: values=off
*/
static int hw_init = 0;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
static long int last_ps = -1;
static int muted = -1;
void audiohw_mute(int mute)
{
logf("mute %d", mute);
if (!hw_init || muted == mute)
return;
muted = mute;
if(mute)
{
long int ps0 = 0;
alsa_controls_set_ints("Output Port Switch", 1, &ps0);
}
else
{
last_ps = 0;
surfans_get_outputs();
}
}
int surfans_get_outputs(void){
long int ps = 0; // Muted, if nothing is plugged in!
int status = 0;
if (!hw_init) return ps;
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
sysfs_get_int(sysfs_hs_switch, &status);
if (status) ps = 2; // headset
sysfs_get_int(sysfs_bal_switch, &status);
if (status) ps = 3; // balanced output
surfans_set_output(ps);
return ps;
}
void surfans_set_output(int ps)
{
if (!hw_init || muted) return;
if (last_ps != ps)
{
logf("set out %d/%d", ps, last_ps);
/* Output port switch */
last_ps = ps;
alsa_controls_set_ints("Output Port Switch", 1, &last_ps);
audiohw_set_volume(vol_l_hw, vol_r_hw);
}
}
void audiohw_preinit(void)
{
logf("hw preinit");
alsa_controls_init("default");
hw_init = 1;
audiohw_mute(false); /* No need */
}
void audiohw_postinit(void)
{
logf("hw postinit");
}
void audiohw_close(void)
{
logf("hw close");
hw_init = 0;
alsa_controls_close();
}
void audiohw_set_frequency(int fsel)
{
(void)fsel;
}
void audiohw_set_volume(int vol_l, int vol_r)
{
logf("hw vol %d %d", vol_l, vol_r);
long l,r;
vol_l_hw = vol_l;
vol_r_hw = vol_r;
l = -vol_l/5;
r = -vol_r/5;
if (!hw_init)
return;
alsa_controls_set_ints("Left Playback Volume", 1, &l);
alsa_controls_set_ints("Right Playback Volume", 1, &r);
}
void audiohw_set_filter_roll_off(int value)
{
logf("rolloff %d", value);
/* 0 = Sharp;
1 = Slow;
2 = Short Sharp
3 = Short Slow
4 = Super Slow */
#if defined(XDUOO_X20)
long int value_hw = value;
alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw);
#else
(void)value;
#endif
}

View file

@ -232,6 +232,8 @@ struct sound_settings_info
#include "codec-dx90.h" #include "codec-dx90.h"
#elif defined(HAVE_ROCKER_CODEC) #elif defined(HAVE_ROCKER_CODEC)
#include "rocker_codec.h" #include "rocker_codec.h"
#elif defined(HAVE_SURFANS_LINUX_CODEC)
#include "surfanslinux_codec.h"
#elif defined(HAVE_XDUOO_LINUX_CODEC) #elif defined(HAVE_XDUOO_LINUX_CODEC)
#include "xduoolinux_codec.h" #include "xduoolinux_codec.h"
#elif defined(HAVE_FIIO_LINUX_CODEC) #elif defined(HAVE_FIIO_LINUX_CODEC)

View file

@ -165,6 +165,7 @@
#define FIIO_M3K_PAD 73 #define FIIO_M3K_PAD 73
#define SHANLING_Q1_PAD 74 #define SHANLING_Q1_PAD 74
#define ECHO_R1_PAD 75 #define ECHO_R1_PAD 75
#define SURFANS_F28_PAD 76
/* CONFIG_REMOTE_KEYPAD */ /* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1 #define H100_REMOTE 1
@ -206,7 +207,7 @@
* use the charging hardware. */ * use the charging hardware. */
/* CONFIG_BATTERY_MEASURE bits */ /* CONFIG_BATTERY_MEASURE bits */
/* If both VOLTAGE_MEASURE and PERCENTAGE_MEASURE are defined, /* If both VOLTAGE_MEASURE and PERCENTAGE_MEASURE are defined,
* _battery_level() (percentage) will be preferred, unless _battery_level() * _battery_level() (percentage) will be preferred, unless _battery_level()
* returns -1, then voltage will be used from _voltage_level(). */ * returns -1, then voltage will be used from _voltage_level(). */
#define VOLTAGE_MEASURE 1 /* Target can report battery voltage #define VOLTAGE_MEASURE 1 /* Target can report battery voltage
@ -616,6 +617,8 @@ Lyre prototype 1 */
#include "config/erosqnative.h" #include "config/erosqnative.h"
#elif defined(ECHO_R1) #elif defined(ECHO_R1)
#include "config/echor1.h" #include "config/echor1.h"
#elif defined(SURFANS_F28)
#include "config/surfansf28.h"
#else #else
//#error "unknown hwardware platform!" //#error "unknown hwardware platform!"
#endif #endif

View file

@ -54,7 +54,7 @@
#define MIN_BRIGHTNESS_SETTING 1 #define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 255 #define MAX_BRIGHTNESS_SETTING 255
#define BRIGHTNESS_STEP 5 #define BRIGHTNESS_STEP 5
#define DEFAULT_BRIGHTNESS_SETTING 70 #define DEFAULT_BRIGHTNESS_SETTING 255
/* Which backlight fading type? */ /* Which backlight fading type? */
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING

View file

@ -0,0 +1,68 @@
/*
* This config file is for the Surfans F28
*/
/* For Rolo and boot loader */
#define MODEL_NUMBER 120
#define MODEL_NAME "Surfans F28"
/* LCD dimensions */
#define LCD_WIDTH 320
#define LCD_HEIGHT 480
/* sqrt(320^2 + 480^2) / 3.5 = 165 */
#define LCD_DPI 165
/* define this if you have access to the quickscreen */
//#define HAVE_QUICKSCREEN
//#define HAVE_HOTKEY
#define HAVE_BUTTON_DATA
#define HAVE_TOUCHSCREEN
#define HAVE_HEADPHONE_DETECTION
/* KeyPad configuration for plugins */
#define CONFIG_KEYPAD SURFANS_F28_PAD
/* define this if the target has volume keys which can be used in the lists */
#define HAVE_VOLUME_IN_LIST
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Define this to the CPU frequency */
#define CPU_FREQ 1008000000
/* Battery */
#define BATTERY_TYPES_COUNT 1
/* Audio codec */
#define HAVE_SURFANS_LINUX_CODEC
#define HAVE_ALSA_32BIT
/* We don't have hardware controls */
#define HAVE_SW_TONE_CONTROLS
/* HW codec is flexible */
#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
/* Battery */
#define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define CURRENT_NORMAL 100 // 1.7mA * 60s
#define CURRENT_BACKLIGHT 180
#define CURRENT_MAX_CHG 500 // bursts higher if needed
/* ROLO */
#define BOOTFILE_EXT "f28"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
/* USB */
#define USB_VID_STR "18D1"
#define USB_PID_STR "0D02"
/* Generic HiBy stuff */
#include "hibylinux.h"

View file

@ -0,0 +1,17 @@
#ifndef __SURFANSLINUX_CODEC__
#define __SURFANSLINUX_CODEC__
#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP)
AUDIOHW_SETTING(VOLUME, "dB", 1, 5, -102*10, 0, -30*10)
#endif
// We want this, but the codec takes over a second to unmute!
//#define AUDIOHW_MUTE_ON_STOP
//#define AUDIOHW_NEEDS_INITIAL_UNMUTE
AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 4, 0)
#define AUDIOHW_HAVE_SHORT2_ROLL_OFF
void audiohw_mute(int mute);
void surfans_set_output(int ps);
int surfans_get_outputs(void);

View file

@ -1,49 +0,0 @@
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $Id$
#
INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
# bootloader build is sligtly different
ifneq (,$(findstring bootloader,$(APPSDIR)))
SRC += $(call preprocess, $(APPSDIR)/SOURCES)
CLEANOBJS += $(BUILDDIR)/bootloader.*
endif #bootloader
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
ifneq (,$(findstring bootloader,$(APPSDIR)))
# bootloader build
$(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
$(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf
$(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
else
# rockbox app build
$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
-L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
$(BUILDDIR)/$(BINARY): $(BUILDDIR)/rockbox.elf
$(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
endif

View file

@ -0,0 +1,64 @@
/***************************************************************************
* __________ __ ___
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 Marcin Bukat
*
* 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 <linux/input.h>
#include "sysfs.h"
#include "button.h"
#include "button-target.h"
#include "surfanslinux_codec.h"
/*
/dev/input/event0: rotary encoder (left/right)
/dev/input/event1: adc (prev/play)
/dev/input/event2: touchscreen
/dev/input/event3: gpios (power/next)
*/
int button_map(int keycode)
{
switch(keycode)
{
case KEY_LEFT:
return BUTTON_LEFT;
case KEY_RIGHT:
return BUTTON_RIGHT;
case KEY_PLAYPAUSE:
return BUTTON_PLAY;
case KEY_NEXTSONG:
return BUTTON_NEXT;
case KEY_PREVIOUSSONG:
return BUTTON_PREV;
case KEY_POWER:
return BUTTON_POWER;
default:
return 0;
}
}
bool headphones_inserted(void)
{
#ifdef BOOTLOADER
int ps = 0;
#else
int ps = surfans_get_outputs();
#endif
return (ps == 2 || ps == 3);
}

View file

@ -0,0 +1,52 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 by Marcin Bukat
*
* 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_
#include <stdbool.h>
#include "config.h"
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_PREV 0x00000002
#define BUTTON_NEXT 0x00000004
#define BUTTON_PLAY 0x00000008
#define BUTTON_LEFT 0x00000010
#define BUTTON_RIGHT 0x00000020
#define BUTTON_MAIN 0x0000003f
/* Touchscreen virtual buttons */
#define BUTTON_TOPLEFT 0x00001000
#define BUTTON_TOPMIDDLE 0x00002000
#define BUTTON_TOPRIGHT 0x00004000
#define BUTTON_MIDLEFT 0x00008000
#define BUTTON_CENTER 0x00010000
#define BUTTON_MIDRIGHT 0x00020000
#define BUTTON_BOTTOMLEFT 0x00040000
#define BUTTON_BOTTOMMIDDLE 0x00080000
#define BUTTON_BOTTOMRIGHT 0x00100000
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 25
int button_map(int keycode);
#endif /* _BUTTON_TARGET_H_ */

View file

@ -0,0 +1,89 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2020 by Solomon Peachy
*
* 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 <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "config.h"
#include "font.h"
#include "lcd.h"
#include "kernel.h"
#include "button.h"
#ifndef BOOTLOADER
#include "pcm-alsa.h"
static int line = 0;
extern int hwver;
bool dbg_hw_info(void)
{
int btn = 0;
/* Try to read the bootloader */
char verstr[40];
memset(verstr, 0, sizeof(verstr));
int fd = open("/etc/rockbox-bl-info.txt", O_RDONLY);
if(fd >= 0)
{
read(fd, verstr, sizeof(verstr) -1);
close(fd);
}
lcd_setfont(FONT_SYSFIXED);
while(btn ^ BUTTON_POWER) {
lcd_clear_display();
line = 0;
if (verstr[0]) {
lcd_putsf(0, line++, "Boot ver: %s", verstr);
}
#ifdef EROS_Q
lcd_putsf(0, line++, "hwver: %d", hwver);
#endif
lcd_putsf(0, line++, "pcm srate: %d", pcm_alsa_get_rate());
lcd_putsf(0, line++, "pcm xruns: %d", pcm_alsa_get_xruns());
#ifdef HAVE_HEADPHONE_DETECTION
lcd_putsf(0, line++, "hp: %d", headphones_inserted());
#endif
#ifdef HAVE_LINEOUT_DETECTION
lcd_putsf(0, line++, "lo: %d", lineout_inserted());
#endif
int bdata;
btn = button_read_device(&bdata);
lcd_putsf(0, line++, "btn: %d", btn);
lcd_update();
sleep(HZ/16);
}
return true;
}
#endif /* !BOOTLOADER */

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2016 Amaury Pouly
*
* 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 __LCD_TARGET_H__
#define __LCD_TARGET_H__
/* Agptek needs special ioctl() to redraw updated framebuffer content */
#define LCD_OPTIMIZED_UPDATE
#define LCD_OPTIMIZED_UPDATE_RECT
extern fb_data *framebuffer; /* see lcd-agptek.c */
#define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col))
extern void lcd_set_active(bool active);
#endif /* __LCD_TARGET_H__ */

View file

@ -0,0 +1,41 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 by Marcin Bukat
*
* 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-f28.h"
#include "power.h"
#include "panic.h"
#include "sysfs.h"
const char * const sysfs_bat_voltage =
"/sys/class/power_supply/battery/voltage_now";
unsigned int f28_power_get_battery_voltage(void)
{
int battery_voltage;
sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
return battery_voltage/1000;
}

View file

@ -0,0 +1,27 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 by Marcin Bukat
*
* 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_F28_H_
#define _POWER_F28_H_
#include <stdbool.h>
#include "config.h"
unsigned int f28_power_get_battery_voltage(void);
#endif /* _POWER_F28_H_ */

View file

@ -0,0 +1,47 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 Marcin Bukat
*
* 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-f28.h"
// XXX all of this... blabla
// max voltage is 4360 apparently
unsigned short battery_level_disksafe = 3470;
/* the OF shuts down at this voltage */
unsigned short battery_level_shutoff = 3400;
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
unsigned short percent_to_volt_discharge[11] =
{
3400, 3675, 3715, 3750, 3775, 3810, 3850, 3915, 3985, 4060, 4155
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
unsigned short percent_to_volt_charge[11] =
{
3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
};
int _battery_voltage(void)
{
return f28_power_get_battery_voltage();
}

View file

@ -0,0 +1,28 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 Marcin Bukat
* Copyright (C) 2016 Amaury Pouly
*
* 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 __SYSTEM_TARGET_H__
#define __SYSTEM_TARGET_H__
#include "kernel-unix.h"
#include "system-hosted.h"
#define NEED_GENERIC_BYTESWAPS
#endif /* __SYSTEM_TARGET_H__ */

View file

@ -77,7 +77,7 @@ bool headphones_inserted(void)
#ifdef BOOTLOADER #ifdef BOOTLOADER
int ps = 0; int ps = 0;
#else #else
int ps = xduoo_get_outputs(); int ps = surfans_get_outputs();
#endif #endif
return (ps == 2 || ps == 3); return (ps == 2 || ps == 3);
@ -88,7 +88,7 @@ bool lineout_inserted(void)
#ifdef BOOTLOADER #ifdef BOOTLOADER
int ps = 0; int ps = 0;
#else #else
int ps = xduoo_get_outputs(); int ps = surfans_get_outputs();
#endif #endif
return (ps == 1); return (ps == 1);
} }

View file

@ -1,49 +0,0 @@
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $Id$
#
INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
# bootloader build is sligtly different
ifneq (,$(findstring bootloader,$(APPSDIR)))
SRC += $(call preprocess, $(APPSDIR)/SOURCES)
CLEANOBJS += $(BUILDDIR)/bootloader.*
endif #bootloader
.SECONDEXPANSION: # $$(OBJ) is not populated until after this
ifneq (,$(findstring bootloader,$(APPSDIR)))
# bootloader build
$(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
$(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf
$(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
else
# rockbox app build
$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
-L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
-L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
$(BUILDDIR)/$(BINARY): $(BUILDDIR)/rockbox.elf
$(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
endif

35
tools/configure vendored
View file

@ -1730,8 +1730,8 @@ cat <<EOF
==Shanling== 242) X3II 248) Eros Q / K native ==Shanling== 242) X3II 248) Eros Q / K native
260) Q1 243) X20 (hw3 bl only) 260) Q1 243) X20 (hw3 bl only)
249) Eros Q / K native 249) Eros Q / K native
(hw4 bl only) ==Surfans== (hw4 bl only)
==Echo project== ==Echo project== 280) F28 (WIP)
270) Echo R1 (WIP) 270) Echo R1 (WIP)
EOF EOF
@ -4019,7 +4019,7 @@ fi
240|agptekrocker) 240|agptekrocker)
application="yes" application="yes"
app_type="rocker" app_type="hibyos"
target_id=97 target_id=97
modelname="agptekrocker" modelname="agptekrocker"
target="AGPTEK_ROCKER" target="AGPTEK_ROCKER"
@ -4064,7 +4064,7 @@ fi
242|xduoox3ii) 242|xduoox3ii)
target_id=110 target_id=110
application=yes application=yes
app_type="xduoo" app_type="hibyos"
modelname="xduoox3ii" modelname="xduoox3ii"
target="XDUOO_X3II" target="XDUOO_X3II"
memory=8 memory=8
@ -4087,7 +4087,7 @@ fi
243|xduoox20) 243|xduoox20)
target_id=111 target_id=111
application=yes application=yes
app_type="xduoo" app_type="hibyos"
modelname="xduoox20" modelname="xduoox20"
target="XDUOO_X20" target="XDUOO_X20"
memory=8 memory=8
@ -4133,7 +4133,7 @@ fi
245|aigoerosq|erosq) 245|aigoerosq|erosq)
target_id=113 target_id=113
application=yes application=yes
app_type="erosq" app_type="hibyos"
modelname="aigoerosq" modelname="aigoerosq"
target="EROS_Q" target="EROS_Q"
memory=8 memory=8
@ -4373,6 +4373,29 @@ fi
t_model="echoplayer" t_model="echoplayer"
;; ;;
280|surfansf28)
target_id=120
application=yes
app_type="hibyos"
modelname="surfansf28"
target="SURFANS_F28"
memory=32 # 64 total!
mipsellinuxcc
tool="cp "
boottool="cp "
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 10"
output="rockbox.f28"
bootoutput="bootloader.f28"
appextra="recorder:gui:hosted"
plugins="no"
# architecture, manufacturer and model for the target-tree build
t_cpu="hosted"
t_manufacturer="surfans"
t_model="f28"
sysfontbl="16-Terminus"
;;
*) *)
echo "Please select a supported target platform!" echo "Please select a supported target platform!"
exit 7 exit 7

View file

@ -42,6 +42,8 @@ if ($model eq 'rocker') {
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
} elsif ($model eq 'eros_q') { } elsif ($model eq 'eros_q') {
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U"); @ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
} elsif ($model eq 'f28') {
@ubiopts = ("-e", "124KiB", "-c", "1024", "-m", "2048", "-j", "8192KiB", "-U");
} elsif ($model eq 'm3k') { } elsif ($model eq 'm3k') {
@ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U"); @ubiopts = ("-e", "124KiB", "-c", "2048", "-m", "2048", "-j", "8192KiB", "-U");
$hiby = 0; $hiby = 0;

View file

@ -105,12 +105,8 @@ endif
ifneq (,$(findstring bootloader,$(APPSDIR))) ifneq (,$(findstring bootloader,$(APPSDIR)))
ifneq (,$(findstring sonynwz,$(APP_TYPE))) ifneq (,$(findstring sonynwz,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make
else ifneq (,$(findstring rocker,$(APP_TYPE))) else ifneq (,$(findstring hibyos,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/agptek/rocker.make include $(ROOTDIR)/firmware/target/hosted/hibyos.make
else ifneq (,$(findstring xduoo,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/xduoo/xduoo.make
else ifneq (,$(findstring erosq,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/aigo/erosq.make
else ifneq (,$(findstring fiio,$(APP_TYPE))) else ifneq (,$(findstring fiio,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/fiio/fiio.make include $(ROOTDIR)/firmware/target/hosted/fiio/fiio.make
else ifneq (,$(findstring ingenic_x1000,$(MANUFACTURER))) else ifneq (,$(findstring ingenic_x1000,$(MANUFACTURER)))
@ -153,22 +149,14 @@ else # core
include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make
endif endif
ifneq (,$(findstring rocker,$(APP_TYPE))) ifneq (,$(findstring hibyos,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/agptek/rocker.make include $(ROOTDIR)/firmware/target/hosted/hibyos.make
endif
ifneq (,$(findstring xduoo,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/xduoo/xduoo.make
endif endif
ifneq (,$(findstring fiio,$(APP_TYPE))) ifneq (,$(findstring fiio,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/fiio/fiio.make include $(ROOTDIR)/firmware/target/hosted/fiio/fiio.make
endif endif
ifneq (,$(findstring erosq,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/aigo/erosq.make
endif
ifneq (,$(findstring android_ndk, $(APP_TYPE))) ifneq (,$(findstring android_ndk, $(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/ibasso/android_ndk.make include $(ROOTDIR)/firmware/target/hosted/ibasso/android_ndk.make
else else