summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/buffering.c9
-rw-r--r--apps/buffering.h3
-rw-r--r--apps/codec_thread.c8
-rw-r--r--apps/playback.c13
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/kernel/include/thread.h5
-rw-r--r--firmware/kernel/thread-internal.h3
-rw-r--r--firmware/kernel/thread.c18
-rw-r--r--firmware/storage.c58
9 files changed, 0 insertions, 121 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 1826fa1b91..96ec92201f 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1572,15 +1572,6 @@ size_t buf_get_watermark(void)
1572 return BUF_WATERMARK; 1572 return BUF_WATERMARK;
1573} 1573}
1574 1574
1575#ifdef HAVE_IO_PRIORITY
1576void buf_back_off_storage(bool back_off)
1577{
1578 int priority = back_off ?
1579 IO_PRIORITY_BACKGROUND : IO_PRIORITY_IMMEDIATE;
1580 thread_set_io_priority(buffering_thread_id, priority);
1581}
1582#endif
1583
1584/** -- buffer thread helpers -- **/ 1575/** -- buffer thread helpers -- **/
1585static void shrink_buffer_inner(struct memory_handle *h) 1576static void shrink_buffer_inner(struct memory_handle *h)
1586{ 1577{
diff --git a/apps/buffering.h b/apps/buffering.h
index 218f77ed85..5a1369a31d 100644
--- a/apps/buffering.h
+++ b/apps/buffering.h
@@ -111,9 +111,6 @@ size_t buf_length(void);
111size_t buf_used(void); 111size_t buf_used(void);
112bool buf_pin_handle(int handle_id, bool pin); 112bool buf_pin_handle(int handle_id, bool pin);
113bool buf_signal_handle(int handle_id, bool signal); 113bool buf_signal_handle(int handle_id, bool signal);
114#ifdef HAVE_IO_PRIORITY
115void buf_back_off_storage(bool back_off);
116#endif
117 114
118/* Settings */ 115/* Settings */
119void buf_set_watermark(size_t bytes); 116void buf_set_watermark(size_t bytes);
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index f2039d10e6..a1fa96d021 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -470,15 +470,7 @@ static void load_codec(const struct codec_load_info *ev_data)
470 /* Either not a valid handle or the buffer method failed */ 470 /* Either not a valid handle or the buffer method failed */
471 const char *codec_fn = get_codec_filename(data.afmt); 471 const char *codec_fn = get_codec_filename(data.afmt);
472 if (codec_fn) 472 if (codec_fn)
473 {
474#ifdef HAVE_IO_PRIORITY
475 buf_back_off_storage(true);
476#endif
477 status = codec_load_file(codec_fn, &ci); 473 status = codec_load_file(codec_fn, &ci);
478#ifdef HAVE_IO_PRIORITY
479 buf_back_off_storage(false);
480#endif
481 }
482 } 474 }
483 475
484 /* Types must agree */ 476 /* Types must agree */
diff --git a/apps/playback.c b/apps/playback.c
index efc23306a0..5c2fc7f8ce 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1560,9 +1560,6 @@ static bool audio_load_cuesheet(struct track_info *info,
1560 int hid = ERR_UNSUPPORTED_TYPE; 1560 int hid = ERR_UNSUPPORTED_TYPE;
1561 struct cuesheet_file cue_file; 1561 struct cuesheet_file cue_file;
1562 1562
1563#ifdef HAVE_IO_PRIORITY
1564 buf_back_off_storage(true);
1565#endif
1566 if (look_for_cuesheet_file(track_id3, &cue_file)) 1563 if (look_for_cuesheet_file(track_id3, &cue_file))
1567 { 1564 {
1568 hid = bufalloc(NULL, sizeof (struct cuesheet), TYPE_CUESHEET); 1565 hid = bufalloc(NULL, sizeof (struct cuesheet), TYPE_CUESHEET);
@@ -1586,9 +1583,6 @@ static bool audio_load_cuesheet(struct track_info *info,
1586 } 1583 }
1587 } 1584 }
1588 1585
1589#ifdef HAVE_IO_PRIORITY
1590 buf_back_off_storage(false);
1591#endif
1592 if (hid == ERR_BUFFER_FULL) 1586 if (hid == ERR_BUFFER_FULL)
1593 { 1587 {
1594 logf("buffer is full for now (%s)", __func__); 1588 logf("buffer is full for now (%s)", __func__);
@@ -1627,10 +1621,6 @@ static bool audio_load_albumart(struct track_info *info,
1627 memset(&user_data, 0, sizeof(user_data)); 1621 memset(&user_data, 0, sizeof(user_data));
1628 user_data.dim = &albumart_slots[i].dim; 1622 user_data.dim = &albumart_slots[i].dim;
1629 1623
1630#ifdef HAVE_IO_PRIORITY
1631 buf_back_off_storage(true);
1632#endif
1633
1634 /* We can only decode jpeg for embedded AA */ 1624 /* We can only decode jpeg for embedded AA */
1635 if (track_id3->has_embedded_albumart && track_id3->albumart.type == AA_TYPE_JPG) 1625 if (track_id3->has_embedded_albumart && track_id3->albumart.type == AA_TYPE_JPG)
1636 { 1626 {
@@ -1651,9 +1641,6 @@ static bool audio_load_albumart(struct track_info *info,
1651 } 1641 }
1652 } 1642 }
1653 1643
1654#ifdef HAVE_IO_PRIORITY
1655 buf_back_off_storage(false);
1656#endif
1657 if (hid == ERR_BUFFER_FULL) 1644 if (hid == ERR_BUFFER_FULL)
1658 { 1645 {
1659 logf("buffer is full for now (%s)", __func__); 1646 logf("buffer is full for now (%s)", __func__);
diff --git a/firmware/export/config.h b/firmware/export/config.h
index b1ee101fe6..a56dd32303 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -1196,10 +1196,6 @@ Lyre prototype 1 */
1196#define HAVE_PLUGIN_CHECK_OPEN_CLOSE 1196#define HAVE_PLUGIN_CHECK_OPEN_CLOSE
1197#endif 1197#endif
1198 1198
1199#if defined(HAVE_DIRCACHE) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
1200#define HAVE_IO_PRIORITY
1201#endif
1202
1203#if defined(CPU_COLDIRE) || CONFIG_CPU == IMX31L 1199#if defined(CPU_COLDIRE) || CONFIG_CPU == IMX31L
1204/* Can record and play simultaneously */ 1200/* Can record and play simultaneously */
1205#define HAVE_PCM_FULL_DUPLEX 1201#define HAVE_PCM_FULL_DUPLEX
diff --git a/firmware/kernel/include/thread.h b/firmware/kernel/include/thread.h
index dfb632785e..a4f338ed0c 100644
--- a/firmware/kernel/include/thread.h
+++ b/firmware/kernel/include/thread.h
@@ -169,11 +169,6 @@ int thread_set_priority(unsigned int thread_id, int priority);
169int thread_get_priority(unsigned int thread_id); 169int thread_get_priority(unsigned int thread_id);
170#endif /* HAVE_PRIORITY_SCHEDULING */ 170#endif /* HAVE_PRIORITY_SCHEDULING */
171 171
172#ifdef HAVE_IO_PRIORITY
173void thread_set_io_priority(unsigned int thread_id, int io_priority);
174int thread_get_io_priority(unsigned int thread_id);
175#endif /* HAVE_IO_PRIORITY */
176
177#if NUM_CORES > 1 172#if NUM_CORES > 1
178unsigned int switch_core(unsigned int new_core); 173unsigned int switch_core(unsigned int new_core);
179#endif 174#endif
diff --git a/firmware/kernel/thread-internal.h b/firmware/kernel/thread-internal.h
index 10606a54a6..868e57c65c 100644
--- a/firmware/kernel/thread-internal.h
+++ b/firmware/kernel/thread-internal.h
@@ -134,9 +134,6 @@ struct thread_entry
134#ifdef HAVE_SCHEDULER_BOOSTCTRL 134#ifdef HAVE_SCHEDULER_BOOSTCTRL
135 unsigned char cpu_boost; /* CPU frequency boost flag */ 135 unsigned char cpu_boost; /* CPU frequency boost flag */
136#endif 136#endif
137#ifdef HAVE_IO_PRIORITY
138 unsigned char io_priority;
139#endif
140}; 137};
141 138
142/* Thread ID, 32 bits = |VVVVVVVV|VVVVVVVV|VVVVVVVV|SSSSSSSS| */ 139/* Thread ID, 32 bits = |VVVVVVVV|VVVVVVVV|VVVVVVVV|SSSSSSSS| */
diff --git a/firmware/kernel/thread.c b/firmware/kernel/thread.c
index 05c09dc594..ea76421389 100644
--- a/firmware/kernel/thread.c
+++ b/firmware/kernel/thread.c
@@ -367,10 +367,6 @@ static void new_thread_base_init(struct thread_entry *thread,
367#ifdef HAVE_SCHEDULER_BOOSTCTRL 367#ifdef HAVE_SCHEDULER_BOOSTCTRL
368 thread->cpu_boost = 0; 368 thread->cpu_boost = 0;
369#endif 369#endif
370#ifdef HAVE_IO_PRIORITY
371 /* Default to high (foreground) priority */
372 thread->io_priority = IO_PRIORITY_IMMEDIATE;
373#endif
374} 370}
375 371
376/*--------------------------------------------------------------------------- 372/*---------------------------------------------------------------------------
@@ -1421,20 +1417,6 @@ int thread_get_priority(unsigned int thread_id)
1421} 1417}
1422#endif /* HAVE_PRIORITY_SCHEDULING */ 1418#endif /* HAVE_PRIORITY_SCHEDULING */
1423 1419
1424#ifdef HAVE_IO_PRIORITY
1425int thread_get_io_priority(unsigned int thread_id)
1426{
1427 struct thread_entry *thread = __thread_id_entry(thread_id);
1428 return thread->io_priority;
1429}
1430
1431void thread_set_io_priority(unsigned int thread_id,int io_priority)
1432{
1433 struct thread_entry *thread = __thread_id_entry(thread_id);
1434 thread->io_priority = io_priority;
1435}
1436#endif
1437
1438/*--------------------------------------------------------------------------- 1420/*---------------------------------------------------------------------------
1439 * Starts a frozen thread - similar semantics to wakeup_thread except that 1421 * Starts a frozen thread - similar semantics to wakeup_thread except that
1440 * the thread is on no scheduler or wakeup queue at all. It exists simply by 1422 * the thread is on no scheduler or wakeup queue at all. It exists simply by
diff --git a/firmware/storage.c b/firmware/storage.c
index e0b491a5f9..e9a3396f30 100644
--- a/firmware/storage.c
+++ b/firmware/storage.c
@@ -33,63 +33,9 @@ static unsigned int storage_drivers[NUM_DRIVES];
33static unsigned int num_drives; 33static unsigned int num_drives;
34#endif 34#endif
35 35
36
37#ifdef HAVE_IO_PRIORITY
38
39/* Same for flash? */
40#define STORAGE_MINIMUM_IDLE_TIME (HZ/10)
41#define STORAGE_DELAY_UNIT (HZ/20)
42
43static unsigned int storage_last_thread[NUM_DRIVES];
44static unsigned int storage_last_activity[NUM_DRIVES];
45
46static bool storage_should_wait(int drive, int prio)
47{
48 int other_prio = thread_get_io_priority(storage_last_thread[drive]);
49 if(TIME_BEFORE(current_tick,storage_last_activity[drive]+STORAGE_MINIMUM_IDLE_TIME))
50 {
51 if(prio<=other_prio)
52 {
53 /* There is another active thread, but we have lower priority */
54 return false;
55 }
56 else
57 {
58 /* There is another active thread, but it has lower priority */
59 return true;
60 }
61 }
62 else
63 {
64 /* There's nothing going on anyway */
65 return false;
66 }
67}
68
69static void storage_wait_turn(IF_MD_NONVOID(int drive))
70{
71#ifndef HAVE_MULTIDRIVE
72 int drive=0;
73#endif
74 int my_prio = thread_get_io_priority(thread_self());
75 int loops=my_prio;
76 while(storage_should_wait(drive, my_prio) && (loops--)>=0)
77 {
78 sleep(STORAGE_DELAY_UNIT);
79 }
80
81 storage_last_thread[drive] = thread_self();
82 storage_last_activity[drive] = current_tick;
83}
84#endif
85
86int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count, 36int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count,
87 void* buf) 37 void* buf)
88{ 38{
89#ifdef HAVE_IO_PRIORITY
90 storage_wait_turn(IF_MD(drive));
91#endif
92
93#ifdef CONFIG_STORAGE_MULTI 39#ifdef CONFIG_STORAGE_MULTI
94 int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET; 40 int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
95 int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET; 41 int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
@@ -132,10 +78,6 @@ int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count,
132int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count, 78int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count,
133 const void* buf) 79 const void* buf)
134{ 80{
135#ifdef HAVE_IO_PRIORITY
136 storage_wait_turn(IF_MD(drive));
137#endif
138
139#ifdef CONFIG_STORAGE_MULTI 81#ifdef CONFIG_STORAGE_MULTI
140 int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET; 82 int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
141 int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET; 83 int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;