summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-08 09:47:40 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-11 16:37:17 -0400
commit2a471e288c16b91a7186a60b3fb84dd55a494c7a (patch)
tree3e746212c5fa69b59f61d19b6e29d11aa8a5e31b /firmware
parent5efaa9ef8073bb216e3dcdbb4476f2fa7c672b76 (diff)
downloadrockbox-2a471e288c16b91a7186a60b3fb84dd55a494c7a.tar.gz
rockbox-2a471e288c16b91a7186a60b3fb84dd55a494c7a.zip
New port: AIGO EROS Q / EROS K
The Q and K have a slightly different case, but the hardware under the shell is completely identical. These models are rebadged versions: * Hifiwalker H2 (== Q) * AGPTek H3 (== K) * Surfans F20 (== K) Other notes: * Significant improvements in the shared Hiby-platform launcher/loader * SD card can theoretically be hot-swapped now * Support external USB mass storage! * Some consolidation of Hiby-platform targets * Some consolidation of plugin keymaps Todo/known issues: * Keymaps need to be gone over properly * Convert to HAVE_SCROLLWHEEL? Change-Id: I5a8a4f22c38a5b69392ca7c0a8ad8c4e07d9523c
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/asm/SOURCES4
-rw-r--r--firmware/drivers/audio/erosqlinux_codec.c181
-rw-r--r--firmware/export/audiohw.h2
-rw-r--r--firmware/export/config.h3
-rw-r--r--firmware/export/config/agptekrocker.h1
-rw-r--r--firmware/export/config/aigoerosq.h132
-rw-r--r--firmware/export/config/fiiom3k.h2
-rw-r--r--firmware/export/config/xduoox20.h2
-rw-r--r--firmware/export/config/xduoox3ii.h1
-rw-r--r--firmware/export/erosqlinux_codec.h13
-rw-r--r--firmware/export/rbpaths.h6
-rw-r--r--firmware/export/system.h2
-rw-r--r--firmware/font.c2
-rw-r--r--firmware/target/hosted/aigo/adc-target.h0
-rw-r--r--firmware/target/hosted/aigo/button-erosq.c188
-rw-r--r--firmware/target/hosted/aigo/button-target.h45
-rw-r--r--firmware/target/hosted/aigo/debug-erosq.c1
-rw-r--r--firmware/target/hosted/aigo/erosq.make49
-rw-r--r--firmware/target/hosted/aigo/lcd-target.h32
-rw-r--r--firmware/target/hosted/aigo/power-erosq.c74
-rw-r--r--firmware/target/hosted/aigo/power-erosq.h31
-rw-r--r--firmware/target/hosted/aigo/powermgmt-erosq.c61
-rw-r--r--firmware/target/hosted/aigo/system-target.h28
-rw-r--r--firmware/target/hosted/aigo/usb-erosq.c118
-rw-r--r--firmware/target/hosted/filesystem-app.c6
-rw-r--r--firmware/target/hosted/xduoo/button-target.h1
27 files changed, 985 insertions, 12 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index cbbebbc66f..8bf3d96bdf 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -115,7 +115,7 @@ target/hosted/sonynwz/nvp-nwz.c
115target/hosted/sonynwz/nwz-db.c 115target/hosted/sonynwz/nwz-db.c
116#endif 116#endif
117 117
118#if ((defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(FIIO_M3K)) && !defined(SIMULATOR)) 118#if ((defined(HIBY_LINUX) || defined(FIIO_M3K)) && !defined(SIMULATOR))
119drivers/lcd-memframe.c 119drivers/lcd-memframe.c
120target/hosted/alsa-controls.c 120target/hosted/alsa-controls.c
121target/hosted/pcm-alsa.c 121target/hosted/pcm-alsa.c
@@ -155,6 +155,14 @@ target/hosted/fiio/system-fiio.c
155target/hosted/fiio/usb-fiio.c 155target/hosted/fiio/usb-fiio.c
156#endif 156#endif
157 157
158#if (defined(EROS_Q)) && !defined(SIMULATOR)
159target/hosted/aigo/button-erosq.c
160target/hosted/aigo/debug-erosq.c
161target/hosted/aigo/power-erosq.c
162target/hosted/aigo/powermgmt-erosq.c
163target/hosted/aigo/usb-erosq.c
164#endif
165
158#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR) 166#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR)
159drivers/adc-as3514.c 167drivers/adc-as3514.c
160#if (CONFIG_RTC == RTC_AS3514) 168#if (CONFIG_RTC == RTC_AS3514)
@@ -513,6 +521,8 @@ drivers/audio/rocker_codec.c
513drivers/audio/xduoolinux_codec.c 521drivers/audio/xduoolinux_codec.c
514#elif defined(HAVE_FIIO_LINUX_CODEC) && !defined(SIMULATOR) 522#elif defined(HAVE_FIIO_LINUX_CODEC) && !defined(SIMULATOR)
515drivers/audio/fiiolinux_codec.c 523drivers/audio/fiiolinux_codec.c
524#elif defined(HAVE_EROSQ_LINUX_CODEC) && !defined(SIMULATOR)
525drivers/audio/erosqlinux_codec.c
516#elif defined(HAVE_SDL_AUDIO) 526#elif defined(HAVE_SDL_AUDIO)
517drivers/audio/sdl.c 527drivers/audio/sdl.c
518 528
diff --git a/firmware/asm/SOURCES b/firmware/asm/SOURCES
index e93f77c770..2b18ea2026 100644
--- a/firmware/asm/SOURCES
+++ b/firmware/asm/SOURCES
@@ -15,8 +15,8 @@ mempcpy.c
15 defined(CREATIVE_ZVx) || defined(SANSA_CONNECT) || defined(SANSA_FUZEPLUS) || \ 15 defined(CREATIVE_ZVx) || defined(SANSA_CONNECT) || defined(SANSA_FUZEPLUS) || \
16 defined(COWON_D2) || defined(MINI2440) || defined(SAMSUNG_YPR0) || \ 16 defined(COWON_D2) || defined(MINI2440) || defined(SAMSUNG_YPR0) || \
17 defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90) || (defined(MROBE_500) && !defined(LCD_USE_DMA)) || \ 17 defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90) || (defined(MROBE_500) && !defined(LCD_USE_DMA)) || \
18 defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(SONY_NWZ_LINUX) || defined(AGPTEK_ROCKER) || \ 18 defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX) || \
19 defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(FIIO_M3K)) && \ 19 defined(FIIO_M3K)) && \
20 !defined(SIMULATOR) 20 !defined(SIMULATOR)
21#if LCD_DEPTH >= 24 21#if LCD_DEPTH >= 24
22lcd-as-memframe-24bit.c 22lcd-as-memframe-24bit.c
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c
new file mode 100644
index 0000000000..deb3bb4b87
--- /dev/null
+++ b/firmware/drivers/audio/erosqlinux_codec.c
@@ -0,0 +1,181 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 *
11 * Copyright (c) 2018 Marcin Bukat
12 * Copyright (c) 2020 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#include "pcm_sw_volume.h"
37
38#include "logf.h"
39
40static int fd_hw;
41static int inited = 0;
42
43static long int vol_l_hw = 255;
44static long int vol_r_hw = 255;
45static long int last_ps = 0;
46
47static void hw_open(void)
48{
49 fd_hw = open("/dev/snd/controlC0", O_RDWR);
50 if(fd_hw < 0)
51 panicf("Cannot open '/dev/snd/controlC0'");
52}
53
54static void hw_close(void)
55{
56 close(fd_hw);
57}
58
59void audiohw_mute(int mute)
60{
61 logf("mute %d", mute);
62
63 if(mute)
64 {
65 long int ps0 = 0;
66 alsa_controls_set_ints("Output Port Switch", 1, &ps0);
67 }
68 else
69 {
70 last_ps = 0;
71 erosq_get_outputs();
72 }
73}
74
75int erosq_get_outputs(void) {
76 long int ps = 0; // Muted, if nothing is plugged in!
77
78 int status = 0;
79
80 if (!inited) return ps;
81
82 const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
83 const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
84
85 sysfs_get_int(sysfs_lo_switch, &status);
86 if (status) ps = 1; // lineout
87
88 sysfs_get_int(sysfs_hs_switch, &status);
89 if (status) ps = 2; // headset
90
91 erosq_set_output(ps);
92
93 return ps;
94}
95
96void erosq_set_output(int ps)
97{
98 if (!inited) return;
99
100 if (last_ps != ps)
101 {
102 logf("set out %d/%d", ps, last_ps);
103 /* Output port switch */
104 last_ps = ps;
105 alsa_controls_set_ints("Output Port Switch", 1, &last_ps);
106 audiohw_set_volume(vol_l_hw, vol_r_hw);
107 }
108}
109
110void audiohw_preinit(void)
111{
112 logf("hw preinit");
113 alsa_controls_init();
114 hw_open();
115 audiohw_mute(true); /* Start muted to avoid the POP */
116 inited = 1;
117}
118
119void audiohw_postinit(void)
120{
121 logf("hw postinit");
122 erosq_set_output(erosq_get_outputs()); /* Unmute */
123}
124
125void audiohw_close(void)
126{
127 logf("hw close");
128 inited = 0;
129 hw_close();
130 alsa_controls_close();
131}
132
133void audiohw_set_frequency(int fsel)
134{
135 (void)fsel;
136}
137
138void audiohw_set_volume(int vol_l, int vol_r)
139{
140 logf("hw vol %d %d", vol_l, vol_r);
141
142 long l,r;
143
144 vol_l_hw = vol_l;
145 vol_r_hw = vol_r;
146
147 if (lineout_inserted()) {
148 l = 0;
149 r = 0;
150 } else {
151 l = vol_l_hw;
152 r = vol_r_hw;
153 }
154
155 /* SW volume for <= 1.0 gain, HW at unity, < -740 == MUTE */
156 int sw_volume_l = l <= -740 ? PCM_MUTE_LEVEL : MIN(l, 0);
157 int sw_volume_r = r <= -740 ? PCM_MUTE_LEVEL : MIN(r, 0);
158 pcm_set_master_volume(sw_volume_l, sw_volume_r);
159}
160
161void audiohw_set_lineout_volume(int vol_l, int vol_r)
162{
163 long l,r;
164
165 logf("lo vol %d %d", vol_l, vol_r);
166
167 (void)vol_l;
168 (void)vol_r;
169
170 if (lineout_inserted()) {
171 l = 0;
172 r = 0;
173 } else {
174 l = vol_l_hw;
175 r = vol_r_hw;
176 }
177
178 int sw_volume_l = l <= -740 ? PCM_MUTE_LEVEL : MIN(l, 0);
179 int sw_volume_r = r <= -740 ? PCM_MUTE_LEVEL : MIN(r, 0);
180 pcm_set_master_volume(sw_volume_l, sw_volume_r);
181}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 1ff220e403..8a46cbea78 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -226,6 +226,8 @@ struct sound_settings_info
226#include "xduoolinux_codec.h" 226#include "xduoolinux_codec.h"
227#elif defined(HAVE_FIIO_LINUX_CODEC) 227#elif defined(HAVE_FIIO_LINUX_CODEC)
228#include "fiiolinux_codec.h" 228#include "fiiolinux_codec.h"
229#elif defined(HAVE_EROSQ_LINUX_CODEC)
230#include "erosqlinux_codec.h"
229#endif 231#endif
230 232
231/* convert caps into defines */ 233/* convert caps into defines */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index a9753e3cf8..7e8d751090 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -162,6 +162,7 @@
162#define XDUOO_X3II_PAD 69 162#define XDUOO_X3II_PAD 69
163#define XDUOO_X20_PAD 70 163#define XDUOO_X20_PAD 70
164#define FIIO_M3K_PAD 71 164#define FIIO_M3K_PAD 71
165#define EROSQ_PAD 72
165 166
166/* CONFIG_REMOTE_KEYPAD */ 167/* CONFIG_REMOTE_KEYPAD */
167#define H100_REMOTE 1 168#define H100_REMOTE 1
@@ -602,6 +603,8 @@ Lyre prototype 1 */
602#include "config/xduoox20.h" 603#include "config/xduoox20.h"
603#elif defined(FIIO_M3K) 604#elif defined(FIIO_M3K)
604#include "config/fiiom3k.h" 605#include "config/fiiom3k.h"
606#elif defined(EROS_Q)
607#include "config/aigoerosq.h"
605#else 608#else
606//#error "unknown hwardware platform!" 609//#error "unknown hwardware platform!"
607#endif 610#endif
diff --git a/firmware/export/config/agptekrocker.h b/firmware/export/config/agptekrocker.h
index a97522d976..230dc6cac4 100644
--- a/firmware/export/config/agptekrocker.h
+++ b/firmware/export/config/agptekrocker.h
@@ -17,6 +17,7 @@
17#define CONFIG_PLATFORM (PLATFORM_HOSTED) 17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif 18#endif
19 19
20#define HIBY_LINUX
20#define HAVE_FPU 21#define HAVE_FPU
21 22
22/* define this if you have a colour LCD */ 23/* define this if you have a colour LCD */
diff --git a/firmware/export/config/aigoerosq.h b/firmware/export/config/aigoerosq.h
new file mode 100644
index 0000000000..9207b5548f
--- /dev/null
+++ b/firmware/export/config/aigoerosq.h
@@ -0,0 +1,132 @@
1/*
2 * This config file is for the AIGO EROS Q / EROS K (and its clones)
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 113
7
8#define MODEL_NAME "AIGO Eros Q"
9
10/* LCD dimensions */
11#define LCD_WIDTH 320
12#define LCD_HEIGHT 240
13/* sqrt(240^2 + 320^2) / 2.0 = 200 */
14#define LCD_DPI 200
15
16#ifndef SIMULATOR
17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif
19
20#define HIBY_LINUX
21#define HAVE_FPU
22
23/* define this if you have a colour LCD */
24#define HAVE_LCD_COLOR
25
26#define HAVE_LCD_ENABLE
27
28/* Define this if the LCD can shut down */
29#define HAVE_LCD_SHUTDOWN
30
31/* define this if you want album art for this target */
32#define HAVE_ALBUMART
33
34/* define this to enable bitmap scaling */
35#define HAVE_BMP_SCALING
36
37/* define this to enable JPEG decoding */
38#define HAVE_JPEG
39
40/* define this if you have access to the quickscreen */
41#define HAVE_QUICKSCREEN
42
43/* define this if you would like tagcache to build on this target */
44#define HAVE_TAGCACHE
45
46#define LCD_DEPTH 32
47/* Check that but should not matter */
48#define LCD_PIXELFORMAT XRGB8888
49
50#define HAVE_BACKLIGHT
51#define HAVE_BACKLIGHT_BRIGHTNESS
52
53/* Main LCD backlight brightness range and defaults: the backlight driver
54 * has levels from 0 to 255. But 0 is off so start at 1.
55 */
56#define MIN_BRIGHTNESS_SETTING 1
57#define MAX_BRIGHTNESS_SETTING 255
58#define BRIGHTNESS_STEP 5
59#define DEFAULT_BRIGHTNESS_SETTING 70
60
61/* Which backlight fading type? */
62#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
63
64/* define this if you have a real-time clock */
65#define CONFIG_RTC APPLICATION
66
67/* The number of bytes reserved for loadable codecs */
68#define CODEC_SIZE 0x80000
69
70/* The number of bytes reserved for loadable plugins */
71#define PLUGIN_BUFFER_SIZE 0x100000
72
73#define HAVE_HEADPHONE_DETECTION
74#define HAVE_LINEOUT_DETECTION
75
76/* KeyPad configuration for plugins */
77#define CONFIG_KEYPAD EROSQ_PAD
78
79/* define this if the target has volume keys which can be used in the lists */
80#define HAVE_VOLUME_IN_LIST
81
82#ifndef SIMULATOR
83/* We have usb power and can detect usb but it is handled by Linux */
84#define HAVE_USB_POWER
85
86#endif
87
88#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
89
90/* Linux controlls charging, we can monitor */
91#define CONFIG_CHARGING CHARGING_MONITOR
92
93/* define this if the hardware can be powered off while charging */
94#define HAVE_POWEROFF_WHILE_CHARGING
95
96/* same dimensions as gigabeats */
97#define CONFIG_LCD LCD_INGENIC_LINUX
98
99/* Define this if you have a software controlled poweroff */
100#define HAVE_SW_POWEROFF
101
102/* Define this to the CPU frequency */
103#define CPU_FREQ 108000000
104
105/* No special storage */
106#define CONFIG_STORAGE STORAGE_HOSTFS
107#define HAVE_STORAGE_FLUSH
108
109/* Battery */
110#define BATTERY_TYPES_COUNT 1
111
112/* Audio codec */
113#define HAVE_EROSQ_LINUX_CODEC
114/* Rockbox has to handle the volume level */
115#define HAVE_SW_VOLUME_CONTROL
116
117/* We don't have hardware controls */
118#define HAVE_SW_TONE_CONTROLS
119
120/* HW codec is flexible */
121#define HW_SAMPR_CAPS SAMPR_CAP_ALL_192
122
123/* Battery */
124#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */
125#define BATTERY_CAPACITY_MIN 2000 /* min. capacity selectable */
126#define BATTERY_CAPACITY_MAX 2000 /* max. capacity selectable */
127#define BATTERY_CAPACITY_INC 0 /* capacity increment */
128
129/* ROLO */
130#define BOOTFILE_EXT "erosq"
131#define BOOTFILE "rockbox." BOOTFILE_EXT
132#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/fiiom3k.h b/firmware/export/config/fiiom3k.h
index 5b68f3738e..88652b633f 100644
--- a/firmware/export/config/fiiom3k.h
+++ b/firmware/export/config/fiiom3k.h
@@ -17,6 +17,8 @@
17#define CONFIG_PLATFORM (PLATFORM_HOSTED) 17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif 18#endif
19 19
20#define HAVE_FPU
21
20#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_48 | SAMPR_CAP_88 | SAMPR_CAP_96 | SAMPR_CAP_176 | SAMPR_CAP_192) 22#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_48 | SAMPR_CAP_88 | SAMPR_CAP_96 | SAMPR_CAP_176 | SAMPR_CAP_192)
21 23
22/* define this if you have a bitmap LCD display */ 24/* define this if you have a bitmap LCD display */
diff --git a/firmware/export/config/xduoox20.h b/firmware/export/config/xduoox20.h
index a8d2175719..70e6131cb7 100644
--- a/firmware/export/config/xduoox20.h
+++ b/firmware/export/config/xduoox20.h
@@ -17,6 +17,8 @@
17#define CONFIG_PLATFORM (PLATFORM_HOSTED) 17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif 18#endif
19 19
20#define HIBY_LINUX
21
20#define HAVE_FPU 22#define HAVE_FPU
21 23
22/* define this if you have a colour LCD */ 24/* define this if you have a colour LCD */
diff --git a/firmware/export/config/xduoox3ii.h b/firmware/export/config/xduoox3ii.h
index 143d4442fd..d19165114a 100644
--- a/firmware/export/config/xduoox3ii.h
+++ b/firmware/export/config/xduoox3ii.h
@@ -17,6 +17,7 @@
17#define CONFIG_PLATFORM (PLATFORM_HOSTED) 17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif 18#endif
19 19
20#define HIBY_LINUX
20#define HAVE_FPU 21#define HAVE_FPU
21 22
22/* define this if you have a colour LCD */ 23/* define this if you have a colour LCD */
diff --git a/firmware/export/erosqlinux_codec.h b/firmware/export/erosqlinux_codec.h
new file mode 100644
index 0000000000..8a3afbfe3c
--- /dev/null
+++ b/firmware/export/erosqlinux_codec.h
@@ -0,0 +1,13 @@
1#ifndef __EROSQLINUX_CODEC__
2#define __EROSQLINUX_CODEC__
3
4#define AUDIOHW_CAPS (LINEOUT_CAP)
5
6AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
7
8
9void audiohw_mute(int mute);
10void erosq_set_output(int ps);
11int erosq_get_outputs(void);
12
13#endif
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index 6b686eec0e..215b4c0c4b 100644
--- a/firmware/export/rbpaths.h
+++ b/firmware/export/rbpaths.h
@@ -42,7 +42,7 @@
42 42
43#if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \ 43#if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \
44 defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || \ 44 defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || \
45 defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(FIIO_M3K) 45 defined(HIBY_LINUX) || defined(FIIO_M3K)
46 46
47#if defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) 47#if defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1)
48#define HOME_DIR "/mnt/media0" 48#define HOME_DIR "/mnt/media0"
@@ -51,7 +51,7 @@
51#elif defined(DX50) || defined(DX90) 51#elif defined(DX50) || defined(DX90)
52/* Where to put save files like recordings, playlists, screen dumps ...*/ 52/* Where to put save files like recordings, playlists, screen dumps ...*/
53#define HOME_DIR "/mnt/sdcard" 53#define HOME_DIR "/mnt/sdcard"
54#elif defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20) 54#elif defined(HIBY_LINUX)
55#define HOME_DIR "/mnt/sd_0" 55#define HOME_DIR "/mnt/sd_0"
56#elif defined(FIIO_M3K) 56#elif defined(FIIO_M3K)
57#define HOME_DIR "/mnt" 57#define HOME_DIR "/mnt"
@@ -92,7 +92,7 @@
92#define VIEWERS_DIR PLUGIN_DIR "/viewers" 92#define VIEWERS_DIR PLUGIN_DIR "/viewers"
93 93
94#if defined(APPLICATION) && !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \ 94#if defined(APPLICATION) && !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \
95 defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) 95 defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX))
96#define PLUGIN_DATA_DIR ROCKBOX_DIR "/rocks.data" 96#define PLUGIN_DATA_DIR ROCKBOX_DIR "/rocks.data"
97#define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR 97#define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR
98#define PLUGIN_APPS_DATA_DIR PLUGIN_DATA_DIR 98#define PLUGIN_APPS_DATA_DIR PLUGIN_DATA_DIR
diff --git a/firmware/export/system.h b/firmware/export/system.h
index cfec235bc4..1885acfffd 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -347,7 +347,7 @@ static inline void cpu_boost_unlock(void)
347#ifndef SIMULATOR 347#ifndef SIMULATOR
348bool dbg_ports(void); 348bool dbg_ports(void);
349#endif 349#endif
350#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SONY_NWZ_LINUX) || defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20) 350#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX) || defined(FIIO_M3K)
351bool dbg_hw_info(void); 351bool dbg_hw_info(void);
352#endif 352#endif
353 353
diff --git a/firmware/font.c b/firmware/font.c
index 3208125a6a..b2ac1a3c3c 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -85,7 +85,7 @@
85/* compiled-in font */ 85/* compiled-in font */
86extern struct font sysfont; 86extern struct font sysfont;
87 87
88#if !defined(BOOTLOADER) || defined(SONY_NWZ_LINUX) 88#if !defined(BOOTLOADER) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX) || defined(FIIO_M3K)
89 89
90struct buflib_alloc_data { 90struct buflib_alloc_data {
91 struct font font; /* must be the first member! */ 91 struct font font; /* must be the first member! */
diff --git a/firmware/target/hosted/aigo/adc-target.h b/firmware/target/hosted/aigo/adc-target.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/firmware/target/hosted/aigo/adc-target.h
diff --git a/firmware/target/hosted/aigo/button-erosq.c b/firmware/target/hosted/aigo/button-erosq.c
new file mode 100644
index 0000000000..2735c48c71
--- /dev/null
+++ b/firmware/target/hosted/aigo/button-erosq.c
@@ -0,0 +1,188 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 * Copyright (C) 2020 Solomon Peachy
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <poll.h>
22//#include <dir.h>
23#include <errno.h>
24#include <unistd.h>
25#include <sys/types.h>
26#include <linux/input.h>
27#include <fcntl.h>
28#include <string.h>
29#include <stdlib.h>
30
31#include "sysfs.h"
32#include "button.h"
33#include "button-target.h"
34#include "panic.h"
35
36#include "kernel.h"
37#include "backlight.h"
38#include "backlight-target.h"
39#include "erosqlinux_codec.h"
40
41#define NR_POLL_DESC 3
42static struct pollfd poll_fds[NR_POLL_DESC];
43
44static int button_map(int keycode)
45{
46 switch(keycode)
47 {
48 case KEY_POWER:
49 return BUTTON_POWER;
50
51 case KEY_MENU:
52 return BUTTON_MENU;
53
54 case KEY_BACK:
55 return BUTTON_BACK;
56
57 case KEY_NEXTSONG:
58 return BUTTON_PREV;
59
60 case KEY_PREVIOUSSONG:
61 return BUTTON_NEXT; // Yes, backwards!
62
63 case KEY_PLAYPAUSE:
64 return BUTTON_PLAY;
65
66 case KEY_LEFT:
67 return BUTTON_SCROLL_BACK;
68
69 case KEY_RIGHT:
70 return BUTTON_SCROLL_FWD;
71
72 case KEY_VOLUMEUP:
73 return BUTTON_VOL_UP;
74
75 case KEY_VOLUMEDOWN:
76 return BUTTON_VOL_DOWN;
77
78 default:
79 return 0;
80 }
81}
82
83void button_init_device(void)
84{
85 const char * const input_devs[] = {
86 "/dev/input/event0", // Rotary encoder
87 "/dev/input/event1" // Keys
88 };
89
90 for(int i = 0; i < NR_POLL_DESC; i++)
91 {
92 int fd = open(input_devs[i], O_RDWR | O_CLOEXEC);
93
94 if(fd < 0)
95 {
96 panicf("Cannot open input device: %s\n", input_devs[i]);
97 }
98
99 poll_fds[i].fd = fd;
100 poll_fds[i].events = POLLIN;
101 poll_fds[i].revents = 0;
102 }
103}
104
105int button_read_device(void)
106{
107 static int button_bitmap = 0;
108 struct input_event event;
109
110 // FIXME TODO: Make this work via HAVE_SCROLL_WHEEL instead
111
112 /* Wheel gives us press+release back to back, clear them after time elapses */
113 static long last_tick = 0;
114 if (button_bitmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD) &&
115 current_tick - last_tick >= 2)
116 {
117 button_bitmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
118 }
119
120 /* check if there are any events pending and process them */
121 while(poll(poll_fds, NR_POLL_DESC, 0))
122 {
123 for(int i = 0; i < NR_POLL_DESC; i++)
124 {
125 /* read only if non-blocking */
126 if(poll_fds[i].revents & POLLIN)
127 {
128 int size = read(poll_fds[i].fd, &event, sizeof(event));
129 if(size == (int)sizeof(event))
130 {
131 int keycode = event.code;
132 /* event.value == 1 means press
133 * event.value == 0 means release
134 */
135 bool press = event.value ? true : false;
136
137 /* map linux event code to rockbox button bitmap */
138 if(press)
139 {
140 int bmap = button_map(keycode);
141 if (bmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD))
142 last_tick = current_tick;
143 button_bitmap |= bmap;
144 }
145 else
146 {
147 /* Wheel gives us press+release back to back; ignore the release */
148 int bmap = button_map(keycode) & ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
149 button_bitmap &= ~bmap;
150 }
151 }
152 }
153 }
154 }
155
156 return button_bitmap;
157}
158
159bool headphones_inserted(void)
160{
161#ifdef BOOTLOADER
162 int ps = 0;
163#else
164 int ps = erosq_get_outputs();
165#endif
166
167 return (ps == 2);
168}
169
170bool lineout_inserted(void)
171{
172#ifdef BOOTLOADER
173 int ps = 0;
174#else
175 int ps = erosq_get_outputs();
176#endif
177
178 return (ps == 1);
179}
180
181void button_close_device(void)
182{
183 /* close descriptors */
184 for(int i = 0; i < NR_POLL_DESC; i++)
185 {
186 close(poll_fds[i].fd);
187 }
188}
diff --git a/firmware/target/hosted/aigo/button-target.h b/firmware/target/hosted/aigo/button-target.h
new file mode 100644
index 0000000000..f59f491d2f
--- /dev/null
+++ b/firmware/target/hosted/aigo/button-target.h
@@ -0,0 +1,45 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2020 Solomon Peachy
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23/* Main unit's buttons */
24#define BUTTON_POWER 0x00000001
25#define BUTTON_MENU 0x00000002
26#define BUTTON_BACK 0x00000004
27#define BUTTON_PLAY 0x00000008
28#define BUTTON_NEXT 0x00000010
29#define BUTTON_PREV 0x00000020
30#define BUTTON_VOL_UP 0x00000040
31#define BUTTON_VOL_DOWN 0x00000080
32#define BUTTON_SCROLL_BACK 0x00000100
33#define BUTTON_SCROLL_FWD 0x00000200
34
35#define BUTTON_MAIN (BUTTON_POWER | BUTTON_MENU | BUTTON_BACK | BUTTON_PREV | \
36 BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD)
37
38#define BUTTON_LEFT BUTTON_PREV
39#define BUTTON_RIGHT BUTTON_NEXT
40
41/* Software power-off */
42#define POWEROFF_BUTTON BUTTON_POWER
43#define POWEROFF_COUNT 25
44
45#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/hosted/aigo/debug-erosq.c b/firmware/target/hosted/aigo/debug-erosq.c
new file mode 100644
index 0000000000..9812b8f8b9
--- /dev/null
+++ b/firmware/target/hosted/aigo/debug-erosq.c
@@ -0,0 +1 @@
#include "../agptek/debug-agptek.c"
diff --git a/firmware/target/hosted/aigo/erosq.make b/firmware/target/hosted/aigo/erosq.make
new file mode 100644
index 0000000000..d159db77f3
--- /dev/null
+++ b/firmware/target/hosted/aigo/erosq.make
@@ -0,0 +1,49 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
10INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
11
12SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
13
14# bootloader build is sligtly different
15ifneq (,$(findstring bootloader,$(APPSDIR)))
16
17SRC += $(call preprocess, $(APPSDIR)/SOURCES)
18CLEANOBJS += $(BUILDDIR)/bootloader.*
19
20endif #bootloader
21
22.SECONDEXPANSION: # $$(OBJ) is not populated until after this
23
24ifneq (,$(findstring bootloader,$(APPSDIR)))
25# bootloader build
26
27$(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS)
28 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
29 -L$(BUILDDIR)/firmware -lfirmware \
30 -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
31 $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
32
33$(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf
34 $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
35
36else
37# rockbox app build
38
39$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
40 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
41 -L$(BUILDDIR)/firmware -lfirmware \
42 -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
43 -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
44 $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
45
46$(BUILDDIR)/$(BINARY): $(BUILDDIR)/rockbox.elf
47 $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
48
49endif
diff --git a/firmware/target/hosted/aigo/lcd-target.h b/firmware/target/hosted/aigo/lcd-target.h
new file mode 100644
index 0000000000..808df3c60a
--- /dev/null
+++ b/firmware/target/hosted/aigo/lcd-target.h
@@ -0,0 +1,32 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2016 Amaury Pouly
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#ifndef __LCD_TARGET_H__
22#define __LCD_TARGET_H__
23
24/* needs special ioctl() to redraw updated framebuffer content */
25#define LCD_OPTIMIZED_UPDATE
26#define LCD_OPTIMIZED_UPDATE_RECT
27
28extern fb_data *framebuffer; /* see lcd-erosq.c */
29#define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col))
30
31extern void lcd_set_active(bool active);
32#endif /* __LCD_TARGET_H__ */
diff --git a/firmware/target/hosted/aigo/power-erosq.c b/firmware/target/hosted/aigo/power-erosq.c
new file mode 100644
index 0000000000..0a4f820337
--- /dev/null
+++ b/firmware/target/hosted/aigo/power-erosq.c
@@ -0,0 +1,74 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include <sys/types.h>
21#include <fcntl.h>
22#include <string.h>
23#include <unistd.h>
24#include <stdio.h>
25
26#include "system.h"
27#include "power-erosq.h"
28#include "power.h"
29#include "panic.h"
30#include "sysfs.h"
31
32const char * const sysfs_bat_voltage =
33 "/sys/class/power_supply/battery/voltage_now";
34
35const char * const sysfs_bat_capacity =
36 "/sys/class/power_supply/battery/capacity";
37
38const char * const sysfs_bat_status =
39 "/sys/class/power_supply/battery/status";
40
41const char * const sysfs_pow_supply =
42 "/sys/class/power_supply/usb/present";
43
44unsigned int erosq_power_input_status(void)
45{
46 int present = 0;
47 sysfs_get_int(sysfs_pow_supply, &present);
48
49 return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
50}
51
52bool erosq_power_charging_status(void)
53{
54 char buf[12] = {0};
55 sysfs_get_string(sysfs_bat_status, buf, sizeof(buf));
56
57 return (strncmp(buf, "Charging", 8) == 0);
58}
59
60unsigned int erosq_power_get_battery_voltage(void)
61{
62 int battery_voltage;
63 sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
64
65 return battery_voltage/1000;
66}
67
68unsigned int erosq_power_get_battery_capacity(void)
69{
70 int battery_capacity;
71 sysfs_get_int(sysfs_bat_capacity, &battery_capacity);
72
73 return battery_capacity;
74}
diff --git a/firmware/target/hosted/aigo/power-erosq.h b/firmware/target/hosted/aigo/power-erosq.h
new file mode 100644
index 0000000000..d06b956924
--- /dev/null
+++ b/firmware/target/hosted/aigo/power-erosq.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#ifndef _POWER_XDUOO_H_
21#define _POWER_XDUOO_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26unsigned int erosq_power_input_status(void);
27bool erosq_power_charging_status(void);
28unsigned int erosq_power_get_battery_voltage(void);
29unsigned int erosq_power_get_battery_capacity(void);
30#endif /* _POWER_XDUOO_H_ */
31
diff --git a/firmware/target/hosted/aigo/powermgmt-erosq.c b/firmware/target/hosted/aigo/powermgmt-erosq.c
new file mode 100644
index 0000000000..14286de3fd
--- /dev/null
+++ b/firmware/target/hosted/aigo/powermgmt-erosq.c
@@ -0,0 +1,61 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "powermgmt.h"
21#include "power.h"
22#include "power-erosq.h"
23
24const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
25{
26 3470
27};
28
29/* the OF shuts down at this voltage */
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3400
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 { 3400, 3639, 3697, 3723, 3757, 3786, 3836, 3906, 3980, 4050, 4159 }
39};
40
41/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
42const unsigned short const percent_to_volt_charge[11] =
43{
44 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
45};
46
47unsigned int power_input_status(void)
48{
49 /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */
50 return erosq_power_input_status();
51}
52
53int _battery_voltage(void)
54{
55 return erosq_power_get_battery_voltage();
56}
57
58bool charging_state(void)
59{
60 return erosq_power_charging_status();
61}
diff --git a/firmware/target/hosted/aigo/system-target.h b/firmware/target/hosted/aigo/system-target.h
new file mode 100644
index 0000000000..830f19fde4
--- /dev/null
+++ b/firmware/target/hosted/aigo/system-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 * Copyright (C) 2016 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __SYSTEM_TARGET_H__
22#define __SYSTEM_TARGET_H__
23
24#include "kernel-unix.h"
25#include "system-hosted.h"
26
27#define NEED_GENERIC_BYTESWAPS
28#endif /* __SYSTEM_TARGET_H__ */
diff --git a/firmware/target/hosted/aigo/usb-erosq.c b/firmware/target/hosted/aigo/usb-erosq.c
new file mode 100644
index 0000000000..2a3acf4d62
--- /dev/null
+++ b/firmware/target/hosted/aigo/usb-erosq.c
@@ -0,0 +1,118 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2018 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include <stdlib.h>
22#include <sys/mount.h>
23#include <string.h>
24#include "config.h"
25#include "disk.h"
26#include "usb.h"
27#include "sysfs.h"
28#include "power.h"
29#include "power-erosq.h"
30
31static bool adb_mode = false;
32
33/* TODO: implement usb detection properly */
34int usb_detect(void)
35{
36 return power_input_status() == POWER_INPUT_USB_CHARGER ? USB_INSERTED : USB_EXTRACTED;
37}
38
39void usb_enable(bool on)
40{
41 /* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell
42 * without entering ums mode
43 */
44 if (!adb_mode)
45 {
46 sysfs_set_int("/sys/class/android_usb/android0/enable", on ? 1 : 0);
47 }
48}
49
50/* This is called by usb thread after usb extract in order to return
51 * regular FS access
52 *
53 * returns the # of successful mounts
54*/
55int disk_mount_all(void)
56{
57 const char *dev[] = {"/dev/mmcblk0p1", "/dev/mmcblk0"};
58 const char *fs[] = {"vfat", "exfat"};
59
60 sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "");
61
62 for (int i=0; i<2; i++)
63 {
64 for (int j=0; j<2; j++)
65 {
66 if (mount(dev[i], "/mnt/sd_0", fs[j], 0, NULL) == 0)
67 {
68 return 1;
69 }
70 }
71 }
72
73 return 0;
74}
75
76/* This is called by usb thread after all threads ACKs usb inserted message
77 *
78 * returns the # of successful unmounts
79 */
80int disk_unmount_all(void)
81{
82 if (umount("/mnt/sd_0") == 0)
83 {
84 sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
85 return 1;
86 }
87
88 return 0;
89}
90
91void usb_init_device(void)
92{
93 char functions[32] = {0};
94
95 /* Check if ADB was activated in bootloader */
96 sysfs_get_string("/sys/class/android_usb/android0/functions", functions, sizeof(functions));
97 adb_mode = (strstr(functions, "adb") == NULL) ? false : true;
98
99 usb_enable(false);
100
101 if (adb_mode)
102 {
103 sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage,adb");
104 sysfs_set_string("/sys/class/android_usb/android0/idVendor", "18D1");
105 sysfs_set_string("/sys/class/android_usb/android0/idProduct", "D002");
106 }
107 else
108 {
109 sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage");
110 sysfs_set_string("/sys/class/android_usb/android0/idVendor", "C502");
111 sysfs_set_string("/sys/class/android_usb/android0/idProduct", "0023");
112 }
113
114 sysfs_set_string("/sys/class/android_usb/android0/iManufacturer", "Rockbox.org");
115 sysfs_set_string("/sys/class/android_usb/android0/iProduct", "Rockbox media player");
116 sysfs_set_string("/sys/class/android_usb/android0/iSerial", "0123456789ABCDEF");
117 sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/inquiry_string", "ErosQ 0100");
118}
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c
index 4e2fa8db7b..24c5a7e062 100644
--- a/firmware/target/hosted/filesystem-app.c
+++ b/firmware/target/hosted/filesystem-app.c
@@ -37,7 +37,7 @@
37#include "logf.h" 37#include "logf.h"
38 38
39#if !(defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR)) 39#if !(defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR))
40#if (defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) 40#if defined(HIBY_LINUX)
41#define PIVOT_ROOT "/mnt/sd_0" 41#define PIVOT_ROOT "/mnt/sd_0"
42#elif defined(FIIO_M3K) 42#elif defined(FIIO_M3K)
43#define PIVOT_ROOT "/mnt" // XXX check this! 43#define PIVOT_ROOT "/mnt" // XXX check this!
@@ -56,8 +56,8 @@ static const char rbhome[] = HOME_DIR;
56#endif 56#endif
57 57
58#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ 58#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \
59 defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER) || \ 59 defined(SONY_NWZ_LINUX) || defined(DX90) || defined(HIBY_LINUX) || \
60 defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(FIIO_M3K) || defined(FIIO_M3K_PRO)) && \ 60 defined(FIIO_M3K)) && \
61 !defined(__PCTOOL__) 61 !defined(__PCTOOL__)
62/* Special dirs are user-accessible (and user-writable) dirs which take priority 62/* Special dirs are user-accessible (and user-writable) dirs which take priority
63 * over the ones where Rockbox is installed to. Classic example would be 63 * over the ones where Rockbox is installed to. Classic example would be
diff --git a/firmware/target/hosted/xduoo/button-target.h b/firmware/target/hosted/xduoo/button-target.h
index d41b33894a..3240d3df8e 100644
--- a/firmware/target/hosted/xduoo/button-target.h
+++ b/firmware/target/hosted/xduoo/button-target.h
@@ -41,4 +41,3 @@
41#define POWEROFF_COUNT 25 41#define POWEROFF_COUNT 25
42 42
43#endif /* _BUTTON_TARGET_H_ */ 43#endif /* _BUTTON_TARGET_H_ */
44