Skip to content

Commit 82f3d0c

Browse files
committed
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
1 parent 3270daf commit 82f3d0c

27 files changed

+730
-127
lines changed

apps/bitmaps/native/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ toolsicon.130x130x16.bmp
4646
hibyicon.70x70x16.bmp
4747
rockboxicon.70x70x16.bmp
4848
toolsicon.70x70x16.bmp
49-
#elif (defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(EROS_Q))
49+
#elif (defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(EROS_Q) || defined(SURFANS_F28))
5050
hibyicon.130x130x16.bmp
5151
rockboxicon.130x130x16.bmp
5252
toolsicon.130x130x16.bmp

apps/features.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ depth_3d
182182
#endif
183183

184184
/* This should be AUDIOHW_HAVE_FILTER_ROLL_OFF but that is only defined later */
185-
#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)
185+
#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)
186186
filter_roll_off
187187
#endif
188188

bootloader/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mpio_hd200_hd300.c
7777
#elif defined(SONY_NWZ_LINUX)
7878
nwz_linux.c
7979
#elif defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX)
80-
rocker_linux.c
80+
hibyos_linux.c
8181
#elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \
8282
|| defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \
8383
|| defined(IHIFI760) || defined(IHIFI960) || defined(IHIFI800) \

bootloader/rocker_linux.c renamed to bootloader/hibyos_linux.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@
9090
#define BUTTON_DOWN BUTTON_SCROLL_FWD
9191
#define BUTTON_SELECT BUTTON_PLAY
9292
#include "bitmaps/hibyicon.h"
93+
#elif defined(SURFANS_F28)
94+
#define ICON_WIDTH 130
95+
#define ICON_HEIGHT 130
96+
#define ICON_NAME bm_hibyicon
97+
#define OF_NAME "HIBY PLAYER"
98+
#define BUTTON_UP BUTTON_PREV
99+
#define BUTTON_DOWN BUTTON_NEXT
100+
#define BUTTON_SELECT BUTTON_PLAY
101+
#include "bitmaps/hibyicon.h"
93102
#else
94103
#error "must define ICON_WIDTH/HEIGHT"
95104
#endif

firmware/SOURCES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ target/hosted/agptek/power-agptek.c
151151
target/hosted/agptek/powermgmt-agptek.c
152152
#endif
153153

