summaryrefslogtreecommitdiffstats
path: root/firmware/target
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/target
parent5efaa9ef8073bb216e3dcdbb4476f2fa7c672b76 (diff)
downloadrockbox-2a471e288c.tar.gz
rockbox-2a471e288c.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/target')
-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
13 files changed, 630 insertions, 4 deletions
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 @@
+/***************************************************************************
+ * __________ __ ___
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2020 Solomon Peachy
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <poll.h>
+//#include <dir.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <linux/input.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "sysfs.h"
+#include "button.h"
+#include "button-target.h"
+#include "panic.h"
+
+#include "kernel.h"
+#include "backlight.h"
+#include "backlight-target.h"
+#include "erosqlinux_codec.h"
+
+#define NR_POLL_DESC 3
+static struct pollfd poll_fds[NR_POLL_DESC];
+
+static int button_map(int keycode)
+{
+ switch(keycode)
+ {
+ case KEY_POWER:
+ return BUTTON_POWER;
+
+ case KEY_MENU:
+ return BUTTON_MENU;
+
+ case KEY_BACK:
+ return BUTTON_BACK;
+
+ case KEY_NEXTSONG:
+ return BUTTON_PREV;
+
+ case KEY_PREVIOUSSONG:
+ return BUTTON_NEXT; // Yes, backwards!
+
+ case KEY_PLAYPAUSE:
+ return BUTTON_PLAY;
+
+ case KEY_LEFT:
+ return BUTTON_SCROLL_BACK;
+
+ case KEY_RIGHT:
+ return BUTTON_SCROLL_FWD;
+
+ case KEY_VOLUMEUP:
+ return BUTTON_VOL_UP;
+
+ case KEY_VOLUMEDOWN:
+ return BUTTON_VOL_DOWN;
+
+ default:
+ return 0;
+ }
+}
+
+void button_init_device(void)
+{
+ const char * const input_devs[] = {
+ "/dev/input/event0", // Rotary encoder
+ "/dev/input/event1" // Keys
+ };
+
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ int fd = open(input_devs[i], O_RDWR | O_CLOEXEC);
+
+ if(fd < 0)
+ {
+ panicf("Cannot open input device: %s\n", input_devs[i]);
+ }
+
+ poll_fds[i].fd = fd;
+ poll_fds[i].events = POLLIN;
+ poll_fds[i].revents = 0;
+ }
+}
+
+int button_read_device(void)
+{
+ static int button_bitmap = 0;
+ struct input_event event;
+
+ // FIXME TODO: Make this work via HAVE_SCROLL_WHEEL instead
+
+ /* Wheel gives us press+release back to back, clear them after time elapses */
+ static long last_tick = 0;
+ if (button_bitmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD) &&
+ current_tick - last_tick >= 2)
+ {
+ button_bitmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
+ }
+
+ /* check if there are any events pending and process them */
+ while(poll(poll_fds, NR_POLL_DESC, 0))
+ {
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ /* read only if non-blocking */
+ if(poll_fds[i].revents & POLLIN)
+ {
+ int size = read(poll_fds[i].fd, &event, sizeof(event));
+ if(size == (int)sizeof(event))
+ {
+ int keycode = event.code;
+ /* event.value == 1 means press
+ * event.value == 0 means release
+ */
+ bool press = event.value ? true : false;
+
+ /* map linux event code to rockbox button bitmap */
+ if(press)
+ {
+ int bmap = button_map(keycode);
+ if (bmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD))
+ last_tick = current_tick;
+ button_bitmap |= bmap;
+ }
+ else
+ {
+ /* Wheel gives us press+release back to back; ignore the release */
+ int bmap = button_map(keycode) & ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
+ button_bitmap &= ~bmap;
+ }
+ }
+ }
+ }
+ }
+
+ return button_bitmap;
+}
+
+bool headphones_inserted(void)
+{
+#ifdef BOOTLOADER
+ int ps = 0;
+#else
+ int ps = erosq_get_outputs();
+#endif
+
+ return (ps == 2);
+}
+
+bool lineout_inserted(void)
+{
+#ifdef BOOTLOADER
+ int ps = 0;
+#else
+ int ps = erosq_get_outputs();
+#endif
+
+ return (ps == 1);
+}
+
+void button_close_device(void)
+{
+ /* close descriptors */
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ close(poll_fds[i].fd);
+ }
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2020 Solomon Peachy
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+/* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+#define BUTTON_MENU 0x00000002
+#define BUTTON_BACK 0x00000004
+#define BUTTON_PLAY 0x00000008
+#define BUTTON_NEXT 0x00000010
+#define BUTTON_PREV 0x00000020
+#define BUTTON_VOL_UP 0x00000040
+#define BUTTON_VOL_DOWN 0x00000080
+#define BUTTON_SCROLL_BACK 0x00000100
+#define BUTTON_SCROLL_FWD 0x00000200
+
+#define BUTTON_MAIN (BUTTON_POWER | BUTTON_MENU | BUTTON_BACK | BUTTON_PREV | \
+ BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_SCROLL_BACK | BUTTON_SCROLL_FWD)
+
+#define BUTTON_LEFT BUTTON_PREV
+#define BUTTON_RIGHT BUTTON_NEXT
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 25
+
+#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 @@
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+# $Id$
+#
+
+INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
+
+SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
+
+# bootloader build is sligtly different
+ifneq (,$(findstring bootloader,$(APPSDIR)))
+
+SRC += $(call preprocess, $(APPSDIR)/SOURCES)
+CLEANOBJS += $(BUILDDIR)/bootloader.*
+
+endif #bootloader
+
+.SECONDEXPANSION: # $$(OBJ) is not populated until after this
+
+ifneq (,$(findstring bootloader,$(APPSDIR)))
+# bootloader build
+
+$(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS)
+ $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
+ -L$(BUILDDIR)/firmware -lfirmware \
+ -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
+ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
+
+$(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
+
+else
+# rockbox app build
+
+$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
+ $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
+ -L$(BUILDDIR)/firmware -lfirmware \
+ -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
+ -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
+ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
+
+$(BUILDDIR)/$(BINARY): $(BUILDDIR)/rockbox.elf
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
+
+endif
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2016 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __LCD_TARGET_H__
+#define __LCD_TARGET_H__
+
+/* needs special ioctl() to redraw updated framebuffer content */
+#define LCD_OPTIMIZED_UPDATE
+#define LCD_OPTIMIZED_UPDATE_RECT
+
+extern fb_data *framebuffer; /* see lcd-erosq.c */
+#define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col))
+
+extern void lcd_set_active(bool active);
+#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "system.h"
+#include "power-erosq.h"
+#include "power.h"
+#include "panic.h"
+#include "sysfs.h"
+
+const char * const sysfs_bat_voltage =
+ "/sys/class/power_supply/battery/voltage_now";
+
+const char * const sysfs_bat_capacity =
+ "/sys/class/power_supply/battery/capacity";
+
+const char * const sysfs_bat_status =
+ "/sys/class/power_supply/battery/status";
+
+const char * const sysfs_pow_supply =
+ "/sys/class/power_supply/usb/present";
+
+unsigned int erosq_power_input_status(void)
+{
+ int present = 0;
+ sysfs_get_int(sysfs_pow_supply, &present);
+
+ return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
+}
+
+bool erosq_power_charging_status(void)
+{
+ char buf[12] = {0};
+ sysfs_get_string(sysfs_bat_status, buf, sizeof(buf));
+
+ return (strncmp(buf, "Charging", 8) == 0);
+}
+
+unsigned int erosq_power_get_battery_voltage(void)
+{
+ int battery_voltage;
+ sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
+
+ return battery_voltage/1000;
+}
+
+unsigned int erosq_power_get_battery_capacity(void)
+{
+ int battery_capacity;
+ sysfs_get_int(sysfs_bat_capacity, &battery_capacity);
+
+ return battery_capacity;
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _POWER_XDUOO_H_
+#define _POWER_XDUOO_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+unsigned int erosq_power_input_status(void);
+bool erosq_power_charging_status(void);
+unsigned int erosq_power_get_battery_voltage(void);
+unsigned int erosq_power_get_battery_capacity(void);
+#endif /* _POWER_XDUOO_H_ */
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "powermgmt.h"
+#include "power.h"
+#include "power-erosq.h"
+
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
+{
+ 3470
+};
+
+/* the OF shuts down at this voltage */
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
+{
+ 3400
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{
+ { 3400, 3639, 3697, 3723, 3757, 3786, 3836, 3906, 3980, 4050, 4159 }
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
+const unsigned short const percent_to_volt_charge[11] =
+{
+ 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
+};
+
+unsigned int power_input_status(void)
+{
+ /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */
+ return erosq_power_input_status();
+}
+
+int _battery_voltage(void)
+{
+ return erosq_power_get_battery_voltage();
+}
+
+bool charging_state(void)
+{
+ return erosq_power_charging_status();
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2016 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __SYSTEM_TARGET_H__
+#define __SYSTEM_TARGET_H__
+
+#include "kernel-unix.h"
+#include "system-hosted.h"
+
+#define NEED_GENERIC_BYTESWAPS
+#endif /* __SYSTEM_TARGET_H__ */
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 @@
+/***************************************************************************
+ * __________ __ ___
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2018 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <string.h>
+#include "config.h"
+#include "disk.h"
+#include "usb.h"
+#include "sysfs.h"
+#include "power.h"
+#include "power-erosq.h"
+
+static bool adb_mode = false;
+
+/* TODO: implement usb detection properly */
+int usb_detect(void)
+{
+ return power_input_status() == POWER_INPUT_USB_CHARGER ? USB_INSERTED : USB_EXTRACTED;
+}
+
+void usb_enable(bool on)
+{
+ /* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell
+ * without entering ums mode
+ */
+ if (!adb_mode)
+ {
+ sysfs_set_int("/sys/class/android_usb/android0/enable", on ? 1 : 0);
+ }
+}
+
+/* This is called by usb thread after usb extract in order to return
+ * regular FS access
+ *
+ * returns the # of successful mounts
+*/
+int disk_mount_all(void)
+{
+ const char *dev[] = {"/dev/mmcblk0p1", "/dev/mmcblk0"};
+ const char *fs[] = {"vfat", "exfat"};
+
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "");
+
+ for (int i=0; i<2; i++)
+ {
+ for (int j=0; j<2; j++)
+ {
+ if (mount(dev[i], "/mnt/sd_0", fs[j], 0, NULL) == 0)
+ {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* This is called by usb thread after all threads ACKs usb inserted message
+ *
+ * returns the # of successful unmounts
+ */
+int disk_unmount_all(void)
+{
+ if (umount("/mnt/sd_0") == 0)
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
+ return 1;
+ }
+
+ return 0;
+}
+
+void usb_init_device(void)
+{
+ char functions[32] = {0};
+
+ /* Check if ADB was activated in bootloader */
+ sysfs_get_string("/sys/class/android_usb/android0/functions", functions, sizeof(functions));
+ adb_mode = (strstr(functions, "adb") == NULL) ? false : true;
+
+ usb_enable(false);
+
+ if (adb_mode)
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage,adb");
+ sysfs_set_string("/sys/class/android_usb/android0/idVendor", "18D1");
+ sysfs_set_string("/sys/class/android_usb/android0/idProduct", "D002");
+ }
+ else
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage");
+ sysfs_set_string("/sys/class/android_usb/android0/idVendor", "C502");
+ sysfs_set_string("/sys/class/android_usb/android0/idProduct", "0023");
+ }
+
+ sysfs_set_string("/sys/class/android_usb/android0/iManufacturer", "Rockbox.org");
+ sysfs_set_string("/sys/class/android_usb/android0/iProduct", "Rockbox media player");
+ sysfs_set_string("/sys/class/android_usb/android0/iSerial", "0123456789ABCDEF");
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/inquiry_string", "ErosQ 0100");
+}
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 @@
#include "logf.h"
#if !(defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR))
-#if (defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20))
+#if defined(HIBY_LINUX)
#define PIVOT_ROOT "/mnt/sd_0"
#elif defined(FIIO_M3K)
#define PIVOT_ROOT "/mnt" // XXX check this!
@@ -56,8 +56,8 @@ static const char rbhome[] = HOME_DIR;
#endif
#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \
- defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER) || \
- defined(XDUOO_X3II) || defined(XDUOO_X20) || defined(FIIO_M3K) || defined(FIIO_M3K_PRO)) && \
+ defined(SONY_NWZ_LINUX) || defined(DX90) || defined(HIBY_LINUX) || \
+ defined(FIIO_M3K)) && \
!defined(__PCTOOL__)
/* Special dirs are user-accessible (and user-writable) dirs which take priority
* 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 @@
#define POWEROFF_COUNT 25
#endif /* _BUTTON_TARGET_H_ */
-