summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2018-11-05 13:01:55 +0100
committerSolomon Peachy <pizza@shaftnet.org>2020-04-06 18:15:41 +0200
commit180cef835bf40d0081895773aaa637ac926bb0ac (patch)
tree48c380d76c0ea40931cb5e863b40fc5dfa1ecba4 /firmware
parentced3a20aacf26642ccc3ffd136f64247c67e5769 (diff)
downloadrockbox-180cef835bf40d0081895773aaa637ac926bb0ac.tar.gz
rockbox-180cef835bf40d0081895773aaa637ac926bb0ac.zip
xDuoo X3II and X20 port
Provided by Roman Stolyarov Integration, Refactoring, and Upstreaming by Solomon Peachy X3II confirmed working by forum tester, X20 is nearly identical. This includes bootloader, main firmware, and the flash image patcher. Eventual Todo: * Further refactor AGPTek Rocker & xduoo hiby bootloaders * Further refactor AGPTek Rocker & xduoo hosted platform code Change-Id: I34a674051d368efcc75d1d18c725971fe46c3eee
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES38
-rw-r--r--firmware/asm/SOURCES2
-rw-r--r--firmware/drivers/audio/xduoolinux_codec.c122
-rw-r--r--firmware/export/audiohw.h2
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/export/config/agptekrocker.h2
-rw-r--r--firmware/export/config/xduoox20.h126
-rw-r--r--firmware/export/config/xduoox3ii.h126
-rw-r--r--firmware/export/rbpaths.h2
-rw-r--r--firmware/export/xduoolinux_codec.h7
-rw-r--r--firmware/target/hosted/backlight-target.h (renamed from firmware/target/hosted/agptek/backlight-target.h)0
-rw-r--r--firmware/target/hosted/backlight-unix.c (renamed from firmware/target/hosted/agptek/backlight-agptek.c)0
-rw-r--r--firmware/target/hosted/filesystem-app.c6
-rw-r--r--firmware/target/hosted/rtc.c2
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h16
-rw-r--r--firmware/target/hosted/sysfs.c (renamed from firmware/target/hosted/agptek/sysfs.c)0
-rw-r--r--firmware/target/hosted/sysfs.h (renamed from firmware/target/hosted/agptek/sysfs.h)0
-rw-r--r--firmware/target/hosted/system-hosted.c (renamed from firmware/target/hosted/agptek/system-agptek.c)0
-rw-r--r--firmware/target/hosted/xduoo/adc-target.h0
-rw-r--r--firmware/target/hosted/xduoo/button-target.h46
-rw-r--r--firmware/target/hosted/xduoo/button-xduoo.c202
-rw-r--r--firmware/target/hosted/xduoo/debug-xduoo.c6
-rw-r--r--firmware/target/hosted/xduoo/lcd-target.h32
-rw-r--r--firmware/target/hosted/xduoo/lcd-xduoo.c140
-rw-r--r--firmware/target/hosted/xduoo/power-xduoo.c74
-rw-r--r--firmware/target/hosted/xduoo/power-xduoo.h31
-rw-r--r--firmware/target/hosted/xduoo/powermgmt-xduoo.c70
-rw-r--r--firmware/target/hosted/xduoo/system-target.h28
-rw-r--r--firmware/target/hosted/xduoo/usb-xduoo.c118
-rw-r--r--firmware/target/hosted/xduoo/xduoo.make52
30 files changed, 1236 insertions, 20 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 89f4f52895..7be6010ab7 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -113,25 +113,37 @@ target/hosted/sonynwz/nvp-nwz.c
113target/hosted/sonynwz/nwz-db.c 113target/hosted/sonynwz/nwz-db.c
114#endif 114#endif
115 115
116#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR) 116#if ((defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(SIMULATOR))
117drivers/lcd-memframe.c 117drivers/lcd-memframe.c
118target/hosted/alsa-controls.c
119target/hosted/pcm-alsa.c
118target/hosted/backtrace-glibc.c 120target/hosted/backtrace-glibc.c
119target/hosted/kernel-unix.c
120target/hosted/filesystem-unix.c 121target/hosted/filesystem-unix.c
122target/hosted/kernel-unix.c
121target/hosted/lc-unix.c 123target/hosted/lc-unix.c
122target/hosted/alsa-controls.c 124target/hosted/sysfs.c
123target/hosted/pcm-alsa.c 125target/hosted/backlight-unix.c
124target/hosted/agptek/sysfs.c 126target/hosted/system-hosted.c
125target/hosted/agptek/backlight-agptek.c 127#endif
128
129#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR)
126target/hosted/agptek/button-agptek.c 130target/hosted/agptek/button-agptek.c
127target/hosted/agptek/debug-agptek.c 131target/hosted/agptek/debug-agptek.c
128target/hosted/agptek/lcd-agptek.c 132target/hosted/agptek/lcd-agptek.c
129target/hosted/agptek/power-agptek.c 133target/hosted/agptek/power-agptek.c
130target/hosted/agptek/powermgmt-agptek.c 134target/hosted/agptek/powermgmt-agptek.c
131target/hosted/agptek/system-agptek.c
132target/hosted/agptek/usb-agptek.c 135target/hosted/agptek/usb-agptek.c
133#endif 136#endif
134 137
138#if ((defined(XDUOO_X3II)||defined(XDUOO_X20)) && !defined(SIMULATOR))
139target/hosted/xduoo/button-xduoo.c
140target/hosted/xduoo/debug-xduoo.c
141target/hosted/xduoo/lcd-xduoo.c
142target/hosted/xduoo/power-xduoo.c
143target/hosted/xduoo/powermgmt-xduoo.c
144target/hosted/xduoo/usb-xduoo.c
145#endif
146
135#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR) 147#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR)
136drivers/adc-as3514.c 148drivers/adc-as3514.c
137#if (CONFIG_RTC == RTC_AS3514) 149#if (CONFIG_RTC == RTC_AS3514)
@@ -502,6 +514,8 @@ target/hosted/alsa-controls.c
502target/hosted/pcm-alsa.c 514target/hosted/pcm-alsa.c
503#elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR) 515#elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR)
504drivers/audio/rocker_codec.c 516drivers/audio/rocker_codec.c
517#elif defined(HAVE_XDUOO_LINUX_CODEC) && !defined(SIMULATOR)
518drivers/audio/xduoolinux_codec.c
505#elif defined(HAVE_SDL_AUDIO) 519#elif defined(HAVE_SDL_AUDIO)
506drivers/audio/sdl.c 520drivers/audio/sdl.c
507#if CONFIG_CODEC == SWCODEC 521#if CONFIG_CODEC == SWCODEC
@@ -584,7 +598,7 @@ target/arm/ipod/powermgmt-ipod-pcf.c
584target/arm/pp/i2c-pp.c 598target/arm/pp/i2c-pp.c
585#elif CONFIG_I2C == I2C_PNX0101 599#elif CONFIG_I2C == I2C_PNX0101
586target/arm/pnx0101/i2c-pnx0101.c 600target/arm/pnx0101/i2c-pnx0101.c
587#elif CONFIG_I2C == I2C_TCC780X || CONFIG_I2C == I2C_TCC77X 601#elif CONFIG_I2C == I2C_TCC780X || CONFIG_I2C == I2C_TCC77X
588target/arm/i2c-telechips.c 602target/arm/i2c-telechips.c
589#elif CONFIG_I2C == I2C_S3C2440 603#elif CONFIG_I2C == I2C_S3C2440
590target/arm/s3c2440/i2c-s3c2440.c 604target/arm/s3c2440/i2c-s3c2440.c
@@ -837,9 +851,9 @@ drivers/isp1583.c
837target/arm/rk27xx/usb-drv-rk27xx.c 851target/arm/rk27xx/usb-drv-rk27xx.c
838#endif 852#endif
839#else /* !defined(HAVE_USBSTACK) */ 853#else /* !defined(HAVE_USBSTACK) */
840#if CONFIG_USBOTG == USBOTG_ISP1362 854#if CONFIG_USBOTG == USBOTG_ISP1362
841drivers/isp1362.c 855drivers/isp1362.c
842#elif CONFIG_USBOTG == USBOTG_M5636 856#elif CONFIG_USBOTG == USBOTG_M5636
843drivers/m5636.c 857drivers/m5636.c
844#endif 858#endif
845#endif /* !defined(HAVE_USBSTACK) */ 859#endif /* !defined(HAVE_USBSTACK) */
@@ -1415,7 +1429,7 @@ target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
1415target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c 1429target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c
1416target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c 1430target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c
1417target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c 1431target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
1418target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c 1432target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
1419#ifndef BOOTLOADER 1433#ifndef BOOTLOADER
1420target/arm/pnx0101/pcm-pnx0101.c 1434target/arm/pnx0101/pcm-pnx0101.c
1421#endif /* BOOTLOADER */ 1435#endif /* BOOTLOADER */
@@ -1989,7 +2003,7 @@ target/hosted/ibasso/dx90/button-dx90.c
1989#ifdef WIN32 2003#ifdef WIN32
1990asm/mempcpy.c 2004asm/mempcpy.c
1991target/hosted/filesystem-win32.c 2005target/hosted/filesystem-win32.c
1992#else /* !WIN32 */ 2006#else /* !WIN32 */
1993target/hosted/filesystem-unix.c 2007target/hosted/filesystem-unix.c
1994#endif /* WIN32 */ 2008#endif /* WIN32 */
1995target/hosted/sdl/load_code-sdl.c 2009target/hosted/sdl/load_code-sdl.c
diff --git a/firmware/asm/SOURCES b/firmware/asm/SOURCES
index eba5bd2cb6..085b6351a5 100644
--- a/firmware/asm/SOURCES
+++ b/firmware/asm/SOURCES
@@ -15,7 +15,7 @@ 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(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && \
19 !defined(SIMULATOR) 19 !defined(SIMULATOR)
20#if LCD_DEPTH >= 24 20#if LCD_DEPTH >= 24
21lcd-as-memframe-24bit.c 21lcd-as-memframe-24bit.c
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c
new file mode 100644
index 0000000000..5db4902e5f
--- /dev/null
+++ b/firmware/drivers/audio/xduoolinux_codec.c
@@ -0,0 +1,122 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 *
11 * Copyright (c) 2018 Marcin Bukat
12 * Copyright (c) 2018 Roman Stolyarov
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#include "config.h"
25#include "audio.h"
26#include "audiohw.h"
27#include "system.h"
28#include "kernel.h"
29#include "panic.h"
30#include "sysfs.h"
31#include "alsa-controls.h"
32
33static int fd_hw;
34
35static void hw_open(void)
36{
37 fd_hw = open("/dev/snd/controlC0", O_RDWR);
38 if(fd_hw < 0)
39 panicf("Cannot open '/dev/snd/controlC0'");
40}
41
42static void hw_close(void)
43{
44 close(fd_hw);
45}
46
47void audiohw_preinit(void)
48{
49 alsa_controls_init();
50 hw_open();
51}
52
53void audiohw_postinit(void)
54{
55 long int ps = 2; // headset
56 int status = 0;
57
58 const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
59 const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
60#ifdef XDUOO_X20
61 const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
62#endif
63
64#if defined(XDUOO_X3II)
65 alsa_controls_set_bool("AK4490 Soft Mute", true);
66#endif
67
68 sysfs_get_int(sysfs_lo_switch, &status);
69 if (status) ps = 1; // lineout
70
71 sysfs_get_int(sysfs_hs_switch, &status);
72 if (status) ps = 2; // headset
73
74#ifdef XDUOO_X20
75 sysfs_get_int(sysfs_bal_switch, &status);
76 if (status) ps = 3; // balance
77#endif
78
79 /* Output port switch */
80 alsa_controls_set_ints("Output Port Switch", 1, &ps);
81
82#if defined(XDUOO_X3II)
83 alsa_controls_set_bool("AK4490 Soft Mute", false);
84#endif
85}
86
87void audiohw_close(void)
88{
89 hw_close();
90 alsa_controls_close();
91}
92
93void audiohw_set_frequency(int fsel)
94{
95 (void)fsel;
96}
97
98void audiohw_set_volume(int vol_l, int vol_r)
99{
100 long int vol_l_hw = -vol_l/5;
101 long int vol_r_hw = -vol_r/5;
102
103 alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw);
104 alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw);
105}
106
107void audiohw_set_filter_roll_off(int value)
108{
109 /* 0 = fast (sharp);
110 1 = slow;
111 2 = fast2
112 3 = slow2
113 4 = NOS ? */
114 long int value_hw = value;
115#if defined(XDUOO_X3II)
116 alsa_controls_set_ints("AK4490 Digital Filter", 1, &value_hw);
117#elif defined(XDUOO_X20)
118 alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw);
119#else
120 (void)value;
121#endif
122}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 458fba3412..00bb15812d 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -224,6 +224,8 @@ struct sound_settings_info
224#include "codec-dx90.h" 224#include "codec-dx90.h"
225#elif defined(HAVE_ROCKER_CODEC) 225#elif defined(HAVE_ROCKER_CODEC)
226#include "rocker_codec.h" 226#include "rocker_codec.h"
227#elif defined(HAVE_XDUOO_LINUX_CODEC)
228#include "rocker_codec.h"
227#endif 229#endif
228 230
229/* convert caps into defines */ 231/* convert caps into defines */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index a41cceff59..c55d489c26 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -171,6 +171,8 @@
171#define XDUOO_X3_PAD 66 171#define XDUOO_X3_PAD 66
172#define IHIFI_770_PAD 67 172#define IHIFI_770_PAD 67
173#define IHIFI_800_PAD 68 173#define IHIFI_800_PAD 68
174#define XDUOO_X3II_PAD 69
175#define XDUOO_X20_PAD 70
174 176
175/* CONFIG_REMOTE_KEYPAD */ 177/* CONFIG_REMOTE_KEYPAD */
176#define H100_REMOTE 1 178#define H100_REMOTE 1
@@ -624,6 +626,10 @@ Lyre prototype 1 */
624#include "config/agptekrocker.h" 626#include "config/agptekrocker.h"
625#elif defined(XDUOO_X3) 627#elif defined(XDUOO_X3)
626#include "config/xduoox3.h" 628#include "config/xduoox3.h"
629#elif defined(XDUOO_X3II)
630#include "config/xduoox3ii.h"
631#elif defined(XDUOO_X20)
632#include "config/xduoox20.h"
627#else 633#else
628/* no known platform */ 634/* no known platform */
629#endif 635#endif
diff --git a/firmware/export/config/agptekrocker.h b/firmware/export/config/agptekrocker.h
index 172e079721..372287f4b5 100644
--- a/firmware/export/config/agptekrocker.h
+++ b/firmware/export/config/agptekrocker.h
@@ -3,7 +3,7 @@
3 */ 3 */
4 4
5/* For Rolo and boot loader */ 5/* For Rolo and boot loader */
6#define MODEL_NUMBER 103//??? 6#define MODEL_NUMBER 105
7 7
8#define MODEL_NAME "Agptek Rocker" 8#define MODEL_NAME "Agptek Rocker"
9 9
diff --git a/firmware/export/config/xduoox20.h b/firmware/export/config/xduoox20.h
new file mode 100644
index 0000000000..d451ba31f4
--- /dev/null
+++ b/firmware/export/config/xduoox20.h
@@ -0,0 +1,126 @@
1/*
2 * This config file is for the xDuoo X20
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 111
7
8#define MODEL_NAME "xDuoo X20"
9
10/* LCD dimensions */
11#define LCD_WIDTH 240
12#define LCD_HEIGHT 320
13/* sqrt(240^2 + 320^2) / 2.4 = 166 */
14#define LCD_DPI 166
15
16#ifndef SIMULATOR
17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif
19
20/* define this if you have a bitmap LCD display */
21#define HAVE_LCD_BITMAP
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 2555. But 0 is off so start at 1.
55 */
56#define MIN_BRIGHTNESS_SETTING 1
57#define MAX_BRIGHTNESS_SETTING 255
58#define DEFAULT_BRIGHTNESS_SETTING 70
59
60/* Which backlight fading type? */
61#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
62
63/* define this if you have a real-time clock */
64#define CONFIG_RTC APPLICATION
65
66/* The number of bytes reserved for loadable codecs */
67#define CODEC_SIZE 0x80000
68
69/* The number of bytes reserved for loadable plugins */
70#define PLUGIN_BUFFER_SIZE 0x100000
71
72/* Define this if you do software codec */
73#define CONFIG_CODEC SWCODEC
74
75#define HAVE_HEADPHONE_DETECTION
76
77/* KeyPad configuration for plugins */
78#define CONFIG_KEYPAD XDUOO_X20_PAD
79
80/* Define this if a programmable hotkey is mapped */
81#define HAVE_HOTKEY
82
83/* define this if the target has volume keys which can be used in the lists */
84#define HAVE_VOLUME_IN_LIST
85
86#ifndef SIMULATOR
87/* We have usb power and can detect usb but it is handled by Linux */
88#define HAVE_USB_POWER
89
90#endif
91
92#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
93
94/* Linux controlls charging, we can monitor */
95#define CONFIG_CHARGING CHARGING_MONITOR
96
97/* define this if the hardware can be powered off while charging */
98#define HAVE_POWEROFF_WHILE_CHARGING
99
100/* same dimensions as gigabeats */
101#define CONFIG_LCD LCD_INGENIC_LINUX
102
103/* Define this if you have a software controlled poweroff */
104#define HAVE_SW_POWEROFF
105
106/* Define this to the CPU frequency */
107#define CPU_FREQ 504000000
108
109/* No special storage */
110#define CONFIG_STORAGE STORAGE_HOSTFS
111#define HAVE_STORAGE_FLUSH
112
113/* Battery */
114#define BATTERY_TYPES_COUNT 1
115
116/* Audio codec */
117#define HAVE_XDUOO_LINUX_CODEC
118
119/* We don't have hardware controls */
120#define HAVE_SW_TONE_CONTROLS
121
122/* Battery */
123#define BATTERY_CAPACITY_DEFAULT 2400 /* default battery capacity */
124#define BATTERY_CAPACITY_MIN 2400 /* min. capacity selectable */
125#define BATTERY_CAPACITY_MAX 2400 /* max. capacity selectable */
126#define BATTERY_CAPACITY_INC 0 /* capacity increment */
diff --git a/firmware/export/config/xduoox3ii.h b/firmware/export/config/xduoox3ii.h
new file mode 100644
index 0000000000..af63c4f97b
--- /dev/null
+++ b/firmware/export/config/xduoox3ii.h
@@ -0,0 +1,126 @@
1/*
2 * This config file is for the xDuoo X3ii
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 110
7
8#define MODEL_NAME "xDuoo X3ii"
9
10/* LCD dimensions */
11#define LCD_WIDTH 240
12#define LCD_HEIGHT 320
13/* sqrt(240^2 + 320^2) / 2.4 = 166 */
14#define LCD_DPI 166
15
16#ifndef SIMULATOR
17#define CONFIG_PLATFORM (PLATFORM_HOSTED)
18#endif
19
20/* define this if you have a bitmap LCD display */
21#define HAVE_LCD_BITMAP
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 2555. But 0 is off so start at 1.
55 */
56#define MIN_BRIGHTNESS_SETTING 1
57#define MAX_BRIGHTNESS_SETTING 255
58#define DEFAULT_BRIGHTNESS_SETTING 70
59
60/* Which backlight fading type? */
61#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
62
63/* define this if you have a real-time clock */
64#define CONFIG_RTC APPLICATION
65
66/* The number of bytes reserved for loadable codecs */
67#define CODEC_SIZE 0x80000
68
69/* The number of bytes reserved for loadable plugins */
70#define PLUGIN_BUFFER_SIZE 0x100000
71
72/* Define this if you do software codec */
73#define CONFIG_CODEC SWCODEC
74
75#define HAVE_HEADPHONE_DETECTION
76
77/* KeyPad configuration for plugins */
78#define CONFIG_KEYPAD XDUOO_X3II_PAD
79
80/* Define this if a programmable hotkey is mapped */
81#define HAVE_HOTKEY
82
83/* define this if the target has volume keys which can be used in the lists */
84#define HAVE_VOLUME_IN_LIST
85
86#ifndef SIMULATOR
87/* We have usb power and can detect usb but it is handled by Linux */
88#define HAVE_USB_POWER
89
90#endif
91
92#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
93
94/* Linux controlls charging, we can monitor */
95#define CONFIG_CHARGING CHARGING_MONITOR
96
97/* define this if the hardware can be powered off while charging */
98#define HAVE_POWEROFF_WHILE_CHARGING
99
100/* same dimensions as gigabeats */
101#define CONFIG_LCD LCD_INGENIC_LINUX
102
103/* Define this if you have a software controlled poweroff */
104#define HAVE_SW_POWEROFF
105
106/* Define this to the CPU frequency */
107#define CPU_FREQ 504000000
108
109/* No special storage */
110#define CONFIG_STORAGE STORAGE_HOSTFS
111#define HAVE_STORAGE_FLUSH
112
113/* Battery */
114#define BATTERY_TYPES_COUNT 1
115
116/* Audio codec */
117#define HAVE_XDUOO_LINUX_CODEC
118
119/* We don't have hardware controls */
120#define HAVE_SW_TONE_CONTROLS
121
122/* Battery */
123#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */
124#define BATTERY_CAPACITY_MIN 2000 /* min. capacity selectable */
125#define BATTERY_CAPACITY_MAX 2000 /* max. capacity selectable */
126#define BATTERY_CAPACITY_INC 0 /* capacity increment */
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index 165dd37494..b95f1614eb 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) 45 defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)
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"
diff --git a/firmware/export/xduoolinux_codec.h b/firmware/export/xduoolinux_codec.h
new file mode 100644
index 0000000000..ccd49f09aa
--- /dev/null
+++ b/firmware/export/xduoolinux_codec.h
@@ -0,0 +1,7 @@
1#ifndef __XDUOOLINUX_CODEC__
2#define __XDUOOLINUX_CODEC__
3
4#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP)
5AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -127, 0, -30)
6AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 4, 0)
7#endif
diff --git a/firmware/target/hosted/agptek/backlight-target.h b/firmware/target/hosted/backlight-target.h
index e3b8a7bd78..e3b8a7bd78 100644
--- a/firmware/target/hosted/agptek/backlight-target.h
+++ b/firmware/target/hosted/backlight-target.h
diff --git a/firmware/target/hosted/agptek/backlight-agptek.c b/firmware/target/hosted/backlight-unix.c
index 2f00787f72..2f00787f72 100644
--- a/firmware/target/hosted/agptek/backlight-agptek.c
+++ b/firmware/target/hosted/backlight-unix.c
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c
index d9fcd64e2d..b49412ea48 100644
--- a/firmware/target/hosted/filesystem-app.c
+++ b/firmware/target/hosted/filesystem-app.c
@@ -36,8 +36,7 @@
36#include "rbpaths.h" 36#include "rbpaths.h"
37#include "logf.h" 37#include "logf.h"
38 38
39 39#if (defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(BOOTLOADER)
40#if defined(AGPTEK_ROCKER) && !defined(BOOTLOADER)
41#define PIVOT_ROOT "/mnt/sd_0" 40#define PIVOT_ROOT "/mnt/sd_0"
42#endif 41#endif
43 42
@@ -52,7 +51,8 @@ static const char rbhome[] = HOME_DIR;
52#endif 51#endif
53 52
54#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ 53#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \
55 defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER)) && \ 54 defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER) || \
55 defined(XDUOO_X3II) || defined(XDUOO_X20)) && \
56 !defined(__PCTOOL__) 56 !defined(__PCTOOL__)
57/* Special dirs are user-accessible (and user-writable) dirs which take priority 57/* Special dirs are user-accessible (and user-writable) dirs which take priority
58 * over the ones where Rockbox is installed to. Classic example would be 58 * over the ones where Rockbox is installed to. Classic example would be
diff --git a/firmware/target/hosted/rtc.c b/firmware/target/hosted/rtc.c
index 178e797a8d..488531c77c 100644
--- a/firmware/target/hosted/rtc.c
+++ b/firmware/target/hosted/rtc.c
@@ -42,7 +42,7 @@ int rtc_read_datetime(struct tm *tm)
42 42
43int rtc_write_datetime(const struct tm *tm) 43int rtc_write_datetime(const struct tm *tm)
44{ 44{
45#if defined(AGPTEK_ROCKER) && !defined(WIN32) 45#if !defined(WIN32)
46 struct timeval tv; 46 struct timeval tv;
47 struct tm *tm_time; 47 struct tm *tm_time;
48 48
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index 99ae062595..1e96383682 100644
--- a/firmware/target/hosted/sdl/sim-ui-defines.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -521,6 +521,7 @@
521#define UI_HEIGHT 380 521#define UI_HEIGHT 380
522#define UI_LCD_POSX 29 522#define UI_LCD_POSX 29
523#define UI_LCD_POSY 25 523#define UI_LCD_POSY 25
524
524#elif defined(XDUOO_X3) 525#elif defined(XDUOO_X3)
525#define UI_TITLE "xDuoo X3" 526#define UI_TITLE "xDuoo X3"
526#define UI_WIDTH 192 /* width of GUI window */ 527#define UI_WIDTH 192 /* width of GUI window */
@@ -528,6 +529,20 @@
528#define UI_LCD_POSX 34 529#define UI_LCD_POSX 34
529#define UI_LCD_POSY 73 530#define UI_LCD_POSY 73
530 531
532#elif defined(XDUOO_X3II)
533#define UI_TITLE "xDuoo X3ii"
534#define UI_WIDTH 322 /* width of GUI window */
535#define UI_HEIGHT 609 /* height of GUI window */
536#define UI_LCD_POSX 43
537#define UI_LCD_POSY 62
538
539#elif defined(XDUOO_X20)
540#define UI_TITLE "xDuoo X20"
541#define UI_WIDTH 322 /* width of GUI window */
542#define UI_HEIGHT 609 /* height of GUI window */
543#define UI_LCD_POSX 43
544#define UI_LCD_POSY 62
545
531#elif defined(IHIFI770) 546#elif defined(IHIFI770)
532#define UI_TITLE "iHiFi 770" 547#define UI_TITLE "iHiFi 770"
533#define UI_WIDTH 382 /* width of GUI window */ 548#define UI_WIDTH 382 /* width of GUI window */
@@ -554,4 +569,3 @@
554#endif 569#endif
555 570
556#endif /* #ifndef __UISDL_H__ */ 571#endif /* #ifndef __UISDL_H__ */
557
diff --git a/firmware/target/hosted/agptek/sysfs.c b/firmware/target/hosted/sysfs.c
index 177f338911..177f338911 100644
--- a/firmware/target/hosted/agptek/sysfs.c
+++ b/firmware/target/hosted/sysfs.c
diff --git a/firmware/target/hosted/agptek/sysfs.h b/firmware/target/hosted/sysfs.h
index 639cc1c409..639cc1c409 100644
--- a/firmware/target/hosted/agptek/sysfs.h
+++ b/firmware/target/hosted/sysfs.h
diff --git a/firmware/target/hosted/agptek/system-agptek.c b/firmware/target/hosted/system-hosted.c
index 7f0949daf2..7f0949daf2 100644
--- a/firmware/target/hosted/agptek/system-agptek.c
+++ b/firmware/target/hosted/system-hosted.c
diff --git a/firmware/target/hosted/xduoo/adc-target.h b/firmware/target/hosted/xduoo/adc-target.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/firmware/target/hosted/xduoo/adc-target.h
diff --git a/firmware/target/hosted/xduoo/button-target.h b/firmware/target/hosted/xduoo/button-target.h
new file mode 100644
index 0000000000..6cca5c22a0
--- /dev/null
+++ b/firmware/target/hosted/xduoo/button-target.h
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2018 by Roman Stolyarov
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#define HAS_BUTTON_HOLD
24
25/* Main unit's buttons */
26#define BUTTON_POWER 0x00000001
27#define BUTTON_HOME 0x00000002
28#define BUTTON_OPTION 0x00000004
29#define BUTTON_PREV 0x00000008
30#define BUTTON_NEXT 0x00000010
31#define BUTTON_PLAY 0x00000020
32#define BUTTON_VOL_UP 0x00000040
33#define BUTTON_VOL_DOWN 0x00000080
34
35#define BUTTON_LEFT 0
36#define BUTTON_RIGHT 0
37
38#define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \
39 BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN)
40
41/* Software power-off */
42#define POWEROFF_BUTTON BUTTON_POWER
43#define POWEROFF_COUNT 25
44
45#endif /* _BUTTON_TARGET_H_ */
46
diff --git a/firmware/target/hosted/xduoo/button-xduoo.c b/firmware/target/hosted/xduoo/button-xduoo.c
new file mode 100644
index 0000000000..9fd1392b89
--- /dev/null
+++ b/firmware/target/hosted/xduoo/button-xduoo.c
@@ -0,0 +1,202 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 * Copyright (C) 2018 Roman Stolyarov
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
40static bool soft_hold = false;
41#ifndef BOOTLOADER
42static unsigned soft_hold_counter = 0;
43#define SOFT_HOLD_BUTTON BUTTON_POWER
44#define SOFT_HOLD_CNTMAX_1 (HZ)
45#define SOFT_HOLD_CNTMAX_2 (HZ*2)
46#endif
47
48#define NR_POLL_DESC 3
49static struct pollfd poll_fds[NR_POLL_DESC];
50
51static int button_map(int keycode)
52{
53 switch(keycode)
54 {
55 case KEY_BACK:
56 return BUTTON_HOME;
57
58 case KEY_MENU:
59 return BUTTON_OPTION;
60
61 case KEY_UP:
62 return BUTTON_PREV;
63
64 case KEY_DOWN:
65 return BUTTON_NEXT;
66
67 case KEY_ENTER:
68 return BUTTON_PLAY;
69
70 case KEY_VOLUMEUP:
71 return BUTTON_VOL_UP;
72
73 case KEY_VOLUMEDOWN:
74 return BUTTON_VOL_DOWN;
75
76 case KEY_POWER:
77 return BUTTON_POWER;
78
79 default:
80 return 0;
81 }
82}
83
84void button_init_device(void)
85{
86 const char * const input_devs[] = {
87 "/dev/input/event0",
88 "/dev/input/event1",
89 "/dev/input/event2"
90 };
91
92 for(int i = 0; i < NR_POLL_DESC; i++)
93 {
94 int fd = open(input_devs[i], O_RDWR);
95
96 if(fd < 0)
97 {
98 panicf("Cannot open input device: %s\n", input_devs[i]);
99 }
100
101 poll_fds[i].fd = fd;
102 poll_fds[i].events = POLLIN;
103 poll_fds[i].revents = 0;
104 }
105}
106
107int button_read_device(void)
108{
109 static int button_bitmap = 0;
110 struct input_event event;
111
112 /* check if there are any events pending and process them */
113 while(poll(poll_fds, NR_POLL_DESC, 0))
114 {
115 for(int i = 0; i < NR_POLL_DESC; i++)
116 {
117 /* read only if non-blocking */
118 if(poll_fds[i].revents & POLLIN)
119 {
120 int size = read(poll_fds[i].fd, &event, sizeof(event));
121 if(size == (int)sizeof(event))
122 {
123 int keycode = event.code;
124 /* event.value == 1 means press
125 * event.value == 0 means release
126 */
127 bool press = event.value ? true : false;
128
129 /* map linux event code to rockbox button bitmap */
130 if(press)
131 {
132 button_bitmap |= button_map(keycode);
133 }
134 else
135 {
136 button_bitmap &= ~button_map(keycode);
137 }
138 }
139 }
140 }
141 }
142
143#ifndef BOOTLOADER
144 if (button_bitmap == SOFT_HOLD_BUTTON) {
145 soft_hold_counter++;
146 if (soft_hold_counter == SOFT_HOLD_CNTMAX_1) {
147 soft_hold = !soft_hold;
148 backlight_hold_changed(soft_hold);
149 }
150 else
151 if (soft_hold_counter == SOFT_HOLD_CNTMAX_2) {
152 soft_hold = false;
153 backlight_hold_changed(soft_hold);
154 }
155 } else {
156 soft_hold_counter = 0;
157 }
158
159 if((soft_hold) && (button_bitmap != SOFT_HOLD_BUTTON)) {
160 return BUTTON_NONE;
161 }
162#endif
163
164 return button_bitmap;
165}
166
167bool headphones_inserted(void)
168{
169 int status = 0;
170 const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
171 const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
172#ifdef XDUOO_X20
173 const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
174#endif
175
176 sysfs_get_int(sysfs_lo_switch, &status);
177 if (status) return true;
178
179 sysfs_get_int(sysfs_hs_switch, &status);
180 if (status) return true;
181
182#ifdef XDUOO_X20
183 sysfs_get_int(sysfs_bal_switch, &status);
184 if (status) return true;
185#endif
186
187 return false;
188}
189
190void button_close_device(void)
191{
192 /* close descriptors */
193 for(int i = 0; i < NR_POLL_DESC; i++)
194 {
195 close(poll_fds[i].fd);
196 }
197}
198
199bool button_hold(void)
200{
201 return soft_hold;
202}
diff --git a/firmware/target/hosted/xduoo/debug-xduoo.c b/firmware/target/hosted/xduoo/debug-xduoo.c
new file mode 100644
index 0000000000..33f3ac4b97
--- /dev/null
+++ b/firmware/target/hosted/xduoo/debug-xduoo.c
@@ -0,0 +1,6 @@
1#include <stdbool.h>
2
3bool debug_hw_info(void)
4{
5 return false;
6}
diff --git a/firmware/target/hosted/xduoo/lcd-target.h b/firmware/target/hosted/xduoo/lcd-target.h
new file mode 100644
index 0000000000..bb9b77771b
--- /dev/null
+++ b/firmware/target/hosted/xduoo/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-xduoo.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/xduoo/lcd-xduoo.c b/firmware/target/hosted/xduoo/lcd-xduoo.c
new file mode 100644
index 0000000000..4b3148da03
--- /dev/null
+++ b/firmware/target/hosted/xduoo/lcd-xduoo.c
@@ -0,0 +1,140 @@
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
22#include <stdlib.h>
23#include <unistd.h>
24#include <stdio.h>
25#include <linux/fb.h>
26#include <sys/mman.h>
27#include <sys/ioctl.h>
28#include <fcntl.h>
29#include "lcd.h"
30#include "lcd-target.h"
31#include "backlight-target.h"
32#include "sysfs.h"
33#include "panic.h"
34
35static int fd = -1;
36static struct fb_var_screeninfo vinfo;
37fb_data *framebuffer = 0; /* global variable, see lcd-target.h */
38
39void lcd_init_device(void)
40{
41 const char * const fb_dev = "/dev/fb0";
42 fd = open(fb_dev, O_RDWR);
43 if(fd < 0)
44 {
45 panicf("Cannot open framebuffer: %s\n", fb_dev);
46 }
47
48 /* get fixed and variable information */
49 struct fb_fix_screeninfo finfo;
50 if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0)
51 {
52 panicf("Cannot read framebuffer fixed information");
53 }
54
55 if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
56 {
57 panicf("Cannot read framebuffer variable information");
58 }
59
60#if 0
61 /* check resolution and framebuffer size */
62 if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH)
63 {
64 panicf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres,
65 vinfo.yres, vinfo.bits_per_pixel);
66 }
67#endif
68 /* Note: we use a framebuffer size of width*height*bbp. We cannot trust the
69 * values returned by the driver for line_length */
70
71 /* map framebuffer */
72 framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
73 if((void *)framebuffer == MAP_FAILED)
74 {
75 panicf("Cannot map framebuffer");
76 }
77
78#ifdef HAVE_LCD_ENABLE
79 lcd_set_active(true);
80#endif
81}
82
83#ifdef HAVE_LCD_SHUTDOWN
84void lcd_shutdown(void)
85{
86 munmap(framebuffer, FRAMEBUFFER_SIZE);
87 close(fd);
88}
89#endif
90
91void lcd_enable(bool on)
92{
93 const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank";
94
95 if (lcd_active() != on)
96 {
97 sysfs_set_int(sysfs_fb_blank, on ? 0 : 1);
98 lcd_set_active(on);
99
100 if (on)
101 {
102 send_event(LCD_EVENT_ACTIVATION, NULL);
103 }
104 }
105}
106
107static void redraw(void)
108{
109 ioctl(fd, FBIOPAN_DISPLAY, &vinfo);
110}
111
112extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
113 int width, int height);
114
115void lcd_update(void)
116{
117 /* Copy the Rockbox framebuffer to the second framebuffer */
118 lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0),
119 LCD_WIDTH*LCD_HEIGHT, 1);
120 redraw();
121}
122
123void lcd_update_rect(int x, int y, int width, int height)
124{
125 fb_data *dst = LCD_FRAMEBUF_ADDR(x, y);
126 fb_data * src = FBADDR(x,y);
127
128 /* Copy part of the Rockbox framebuffer to the second framebuffer */
129 if (width < LCD_WIDTH)
130 {
131 /* Not full width - do line-by-line */
132 lcd_copy_buffer_rect(dst, src, width, height);
133 }
134 else
135 {
136 /* Full width - copy as one line */
137 lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
138 }
139 redraw();
140}
diff --git a/firmware/target/hosted/xduoo/power-xduoo.c b/firmware/target/hosted/xduoo/power-xduoo.c
new file mode 100644
index 0000000000..97a8dd4779
--- /dev/null
+++ b/firmware/target/hosted/xduoo/power-xduoo.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-xduoo.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 xduoo_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 xduoo_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 xduoo_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 xduoo_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/xduoo/power-xduoo.h b/firmware/target/hosted/xduoo/power-xduoo.h
new file mode 100644
index 0000000000..d573865ed2
--- /dev/null
+++ b/firmware/target/hosted/xduoo/power-xduoo.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 xduoo_power_input_status(void);
27bool xduoo_power_charging_status(void);
28unsigned int xduoo_power_get_battery_voltage(void);
29unsigned int xduoo_power_get_battery_capacity(void);
30#endif /* _POWER_XDUOO_H_ */
31
diff --git a/firmware/target/hosted/xduoo/powermgmt-xduoo.c b/firmware/target/hosted/xduoo/powermgmt-xduoo.c
new file mode 100644
index 0000000000..30001934ba
--- /dev/null
+++ b/firmware/target/hosted/xduoo/powermgmt-xduoo.c
@@ -0,0 +1,70 @@
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-xduoo.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 xduoo_power_input_status();
51}
52
53#if defined(XDUOO_X3II)
54int _battery_voltage(void)
55{
56 return xduoo_power_get_battery_voltage();
57}
58#endif
59
60#if defined(XDUOO_X20)
61int _battery_level(void)
62{
63 return xduoo_power_get_battery_capacity();
64}
65#endif
66
67bool charging_state(void)
68{
69 return xduoo_power_charging_status();
70}
diff --git a/firmware/target/hosted/xduoo/system-target.h b/firmware/target/hosted/xduoo/system-target.h
new file mode 100644
index 0000000000..830f19fde4
--- /dev/null
+++ b/firmware/target/hosted/xduoo/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/xduoo/usb-xduoo.c b/firmware/target/hosted/xduoo/usb-xduoo.c
new file mode 100644
index 0000000000..19248ad262
--- /dev/null
+++ b/firmware/target/hosted/xduoo/usb-xduoo.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-xduoo.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", "0029");
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", "xDuoo 0100");
118}
diff --git a/firmware/target/hosted/xduoo/xduoo.make b/firmware/target/hosted/xduoo/xduoo.make
new file mode 100644
index 0000000000..5c37d27412
--- /dev/null
+++ b/firmware/target/hosted/xduoo/xduoo.make
@@ -0,0 +1,52 @@
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)/rockbox.x3ii : $(BUILDDIR)/rockbox.elf
47 $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
48
49$(BUILDDIR)/rockbox.x20 : $(BUILDDIR)/rockbox.elf
50 $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
51
52endif