154+
#if defined(SURFANS_F28) && !defined(SIMULATOR)
155+
target/hosted/surfans/button-f28.c
156+
target/hosted/surfans/debug-f28.c
157+
target/hosted/surfans/power-f28.c
158+
target/hosted/surfans/powermgmt-f28.c
159+
#endif
160+
154161
#if (defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(SIMULATOR)
155162
target/hosted/xduoo/button-xduoo.c
156163
target/hosted/xduoo/debug-xduoo.c
@@ -543,6 +550,8 @@ target/hosted/alsa-controls.c
543550
target/hosted/pcm-alsa.c
544551
#elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR)
545552
drivers/audio/rocker_codec.c
553+
#elif defined(HAVE_SURFANS_LINUX_CODEC) && !defined(SIMULATOR)
554+
drivers/audio/surfanslinux_codec.c
546555
#elif defined(HAVE_XDUOO_LINUX_CODEC) && !defined(SIMULATOR)
547556
drivers/audio/xduoolinux_codec.c
548557
#elif defined(HAVE_FIIO_LINUX_CODEC) && !defined(SIMULATOR)
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/***************************************************************************
2+
* __________ __ ___.
3+
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4+
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5+
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6+
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7+
* \/ \/ \/ \/ \/
8+
* $Id$
9+
*
10+
*
11+
* Copyright (c) 2018 Marcin Bukat
12+
* Copyright (c) 2025 Solomon Peachy
13+
*
14+
* This program is free software; you can redistribute it and/or
15+
* modify it under the terms of the GNU General Public License
16+
* as published by the Free Software Foundation; either version 2
17+
* of the License, or (at your option) any later version.
18+
*
19+
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20+
* KIND, either express or implied.
21+
*
22+
****************************************************************************/
23+
24+
//#define LOGF_ENABLE
25+
26+
#include "config.h"
27+
#include "audio.h"
28+
#include "audiohw.h"
29+
#include "button.h"
30+
#include "system.h"
31+
#include "kernel.h"
32+
#include "panic.h"
33+
#include "sysfs.h"
34+
#include "alsa-controls.h"
35+
#include "pcm-alsa.h"
36+
37+
#include "logf.h"
38+
39+
/*
40+
41+
f28:
42+
43+
**** List of PLAYBACK Hardware Devices ****
44+
card 0: tyinx1 [tyin_x1], device 0: tyin_x1-es9018_k2m-i2s es9018_k2m-hifi-0 []
45+
Subdevices: 1/1
46+
Subdevice #0: subdevice #0
47+
card 0: tyinx1 [tyin_x1], device 1: tyin_x1-es9018_k2m-pcm es9018_k2m-hifi-1 []
48+
Subdevices: 1/1
49+
Subdevice #0: subdevice #0
50+
card 1: saspdif [sa_spdif], device 0: SA SPDIF Dummy spdif dump dai-0 []
51+
Subdevices: 1/1
52+
Subdevice #0: subdevice #0
53+
54+
Mixer controls:
55+
56+
numid=3,iface=MIXER,name='ES9018_K2M Digital Filter'
57+
; type=INTEGER,access=rw------,values=1,min=0,max=4,step=0
58+
: values=0
59+
numid=5,iface=MIXER,name='Hardware Mute'
60+
; type=BOOLEAN,access=rw------,values=1
61+
: values=off
62+
numid=1,iface=MIXER,name='Left Playback Volume'
63+
; type=INTEGER,access=rw------,values=1,min=0,max=255,step=0
64+
: values=0
65+
numid=4,iface=MIXER,name='Output Port Switch'
66+
; type=INTEGER,access=rw------,values=1,min=0,max=5,step=0
67+
: values=0
68+
numid=2,iface=MIXER,name='Right Playback Volume'
69+
; type=INTEGER,access=rw------,values=1,min=0,max=255,step=0
70+
: values=0
71+
numid=6,iface=MIXER,name='isDSD'
72+
; type=BOOLEAN,access=rw------,values=1
73+
: values=off
74+
75+
*/
76+
77+
static int hw_init = 0;
78+
79+
static long int vol_l_hw = 255;
80+
static long int vol_r_hw = 255;
81+
static long int last_ps = -1;
82+
83+
static int muted = -1;
84+
85+
void audiohw_mute(int mute)
86+
{
87+
logf("mute %d", mute);
88+
89+
if (!hw_init || muted == mute)
90+
return;
91+
92+
muted = mute;
93+
94+
if(mute)
95+
{
96+
long int ps0 = 0;
97+
alsa_controls_set_ints("Output Port Switch", 1, &ps0);
98+
}
99+
else
100+
{
101+
last_ps = 0;
102+
surfans_get_outputs();
103+
}
104+
}
105+
106+
int surfans_get_outputs(void){
107+
long int ps = 0; // Muted, if nothing is plugged in!
108+
109+
int status = 0;
110+
111+
if (!hw_init) return ps;
112+
113+
const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
114+
const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
115+
116+
sysfs_get_int(sysfs_hs_switch, &status);
117+
if (status) ps = 2; // headset
118+
119+
sysfs_get_int(sysfs_bal_switch, &status);
120+
if (status) ps = 3; // balanced output
121+
122+
surfans_set_output(ps);
123+
124+
return ps;
125+
}
126+
127+
void surfans_set_output(int ps)
128+
{
129+
if (!hw_init || muted) return;
130+
131+
if (last_ps != ps)
132+
{
133+
logf("set out %d/%d", ps, last_ps);
134+
/* Output port switch */
135+
last_ps = ps;
136+
alsa_controls_set_ints("Output Port Switch", 1, &last_ps);
137+
audiohw_set_volume(vol_l_hw, vol_r_hw);
138+
}
139+
}
140+
141+
void audiohw_preinit(void)
142+
{
143+
logf("hw preinit");
144+
alsa_controls_init("default");
145+
hw_init = 1;
146+
147+
audiohw_mute(false); /* No need */
148+
}
149+
150+
void audiohw_postinit(void)
151+
{
152+
logf("hw postinit");
153+
}
154+
155+
void audiohw_close(void)
156+
{
157+
logf("hw close");
158+
hw_init = 0;
159+
alsa_controls_close();
160+
}
161+
162+
void audiohw_set_frequency(int fsel)
163+
{
164+
(void)fsel;
165+
}
166+
167+
void audiohw_set_volume(int vol_l, int vol_r)
168+
{
169+
logf("hw vol %d %d", vol_l, vol_r);
170+
171+
long l,r;
172+
173+
vol_l_hw = vol_l;
174+
vol_r_hw = vol_r;
175+
176+
l = -vol_l/5;
177+
r = -vol_r/5;
178+
179+
if (!hw_init)
180+
return;
181+
182+
alsa_controls_set_ints("Left Playback Volume", 1, &l);
183+
alsa_controls_set_ints("Right Playback Volume", 1, &r);
184+
}
185+
186+
void audiohw_set_filter_roll_off(int value)
187+
{
188+
logf("rolloff %d", value);
189+
/* 0 = Sharp;
190+
1 = Slow;
191+
2 = Short Sharp
192+
3 = Short Slow
193+
4 = Super Slow */
194+
#if defined(XDUOO_X20)
195+
long int value_hw = value;
196+
alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw);
197+
#else
198+
(void)value;
199+
#endif
200+
}

