summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-18 10:16:27 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-18 10:19:42 -0400
commit6a94f1e995fee94c792a4bef2fd0bce1974ede7b (patch)
tree3170ecaf1f30cd608082099806a06752bdf55cd6
parent5f75c493e3bebc53f951b72acdf552b8a2aeb4ae (diff)
downloadrockbox-6a94f1e995fee94c792a4bef2fd0bce1974ede7b.tar.gz
rockbox-6a94f1e995fee94c792a4bef2fd0bce1974ede7b.zip
sonynwz: Properly support multidrive, with hotswap of the SD card
Change-Id: I7eb8efb0986a395d5ffbcc06a54bb680e0b59e9d
-rw-r--r--firmware/export/config/samsungypr0.h1
-rw-r--r--firmware/export/config/sonynwa20.h2
-rw-r--r--firmware/export/config/sonynwza10.h2
-rw-r--r--firmware/export/config/sonynwzlinux.h13
-rw-r--r--firmware/target/hosted/sonynwz/system-nwz.c74
5 files changed, 81 insertions, 11 deletions
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index 286299bf81..29c565c525 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -169,3 +169,4 @@
169#define HAVE_HOTSWAP 169#define HAVE_HOTSWAP
170#define HAVE_STORAGE_FLUSH 170#define HAVE_STORAGE_FLUSH
171#define MULTIDRIVE_DIR "/mnt/mmc" 171#define MULTIDRIVE_DIR "/mnt/mmc"
172#define MULTIDRIVE_DEV "/sys/block/mmcblk0"
diff --git a/firmware/export/config/sonynwa20.h b/firmware/export/config/sonynwa20.h
index d9f6292459..e5380114b7 100644
--- a/firmware/export/config/sonynwa20.h
+++ b/firmware/export/config/sonynwa20.h
@@ -13,4 +13,6 @@
13/* sqrt(240^2 + 320^2) / 2 = 200 */ 13/* sqrt(240^2 + 320^2) / 2 = 200 */
14#define LCD_DPI 200 14#define LCD_DPI 200
15 15
16#define NWZ_HAS_SD
17
16#include "sonynwzlinux.h" 18#include "sonynwzlinux.h"
diff --git a/firmware/export/config/sonynwza10.h b/firmware/export/config/sonynwza10.h
index a0650cf22d..750a4d59d7 100644
--- a/firmware/export/config/sonynwza10.h
+++ b/firmware/export/config/sonynwza10.h
@@ -13,4 +13,6 @@
13/* sqrt(240^2 + 320^2) / 2 = 200 */ 13/* sqrt(240^2 + 320^2) / 2 = 200 */
14#define LCD_DPI 200 14#define LCD_DPI 200
15 15
16#define NWZ_HAS_SD
17
16#include "sonynwzlinux.h" 18#include "sonynwzlinux.h"
diff --git a/firmware/export/config/sonynwzlinux.h b/firmware/export/config/sonynwzlinux.h
index 074ad1c417..71affd1584 100644
--- a/firmware/export/config/sonynwzlinux.h
+++ b/firmware/export/config/sonynwzlinux.h
@@ -57,9 +57,6 @@
57/* The number of bytes reserved for loadable plugins */ 57/* The number of bytes reserved for loadable plugins */
58#define PLUGIN_BUFFER_SIZE 0x100000 58#define PLUGIN_BUFFER_SIZE 0x100000
59 59
60
61
62
63#define CONFIG_TUNER SI4700 60#define CONFIG_TUNER SI4700
64 61
65/* There is no hardware tone control */ 62/* There is no hardware tone control */
@@ -105,8 +102,18 @@
105/* Define this to the CPU frequency */ 102/* Define this to the CPU frequency */
106#define CPU_FREQ 532000000 103#define CPU_FREQ 532000000
107 104
105#ifdef NWZ_HAS_SD
106/* External SD card can be mounted */
107#define CONFIG_STORAGE (STORAGE_HOSTFS|STORAGE_SD)
108#define HAVE_MULTIDRIVE /* But _not_ CONFIG_STORAGE_MULTI */
109#define NUM_DRIVES 2
110#define HAVE_HOTSWAP
111#define MULTIDRIVE_DIR "/mnt/media"
112#define MULTIDRIVE_DEV "/sys/block/mmcblk1"
113#else
108/* No special storage */ 114/* No special storage */
109#define CONFIG_STORAGE STORAGE_HOSTFS 115#define CONFIG_STORAGE STORAGE_HOSTFS
116#endif
110#define HAVE_STORAGE_FLUSH 117#define HAVE_STORAGE_FLUSH
111 118
112/* Battery */ 119/* Battery */
diff --git a/firmware/target/hosted/sonynwz/system-nwz.c b/firmware/target/hosted/sonynwz/system-nwz.c
index c10c26250b..00a3b77252 100644
--- a/firmware/target/hosted/sonynwz/system-nwz.c
+++ b/firmware/target/hosted/sonynwz/system-nwz.c
@@ -1,10 +1,10 @@
1/*************************************************************************** 1/***************************************************************************
2 * __________ __ ___. 2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * 8 *
9 * Copyright (C) 2016 Amaury Pouly 9 * Copyright (C) 2016 Amaury Pouly
10 * 10 *
@@ -23,20 +23,24 @@
23#include <signal.h> 23#include <signal.h>
24#include <ucontext.h> 24#include <ucontext.h>
25#include <string.h> 25#include <string.h>
26#include <stdio.h>
27
26#include "system.h" 28#include "system.h"
27#include "lcd.h" 29#include "lcd.h"
28#include "font.h" 30#include "font.h"
29#include "logf.h"
30#include "system.h" 31#include "system.h"
31#include "backlight-target.h" 32#include "backlight-target.h"
32#include "button.h" 33#include "button.h"
33#include "adc.h" 34#include "adc.h"
34#include "power.h" 35#include "power.h"
36#include "mv.h"
35#include "power-nwz.h" 37#include "power-nwz.h"
36#include <backtrace.h> 38#include <backtrace.h>
37#include <stdio.h> 39
40#include "logf.h"
38 41
39static const char **kern_mod_list; 42static const char **kern_mod_list;
43bool os_file_exists(const char *ospath);
40 44
41void power_off(void) 45void power_off(void)
42{ 46{
@@ -238,3 +242,57 @@ bool nwz_is_kernel_module_loaded(const char *name)
238 return true; 242 return true;
239 return false; 243 return false;
240} 244}
245
246#ifdef CONFIG_STORAGE_MULTI
247int hostfs_driver_type(int drive)
248{
249 return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM;
250}
251#endif /* CONFIG_STORAGE_MULTI */
252
253#ifdef HAVE_HOTSWAP
254bool hostfs_removable(IF_MD_NONVOID(int volume))
255{
256#ifdef HAVE_MULTIDRIVE
257 if (volume > 0)
258 return true;
259 else
260#endif
261 return false; /* internal: always present */
262}
263
264bool hostfs_present(int volume)
265{
266#ifdef HAVE_MULTIDRIVE
267 if (volume > 0)
268#if defined(MULTIDRIVE_DEV)
269 return os_file_exists(MULTIDRIVE_DEV);
270#else
271 return true; // FIXME?
272#endif
273 else
274#endif
275 return true; /* internal: always present */
276}
277#endif /* HAVE_HOTSWAP */
278
279#ifdef HAVE_MULTIDRIVE
280int volume_drive(int drive)
281{
282 return drive;
283}
284#endif /* HAVE_MULTIDRIVE */
285
286#ifdef HAVE_HOTSWAP
287bool volume_removable(IF_MV_NONVOID(int volume))
288{
289 /* don't support more than one partition yet, so volume == drive */
290 return hostfs_removable(volume);
291}
292
293bool volume_present(int volume)
294{
295 /* don't support more than one partition yet, so volume == drive */
296 return hostfs_present(volume);
297}
298#endif /* HAVE_HOTSWAP */