diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2006-10-21 14:47:55 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2006-10-21 14:47:55 +0000 |
commit | 9afce4d35997ce0883474d3f978aa570b7233f03 (patch) | |
tree | 91641c02af223f9b3776662ce2ed3a9eab59afe2 /apps | |
parent | e918edc48b6e79bcaf0128d562f9fb25a3e0b3ff (diff) | |
download | rockbox-9afce4d35997ce0883474d3f978aa570b7233f03.tar.gz rockbox-9afce4d35997ce0883474d3f978aa570b7233f03.zip |
Disk spindown control during jpeg slideshow: for times below 10s, keep the disk spinning, for longer times spin down the disk immediately after loading the picture. Inspired by #FS5653 (Paul Jam / Gwen Roelants) and Jens Arnold
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11299 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugin.c | 1 | ||||
-rw-r--r-- | apps/plugin.h | 3 | ||||
-rw-r--r-- | apps/plugins/jpeg.c | 63 |
3 files changed, 54 insertions, 13 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 38fdaa8f35..bc8419d313 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -472,6 +472,7 @@ static const struct plugin_api rockbox_api = { | |||
472 | wheel_status, | 472 | wheel_status, |
473 | wheel_send_events, | 473 | wheel_send_events, |
474 | #endif | 474 | #endif |
475 | ata_spindown, | ||
475 | }; | 476 | }; |
476 | 477 | ||
477 | int plugin_load(const char* plugin, void* parameter) | 478 | int plugin_load(const char* plugin, void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index 461c0d816a..609f4cc65b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -105,7 +105,7 @@ | |||
105 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 105 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
106 | 106 | ||
107 | /* increase this every time the api struct changes */ | 107 | /* increase this every time the api struct changes */ |
108 | #define PLUGIN_API_VERSION 32 | 108 | #define PLUGIN_API_VERSION 33 |
109 | 109 | ||
110 | /* update this to latest version if a change to the api struct breaks | 110 | /* update this to latest version if a change to the api struct breaks |
111 | backwards compatibility (and please take the opportunity to sort in any | 111 | backwards compatibility (and please take the opportunity to sort in any |
@@ -552,6 +552,7 @@ struct plugin_api { | |||
552 | int (*wheel_status)(void); | 552 | int (*wheel_status)(void); |
553 | void (*wheel_send_events)(bool send); | 553 | void (*wheel_send_events)(bool send); |
554 | #endif | 554 | #endif |
555 | void (*ata_spindown)(int seconds); | ||
555 | }; | 556 | }; |
556 | 557 | ||
557 | /* plugin header */ | 558 | /* plugin header */ |
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index ce2f55cb24..716599aec1 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c | |||
@@ -165,7 +165,11 @@ static struct plugin_api* rb; | |||
165 | #define INLINE static inline | 165 | #define INLINE static inline |
166 | #define ENDIAN_SWAP16(n) n /* only for poor little endian machines */ | 166 | #define ENDIAN_SWAP16(n) n /* only for poor little endian machines */ |
167 | 167 | ||
168 | static int slideshow_enabled = false; | 168 | static int slideshow_enabled = false; /* run slideshow */ |
169 | static int running_slideshow = false; /* loading image because of slideshw */ | ||
170 | #ifndef SIMULATOR | ||
171 | static int immediate_ata_off = false; /* power down disk after loading */ | ||
172 | #endif | ||
169 | static int button_timeout = HZ*5; | 173 | static int button_timeout = HZ*5; |
170 | 174 | ||
171 | /**************** begin JPEG code ********************/ | 175 | /**************** begin JPEG code ********************/ |
@@ -174,7 +178,7 @@ INLINE unsigned range_limit(int value) | |||
174 | { | 178 | { |
175 | #if CONFIG_CPU == SH7034 | 179 | #if CONFIG_CPU == SH7034 |
176 | unsigned tmp; | 180 | unsigned tmp; |
177 | asm ( /* Note: Uses knowledge that only the low byte of the result is used */ | 181 | asm ( /* Note: Uses knowledge that only low byte of result is used */ |
178 | "mov #-128,%[t] \n" | 182 | "mov #-128,%[t] \n" |
179 | "sub %[t],%[v] \n" /* value -= -128; equals value += 128; */ | 183 | "sub %[t],%[v] \n" /* value -= -128; equals value += 128; */ |
180 | "extu.b %[v],%[t] \n" | 184 | "extu.b %[v],%[t] \n" |
@@ -2092,7 +2096,7 @@ int show_menu(void) /* return 1 to quit */ | |||
2092 | static const struct menu_item items[] = { | 2096 | static const struct menu_item items[] = { |
2093 | { "Quit", NULL }, | 2097 | { "Quit", NULL }, |
2094 | { "Toggle Slideshow Mode", NULL }, | 2098 | { "Toggle Slideshow Mode", NULL }, |
2095 | { "Change Slideshow Timeout", NULL }, | 2099 | { "Change Slideshow Time", NULL }, |
2096 | { "Show Playback Menu", NULL }, | 2100 | { "Show Playback Menu", NULL }, |
2097 | { "Return", NULL }, | 2101 | { "Return", NULL }, |
2098 | }; | 2102 | }; |
@@ -2135,7 +2139,7 @@ int show_menu(void) /* return 1 to quit */ | |||
2135 | case 20: result = 11; break; | 2139 | case 20: result = 11; break; |
2136 | default: result = (button_timeout/HZ)-1; break; | 2140 | default: result = (button_timeout/HZ)-1; break; |
2137 | } | 2141 | } |
2138 | rb->set_option("Slideshow Timeout", &result, INT, | 2142 | rb->set_option("Slideshow Time", &result, INT, |
2139 | timeout , 12, NULL); | 2143 | timeout , 12, NULL); |
2140 | switch (result) | 2144 | switch (result) |
2141 | { | 2145 | { |
@@ -2151,6 +2155,27 @@ int show_menu(void) /* return 1 to quit */ | |||
2151 | case 4: | 2155 | case 4: |
2152 | break; | 2156 | break; |
2153 | } | 2157 | } |
2158 | |||
2159 | #ifndef SIMULATOR | ||
2160 | /* change ata spindown time based on slideshow time setting */ | ||
2161 | immediate_ata_off = false; | ||
2162 | rb->ata_spindown(rb->global_settings->disk_spindown); | ||
2163 | |||
2164 | if (slideshow_enabled) | ||
2165 | { | ||
2166 | if(button_timeout/HZ < 10) | ||
2167 | { | ||
2168 | /* slideshow times < 10s keep disk spinning */ | ||
2169 | rb->ata_spindown(0); | ||
2170 | } | ||
2171 | else if (!rb->mp3_is_playing()) | ||
2172 | { | ||
2173 | /* slideshow times > 10s and not playing: ata_off after load */ | ||
2174 | immediate_ata_off = true; | ||
2175 | } | ||
2176 | } | ||
2177 | #endif | ||
2178 | |||
2154 | rb->lcd_clear_display(); | 2179 | rb->lcd_clear_display(); |
2155 | rb->menu_exit(m); | 2180 | rb->menu_exit(m); |
2156 | return 0; | 2181 | return 0; |
@@ -2169,6 +2194,8 @@ int scroll_bmp(struct t_disp* pdisp) | |||
2169 | button = rb->button_get_w_tmo(button_timeout); | 2194 | button = rb->button_get_w_tmo(button_timeout); |
2170 | else button = rb->button_get(true); | 2195 | else button = rb->button_get(true); |
2171 | 2196 | ||
2197 | running_slideshow = false; | ||
2198 | |||
2172 | switch(button) | 2199 | switch(button) |
2173 | { | 2200 | { |
2174 | case JPEG_LEFT: | 2201 | case JPEG_LEFT: |
@@ -2271,6 +2298,7 @@ int scroll_bmp(struct t_disp* pdisp) | |||
2271 | case BUTTON_NONE: | 2298 | case BUTTON_NONE: |
2272 | if (!slideshow_enabled) | 2299 | if (!slideshow_enabled) |
2273 | break; | 2300 | break; |
2301 | running_slideshow = true; | ||
2274 | if (entries > 0) | 2302 | if (entries > 0) |
2275 | return change_filename(DIR_NEXT); | 2303 | return change_filename(DIR_NEXT); |
2276 | break; | 2304 | break; |
@@ -2340,7 +2368,7 @@ int scroll_bmp(struct t_disp* pdisp) | |||
2340 | void cb_progess(int current, int total) | 2368 | void cb_progess(int current, int total) |
2341 | { | 2369 | { |
2342 | rb->yield(); /* be nice to the other threads */ | 2370 | rb->yield(); /* be nice to the other threads */ |
2343 | if(!slideshow_enabled) | 2371 | if(!running_slideshow) |
2344 | { | 2372 | { |
2345 | rb->scrollbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, total, 0, | 2373 | rb->scrollbar(0, LCD_HEIGHT-8, LCD_WIDTH, 8, total, 0, |
2346 | current, HORIZONTAL); | 2374 | current, HORIZONTAL); |
@@ -2461,7 +2489,7 @@ struct t_disp* get_image(struct jpeg* p_jpg, int ds) | |||
2461 | buf += size; | 2489 | buf += size; |
2462 | buf_size -= size; | 2490 | buf_size -= size; |
2463 | 2491 | ||
2464 | if(!slideshow_enabled) | 2492 | if(!running_slideshow) |
2465 | { | 2493 | { |
2466 | rb->snprintf(print, sizeof(print), "decoding %d*%d", | 2494 | rb->snprintf(print, sizeof(print), "decoding %d*%d", |
2467 | p_jpg->x_size/ds, p_jpg->y_size/ds); | 2495 | p_jpg->x_size/ds, p_jpg->y_size/ds); |
@@ -2491,7 +2519,7 @@ struct t_disp* get_image(struct jpeg* p_jpg, int ds) | |||
2491 | } | 2519 | } |
2492 | time = *rb->current_tick - time; | 2520 | time = *rb->current_tick - time; |
2493 | 2521 | ||
2494 | if(!slideshow_enabled) | 2522 | if(!running_slideshow) |
2495 | { | 2523 | { |
2496 | rb->snprintf(print, sizeof(print), " %d.%02d sec ", time/HZ, time%HZ); | 2524 | rb->snprintf(print, sizeof(print), " %d.%02d sec ", time/HZ, time%HZ); |
2497 | rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ | 2525 | rb->lcd_getstringsize(print, &w, &h); /* centered in progress bar */ |
@@ -2630,7 +2658,7 @@ int load_and_show(char* filename) | |||
2630 | } | 2658 | } |
2631 | } | 2659 | } |
2632 | 2660 | ||
2633 | if(!slideshow_enabled) | 2661 | if(!running_slideshow) |
2634 | { | 2662 | { |
2635 | #ifdef HAVE_LCD_COLOR | 2663 | #ifdef HAVE_LCD_COLOR |
2636 | rb->lcd_set_foreground(LCD_WHITE); | 2664 | rb->lcd_set_foreground(LCD_WHITE); |
@@ -2650,13 +2678,19 @@ int load_and_show(char* filename) | |||
2650 | rb->read(fd, buf_jpeg, filesize); | 2678 | rb->read(fd, buf_jpeg, filesize); |
2651 | rb->close(fd); | 2679 | rb->close(fd); |
2652 | 2680 | ||
2653 | if(!slideshow_enabled) | 2681 | if(!running_slideshow) |
2654 | { | 2682 | { |
2655 | rb->snprintf(print, sizeof(print), "decoding markers"); | 2683 | rb->snprintf(print, sizeof(print), "decoding markers"); |
2656 | rb->lcd_puts(0, 2, print); | 2684 | rb->lcd_puts(0, 2, print); |
2657 | rb->lcd_update(); | 2685 | rb->lcd_update(); |
2658 | } | 2686 | } |
2659 | 2687 | #ifndef SIMULATOR | |
2688 | else if(immediate_ata_off) | ||
2689 | { | ||
2690 | /* running slideshow and time is long enough: power down disk */ | ||
2691 | rb->ata_sleep(); | ||
2692 | } | ||
2693 | #endif | ||
2660 | 2694 | ||
2661 | rb->memset(&jpg, 0, sizeof(jpg)); /* clear info struct */ | 2695 | rb->memset(&jpg, 0, sizeof(jpg)); /* clear info struct */ |
2662 | /* process markers, unstuffing */ | 2696 | /* process markers, unstuffing */ |
@@ -2673,7 +2707,7 @@ int load_and_show(char* filename) | |||
2673 | default_huff_tbl(&jpg); /* use default */ | 2707 | default_huff_tbl(&jpg); /* use default */ |
2674 | build_lut(&jpg); /* derive Huffman and other lookup-tables */ | 2708 | build_lut(&jpg); /* derive Huffman and other lookup-tables */ |
2675 | 2709 | ||
2676 | if(!slideshow_enabled) | 2710 | if(!running_slideshow) |
2677 | { | 2711 | { |
2678 | rb->snprintf(print, sizeof(print), "image %dx%d", jpg.x_size, jpg.y_size); | 2712 | rb->snprintf(print, sizeof(print), "image %dx%d", jpg.x_size, jpg.y_size); |
2679 | rb->lcd_puts(0, 2, print); | 2713 | rb->lcd_puts(0, 2, print); |
@@ -2700,7 +2734,7 @@ int load_and_show(char* filename) | |||
2700 | 2734 | ||
2701 | set_view(p_disp, cx, cy); | 2735 | set_view(p_disp, cx, cy); |
2702 | 2736 | ||
2703 | if(!slideshow_enabled) | 2737 | if(!running_slideshow) |
2704 | { | 2738 | { |
2705 | rb->snprintf(print, sizeof(print), "showing %dx%d", | 2739 | rb->snprintf(print, sizeof(print), "showing %dx%d", |
2706 | p_disp->width, p_disp->height); | 2740 | p_disp->width, p_disp->height); |
@@ -2840,6 +2874,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2840 | }while (condition != PLUGIN_OK && condition != PLUGIN_USB_CONNECTED | 2874 | }while (condition != PLUGIN_OK && condition != PLUGIN_USB_CONNECTED |
2841 | && condition != PLUGIN_ERROR); | 2875 | && condition != PLUGIN_ERROR); |
2842 | 2876 | ||
2877 | #ifndef SIMULATOR | ||
2878 | /* set back ata spindown time in case we changed it */ | ||
2879 | rb->ata_spindown(rb->global_settings->disk_spindown); | ||
2880 | #endif | ||
2881 | |||
2843 | #ifdef CONFIG_BACKLIGHT | 2882 | #ifdef CONFIG_BACKLIGHT |
2844 | /* reset backlight settings */ | 2883 | /* reset backlight settings */ |
2845 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | 2884 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); |