firmware/export/audiohw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ struct sound_settings_info
232232
#include "codec-dx90.h"
233233
#elif defined(HAVE_ROCKER_CODEC)
234234
#include "rocker_codec.h"
235+
#elif defined(HAVE_SURFANS_LINUX_CODEC)
236+
#include "surfanslinux_codec.h"
235237
#elif defined(HAVE_XDUOO_LINUX_CODEC)
236238
#include "xduoolinux_codec.h"
237239
#elif defined(HAVE_FIIO_LINUX_CODEC)

firmware/export/config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
#define FIIO_M3K_PAD 73
166166
#define SHANLING_Q1_PAD 74
167167
#define ECHO_R1_PAD 75
168+
#define SURFANS_F28_PAD 76
168169

169170
/* CONFIG_REMOTE_KEYPAD */
170171
#define H100_REMOTE 1
@@ -206,7 +207,7 @@
206207
* use the charging hardware. */
207208

208209
/* CONFIG_BATTERY_MEASURE bits */
209-
/* If both VOLTAGE_MEASURE and PERCENTAGE_MEASURE are defined,
210+
/* If both VOLTAGE_MEASURE and PERCENTAGE_MEASURE are defined,
210211
* _battery_level() (percentage) will be preferred, unless _battery_level()
211212
* returns -1, then voltage will be used from _voltage_level(). */
212213
#define VOLTAGE_MEASURE 1 /* Target can report battery voltage
@@ -616,6 +617,8 @@ Lyre prototype 1 */
616617
#include "config/erosqnative.h"
617618
#elif defined(ECHO_R1)
618619
#include "config/echor1.h"
620+
#elif defined(SURFANS_F28)
621+
#include "config/surfansf28.h"
619622
#else
620623
//#error "unknown hwardware platform!"
621624
#endif

firmware/export/config/hibylinux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define MIN_BRIGHTNESS_SETTING 1
5555
#define MAX_BRIGHTNESS_SETTING 255
5656
#define BRIGHTNESS_STEP 5
57-
#define DEFAULT_BRIGHTNESS_SETTING 70
57+
#define DEFAULT_BRIGHTNESS_SETTING 255
5858

5959
/* Which backlight fading type? */
6060
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING

firmware/export/config/surfansf28.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* This config file is for the Surfans F28
3+
*/
4+
5+
/* For Rolo and boot loader */
6+
#define MODEL_NUMBER 120
7+
8+
#define MODEL_NAME "Surfans F28"
9+
10+
/* LCD dimensions */
11+
#define LCD_WIDTH 320
12+
#define LCD_HEIGHT 480
13+
/* sqrt(320^2 + 480^2) / 3.5 = 165 */
14+
#define LCD_DPI 165
15+
16+
/* define this if you have access to the quickscreen */
17+
//#define HAVE_QUICKSCREEN
18+
//#define HAVE_HOTKEY
19+
20+
#define HAVE_BUTTON_DATA
21+
#define HAVE_TOUCHSCREEN
22+
#define HAVE_HEADPHONE_DETECTION
23+
24+
/* KeyPad configuration for plugins */
25+
#define CONFIG_KEYPAD SURFANS_F28_PAD
26+
27+
/* define this if the target has volume keys which can be used in the lists */
28+
#define HAVE_VOLUME_IN_LIST
29+
30+
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
31+
32+
/* Define this to the CPU frequency */
33+
#define CPU_FREQ 1008000000
34+
35+
/* Battery */
36+
#define BATTERY_TYPES_COUNT 1
37+
38+
/* Audio codec */
39+
#define HAVE_SURFANS_LINUX_CODEC
40+
#define HAVE_ALSA_32BIT
41+
42+
/* We don't have hardware controls */
43+
#define HAVE_SW_TONE_CONTROLS
44+
45+
/* HW codec is flexible */
46+
#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
47+
48+
/* Battery */
49+
#define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */
50+
#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
51+
#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
52+
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
53+
54+
#define CURRENT_NORMAL 100 // 1.7mA * 60s
55+
#define CURRENT_BACKLIGHT 180
56+
#define CURRENT_MAX_CHG 500 // bursts higher if needed
57+
58+
/* ROLO */
59+
#define BOOTFILE_EXT "f28"
60+
#define BOOTFILE "rockbox." BOOTFILE_EXT
61+
#define BOOTDIR "/.rockbox"
62+
63+
/* USB */
64+
#define USB_VID_STR "18D1"
65+
#define USB_PID_STR "0D02"
66+
67+
/* Generic HiBy stuff */
68+
#include "hibylinux.h"

0 commit comments

Comments
 (0)