A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

Initial commit for the Sony NWZ linux port

SUPPORTED SERIES:
- NWZ-E450
- NWZ-E460
- NWZ-E470
- NWZ-E580
- NWZ-A10

NOTES:
- bootloader makefile convert an extra font to be installed alongside the bootloader
since sysfont is way too small
- the toolsicon bitmap comes from the Oxygen iconset
- touchscreen driver is untested

TODO:
- implement audio routing driver (pcm is handled by pcm-alsa)
- fix playback: it crashes on illegal instruction in DEBUG builds
- find out why the browser starts at / instead of /contents
- implement radio support
- implement return to OF for usb handling
- calibrate battery curve (NB: of can report a battery level on a 0-5 scale but
probabl don't want to use that ?)
- implement simulator build (we need a nice image of the player)
- figure out if we can detect jack removal

POTENTIAL TODOS:
- try to build a usb serial gadget and gdbserver

Change-Id: Ic77d71e0651355d47cc4e423a40fb64a60c69a80

+4439 -2913
+2 -1
apps/bitmaps/bitmaps.make
··· 29 29 30 30 BMPHFILES = $(BMPINCDIR)/usblogo.h $(BMPINCDIR)/remote_usblogo.h \ 31 31 $(BMPINCDIR)/default_icons.h $(BMPINCDIR)/remote_default_icons.h \ 32 - $(BMPINCDIR)/rockboxlogo.h $(BMPINCDIR)/remote_rockboxlogo.h 32 + $(BMPINCDIR)/rockboxlogo.h $(BMPINCDIR)/remote_rockboxlogo.h \ 33 + $(BMPINCDIR)/rockboxicon.h $(BMPINCDIR)/toolsicon.h 33 34 34 35 $(BMPHFILES): $(BMPOBJ) 35 36
+6
apps/bitmaps/native/SOURCES
··· 39 39 rockboxlogo.640x198x16.bmp 40 40 #endif 41 41 42 + /* The Sony NWZ linux bootloader needs icons to display a menu */ 43 + #if defined(BOOTLOADER) && defined(SONY_NWZ_LINUX) 44 + rockboxicon.130x130x16.bmp 45 + toolsicon.130x130x16.bmp 46 + #endif 47 + 42 48 #ifndef BOOTLOADER /* We don't need these for the bootloader */ 43 49 44 50 /* USB logo */
+1 -1
apps/debug_menu.c
··· 2594 2594 #endif 2595 2595 { "Skin Engine RAM usage", dbg_skin_engine }, 2596 2596 #endif 2597 - #if (CONFIG_PLATFORM & PLATFORM_NATIVE) 2597 + #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SONY_NWZ_LINUX) 2598 2598 { "View HW info", dbg_hw_info }, 2599 2599 #endif 2600 2600 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
+1
apps/keymaps/keymap-nwz.c
··· 210 210 }; /* button_context_colorchooser */ 211 211 212 212 static const struct button_mapping button_context_eq[] = { 213 + { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, 213 214 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, 214 215 215 216 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
+2
bootloader/SOURCES
··· 71 71 show_logo.c 72 72 #elif defined(MPIO_HD200) || defined(MPIO_HD300) 73 73 mpio_hd200_hd300.c 74 + #elif defined(SONY_NWZ_LINUX) 75 + nwz_linux.c 74 76 #elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \ 75 77 || defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \ 76 78 || defined(IHIFI760) || defined(IHIFI960)
+2
bootloader/common.c
··· 60 60 bool verbose = true; 61 61 #endif 62 62 63 + #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) 63 64 int line = 0; 64 65 #ifdef HAVE_REMOTE_LCD 65 66 int remote_line = 0; ··· 101 102 #endif 102 103 return len; 103 104 } 105 + #endif 104 106 105 107 void error(int errortype, int error, bool shutdown) 106 108 {
+2
bootloader/common.h
··· 30 30 #define EBOOTFILE -3 31 31 32 32 /* Functions common to all bootloaders */ 33 + #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) 33 34 void reset_screen(void); 34 35 int printf(const char *format, ...); 36 + #endif 35 37 void error(int errortype, int error, bool shutdown); 36 38 int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size); 37 39 #ifdef ROCKBOX_HAS_LOGF
+524
bootloader/nwz_linux.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by Amaury Pouly 11 + * 12 + * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing 13 + * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach 14 + * 15 + * This program is free software; you can redistribute it and/or 16 + * modify it under the terms of the GNU General Public License 17 + * as published by the Free Software Foundation; either version 2 18 + * of the License, or (at your option) any later version. 19 + * 20 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 + * KIND, either express or implied. 22 + * 23 + ****************************************************************************/ 24 + 25 + #include "system.h" 26 + #include "lcd.h" 27 + #include "backlight.h" 28 + #include "button-target.h" 29 + #include "button.h" 30 + #include "../kernel/kernel-internal.h" 31 + #include "core_alloc.h" 32 + #include "filesystem-app.h" 33 + #include "nvp-nwz.h" 34 + #include "power-nwz.h" 35 + #include "lcd.h" 36 + #include "font.h" 37 + #include "power.h" 38 + #include <string.h> 39 + #include <stdlib.h> 40 + #include <unistd.h> 41 + #include <sys/types.h> 42 + #include <sys/stat.h> 43 + #include <fcntl.h> 44 + #include <dirent.h> 45 + #include <sys/wait.h> 46 + #include <stdarg.h> 47 + 48 + /* all images must have the following size */ 49 + #define ICON_WIDTH 130 50 + #define ICON_HEIGHT 130 51 + 52 + /* images */ 53 + #include "bitmaps/rockboxicon.h" 54 + #include "bitmaps/toolsicon.h" 55 + 56 + /* don't issue an error when parsing the file for dependencies */ 57 + #if defined(BMPWIDTH_rockboxicon) && (BMPWIDTH_rockboxicon != ICON_WIDTH || \ 58 + BMPHEIGHT_rockboxicon != ICON_HEIGHT) 59 + #error rockboxicon has the wrong resolution 60 + #endif 61 + #if defined(BMPWIDTH_toolsicon) && (BMPWIDTH_toolsicon != ICON_WIDTH || \ 62 + BMPHEIGHT_toolsicon != ICON_HEIGHT) 63 + #error toolsicon has the wrong resolution 64 + #endif 65 + 66 + /* buffer for Sony image, filled from NVP */ 67 + unsigned short sonyicon[ICON_WIDTH * ICON_HEIGHT]; 68 + const struct bitmap bm_sonyicon = 69 + { 70 + .width = ICON_WIDTH, 71 + .height = ICON_HEIGHT, 72 + .format = FORMAT_NATIVE, 73 + .data = (unsigned char*)sonyicon 74 + }; 75 + 76 + /* return icon y position (x is always centered) */ 77 + int get_icon_y(void) 78 + { 79 + /* adjust so that this contains the Sony logo and produces a nice logo 80 + * when used with rockbox */ 81 + if(LCD_HEIGHT == 320) 82 + return 70; 83 + else if(LCD_HEIGHT == 400) 84 + return 100; 85 + else 86 + return LCD_HEIGHT / 2 - ICON_HEIGHT + 30; /* guess, probably won't work */ 87 + } 88 + 89 + /* Sony logo extraction */ 90 + bool extract_sony_logo(void) 91 + { 92 + /* load the entire image from the nvp */ 93 + int bti_size = nwz_nvp_read(NWZ_NVP_BTI, NULL); 94 + if(bti_size < 0) 95 + return false; 96 + unsigned short *bti = malloc(bti_size); 97 + if(nwz_nvp_read(NWZ_NVP_BTI, bti) != bti_size) 98 + return false; 99 + /* compute the offset in the image of the logo itself */ 100 + int x_off = (LCD_WIDTH - ICON_WIDTH) / 2; /* logo is centered horizontally */ 101 + int y_off = get_icon_y(); 102 + /* extract part of the image */ 103 + for(int y = 0; y < ICON_HEIGHT; y++) 104 + { 105 + memcpy(sonyicon + ICON_WIDTH * y, 106 + bti + LCD_WIDTH * (y + y_off) + x_off, ICON_WIDTH * sizeof(unsigned short)); 107 + } 108 + free(bti); 109 + return true; 110 + } 111 + 112 + /* Important Note: this bootloader is carefully written so that in case of 113 + * error, the OF is run. This seems like the safest option since the OF is 114 + * always there and might do magic things. */ 115 + 116 + enum boot_mode 117 + { 118 + BOOT_ROCKBOX, 119 + BOOT_TOOLS, 120 + BOOT_OF, 121 + BOOT_COUNT, 122 + BOOT_USB, /* special */ 123 + BOOT_STOP, /* power down/suspend */ 124 + }; 125 + 126 + static void display_text_center(int y, const char *text) 127 + { 128 + int width; 129 + lcd_getstringsize(text, &width, NULL); 130 + lcd_putsxy(LCD_WIDTH / 2 - width / 2, y, text); 131 + } 132 + 133 + static void display_text_centerf(int y, const char *format, ...) 134 + { 135 + char buf[1024]; 136 + va_list ap; 137 + va_start(ap, format); 138 + 139 + vsnprintf(buf, sizeof(buf), format, ap); 140 + display_text_center(y, buf); 141 + } 142 + 143 + /* get timeout before taking action if the user doesn't touch the device */ 144 + int get_inactivity_tmo(void) 145 + { 146 + if(button_hold()) 147 + return 5 * HZ; /* Inactivity timeout when on hold */ 148 + else 149 + return 10 * HZ; /* Inactivity timeout when not on hold */ 150 + } 151 + 152 + /* return action on idle timeout */ 153 + enum boot_mode inactivity_action(enum boot_mode cur_selection) 154 + { 155 + if(button_hold()) 156 + return BOOT_STOP; /* power down/suspend */ 157 + else 158 + return cur_selection; /* return last choice */ 159 + } 160 + 161 + /* we store the boot mode in a file in /tmp so we can reload it between 'boots' 162 + * (since the mostly suspends instead of powering down) */ 163 + enum boot_mode load_boot_mode(enum boot_mode mode) 164 + { 165 + int fd = open("/tmp/rb_bl_mode.txt", O_RDONLY); 166 + if(fd >= 0) 167 + { 168 + read(fd, &mode, sizeof(mode)); 169 + close(fd); 170 + } 171 + return mode; 172 + } 173 + 174 + void save_boot_mode(enum boot_mode mode) 175 + { 176 + int fd = open("/tmp/rb_bl_mode.txt", O_RDWR | O_CREAT | O_TRUNC); 177 + if(fd >= 0) 178 + { 179 + write(fd, &mode, sizeof(mode)); 180 + close(fd); 181 + } 182 + } 183 + 184 + enum boot_mode get_boot_mode(void) 185 + { 186 + /* load previous mode, or start with rockbox if none */ 187 + enum boot_mode init_mode = load_boot_mode(BOOT_ROCKBOX); 188 + /* wait for user action */ 189 + enum boot_mode mode = init_mode; 190 + int last_activity = current_tick; 191 + bool hold_status = button_hold(); 192 + while(true) 193 + { 194 + /* on usb detect, return to usb 195 + * FIXME this is a hack, we need proper usb detection */ 196 + if(power_input_status() & POWER_INPUT_USB_CHARGER) 197 + { 198 + /* save last choice */ 199 + save_boot_mode(mode); 200 + return BOOT_USB; 201 + } 202 + /* inactivity detection */ 203 + int timeout = last_activity + get_inactivity_tmo(); 204 + if(TIME_AFTER(current_tick, timeout)) 205 + { 206 + /* save last choice */ 207 + save_boot_mode(mode); 208 + return inactivity_action(mode); 209 + } 210 + /* redraw */ 211 + lcd_clear_display(); 212 + /* display top text */ 213 + if(button_hold()) 214 + { 215 + lcd_set_foreground(LCD_RGBPACK(255, 0, 0)); 216 + display_text_center(0, "ON HOLD!"); 217 + } 218 + else 219 + { 220 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 221 + display_text_center(0, "SELECT PLAYER"); 222 + } 223 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 224 + /* display icon */ 225 + const struct bitmap *icon = (mode == BOOT_OF) ? &bm_sonyicon : 226 + (mode == BOOT_ROCKBOX) ? &bm_rockboxicon : &bm_toolsicon; 227 + lcd_bmp(icon, (LCD_WIDTH - ICON_WIDTH) / 2, get_icon_y()); 228 + /* display bottom description */ 229 + const char *desc = (mode == BOOT_OF) ? "SONY" : 230 + (mode == BOOT_ROCKBOX) ? "ROCKBOX" : "TOOLS"; 231 + display_text_center(get_icon_y() + ICON_HEIGHT + 30, desc); 232 + /* display arrows */ 233 + int arrow_width, arrow_height; 234 + lcd_getstringsize("<", &arrow_width, &arrow_height); 235 + int arrow_y = get_icon_y() + ICON_HEIGHT / 2 - arrow_height / 2; 236 + lcd_putsxy(arrow_width / 2, arrow_y, "<"); 237 + lcd_putsxy(LCD_WIDTH - 3 * arrow_width / 2, arrow_y, ">"); 238 + 239 + lcd_set_foreground(LCD_RGBPACK(0, 255, 0)); 240 + display_text_centerf(LCD_HEIGHT - arrow_height * 3 / 2, "timeout in %d sec", 241 + (timeout - current_tick + HZ - 1) / HZ); 242 + 243 + lcd_update(); 244 + 245 + /* wait for a key */ 246 + int btn = button_get_w_tmo(HZ / 10); 247 + /* record action, changing HOLD counts as action */ 248 + if(btn & BUTTON_MAIN || hold_status != button_hold()) 249 + last_activity = current_tick; 250 + hold_status = button_hold(); 251 + /* ignore release, allow repeat */ 252 + if(btn & BUTTON_REL) 253 + continue; 254 + if(btn & BUTTON_REPEAT) 255 + btn &= ~BUTTON_REPEAT; 256 + /* play -> stop loop and return mode */ 257 + if(btn == BUTTON_PLAY) 258 + break; 259 + /* left/right/up/down: change mode */ 260 + if(btn == BUTTON_LEFT || btn == BUTTON_DOWN) 261 + mode = (mode + BOOT_COUNT - 1) % BOOT_COUNT; 262 + if(btn == BUTTON_RIGHT || btn == BUTTON_UP) 263 + mode = (mode + 1) % BOOT_COUNT; 264 + } 265 + 266 + /* save mode */ 267 + save_boot_mode(mode); 268 + return mode; 269 + } 270 + 271 + void error_screen(const char *msg) 272 + { 273 + lcd_clear_display(); 274 + lcd_putsf(0, 0, msg); 275 + lcd_update(); 276 + } 277 + 278 + void create_sony_logo(void) 279 + { 280 + for(int y = 0; y < ICON_HEIGHT; y++) 281 + for(int x = 0; x < ICON_WIDTH; x++) 282 + sonyicon[y * ICON_WIDTH + x] = 0xf81f; 283 + } 284 + 285 + int choice_screen(const char *title, bool center, int nr_choices, const char *choices[]) 286 + { 287 + int choice = 0; 288 + int max_len = 0; 289 + int h; 290 + lcd_getstringsize("x", NULL, &h); 291 + for(int i = 0; i < nr_choices; i++) 292 + { 293 + int len = strlen(choices[i]); 294 + if(len > max_len) 295 + max_len = len; 296 + } 297 + char *buf = malloc(max_len + 10); 298 + int top_y = 2 * h; 299 + int nr_lines = (LCD_HEIGHT - top_y) / h; 300 + while(true) 301 + { 302 + /* make sure choice is visible */ 303 + int offset = choice - nr_lines / 2; 304 + if(offset < 0) 305 + offset = 0; 306 + lcd_clear_display(); 307 + /* display top text */ 308 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 309 + display_text_center(0, title); 310 + int line = 0; 311 + for(int i = 0; i < nr_choices && line < nr_lines; i++) 312 + { 313 + if(i < offset) 314 + continue; 315 + if(i == choice) 316 + lcd_set_foreground(LCD_RGBPACK(255, 0, 0)); 317 + else 318 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 319 + sprintf(buf, "%s", choices[i]); 320 + if(center) 321 + display_text_center(top_y + h * line, buf); 322 + else 323 + lcd_putsxy(0, top_y + h * line, buf); 324 + line++; 325 + } 326 + 327 + lcd_update(); 328 + 329 + /* wait for a key */ 330 + int btn = button_get_w_tmo(HZ / 10); 331 + /* ignore release, allow repeat */ 332 + if(btn & BUTTON_REL) 333 + continue; 334 + if(btn & BUTTON_REPEAT) 335 + btn &= ~BUTTON_REPEAT; 336 + /* play -> stop loop and return mode */ 337 + if(btn == BUTTON_PLAY || btn == BUTTON_BACK) 338 + { 339 + free(buf); 340 + return btn == BUTTON_PLAY ? choice : -1; 341 + } 342 + /* left/right/up/down: change mode */ 343 + if(btn == BUTTON_LEFT || btn == BUTTON_UP) 344 + choice = (choice + nr_choices - 1) % nr_choices; 345 + if(btn == BUTTON_RIGHT || btn == BUTTON_DOWN) 346 + choice = (choice + 1) % nr_choices; 347 + } 348 + } 349 + 350 + void run_file(const char *name) 351 + { 352 + char *dirname = "/contents/"; 353 + char *buf = malloc(strlen(dirname) + strlen(name) + 1); 354 + sprintf(buf, "%s%s", dirname, name); 355 + 356 + lcd_clear_display(); 357 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 358 + lcd_putsf(0, 0, "Running %s", name); 359 + lcd_update(); 360 + 361 + pid_t pid = fork(); 362 + if(pid == 0) 363 + { 364 + execlp("sh", "sh", buf, NULL); 365 + _exit(42); 366 + } 367 + int status; 368 + waitpid(pid, &status, 0); 369 + if(WIFEXITED(status)) 370 + { 371 + lcd_set_foreground(LCD_RGBPACK(255, 201, 0)); 372 + lcd_putsf(0, 1, "program returned %d", WEXITSTATUS(status)); 373 + } 374 + else 375 + { 376 + lcd_set_foreground(LCD_RGBPACK(255, 0, 0)); 377 + lcd_putsf(0, 1, "an error occured: %x", status); 378 + } 379 + lcd_set_foreground(LCD_RGBPACK(255, 0, 0)); 380 + lcd_putsf(0, 3, "Press any key or wait"); 381 + lcd_update(); 382 + /* wait a small time */ 383 + sleep(HZ); 384 + /* ignore event */ 385 + while(button_get(false) != 0) {} 386 + /* wait for any key or timeout */ 387 + button_get_w_tmo(4 * HZ); 388 + } 389 + 390 + void run_script_menu(void) 391 + { 392 + const char **entries = NULL; 393 + int nr_entries = 0; 394 + DIR *dir = opendir("/contents/"); 395 + struct dirent *ent; 396 + while((ent = readdir(dir))) 397 + { 398 + if(ent->d_type != DT_REG) 399 + continue; 400 + entries = realloc(entries, (nr_entries + 1) * sizeof(const char *)); 401 + entries[nr_entries++] = strdup(ent->d_name); 402 + } 403 + closedir(dir); 404 + int idx = choice_screen("RUN SCRIPT", false, nr_entries, entries); 405 + if(idx >= 0) 406 + run_file(entries[idx]); 407 + for(int i = 0; i < nr_entries; i++) 408 + free((char *)entries[i]); 409 + free(entries); 410 + } 411 + 412 + void tools_screen(void) 413 + { 414 + const char *choices[] = {"Service menu", "Run script", "Restart", "Shutdown"}; 415 + int choice = choice_screen("TOOLS MENU", true, 4, choices); 416 + if(choice == 0) 417 + { 418 + /* run service menu */ 419 + fflush(stdout); 420 + execl("/usr/local/bin/mptapp", "mptapp", NULL); 421 + error_screen("Cannot boot service menu"); 422 + sleep(5 * HZ); 423 + } 424 + else if(choice == 1) 425 + run_script_menu(); 426 + else if(choice == 2) 427 + nwz_power_restart(); 428 + else if(choice == 3) 429 + nwz_power_shutdown(); 430 + } 431 + 432 + /* open log file */ 433 + int open_log(void) 434 + { 435 + /* open regular log file */ 436 + int fd = open("/contents/rockbox.log", O_RDWR | O_CREAT | O_APPEND); 437 + /* get its size */ 438 + struct stat stat; 439 + if(fstat(fd, &stat) != 0) 440 + return fd; /* on error, don't do anything */ 441 + /* if file is too large, rename it and start a new log file */ 442 + if(stat.st_size < 1000000) 443 + return fd; 444 + close(fd); 445 + /* move file */ 446 + rename("/contents/rockbox.log", "/contents/rockbox.log.1"); 447 + /* re-open the file, truncate in case the move was unsuccessful */ 448 + return open("/contents/rockbox.log", O_RDWR | O_CREAT | O_APPEND | O_TRUNC); 449 + } 450 + 451 + int main(int argc, char **argv) 452 + { 453 + (void) argc; 454 + (void) argv; 455 + /* redirect stdout and stderr to have error messages logged somewhere on the 456 + * user partition */ 457 + int fd = open_log(); 458 + if(fd >= 0) 459 + { 460 + dup2(fd, fileno(stdout)); 461 + dup2(fd, fileno(stderr)); 462 + close(fd); 463 + } 464 + system_init(); 465 + core_allocator_init(); 466 + kernel_init(); 467 + paths_init(); 468 + lcd_init(); 469 + font_init(); 470 + button_init(); 471 + backlight_init(); 472 + backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); 473 + /* try to load the extra font we install on the device */ 474 + int font_id = font_load("/usr/local/share/rockbox/bootloader.fnt"); 475 + if(font_id >= 0) 476 + lcd_setfont(font_id); 477 + /* extract logo */ 478 + if(!extract_sony_logo()) 479 + create_sony_logo(); 480 + /* run all tools menu */ 481 + while(true) 482 + { 483 + enum boot_mode mode = get_boot_mode(); 484 + if(mode == BOOT_USB || mode == BOOT_OF) 485 + { 486 + fflush(stdout); 487 + fflush(stderr); 488 + close(fileno(stdout)); 489 + close(fileno(stderr)); 490 + /* for now the only way we have to trigger USB mode it to run the OF */ 491 + /* boot OF */ 492 + execvp("/usr/local/bin/SpiderApp.of", argv); 493 + error_screen("Cannot boot OF"); 494 + sleep(5 * HZ); 495 + } 496 + else if(mode == BOOT_TOOLS) 497 + { 498 + tools_screen(); 499 + } 500 + else if(mode == BOOT_ROCKBOX) 501 + { 502 + /* Rockbox expects /.rockbox to contain themes, rocks, etc, but we 503 + * cannot easily create this symlink because the root filesystem is 504 + * mounted read-only. Although we could remount it read-write temporarily, 505 + * this is neededlessly complicated and we defer this job to the dualboot 506 + * install script */ 507 + fflush(stdout); 508 + execl("/contents/.rockbox/rockbox.sony", "rockbox.sony", NULL); 509 + printf("execvp failed: %s\n", strerror(errno)); 510 + /* fallback to OF in case of failure */ 511 + error_screen("Cannot boot Rockbox"); 512 + sleep(5 * HZ); 513 + } 514 + else 515 + { 516 + /* FIXME doesn't seem to work */ 517 + printf("suspend\n"); 518 + nwz_power_suspend(); 519 + } 520 + } 521 + /* if we reach this point, everything failed, so return an error so that 522 + * sysmgrd knows something is wrong */ 523 + return 1; 524 + }
+20
firmware/SOURCES
··· 95 95 #endif 96 96 #endif 97 97 98 + #ifdef SONY_NWZ_LINUX 99 + target/hosted/backtrace-glibc.c 100 + target/hosted/kernel-unix.c 101 + target/hosted/filesystem-unix.c 102 + target/hosted/lc-unix.c 103 + target/hosted/pcm-alsa.c 104 + target/hosted/sonynwz/lcd-nwz.c 105 + target/hosted/sonynwz/button-nwz.c 106 + target/hosted/sonynwz/system-nwz.c 107 + target/hosted/sonynwz/powermgmt-nwz.c 108 + target/hosted/sonynwz/power-nwz.c 109 + target/hosted/sonynwz/adc-nwz.c 110 + target/hosted/sonynwz/debug-nwz.c 111 + target/hosted/sonynwz/nvp-nwz.c 112 + target/hosted/sonynwz/nwz-db.c 113 + #endif 114 + 98 115 #if defined(SAMSUNG_YPR0) && !defined(SIMULATOR) 99 116 drivers/adc-as3514.c 100 117 #if (CONFIG_RTC == RTC_AS3514) ··· 447 464 #elif defined(SAMSUNG_YPR1) && defined(HAVE_WM8978) 448 465 drivers/audio/wm8978.c 449 466 target/hosted/pcm-alsa.c 467 + #elif defined(HAVE_NWZ_LINUX_CODEC) 468 + drivers/audio/nwzlinux-codec.c 469 + target/hosted/alsa-controls.c 450 470 #elif defined(HAVE_SDL_AUDIO) 451 471 drivers/audio/sdl.c 452 472 #if CONFIG_CODEC == SWCODEC
+1 -1
firmware/asm/SOURCES
··· 15 15 defined(CREATIVE_ZVx) || defined(SANSA_CONNECT) || defined(SANSA_FUZEPLUS) || \ 16 16 defined(COWON_D2) || defined(MINI2440) || defined(SAMSUNG_YPR0) || \ 17 17 defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90) || (defined(MROBE_500) && !defined(LCD_USE_DMA)) || \ 18 - defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI)) && \ 18 + defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(SONY_NWZ_LINUX)) && \ 19 19 !defined(SIMULATOR) 20 20 #if LCD_DEPTH == 24 21 21 lcd-as-memframe-24bit.c
+385
firmware/drivers/audio/nwzlinux-codec.c
··· 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 + #include "logf.h" 22 + #include "system.h" 23 + #include "kernel.h" 24 + #include "string.h" 25 + #include "stdio.h" 26 + #include "audio.h" 27 + #include "sound.h" 28 + #include "audiohw.h" 29 + #include "cscodec.h" 30 + #include "nwzlinux_codec.h" 31 + #include "stdlib.h" 32 + #include "panic.h" 33 + #include <sys/ioctl.h> 34 + #include "nwz_audio.h" 35 + #include "pcm-alsa.h" 36 + #include "alsa-controls.h" 37 + 38 + /* This driver handle the Sony linux audio drivers: despite using many differents 39 + * codecs, it appears that they all share a common interface and common controls. */ 40 + 41 + /* This is the alsa mixer interface exposed by Sony: 42 + numid=3,iface=MIXER,name='Capture Src Switch' 43 + ; type=ENUMERATED,access=rw------,values=1,items=4 44 + ; Item #0 'None' 45 + ; Item #1 'Line' 46 + ; Item #2 'Fm' 47 + ; Item #3 'Mic' 48 + : values=0 49 + numid=2,iface=MIXER,name='Playback Src Switch' 50 + ; type=ENUMERATED,access=rw------,values=1,items=7 51 + ; Item #0 'None' 52 + ; Item #1 'Music' 53 + ; Item #2 'Video' 54 + ; Item #3 'Tv' 55 + ; Item #4 'Fm' 56 + ; Item #5 'Line' 57 + ; Item #6 'Mic' 58 + : values=1 59 + numid=1,iface=MIXER,name='Playback Volume' 60 + ; type=INTEGER,access=rw------,values=2,min=0,max=100,step=1 61 + : values=5,5 62 + numid=7,iface=MIXER,name='CODEC Acoustic Switch' 63 + ; type=BOOLEAN,access=rw------,values=1 64 + : values=on 65 + numid=8,iface=MIXER,name='CODEC Cue/Rev Switch' 66 + ; type=BOOLEAN,access=rw------,values=1 67 + : values=off 68 + numid=9,iface=MIXER,name='CODEC Fade In Switch' 69 + ; type=BOOLEAN,access=rw------,values=1 70 + : values=off 71 + numid=6,iface=MIXER,name='CODEC Mute Switch' 72 + ; type=BOOLEAN,access=rw------,values=1 73 + : values=off 74 + numid=5,iface=MIXER,name='CODEC Power Switch' 75 + ; type=BOOLEAN,access=rw------,values=1 76 + : values=on 77 + numid=10,iface=MIXER,name='CODEC Stanby Switch' 78 + ; type=BOOLEAN,access=rw------,values=1 79 + : values=off 80 + numid=4,iface=MIXER,name='Output Switch' 81 + ; type=ENUMERATED,access=rw------,values=1,items=4 82 + ; Item #0 'Headphone' 83 + ; Item #1 'LineVariable' 84 + ; Item #2 'LineFixed' 85 + ; Item #3 'Speaker' 86 + : values=0 87 + */ 88 + 89 + /* List of various codecs used by Sony */ 90 + enum nwz_codec_t 91 + { 92 + NWZ_CS42L56, 93 + NWZ_R2A15602LG_D, 94 + NWZ_CS47L01_A, 95 + NWZ_CS47L01_D, 96 + NWZ_CXD3774GF_D, 97 + NWZ_UNK_CODEC, 98 + }; 99 + 100 + #define NWZ_LEVEL_MUTE -1000 101 + /* Description of the volume curve implemented by the kernel driver */ 102 + struct nwz_vol_curve_t 103 + { 104 + int count; /* number of levels */ 105 + int level[]; /* levels in tenth-dB, level[0] is always mute */ 106 + }; 107 + 108 + /* file descriptor of the icx_noican device */ 109 + static int fd_noican; 110 + /* file descriptor of the hardware sound device */ 111 + static int fd_hw; 112 + /* Codec */ 113 + static enum nwz_codec_t nwz_codec; 114 + 115 + static enum nwz_codec_t find_codec(void) 116 + { 117 + if(nwz_is_kernel_module_loaded("cs42L56_d")) 118 + return NWZ_CS42L56; 119 + if(nwz_is_kernel_module_loaded("r2A15602LG_d")) 120 + return NWZ_R2A15602LG_D; 121 + if(nwz_is_kernel_module_loaded("cs47L01_d")) 122 + return NWZ_CS47L01_D; 123 + if(nwz_is_kernel_module_loaded("cs47L01_a")) 124 + return NWZ_CS47L01_A; 125 + if(nwz_is_kernel_module_loaded("cxd3774gf_d")) 126 + return NWZ_CXD3774GF_D; 127 + return NWZ_UNK_CODEC; 128 + } 129 + 130 + const char *nwz_get_codec_name(void) 131 + { 132 + switch(nwz_codec) 133 + { 134 + case NWZ_CS42L56: return "cs42L56_d"; 135 + case NWZ_R2A15602LG_D: return "r2A15602LG_d"; 136 + case NWZ_CS47L01_D: return "cs47L01_d"; 137 + case NWZ_CS47L01_A: return "cs47L01_a"; 138 + case NWZ_CXD3774GF_D: return "cxd3774gf_d"; 139 + default: return "Unknown"; 140 + } 141 + } 142 + 143 + static struct nwz_vol_curve_t cxd3774gf_vol_curve = 144 + { 145 + .count = 31, 146 + /* Most Sonys seem to follow the convention of 3dB/step then 2dB/step then 1dB/step */ 147 + .level = {NWZ_LEVEL_MUTE, 148 + -550, -520, -490, -460, -430, -400, -370, -340, -310, -280, -250, /* 3dB/step */ 149 + -230, -210, -190, -170, -150, -130, -110, -90, /* 2dB/step */ 150 + -80, -70, -60, -50, -40, -30, -20, -10, 0, /* 1dB/step */ 151 + 15, 35, /* 1.5dB then 2dB */ 152 + } 153 + }; 154 + 155 + struct nwz_vol_curve_t *nwz_get_codec_vol_curve(void) 156 + { 157 + switch(nwz_codec) 158 + { 159 + case NWZ_CS47L01_A: 160 + case NWZ_CS47L01_D: 161 + /* there are 32 levels but the last two are the same so in fact it 162 + * is the same curve as the cxd3774gf_d */ 163 + case NWZ_CXD3774GF_D: 164 + return &cxd3774gf_vol_curve; 165 + default: 166 + /* return the safest curve (only 31 levels) */ 167 + return &cxd3774gf_vol_curve; 168 + } 169 + } 170 + 171 + static void noican_init(void) 172 + { 173 + fd_noican = open(NWZ_NC_DEV, O_RDWR); 174 + /* some targets don't have noise cancelling so silently fail */ 175 + } 176 + 177 + static void noican_close(void) 178 + { 179 + if(fd_noican >= 0) 180 + close(fd_noican); 181 + } 182 + 183 + /* Set NC switch */ 184 + static void noican_set_switch(int sw) 185 + { 186 + if(ioctl(fd_noican, NWZ_NC_SET_SWITCH, &sw) < 0) 187 + panicf("ioctl(NWZ_NC_SET_SWITCH) failed"); 188 + } 189 + 190 + /* Get NC switch */ 191 + static int noican_get_switch(void) 192 + { 193 + int val; 194 + if(ioctl(fd_noican, NWZ_NC_GET_SWITCH, &val) < 0) 195 + panicf("ioctl(NWZ_NC_GET_SWITCH) failed"); 196 + return val; 197 + } 198 + 199 + /* Get HP status */ 200 + static int noican_get_hp_status(void) 201 + { 202 + int val; 203 + if(ioctl(fd_noican, NWZ_NC_GET_HP_STATUS, &val) < 0) 204 + panicf("ioctl(NWZ_NC_GET_HP_STATUS) failed"); 205 + return val; 206 + } 207 + 208 + /* Set HP type */ 209 + static void noican_set_hp_type(int type) 210 + { 211 + if(ioctl(fd_noican, NWZ_NC_SET_HP_TYPE, &type) < 0) 212 + panicf("ioctl(NWZ_NC_SET_HP_TYPE) failed"); 213 + } 214 + 215 + /* Get HP type */ 216 + static int noican_get_hp_type(void) 217 + { 218 + int val; 219 + if(ioctl(fd_noican, NWZ_NC_GET_HP_TYPE, &val) < 0) 220 + panicf("ioctl(NWZ_NC_GET_HP_TYPE) failed"); 221 + return val; 222 + } 223 + 224 + 225 + /* Set gain */ 226 + static void noican_set_gain(int gain) 227 + { 228 + if(ioctl(fd_noican, NWZ_NC_SET_GAIN, &gain) < 0) 229 + panicf("ioctl(NWZ_NC_SET_GAIN) failed"); 230 + } 231 + 232 + /* Get gain */ 233 + static int noican_get_gain(void) 234 + { 235 + int val; 236 + if(ioctl(fd_noican, NWZ_NC_GET_GAIN, &val) < 0) 237 + panicf("ioctl(NWZ_NC_GET_GAIN) failed"); 238 + return val; 239 + } 240 + 241 + /* Set filter */ 242 + static void noican_set_filter(int filter) 243 + { 244 + if(ioctl(fd_noican, NWZ_NC_SET_FILTER, &filter) < 0) 245 + panicf("ioctl(NWZ_NC_SET_FILTER) failed"); 246 + } 247 + 248 + /* Get filter */ 249 + static int noican_get_filter(void) 250 + { 251 + int val; 252 + if(ioctl(fd_noican, NWZ_NC_GET_FILTER, &val) < 0) 253 + panicf("ioctl(NWZ_NC_GET_FILTER) failed"); 254 + return val; 255 + } 256 + 257 + static void hw_open(void) 258 + { 259 + fd_hw = open("/dev/snd/hwC0D0", O_RDWR); 260 + if(fd_hw < 0) 261 + panicf("Cannot open '/dev/snd/hwC0D0'"); 262 + } 263 + 264 + static void hw_close(void) 265 + { 266 + close(fd_hw); 267 + } 268 + 269 + void audiohw_preinit(void) 270 + { 271 + alsa_controls_init(); 272 + /* turn on codec */ 273 + alsa_controls_set_bool("CODEC Power Switch", true); 274 + /* mute */ 275 + alsa_controls_set_bool("CODEC Mute Switch", true); 276 + /* Acoustic and Cue/Rev control how the volume curve, but it is not clear 277 + * what the intention of these modes are and the OF does not seem to use 278 + * them by default */ 279 + alsa_controls_set_bool("CODEC Acoustic Switch", false); 280 + alsa_controls_set_bool("CODEC Cue/Rev Switch", false); 281 + /* not sure exactly what it means */ 282 + alsa_controls_set_enum("Playback Src Switch", "Music"); 283 + /* use headphone output */ 284 + alsa_controls_set_enum("Output Switch", "Headphone"); 285 + /* unmute */ 286 + alsa_controls_set_bool("CODEC Mute Switch", false); 287 + 288 + /* init noican */ 289 + noican_init(); 290 + if(fd_noican >= 0) 291 + { 292 + /* dump configuration, for debug purposes */ 293 + printf("nc hp status: %d\n", noican_get_hp_status()); 294 + printf("nc type: %d\n", noican_get_hp_type()); 295 + printf("nc switch: %d\n", noican_get_switch()); 296 + printf("nc gain: %d\n", noican_get_gain()); 297 + printf("nc filter: %d\n", noican_get_filter()); 298 + /* make sure we start in a clean state */ 299 + noican_set_switch(NWZ_NC_SWITCH_OFF); 300 + noican_set_hp_type(NC_HP_TYPE_DEFAULT); 301 + noican_set_filter(NWZ_NC_FILTER_INDEX_0); 302 + noican_set_gain(NWZ_NC_GAIN_CENTER); 303 + } 304 + 305 + /* init hw */ 306 + hw_open(); 307 + nwz_codec = find_codec(); 308 + printf("Codec: %s\n", nwz_get_codec_name()); 309 + } 310 + 311 + void audiohw_postinit(void) 312 + { 313 + } 314 + 315 + /* volume must be driver unit */ 316 + static void nwz_set_driver_vol(int vol) 317 + { 318 + long vols[2]; 319 + /* the driver expects percent, convert from centibel in range 0...x */ 320 + vols[0] = vols[1] = vol; 321 + /* on some recent players like A10, Sony decided to merge left/right volume 322 + * into one, thus we need to make sure we write the correct number of values */ 323 + int vol_cnt; 324 + alsa_controls_get_info("Playback Volume", &vol_cnt); 325 + alsa_controls_set_ints("Playback Volume", vol_cnt, vols); 326 + } 327 + 328 + /* volume is in tenth-dB */ 329 + void audiohw_set_volume(int vol_l, int vol_r) 330 + { 331 + /* FIXME at the moment we don't support balance and just average left and right. 332 + * But this could be implemented using pcm alsa digital volume */ 333 + 334 + /* the Sony drivers expect vol_l = vol_r */ 335 + int vol = (vol_l + vol_r) / 2; 336 + printf("request volume %d dB\n", vol / 10); 337 + struct nwz_vol_curve_t *curve = nwz_get_codec_vol_curve(); 338 + /* min/max for pcm volume */ 339 + int min_pcm = -430; 340 + int max_pcm = 0; 341 + /* On some codecs (like cs47L01), Sony clear overdrives the DAC which produces 342 + * massive clipping at any level (since they fix the DAC volume at around +6dB 343 + * and then adjust HP volume in negative at the top of range !!). The only 344 + * solution around this problem is to use the digital volume first so that 345 + * very quickly the digital volume compensate for the DAC overdrive and we 346 + * avoid clipping. */ 347 + int sony_clip_level = -80; /* any volume above this will cause massive clipping the DAC */ 348 + 349 + /* to avoid the clipping problem, virtually decrease requested volume by the 350 + * clipping threshold, so that we will compensate in digital later by 351 + * at least this amount if possibly */ 352 + vol -= sony_clip_level; 353 + 354 + int drv_vol = curve->count - 1; 355 + /* pick driver level just above request volume */ 356 + while(drv_vol > 0 && curve->level[drv_vol - 1] >= vol) 357 + drv_vol--; 358 + /* now remove the artifical volume change */ 359 + vol += sony_clip_level; 360 + /* now adjust digital volume */ 361 + vol -= curve->level[drv_vol]; 362 + if(vol < min_pcm) 363 + { 364 + vol = min_pcm; /* digital cannot do <43dB */ 365 + drv_vol = 0; /* mute */ 366 + } 367 + else if(vol > max_pcm) 368 + vol = max_pcm; /* digital cannot do >0dB */ 369 + printf(" set driver volume %d (%d dB)\n", drv_vol, curve->level[drv_vol] / 10); 370 + nwz_set_driver_vol(drv_vol); 371 + printf(" set digital volume %d dB\n", vol / 10); 372 + pcm_alsa_set_digital_volume(vol / 10); 373 + } 374 + 375 + void audiohw_close(void) 376 + { 377 + hw_close(); 378 + alsa_controls_close(); 379 + noican_close(); 380 + } 381 + 382 + void audiohw_set_frequency(int fsel) 383 + { 384 + (void) fsel; 385 + }
+2
firmware/export/audiohw.h
··· 207 207 #include "df1704.h" 208 208 #elif defined(HAVE_PCM1792_CODEC) 209 209 #include "pcm1792.h" 210 + #elif defined(HAVE_NWZ_LINUX_CODEC) 211 + #include "nwzlinux_codec.h" 210 212 #elif (CONFIG_PLATFORM & (PLATFORM_ANDROID | PLATFORM_MAEMO\ 211 213 | PLATFORM_PANDORA | PLATFORM_SDL)) 212 214 #include "hosted_codec.h"
+36
firmware/export/backtrace.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2017 by 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 __ROCKBOX_BACKTRACE_H__ 22 + #define __ROCKBOX_BACKTRACE_H__ 23 + 24 + #include "config.h" 25 + #ifdef BACKTRACE_UNWARMINDER 26 + #include "backtrace-unwarminder.h" 27 + #endif 28 + 29 + /* Print a backtrace using lcd_* functions, starting at the given line and updating 30 + * the line number. On targets that support it (typically native targets), the 31 + * backtrace will start at the given value of PC and using the stack frame given 32 + * by PC. On hosted targets, it will typically ignore those values and backtrace 33 + * from the caller */ 34 + void rb_backtrace(int pcAddr, int spAddr, unsigned *line); 35 + 36 + #endif /* __ROCKBOX_BACKTRACE_H__ */
+11
firmware/export/config.h
··· 277 277 #define LCD_IHIFI 60 /* as used by IHIFI 760/960 */ 278 278 #define LCD_CREATIVEZENXFISTYLE 61 /* as used by Creative Zen X-Fi Style */ 279 279 #define LCD_SAMSUNGYPR1 62 /* as used by Samsung YP-R1 */ 280 + #define LCD_NWZ_LINUX 63 /* as used in the Linux-based NWZ series */ 280 281 281 282 /* LCD_PIXELFORMAT */ 282 283 #define HORIZONTAL_PACKING 1 ··· 581 582 #include "config/ibassodx50.h" 582 583 #elif defined(DX90) 583 584 #include "config/ibassodx90.h" 585 + #elif defined(SONY_NWZE460) 586 + #include "config/sonynwze460.h" 587 + #elif defined(SONY_NWZE450) 588 + #include "config/sonynwze450.h" 589 + #elif defined(SONY_NWZE580) 590 + #include "config/sonynwze580.h" 591 + #elif defined(SONY_NWZA10) 592 + #include "config/sonynwza10.h" 593 + #elif defined(SONY_NWZE470) 594 + #include "config/sonynwze470.h" 584 595 #else 585 596 /* no known platform */ 586 597 #endif
+16
firmware/export/config/sonynwza10.h
··· 1 + /* 2 + * This config file is for the Sony NW-A10 series 3 + */ 4 + 5 + /* For Rolo and boot loader */ 6 + #define MODEL_NUMBER 104 7 + 8 + #define MODEL_NAME "Sony NWZ-A10 Series" 9 + 10 + /* LCD dimensions */ 11 + #define LCD_WIDTH 240 12 + #define LCD_HEIGHT 320 13 + /* sqrt(240^2 + 320^2) / 2 = 200 */ 14 + #define LCD_DPI 200 15 + 16 + #include "sonynwzlinux.h"
+16
firmware/export/config/sonynwze450.h
··· 1 + /* 2 + * This config file is for the Sony NWZ-E450 series 3 + */ 4 + 5 + /* For Rolo and boot loader */ 6 + #define MODEL_NUMBER 100 7 + 8 + #define MODEL_NAME "Sony NWZ-E450 Series" 9 + 10 + /* LCD dimensions */ 11 + #define LCD_WIDTH 240 12 + #define LCD_HEIGHT 320 13 + /* sqrt(240^2 + 320^2) / 2 = 200 */ 14 + #define LCD_DPI 200 15 + 16 + #include "sonynwzlinux.h"
+16
firmware/export/config/sonynwze460.h
··· 1 + /* 2 + * This config file is for the Sony NWZ-E460 series 3 + */ 4 + 5 + /* For Rolo and boot loader */ 6 + #define MODEL_NUMBER 101 7 + 8 + #define MODEL_NAME "Sony NWZ-E460 Series" 9 + 10 + /* LCD dimensions */ 11 + #define LCD_WIDTH 240 12 + #define LCD_HEIGHT 320 13 + /* sqrt(240^2 + 320^2) / 2 = 200 */ 14 + #define LCD_DPI 200 15 + 16 + #include "sonynwzlinux.h"
+16
firmware/export/config/sonynwze470.h
··· 1 + /* 2 + * This config file is for the Sony NWZ-E470 series 3 + */ 4 + 5 + /* For Rolo and boot loader */ 6 + #define MODEL_NUMBER 103 7 + 8 + #define MODEL_NAME "Sony NWZ-E470 Series" 9 + 10 + /* LCD dimensions */ 11 + #define LCD_WIDTH 240 12 + #define LCD_HEIGHT 320 13 + /* sqrt(240^2 + 320^2) / 2 = 200 */ 14 + #define LCD_DPI 200 15 + 16 + #include "sonynwzlinux.h"
+16
firmware/export/config/sonynwze580.h
··· 1 + /* 2 + * This config file is for the Sony NWZ-E580 series 3 + */ 4 + 5 + /* For Rolo and boot loader */ 6 + #define MODEL_NUMBER 102 7 + 8 + #define MODEL_NAME "Sony NWZ-E580 Series" 9 + 10 + /* LCD dimensions */ 11 + #define LCD_WIDTH 240 12 + #define LCD_HEIGHT 320 13 + /* sqrt(240^2 + 320^2) / 2 = 200 */ 14 + #define LCD_DPI 200 15 + 16 + #include "sonynwzlinux.h"
+105
firmware/export/config/sonynwzlinux.h
··· 1 + /* 2 + * This config file is for the Sony NWZ Linux based targets 3 + */ 4 + 5 + #define CONFIG_PLATFORM (PLATFORM_HOSTED) 6 + 7 + /* define this if you have a bitmap LCD display */ 8 + #define HAVE_LCD_BITMAP 9 + 10 + /* define this if you have a colour LCD */ 11 + #define HAVE_LCD_COLOR 12 + 13 + /* Define this if the LCD can shut down */ 14 + #define HAVE_LCD_SHUTDOWN 15 + 16 + /* define this if you want album art for this target */ 17 + #define HAVE_ALBUMART 18 + 19 + /* define this to enable bitmap scaling */ 20 + #define HAVE_BMP_SCALING 21 + 22 + /* define this to enable JPEG decoding */ 23 + #define HAVE_JPEG 24 + 25 + /* define this if you have access to the quickscreen */ 26 + #define HAVE_QUICKSCREEN 27 + 28 + /* define this if you would like tagcache to build on this target */ 29 + #define HAVE_TAGCACHE 30 + 31 + /* define this if the target has volume keys which can be used in the lists */ 32 + #define HAVE_VOLUME_IN_LIST 33 + 34 + #define LCD_DEPTH 16 35 + /* Check that but should not matter */ 36 + #define LCD_PIXELFORMAT RGB565 37 + 38 + #define HAVE_BACKLIGHT 39 + #define HAVE_BACKLIGHT_BRIGHTNESS 40 + 41 + /* Main LCD backlight brightness range and defaults: the backlight driver only 42 + * has levels from 0 to 5. But 0 is off so start at 1. The driver has configurable 43 + * periods for fade in/out but we can't easily export that to Rockbox */ 44 + #define MIN_BRIGHTNESS_SETTING 1 45 + #define MAX_BRIGHTNESS_SETTING 5 46 + #define DEFAULT_BRIGHTNESS_SETTING 4 47 + 48 + /* Which backlight fading type? */ 49 + #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING 50 + 51 + /* define this if you have a real-time clock */ 52 + #define CONFIG_RTC 0 53 + 54 + /* The number of bytes reserved for loadable codecs */ 55 + #define CODEC_SIZE 0x80000 56 + 57 + /* The number of bytes reserved for loadable plugins */ 58 + #define PLUGIN_BUFFER_SIZE 0x100000 59 + 60 + /* Define this if you do software codec */ 61 + #define CONFIG_CODEC SWCODEC 62 + 63 + /* KeyPad configuration for plugins */ 64 + #define CONFIG_KEYPAD SONY_NWZ_PAD 65 + #define HAS_BUTTON_HOLD 66 + 67 + /* We have usb power and can detect usb but it is handled by Linux */ 68 + #define HAVE_USB_POWER 69 + #define USB_NONE 70 + 71 + #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE 72 + 73 + /* Linux controlls charging, we can monitor */ 74 + #define CONFIG_CHARGING CHARGING_MONITOR 75 + 76 + /* define this if the hardware can be powered off while charging */ 77 + #define HAVE_POWEROFF_WHILE_CHARGING 78 + 79 + /* same dimensions as gigabeats */ 80 + #define CONFIG_LCD LCD_NWZ_LINUX 81 + 82 + /* Define this if you have a software controlled poweroff */ 83 + #define HAVE_SW_POWEROFF 84 + 85 + /* Define this to the CPU frequency */ 86 + #define CPU_FREQ 532000000 87 + 88 + /* No special storage */ 89 + #define CONFIG_STORAGE STORAGE_HOSTFS 90 + #define HAVE_STORAGE_FLUSH 91 + 92 + /* Battery */ 93 + #define BATTERY_TYPES_COUNT 1 94 + 95 + /* Audio codec */ 96 + #define HAVE_NWZ_LINUX_CODEC 97 + 98 + /* special define to be use in various places */ 99 + #define SONY_NWZ_LINUX 100 + 101 + /* Battery */ 102 + #define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */ 103 + #define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */ 104 + #define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */ 105 + #define BATTERY_CAPACITY_INC 0 /* capacity increment */
+29
firmware/export/nwzlinux_codec.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * 9 + * Copyright (C) 2016 by 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 __NWZLINUX_CODEC_H__ 22 + #define __NWZLINUX_CODEC_H__ 23 + 24 + #define AUDIOHW_CAPS 0 25 + 26 + /* Ranges from -100dB to 4dB */ 27 + AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -100, 4, -10) 28 + 29 + #endif /* __NWZLINUX_CODEC_H__ */
+6 -2
firmware/export/rbpaths.h
··· 40 40 #define ROCKBOX_DIR_LEN (sizeof(ROCKBOX_DIR)-1) 41 41 #endif /* def __PCTOOL__ */ 42 42 43 - #if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90) 43 + #if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \ 44 + defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) 44 45 45 46 #if defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) 46 47 #define HOME_DIR "/mnt/media0" 48 + #elif defined(SONY_NWZ_LINUX) 49 + #define HOME_DIR "/contents" 47 50 #elif defined(DX50) || defined(DX90) 48 51 /* Where to put save files like recordings, playlists, screen dumps ...*/ 49 52 #define HOME_DIR "/mnt/sdcard" ··· 83 86 #define PLUGIN_DEMOS_DIR PLUGIN_DIR "/demos" 84 87 #define VIEWERS_DIR PLUGIN_DIR "/viewers" 85 88 86 - #if defined(APPLICATION) && !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90)) 89 + #if defined(APPLICATION) && !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \ 90 + defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX)) 87 91 #define PLUGIN_DATA_DIR ROCKBOX_DIR "/rocks.data" 88 92 #define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR 89 93 #define PLUGIN_APPS_DATA_DIR PLUGIN_DATA_DIR
+1 -1
firmware/export/system.h
··· 336 336 #ifndef SIMULATOR 337 337 bool dbg_ports(void); 338 338 #endif 339 - #if (CONFIG_PLATFORM & PLATFORM_NATIVE) 339 + #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SONY_NWZ_LINUX) 340 340 bool dbg_hw_info(void); 341 341 #endif 342 342
+1 -1
firmware/font.c
··· 85 85 /* compiled-in font */ 86 86 extern struct font sysfont; 87 87 88 - #ifndef BOOTLOADER 88 + #if !defined(BOOTLOADER) || defined(SONY_NWZ_LINUX) 89 89 90 90 struct buflib_alloc_data { 91 91 struct font font; /* must be the first member! */
+1 -1
firmware/panic.c
··· 115 115 } 116 116 117 117 #if defined(CPU_ARM) 118 - backtrace(pc, sp, &y); 118 + rb_backtrace(pc, sp, &y); 119 119 #endif 120 120 #ifdef ROCKBOX_HAS_LOGF 121 121 logf_panic_dump(&y);
+1 -1
firmware/target/arm/system-arm.c
··· 148 148 if (!triggered) 149 149 { 150 150 triggered = true; 151 - backtrace(pc, __get_sp(), &line); 151 + rb_backtrace(pc, __get_sp(), &line); 152 152 } 153 153 154 154 lcd_update();
+181
firmware/target/hosted/alsa-controls.c
··· 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 + #include "alsa-controls.h" 21 + #include "panic.h" 22 + #include <stdlib.h> 23 + 24 + /* alsa control handle, we keep it open at all times */ 25 + static snd_ctl_t *alsa_ctl; 26 + /* list of all controls, we allocate and fill it once, so we can easily lookup */ 27 + static snd_ctl_elem_list_t *alsa_ctl_list; 28 + 29 + void alsa_controls_init(void) 30 + { 31 + snd_ctl_elem_info_t *info; 32 + /* allocate list on heap because it is used it is used in other functions */ 33 + snd_ctl_elem_list_malloc(&alsa_ctl_list); 34 + /* allocate info on stack so there is no need to free them */ 35 + snd_ctl_elem_info_alloca(&info); 36 + /* there is only one card and "default" always works */ 37 + if(snd_ctl_open(&alsa_ctl, "default", 0) < 0) 38 + panicf("Cannot open ctl\n"); 39 + /* ALSA is braindead: first "get" the list -> only retrieve count */ 40 + if(snd_ctl_elem_list(alsa_ctl, alsa_ctl_list) < 0) 41 + panicf("Cannot get element list\n"); 42 + /* now we can allocate the list since the know the size */ 43 + int count = snd_ctl_elem_list_get_count(alsa_ctl_list); 44 + if(snd_ctl_elem_list_alloc_space(alsa_ctl_list, count) < 0) 45 + panicf("Cannot allocate space for element list\n"); 46 + /* ... and get the list again! */ 47 + if(snd_ctl_elem_list(alsa_ctl, alsa_ctl_list) < 0) 48 + panicf("Cannot get element list\n"); 49 + } 50 + 51 + void alsa_controls_close(void) 52 + { 53 + snd_ctl_close(alsa_ctl); 54 + } 55 + 56 + /* find a control element ID by name, return false of not found, the id needs 57 + * to be allocated */ 58 + bool alsa_controls_find(snd_ctl_elem_id_t *id, const char *name) 59 + { 60 + /* ALSA identifies controls by "id"s, it almost makes sense, except ids 61 + * are a horrible opaque structure */ 62 + int count = snd_ctl_elem_list_get_count(alsa_ctl_list); 63 + /* enumerate controls */ 64 + for(int i = 0; i < count; i++) 65 + { 66 + snd_ctl_elem_list_get_id(alsa_ctl_list, i, id); 67 + 68 + if(strcmp(snd_ctl_elem_id_get_name(id), name) == 0) 69 + return true; 70 + } 71 + /* not found */ 72 + return false; 73 + } 74 + 75 + /* find a control element enum index by name, return -1 if not found */ 76 + int alsa_controls_find_enum(const char *name, const char *enum_name) 77 + { 78 + snd_ctl_elem_id_t *id; 79 + snd_ctl_elem_info_t *info; 80 + /* allocate things on stack to speedup */ 81 + snd_ctl_elem_id_alloca(&id); 82 + snd_ctl_elem_info_alloca(&info); 83 + /* find control */ 84 + if(!alsa_controls_find(id, name)) 85 + panicf("Cannot find control '%s'", name); 86 + snd_ctl_elem_info_set_id(info, id); 87 + if(snd_ctl_elem_info(alsa_ctl, info) < 0) 88 + panicf("Cannot get control '%s' info", name); 89 + /* list items */ 90 + unsigned count = snd_ctl_elem_info_get_items(info); 91 + for(unsigned i = 0; i < count; i++) 92 + { 93 + snd_ctl_elem_info_set_item(info, i); 94 + if(snd_ctl_elem_info(alsa_ctl, info) < 0) 95 + panicf("Cannot get control '%s' info for item %u", name, i); 96 + if(strcmp(snd_ctl_elem_info_get_item_name(info), enum_name) == 0) 97 + return i; 98 + } 99 + return -1; 100 + } 101 + 102 + /* set a control, potentially supports several values */ 103 + void alsa_controls_set(const char *name, snd_ctl_elem_type_t type, 104 + unsigned nr_values, long *val) 105 + { 106 + snd_ctl_elem_id_t *id; 107 + snd_ctl_elem_info_t *info; 108 + snd_ctl_elem_value_t *value; 109 + /* allocate things on stack to speedup */ 110 + snd_ctl_elem_id_alloca(&id); 111 + snd_ctl_elem_info_alloca(&info); 112 + snd_ctl_elem_value_alloca(&value); 113 + /* find control */ 114 + if(!alsa_controls_find(id, name)) 115 + panicf("Cannot find control '%s'", name); 116 + /* check the type of the control */ 117 + snd_ctl_elem_info_set_id(info, id); 118 + if(snd_ctl_elem_info(alsa_ctl, info) < 0) 119 + panicf("Cannot get control '%s' info", name); 120 + if(snd_ctl_elem_info_get_type(info) != type) 121 + panicf("Control '%s' has wrong type (got %d, expected %d", name, 122 + snd_ctl_elem_info_get_type(info), type); 123 + if(snd_ctl_elem_info_get_count(info) != nr_values) 124 + panicf("Control '%s' has wrong count (got %u, expected %u)", 125 + name, snd_ctl_elem_info_get_count(info), nr_values); 126 + /* set value */ 127 + snd_ctl_elem_value_set_id(value, id); 128 + for(unsigned i = 0; i < nr_values; i++) 129 + { 130 + /* ALSA is braindead: there are "typed" setters but they all take long anyway */ 131 + if(type == SND_CTL_ELEM_TYPE_BOOLEAN) 132 + snd_ctl_elem_value_set_boolean(value, i, val[i]); 133 + else if(type == SND_CTL_ELEM_TYPE_INTEGER) 134 + snd_ctl_elem_value_set_integer(value, i, val[i]); 135 + else if(type == SND_CTL_ELEM_TYPE_ENUMERATED) 136 + snd_ctl_elem_value_set_enumerated(value, i, val[i]); 137 + } 138 + /* write value */ 139 + if(snd_ctl_elem_write(alsa_ctl, value) < 0) 140 + panicf("Cannot write control '%s'", name); 141 + } 142 + 143 + /* get control information */ 144 + void alsa_controls_get_info(const char *name, int *out_count) 145 + { 146 + snd_ctl_elem_id_t *id; 147 + snd_ctl_elem_info_t *info; 148 + /* allocate things on stack to speedup */ 149 + snd_ctl_elem_id_alloca(&id); 150 + snd_ctl_elem_info_alloca(&info); 151 + /* find control */ 152 + if(!alsa_controls_find(id, name)) 153 + panicf("Cannot find control '%s'", name); 154 + /* get info */ 155 + snd_ctl_elem_info_set_id(info, id); 156 + if(snd_ctl_elem_info(alsa_ctl, info) < 0) 157 + panicf("Cannot get control '%s' info", name); 158 + *out_count = snd_ctl_elem_info_get_count(info); 159 + } 160 + 161 + /* helper function: set a control with a single boolean value */ 162 + void alsa_controls_set_bool(const char *name, bool val) 163 + { 164 + long lval = val; 165 + alsa_controls_set(name, SND_CTL_ELEM_TYPE_BOOLEAN, 1, &lval); 166 + } 167 + 168 + /* helper function: set a control with a single enum value */ 169 + void alsa_controls_set_enum(const char *name, const char *enum_name) 170 + { 171 + long idx = alsa_controls_find_enum(name, enum_name); 172 + if(idx < 0) 173 + panicf("Cannot find enum '%s' for control '%s'", enum_name, name); 174 + alsa_controls_set(name, SND_CTL_ELEM_TYPE_ENUMERATED, 1, &idx); 175 + } 176 + 177 + /* helper function: set a control with one or more integers */ 178 + void alsa_controls_set_ints(const char *name, int count, long *val) 179 + { 180 + return alsa_controls_set(name, SND_CTL_ELEM_TYPE_INTEGER, count, val); 181 + }
+51
firmware/target/hosted/alsa-controls.h
··· 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 + #ifndef __ALSA_CONTROLS_RB_H__ 21 + #define __ALSA_CONTROLS_RB_H__ 22 + 23 + #include <config.h> 24 + #include <stddef.h> 25 + #include <stdbool.h> 26 + #include <alsa/asoundlib.h> 27 + #include <alloca.h> 28 + 29 + /* open alsa control interface and list all controls, keep control open */ 30 + void alsa_controls_init(void); 31 + /* close alsa controls */ 32 + void alsa_controls_close(void); 33 + 34 + /* find a control element ID by name, return false of not found, the id needs 35 + * to be allocated */ 36 + bool alsa_controls_find(snd_ctl_elem_id_t *id, const char *name); 37 + /* find a control element enum index by name, return -1 if not found */ 38 + int alsa_controls_find_enum(const char *name, const char *enum_name); 39 + /* set a control, potentially supports several values */ 40 + void alsa_controls_set(const char *name, snd_ctl_elem_type_t type, 41 + unsigned nr_values, long *val); 42 + /* get control information: number of values */ 43 + void alsa_controls_get_info(const char *name, int *out_count); 44 + /* helper function: set a control with a single boolean value */ 45 + void alsa_controls_set_bool(const char *name, bool val); 46 + /* helper function: set a control with a single enum value */ 47 + void alsa_controls_set_enum(const char *name, const char *enum_name); 48 + /* helper function: set a control with one or more integers */ 49 + void alsa_controls_set_ints(const char *name, int count, long *val); 50 + 51 + #endif /* __ALSA_CONTROLS_RB_H__ */
+60
firmware/target/hosted/backtrace-glibc.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (c) 2017 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 + #include "config.h" 22 + #include "system.h" 23 + #include "lcd.h" 24 + #include <execinfo.h> 25 + #include <stdio.h> 26 + #include <stdlib.h> 27 + #include <unistd.h> 28 + 29 + /* backtrace from the call-site of this function */ 30 + void rb_backtrace(int pc, int sp, unsigned *line) 31 + { 32 + /* ignore SP and PC */ 33 + (void) pc; 34 + (void) sp; 35 + 36 + /* backtrace */ 37 + #define BT_BUF_SIZE 100 38 + void *buffer[BT_BUF_SIZE]; 39 + int count = backtrace(buffer, BT_BUF_SIZE); 40 + /* print symbols to stdout for debug */ 41 + fprintf(stdout, "backtrace:\n"); 42 + fflush(stdout); 43 + backtrace_symbols_fd(buffer, count, STDOUT_FILENO); 44 + /* print on screen */ 45 + char **strings; 46 + strings = backtrace_symbols(buffer, count); 47 + if(strings == NULL) 48 + { 49 + perror("backtrace_symbols"); 50 + return; 51 + } 52 + 53 + for(int i = 0; i < count; i++) 54 + { 55 + lcd_putsf(0, (*line)++, " %s", buffer[i], strings[i]); 56 + lcd_update(); 57 + } 58 + 59 + free(strings); 60 + }
+3 -2
firmware/target/hosted/filesystem-app.c
··· 43 43 && !defined(__PCTOOL__) 44 44 static const char *rbhome; 45 45 #else 46 - /* YPR0, YPR1 */ 46 + /* YPR0, YPR1, NWZ */ 47 47 static const char rbhome[] = HOME_DIR; 48 48 #endif 49 49 50 - #if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90)) && !defined(__PCTOOL__) 50 + #if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ 51 + defined(SONY_NWZ_LINUX) || defined(DX90)) && !defined(__PCTOOL__) 51 52 /* Special dirs are user-accessible (and user-writable) dirs which take priority 52 53 * over the ones where Rockbox is installed to. Classic example would be 53 54 * $HOME/.config/rockbox.org vs /usr/share/rockbox */
+72 -17
firmware/target/hosted/pcm-alsa.c
··· 50 50 #include "system.h" 51 51 #include "debug.h" 52 52 #include "kernel.h" 53 + #include "panic.h" 53 54 54 55 #include "pcm.h" 55 56 #include "pcm-internal.h" 56 57 #include "pcm_mixer.h" 57 58 #include "pcm_sampr.h" 58 59 #include "audiohw.h" 60 + #include "pcm-alsa.h" 59 61 60 62 #include <pthread.h> 61 63 #include <signal.h> ··· 66 68 * with multple applications running */ 67 69 static char device[] = "plughw:0,0"; /* playback device */ 68 70 static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access mode */ 71 + #ifdef SONY_NWZ_LINUX 72 + /* Sony NWZ must use 32-bit per sample */ 73 + static const snd_pcm_format_t format = SND_PCM_FORMAT_S32_LE; /* sample format */ 74 + typedef long sample_t; 75 + #else 69 76 static const snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */ 77 + typedef short sample_t; 78 + #endif 70 79 static const int channels = 2; /* count of channels */ 71 80 static unsigned int rate = 44100; /* stream rate */ 72 81 73 82 static snd_pcm_t *handle; 74 83 static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */ 75 84 static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4; /* ~4k */ 76 - static short *frames; 85 + static sample_t *frames; 77 86 78 87 static const void *pcm_data = 0; 79 88 static size_t pcm_size = 0; ··· 153 162 goto error; 154 163 } 155 164 if (!frames) 156 - frames = malloc(period_size * channels * sizeof(short)); 165 + frames = malloc(period_size * channels * sizeof(sample_t)); 157 166 158 167 /* write the parameters to device */ 159 168 err = snd_pcm_hw_params(handle, params); ··· 212 221 return err; 213 222 } 214 223 224 + #ifdef SONY_NWZ_LINUX 225 + /* Digital volume explanation: 226 + * with very good approximation (<0.1dB) the convertion from dB to multiplicative 227 + * factor, for dB>=0, is 2^(dB/3). We can then notice that if we write dB=3*k+r 228 + * then this is 2^k*2^(r/3) so we only need to look at r=0,1,2. For r=0 this is 229 + * 1, for r=1 we have 2^(1/3)~=1.25 so we approximate by 1+1/4, and 2^(2/3)~=1.5 230 + * so we approximate by 1+1/2. To go from negative to nonnegative we notice that 231 + * 48 dB => 63095 factor ~= 2^16 so we virtually pre-multiply everything by 2^(-16) 232 + * and add 48dB to the input volume. We cannot go lower -43dB because several 233 + * values between -48dB and -43dB would require a fractional multiplier, which is 234 + * stupid to implement for such very low volume. */ 235 + static int dig_vol_mult = 2 ^ 16; /* multiplicative factor to apply to each sample */ 236 + 237 + void pcm_alsa_set_digital_volume(int vol_db) 238 + { 239 + if(vol_db > 0 || vol_db < -43) 240 + panicf("invalid pcm alsa volume"); 241 + if(format != SND_PCM_FORMAT_S32_LE) 242 + panicf("this function assumes 32-bit sample size"); 243 + vol_db += 48; /* -42dB .. 0dB => 5dB .. 48dB */ 244 + /* NOTE if vol_dB = 5 then vol_shift = 1 but r = 1 so we do vol_shift - 1 >= 0 245 + * otherwise vol_dB >= 0 implies vol_shift >= 2 so vol_shift - 2 >= 0 */ 246 + int vol_shift = vol_db / 3; 247 + int r = vol_db % 3; 248 + if(r == 0) 249 + dig_vol_mult = 1 << vol_shift; 250 + else if(r == 1) 251 + dig_vol_mult = 1 << vol_shift | 1 << (vol_shift - 2); 252 + else 253 + dig_vol_mult = 1 << vol_shift | 1 << (vol_shift - 1); 254 + printf("%d dB -> factor = %d\n", vol_db - 48, dig_vol_mult); 255 + } 256 + #endif 257 + 215 258 /* copy pcm samples to a spare buffer, suitable for snd_pcm_writei() */ 216 259 static bool fill_frames(void) 217 260 { ··· 229 272 return false; 230 273 } 231 274 } 232 - copy_n = MIN((ssize_t)pcm_size, frames_left*4); 233 - memcpy(&frames[2*(period_size-frames_left)], pcm_data, copy_n); 234 275 235 - pcm_data += copy_n; 236 - pcm_size -= copy_n; 237 - frames_left -= copy_n/4; 276 + if (pcm_size % 4) 277 + panicf("Wrong pcm_size"); 278 + /* the compiler will optimize this test away */ 279 + copy_n = MIN((ssize_t)pcm_size/4, frames_left); 280 + if (format == SND_PCM_FORMAT_S32_LE) 281 + { 282 + /* We have to convert 16-bit to 32-bit, the need to multiply the 283 + * sample by some value so the sound is not too low */ 284 + const short *pcm_ptr = pcm_data; 285 + sample_t *sample_ptr = &frames[2*(period_size-frames_left)]; 286 + for (int i = 0; i < copy_n*2; i++) 287 + *sample_ptr++ = *pcm_ptr++ * dig_vol_mult; 288 + } 289 + else 290 + { 291 + /* Rockbox and PCM have same format: memcopy */ 292 + memcpy(&frames[2*(period_size-frames_left)], pcm_data, copy_n); 293 + } 294 + pcm_data += copy_n*4; 295 + pcm_size -= copy_n*4; 296 + frames_left -= copy_n; 238 297 239 298 if (new_buffer) 240 299 { ··· 285 344 { 286 345 int err; 287 346 snd_pcm_sframes_t sample_size; 288 - short *samples; 347 + sample_t *samples; 289 348 290 349 #ifdef USE_ASYNC_CALLBACK 291 350 /* assign alternative stack for the signal handlers */ ··· 323 382 324 383 /* fill buffer with silence to initiate playback without noisy click */ 325 384 sample_size = buffer_size; 326 - samples = malloc(sample_size * channels * sizeof(short)); 385 + samples = malloc(sample_size * channels * sizeof(sample_t)); 327 386 328 387 snd_pcm_format_set_silence(format, samples, sample_size); 329 388 err = snd_pcm_writei(handle, samples, sample_size); ··· 367 426 368 427 if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) 369 428 { 370 - printf("%s(): Cannot open device %s: %s\n", __func__, device, snd_strerror(err)); 371 - exit(EXIT_FAILURE); 372 - return; 429 + panicf("%s(): Cannot open device %s: %s\n", __func__, device, snd_strerror(err)); 373 430 } 374 431 375 432 if ((err = snd_pcm_nonblock(handle, 1))) 376 - printf("Could not set non-block mode: %s\n", snd_strerror(err)); 433 + panicf("Could not set non-block mode: %s\n", snd_strerror(err)); 377 434 378 435 if ((err = set_hwparams(handle, rate)) < 0) 379 436 { 380 - printf("Setting of hwparams failed: %s\n", snd_strerror(err)); 381 - exit(EXIT_FAILURE); 437 + panicf("Setting of hwparams failed: %s\n", snd_strerror(err)); 382 438 } 383 439 if ((err = set_swparams(handle)) < 0) 384 440 { 385 - printf("Setting of swparams failed: %s\n", snd_strerror(err)); 386 - exit(EXIT_FAILURE); 441 + panicf("Setting of swparams failed: %s\n", snd_strerror(err)); 387 442 } 388 443 389 444 pcm_dma_apply_settings();
+31
firmware/target/hosted/pcm-alsa.h
··· 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 + #ifndef __PCM_ALSA_RB_H__ 21 + #define __PCM_ALSA_RB_H__ 22 + 23 + #include <config.h> 24 + 25 + #ifdef SONY_NWZ_LINUX 26 + /* Set the PCM volume in dB: each sample with have this volume applied digitally 27 + * before being sent to ALSA. Volume must satisfy -43 <= dB <= 0 */ 28 + void pcm_alsa_set_digital_volume(int vol_db); 29 + #endif 30 + 31 + #endif /* __PCM_ALSA_RB_H__ */
+63
firmware/target/hosted/sonynwz/adc-nwz.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * 9 + * Copyright (C) 2016 by 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 + #include "adc.h" 22 + #include "adc-target.h" 23 + #include <unistd.h> 24 + #include <sys/types.h> 25 + #include <sys/stat.h> 26 + #include <fcntl.h> 27 + #include <sys/ioctl.h> 28 + 29 + static int adc_fd = -1; /* file descriptor */ 30 + 31 + static const char *nwz_adc_channel_name[NWZ_ADC_MAX_CHAN + 1] = 32 + { 33 + [NWZ_ADC_VCCBAT] = "VCCBAT", 34 + [NWZ_ADC_VCCVBUS] = "VCCBUS", 35 + [NWZ_ADC_ADIN3] = "ADIN3", 36 + [NWZ_ADC_ADIN4] = "ADIN4", 37 + [NWZ_ADC_ADIN5] = "ADIN5", 38 + [NWZ_ADC_ADIN6] = "ADIN6", 39 + [NWZ_ADC_ADIN7] = "ADIN7", 40 + [NWZ_ADC_ADIN8] = "ADIN8" 41 + }; 42 + 43 + void adc_init(void) 44 + { 45 + adc_fd = open(NWZ_ADC_DEV, O_RDONLY); 46 + } 47 + 48 + unsigned short adc_read(int channel) 49 + { 50 + unsigned char val; 51 + if(ioctl(adc_fd, NWZ_ADC_GET_VAL(channel), &val) < 0) 52 + return 0; 53 + else 54 + return val; 55 + } 56 + 57 + const char *adc_name(int channel) 58 + { 59 + if(channel < NWZ_ADC_MIN_CHAN || channel > NWZ_ADC_MAX_CHAN) 60 + return ""; 61 + return nwz_adc_channel_name[channel]; 62 + } 63 +
+29
firmware/target/hosted/sonynwz/backlight-target.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by 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 BACKLIGHT_TARGET_H 22 + #define BACKLIGHT_TARGET_H 23 + 24 + bool backlight_hw_init(void); 25 + void backlight_hw_on(void); 26 + void backlight_hw_off(void); 27 + void backlight_hw_brightness(int brightness); 28 + 29 + #endif /* BACKLIGHT_TARGET_H */
+323
firmware/target/hosted/sonynwz/button-nwz.c
··· 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 + #include "button.h" 21 + #define LOGF_ENABLE 22 + #include "logf.h" 23 + #include "panic.h" 24 + #include "backlight.h" 25 + 26 + #include "nwz_keys.h" 27 + #include "nwz_ts.h" 28 + 29 + #include <poll.h> 30 + #include <dir.h> 31 + #include <errno.h> 32 + #include <unistd.h> 33 + #include <sys/types.h> 34 + #include <linux/input.h> 35 + #include <fcntl.h> 36 + #include <string.h> 37 + #include <stdlib.h> 38 + 39 + /* device types */ 40 + #define DEV_KEY 0 /* icx_keys driver */ 41 + #define DEV_TOUCH 1 /* icx_touch_screen driver */ 42 + 43 + /* HOLD status */ 44 + static bool hold_status; 45 + /* button bitmap */ 46 + static int button_bitmap; 47 + /* poll() descriptors (up to 2 for now: keys and touchscreen) */ 48 + #define NR_POLL_DESC 2 49 + static struct pollfd poll_fds[NR_POLL_DESC]; 50 + static nfds_t poll_nfds; 51 + int dev_type[NR_POLL_DESC]; /* DEV_* */ 52 + 53 + #ifdef HAVE_TOUCHSCREEN 54 + /* structure to track touch state */ 55 + static struct 56 + { 57 + int x, y; /* current position (valid is touch is true) */ 58 + int max_x, max_y; /* maximum possible values */ 59 + int pressure, tool_width; /* current pressure and tool width */ 60 + int max_pressure, max_tool_width; /* maximum possible values */ 61 + bool touch; /* is the user touching the screen? */ 62 + /* the hardware supports "flick" gesture */ 63 + bool flick; /* was the action a flick? */ 64 + int flick_x, flick_y; /* if so, this is the flick direction */ 65 + }ts_state; 66 + /* rockbox state, updated from ts state on SYN event */ 67 + static int touch_x, touch_y; 68 + static bool touch_detect; 69 + 70 + /* get touchscreen information and init state */ 71 + int ts_init_state(int fd) 72 + { 73 + memset(state, 0, sizeof(struct nwz_ts_state_t)); 74 + struct input_absinfo info; 75 + if(ioctl(fd, EVIOCGABS(ABS_X), &info) < 0) 76 + return -1; 77 + state->max_x = info.maximum; 78 + if(ioctl(fd, EVIOCGABS(ABS_Y), &info) < 0) 79 + return -1; 80 + state->max_y = info.maximum; 81 + if(ioctl(fd, EVIOCGABS(ABS_PRESSURE), &info) < 0) 82 + return -1; 83 + state->max_pressure = info.maximum; 84 + if(ioctl(fd, EVIOCGABS(ABS_TOOL_WIDTH), &info) < 0) 85 + return -1; 86 + state->max_tool_width = info.maximum; 87 + touch_detect = false; 88 + return 0; 89 + } 90 + 91 + void handle_touch(struct input_event *evt) 92 + { 93 + switch(evt->type) 94 + { 95 + case EV_SYN: 96 + /* on SYN, we copy the state to the rockbox state */ 97 + touch_x = ts_state->x; 98 + touch_y = ts_state->y; 99 + /* map coordinate to screen */ 100 + x = x * LCD_WIDTH / ts_state->max_x; 101 + y = y * LCD_HEIGHT / ts_state->max_y; 102 + /* don't trust driver reported ranges */ 103 + x = MAX(0, MIN(x, LCD_WIDTH - 1)); 104 + y = MAX(0, MIN(y, LCD_HEIGHT - 1)); 105 + touch_detect = ts_state->touch; 106 + /* reset flick */ 107 + state->flick = false; 108 + break; 109 + case EV_REL: 110 + if(evt->code == REL_RX) 111 + state->flick_x = evt->value; 112 + else if(evt->code == REL_RY) 113 + state->flick_y = evt->value; 114 + else 115 + break; 116 + state->flick = true; 117 + break; 118 + case EV_ABS: 119 + if(evt->code == ABS_X) 120 + state->x = evt->value; 121 + else if(evt->code == ABS_Y) 122 + state->y = evt->value; 123 + else if(evt->code == ABS_PRESSURE) 124 + state->pressure = evt->value; 125 + else if(evt->code == ABS_TOOL_WIDTH) 126 + state->tool_width = evt->value; 127 + break; 128 + case EV_KEY: 129 + if(evt->code == BTN_TOUCH) 130 + state->touch = evt->value; 131 + break; 132 + default: 133 + break; 134 + } 135 + } 136 + #endif 137 + 138 + static void load_hold_status(int fd) 139 + { 140 + /* HOLD is reported as the first LED */ 141 + unsigned long led_hold = 0; 142 + if(ioctl(fd, EVIOCGLED(sizeof(led_hold)), &led_hold) < 0) 143 + logf("cannot read HOLD status: %s", strerror(errno)); 144 + hold_status = !!led_hold; 145 + } 146 + 147 + static void key_init_state(int fd) 148 + { 149 + /* the driver knows the HOLD statu at all times */ 150 + load_hold_status(fd); 151 + /* the driver can be queried for button status but the output is garbage 152 + * so just assume no keys are pressed */ 153 + button_bitmap = 0; 154 + } 155 + 156 + static void open_input_device(const char *path) 157 + { 158 + int fd = open(path, O_RDWR); 159 + if(fd < 0) 160 + return; 161 + /* query name */ 162 + char name[256]; 163 + if(ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0) 164 + { 165 + close(fd); 166 + return; 167 + } 168 + 169 + if(strcmp(name, NWZ_KEY_NAME) == 0) 170 + dev_type[poll_nfds] = DEV_KEY; 171 + else if(strcmp(name, NWZ_TS_NAME) == 0) 172 + dev_type[poll_nfds] = DEV_TOUCH; 173 + else 174 + { 175 + /* only keep devices we know about */ 176 + close(fd); 177 + return; 178 + } 179 + /* if we found a key driver, we can read the hold status from it (and keep 180 + * it updated with events) */ 181 + if(dev_type[poll_nfds] == DEV_KEY) 182 + key_init_state(fd); 183 + #ifdef HAVE_TOUCHSCREEN 184 + else if(dev_type[poll_nfds] == DEV_TOUCH) 185 + ts_init_state(fd); 186 + #endif 187 + /* fill poll descriptor */ 188 + poll_fds[poll_nfds].fd = fd; 189 + poll_fds[poll_nfds].events = POLLIN; 190 + poll_fds[poll_nfds].revents = 0; 191 + poll_nfds++; 192 + } 193 + 194 + /* keycode -> rockbox button mapping */ 195 + static int button_map[NWZ_KEY_MASK + 1] = 196 + { 197 + [0 ... NWZ_KEY_MASK] = 0, 198 + [NWZ_KEY_PLAY] = BUTTON_PLAY, 199 + [NWZ_KEY_RIGHT] = BUTTON_RIGHT, 200 + [NWZ_KEY_LEFT] = BUTTON_LEFT, 201 + [NWZ_KEY_UP] = BUTTON_UP, 202 + [NWZ_KEY_DOWN] = BUTTON_DOWN, 203 + [NWZ_KEY_ZAPPIN] = 0, 204 + [NWZ_KEY_AD0_6] = 0, 205 + [NWZ_KEY_AD0_7] = 0, 206 + [NWZ_KEY_NONE] = 0, 207 + [NWZ_KEY_VOL_DOWN] = BUTTON_VOL_DOWN, 208 + [NWZ_KEY_VOL_UP] = BUTTON_VOL_UP, 209 + [NWZ_KEY_BACK] = BUTTON_BACK, 210 + [NWZ_KEY_OPTION] = BUTTON_POWER, 211 + [NWZ_KEY_BT] = 0, 212 + [NWZ_KEY_AD1_5] = 0, 213 + [NWZ_KEY_AD1_6] = 0, 214 + [NWZ_KEY_AD1_7] = 0, 215 + }; 216 + 217 + static void handle_key(struct input_event evt) 218 + { 219 + /* See headers/nwz_keys.h for explanation of Sony's nonstandard interface */ 220 + int keycode = evt.code & NWZ_KEY_MASK; 221 + bool press = (evt.value == 0); 222 + if(press) 223 + button_bitmap |= button_map[keycode]; 224 + else 225 + button_bitmap &= ~button_map[keycode]; 226 + bool new_hold_status = !!(evt.code & NWZ_KEY_HOLD_MASK); 227 + if(new_hold_status != hold_status) 228 + { 229 + hold_status = new_hold_status; 230 + #ifndef BOOTLOADER 231 + backlight_hold_changed(hold_status); 232 + #endif 233 + } 234 + } 235 + 236 + bool button_hold(void) 237 + { 238 + return hold_status; 239 + } 240 + 241 + void button_init_device(void) 242 + { 243 + const char *input_path = "/dev/input"; 244 + char device_name[PATH_MAX]; 245 + /* find what input devices are available */ 246 + DIR* input_dir = opendir(input_path); 247 + if(input_dir == NULL) 248 + panicf("Cannot read /dev/input directory: %s", strerror(errno)); 249 + strcpy(device_name, input_path); 250 + strcat(device_name, "/"); 251 + char *device_name_p = device_name + strlen(device_name); 252 + struct dirent *dir_entry; 253 + while((dir_entry = readdir(input_dir))) 254 + { 255 + /* skip '.' and '..' entries */ 256 + if(strcmp(dir_entry->d_name, ".") == 0 || strcmp(dir_entry->d_name, "..") == 0) 257 + continue; 258 + /* create device full path and open it */ 259 + strcpy(device_name_p, dir_entry->d_name); 260 + open_input_device(device_name); 261 + } 262 + closedir(input_dir); 263 + /* check if we have at least one device */ 264 + if(poll_nfds == 0) 265 + panicf("No input device found"); 266 + } 267 + 268 + int button_read_device( 269 + #ifdef HAVE_BUTTON_DATA 270 + int *data 271 + #else 272 + void 273 + #endif 274 + ) 275 + { 276 + struct input_event event; 277 + /* check if there are any events pending and process them */ 278 + while(true) 279 + { 280 + /* stop when there are no more events */ 281 + if(poll(poll_fds, poll_nfds, 0) == 0) 282 + break; 283 + for(unsigned int i = 0; i < poll_nfds; i++) 284 + { 285 + /* only read if we won't block */ 286 + if(!(poll_fds[i].revents & POLLIN)) 287 + continue; 288 + if(read(poll_fds[i].fd, &event, sizeof(event)) != (int)sizeof(event)) 289 + continue; 290 + if(dev_type[i] == DEV_KEY) 291 + handle_key(event); 292 + #ifdef HAVE_TOUCHSCREEN 293 + else if(dev_type[i] == DEV_TOUCH) 294 + handle_touch(event); 295 + #endif 296 + } 297 + } 298 + #ifdef HAVE_TOUCHSCREEN 299 + button_bitmap |= touchscreen_to_pixels(touch_x, touch_y, data); 300 + #endif 301 + return hold_status ? 0 : button_bitmap; 302 + } 303 + 304 + void nwz_button_reload_after_suspend(void) 305 + { 306 + /* reinit everything, particularly important for keys and HOLD */ 307 + for(unsigned int i = 0; i < poll_nfds; i++) 308 + { 309 + if(dev_type[i] == DEV_KEY) 310 + key_init_state(poll_fds[i].fd); 311 + #ifdef HAVE_TOUCHSCREEN 312 + else if(dev_type[i] == DEV_TOUCH) 313 + ts_init_state(poll_fds[i].fd); 314 + #endif 315 + } 316 + } 317 + 318 + void button_close_device(void) 319 + { 320 + /* close descriptors */ 321 + for(unsigned int i = 0; i < poll_nfds; i++) 322 + close(poll_fds[i].fd); 323 + }
+47
firmware/target/hosted/sonynwz/button-target.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by 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 _BUTTON_TARGET_H_ 22 + #define _BUTTON_TARGET_H_ 23 + 24 + #include <stdbool.h> 25 + #include "config.h" 26 + 27 + /* Main unit's buttons */ 28 + #define BUTTON_POWER 0x00000001 29 + #define BUTTON_BACK 0x00000002 30 + #define BUTTON_PLAY 0x00000004 31 + #define BUTTON_LEFT 0x00000008 32 + #define BUTTON_UP 0x00000010 33 + #define BUTTON_DOWN 0x00000020 34 + #define BUTTON_RIGHT 0x00000040 35 + #define BUTTON_VOL_DOWN 0x00000080 36 + #define BUTTON_VOL_UP 0x00000100 37 + 38 + #define BUTTON_MAIN 0x000001ff 39 + 40 + /* Software power-off */ 41 + #define POWEROFF_BUTTON BUTTON_POWER 42 + #define POWEROFF_COUNT 10 43 + 44 + /* force driver to reload button state (useful after suspend) */ 45 + void nwz_button_reload_after_suspend(void); 46 + 47 + #endif /* _BUTTON_TARGET_H_ */
+439
firmware/target/hosted/sonynwz/debug-nwz.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * 9 + * Copyright (C) 2016 by 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 + #include "cpu.h" 22 + #include "system.h" 23 + #include "kernel.h" 24 + #include "lcd.h" 25 + #include "font.h" 26 + #include "adc.h" 27 + #include "adc-target.h" 28 + #include "button.h" 29 + #include "button-target.h" 30 + #include "powermgmt.h" 31 + #include "power-nwz.h" 32 + #include "nvp-nwz.h" 33 + #include "nwz_sysinfo.h" 34 + #include <unistd.h> 35 + #include <string.h> 36 + #include <sys/types.h> 37 + #include <fcntl.h> 38 + #include <sys/ioctl.h> 39 + 40 + /* NOTE: some targets with touchscreen don't have the usual keypad, on those 41 + * we use a mixture of rewind/forward/volume+/- to emulate it */ 42 + #define ACT_NONE 0 43 + #define ACT_CANCEL 1 44 + #define ACT_OK 2 45 + #define ACT_PREV 3 46 + #define ACT_NEXT 4 47 + #define ACT_REPEAT 0x1000 48 + 49 + int xlate_button(int btn) 50 + { 51 + switch(btn) 52 + { 53 + #ifdef BUTTON_POWER 54 + case BUTTON_POWER: 55 + #endif 56 + case BUTTON_BACK: 57 + return ACT_CANCEL; 58 + case BUTTON_PLAY: 59 + return ACT_OK; 60 + case BUTTON_UP: 61 + case BUTTON_LEFT: 62 + case BUTTON_VOL_UP: 63 + return ACT_PREV; 64 + case BUTTON_DOWN: 65 + case BUTTON_RIGHT: 66 + case BUTTON_VOL_DOWN: 67 + return ACT_NEXT; 68 + default: 69 + return ACT_NONE; 70 + } 71 + } 72 + 73 + int my_get_status(void) 74 + { 75 + return xlate_button(button_status()); 76 + } 77 + 78 + int my_get_action(int tmo) 79 + { 80 + int btn = button_get_w_tmo(tmo); 81 + while(btn & BUTTON_REL) 82 + btn = button_get_w_tmo(tmo); 83 + bool repeat = btn & BUTTON_REPEAT; 84 + int act = xlate_button(btn & ~BUTTON_REPEAT); 85 + if(repeat) 86 + act |= ACT_REPEAT; 87 + return act; 88 + } 89 + 90 + bool dbg_hw_info_adc(void) 91 + { 92 + lcd_setfont(FONT_SYSFIXED); 93 + 94 + while(1) 95 + { 96 + int button = my_get_action(HZ / 25); 97 + switch(button) 98 + { 99 + case ACT_NEXT: 100 + case ACT_PREV: 101 + case ACT_OK: 102 + lcd_setfont(FONT_UI); 103 + return true; 104 + case ACT_CANCEL: 105 + lcd_setfont(FONT_UI); 106 + return false; 107 + } 108 + 109 + lcd_clear_display(); 110 + 111 + /* add battery readout in mV, this it is not the direct output of a channel */ 112 + lcd_putsf(0, 0, "Battery(mV) %d", _battery_voltage()); 113 + for(unsigned i = NWZ_ADC_MIN_CHAN; i <= NWZ_ADC_MAX_CHAN; i++) 114 + lcd_putsf(0, i + 1, "%7s %3d", adc_name(i), adc_read(i)); 115 + 116 + lcd_update(); 117 + yield(); 118 + } 119 + } 120 + 121 + static const char *charge_status_name(int chgstat) 122 + { 123 + switch(chgstat) 124 + { 125 + case NWZ_POWER_STATUS_CHARGE_STATUS_CHARGING: return "charging"; 126 + case NWZ_POWER_STATUS_CHARGE_STATUS_SUSPEND: return "suspend"; 127 + case NWZ_POWER_STATUS_CHARGE_STATUS_TIMEOUT: return "timeout"; 128 + case NWZ_POWER_STATUS_CHARGE_STATUS_NORMAL: return "normal"; 129 + default: return "unknown"; 130 + } 131 + } 132 + 133 + static const char *get_batt_gauge_name(int gauge) 134 + { 135 + switch(gauge) 136 + { 137 + case NWZ_POWER_BAT_NOBAT: return "no batt"; 138 + case NWZ_POWER_BAT_VERYLOW: return "very low"; 139 + case NWZ_POWER_BAT_LOW: return "low"; 140 + case NWZ_POWER_BAT_GAUGE0: return "____"; 141 + case NWZ_POWER_BAT_GAUGE1: return "O___"; 142 + case NWZ_POWER_BAT_GAUGE2: return "OO__"; 143 + case NWZ_POWER_BAT_GAUGE3: return "OOO_"; 144 + case NWZ_POWER_BAT_GAUGE4: return "OOOO"; 145 + default: return "unknown"; 146 + } 147 + } 148 + 149 + static const char *acc_charge_mode_name(int mode) 150 + { 151 + switch(mode) 152 + { 153 + case NWZ_POWER_ACC_CHARGE_NONE: return "none"; 154 + case NWZ_POWER_ACC_CHARGE_VBAT: return "vbat"; 155 + case NWZ_POWER_ACC_CHARGE_VSYS: return "vsys"; 156 + default: return "unknown"; 157 + } 158 + } 159 + 160 + bool dbg_hw_info_power(void) 161 + { 162 + lcd_setfont(FONT_SYSFIXED); 163 + 164 + while(1) 165 + { 166 + int button = my_get_action(HZ / 25); 167 + switch(button) 168 + { 169 + case ACT_NEXT: 170 + case ACT_PREV: 171 + case ACT_OK: 172 + lcd_setfont(FONT_UI); 173 + return true; 174 + case ACT_CANCEL: 175 + lcd_setfont(FONT_UI); 176 + return false; 177 + } 178 + 179 + lcd_clear_display(); 180 + 181 + int line = 0; 182 + int status = nwz_power_get_status(); 183 + int chgstat = status & NWZ_POWER_STATUS_CHARGE_STATUS; 184 + int acc_chg_mode = nwz_power_get_acc_charge_mode(); 185 + lcd_putsf(0, line++, "ac detected: %s", 186 + (status & NWZ_POWER_STATUS_AC_DET) ? "yes" : "no"); 187 + lcd_putsf(0, line++, "vbus detected: %s ", 188 + (status & NWZ_POWER_STATUS_VBUS_DET) ? "yes" : "no"); 189 + lcd_putsf(0, line++, "vbus voltage: %d mV (AD=%d)", 190 + nwz_power_get_vbus_voltage(), nwz_power_get_vbus_adval()); 191 + lcd_putsf(0, line++, "vbus limit: %d mA ", 192 + nwz_power_get_vbus_limit()); 193 + lcd_putsf(0, line++, "vsys voltage: %d mV (AD=%d)", 194 + nwz_power_get_vsys_voltage(), nwz_power_get_vsys_adval()); 195 + lcd_putsf(0, line++, "charge switch: %s ", 196 + nwz_power_get_charge_switch() ? "on" : "off"); 197 + lcd_putsf(0, line++, "full voltage: %s V ", 198 + (status & NWZ_POWER_STATUS_CHARGE_LOW) ? "4.1" : "4.2"); 199 + lcd_putsf(0, line++, "current limit: %d mA", 200 + nwz_power_get_charge_current()); 201 + lcd_putsf(0, line++, "charge status: %s (%x)", 202 + charge_status_name(chgstat), chgstat); 203 + lcd_putsf(0, line++, "battery full: %s ", 204 + nwz_power_is_fully_charged() ? "yes" : "no"); 205 + lcd_putsf(0, line++, "bat gauge: %s (%d)", 206 + get_batt_gauge_name(nwz_power_get_battery_gauge()), 207 + nwz_power_get_battery_gauge()); 208 + lcd_putsf(0, line++, "avg voltage: %d mV (AD=%d)", 209 + nwz_power_get_battery_voltage(), nwz_power_get_battery_adval()); 210 + lcd_putsf(0, line++, "sample count: %d ", 211 + nwz_power_get_sample_count()); 212 + lcd_putsf(0, line++, "raw voltage: %d mV (AD=%d)", 213 + nwz_power_get_vbat_voltage(), nwz_power_get_vbat_adval()); 214 + lcd_putsf(0, line++, "acc charge mode: %s (%d)", 215 + acc_charge_mode_name(acc_chg_mode), acc_chg_mode); 216 + 217 + lcd_update(); 218 + yield(); 219 + } 220 + } 221 + 222 + bool dbg_hw_info_button(void) 223 + { 224 + lcd_setfont(FONT_SYSFIXED); 225 + 226 + while(1) 227 + { 228 + int btn = my_get_action(0); 229 + switch(btn) 230 + { 231 + case ACT_OK: 232 + lcd_setfont(FONT_UI); 233 + return true; 234 + case ACT_CANCEL: 235 + lcd_setfont(FONT_UI); 236 + return false; 237 + } 238 + 239 + lcd_clear_display(); 240 + int line = 0; 241 + 242 + #ifdef HAVE_BUTTON_DATA 243 + int data; 244 + btn = button_read_device(&data); 245 + #else 246 + btn = button_read_device(); 247 + #endif 248 + lcd_putsf(0, line++, "raw buttons: %x", btn); 249 + #ifdef HAS_BUTTON_HOLD 250 + lcd_putsf(0, line++, "hold: %d", button_hold()); 251 + #endif 252 + #ifdef HAVE_HEADPHONE_DETECTION 253 + lcd_putsf(0, line++, "headphones: %d", headphones_inserted()); 254 + #endif 255 + #ifdef HAVE_BUTTON_DATA 256 + #ifdef HAVE_TOUCHSCREEN 257 + lcd_putsf(0, line++, "touch: x=%d y=%d", data >> 16, data & 0xffff); 258 + #else 259 + lcd_putsf(0, line++, "data: %d", data); 260 + #endif 261 + #endif 262 + 263 + lcd_update(); 264 + yield(); 265 + } 266 + } 267 + 268 + int read_sysinfo(int ioctl_nr, unsigned int *val) 269 + { 270 + int fd = open(NWZ_SYSINFO_DEV, O_RDONLY); 271 + if(fd < 0) 272 + return -1; 273 + int ret = ioctl(fd, ioctl_nr, val); 274 + close(fd); 275 + return ret; 276 + } 277 + 278 + bool dbg_hw_info_sysinfo(void) 279 + { 280 + lcd_setfont(FONT_SYSFIXED); 281 + 282 + while(1) 283 + { 284 + int btn = my_get_action(0); 285 + switch(btn) 286 + { 287 + case ACT_OK: 288 + lcd_setfont(FONT_UI); 289 + return true; 290 + case ACT_CANCEL: 291 + lcd_setfont(FONT_UI); 292 + return false; 293 + } 294 + 295 + lcd_clear_display(); 296 + int line = 0; 297 + unsigned int val; 298 + 299 + lcd_putsf(0, line++, "mid: %x (%s)", nwz_get_model_id(), nwz_get_model_name()); 300 + #define print_info(def, name) \ 301 + if(read_sysinfo(NWZ_SYSINFO_GET_##def##_TYPE, &val) < 0) \ 302 + lcd_putsf(0, line++, "%s: -", name); \ 303 + else \ 304 + lcd_putsf(0, line++, "%s: %d", name, val); 305 + 306 + /* WARNING the interpretation of values is difficult because it changes 307 + * very often */ 308 + /* DAC type: ... */ 309 + print_info(DAC, "dac") 310 + /* Noise cancelling: 0=no, 1=yes */ 311 + print_info(NCR, "nc") 312 + /* Speaker: 0=no, 1=yes */ 313 + print_info(SPK, "spk") 314 + /* Microphone: 0=no, 1=yes */ 315 + print_info(MIC, "mic") 316 + /* Video encoder: 0=no, ... */ 317 + print_info(NPE, "videoenc") 318 + /* FM receiver: 0=no, 1=si470x */ 319 + print_info(FMT, "fm") 320 + /* Touch screen: 0=none, ... */ 321 + print_info(TSP, "touch") 322 + /* Bluetooth: 0=no, 1=yes */ 323 + print_info(WAB, "bt") 324 + /* SD card: 0=no, ... */ 325 + print_info(SDC, "sd") 326 + 327 + lcd_update(); 328 + yield(); 329 + } 330 + } 331 + 332 + #include "pcm-alsa.h" 333 + 334 + bool dbg_hw_info_audio(void) 335 + { 336 + lcd_setfont(FONT_SYSFIXED); 337 + int vol = 0; 338 + 339 + while(1) 340 + { 341 + int btn = my_get_action(0); 342 + switch(btn) 343 + { 344 + case ACT_PREV: 345 + vol--; 346 + pcm_alsa_set_digital_volume(vol); 347 + break; 348 + case ACT_NEXT: 349 + vol++; 350 + pcm_alsa_set_digital_volume(vol); 351 + break; 352 + case ACT_OK: 353 + lcd_setfont(FONT_UI); 354 + return true; 355 + case ACT_CANCEL: 356 + lcd_setfont(FONT_UI); 357 + return false; 358 + } 359 + 360 + lcd_clear_display(); 361 + int line = 0; 362 + unsigned int val; 363 + 364 + lcd_putsf(0, line++, "vol: %d dB", vol); 365 + 366 + lcd_update(); 367 + yield(); 368 + } 369 + } 370 + 371 + static struct 372 + { 373 + const char *name; 374 + bool (*fn)(void); 375 + } debug_screens[] = 376 + { 377 + {"sysinfo", dbg_hw_info_sysinfo}, 378 + {"adc", dbg_hw_info_adc}, 379 + {"power", dbg_hw_info_power}, 380 + {"button", dbg_hw_info_button}, 381 + {"audio", dbg_hw_info_audio}, 382 + }; 383 + 384 + bool dbg_hw_info(void) 385 + { 386 + int nr_lines = lcd_getheight() / font_get(lcd_getfont())->height; 387 + int len = ARRAYLEN(debug_screens); 388 + int top_visible = 0; 389 + int highlight = 0; 390 + while(1) 391 + { 392 + int button = my_get_action(HZ / 10); 393 + switch(button) 394 + { 395 + case ACT_NEXT: 396 + highlight = (highlight + 1) % len; 397 + break; 398 + case ACT_PREV: 399 + highlight = (highlight + len - 1) % len; 400 + break; 401 + case ACT_OK: 402 + // if the screen returns true, advance to next screen 403 + while(debug_screens[highlight].fn()) 404 + highlight = (highlight + 1) % len; 405 + lcd_setfont(FONT_UI); 406 + break; 407 + case ACT_CANCEL: 408 + return false; 409 + } 410 + // adjust top visible if needed 411 + if(highlight < top_visible) 412 + top_visible = highlight; 413 + else if(highlight >= top_visible + nr_lines) 414 + top_visible = highlight - nr_lines + 1; 415 + 416 + lcd_clear_display(); 417 + 418 + for(int i = top_visible; i < len && i < top_visible + nr_lines; i++) 419 + { 420 + if(i == highlight) 421 + { 422 + lcd_set_foreground(LCD_BLACK); 423 + lcd_set_background(LCD_RGBPACK(255, 255, 0)); 424 + } 425 + else 426 + { 427 + lcd_set_foreground(LCD_WHITE); 428 + lcd_set_background(LCD_BLACK); 429 + } 430 + lcd_putsf(0, i - top_visible, "%s", debug_screens[i].name); 431 + } 432 + lcd_set_foreground(LCD_WHITE); 433 + lcd_set_background(LCD_BLACK); 434 + 435 + lcd_update(); 436 + yield(); 437 + } 438 + return false; 439 + }
+200
firmware/target/hosted/sonynwz/lcd-nwz.c
··· 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 + #include <stdlib.h> 22 + #include <unistd.h> 23 + #include <stdio.h> 24 + #include <string.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 + 33 + static int fb_fd = 0; 34 + fb_data *nwz_framebuffer = 0; /* global variable, see lcd-target.h */ 35 + enum 36 + { 37 + FB_MP200, /* MP200 fb driver */ 38 + FB_EMXX, /* EMXX fb driver */ 39 + FB_OTHER, /* unknown */ 40 + }nwz_fb_type; 41 + 42 + void identify_fb(const char *id) 43 + { 44 + if(strcmp(id, "MP200 FB") == 0) 45 + nwz_fb_type = FB_MP200; 46 + else if(strcmp(id, "EMXX FB") == 0) 47 + nwz_fb_type = FB_EMXX; 48 + else 49 + nwz_fb_type = FB_OTHER; 50 + printf("lcd: fb id = '%s -> type = %d\n", id, nwz_fb_type); 51 + } 52 + 53 + /* select which page (0 or 1) to display, disable DSP, transparency and rotation */ 54 + static int nwz_fb_set_page(int page) 55 + { 56 + /* set page mode to no transparency and no rotation */ 57 + struct nwz_fb_image_info mode_info; 58 + mode_info.tc_enable = 0; 59 + mode_info.t_color = 0; 60 + mode_info.alpha = 0; 61 + mode_info.rot = 0; 62 + mode_info.page = page; 63 + mode_info.update = NWZ_FB_ONLY_2D_MODE; 64 + if(ioctl(fb_fd, NWZ_FB_UPDATE, &mode_info) < 0) 65 + return -1; 66 + return 0; 67 + } 68 + 69 + /* make sure framebuffer is in standard state so rendering works */ 70 + static int nwz_fb_set_standard_mode(void) 71 + { 72 + /* disable timer (apparently useless with LCD) */ 73 + struct nwz_fb_update_timer update_timer; 74 + update_timer.timerflag = NWZ_FB_TIMER_OFF; 75 + update_timer.timeout = NWZ_FB_DEFAULT_TIMEOUT; 76 + /* we don't check the result of the next ioctl() because it will fail in 77 + * newer version of the driver, where the timer disapperared. */ 78 + ioctl(fb_fd, NWZ_FB_UPDATE_TIMER, &update_timer); 79 + return nwz_fb_set_page(0); 80 + } 81 + 82 + void backlight_hw_brightness(int brightness) 83 + { 84 + struct nwz_fb_brightness bl; 85 + bl.level = brightness; /* brightness level: 0-5 */ 86 + bl.step = 25; /* number of hardware steps to do when changing: 1-100 (smooth transition) */ 87 + bl.period = NWZ_FB_BL_MIN_PERIOD; /* period in ms between steps when changing: >=10 */ 88 + 89 + ioctl(fb_fd, nwz_fb_type == FB_MP200 ? NWZ_FB_SET_BRIGHTNESS_MP200 : NWZ_FB_SET_BRIGHTNESS_EMXX, &bl); 90 + } 91 + 92 + bool backlight_hw_init(void) 93 + { 94 + backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); 95 + return true; 96 + } 97 + 98 + void backlight_hw_on(void) 99 + { 100 + #ifdef HAVE_LCD_ENABLE 101 + lcd_enable(true); /* power on lcd + visible display */ 102 + #endif 103 + /* don't do anything special, the core will set the brightness */ 104 + } 105 + 106 + void backlight_hw_off(void) 107 + { 108 + /* there is no real on/off but we can set to 0 brightness */ 109 + backlight_hw_brightness(0); 110 + #ifdef HAVE_LCD_ENABLE 111 + lcd_enable(false); /* power off visible display */ 112 + #endif 113 + } 114 + 115 + void lcd_shutdown(void) 116 + { 117 + munmap(nwz_framebuffer, FRAMEBUFFER_SIZE); 118 + close(fb_fd); 119 + } 120 + 121 + void lcd_init_device(void) 122 + { 123 + fb_fd = open("/dev/fb/0", O_RDWR); 124 + if(fb_fd < 0) 125 + { 126 + perror("Cannot open framebuffer"); 127 + exit(0); 128 + } 129 + 130 + /* get fixed and variable information */ 131 + struct fb_fix_screeninfo finfo; 132 + if(ioctl(fb_fd, FBIOGET_FSCREENINFO, &finfo) < 0) 133 + { 134 + perror("Cannot read framebuffer fixed information"); 135 + exit(0); 136 + } 137 + identify_fb(finfo.id); 138 + struct fb_var_screeninfo vinfo; 139 + if(ioctl(fb_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) 140 + { 141 + perror("Cannot read framebuffer variable information"); 142 + exit(0); 143 + } 144 + /* check resolution and framebuffer size */ 145 + if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH) 146 + { 147 + printf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres, 148 + vinfo.yres, vinfo.bits_per_pixel); 149 + exit(0); 150 + } 151 + /* Note: we use a framebuffer size of width*height*bbp. We cannot trust the 152 + * values returned by the driver for line_length */ 153 + 154 + /* map framebuffer */ 155 + nwz_framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0); 156 + if((void *)nwz_framebuffer == (void *)-1) 157 + { 158 + perror("Cannot map framebuffer"); 159 + fflush(stdout); 160 + execlp("/usr/local/bin/SpiderApp.of", "SpiderApp", NULL); 161 + exit(0); 162 + } 163 + /* make sure rendering state is correct */ 164 + nwz_fb_set_standard_mode(); 165 + } 166 + 167 + static void redraw(void) 168 + { 169 + nwz_fb_set_page(0); 170 + } 171 + 172 + extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, 173 + int width, int height); 174 + 175 + void lcd_update(void) 176 + { 177 + /* Copy the Rockbox framebuffer to the second framebuffer */ 178 + lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0), 179 + LCD_WIDTH*LCD_HEIGHT, 1); 180 + redraw(); 181 + } 182 + 183 + void lcd_update_rect(int x, int y, int width, int height) 184 + { 185 + fb_data *dst = LCD_FRAMEBUF_ADDR(x, y); 186 + fb_data * src = FBADDR(x,y); 187 + 188 + /* Copy part of the Rockbox framebuffer to the second framebuffer */ 189 + if (width < LCD_WIDTH) 190 + { 191 + /* Not full width - do line-by-line */ 192 + lcd_copy_buffer_rect(dst, src, width, height); 193 + } 194 + else 195 + { 196 + /* Full width - copy as one line */ 197 + lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1); 198 + } 199 + redraw(); 200 + }
+119
firmware/target/hosted/sonynwz/nvp-nwz.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by 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 + #include "nvp-nwz.h" 22 + #include <stdlib.h> 23 + #include <unistd.h> 24 + #include <string.h> 25 + #include <sys/types.h> 26 + #include <fcntl.h> 27 + #include <stdio.h> 28 + 29 + static unsigned long find_model_id(void) 30 + { 31 + /* try with the environment variable */ 32 + const char *mid = getenv("ICX_MODEL_ID"); 33 + if(mid == NULL) 34 + return 0; 35 + char *end; 36 + unsigned long v = strtoul(mid, &end, 0); 37 + if(*end) 38 + return 0; 39 + else 40 + return v; 41 + } 42 + 43 + unsigned long nwz_get_model_id(void) 44 + { 45 + static unsigned long model_id = 0xffffffff; 46 + if(model_id == 0xffffffff) 47 + model_id = find_model_id(); 48 + return model_id; 49 + } 50 + 51 + const char *nwz_get_model_name(void) 52 + { 53 + for(int i = 0; i < NWZ_MODEL_COUNT; i++) 54 + if(nwz_model[i].mid == nwz_get_model_id()) 55 + return nwz_model[i].name; 56 + return NULL; 57 + } 58 + 59 + static int find_series(void) 60 + { 61 + for(int i = 0; i < NWZ_SERIES_COUNT; i++) 62 + for(int j = 0; j < nwz_series[i].mid_count; j++) 63 + if(nwz_series[i].mid[j] == nwz_get_model_id()) 64 + return i; 65 + return -1; 66 + } 67 + 68 + int nwz_get_series(void) 69 + { 70 + static int series = -2; 71 + if(series == -2) 72 + series = find_series(); 73 + return series; 74 + } 75 + 76 + static nwz_nvp_index_t *get_nvp_index(void) 77 + { 78 + static nwz_nvp_index_t *index = 0; 79 + if(index == 0) 80 + { 81 + int series = nwz_get_series(); 82 + index = series < 0 ? 0 : nwz_series[series].nvp_index; 83 + } 84 + return index; 85 + } 86 + 87 + int nwz_nvp_read(enum nwz_nvp_node_t node, void *data) 88 + { 89 + int size = nwz_nvp[node].size; 90 + if(data == 0) 91 + return size; 92 + nwz_nvp_index_t *index = get_nvp_index(); 93 + if(index == 0 || (*index)[node] == NWZ_NVP_INVALID) 94 + return -1; 95 + char nvp_path[32]; 96 + snprintf(nvp_path, sizeof(nvp_path), "/dev/icx_nvp/%03d", (*index)[node]); 97 + int fd = open(nvp_path, O_RDONLY); 98 + if(fd < 0) 99 + return -1; 100 + int cnt = read(fd, data, size); 101 + close(fd); 102 + return cnt == size ? size : -1; 103 + } 104 + 105 + int nwz_nvp_write(enum nwz_nvp_node_t node, void *data) 106 + { 107 + int size = nwz_nvp[node].size; 108 + nwz_nvp_index_t *index = get_nvp_index(); 109 + if(index == 0 || (*index)[node] == NWZ_NVP_INVALID) 110 + return -1; 111 + char nvp_path[32]; 112 + snprintf(nvp_path, sizeof(nvp_path), "/dev/icx_nvp/%03d", (*index)[node]); 113 + int fd = open(nvp_path, O_WRONLY); 114 + if(fd < 0) 115 + return -1; 116 + int cnt = write(fd, data, size); 117 + close(fd); 118 + return cnt == size ? 0 : -1; 119 + }
+41
firmware/target/hosted/sonynwz/nvp-nwz.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by 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 __NVP_NWZ_H__ 22 + #define __NVP_NWZ_H__ 23 + 24 + #include "system.h" 25 + #include "nwz-db.h" 26 + 27 + /* get model ID */ 28 + unsigned long nwz_get_model_id(void); 29 + /* get model NAME (ie NWZ-E463) */ 30 + const char *nwz_get_model_name(void); 31 + /* return series (index into nwz_db) */ 32 + int nwz_get_series(void); 33 + 34 + /* read a nvp node and return its size, if the data pointer is null, then simply 35 + * return the size, return -1 on error */ 36 + int nwz_nvp_read(enum nwz_nvp_node_t node, void *data); 37 + /* write a nvp node, return 0 on success and -1 on error, the size of the buffer 38 + * must be the one returned by nwz_nvp_read */ 39 + int nwz_nvp_write(enum nwz_nvp_node_t node, void *data); 40 + 41 + #endif /* __NVP_NWZ_H__ */
+112
firmware/target/hosted/sonynwz/nwz_audio.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 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 __NWZ_AUDIO_H__ 22 + #define __NWZ_AUDIO_H__ 23 + 24 + /* The Sony audio driver is a beast that involves several modules but eventually 25 + * all boils down to the codec driver that handles everything, including ALSA 26 + * controls. The volume, power up and other controls are doing through the ALSA 27 + * interface. The driver also accepts private IOCTL on the hardware device 28 + * (/dev/snd/hwC0D0). Finally some noice cancelling (NC) ioctl must be sent to 29 + * the noican driver (/dev/icx_noican). 30 + */ 31 + 32 + /** 33 + * Sound driver 34 + */ 35 + 36 + #define NWZ_AUDIO_TYPE 'a' 37 + 38 + #define NWZ_AUDIO_GET_CLRSTRO_VAL _IOR(NWZ_AUDIO_TYPE, 0x04, struct nwz_cst_param_t) 39 + struct nwz_cst_param_t 40 + { 41 + int no_ext_cbl; 42 + int with_ext_cbl; 43 + }; 44 + 45 + #define NEW_AUDIO_ALC_DATA_NUM 32 46 + 47 + enum nwz_audio_alc_types 48 + { 49 + NWZ_ALC_TYPE_NONE = 0, /* invalid */ 50 + NWZ_ALC_TYPE_HP_DSP, /* HP / DSP ALC */ 51 + NWZ_ALC_TYPE_HP_ARM, /* HP / ARM ALC */ 52 + NWZ_ALC_TYPE_LINE_DSP, /* LINE / DSP ALC */ 53 + NWZ_ALC_TYPE_LINE_ARM, /* LINE / ARM ALC */ 54 + NWZ_ALC_TYPE_BT_DSP, /* BT / DSP ALC */ 55 + NWZ_ALC_TYPE_BT_ARM /* BT / ARM ALC */ 56 + }; 57 + 58 + struct nwz_audio_alc_data_ex_t 59 + { 60 + enum nwz_audio_alc_types type; 61 + unsigned short table[NEW_AUDIO_ALC_DATA_NUM]; 62 + }; 63 + 64 + #define NWZ_AUDIO_GET_ALC_DATA_EX _IOWR(NWZ_AUDIO_TYPE, 0x0f, struct nwz_audio_alc_data_ex_t) 65 + 66 + /** 67 + * Noise cancelling driver 68 + */ 69 + 70 + #define NWZ_NC_DEV "/dev/icx_noican" 71 + 72 + #define NWZ_NC_TYPE 'c' 73 + 74 + /* Enable/Disable NC switch */ 75 + #define NWZ_NC_SET_SWITCH _IOW(NWZ_NC_TYPE, 0x01, int) 76 + #define NWZ_NC_GET_SWITCH _IOR(NWZ_NC_TYPE, 0x02, int) 77 + #define NWZ_NC_SWITCH_OFF 0 78 + #define NWZ_NC_SWITCH_ON 1 79 + 80 + /* Get NC HP status (whether it is NC capable or not) */ 81 + #define NWZ_NC_GET_HP_STATUS _IOR(NWZ_NC_TYPE, 0x09, int) 82 + #define NWZ_NC_HP_NMLHP (0x1 << 0) 83 + #define NWZ_NC_HP_NCHP (0x1 << 1) 84 + 85 + /* NC amp gain */ 86 + #define NWZ_NC_SET_GAIN _IOW(NWZ_NC_TYPE, 0x03, int) 87 + #define NWZ_NC_GET_GAIN _IOR(NWZ_NC_TYPE, 0x04, int) 88 + #define NWZ_NC_GAIN_MIN 0 89 + #define NWZ_NC_GAIN_CENTER 15 90 + #define NWZ_NC_GAIN_MAX 30 91 + 92 + /* NC amp gain by value */ 93 + #define NWZ_NC_SET_GAIN_VALUE _IOW(NWZ_NC_TYPE, 0x05, int) 94 + #define NWZ_NC_GET_GAIN_VALUE _IOR(NWZ_NC_TYPE, 0x06, int) 95 + #define NWZ_NC_MAKE_GAIN(l, r) (((r) << 8) | (l)) 96 + #define NWZ_NC_GET_L_GAIN(vol) ((vol) & 0xff) 97 + #define NWZ_NC_GET_R_GAIN(vol) (((vol) >> 8) & 0xff) 98 + 99 + /* Set/Get NC filter */ 100 + #define NWZ_NC_SET_FILTER _IOWR(NWZ_NC_TYPE, 0x07, int) 101 + #define NWZ_NC_GET_FILTER _IOWR(NWZ_NC_TYPE, 0x08, int) 102 + #define NWZ_NC_FILTER_INDEX_0 0 103 + #define NWZ_NC_FILTER_INDEX_1 1 104 + #define NWZ_NC_FILTER_INDEX_2 2 105 + 106 + /* Get/Set HP type */ 107 + #define NWZ_NC_SET_HP_TYPE _IOWR(NWZ_NC_TYPE, 0x09, int) 108 + #define NWZ_NC_GET_HP_TYPE _IOWR(NWZ_NC_TYPE, 0x0a, int) 109 + #define NC_HP_TYPE_DEFAULT 0 110 + #define NC_HP_TYPE_NWNC200 1 111 + 112 + #endif /* __NWZ_AUDIO_H__ */
+72
firmware/target/hosted/sonynwz/nwz_sysinfo.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2017 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 __NWZ_SYSINFO_H__ 22 + #define __NWZ_SYSINFO_H__ 23 + 24 + #define NWZ_SYSINFO_DEV "/dev/icx_sysinfo" 25 + #define NWZ_SYSINFO_TYPE 's' 26 + 27 + #define NWZ_SYSINFO_GET_SYS_INFO _IOR(NWZ_SYSINFO_TYPE, 0, unsigned int *) 28 + #define NWZ_SYSINFO_PUT_SYS_INFO _IOW(NWZ_SYSINFO_TYPE, 1, unsigned int *) 29 + #define NWZ_SYSINFO_GET_BRD_REVS _IOR(NWZ_SYSINFO_TYPE, 2, unsigned int *) 30 + #define NWZ_SYSINFO_PUT_BRD_REVS _IOW(NWZ_SYSINFO_TYPE, 3, unsigned int *) 31 + #define NWZ_SYSINFO_GET_MEM_SIZE _IOR(NWZ_SYSINFO_TYPE, 4, unsigned int *) 32 + #define NWZ_SYSINFO_PUT_MEM_SIZE _IOW(NWZ_SYSINFO_TYPE, 5, unsigned int *) 33 + #define NWZ_SYSINFO_GET_BTT_TYPE _IOR(NWZ_SYSINFO_TYPE, 6, unsigned int *) 34 + #define NWZ_SYSINFO_PUT_BTT_TYPE _IOW(NWZ_SYSINFO_TYPE, 7, unsigned int *) 35 + #define NWZ_SYSINFO_GET_LCD_TYPE _IOR(NWZ_SYSINFO_TYPE, 8, unsigned int *) 36 + #define NWZ_SYSINFO_PUT_LCD_TYPE _IOW(NWZ_SYSINFO_TYPE, 9, unsigned int *) 37 + #define NWZ_SYSINFO_GET_NPE_TYPE _IOR(NWZ_SYSINFO_TYPE, 10, unsigned int *) 38 + #define NWZ_SYSINFO_PUT_NPE_TYPE _IOW(NWZ_SYSINFO_TYPE, 11, unsigned int *) 39 + #define NWZ_SYSINFO_GET_DAC_TYPE _IOR(NWZ_SYSINFO_TYPE, 12, unsigned int *) 40 + #define NWZ_SYSINFO_PUT_DAC_TYPE _IOW(NWZ_SYSINFO_TYPE, 13, unsigned int *) 41 + #define NWZ_SYSINFO_GET_NCR_TYPE _IOR(NWZ_SYSINFO_TYPE, 14, unsigned int *) 42 + #define NWZ_SYSINFO_PUT_NCR_TYPE _IOW(NWZ_SYSINFO_TYPE, 15, unsigned int *) 43 + #define NWZ_SYSINFO_GET_SPK_TYPE _IOR(NWZ_SYSINFO_TYPE, 16, unsigned int *) 44 + #define NWZ_SYSINFO_PUT_SPK_TYPE _IOW(NWZ_SYSINFO_TYPE, 17, unsigned int *) 45 + #define NWZ_SYSINFO_GET_FMT_TYPE _IOR(NWZ_SYSINFO_TYPE, 18, unsigned int *) 46 + #define NWZ_SYSINFO_PUT_FMT_TYPE _IOW(NWZ_SYSINFO_TYPE, 19, unsigned int *) 47 + #define NWZ_SYSINFO_GET_OSG_TYPE _IOR(NWZ_SYSINFO_TYPE, 20, unsigned int *) 48 + #define NWZ_SYSINFO_PUT_OSG_TYPE _IOW(NWZ_SYSINFO_TYPE, 21, unsigned int *) 49 + #define NWZ_SYSINFO_GET_WAB_TYPE _IOR(NWZ_SYSINFO_TYPE, 22, unsigned int *) 50 + #define NWZ_SYSINFO_PUT_WAB_TYPE _IOW(NWZ_SYSINFO_TYPE, 23, unsigned int *) 51 + #define NWZ_SYSINFO_GET_TSP_TYPE _IOR(NWZ_SYSINFO_TYPE, 24, unsigned int *) 52 + #define NWZ_SYSINFO_PUT_TSP_TYPE _IOW(NWZ_SYSINFO_TYPE, 25, unsigned int *) 53 + #define NWZ_SYSINFO_GET_GSR_TYPE _IOR(NWZ_SYSINFO_TYPE, 26, unsigned int *) 54 + #define NWZ_SYSINFO_PUT_GSR_TYPE _IOW(NWZ_SYSINFO_TYPE, 27, unsigned int *) 55 + #define NWZ_SYSINFO_GET_MIC_TYPE _IOR(NWZ_SYSINFO_TYPE, 28, unsigned int *) 56 + #define NWZ_SYSINFO_PUT_MIC_TYPE _IOW(NWZ_SYSINFO_TYPE, 29, unsigned int *) 57 + #define NWZ_SYSINFO_GET_WMP_TYPE _IOR(NWZ_SYSINFO_TYPE, 30, unsigned int *) 58 + #define NWZ_SYSINFO_PUT_WMP_TYPE _IOW(NWZ_SYSINFO_TYPE, 31, unsigned int *) 59 + #define NWZ_SYSINFO_GET_SMS_TYPE _IOR(NWZ_SYSINFO_TYPE, 32, unsigned int *) 60 + #define NWZ_SYSINFO_PUT_SMS_TYPE _IOW(NWZ_SYSINFO_TYPE, 33, unsigned int *) 61 + #define NWZ_SYSINFO_GET_HCG_TYPE _IOR(NWZ_SYSINFO_TYPE, 34, unsigned int *) 62 + #define NWZ_SYSINFO_PUT_HCG_TYPE _IOW(NWZ_SYSINFO_TYPE, 35, unsigned int *) 63 + #define NWZ_SYSINFO_GET_RTC_TYPE _IOR(NWZ_SYSINFO_TYPE, 36, unsigned int *) 64 + #define NWZ_SYSINFO_PUT_RTC_TYPE _IOW(NWZ_SYSINFO_TYPE, 37, unsigned int *) 65 + #define NWZ_SYSINFO_GET_SDC_TYPE _IOR(NWZ_SYSINFO_TYPE, 38, unsigned int *) 66 + #define NWZ_SYSINFO_PUT_SDC_TYPE _IOW(NWZ_SYSINFO_TYPE, 39, unsigned int *) 67 + #define NWZ_SYSINFO_GET_SCG_TYPE _IOR(NWZ_SYSINFO_TYPE, 40, unsigned int *) 68 + #define NWZ_SYSINFO_PUT_SCG_TYPE _IOW(NWZ_SYSINFO_TYPE, 41, unsigned int *) 69 + #define NWZ_SYSINFO_GET_NFC_TYPE _IOR(NWZ_SYSINFO_TYPE, 42, unsigned int *) 70 + #define NWZ_SYSINFO_PUT_NFC_TYPE _IOW(NWZ_SYSINFO_TYPE, 43, unsigned int *) 71 + 72 + #endif /* __NWZ_SYSINFO_H__ */
+208
firmware/target/hosted/sonynwz/power-nwz.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 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 "system.h" 23 + #include "power-nwz.h" 24 + #include "button-target.h" 25 + #include <unistd.h> 26 + #include <sys/types.h> 27 + #include <sys/stat.h> 28 + #include <fcntl.h> 29 + #include <sys/ioctl.h> 30 + #include <string.h> 31 + #include <sys/reboot.h> 32 + 33 + static int power_fd = -1; /* file descriptor */ 34 + 35 + void power_init(void) 36 + { 37 + power_fd = open(NWZ_POWER_DEV, O_RDWR); 38 + } 39 + 40 + void power_close(void) 41 + { 42 + close(power_fd); 43 + } 44 + 45 + int nwz_power_get_status(void) 46 + { 47 + int status; 48 + if(ioctl(power_fd, NWZ_POWER_GET_STATUS, &status) < 0) 49 + return -1; 50 + return status; 51 + } 52 + 53 + static int nwz_power_adval_to_mv(int adval, int ad_base) 54 + { 55 + if(adval == -1) 56 + return -1; 57 + /* the AD base corresponds to the millivolt value if adval was 255 */ 58 + return (adval * ad_base) / 255; 59 + } 60 + 61 + int nwz_power_get_vbus_adval(void) 62 + { 63 + int status; 64 + if(ioctl(power_fd, NWZ_POWER_GET_VBUS_ADVAL, &status) < 0) 65 + return -1; 66 + return status; 67 + } 68 + 69 + int nwz_power_get_vbus_voltage(void) 70 + { 71 + return nwz_power_adval_to_mv(nwz_power_get_vbus_adval(), NWZ_POWER_AD_BASE_VBUS); 72 + } 73 + 74 + int nwz_power_get_vbus_limit(void) 75 + { 76 + int status; 77 + if(ioctl(power_fd, NWZ_POWER_GET_VBUS_LIMIT, &status) < 0) 78 + return -1; 79 + return status; 80 + } 81 + 82 + int nwz_power_get_charge_switch(void) 83 + { 84 + int status; 85 + if(ioctl(power_fd, NWZ_POWER_GET_CHARGE_SWITCH, &status) < 0) 86 + return -1; 87 + return status; 88 + } 89 + 90 + int nwz_power_get_charge_current(void) 91 + { 92 + int status; 93 + if(ioctl(power_fd, NWZ_POWER_GET_CHARGE_CURRENT, &status) < 0) 94 + return -1; 95 + return status; 96 + } 97 + 98 + int nwz_power_get_battery_gauge(void) 99 + { 100 + int status; 101 + if(ioctl(power_fd, NWZ_POWER_GET_BAT_GAUGE, &status) < 0) 102 + return -1; 103 + return status; 104 + } 105 + 106 + int nwz_power_get_battery_adval(void) 107 + { 108 + int status; 109 + if(ioctl(power_fd, NWZ_POWER_GET_BAT_ADVAL, &status) < 0) 110 + return -1; 111 + return status; 112 + } 113 + 114 + int nwz_power_get_battery_voltage(void) 115 + { 116 + return nwz_power_adval_to_mv(nwz_power_get_battery_adval(), NWZ_POWER_AD_BASE_VBAT); 117 + } 118 + 119 + int nwz_power_get_vbat_adval(void) 120 + { 121 + int status; 122 + if(ioctl(power_fd, NWZ_POWER_GET_VBAT_ADVAL, &status) < 0) 123 + return -1; 124 + return status; 125 + } 126 + 127 + int nwz_power_get_vbat_voltage(void) 128 + { 129 + return nwz_power_adval_to_mv(nwz_power_get_vbat_adval(), NWZ_POWER_AD_BASE_VBAT); 130 + } 131 + 132 + int nwz_power_get_sample_count(void) 133 + { 134 + int status; 135 + if(ioctl(power_fd, NWZ_POWER_GET_SAMPLE_COUNT, &status) < 0) 136 + return -1; 137 + return status; 138 + } 139 + 140 + int nwz_power_get_vsys_adval(void) 141 + { 142 + int status; 143 + if(ioctl(power_fd, NWZ_POWER_GET_VSYS_ADVAL, &status) < 0) 144 + return -1; 145 + return status; 146 + } 147 + 148 + int nwz_power_get_vsys_voltage(void) 149 + { 150 + return nwz_power_adval_to_mv(nwz_power_get_vsys_adval(), NWZ_POWER_AD_BASE_VSYS); 151 + } 152 + 153 + int nwz_power_get_acc_charge_mode(void) 154 + { 155 + int status; 156 + if(ioctl(power_fd, NWZ_POWER_GET_ACCESSARY_CHARGE_MODE, &status) < 0) 157 + return -1; 158 + return status; 159 + } 160 + 161 + int nwz_power_is_fully_charged(void) 162 + { 163 + int status; 164 + if(ioctl(power_fd, NWZ_POWER_IS_FULLY_CHARGED, &status) < 0) 165 + return -1; 166 + return status; 167 + } 168 + 169 + static int write_string_to_file(const char *file, const char *msg) 170 + { 171 + int fd = open(file, O_WRONLY); 172 + if(fd < 0) 173 + return -1; 174 + const int len = strlen(msg); 175 + int res = write(fd, msg, len); 176 + close(fd); 177 + return res == len ? 0 : -1; 178 + } 179 + 180 + int do_nwz_power_suspend(void) 181 + { 182 + /* older devices use /proc/pm, while the new one use the standard sys file */ 183 + if(write_string_to_file("/proc/pm", "S3") == 0) 184 + return 0; 185 + return write_string_to_file("/sys/power/state", "mem"); 186 + } 187 + 188 + int nwz_power_suspend(void) 189 + { 190 + int ret = do_nwz_power_suspend(); 191 + /* the button driver tracks button status using events, but the kernel does 192 + * not generate an event if a key is changed during suspend, so make sure we 193 + * reload as much information as possible */ 194 + nwz_button_reload_after_suspend(); 195 + return ret; 196 + } 197 + 198 + int nwz_power_shutdown(void) 199 + { 200 + sync(); /* man page advises to sync to avoid data loss */ 201 + return reboot(RB_POWER_OFF); 202 + } 203 + 204 + int nwz_power_restart(void) 205 + { 206 + sync(); /* man page advises to sync to avoid data loss */ 207 + return reboot(RB_AUTOBOOT); 208 + }
+69
firmware/target/hosted/sonynwz/powermgmt-nwz.c
··· 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 + #include "powermgmt.h" 21 + #include "power.h" 22 + #include "power-nwz.h" 23 + 24 + const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 25 + { 26 + 3470 27 + }; 28 + 29 + /* the OF shuts down at this voltage */ 30 + const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = 31 + { 32 + 3450 33 + }; 34 + 35 + /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ 36 + const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 37 + { 38 + { 3450, 3502, 3550, 3587, 3623, 3669, 3742, 3836, 3926, 4026, 4200 } 39 + }; 40 + 41 + /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ 42 + const unsigned short const percent_to_volt_charge[11] = 43 + { 44 + 3450, 3670, 3721, 3751, 3782, 3821, 3876, 3941, 4034, 4125, 4200 45 + }; 46 + 47 + unsigned int power_input_status(void) 48 + { 49 + unsigned pwr = 0; 50 + int sts = nwz_power_get_status(); 51 + if(sts & NWZ_POWER_STATUS_VBUS_DET) 52 + pwr |= POWER_INPUT_USB_CHARGER; 53 + if(sts & NWZ_POWER_STATUS_AC_DET) 54 + pwr |= POWER_INPUT_MAIN_CHARGER; 55 + return pwr; 56 + } 57 + 58 + int _battery_voltage(void) 59 + { 60 + /* the raw voltage is unstable on some devices, so use the average provided 61 + * by the driver */ 62 + return nwz_power_get_battery_voltage(); 63 + } 64 + 65 + bool charging_state(void) 66 + { 67 + return (nwz_power_get_status() & NWZ_POWER_STATUS_CHARGE_STATUS) == 68 + NWZ_POWER_STATUS_CHARGE_STATUS_CHARGING; 69 + }
+82
firmware/target/hosted/sonynwz/sonynwz.make
··· 1 + # __________ __ ___. 2 + # Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 + # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4 + # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 + # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 + # \/ \/ \/ \/ \/ 7 + # $Id$ 8 + # 9 + 10 + INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) 11 + 12 + SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) 13 + 14 + # bootloader build is sligtly different 15 + ifneq (,$(findstring bootloader,$(APPSDIR))) 16 + 17 + SRC += $(call preprocess, $(APPSDIR)/SOURCES) 18 + CLEANOBJS += $(BUILDDIR)/bootloader.* 19 + 20 + endif #bootloader 21 + 22 + .SECONDEXPANSION: # $$(OBJ) is not populated until after this 23 + 24 + # bootloader build is sligtly different 25 + ifneq (,$(findstring bootloader,$(APPSDIR))) 26 + 27 + # We install a second font along the bootloader because sysfont is too small 28 + # for our purpose 29 + BL_FONT = $(ROOTDIR)/fonts/27-Adobe-Helvetica.bdf 30 + 31 + # Limits for the bootloader sysfont: ASCII 32 + BL_MAXCHAR = 127 33 + 34 + # Function that adds a single file to a tar and explicitely set the name 35 + # in the archive (which can be completely different from the original filename) 36 + # their devices 37 + # arguments: 38 + # $(1) = tar file 39 + # $(2) = archive file name 40 + # $(3) = file to add 41 + tar_add_file = \ 42 + tar -Prf $(1) --transform="s|.*|$(strip $(2))|" $(3) 43 + 44 + $(BUILDDIR)/bootloader.fnt: $(BL_FONT) $(TOOLS) 45 + $(call PRINTS,CONVBDF $(subst $(ROOTDIR)/,,$<))$(TOOLSDIR)/convbdf -l $(MAXCHAR) -f -o $@ $< 46 + 47 + $(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS) 48 + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ 49 + -L$(BUILDDIR)/firmware -lfirmware \ 50 + -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ 51 + $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map 52 + 53 + $(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf $(BUILDDIR)/bootloader.fnt 54 + # NOTE: the install script will call a command like 55 + # tar -C $(ROOTFS_MOUNT_POINT) -f bootloader.tar 56 + # thus the names in the archive must be of the form ./absolute/path 57 + # 58 + # NOTE 2: Sony uses unusual user IDs (500 on somes devices, 1002 on others) 59 + # so make sure the files are readable/executable by anyone 60 + $(SILENT)rm -rf $(BUILDDIR)/bootloader.tar 61 + $(SILENT)$(call tar_add_file, $(BUILDDIR)/bootloader.tar,\ 62 + ./usr/local/bin/SpiderApp, \ 63 + $(BUILDDIR)/bootloader.elf) 64 + $(SILENT)$(call tar_add_file, $(BUILDDIR)/bootloader.tar, \ 65 + ./usr/local/share/rockbox/bootloader.fnt, \ 66 + $(BUILDDIR)/bootloader.fnt) 67 + $(call PRINTS,SCRAMBLE $(notdir $@))$(MKFIRMWARE) $(BUILDDIR)/bootloader.tar $@; 68 + 69 + else # bootloader 70 + 71 + $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) 72 + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ 73 + -L$(BUILDDIR)/firmware -lfirmware \ 74 + -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ 75 + -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ 76 + $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map 77 + 78 + $(BUILDDIR)/rockbox.sony : $(BUILDDIR)/rockbox.elf 79 + $(call PRINTS,OC $(@F))$(call objcopy,$^,$@) 80 + 81 + endif # bootloader 82 +
+204
firmware/target/hosted/sonynwz/system-nwz.c
··· 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 + #include <stdlib.h> 22 + #include <unistd.h> 23 + #include <signal.h> 24 + #include <ucontext.h> 25 + #include <string.h> 26 + #include "system.h" 27 + #include "lcd.h" 28 + #include "font.h" 29 + #include "logf.h" 30 + #include "system.h" 31 + #include "backlight-target.h" 32 + #include "button.h" 33 + #include "adc.h" 34 + #include "power.h" 35 + #include "power-nwz.h" 36 + #include <backtrace.h> 37 + #include <stdio.h> 38 + 39 + static const char **kern_mod_list; 40 + 41 + void power_off(void) 42 + { 43 + exit(0); 44 + } 45 + 46 + static void compute_kern_mod_list(void) 47 + { 48 + /* create empty list */ 49 + kern_mod_list = malloc(sizeof(const char **)); 50 + kern_mod_list[0] = NULL; 51 + /* read from proc file system */ 52 + FILE *f = fopen("/proc/modules", "r"); 53 + if(f == NULL) 54 + { 55 + printf("Cannot open /proc/modules"); 56 + return; 57 + } 58 + for(int i = 0;; i++) 59 + { 60 + /* the last entry of the list points to NULL so getline() will allocate 61 + * some memory */ 62 + size_t n; 63 + if(getline((char **)&kern_mod_list[i], &n, f) < 0) 64 + { 65 + /* make sure last entry is NULL and stop */ 66 + kern_mod_list[i] = NULL; 67 + break; 68 + } 69 + /* grow array */ 70 + kern_mod_list = realloc(kern_mod_list, (i + 2) * sizeof(const char **)); 71 + /* and fill last entry with NULL */ 72 + kern_mod_list[i + 1] = NULL; 73 + /* parse line to only keep module name */ 74 + char *p = strchr(kern_mod_list[i], ' '); 75 + if(p != NULL) 76 + *p = 0; /* stop at first blank */ 77 + } 78 + fclose(f); 79 + } 80 + 81 + static void print_kern_mod_list(void) 82 + { 83 + printf("Kernel modules:\n"); 84 + const char **p = kern_mod_list; 85 + while(*p) 86 + printf(" %s\n", *p++); 87 + } 88 + 89 + /* to make thread-internal.h happy */ 90 + uintptr_t *stackbegin; 91 + uintptr_t *stackend; 92 + 93 + static void nwz_sig_handler(int sig, siginfo_t *siginfo, void *context) 94 + { 95 + /* safe guard variable - we call backtrace() only on first 96 + * UIE call. This prevent endless loop if backtrace() touches 97 + * memory regions which cause abort 98 + */ 99 + static bool triggered = false; 100 + 101 + lcd_set_backdrop(NULL); 102 + lcd_set_drawmode(DRMODE_SOLID); 103 + lcd_set_foreground(LCD_BLACK); 104 + lcd_set_background(LCD_WHITE); 105 + unsigned line = 0; 106 + 107 + lcd_setfont(FONT_SYSFIXED); 108 + lcd_set_viewport(NULL); 109 + lcd_clear_display(); 110 + 111 + /* get context info */ 112 + ucontext_t *uc = (ucontext_t *)context; 113 + unsigned long pc = uc->uc_mcontext.arm_pc; 114 + unsigned long sp = uc->uc_mcontext.arm_sp; 115 + 116 + lcd_putsf(0, line++, "%s at %08x", strsignal(sig), pc); 117 + 118 + if(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) 119 + lcd_putsf(0, line++, "address 0x%08x", siginfo->si_addr); 120 + 121 + if(!triggered) 122 + { 123 + triggered = true; 124 + rb_backtrace(pc, sp, &line); 125 + } 126 + 127 + #ifdef ROCKBOX_HAS_LOGF 128 + lcd_putsf(0, line++, "logf:"); 129 + logf_panic_dump(&line); 130 + #endif 131 + 132 + lcd_update(); 133 + 134 + system_exception_wait(); /* If this returns, try to reboot */ 135 + system_reboot(); 136 + while (1); /* halt */ 137 + } 138 + 139 + void system_init(void) 140 + { 141 + int *s; 142 + /* fake stack, to make thread-internal.h happy */ 143 + stackbegin = stackend = (uintptr_t*)&s; 144 + /* catch some signals for easier debugging */ 145 + struct sigaction sa; 146 + sigfillset(&sa.sa_mask); 147 + sa.sa_flags = SA_SIGINFO; 148 + sa.sa_sigaction = &nwz_sig_handler; 149 + sigaction(SIGILL, &sa, NULL); 150 + sigaction(SIGABRT, &sa, NULL); 151 + sigaction(SIGFPE, &sa, NULL); 152 + sigaction(SIGSEGV, &sa, NULL); 153 + sigaction(SIGPIPE, &sa, NULL); 154 + sigaction(SIGTERM, &sa, NULL); 155 + sigaction(SIGBUS, &sa, NULL); 156 + sigaction(SIGTERM, &sa, NULL); 157 + compute_kern_mod_list(); 158 + print_kern_mod_list(); 159 + /* some init not done on hosted targets */ 160 + adc_init(); 161 + power_init(); 162 + } 163 + 164 + 165 + void system_reboot(void) 166 + { 167 + power_off(); 168 + } 169 + 170 + void system_exception_wait(void) 171 + { 172 + backlight_hw_on(); 173 + backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); 174 + /* wait until button press and release */ 175 + while(button_read_device() != 0) {} 176 + while(button_read_device() == 0) {} 177 + while(button_read_device() != 0) {} 178 + while(button_read_device() == 0) {} 179 + } 180 + 181 + int hostfs_init(void) 182 + { 183 + return 0; 184 + } 185 + 186 + int hostfs_flush(void) 187 + { 188 + sync(); 189 + return 0; 190 + } 191 + 192 + const char **nwz_get_kernel_module_list(void) 193 + { 194 + return kern_mod_list; 195 + } 196 + 197 + bool nwz_is_kernel_module_loaded(const char *name) 198 + { 199 + const char **p = kern_mod_list; 200 + while(*p) 201 + if(strcmp(*p++, name) == 0) 202 + return true; 203 + return false; 204 + }
+34
firmware/target/hosted/sonynwz/system-target.h
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2016 by 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 + 29 + /* get list of loaded kernel modules (computed once at init time), list is NULL 30 + * terminated */ 31 + const char **nwz_get_kernel_module_list(void); 32 + bool nwz_is_kernel_module_loaded(const char *name); 33 + 34 + #endif /* __SYSTEM_TARGET_H__ */
+1 -1
lib/unwarminder/SOURCES
··· 1 - backtrace.c 1 + backtrace-unwarminder.c 2 2 get_sp.S 3 3 unwarm_arm.c 4 4 unwarm.c
+1 -1
lib/unwarminder/backtrace.c lib/unwarminder/backtrace-unwarminder.c
··· 106 106 return TRUE; 107 107 } 108 108 109 - void backtrace(int pcAddr, int spAddr, unsigned *line) 109 + void rb_backtrace(int pcAddr, int spAddr, unsigned *line) 110 110 { 111 111 lcd_putsf(0, (*line)++, "pc:%08x sp:%08x", pcAddr, spAddr); 112 112 lcd_update();
+1 -1
lib/unwarminder/backtrace.h lib/unwarminder/backtrace-unwarminder.h
··· 49 49 50 50 extern const UnwindCallbacks cliCallbacks; 51 51 52 - void backtrace(int pcAddr, int spAddr, unsigned *line); 52 + void rb_backtrace(int pcAddr, int spAddr, unsigned *line); 53 53 54 54 #endif 55 55
+1
lib/unwarminder/unwarminder.make
··· 16 16 CORE_LIBS += $(UNWARMLIB) 17 17 18 18 INCLUDES += -I$(UNWARMLIB_DIR) 19 + DEFINES += -DBACKTRACE_UNWARMINDER 19 20 20 21 $(UNWARMLIB): $(UNWARMLIB_OBJ) 21 22 $(SILENT)$(shell rm -f $@)
+35
rbutil/mknwzboot/Makefile
··· 1 + # __________ __ ___. 2 + # Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 + # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4 + # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 + # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 + # \/ \/ \/ \/ \/ 7 + 8 + # We use the SB code available in the Rockbox utils/sbtools directory 9 + UPGTOOLS_DIR=../../utils/nwztools/upgtools/ 10 + CFLAGS += -I$(UPGTOOLS_DIR) -Wall 11 + # std=gnu99 is required by MinGW on Windows (c99 is sufficient for Linux / MXE) 12 + CFLAGS += -std=gnu99 -g -O3 13 + # dependencies 14 + # FIXME make it work for windows and maybe embed crypto++ 15 + LDOPTS += `pkg-config --libs libcrypto++` 16 + 17 + OUTPUT = mknwzboot 18 + 19 + # inputs for lib 20 + UPGTOOLS_SOURCES = misc.c upg.c fwp.c mg.cpp md5.cpp 21 + LIBSOURCES := mknwzboot.c install_script.c \ 22 + $(addprefix $(UPGTOOLS_DIR),$(UPGTOOLS_SOURCES)) 23 + # inputs for binary only 24 + SOURCES := $(LIBSOURCES) main.c 25 + # dependencies for binary 26 + EXTRADEPS := 27 + 28 + include ../libtools.make 29 + 30 + install_script.c install_script.h: install_script.sh $(BIN2C) 31 + $(BIN2C) install_script.sh install_script 32 + 33 + # explicit dependencies on install_script.{c,h} and mknwzboot.h 34 + $(OBJDIR)mknwzboot.o: install_script.h install_script.c mknwzboot.h 35 + $(OBJDIR)main.o: install_script.h install_script.c main.c mknwzboot.h
+142
rbutil/mknwzboot/install_script.sh
··· 1 + #!/bin/sh 2 + 3 + # The updater script on the NWZ has a major bug/feature: 4 + # it does NOT clear the update flag if the update scrit fails 5 + # thus causing a update/reboot loop and a bricked device 6 + # always clear to make sure we don't end up being screwed 7 + nvpflag fup 0xFFFFFFFF 8 + 9 + # go to /tmp 10 + cd /tmp 11 + 12 + # get content partition path 13 + CONTENTS="/contents" 14 + CONTENTS_PART=`mount | grep contents | awk '{ print $1 }'` 15 + 16 + lcdmsg -c -f /usr/local/bin/font_08x12.bmp -l 0,3 "Contents partition:\n$CONTENTS_PART" 17 + 18 + # We need to remount the contents partition in read-write mode be able to 19 + # write something on it 20 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,6 "Remount $CONTENTS rw" 21 + mount -o remount,rw $CONTENTS_PART $CONTENTS 22 + if [ "$?" != 0 ]; then 23 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: remount failed" 24 + sleep 3 25 + exit 0 26 + fi 27 + 28 + # redirect all output to a log file 29 + exec > "$CONTENTS/install_dualboot_log.txt" 2>&1 30 + 31 + # import constants 32 + . /install_script/constant.txt 33 + _UPDATE_FN_=`nvpstr ufn` 34 + ROOTFS_TMP_DIR=/tmp/rootfs 35 + SPIDERAPP_PATH=$ROOTFS_TMP_DIR/usr/local/bin/SpiderApp 36 + 37 + # mount root partition 38 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,7 "Mount root filesystem" 39 + mkdir $ROOTFS_TMP_DIR 40 + if [ "$?" != 0 ]; then 41 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mkdir failed" 42 + sleep 3 43 + exit 0 44 + fi 45 + 46 + # If there is an ext4 mounter, try it. Otherwise or on failure, try ext3 and 47 + # then ext2. 48 + # NOTE some platforms probably use an mtd and this might need some fixing 49 + if [ -e /usr/local/bin/icx_mount.ext4 ]; then 50 + /usr/local/bin/icx_mount.ext4 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR 51 + else 52 + false 53 + fi 54 + if [ "$?" != 0 ]; then 55 + mount -t ext3 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR 56 + fi 57 + if [ "$?" != 0 ]; then 58 + mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR 59 + fi 60 + if [ "$?" != 0 ]; then 61 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mount failed" 62 + sleep 3 63 + exit 0 64 + fi 65 + 66 + # rename the previous main application unless there is already a copy 67 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,8 "Backup OF" 68 + if [ ! -e $SPIDERAPP_PATH.of ]; then 69 + mv $SPIDERAPP_PATH $SPIDERAPP_PATH.of 70 + fi 71 + 72 + # extract our payload: the second file in the upgrade is a tar file 73 + # the files in the archive have paths of the form ./absolute/path and we extract 74 + # it at the rootfs mount it, so it can create/overwrite any file 75 + # 76 + # we need a small trick here: we want to pipe directly the output of the decryption 77 + # tool to tar, to avoid using space in /tmp/ or on the user partition 78 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,9 "Install rockbox" 79 + FIFO_FILE=/tmp/rb.fifo 80 + mkfifo $FIFO_FILE 81 + if [ "$?" != 0 ]; then 82 + umount "$ROOTFS_TMP_DIR" 83 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create fifo" 84 + sleep 3 85 + exit 0 86 + fi 87 + fwpchk -f /contents/$_UPDATE_FN_.UPG -c -1 $FIFO_FILE & 88 + #tar -tvf $FIFO_FILE 89 + tar -C $ROOTFS_TMP_DIR -xvf $FIFO_FILE 90 + if [ "$?" != 0 ]; then 91 + umount "$ROOTFS_TMP_DIR" 92 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: extraction failed" 93 + sleep 3 94 + exit 0 95 + fi 96 + # wait for fwpchk 97 + wait 98 + if [ "$?" != 0 ]; then 99 + umount "$ROOTFS_TMP_DIR" 100 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: no file to extract" 101 + sleep 3 102 + exit 0 103 + fi 104 + 105 + # create a symlink from /.rockbox to /contents/.rockbox (see dualboot code 106 + # for why) 107 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,10 "Create rockbox symlink" 108 + rm -f "$ROOTFS_TMP_DIR/.rockbox" 109 + ln -s "$CONTENTS/.rockbox" "$ROOTFS_TMP_DIR/.rockbox" 110 + if [ "$?" != 0 ]; then 111 + umount "$ROOTFS_TMP_DIR" 112 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: cannot create rockbox symlink" 113 + sleep 3 114 + exit 0 115 + fi 116 + 117 + # unmount root partition 118 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,11 "Unmount root filesystem" 119 + sync 120 + if [ "$?" != 0 ]; then 121 + umount "$ROOTFS_TMP_DIR" 122 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: sync failed" 123 + sleep 3 124 + exit 0 125 + fi 126 + 127 + umount $ROOTFS_TMP_DIR 128 + if [ "$?" != 0 ]; then 129 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: umount failed" 130 + sleep 3 131 + exit 0 132 + fi 133 + 134 + # Success screen 135 + lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "Rebooting in 3 seconds." 136 + sleep 3 137 + sync 138 + 139 + echo "Installation successful" 140 + # finish 141 + exit 0 142 +
+105
rbutil/mknwzboot/main.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2011 by 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 <getopt.h> 23 + #include <stdlib.h> 24 + #include <stdio.h> 25 + #include <string.h> 26 + #include "mknwzboot.h" 27 + 28 + static void usage(void) 29 + { 30 + printf("Usage: mknwzboot [options | file]...\n"); 31 + printf("Options:\n"); 32 + printf(" -h/--help Display this message\n"); 33 + printf(" -o <file> Set output file\n"); 34 + printf(" -b <file> Set boot file\n"); 35 + printf(" -d/--debug Enable debug output\n"); 36 + printf(" -x Dump device informations\n"); 37 + exit(1); 38 + } 39 + 40 + int main(int argc, char *argv[]) 41 + { 42 + char *outfile = NULL; 43 + char *bootfile = NULL; 44 + bool debug = false; 45 + 46 + if(argc == 1) 47 + usage(); 48 + 49 + while(1) 50 + { 51 + static struct option long_options[] = 52 + { 53 + {"help", no_argument, 0, 'h'}, 54 + {"out-file", required_argument, 0, 'o'}, 55 + {"boot-file", required_argument, 0, 'b'}, 56 + {"debug", no_argument, 0, 'd'}, 57 + {"dev-info", no_argument, 0, 'x'}, 58 + {0, 0, 0, 0} 59 + }; 60 + 61 + int c = getopt_long(argc, argv, "ho:b:dx", long_options, NULL); 62 + if(c == -1) 63 + break; 64 + switch(c) 65 + { 66 + case 'd': 67 + debug = true; 68 + break; 69 + case 'h': 70 + usage(); 71 + break; 72 + case 'o': 73 + outfile = optarg; 74 + break; 75 + case 'b': 76 + bootfile = optarg; 77 + break; 78 + case 'x': 79 + dump_nwz_dev_info(""); 80 + break; 81 + default: 82 + abort(); 83 + } 84 + } 85 + 86 + if(!outfile) 87 + { 88 + printf("You must specify an output file\n"); 89 + return 1; 90 + } 91 + if(!bootfile) 92 + { 93 + printf("You must specify a boot file\n"); 94 + return 1; 95 + } 96 + if(optind != argc) 97 + { 98 + printf("Extra arguments on command line\n"); 99 + return 1; 100 + } 101 + 102 + int err = mknwzboot(bootfile, outfile, debug); 103 + printf("Result: %d\n", err); 104 + return err; 105 + }
+230
rbutil/mknwzboot/mknwzboot.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2011 by 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 + #include <stdio.h> 22 + #include <stdlib.h> 23 + #include <stdarg.h> 24 + #include <string.h> 25 + #include <ctype.h> 26 + #include "mknwzboot.h" 27 + #include "upg.h" 28 + 29 + #include "install_script.h" 30 + 31 + struct nwz_model_desc_t 32 + { 33 + /* Descriptive name of this model */ 34 + const char *model_name; 35 + /* Model name used in the Rockbox header in ".sansa" files - these match the 36 + -add parameter to the "scramble" tool */ 37 + const char *rb_model_name; 38 + /* Model number used to initialise the checksum in the Rockbox header in 39 + ".sansa" files - these are the same as MODEL_NUMBER in config-target.h */ 40 + const int rb_model_num; 41 + /* Codename used in upgtool */ 42 + const char *codename; 43 + }; 44 + 45 + static const struct nwz_model_desc_t nwz_models[] = 46 + { 47 + { "Sony NWZ-E450 Series", "e450", 100, "nwz-e450" }, 48 + { "Sony NWZ-E460 Series", "e460", 101, "nwz-e460" }, 49 + { "Sony NWZ-E470 Series", "e470", 103, "nwz-e470" }, 50 + { "Sony NWZ-E580 Series", "e580", 102, "nwz-e580" }, 51 + { "Sony NWZ-A10 Series", "a10", 104, "nwz-a10" }, 52 + }; 53 + 54 + #define NR_NWZ_MODELS (sizeof(nwz_models) / sizeof(nwz_models[0])) 55 + 56 + void dump_nwz_dev_info(const char *prefix) 57 + { 58 + printf("%smknwzboot models:\n", prefix); 59 + for(int i = 0; i < NR_NWZ_MODELS; i++) 60 + { 61 + printf("%s %s: rb_model=%s rb_num=%d codename=%s\n", prefix, 62 + nwz_models[i].model_name, nwz_models[i].rb_model_name, 63 + nwz_models[i].rb_model_num, nwz_models[i].codename); 64 + } 65 + } 66 + 67 + /* read a file to a buffer */ 68 + static void *read_file(const char *file, size_t *size) 69 + { 70 + FILE *f = fopen(file, "rb"); 71 + if(f == NULL) 72 + { 73 + printf("[ERR] Cannot open file '%s' for reading: %m\n", file); 74 + return NULL; 75 + } 76 + fseek(f, 0, SEEK_END); 77 + *size = ftell(f); 78 + fseek(f, 0, SEEK_SET); 79 + void *buffer = malloc(*size); 80 + if(fread(buffer, *size, 1, f) != 1) 81 + { 82 + free(buffer); 83 + fclose(f); 84 + printf("[ERR] Cannot read file '%s': %m\n", file); 85 + return NULL; 86 + } 87 + fclose(f); 88 + return buffer; 89 + } 90 + 91 + /* write a file from a buffer */ 92 + static bool write_file(const char *file, void *buffer, size_t size) 93 + { 94 + FILE *f = fopen(file, "wb"); 95 + if(f == NULL) 96 + { 97 + printf("[ERR] Cannot open file '%s' for writing: %m\n", file); 98 + return false; 99 + } 100 + if(fwrite(buffer, size, 1, f) != 1) 101 + { 102 + fclose(f); 103 + printf("[ERR] Cannot write file '%s': %m\n", file); 104 + return false; 105 + } 106 + fclose(f); 107 + return true; 108 + } 109 + 110 + static unsigned int be2int(unsigned char* buf) 111 + { 112 + return ((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); 113 + } 114 + 115 + static int find_model(uint8_t *boot, size_t boot_size) 116 + { 117 + if(boot_size < 8) 118 + { 119 + printf("[ERR] Boot file is too small to be valid\n"); 120 + return -1; 121 + } 122 + /* find model by comparing magic scramble value */ 123 + int model = 0; 124 + for(; model < NR_NWZ_MODELS; model++) 125 + if(memcmp(boot + 4, nwz_models[model].rb_model_name, 4) == 0) 126 + break; 127 + if(model == NR_NWZ_MODELS) 128 + { 129 + printf("[ERR] This player is not supported: %.4s\n", boot + 4); 130 + return -1; 131 + } 132 + printf("[INFO] Bootloader file for %s\n", nwz_models[model].model_name); 133 + /* verify checksum */ 134 + uint32_t sum = nwz_models[model].rb_model_num; 135 + for(int i = 8; i < boot_size; i++) 136 + sum += boot[i]; 137 + if(sum != be2int(boot)) 138 + { 139 + printf("[ERR] Checksum mismatch\n"); 140 + return -1; 141 + } 142 + return model; 143 + } 144 + 145 + static bool get_model_keysig(int model, char key[NWZ_KEY_SIZE], char sig[NWZ_SIG_SIZE]) 146 + { 147 + const char *codename = nwz_models[model].codename; 148 + for(int i = 0; g_model_list[i].model; i++) 149 + if(strcmp(g_model_list[i].model, codename) == 0) 150 + { 151 + if(decrypt_keysig(g_model_list[i].kas, key, sig) == 0) 152 + return true; 153 + printf("[ERR] Cannot decrypt kas '%s'\n", g_model_list[i].kas); 154 + return false; 155 + } 156 + printf("[ERR] Codename '%s' matches to entry in upg database\n", codename); 157 + return false; 158 + } 159 + 160 + void nwz_printf(void *u, bool err, color_t c, const char *f, ...) 161 + { 162 + (void)err; 163 + (void)c; 164 + bool *debug = u; 165 + va_list args; 166 + va_start(args, f); 167 + if(err || *debug) 168 + vprintf(f, args); 169 + va_end(args); 170 + } 171 + 172 + static void *memdup(void *data, size_t size) 173 + { 174 + void *buf = malloc(size); 175 + memcpy(buf, data, size); 176 + return buf; 177 + } 178 + 179 + int mknwzboot(const char *bootfile, const char *outfile, bool debug) 180 + { 181 + size_t boot_size; 182 + uint8_t *boot = read_file(bootfile, &boot_size); 183 + if(boot == NULL) 184 + { 185 + printf("[ERR] Cannot open boot file\n"); 186 + return 1; 187 + } 188 + /* check that it is a valid scrambled file */ 189 + int model = find_model(boot, boot_size); 190 + if(model < 0) 191 + { 192 + free(boot); 193 + printf("[ERR] Invalid boot file\n"); 194 + return 2; 195 + } 196 + /* find keys */ 197 + char key[NWZ_KEY_SIZE]; 198 + char sig[NWZ_SIG_SIZE]; 199 + if(!get_model_keysig(model, key, sig)) 200 + { 201 + printf("[ERR][INTERNAL] Cannot get keys for model\n"); 202 + return 3; 203 + } 204 + /* create the upg file */ 205 + struct upg_file_t *upg = upg_new(); 206 + /* first file is the install script: we have to copy data because upg_free() 207 + * will free it */ 208 + upg_append(upg, memdup(install_script, LEN_install_script), LEN_install_script); 209 + /* second file is the bootloader content (expected to be a tar file): we have 210 + * to copy data because upg_free() will free it */ 211 + upg_append(upg, memdup(boot + 8, boot_size - 8), boot_size - 8); 212 + free(boot); 213 + /* write file to buffer */ 214 + size_t upg_size; 215 + void *upg_buf = upg_write_memory(upg, key, sig, &upg_size, &debug, nwz_printf); 216 + upg_free(upg); 217 + if(upg_buf == NULL) 218 + { 219 + printf("[ERR] Cannot create UPG file\n"); 220 + return 4; 221 + } 222 + if(!write_file(outfile, upg_buf, upg_size)) 223 + { 224 + free(upg_buf); 225 + printf("[ERR] Cannpt write UPG file\n"); 226 + return 5; 227 + } 228 + free(upg_buf); 229 + return 0; 230 + }
+141 -10
tools/configure
··· 706 706 GCCOPTS="$GCCOPTS -ffast-math -fsingle-precision-constant" 707 707 } 708 708 709 - ypr0cc () { 710 - 709 + arm1176jzlinuxcc () { 711 710 GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib//` 711 + # Although the ARM1176JZ-S supports unaligned accesses, those seems to disabled 712 + # by the kernel. Since GCC emits unaligned accesses by default on ARMv6, we 713 + # need to disable that 714 + GCCOPTS="$GCCOPTS -mcpu=arm1176jz-s -mno-unaligned-access -mfloat-abi=softfp" 712 715 GCCOPTIMIZE='' 713 716 LDOPTS="-lasound -lpthread -lm -ldl -lrt $LDOPTS" 714 - GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" 717 + GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" # warn about undefined symbols in shared libraries 715 718 SHARED_LDFLAG="-shared" 716 719 SHARED_CFLAGS='' 717 720 endian="little" ··· 721 724 GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" 722 725 723 726 # Set up compiler 724 - gccchoice="4.4.6" 725 - prefixtools "arm-ypr0-linux-gnueabi-" 727 + gccchoice="4.9.4" 728 + prefixtools "arm-rockbox-linux-gnueabi-" 729 + } 730 + 731 + ypr0cc () { 732 + arm1176jzlinuxcc 733 + app_type="ypr0" 734 + } 735 + 736 + sonynwzcc () { 737 + arm1176jzlinuxcc 738 + app_type="sonynwz" 726 739 } 727 740 728 741 androidcc () { ··· 1493 1506 202) Nokia N8xx 211) MA9C ==Sony== 1494 1507 203) Nokia N900 212) MA8 220) NWZ-E370/E380 series 1495 1508 204) Pandora 213) MA8C 221) NWZ-E360 series 1496 - 205) Samsung YP-R0 1497 - 206) Android MIPS ==IHIFI== ==iBasso== 1498 - 207) Android x86 230) 760 232) DX50 1499 - 208) Samsung YP-R1 231) 960 233) DX90 1500 - 1509 + 205) Samsung YP-R0 222) NWZ-E450 series 1510 + 206) Android MIPS ==IHIFI== 223) NWZ-E460 series 1511 + 207) Android x86 230) 760 224) NWZ-E470 series 1512 + 208) Samsung YP-R1 231) 960 225) NWZ-E580 series 1513 + 226) NWZ-A10 series 1514 + ==iBasso== 1515 + 232) DX50 1516 + 233) DX90 1501 1517 1502 1518 EOF 1503 1519 ··· 3851 3867 t_manufacturer="imx233" 3852 3868 t_model="sony-nwz" 3853 3869 arm926ejscc 3870 + ;; 3871 + 3872 + 222|sonynwze450) 3873 + application="yes" 3874 + target_id=96 3875 + modelname="sonynwze450" 3876 + target="SONY_NWZE450" 3877 + memory=16 3878 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 3879 + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 3880 + tool="cp" 3881 + output="rockbox.sony" 3882 + boottool="$rootdir/tools/scramble -add=e450" 3883 + bootoutput="bootloader-nwze450.sony" 3884 + appextra="gui:recorder" 3885 + plugins="" 3886 + swcodec="yes" 3887 + toolset=$genericbitmaptools 3888 + t_cpu="hosted" 3889 + t_manufacturer="sonynwz" 3890 + t_model="nwze450" 3891 + uname=`uname` 3892 + sonynwzcc 3893 + ;; 3894 + 3895 + 223|sonynwze460) 3896 + application="yes" 3897 + target_id=97 3898 + modelname="sonynwze460" 3899 + target="SONY_NWZE460" 3900 + memory=16 3901 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 3902 + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 3903 + tool="cp" 3904 + output="rockbox.sony" 3905 + boottool="$rootdir/tools/scramble -add=e460" 3906 + bootoutput="bootloader-nwze460.sony" 3907 + appextra="gui:recorder" 3908 + plugins="yes" 3909 + swcodec="yes" 3910 + toolset=$genericbitmaptools 3911 + t_cpu="hosted" 3912 + t_manufacturer="sonynwz" 3913 + t_model="nwze460" 3914 + uname=`uname` 3915 + sonynwzcc 3916 + ;; 3917 + 3918 + 224|sonynwze470) 3919 + application="yes" 3920 + target_id=100 3921 + modelname="sonynwze470" 3922 + target="SONY_NWZE470" 3923 + memory=16 3924 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 3925 + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 3926 + tool="cp" 3927 + output="rockbox.sony" 3928 + boottool="$rootdir/tools/scramble -add=e470" 3929 + bootoutput="bootloader-nwze470.sony" 3930 + appextra="gui:recorder" 3931 + plugins="" 3932 + swcodec="yes" 3933 + toolset=$genericbitmaptools 3934 + t_cpu="hosted" 3935 + t_manufacturer="sonynwz" 3936 + t_model="nwze470" 3937 + uname=`uname` 3938 + sonynwzcc 3939 + ;; 3940 + 3941 + 225|sonynwze580) 3942 + application="yes" 3943 + target_id=98 3944 + modelname="sonynwze580" 3945 + target="SONY_NWZE580" 3946 + memory=16 3947 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 3948 + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 3949 + tool="cp" 3950 + output="rockbox.sony" 3951 + boottool="$rootdir/tools/scramble -add=e580" 3952 + bootoutput="bootloader-nwze580.sony" 3953 + appextra="gui:recorder" 3954 + plugins="" 3955 + swcodec="yes" 3956 + toolset=$genericbitmaptools 3957 + t_cpu="hosted" 3958 + t_manufacturer="sonynwz" 3959 + t_model="nwze580" 3960 + uname=`uname` 3961 + sonynwzcc 3962 + ;; 3963 + 3964 + 226|sonynwza10) 3965 + application="yes" 3966 + target_id=101 3967 + modelname="sonynwza10" 3968 + target="SONY_NWZA10" 3969 + memory=16 3970 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" 3971 + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" 3972 + tool="cp" 3973 + output="rockbox.sony" 3974 + boottool="$rootdir/tools/scramble -add=a10" 3975 + bootoutput="bootloader-nwza10.sony" 3976 + appextra="gui:recorder" 3977 + plugins="" 3978 + swcodec="yes" 3979 + toolset=$genericbitmaptools 3980 + t_cpu="hosted" 3981 + t_manufacturer="sonynwz" 3982 + t_model="nwza10" 3983 + uname=`uname` 3984 + sonynwzcc 3854 3985 ;; 3855 3986 3856 3987 230|ihifi760)
+13 -2
tools/root.make
··· 73 73 include $(FIRMDIR)/firmware.make 74 74 include $(ROOTDIR)/apps/bitmaps/bitmaps.make 75 75 ifeq (arch_arm,$(ARCH)) 76 - include $(ROOTDIR)/lib/unwarminder/unwarminder.make 76 + # some targets don't use the unwarminder because they have the glibc backtrace 77 + ifeq (,$(filter sonynwz,$(APP_TYPE))) 78 + include $(ROOTDIR)/lib/unwarminder/unwarminder.make 79 + endif 77 80 endif 78 81 ifeq (,$(findstring bootloader,$(APPSDIR))) 79 82 include $(ROOTDIR)/lib/skin_parser/skin_parser.make ··· 98 101 endif 99 102 100 103 ifneq (,$(findstring bootloader,$(APPSDIR))) 101 - include $(APPSDIR)/bootloader.make 104 + ifneq (,$(findstring sonynwz,$(APP_TYPE))) 105 + include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make 106 + else 107 + include $(APPSDIR)/bootloader.make 108 + endif 102 109 else ifneq (,$(findstring bootbox,$(APPSDIR))) 103 110 include $(APPSDIR)/bootbox.make 104 111 else ifneq (,$(findstring checkwps,$(APP_TYPE))) ··· 130 137 131 138 ifneq (,$(findstring ypr1,$(APP_TYPE))) 132 139 include $(ROOTDIR)/firmware/target/hosted/samsungypr/ypr1/ypr1.make 140 + endif 141 + 142 + ifneq (,$(findstring sonynwz,$(APP_TYPE))) 143 + include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make 133 144 endif 134 145 135 146 ifneq (,$(findstring android_ndk, $(APP_TYPE)))
+12 -1
tools/scramble.c
··· 129 129 "\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n" 130 130 "\t 747p, x777, nn2g, m244, cli+, fuz2, hd20, hd30,\n" 131 131 "\t ip6g, rk27, clzp, zxf2, zxf3, fuz+, e370, e360,\n" 132 - "\t zxfi, zmoz, zen, zenv, ypz5, zxfs)\n"); 132 + "\t zxfi, zmoz, zen, zenv, ypz5, zxfs, e450, e460,\n" 133 + "\t e470,e580,a10)\n"); 133 134 printf("\nNo option results in Archos standard player/recorder format.\n"); 134 135 135 136 exit(1); ··· 382 383 modelnum = 90; 383 384 else if (!strcmp(&argv[1][5], "zxfs")) /* Creative ZEN X-Fi Style */ 384 385 modelnum = 94; 386 + else if (!strcmp(&argv[1][5], "e450")) /* Sony NWZ-E450 series */ 387 + modelnum = 100; 388 + else if (!strcmp(&argv[1][5], "e460")) /* Sony NWZ-E460 series */ 389 + modelnum = 101; 390 + else if (!strcmp(&argv[1][5], "e580")) /* Sony NWZ-E580 series */ 391 + modelnum = 102; 392 + else if (!strcmp(&argv[1][5], "e470")) /* Sony NWZ-E470 series */ 393 + modelnum = 103; 394 + else if (!strcmp(&argv[1][5], "a10")) /* Sony NW-A10 series */ 395 + modelnum = 104; 385 396 else { 386 397 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 387 398 return 2;
+3 -3
utils/nwztools/database/gen_db.py
··· 200 200 #endif /* __NWZ_DB_H__ */ 201 201 """ 202 202 203 - with open("nwz_db.h", "w") as fp: 203 + with open("nwz-db.h", "w") as fp: 204 204 fp.write(header_begin) 205 205 # generate list of all nvp nodes 206 206 for name in sorted(g_nvp_names): ··· 241 241 242 242 /** /!\ This file was automatically generated, DO NOT MODIFY IT DIRECTLY /!\ */ 243 243 244 - #include "nwz_db.h" 244 + #include "nwz-db.h" 245 245 246 246 struct nwz_model_info_t nwz_model[NWZ_MODEL_COUNT] = 247 247 { ··· 256 256 def codename_to_c(codename): 257 257 return re.sub('[^a-zA-Z0-9]', '_', codename, 0) 258 258 259 - with open("nwz_db.c", "w") as fp: 259 + with open("nwz-db.c", "w") as fp: 260 260 fp.write(impl_begin) 261 261 # generate model list (sort by mid) 262 262 for model in sorted(g_models, key = by_mid):
+1 -1
utils/nwztools/database/nwz_db.c firmware/target/hosted/sonynwz/nwz-db.c
··· 20 20 21 21 /** /!\ This file was automatically generated, DO NOT MODIFY IT DIRECTLY /!\ */ 22 22 23 - #include "nwz_db.h" 23 + #include "nwz-db.h" 24 24 25 25 struct nwz_model_info_t nwz_model[NWZ_MODEL_COUNT] = 26 26 {
utils/nwztools/database/nwz_db.h firmware/target/hosted/sonynwz/nwz-db.h
-31
utils/nwztools/plattools/Makefile
··· 1 - PREFIX?=arm-sony-linux-gnueabi- 2 - CC=$(PREFIX)gcc 3 - LD=$(PREFIX)gcc 4 - CFLAGS=-std=gnu99 -Wall -O2 5 - NWZ_DB_DIR=../database 6 - INCLUDES=-I. -I$(NWZ_DB_DIR) 7 - 8 - LIB_FILES=nwz_lib.c $(NWZ_DB_DIR)/nwz_db.c 9 - TOOL_FILES=dest_tool.c test_adc.c test_adc.c test_bl.c test_display.c \ 10 - test_keys.c test_power.c test_ts.c test_fb.c 11 - ALL_ELF=$(patsubst %.c,%.elf,$(TOOL_FILES)) all_tools.elf dualboot.elf 12 - 13 - all: $(ALL_ELF) 14 - 15 - # image dependency 16 - data/rockbox_icon.h data/tools_icon.h: 17 - make -C data 18 - 19 - dualboot.elf: data/rockbox_icon.h data/tools_icon.h 20 - 21 - %.elf: %.c $(LIB_FILES) 22 - $(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ 23 - 24 - all_tools.elf: all_tools.c $(TOOL_FILES) $(LIB_FILES) 25 - $(CC) $(CFLAGS) -DNWZ_EMBED_TOOLS $(INCLUDES) -o $@ $^ 26 - 27 - dualboot.elf: dualboot.c all_tools.c $(TOOL_FILES) $(LIB_FILES) 28 - $(CC) $(CFLAGS) -DNWZ_DUALBOOT -DNWZ_EMBED_TOOLS $(INCLUDES) -o $@ $^ 29 - 30 - clean: 31 - rm -rf $(ALL_ELF)
-27
utils/nwztools/plattools/README
··· 1 - Platform tools 2 - -------------- 3 - 4 - Those tools are designed to run on the devices. They are mostly tests that can 5 - be run in firmware upgrade mode (using exec_file in utils/nwztools/scripts/). To 6 - compile those, you will need the sony nwz cross compiler. The canonical way to 7 - run them is as follows: 8 - 9 - 1) Build the tools: 10 - cd /path/to/utils/nwztools/plattools 11 - make 12 - Note that the default cross compiler prefix is arm-sony-linux-gnueabi- but it 13 - can be changed using PREFIX: 14 - PREFIX="sony-nwz-linux-gnueabi-" make 15 - 16 - 2) Embed the wanted excutable in a firmware upgrade for your device. The README 17 - in utils/nwztools/scripts contains more documentation on how to select the right 18 - target. For example if you want to embed test_display for the NWZ-E460 series, 19 - you should run: 20 - cd /path/to/utils/nwztools/scripts 21 - make exec_file UPG=test_display_nwze46x.upg NWZ_TARGET=nwz-e46x EXEC=../plattools/test_display.elf 22 - 23 - 3) Put the upgrade file on the device and trigger a firmware upgrade. Assuming 24 - your NWZ device is /dev/sdb1 and is mounted at /media/pamaury/WALKMAN, run: 25 - cd /path/to/utils/nwztools/scripts 26 - make copy_fw_upgrade UPG=test_display_nwze46x.upg NWZ_MOUNT=/media/pamaury/WALKMAN/ 27 - sudo make do_fw_upgrade NWZ_DEV=/dev/sdb1
-133
utils/nwztools/plattools/all_tools.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 10 - * Copyright (C) 2011 by Amaury Pouly 11 - * 12 - * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing 13 - * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach 14 - * 15 - * This program is free software; you can redistribute it and/or 16 - * modify it under the terms of the GNU General Public License 17 - * as published by the Free Software Foundation; either version 2 18 - * of the License, or (at your option) any later version. 19 - * 20 - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 - * KIND, either express or implied. 22 - * 23 - ****************************************************************************/ 24 - #include "nwz_lib.h" 25 - #include "nwz_plattools.h" 26 - 27 - #define TOOL_LIST \ 28 - TOOL(dest_tool) \ 29 - TOOL(test_adc) \ 30 - TOOL(test_bl) \ 31 - TOOL(test_display) \ 32 - TOOL(test_keys) \ 33 - TOOL(test_power) \ 34 - TOOL(test_ts) \ 35 - TOOL(test_fb) \ 36 - 37 - typedef int (*nwz_tool_main_t)(int argc, char **argv); 38 - 39 - struct nwz_tool_t 40 - { 41 - const char *name; 42 - nwz_tool_main_t main; 43 - }; 44 - 45 - /* create list of extern definition */ 46 - #define TOOL(name) extern int NWZ_TOOL_MAIN(name)(int argc, char **argv); 47 - TOOL_LIST 48 - #undef TOOL 49 - 50 - /* create actual list */ 51 - #define TOOL(name) { #name, NWZ_TOOL_MAIN(name) }, 52 - static struct nwz_tool_t g_tools[] = 53 - { 54 - TOOL_LIST 55 - }; 56 - #undef TOOL 57 - 58 - #define NR_TOOLS (sizeof(g_tools) / sizeof(g_tools[0])) 59 - 60 - static void hello(void) 61 - { 62 - /* clear screen and display welcome message */ 63 - nwz_lcdmsg(true, 0, 0, "all_tools"); 64 - nwz_lcdmsg(false, 0, 1, "BACK: quit"); 65 - nwz_lcdmsg(false, 0, 2, "LEFT/RIGHT: change tool"); 66 - nwz_lcdmsg(false, 0, 3, "PLAY: run tool"); 67 - } 68 - 69 - /* this tool itself can be embedded in the dualboot */ 70 - #ifdef NWZ_DUALBOOT 71 - int NWZ_TOOL_MAIN(all_tools)(int argc, char **argv) 72 - #else 73 - int main(int argc, char **argv) 74 - #endif 75 - { 76 - hello(); 77 - /* open input device */ 78 - int input_fd = nwz_key_open(); 79 - if(input_fd < 0) 80 - { 81 - nwz_lcdmsg(false, 3, 5, "Cannot open input device"); 82 - sleep(2); 83 - return 1; 84 - } 85 - /* main loop */ 86 - int cur_tool = 0; 87 - while(true) 88 - { 89 - /* print tools */ 90 - int line = 5; 91 - for(size_t i = 0; i < NR_TOOLS; i++) 92 - { 93 - nwz_lcdmsgf(false, 0, line++, "%c %s", (i == cur_tool) ? '>' : ' ', 94 - g_tools[i].name); 95 - } 96 - /* wait for event (1000ms) */ 97 - int ret = nwz_key_wait_event(input_fd, 1000000); 98 - if(ret != 1) 99 - continue; 100 - struct input_event evt; 101 - if(nwz_key_read_event(input_fd, &evt) != 1) 102 - continue; 103 - /* only act on key release */ 104 - if(nwz_key_event_is_press(&evt)) 105 - continue; 106 - int keycode = nwz_key_event_get_keycode(&evt); 107 - if(keycode == NWZ_KEY_LEFT) 108 - { 109 - cur_tool--; 110 - if(cur_tool == -1) 111 - cur_tool += NR_TOOLS; 112 - } 113 - else if(keycode == NWZ_KEY_RIGHT) 114 - { 115 - cur_tool++; 116 - if(cur_tool == NR_TOOLS) 117 - cur_tool = 0; 118 - } 119 - else if(keycode == NWZ_KEY_PLAY) 120 - { 121 - /* close input */ 122 - nwz_key_close(input_fd); 123 - g_tools[cur_tool].main(argc, argv); 124 - /* reopen input and clear the screen */ 125 - input_fd = nwz_key_open(); 126 - hello(); 127 - } 128 - else if(keycode == NWZ_KEY_BACK) 129 - break; 130 - } 131 - nwz_key_close(input_fd); 132 - return 0; 133 - }
-8
utils/nwztools/plattools/data/Makefile
··· 1 - TOOLS_DIR=../../../../tools/ 2 - all: rockbox_icon.h tools_icon.h 3 - 4 - %.h: %.bmp 5 - $(TOOLS_DIR)/bmp2rb -f 4 $^ > $@ 6 - 7 - clean: 8 - rm -rf *.h
-334
utils/nwztools/plattools/data/Oxygen480-categories-preferences-system.svg
··· 1 - <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 - <!-- Created with Inkscape (http://www.inkscape.org/) --> 3 - <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="128" height="128" id="svg5676" sodipodi:version="0.32" inkscape:version="0.45+devel" sodipodi:docname="settings-wip.svgz" inkscape:output_extension="org.inkscape.output.svgz.inkscape" version="1.0"> 4 - <defs id="defs5678"> 5 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4322" id="linearGradient4338" gradientUnits="userSpaceOnUse" gradientTransform="translate(-2.6296821,21.172877)" x1="5.1934605" y1="88.98745" x2="5.1934605" y2="145.64882"/> 6 - <linearGradient y2="0" x2="28" y1="57.5" x1="28" gradientUnits="userSpaceOnUse" id="linearGradient8081"> 7 - <stop id="stop8083" style="stop-color:#ffd700;stop-opacity:1;" offset="0"/> 8 - <stop offset="0.25242719" style="stop-color:#ffea00;stop-opacity:1;" id="stop8087"/> 9 - <stop id="stop8085" style="stop-color:#b06d00;stop-opacity:1;" offset="1"/> 10 - </linearGradient> 11 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient8081" id="linearGradient7698" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.0872079,0,0,1.0872079,-59.143229,30.210796)" x1="58.557281" y1="107.76735" x2="63.943447" y2="107.76735"/> 12 - <linearGradient id="linearGradient6924"> 13 - <stop style="stop-color:#ffffff;stop-opacity:0.73885351;" offset="0" id="stop6926"/> 14 - <stop id="stop10395" offset="0.24999999" style="stop-color:#ffffff;stop-opacity:0;"/> 15 - <stop id="stop10393" offset="0.5" style="stop-color:#cccccc;stop-opacity:0;"/> 16 - <stop style="stop-color:#9a9a9a;stop-opacity:1;" offset="1" id="stop6928"/> 17 - </linearGradient> 18 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient6924" id="linearGradient6930" x1="8.3827581" y1="8.3199806" x2="15.021504" y2="14.958727" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.2050468,0,0,1.2050468,-2.1016162,-2.0259658)"/> 19 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4529" id="linearGradient4640" gradientUnits="userSpaceOnUse" x1="9.3031492" y1="133.25163" x2="-5.8540711" y2="130.59308"/> 20 - <filter inkscape:collect="always" x="-0.10337079" width="1.2067416" y="-0.10337079" height="1.2067416" id="filter4626"> 21 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.42488862" id="feGaussianBlur4628"/> 22 - </filter> 23 - <clipPath clipPathUnits="userSpaceOnUse" id="clipPath4632"> 24 - <rect style="opacity:0.83895126;fill:url(#linearGradient4636);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4626)" id="rect4634" width="13.334369" height="3.7415669" x="-2.9263651" y="130.97287" rx="0" ry="0" inkscape:transform-center-x="-16.434708" inkscape:transform-center-y="-5.5242717"/> 25 - </clipPath> 26 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4529" id="linearGradient4604" gradientUnits="userSpaceOnUse" x1="9.3031492" y1="133.25163" x2="-5.8540711" y2="130.59308"/> 27 - <radialGradient inkscape:collect="always" xlink:href="#linearGradient4434" id="radialGradient4602" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,0.3939752,0.4817163,48.449986)" cx="4.7494926" cy="132.25244" fx="4.7494926" fy="132.25244" r="5.3222656"/> 28 - <filter inkscape:collect="always" id="filter4584"> 29 - <feGaussianBlur inkscape:collect="always" stdDeviation="1.0829419" id="feGaussianBlur4586"/> 30 - </filter> 31 - <clipPath clipPathUnits="userSpaceOnUse" id="clipPath4588"> 32 - <path sodipodi:nodetypes="ccsccccsccc" id="path4590" d="M 13.037731,82.09273 L 18.342123,87.397123 C 21.331352,87.817882 24.407038,89.18508 26.895219,91.673261 C 29.411177,94.189215 30.893289,97.328601 31.294715,100.34972 L 56.289372,125.34436 C 62.090282,131.14528 77.301422,116.01036 71.462392,110.17133 L 46.467742,85.176682 C 43.446635,84.775254 40.307258,83.29314 37.791293,80.777186 C 35.303111,78.289007 33.935917,75.213314 33.515156,72.22409 L 28.210762,66.919697 L 13.037731,82.09273 z" style="opacity:1;fill:url(#linearGradient4592);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 33 - </clipPath> 34 - <filter inkscape:collect="always" id="filter4551"> 35 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.15501048" id="feGaussianBlur4553"/> 36 - </filter> 37 - <linearGradient inkscape:collect="always" id="linearGradient4529"> 38 - <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop4531"/> 39 - <stop style="stop-color:#ffffff;stop-opacity:0;" offset="1" id="stop4533"/> 40 - </linearGradient> 41 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4529" id="linearGradient4537" x1="9.3031492" y1="133.25163" x2="-5.8540711" y2="130.59308" gradientUnits="userSpaceOnUse"/> 42 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient2575" id="linearGradient4525" x1="58.557281" y1="107.76735" x2="63.943447" y2="107.76735" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.0872079,0,0,1.0872079,-71.164046,29.503688)"/> 43 - <linearGradient inkscape:collect="always" id="linearGradient4509"> 44 - <stop style="stop-color:#ffe900;stop-opacity:1;" offset="0" id="stop4511"/> 45 - <stop style="stop-color:#ffe900;stop-opacity:0;" offset="1" id="stop4513"/> 46 - </linearGradient> 47 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4509" id="linearGradient4515" x1="75.585938" y1="85.083641" x2="89.453125" y2="79.224266" gradientUnits="userSpaceOnUse"/> 48 - <filter inkscape:collect="always" id="filter4501"> 49 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.48665741" id="feGaussianBlur4503"/> 50 - </filter> 51 - <linearGradient inkscape:collect="always" id="linearGradient4465"> 52 - <stop style="stop-color:#ffa300;stop-opacity:1;" offset="0" id="stop4467"/> 53 - <stop style="stop-color:#ffa300;stop-opacity:0;" offset="1" id="stop4469"/> 54 - </linearGradient> 55 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4465" id="linearGradient4471" x1="83.886719" y1="77.661766" x2="86.300743" y2="86.671021" gradientUnits="userSpaceOnUse" gradientTransform="translate(-4,-4)"/> 56 - <linearGradient inkscape:collect="always" id="linearGradient4434"> 57 - <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop4436"/> 58 - <stop style="stop-color:#ffffff;stop-opacity:0;" offset="1" id="stop4438"/> 59 - </linearGradient> 60 - <radialGradient inkscape:collect="always" xlink:href="#linearGradient4434" id="radialGradient4440" cx="4.7494926" cy="132.25244" fx="4.7494926" fy="132.25244" r="5.3222656" gradientTransform="matrix(1,0,0,0.3939752,-7.0710881e-2,74.137847)" gradientUnits="userSpaceOnUse"/> 61 - <filter inkscape:collect="always" id="filter4404"> 62 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.15249406" id="feGaussianBlur4406"/> 63 - </filter> 64 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4322" id="linearGradient4342" gradientUnits="userSpaceOnUse" gradientTransform="translate(1.6836694,24.213436)" x1="3.5450988" y1="107.64014" x2="3.190912" y2="104.64899"/> 65 - <linearGradient inkscape:collect="always" id="linearGradient4322"> 66 - <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop4324"/> 67 - <stop style="stop-color:#ffffff;stop-opacity:0;" offset="1" id="stop4326"/> 68 - </linearGradient> 69 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4322" id="linearGradient4346" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,-2.6879854,-4.0690534)" x1="5.1934605" y1="103.9544" x2="5.1348171" y2="115.65614"/> 70 - <filter inkscape:collect="always" x="-0.074906364" width="1.1498127" y="-0.11235955" height="1.224719" id="filter4238"> 71 - <feGaussianBlur inkscape:collect="always" stdDeviation="1.1235955" id="feGaussianBlur4240"/> 72 - </filter> 73 - <clipPath clipPathUnits="userSpaceOnUse" id="clipPath4242"> 74 - <path sodipodi:nodetypes="ccsccccsccc" id="path4244" d="M -4,77.788157 L -4,83.381653 C -2.645772,85.179573 -1.744968,87.522089 -1.744968,90.145881 C -1.744968,92.798965 -2.618764,95.23565 -4,97.040192 L -4,123.39712 C -4,129.51419 12,129.55437 12,123.39712 L 12,97.040192 C 10.618764,95.23565 9.744972,92.798965 9.744968,90.145881 C 9.744968,87.522089 10.645776,85.179573 12,83.381653 L 12,77.788157 L -4,77.788157 z" style="opacity:1;fill:url(#linearGradient4247);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 75 - </clipPath> 76 - <linearGradient id="linearGradient2575" gradientUnits="userSpaceOnUse" x1="28" y1="57.5" x2="28" y2="0"> 77 - <stop offset="0" style="stop-color:#FFEA00" id="stop2577"/> 78 - <stop offset="1" style="stop-color:#cd8000;stop-opacity:1;" id="stop2579"/> 79 - </linearGradient> 80 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient2575" id="linearGradient4190" x1="36" y1="100" x2="28" y2="100" gradientUnits="userSpaceOnUse" spreadMethod="reflect" gradientTransform="matrix(0.9483145,-0.9483145,0.9483145,0.9483145,-36.790528,30.877897)"/> 81 - <linearGradient id="linearGradient6511"> 82 - <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop6513"/> 83 - <stop style="stop-color:#393939;stop-opacity:1;" offset="1" id="stop6515"/> 84 - </linearGradient> 85 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient6511" id="linearGradient6517" x1="38.074299" y1="4.2695875" x2="38.074299" y2="-10.42289" gradientUnits="userSpaceOnUse"/> 86 - <linearGradient id="linearGradient3916"> 87 - <stop style="stop-color:#d3d6d6;stop-opacity:1;" offset="0" id="stop3918"/> 88 - <stop style="stop-color:#f7f7f7;stop-opacity:1;" offset="1" id="stop3921"/> 89 - </linearGradient> 90 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient3916" id="linearGradient3943" gradientUnits="userSpaceOnUse" x1="34.165016" y1="4.863008" x2="34.165016" y2="-14.006344"/> 91 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient3904" id="linearGradient6112" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.1550511,0,0,1.1550511,-41.26484,21.101778)" x1="38.827515" y1="104.49192" x2="36.460194" y2="17.509802"/> 92 - <filter inkscape:collect="always" x="-0.26177245" width="1.5235449" y="-0.075698018" height="1.151396" id="filter3838"> 93 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.41890191" id="feGaussianBlur3840"/> 94 - </filter> 95 - <filter inkscape:collect="always" x="-0.26177242" width="1.5235448" y="-0.075698018" height="1.151396" id="filter3834"> 96 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.41890191" id="feGaussianBlur3836"/> 97 - </filter> 98 - <clipPath clipPathUnits="userSpaceOnUse" id="clipPath3850"> 99 - <path id="path3852" d="M 5.6835937,-4 C 6.7672977,-0.13901249 7.6835937,4 7.6835937,8 C 7.6835937,25.92781 15.683594,26.507796 15.683594,8 C 15.683594,4 16.274299,-0.44557713 17.683594,-4 C 16.034701,-11.286281 10.22872,-24.562662 5.6835937,-4 z" style="opacity:1;fill:#b4b4b4;fill-opacity:1;stroke:none;stroke-width:0.47008219;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" sodipodi:nodetypes="ccccc"/> 100 - </clipPath> 101 - <linearGradient id="linearGradient3904"> 102 - <stop style="stop-color:#141515;stop-opacity:1;" offset="0" id="stop3906"/> 103 - <stop style="stop-color:#535557;stop-opacity:0;" offset="1" id="stop3908"/> 104 - </linearGradient> 105 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient3904" id="linearGradient6119" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.1550511,0,0,1.1550511,-40.633471,-152.2263)" x1="36.460194" y1="108.28275" x2="39.503891" y2="69.41713"/> 106 - <linearGradient inkscape:collect="always" id="linearGradient3220"> 107 - <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop3222"/> 108 - <stop style="stop-color:#ffffff;stop-opacity:0;" offset="1" id="stop3224"/> 109 - </linearGradient> 110 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient3220" id="linearGradient6122" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.6737798,0,0,1.4175761,-25.92314,-147.94457)" x1="36.460194" y1="89.611626" x2="36.460194" y2="17.509802"/> 111 - <radialGradient gradientUnits="userSpaceOnUse" r="139.55859" cy="112.3047" cx="102" id="radialGradient9613"> 112 - <stop id="stop9615" style="stop-color:#535557" offset="0"/> 113 - <stop id="stop9617" style="stop-color:#898A8C" offset="0.13804179"/> 114 - <stop id="stop9619" style="stop-color:#ECECEC" offset="0.20296688"/> 115 - <stop id="stop9621" style="stop-color:#FAFAFA" offset="0.33539036"/> 116 - <stop id="stop9623" style="stop-color:#FFFFFF" offset="0.39464113"/> 117 - <stop id="stop9625" style="stop-color:#FAFAFA" offset="0.5313"/> 118 - <stop id="stop9627" style="stop-color:#EBECEC" offset="0.8449"/> 119 - <stop id="stop9629" style="stop-color:#E1E2E3" offset="1"/> 120 - </radialGradient> 121 - <linearGradient inkscape:collect="always" xlink:href="#radialGradient9613" id="linearGradient6125" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.8398488,-0.8398488,0.8167445,0.8167445,-15.712841,44.354581)" spreadMethod="reflect" x1="32.228344" y1="47.999996" x2="35.935673" y2="47.999996"/> 122 - <filter inkscape:collect="always" id="filter4503"> 123 - <feGaussianBlur inkscape:collect="always" stdDeviation="0.43775175" id="feGaussianBlur4505"/> 124 - </filter> 125 - <clipPath clipPathUnits="userSpaceOnUse" id="clipPath4092"> 126 - <path style="fill:#9c0f56" d="M 59.849,42.398 C 57.593,46.987 10.717,106.259 8.774,111.066 C 4.67,121.218 16.431,133.433 25.989,124.269 C 32.291,118.227 66.959,56.111 72.129,51.415 C 75.623,48.241 95.004,41.083 95.004,41.083 L 80.924,18.23 C 80.924,18.23 62.724,36.552 59.849,42.398 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="csssscc" id="path4094"/> 127 - </clipPath> 128 - <linearGradient id="XMLID_3_" gradientUnits="userSpaceOnUse" x1="11.9185" y1="119.0576" x2="98.418404" y2="44.057598"> 129 - <stop offset="0" style="stop-color:#C9C9C9" id="stop49"/> 130 - <stop offset="0.0229" style="stop-color:#B2B2B2" id="stop51"/> 131 - <stop offset="0.05" style="stop-color:#9F9F9F" id="stop53"/> 132 - <stop offset="0.0819" style="stop-color:#929292" id="stop55"/> 133 - <stop offset="0.1225" style="stop-color:#8A8A8A" id="stop57"/> 134 - <stop offset="0.2012" style="stop-color:#888888" id="stop59"/> 135 - <stop offset="1" style="stop-color:#686868;stop-opacity:1;" id="stop63"/> 136 - </linearGradient> 137 - <linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="31.4995" y1="80.0439" x2="32.347698" y2="80.671898" gradientTransform="translate(229.83849,405.96228)"> 138 - <stop offset="0" style="stop-color:#000000" id="stop183"/> 139 - <stop offset="1" style="stop-color:#000000;stop-opacity:0;" id="stop185"/> 140 - </linearGradient> 141 - <linearGradient id="XMLID_10_" gradientUnits="userSpaceOnUse" x1="23.9844" y1="120.7646" x2="12.7283" y2="109.8655" gradientTransform="translate(229.83849,405.96228)"> 142 - <stop offset="0" style="stop-color:#EEEEEE" id="stop176"/> 143 - <stop offset="1" style="stop-color:#535353;stop-opacity:1;" id="stop178"/> 144 - </linearGradient> 145 - <linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="18.776899" y1="129.5986" x2="18.776899" y2="114.6055" gradientTransform="translate(229.83849,405.96228)"> 146 - <stop offset="0" style="stop-color:#000000" id="stop169"/> 147 - <stop offset="1" style="stop-color:#000000;stop-opacity:0;" id="stop171"/> 148 - </linearGradient> 149 - <radialGradient id="XMLID_8_" cx="64.988297" cy="15.9429" r="19.6182" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)"> 150 - <stop offset="0" style="stop-color:#FFFFFF" id="stop162"/> 151 - <stop offset="1" style="stop-color:#888A85" id="stop164"/> 152 - </radialGradient> 153 - <linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="40.711899" y1="75.171898" x2="48.5495" y2="80.899803" gradientTransform="translate(229.83849,405.96228)"> 154 - <stop offset="0.213" style="stop-color:#555753" id="stop155"/> 155 - <stop offset="1" style="stop-color:#000000" id="stop157"/> 156 - </linearGradient> 157 - <linearGradient id="path30758_1_" gradientUnits="userSpaceOnUse" x1="16.7803" y1="80.697304" x2="67.723602" y2="80.697304" gradientTransform="translate(229.83849,405.96228)"> 158 - <stop offset="0" style="stop-color:#888888" id="stop149"/> 159 - <stop offset="0.8935" style="stop-color:#DDDDDD" id="stop151"/> 160 - </linearGradient> 161 - <linearGradient id="path34280_1_" gradientUnits="userSpaceOnUse" x1="93.023399" y1="39.3867" x2="93.023399" y2="25.928699" gradientTransform="translate(229.83849,405.96228)"> 162 - <stop offset="0" style="stop-color:#555555" id="stop141"/> 163 - <stop offset="0.3965" style="stop-color:#888888" id="stop143"/> 164 - <stop offset="1" style="stop-color:#555555" id="stop145"/> 165 - </linearGradient> 166 - <linearGradient id="rect22846_1_" gradientUnits="userSpaceOnUse" x1="247.60249" y1="-288.60791" x2="261.97269" y2="-288.60791" gradientTransform="matrix(0.9428,-0.2511,-0.2421,-0.9089,6.0921912,215.38258)"> 167 - <stop offset="0" style="stop-color:#888888" id="stop135"/> 168 - <stop offset="1" style="stop-color:#555555" id="stop137"/> 169 - </linearGradient> 170 - <radialGradient id="rect14944_1_" cx="274.56641" cy="36.065399" r="6.8733001" gradientTransform="matrix(0.523,-0.2146,-2.627,-7.0521,27.4228,356.0237)" gradientUnits="userSpaceOnUse"> 171 - <stop offset="0" style="stop-color:#888A85" id="stop127"/> 172 - <stop offset="0.6213" style="stop-color:#FFFFFF" id="stop129"/> 173 - <stop offset="1" style="stop-color:#555753" id="stop131"/> 174 - </radialGradient> 175 - <radialGradient id="rect14938_1_" cx="290.8428" cy="36.069801" r="6.8736" gradientTransform="matrix(0.4892,-0.2059,-2.5913,-7.0931,29.692,361.6149)" gradientUnits="userSpaceOnUse"> 176 - <stop offset="0" style="stop-color:#888A85" id="stop119"/> 177 - <stop offset="0.6213" style="stop-color:#FFFFFF" id="stop121"/> 178 - <stop offset="1" style="stop-color:#555753" id="stop123"/> 179 - </radialGradient> 180 - <radialGradient id="rect10553_1_" cx="292.49219" cy="43.388699" r="6.8727999" gradientTransform="matrix(0.498,-0.2212,-2.9368,-8.3284,56.2613,466.2682)" gradientUnits="userSpaceOnUse"> 181 - <stop offset="0" style="stop-color:#888A85" id="stop111"/> 182 - <stop offset="0.6213" style="stop-color:#FFFFFF" id="stop113"/> 183 - <stop offset="1" style="stop-color:#555753" id="stop115"/> 184 - </radialGradient> 185 - <radialGradient id="rect14950_1_" cx="92.734398" cy="20.4307" r="4.1451998" gradientTransform="matrix(0.6131,-0.2916,-5.2659,-7.9645,125.0096,227.992)" gradientUnits="userSpaceOnUse"> 186 - <stop offset="0" style="stop-color:#FFFFFF" id="stop103"/> 187 - <stop offset="0.5266" style="stop-color:#BABDB6" id="stop105"/> 188 - <stop offset="1" style="stop-color:#888A85" id="stop107"/> 189 - </radialGradient> 190 - <radialGradient id="rect10551_3_" cx="78.776398" cy="44.608398" r="14.3205" gradientUnits="userSpaceOnUse"> 191 - <stop offset="0" style="stop-color:#2E3436" id="stop95"/> 192 - <stop offset="0.72189999" style="stop-color:#000000;stop-opacity:1;" id="stop97"/> 193 - <stop offset="1" style="stop-color:#2E3436" id="stop99"/> 194 - </radialGradient> 195 - <linearGradient id="rect10551_1_" gradientUnits="userSpaceOnUse" x1="77.216797" y1="44.765598" x2="73.449203" y2="30.555201"> 196 - <stop offset="0.7219" style="stop-color:#DDDDDD" id="stop89"/> 197 - <stop offset="1" style="stop-color:#EEEEEC" id="stop91"/> 198 - </linearGradient> 199 - <radialGradient id="XMLID_6_" cx="77.004028" cy="13.140214" r="64.405701" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" fx="77.004028" fy="13.140214"> 200 - <stop offset="0" style="stop-color:#FFFFFF" id="stop82"/> 201 - <stop id="stop13256" style="stop-color:#c3c4c2;stop-opacity:1;" offset="0.5"/> 202 - <stop offset="1" style="stop-color:#000000;stop-opacity:1;" id="stop84"/> 203 - </radialGradient> 204 - <linearGradient id="XMLID_5_" gradientUnits="userSpaceOnUse" x1="15.7207" y1="125.7861" x2="24.9356" y2="108.3428" gradientTransform="translate(-80,0)"> 205 - <stop offset="0" style="stop-color:#000000" id="stop75"/> 206 - <stop offset="0.8935" style="stop-color:#FFFFFF" id="stop77"/> 207 - </linearGradient> 208 - <linearGradient id="XMLID_4_" gradientUnits="userSpaceOnUse" x1="40.527802" y1="55.75" x2="52.981899" y2="64.646004" gradientTransform="translate(-80,0)"> 209 - <stop offset="0" style="stop-color:#ffffff;stop-opacity:0;" id="stop68"/> 210 - <stop offset="0.8935" style="stop-color:#FFFFFF" id="stop70"/> 211 - </linearGradient> 212 - <linearGradient id="path2388_1_" gradientUnits="userSpaceOnUse" x1="14.9214" y1="124.6768" x2="107.7549" y2="-17.989599" gradientTransform="translate(229.83849,405.96228)"> 213 - <stop offset="0" style="stop-color:#DDDDDD" id="stop32"/> 214 - <stop offset="0.6864" style="stop-color:#888888" id="stop34"/> 215 - <stop offset="0.8935" style="stop-color:#DDDDDD" id="stop36"/> 216 - </linearGradient> 217 - <radialGradient id="path5936_1_" cx="172.123" cy="4.7476001" r="4.6967001" gradientTransform="matrix(6.7917,-1.4855,-1.2014,-5.506,-845.12621,725.19548)" gradientUnits="userSpaceOnUse"> 218 - <stop offset="0" style="stop-color:#FFFFFF" id="stop26"/> 219 - <stop offset="1" style="stop-color:#3E3E3E" id="stop28"/> 220 - </radialGradient> 221 - <linearGradient id="XMLID_1_" gradientUnits="userSpaceOnUse" x1="92.627899" y1="26.589399" x2="104.5325" y2="31.2349" gradientTransform="translate(229.83849,405.96228)"> 222 - <stop offset="0" style="stop-color:#FFFFFF" id="stop19"/> 223 - <stop offset="0.6391" style="stop-color:#888888" id="stop21"/> 224 - </linearGradient> 225 - <linearGradient id="rect25493_1_" gradientUnits="userSpaceOnUse" x1="258.88379" y1="-326.0903" x2="286.16019" y2="-287.6532" gradientTransform="matrix(0.9065,-0.2414,-0.2421,-0.9089,10.723991,214.40698)"> 226 - <stop offset="0" style="stop-color:#555555" id="stop5"/> 227 - <stop offset="0.6864" style="stop-color:#888888" id="stop7"/> 228 - </linearGradient> 229 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_5_" id="linearGradient10549" gradientUnits="userSpaceOnUse" gradientTransform="translate(-80,0)" x1="15.7207" y1="125.7861" x2="24.9356" y2="108.3428"/> 230 - <mask maskUnits="userSpaceOnUse" id="mask10545"> 231 - <path style="fill:url(#linearGradient10549)" id="path10547" d="M -0.051,18.554 L -0.847,9.66 C -0.847,9.66 8.141,4.482 10.38,3.193 C 3.985,-0.79 -3.654,1.07 -3.741,1.093 C -10.903,2.996 -15.908,8.865 -15.908,15.222 C -15.908,15.461 -15.901,15.701 -15.887,15.94 C -15.887,15.941 -15.887,15.941 -15.887,15.942 C -15.887,16.299 -16.25,36.73 -19.253,42.838 C -20.334,45.036 -30.401,58.18 -42.058,73.4 C -54.195,89.247 -69.3,108.968 -70.298,111.44 C -70.839,112.778 -71.079,114.126 -71.079,115.435 C -71.079,119.221 -69.06,122.663 -66.483,124.621 C -66.083,123.92 -65.655,123.178 -65.197,122.392 C -67.02,121.101 -68.463,119.074 -68.895,116.783 C -69.291,114.687 -68.831,112.48 -67.631,110.726 C -66.46,109.013 -64.659,107.855 -62.561,107.463 C -60.935,107.16 -59.182,107.593 -57.621,108.682 C -57.428,108.817 -57.245,108.966 -57.063,109.118 C -46.315,92.233 -27.938,65.35 3.195,23.824 C 1.323,20.784 -0.051,18.554 -0.051,18.554 z"/> 232 - </mask> 233 - <linearGradient inkscape:collect="always" xlink:href="#rect25493_1_" id="linearGradient11382" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.9065,-0.2414,-0.2421,-0.9089,10.723991,214.40698)" x1="258.88379" y1="-326.0903" x2="286.16019" y2="-287.6532"/> 234 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_1_" id="linearGradient11384" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="92.627899" y1="26.589399" x2="104.5325" y2="31.2349"/> 235 - <radialGradient inkscape:collect="always" xlink:href="#path5936_1_" id="radialGradient11386" gradientUnits="userSpaceOnUse" gradientTransform="matrix(6.7917,-1.4855,-1.2014,-5.506,-845.12621,725.19548)" cx="172.123" cy="4.7476001" r="4.6967001"/> 236 - <linearGradient inkscape:collect="always" xlink:href="#path2388_1_" id="linearGradient11388" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="14.9214" y1="124.6768" x2="107.7549" y2="-17.989599"/> 237 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_4_" id="linearGradient11390" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="77.040016" y1="14.124305" x2="92.612343" y2="4.8821697"/> 238 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_4_" id="linearGradient11392" gradientUnits="userSpaceOnUse" gradientTransform="translate(-80,0)" x1="40.527802" y1="55.75" x2="52.981899" y2="64.646004"/> 239 - <radialGradient inkscape:collect="always" xlink:href="#XMLID_6_" id="radialGradient11394" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.4337031,0.4442839,-0.7150071,0.6987259,282.84098,375.70944)" cx="77.004028" cy="13.140214" fx="77.004028" fy="13.140214" r="64.405701"/> 240 - <linearGradient inkscape:collect="always" xlink:href="#rect10551_1_" id="linearGradient11396" gradientUnits="userSpaceOnUse" x1="77.216797" y1="44.765598" x2="73.449203" y2="30.555201"/> 241 - <radialGradient inkscape:collect="always" xlink:href="#rect10551_3_" id="radialGradient11398" gradientUnits="userSpaceOnUse" cx="78.776398" cy="44.608398" r="14.3205"/> 242 - <radialGradient inkscape:collect="always" xlink:href="#rect14950_1_" id="radialGradient11400" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.6131,-0.2916,-5.2659,-7.9645,125.0096,227.992)" cx="92.734398" cy="20.4307" r="4.1451998"/> 243 - <radialGradient inkscape:collect="always" xlink:href="#rect10553_1_" id="radialGradient11402" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.498,-0.2212,-2.9368,-8.3284,56.2613,466.2682)" cx="292.49219" cy="43.388699" r="6.8727999"/> 244 - <radialGradient inkscape:collect="always" xlink:href="#rect14938_1_" id="radialGradient11404" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.4892,-0.2059,-2.5913,-7.0931,29.692,361.6149)" cx="290.8428" cy="36.069801" r="6.8736"/> 245 - <radialGradient inkscape:collect="always" xlink:href="#rect14944_1_" id="radialGradient11406" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.523,-0.2146,-2.627,-7.0521,27.4228,356.0237)" cx="274.56641" cy="36.065399" r="6.8733001"/> 246 - <linearGradient inkscape:collect="always" xlink:href="#rect22846_1_" id="linearGradient11408" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.9428,-0.2511,-0.2421,-0.9089,6.0921912,215.38258)" x1="247.60249" y1="-288.60791" x2="261.97269" y2="-288.60791"/> 247 - <linearGradient inkscape:collect="always" xlink:href="#path34280_1_" id="linearGradient11410" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="93.023399" y1="39.3867" x2="93.023399" y2="25.928699"/> 248 - <linearGradient inkscape:collect="always" xlink:href="#path30758_1_" id="linearGradient11412" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="16.7803" y1="80.697304" x2="67.723602" y2="80.697304"/> 249 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_7_" id="linearGradient11414" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="40.711899" y1="75.171898" x2="48.5495" y2="80.899803"/> 250 - <radialGradient inkscape:collect="always" xlink:href="#XMLID_8_" id="radialGradient11416" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" cx="64.988297" cy="15.9429" r="19.6182"/> 251 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_9_" id="linearGradient11418" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="18.776899" y1="129.5986" x2="18.776899" y2="114.6055"/> 252 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_10_" id="linearGradient11420" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="17.509325" y1="123.23078" x2="18.875885" y2="107.20945"/> 253 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_11_" id="linearGradient11422" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="31.4995" y1="80.0439" x2="32.347698" y2="80.671898"/> 254 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_3_" id="linearGradient11424" gradientUnits="userSpaceOnUse" x1="11.9185" y1="119.0576" x2="98.418404" y2="44.057598"/> 255 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4529" id="linearGradient11510" gradientUnits="userSpaceOnUse" x1="9.3031492" y1="133.25163" x2="-5.8540711" y2="130.59308"/> 256 - <linearGradient inkscape:collect="always" xlink:href="#linearGradient4529" id="linearGradient11512" gradientUnits="userSpaceOnUse" x1="9.3031492" y1="133.25163" x2="-5.8540711" y2="130.59308"/> 257 - <filter inkscape:collect="always" id="filter11957"> 258 - <feGaussianBlur inkscape:collect="always" stdDeviation="2.339831" id="feGaussianBlur11959"/> 259 - </filter> 260 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_4_" id="linearGradient12019" gradientUnits="userSpaceOnUse" gradientTransform="translate(-80,0)" x1="40.527802" y1="55.75" x2="52.981899" y2="64.646004"/> 261 - <linearGradient inkscape:collect="always" xlink:href="#path34280_1_" id="linearGradient12037" gradientUnits="userSpaceOnUse" gradientTransform="translate(229.83849,405.96228)" x1="93.023399" y1="39.3867" x2="93.023399" y2="25.928699"/> 262 - <linearGradient inkscape:collect="always" xlink:href="#XMLID_3_" id="linearGradient12051" gradientUnits="userSpaceOnUse" x1="11.9185" y1="119.0576" x2="98.418404" y2="44.057598"/> 263 - <filter inkscape:collect="always" id="filter12490"> 264 - <feGaussianBlur inkscape:collect="always" stdDeviation="2.3509538" id="feGaussianBlur12492"/> 265 - </filter> 266 - </defs> 267 - <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="13" inkscape:cy="18.5" inkscape:document-units="px" inkscape:current-layer="g11357" inkscape:window-width="1024" inkscape:window-height="697" inkscape:window-x="0" inkscape:window-y="0" height="128px" width="128px"/> 268 - <metadata id="metadata5681"> 269 - <rdf:RDF> 270 - <cc:Work rdf:about=""> 271 - <dc:format>image/svg+xml</dc:format> 272 - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> 273 - </cc:Work> 274 - </rdf:RDF> 275 - </metadata> 276 - <g inkscape:label="Livello 1" inkscape:groupmode="layer" id="layer1"> 277 - <path style="fill:#000000;fill-opacity:1;filter:url(#filter12490);opacity:0.8" d="M 97.46875,6 C 97.18152,6.0094408 97.00831,6.0304757 97,6.03125 C 88.50154,6.7547259 81.81102,12.649899 80.96875,19.9375 C 80.96299,19.970198 76.86754,40.857308 72.875,46.3125 C 69.74177,50.594872 11.13376,102.7197 8.28125,107.28125 C 6.43475,110.23375 6.09196,113.64754 6.8125,116.75 C 6.81481,116.75995 6.81016,116.77131 6.8125,116.78125 C 7.27817,118.76618 8.16525,120.60725 9.40625,122.125 C 9.47154,122.20534 9.55786,122.26531 9.625,122.34375 C 9.73846,122.47566 9.85017,122.62373 9.96875,122.75 C 10.13123,122.9234 10.29696,123.08786 10.46875,123.25 C 10.78531,123.54834 11.12253,123.83716 11.46875,124.09375 C 11.51009,124.12442 11.55201,124.15746 11.59375,124.1875 C 11.75577,124.30387 11.92581,124.39345 12.09375,124.5 C 12.34901,124.66192 12.60676,124.83089 12.875,124.96875 C 12.90463,124.98396 12.93897,124.98509 12.96875,125 C 13.16389,125.09785 13.36099,125.19684 13.5625,125.28125 C 13.66656,125.32459 13.76932,125.36661 13.875,125.40625 C 13.96058,125.43847 14.03838,125.47026 14.125,125.5 C 14.26755,125.5489 14.41722,125.58297 14.5625,125.625 C 15.11282,125.78408 15.69527,125.91534 16.28125,125.96875 C 16.62585,125.99943 16.98844,126.00883 17.34375,126 C 17.49276,125.99631 17.6305,125.97967 17.78125,125.96875 C 18.30718,125.93117 18.83023,125.84877 19.375,125.71875 C 19.49773,125.68971 19.62642,125.65895 19.75,125.625 C 19.94658,125.5707 20.14518,125.50448 20.34375,125.4375 C 20.68974,125.32116 21.02361,125.18743 21.375,125.03125 C 21.51637,124.96837 21.67036,124.91327 21.8125,124.84375 C 22.01661,124.74364 22.23195,124.64533 22.4375,124.53125 C 22.50876,124.4917 22.58484,124.44751 22.65625,124.40625 C 22.93651,124.24411 23.21755,124.06393 23.5,123.875 C 23.72992,123.72139 24.01123,123.49888 24.3125,123.25 C 24.51715,123.08053 24.76474,122.86659 25,122.65625 C 25.31217,122.37641 25.73134,121.97195 26.09375,121.625 C 26.40496,121.32709 26.7476,121.00087 27.09375,120.65625 C 27.10095,120.64393 27.11785,120.63734 27.125,120.625 C 40.39609,107.39872 78.3196,61.213642 83.8125,57.75 C 87.95646,55.136652 109.0625,51.3125 109.0625,51.3125 C 113.21925,49.41573 118.90506,43.445638 121.3125,34.4375 C 121.72869,32.077134 121.4811,29.596922 121.375,30.03125 L 108.59375,35.78125 L 100.21875,29.0625 L 98.78125,25.40625 L 99.28125,19.21875 L 113.34375,13.96875 L 113.125,12.15625 C 107.67312,6.0868239 99.47934,5.9339145 97.46875,6 z M 17.8125,106.1875 C 21.2472,106.15572 24.40096,109.89596 24.375,114.15625 C 24.3535,117.67982 20.93573,121.18715 17.5,121.21875 C 14.06408,121.25138 10.73518,117.39784 10.6875,113.53125 C 10.68465,113.29896 10.66822,113.04283 10.6875,112.8125 C 10.70682,112.58223 10.74047,112.35167 10.78125,112.125 C 10.90349,111.44483 11.13404,110.80542 11.4375,110.1875 C 11.53867,109.98155 11.63003,109.78948 11.75,109.59375 C 12.94961,107.63625 15.09816,106.21329 17.8125,106.1875 z" id="path11963"/> 278 - <g id="g11357" transform="matrix(1.0223499,0.1802679,-0.1801715,1.0218034,-142.50883,-466.04399)"> 279 - <path style="fill:url(#linearGradient11382)" d="M 322.52649,444.25728 C 326.15949,443.01428 332.35849,434.45128 332.98149,424.78428 C 333.00949,424.35428 333.65649,426.67828 333.65649,428.98828 C 332.87949,437.94128 328.47049,444.55028 324.84449,447.04628 L 322.52649,444.25728 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="csssc" id="rect25493"/> 280 - <path style="fill:#888a85" d="M 332.98149,424.78428 L 321.82849,432.38828 L 312.74849,427.41628 C 312.08149,428.88428 315.95449,447.98028 320.22749,446.96228 C 328.04849,445.09828 332.16349,435.78528 332.98149,424.78428 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="cccsc" id="path3285"/> 281 - <path style="fill:url(#linearGradient11384)" id="path23" d="M 322.07549,432.68428 L 323.06949,441.37828 L 324.97749,444.59028 C 326.91449,443.03428 328.49449,440.87628 329.72849,438.28428 C 331.33649,434.63428 332.30349,430.21428 332.65649,425.47228 L 322.07549,432.68428 z" enable-background="new "/> 282 - <path style="opacity:0.51380005;fill:url(#radialGradient11386)" d="M 313.59749,428.19228 C 313.59449,428.19728 313.57749,428.21928 313.57649,428.22628 C 313.57149,428.23928 313.56449,428.27228 313.56049,428.28828 C 313.04649,430.36728 316.00549,448.15728 320.19449,447.15928 C 321.12049,446.93828 322.00949,446.60928 322.83249,446.18928 L 320.58049,431.94628 L 313.59749,428.19228 z" enable-background="new " inkscape:r_cy="true" inkscape:r_cx="true" id="path5936"/> 283 - <path style="fill:url(#linearGradient11388)" d="M 305.84149,406.08928 C 297.90049,408.19828 292.53349,414.90528 292.95349,421.96328 C 292.95349,421.99528 292.56249,442.51428 289.68749,448.36028 C 287.43149,452.94928 240.55549,512.22128 238.61249,517.02828 C 234.50849,527.18028 246.26949,539.39528 255.82749,530.23128 C 262.12949,524.18928 296.79749,462.07328 301.96749,457.37728 C 305.46149,454.20328 324.84249,447.04528 324.84249,447.04528 L 310.76249,424.19228 L 310.04449,416.17028 L 322.15949,409.19128 C 315.08849,403.65028 305.90349,406.07228 305.84149,406.08928 z M 247.46049,514.40928 C 250.71349,513.80428 254.33749,516.82428 255.02549,520.87228 C 255.59449,524.22028 252.93349,528.13028 249.67949,528.73528 C 246.42549,529.34128 242.61749,526.22128 241.92549,522.55928 C 241.26149,519.04028 243.34849,515.17628 247.46049,514.40928 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="cccssssccccssssccssss" id="path2388"/> 284 - <path transform="translate(309.83849,405.96228)" mask="url(#mask10545)" style="fill:url(#linearGradient11392)" id="path72" d="M -0.051,18.554 L -0.847,9.66 C -0.847,9.66 8.141,4.482 10.38,3.193 C 3.985,-0.79 -3.654,1.07 -3.741,1.093 C -10.903,2.996 -15.908,8.865 -15.908,15.222 C -15.908,15.461 -15.901,15.701 -15.887,15.94 C -15.887,15.941 -15.887,15.941 -15.887,15.942 C -15.887,16.299 -16.25,36.73 -19.253,42.838 C -20.334,45.036 -30.401,58.18 -42.058,73.4 C -54.195,89.247 -69.3,108.968 -70.298,111.44 C -70.839,112.778 -71.079,114.126 -71.079,115.435 C -71.079,119.221 -69.06,122.663 -66.483,124.621 C -66.083,123.92 -65.655,123.178 -65.197,122.392 C -67.02,121.101 -68.463,119.074 -68.895,116.783 C -69.291,114.687 -68.831,112.48 -67.631,110.726 C -66.46,109.013 -64.659,107.855 -62.561,107.463 C -60.935,107.16 -59.182,107.593 -57.621,108.682 C -57.428,108.817 -57.245,108.966 -57.063,109.118 C -46.315,92.233 -27.938,65.35 3.195,23.824 C 1.323,20.784 -0.051,18.554 -0.051,18.554 z"/> 285 - <path style="fill:url(#radialGradient11394)" id="path86" d="M 310.76249,424.19228 L 310.04449,416.17028 L 322.15949,409.19128 C 320.21949,407.64028 317.84449,406.51628 315.23549,405.92928 C 312.04649,405.90828 308.79349,406.38428 306.47749,407.16528 C 298.74149,409.77428 294.69849,415.49528 294.85149,422.31128 L 303.63249,437.15128 L 306.31749,435.47228 L 312.56749,446.29728 L 310.37649,447.80128 L 313.73849,451.42828 L 324.84249,447.04628 L 310.76249,424.19228 z"/> 286 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#linearGradient11396)" points="65.82,36.446 76.487,27.791 85.179,40.128 72.511,46.783 65.82,36.446 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect10551_2_"/> 287 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#radialGradient11398)" points="65.82,36.446 76.487,29.791 83.179,40.128 72.511,46.783 65.82,36.446 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect10551"/> 288 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#radialGradient11400)" points="68.311,35.653 74.616,32.078 80.237,40.809 73.932,44.384 68.311,35.653 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect14950"/> 289 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#radialGradient11402)" points="67.891,36.615 77.497,32.233 77.891,33.323 68.284,37.705 67.891,36.615 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect10553"/> 290 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#radialGradient11404)" points="72.212,42.972 81.653,38.899 82.001,39.827 72.56,43.9 72.212,42.972 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect14938"/> 291 - <polygon transform="translate(229.83849,405.96228)" style="fill:url(#radialGradient11406)" points="69.661,39.991 79.757,35.751 80.11,36.673 70.015,40.914 69.661,39.991 " inkscape:r_cy="true" inkscape:r_cx="true" id="rect14944"/> 292 - <path style="fill:url(#linearGradient11410)" d="M 320.80249,431.89128 C 320.76149,432.16128 322.10049,439.91928 322.18149,440.18928 C 322.85449,444.45728 323.83149,444.59528 324.03549,445.34928 C 324.76349,444.93528 324.29249,445.39528 324.92349,444.84628 C 324.80849,444.48028 323.48549,441.99528 322.95849,441.11128 C 322.71249,438.97728 321.93149,433.00328 321.86449,432.43528 C 321.45549,432.21328 321.29849,432.12528 320.80249,431.89128 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="ccccccc" id="path34280"/> 293 - <path style="fill:url(#linearGradient11412)" d="M 246.62049,511.92528 C 251.42949,510.02428 257.88249,515.30428 257.53849,521.11028 C 260.82449,517.31028 296.88449,460.33528 297.44649,457.74428 C 298.30649,453.77728 294.17949,450.82228 290.89849,452.88728 C 288.60949,454.32628 246.30749,512.04828 246.62049,511.92528 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="ccsss" id="path30758"/> 294 - <path style="fill:url(#linearGradient11414);stroke:#000000" id="path159" d="M 292.02849,454.56028 C 289.53249,456.91828 266.85449,487.60628 250.66249,509.77928 C 252.02149,510.08228 253.37949,510.67028 254.63749,511.58128 C 256.37949,512.84228 257.66849,514.51428 258.50849,516.33428 C 267.27449,503.42428 294.06749,460.80328 295.50149,457.24628 C 295.53749,457.05828 295.56249,456.87128 295.56249,456.69028 C 295.56249,455.85828 295.18949,455.11828 294.50449,454.63828 C 293.74349,454.10528 292.82549,454.08928 292.02849,454.56028 z"/> 295 - <path style="fill:url(#radialGradient11416)" id="path166" d="M 294.94349,422.46628 C 294.86849,425.66728 294.31649,443.48028 291.48249,449.24328 C 291.40649,449.39728 291.28449,449.60828 291.13649,449.84928 C 291.56049,449.26728 291.86549,448.81828 292.01449,448.54228 C 294.75749,443.48028 297.55549,430.48328 297.76449,427.23428 L 294.94349,422.46628 z"/> 296 - <path style="opacity:0.5;fill:url(#linearGradient11418)" id="path173" d="M 258.69149,526.59428 C 259.24949,525.08628 259.45349,523.49328 259.17549,521.97428 C 258.59949,518.81928 256.61749,515.87328 253.87449,514.09028 C 251.69549,512.67428 249.24349,512.11128 246.97049,512.50528 C 244.03849,513.01528 241.52249,514.52228 239.88549,516.74928 C 238.45149,518.70028 237.78049,521.08528 237.96049,523.44028 C 239.33149,531.34628 248.26549,537.48228 255.82849,530.23128 C 256.49049,529.59728 257.46949,528.33628 258.69149,526.59428 z M 249.67949,528.73528 C 246.42549,529.34128 242.61749,526.22128 241.92549,522.55928 C 241.26049,519.03928 243.34749,515.17528 247.46049,514.40928 C 250.71349,513.80428 254.33749,516.82428 255.02549,520.87228 C 255.59449,524.22028 252.93349,528.13028 249.67949,528.73528 z"/> 297 - <path style="fill:url(#linearGradient11420)" id="path180" d="M 256.01149,520.70428 C 255.59949,518.27928 254.18149,516.01528 252.21849,514.64428 C 250.65849,513.55528 248.90449,513.12328 247.27849,513.42528 C 245.18049,513.81728 243.38049,514.97528 242.20849,516.68828 C 241.00949,518.44128 240.54849,520.64928 240.94449,522.74528 C 241.75449,527.03328 246.08849,530.42228 249.86349,529.71928 C 253.62049,529.02028 256.66649,524.55528 256.01149,520.70428 z M 249.67949,528.73528 C 246.42549,529.34128 242.61749,526.22128 241.92549,522.55928 C 241.26049,519.03928 243.34749,515.17528 247.46049,514.40928 C 250.71349,513.80428 254.33749,516.82428 255.02549,520.87228 C 255.59449,524.22028 252.93349,528.13028 249.67949,528.73528 z"/> 298 - <path style="opacity:0.4;fill:url(#linearGradient11422)" id="path187" d="M 285.39049,455.48028 C 285.64549,454.95828 285.88049,454.31028 286.09549,453.56728 C 274.64749,469.16528 240.27149,512.92628 238.61349,517.02828 C 238.29049,517.82728 238.07649,518.63728 237.94149,519.45128 C 242.96749,511.10428 283.36449,459.62828 285.39049,455.48028 z"/> 299 - <path transform="translate(229.83849,405.96228)" clip-path="url(#clipPath4092)" style="fill:url(#linearGradient11424);filter:url(#filter4503)" id="path65" d="M 72.13,49.416 C 66.96,54.112 32.292,116.228 25.99,122.27 C 18.09,129.844 8.695,122.813 7.986,114.414 C 7.207,123.618 17.468,132.44 25.99,124.27 C 32.292,118.228 66.96,56.112 72.13,51.416 C 75.624,48.242 95.005,41.084 95.005,41.084 L 94.004,39.459 C 90.005,40.965 75.147,46.674 72.13,49.416 z"/> 300 - <path style="fill:url(#linearGradient11408)" d="M 310.04449,416.17028 L 322.15949,409.19128 L 322.67749,410.88528 L 310.13349,418.26728 L 310.04449,416.17028 z" inkscape:r_cy="true" inkscape:r_cx="true" sodipodi:nodetypes="ccccc" id="rect22846"/> 301 - <path style="fill:url(#linearGradient11390);fill-opacity:1" id="path46" d="M 310.21449,416.07228 L 322.15949,409.19128 C 321.63949,408.78428 321.10749,408.43228 320.56949,408.10728 L 310.04449,414.17028 L 310.21449,416.07228 z"/> 302 - </g> 303 - <path style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.47008219000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998000000000;stroke-opacity:1;filter:url(#filter11957);opacity:0.80000000000000004" d="M 10.375,9 L 4.21875,15.46875 L 9.125,23.1875 C 13.08003,25.264868 17.14186,27.693549 20.375,30.75 L 69.625,77.3125 L 65.5625,81.5625 L 70.8125,86.53125 C 73.7103,86.859904 76.69384,88.078409 79.15625,90.40625 C 81.64614,92.760071 83.16605,95.732279 83.625,98.625 L 108.34375,122.03125 C 114.08456,127.45836 128.43479,112.52526 122.65625,107.0625 L 97.90625,83.6875 C 94.97813,83.378226 91.9274,82.010074 89.4375,79.65625 C 86.9751,77.328414 85.57063,74.424084 85.09375,71.5625 L 79.84375,66.59375 L 75.78125,70.84375 L 26.53125,24.28125 C 23.29811,21.224799 20.16307,17.382339 18.375,13.53125 L 10.375,9 z" id="path11428"/> 304 - <g id="g10397" transform="matrix(0.9660937,-2.5302336e-2,2.3546854e-2,0.9608617,2.3338765,6.1294086)"> 305 - <path id="rect3006" d="M 1.750754,7.673054 L 6.651221,15.840499 C 10.689771,18.10883 14.818666,20.740966 18.085644,24.007944 L 103.30145,109.22375 L 109.83541,102.68979 L 24.6196,17.473988 C 21.352622,14.20701 18.204176,10.093654 16.452155,6.039565 L 8.28471,1.139098 L 1.750754,7.673054 z" style="fill:url(#linearGradient6125);fill-opacity:1;stroke:none;stroke-width:0.47008219;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" sodipodi:nodetypes="ccccccccc"/> 306 - <rect transform="matrix(0.7071068,-0.7071068,-0.7071068,-0.7071068,0,0)" style="fill:url(#linearGradient6122);fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" id="rect3912" width="1.1166428" height="98.671562" x="-1.357038" y="-123.11634"/> 307 - <rect style="opacity:0.3857678;fill:url(#linearGradient6119);fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" id="rect4944" width="1.6020314" height="63.508739" x="0.89394951" y="-85.707031" transform="matrix(-0.7071068,0.7071068,-0.7071068,-0.7071068,0,0)"/> 308 - <g transform="matrix(0.8167445,-0.8167445,0.8167445,0.8167445,5.2761549,23.749521)" clip-path="url(#clipPath3850)" id="g3842"> 309 - <path style="fill:#535557;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter3834)" d="M 4.296875,-4.12891 L 5.6640625,-4.12891 C 8.3203089,-0.31380448 8.5987355,3.8409896 7.6171875,8.17578 L 4.9804688,9.1523436 L 4.296875,-4.12891 z" id="path3726" sodipodi:nodetypes="ccccc"/> 310 - <path sodipodi:nodetypes="ccccc" id="path3728" d="M 18.977324,-4.12891 L 17.610137,-4.12891 C 14.95389,-0.31380448 14.675464,3.8409896 15.657012,8.17578 L 18.293731,9.1523436 L 18.977324,-4.12891 z" style="fill:#535557;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter3838)"/> 311 - <path style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter3838)" d="M 18.977324,-4.12891 L 18.231618,-4.0598566 C 16.117808,-1.3279433 15.743286,-1.0597872 15.864172,4.9302704 L 18.293731,9.1523436 L 18.977324,-4.12891 z" id="path3969" sodipodi:nodetypes="ccccc"/> 312 - </g> 313 - <rect transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)" y="41.331993" x="0.84851468" height="109.04897" width="1.9142449" id="rect3886" style="fill:url(#linearGradient6112);fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 314 - <path transform="matrix(0.8167445,-0.8167445,0.8167445,0.8167445,-14.584136,43.609812)" id="path3925" d="M 32,-12 L 30,-4 C 34.143852,8.2009511 38.115959,5.0342786 42,-4 L 40,-12 L 32,-12 z" style="fill:url(#linearGradient3943);fill-opacity:1;stroke:url(#linearGradient6517);stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" sodipodi:nodetypes="ccccc"/> 315 - <path sodipodi:nodetypes="ccsccccsccc" id="rect3956" d="M 63.529919,78.09273 L 68.834311,83.397123 C 71.82354,83.817882 74.899226,85.18508 77.387407,87.673261 C 79.903365,90.189215 81.385477,93.328601 81.786903,96.34972 L 106.78156,121.34436 C 112.58247,127.14528 127.79361,112.01036 121.95458,106.17133 L 96.95993,81.176682 C 93.938823,80.775254 90.799446,79.29314 88.283481,76.777186 C 85.795299,74.289007 84.428105,71.213314 84.007344,68.22409 L 78.70295,62.919697 L 63.529919,78.09273 z" style="opacity:1;fill:url(#linearGradient4190);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 316 - <path transform="matrix(0.9483145,-0.9483145,0.9483145,0.9483145,-6.4444639,0.531831)" clip-path="url(#clipPath4242)" sodipodi:nodetypes="cccccc" id="path4196" d="M -8,120 C 1.7462188,130.07566 10.00314,126.89342 16,120 L 12,136 L -16,128 L -20,112 L -8,120 z" style="fill:#ffa700;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4238)"/> 317 - <rect transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)" y="100.16766" x="-10.297462" height="1.1132338" width="21.457907" id="rect4249" style="opacity:0.48689138;fill:#ffa500;fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 318 - <path sodipodi:nodetypes="ccccccc" id="rect4320" d="M 72.972033,68.720893 L 75.892922,65.800004 L 81.066844,70.973925 C 80.921148,71.564914 80.822369,72.165286 81.579665,72.936868 L 79.073097,75.857759 C 78.372014,75.392484 77.997186,74.796708 78.21501,73.963871 L 72.972033,68.720893 z" style="opacity:0.83895126;fill:url(#linearGradient4346);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 319 - <path sodipodi:nodetypes="ccccc" id="rect4340" d="M 4.6713727,129.88196 L 7.2816355,129.49996 C 7.2464436,130.37087 7.2584731,130.8014 7.8438776,132.01123 L 5.1273299,132.01123 C 4.7973883,130.83537 4.6035939,130.49599 4.6713727,129.88196 z" style="opacity:0.74531836;fill:url(#linearGradient4342);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4404)" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,-4,-4)"/> 320 - <rect transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)" y="126.0467" x="-0.6434837" height="0.390625" width="10.644531" id="rect4432" style="opacity:1;fill:url(#radialGradient4440);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 321 - <path sodipodi:nodetypes="ccc" id="path4454" d="M 83.597656,68.53125 L 68.753906,82.984375 C 84.820174,88.576948 78.33289,74.329762 83.597656,68.53125 z" style="fill:url(#linearGradient4471);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4501)"/> 322 - <path transform="matrix(-1,0,0,-1,169.63281,168.51104)" style="fill:url(#linearGradient4515);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter4501)" d="M 87.597656,72.53125 L 72.753906,86.984375 C 88.820174,92.576948 82.33289,78.329762 87.597656,72.53125 z" id="path4505" sodipodi:nodetypes="ccc"/> 323 - <rect transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)" ry="2.9279406" rx="2.9279406" y="132.02951" x="-7.5001087" height="29.279404" width="5.8558812" id="rect4517" style="opacity:0.83895126;fill:url(#linearGradient4525);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1"/> 324 - <rect inkscape:transform-center-y="-5.5242717" inkscape:transform-center-x="-16.434708" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,-4,-4)" ry="0.5577029" rx="2.9279406" y="130.97287" x="-1.1929667" height="1.1048541" width="11.60097" id="rect4527" style="opacity:0.83895126;fill:url(#linearGradient4537);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4551)"/> 325 - <path transform="translate(50.492188,-4.0046875)" clip-path="url(#clipPath4588)" id="path4559" d="M 13.83125,81.09375 L 12.33125,82.59375 L 17.64375,87.90625 C 20.632979,88.327007 23.718069,89.699319 26.20625,92.1875 C 28.722207,94.703451 30.179824,97.822631 30.58125,100.84375 L 55.58125,125.84375 C 59.791769,130.05428 68.947177,123.22603 71.425,116.9375 C 68.058606,122.54366 60.345306,127.60781 56.58125,123.84375 L 31.58125,98.84375 C 31.179824,95.822631 29.722207,92.703451 27.20625,90.1875 C 24.718069,87.699319 21.632979,86.327007 18.64375,85.90625 L 13.83125,81.09375 z" style="opacity:1;fill:#996100;fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4584)"/> 326 - <rect style="opacity:0.576779;fill:url(#radialGradient4602);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" id="rect4596" width="10.644531" height="0.390625" x="-0.091056541" y="100.35886" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)"/> 327 - <rect clip-path="url(#clipPath4632)" style="opacity:0.576779;fill:url(#linearGradient4604);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4626)" id="rect4598" width="12.602244" height="4.0530515" x="-1.1929667" y="129.5918" rx="0" ry="0" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,-21.221011,-22.313001)" inkscape:transform-center-x="-16.434708" inkscape:transform-center-y="-5.5242717"/> 328 - <rect inkscape:transform-center-y="-5.5242717" inkscape:transform-center-x="-16.434708" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,-21.321011,-22.413001)" ry="0" rx="0" y="130.07516" x="3.1573973" height="1.7051741" width="7.9066095" id="rect4638" style="opacity:0.576779;fill:url(#linearGradient4640);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1;filter:url(#filter4626)" clip-path="url(#clipPath4632)"/> 329 - <path sodipodi:nodetypes="ccccc" style="fill:url(#linearGradient6930);fill-opacity:1;stroke:none;stroke-width:0.30655462;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" d="M 2.9032773,7.9724105 L 7.1391831,15.032254 C 18.678358,20.720438 19.246981,15.680572 15.610994,6.5604419 L 8.5511516,2.3245361 L 2.9032773,7.9724105 z" id="path6537"/> 330 - <rect style="opacity:0.83895126;fill:url(#linearGradient7698);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" id="rect7696" width="5.8558812" height="29.279404" x="4.5207062" y="132.73663" rx="2.9279406" ry="2.9279406" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)"/> 331 - <rect style="opacity:0.95131088;fill:url(#linearGradient4338);fill-opacity:1;stroke:none;stroke-width:0.37;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.08779998;stroke-opacity:1" id="rect4336" width="2.5833137" height="38.179485" x="0.94721299" y="126.14276" transform="matrix(0.7071068,-0.7071068,0.7071068,0.7071068,0,0)"/> 332 - </g> 333 - </g> 334 - </svg>
-53
utils/nwztools/plattools/data/make_images.sh
··· 1 - #!/bin/bash 2 - # 3 - # This script contains the code used to produce all the images. 4 - # Because of the variety of tools needed to achieve that, the result is also 5 - # included in the repository but this makes it easier to modify the data 6 - # to add more content 7 - # 8 - 9 - # path to root of repository 10 - ROOT_DIR=../../../../ 11 - 12 - # final resolution 13 - NWZ_WIDTH=130 14 - NWZ_HEIGHT=130 15 - 16 - # path to rockbox icon 17 - RB_ICON_PATH=$ROOT_DIR/docs/logo/rockbox-icon.svg 18 - # path to tools icon (currently stolen from KDE Oxygen icon set) 19 - TOOL_ICON_PATH=Oxygen480-categories-preferences-system.svg 20 - 21 - # convert_svg width height input output 22 - function convert_svg 23 - { 24 - local width="$1" 25 - local height="$2" 26 - local input="$3" 27 - local output="$4" 28 - TMP=tmp.png 29 - # convert from SVG to PNG 30 - inkscape -z -e $TMP -w $width -h $height $input 31 - if [ "$?" != 0 ]; then 32 - echo "SVG -> PNG conversion failed" 33 - exit 1 34 - fi 35 - # convert from PNG to BMP, force using "version 3" because the OF don't like 36 - # "recent" BMP 37 - convert -channel RGB $TMP -define bmp:format=bmp3 ${output}_icon.bmp 38 - if [ "$?" != 0 ]; then 39 - rm -f $TMP 40 - echo "PNG -> BMP conversion failed" 41 - exit 1 42 - fi 43 - # remove temporary 44 - rm -f $TMP 45 - } 46 - 47 - # start by creating the bitmap files from rockbox-icon.svg for all resolutions 48 - # we make a detour by svg because inkscape can only export to SVG 49 - # NOTE: we use image magick to convert to bmp but the OF tools don't like BMPv5 50 - # and contrary to what the documentation says, image magick tends to produce 51 - # those by default unless asked otherwise 52 - convert_svg $NWZ_WIDTH $NWZ_HEIGHT $RB_ICON_PATH rockbox 53 - convert_svg $NWZ_WIDTH $NWZ_HEIGHT $TOOL_ICON_PATH tools
utils/nwztools/plattools/data/rockbox_icon.bmp apps/bitmaps/native/rockboxicon.130x130x16.bmp
utils/nwztools/plattools/data/tools_icon.bmp apps/bitmaps/native/toolsicon.130x130x16.bmp
-192
utils/nwztools/plattools/dest_tool.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include <string.h> 23 - #include <stdlib.h> 24 - #include "nwz_plattools.h" 25 - 26 - static unsigned long read32(unsigned char *buf) 27 - { 28 - return buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24; 29 - } 30 - 31 - static void write32(unsigned char *buf, unsigned long value) 32 - { 33 - buf[0] = value & 0xff; 34 - buf[1] = (value >> 8) & 0xff; 35 - buf[2] = (value >> 16) & 0xff; 36 - buf[3] = (value >> 24) & 0xff; 37 - } 38 - 39 - static struct 40 - { 41 - unsigned long dest; 42 - const char *name; 43 - } g_dest_list[] = 44 - { 45 - { 0, "J" }, 46 - { 1, "U" }, 47 - { 0x101, "U2" }, 48 - { 0x201, "U3" }, 49 - { 0x301, "CA" }, 50 - { 2, "CEV" }, 51 - { 0x102, "CE7" }, 52 - { 3, "CEW" }, 53 - { 0x103, "CEW2" }, 54 - { 4, "CN" }, 55 - { 5, "KR" }, 56 - { 6, "E" }, 57 - { 0x106, "MX" }, 58 - { 0x206, "E2" }, 59 - { 0x306, "MX3" }, 60 - { 7, "TW" }, 61 - }; 62 - 63 - #define NR_DEST (sizeof(g_dest_list) / sizeof(g_dest_list[0])) 64 - 65 - static int get_dest_index(unsigned long dest) 66 - { 67 - for(size_t i = 0; i < NR_DEST; i++) 68 - if(g_dest_list[i].dest == dest) 69 - return i; 70 - return -1; 71 - } 72 - 73 - static const char *get_dest_name(unsigned long dest) 74 - { 75 - int index = get_dest_index(dest); 76 - return index < 0 ? "NG" : g_dest_list[index].name; 77 - } 78 - 79 - int NWZ_TOOL_MAIN(dest_tool)(int argc, char **argv) 80 - { 81 - /* clear screen and display welcome message */ 82 - nwz_lcdmsg(true, 0, 0, "dest_tool"); 83 - /* open input device */ 84 - int input_fd = nwz_key_open(); 85 - if(input_fd < 0) 86 - { 87 - nwz_lcdmsg(false, 3, 4, "Cannot open input device"); 88 - sleep(2); 89 - return 1; 90 - } 91 - unsigned long model_id = nwz_get_model_id(); 92 - if(model_id == 0) 93 - { 94 - nwz_key_close(input_fd); 95 - nwz_lcdmsg(false, 3, 4, "Cannot get model ID"); 96 - sleep(2); 97 - return 1; 98 - } 99 - const char *model_name = nwz_get_model_name(); 100 - if(model_name == NULL) 101 - model_name = "Unknown"; 102 - const char *series_name = "Unknown"; 103 - bool ok_model = false; 104 - if(nwz_get_series() != -1) 105 - { 106 - series_name = nwz_series[nwz_get_series()].name; 107 - ok_model = true; 108 - } 109 - nwz_lcdmsgf(false, 0, 2, "Model ID: %#x", model_id); 110 - nwz_lcdmsgf(false, 0, 3, "Model: %s", model_name); 111 - nwz_lcdmsgf(false, 0, 4, "Series: %s", series_name); 112 - nwz_lcdmsg(false, 0, 5, "BACK: quit"); 113 - nwz_lcdmsg(false, 0, 6, "LEFT/RIGHT: change dest"); 114 - nwz_lcdmsg(false, 0, 7, "PLAY/PAUSE: change sps"); 115 - /* display input state in a loop */ 116 - while(1) 117 - { 118 - unsigned char nvp_buf[32]; 119 - bool ok_nvp = false; 120 - if(ok_model) 121 - { 122 - /* make sure node has the right size... */ 123 - if(nwz_nvp_read(NWZ_NVP_SHP, NULL) == sizeof(nvp_buf)) 124 - { 125 - if(nwz_nvp_read(NWZ_NVP_SHP, nvp_buf) == sizeof(nvp_buf)) 126 - ok_nvp = true; 127 - else 128 - nwz_lcdmsg(false, 1, 9, "Cannot read NVP.\n"); 129 - } 130 - else 131 - nwz_lcdmsg(false, 1, 9, "NVP node has the wrong size.\n"); 132 - } 133 - else 134 - { 135 - nwz_lcdmsg(false, 1, 9, "Your model is not supported.\n"); 136 - nwz_lcdmsg(false, 1, 10, "Please contact a developer.\n"); 137 - } 138 - /* display information */ 139 - if(ok_nvp) 140 - { 141 - unsigned long dest = read32(nvp_buf); 142 - unsigned long sps = read32(nvp_buf + 4); 143 - const char *dest_name = get_dest_name(dest); 144 - const char *sps_name = sps ? "ON" : "OFF"; 145 - nwz_lcdmsgf(false, 1, 9, "DEST: %s (%#x) ", dest_name, dest); 146 - nwz_lcdmsgf(false, 1, 10, "SPS: %s (%d) ", sps_name, sps); 147 - } 148 - /* wait for event */ 149 - int ret = nwz_key_wait_event(input_fd, -1); 150 - if(ret != 1) 151 - continue; 152 - struct input_event evt; 153 - if(nwz_key_read_event(input_fd, &evt) != 1) 154 - continue; 155 - /* only act on release */ 156 - if(nwz_key_event_is_press(&evt)) 157 - continue; 158 - int keycode = nwz_key_event_get_keycode(&evt); 159 - if(keycode == NWZ_KEY_BACK) 160 - break; 161 - bool write_nvp = false; 162 - if(keycode == NWZ_KEY_LEFT || keycode == NWZ_KEY_RIGHT) 163 - { 164 - int dest_idx = get_dest_index(read32(nvp_buf)); 165 - /* if destination is unknown, replace by the first one */ 166 - if(dest_idx == -1) 167 - dest_idx = 0; 168 - if(keycode == NWZ_KEY_LEFT) 169 - dest_idx--; 170 - else 171 - dest_idx++; 172 - dest_idx = (dest_idx + NR_DEST) % NR_DEST; 173 - write32(nvp_buf, g_dest_list[dest_idx].dest); 174 - write_nvp = true; 175 - } 176 - else if(keycode == NWZ_KEY_PLAY) 177 - { 178 - /* change 0 to 1 and anything nonzero to 0 */ 179 - write32(nvp_buf + 4, read32(nvp_buf + 4) == 0 ? 1 : 0); 180 - write_nvp = true; 181 - } 182 - /* write nvp */ 183 - if(ok_nvp && write_nvp) 184 - { 185 - if(nwz_nvp_write(NWZ_NVP_SHP, nvp_buf) != 0) 186 - nwz_lcdmsg(false, 1, 12, "Cannot write NVP.\n"); 187 - } 188 - } 189 - /* finish nicely */ 190 - nwz_key_close(input_fd); 191 - return 0; 192 - }
-302
utils/nwztools/plattools/dualboot.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 10 - * Copyright (C) 2011 by Amaury Pouly 11 - * 12 - * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing 13 - * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach 14 - * 15 - * This program is free software; you can redistribute it and/or 16 - * modify it under the terms of the GNU General Public License 17 - * as published by the Free Software Foundation; either version 2 18 - * of the License, or (at your option) any later version. 19 - * 20 - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 - * KIND, either express or implied. 22 - * 23 - ****************************************************************************/ 24 - #include "nwz_lib.h" 25 - #include "nwz_plattools.h" 26 - #include <time.h> 27 - #include <errno.h> 28 - 29 - /* all images must have the following size */ 30 - #define ICON_WIDTH 130 31 - #define ICON_HEIGHT 130 32 - 33 - /* images */ 34 - #include "data/rockbox_icon.h" 35 - #if BMPWIDTH_rockbox_icon != ICON_WIDTH || BMPHEIGHT_rockbox_icon != ICON_HEIGHT 36 - #error rockbox_icon has the wrong resolution 37 - #endif 38 - #include "data/tools_icon.h" 39 - #if BMPWIDTH_tools_icon != ICON_WIDTH || BMPHEIGHT_tools_icon != ICON_HEIGHT 40 - #error tools_icon has the wrong resolution 41 - #endif 42 - /* buffer for Sony image, filled from NVP */ 43 - unsigned short sony_icon[ICON_WIDTH * ICON_HEIGHT]; 44 - /* resolution */ 45 - static int width, height, bpp; 46 - 47 - /* return icon y position (x is always centered) */ 48 - int get_icon_y(void) 49 - { 50 - /* adjust so that this contains the Sony logo and produces a nice logo 51 - * when used with rockbox */ 52 - if(height == 320) 53 - return 70; 54 - else if(height == 320) 55 - return 100; 56 - else 57 - return height / 2 - ICON_HEIGHT + 30; /* guess, probably won't work */ 58 - } 59 - 60 - /* Sony logo extraction */ 61 - bool extract_sony_logo(void) 62 - { 63 - /* only support bpp of 16 */ 64 - if(bpp != 16) 65 - return false; 66 - /* load the entire image from the nvp */ 67 - int bti_size = nwz_nvp_read(NWZ_NVP_BTI, NULL); 68 - if(bti_size < 0) 69 - return false; 70 - unsigned short *bti = malloc(bti_size); 71 - if(nwz_nvp_read(NWZ_NVP_BTI, bti) != bti_size) 72 - return false; 73 - /* compute the offset in the image of the logo itself */ 74 - int x_off = (width - ICON_WIDTH) / 2; /* logo is centered horizontally */ 75 - int y_off = get_icon_y(); 76 - /* extract part of the image */ 77 - for(int y = 0; y < ICON_HEIGHT; y++) 78 - { 79 - memcpy(sony_icon + ICON_WIDTH * y, 80 - bti + width * (y + y_off) + x_off, ICON_WIDTH * sizeof(unsigned short)); 81 - } 82 - free(bti); 83 - return true; 84 - } 85 - 86 - /* Important Note: this bootloader is carefully written so that in case of 87 - * error, the OF is run. This seems like the safest option since the OF is 88 - * always there and might do magic things. */ 89 - 90 - enum boot_mode 91 - { 92 - BOOT_ROCKBOX, 93 - BOOT_TOOLS, 94 - BOOT_OF 95 - }; 96 - 97 - void draw_icon(int left, int top, const unsigned short *icon, unsigned short *fb_mmap) 98 - { 99 - for(int y = 0; y < ICON_HEIGHT; y++) 100 - { 101 - memcpy(fb_mmap + width * (y + top) + left, icon + ICON_WIDTH * y, 102 - ICON_WIDTH * sizeof(unsigned short)); 103 - } 104 - } 105 - 106 - enum boot_mode get_boot_mode(void) 107 - { 108 - if(bpp != 16) 109 - { 110 - nwz_lcdmsg(true, 0, 2, "Unsupported bpp"); 111 - sleep(2); 112 - return BOOT_OF; 113 - } 114 - /* open framebuffer */ 115 - int fb_fd = nwz_fb_open(true); 116 - if(fb_fd < 0) 117 - { 118 - nwz_lcdmsg(true, 0, 2, "Cannot open input device"); 119 - sleep(2); 120 - return BOOT_OF; 121 - } 122 - /* open input device */ 123 - int input_fd = nwz_key_open(); 124 - if(input_fd < 0) 125 - { 126 - nwz_fb_close(fb_fd); 127 - nwz_lcdmsg(true, 0, 2, "Cannot open input device"); 128 - sleep(2); 129 - return BOOT_OF; 130 - } 131 - int fb_size = width * height * bpp / 2; 132 - void *fb_mmap = nwz_fb_mmap(fb_fd, 0, fb_size); 133 - void *fb_mmap_p1 = nwz_fb_mmap(fb_fd, NWZ_FB_LCD_PAGE_OFFSET, fb_size); 134 - if(fb_mmap == NULL || fb_mmap_p1 == NULL) 135 - { 136 - nwz_fb_close(fb_fd); 137 - nwz_key_close(input_fd); 138 - nwz_lcdmsg(true, 0, 2, "Cannot map framebuffer"); 139 - sleep(2); 140 - return BOOT_OF; 141 - } 142 - /* wait for user action */ 143 - enum boot_mode mode = BOOT_OF; 144 - /* NOTE on drawing: since screen is redrawn automatically, and we invoke 145 - * external programs to draw, we can't hope to fit it in the frame time 146 - * and it will flicker. To avoid this, we use the fact that all programs 147 - * only write to page 0. So we setup the lcd to update from page 1. When 148 - * we need to update the screen, we ask it to draw from page 0, then copy 149 - * page 0 to page 1 and then switch back to page 1 */ 150 - memset(fb_mmap_p1, 0xff, fb_size); /* clear page 1 */ 151 - nwz_fb_set_page(fb_fd, 1); 152 - bool redraw = true; 153 - while(true) 154 - { 155 - if(redraw) 156 - { 157 - /* redraw screen on page 0: clear screen */ 158 - memset(fb_mmap, 0, fb_size); 159 - /* display top text */ 160 - nwz_display_text_center(width, 0, true, NWZ_COLOR(255, 201, 0), 161 - NWZ_COLOR(0, 0, 0), 0, "SELECT PLAYER"); 162 - /* display icon */ 163 - const unsigned short *icon = (mode == BOOT_OF) ? sony_icon : 164 - (mode == BOOT_ROCKBOX) ? rockbox_icon : tools_icon; 165 - draw_icon((width - ICON_WIDTH) / 2, get_icon_y(), icon, fb_mmap); 166 - /* display bottom description */ 167 - const char *desc = (mode == BOOT_OF) ? "SONY" : 168 - (mode == BOOT_ROCKBOX) ? "ROCKBOX" : "DEBUG TOOLS"; 169 - nwz_display_text_center(width, get_icon_y() + ICON_HEIGHT + 30, true, 170 - NWZ_COLOR(255, 201, 0), NWZ_COLOR(0, 0, 0), 0, desc); 171 - /* display arrows */ 172 - int arrow_y = get_icon_y() + ICON_HEIGHT / 2 - NWZ_FONT_H(true) / 2; 173 - nwz_display_text(NWZ_FONT_W(true) / 2, arrow_y, true, 174 - NWZ_COLOR(255, 201, 0), NWZ_COLOR(0, 0, 0), 0, "<"); 175 - nwz_display_text(width - 3 * NWZ_FONT_W(true) / 2, arrow_y, true, 176 - NWZ_COLOR(255, 201, 0), NWZ_COLOR(0, 0, 0), 0, ">"); 177 - /* switch to page 1 */ 178 - nwz_fb_set_page(fb_fd, 0); 179 - /* copy page 0 to page 1 */ 180 - memcpy(fb_mmap_p1, fb_mmap, fb_size); 181 - /* switch back to page 1 */ 182 - nwz_fb_set_page(fb_fd, 1); 183 - 184 - redraw = false; 185 - } 186 - 187 - /* wait for a key */ 188 - int ret = nwz_key_wait_event(input_fd, -1); 189 - if(ret != 1) 190 - continue; 191 - struct input_event evt; 192 - if(nwz_key_read_event(input_fd, &evt) != 1) 193 - continue; 194 - /* only act on release */ 195 - if(nwz_key_event_is_press(&evt)) 196 - continue; 197 - int key_code = nwz_key_event_get_keycode(&evt); 198 - /* play -> stop loop and return mode */ 199 - if(key_code == NWZ_KEY_PLAY) 200 - break; 201 - /* left/right/up/down: change mode */ 202 - if(key_code == NWZ_KEY_LEFT || key_code == NWZ_KEY_DOWN) 203 - { 204 - if(mode == BOOT_ROCKBOX) 205 - mode = BOOT_OF; 206 - else if(mode == BOOT_OF) 207 - mode = BOOT_TOOLS; 208 - else 209 - mode = BOOT_ROCKBOX; 210 - redraw = true; 211 - } 212 - if(key_code == NWZ_KEY_RIGHT || key_code == NWZ_KEY_UP) 213 - { 214 - if(mode == BOOT_ROCKBOX) 215 - mode = BOOT_TOOLS; 216 - else if(mode == BOOT_OF) 217 - mode = BOOT_ROCKBOX; 218 - else 219 - mode = BOOT_OF; 220 - redraw = true; 221 - } 222 - } 223 - /* switch back to page 0 */ 224 - nwz_fb_set_page(fb_fd, 0); 225 - nwz_key_close(input_fd); 226 - nwz_fb_close(fb_fd); 227 - return mode; 228 - } 229 - 230 - static char *boot_rb_argv[] = 231 - { 232 - "rockbox.sony", 233 - NULL 234 - }; 235 - 236 - int NWZ_TOOL_MAIN(all_tools)(int argc, char **argv); 237 - 238 - void error_screen(const char *msg) 239 - { 240 - nwz_lcdmsg(true, 0, 0, msg); 241 - sleep(3); 242 - } 243 - 244 - void create_sony_logo(void) 245 - { 246 - for(int y = 0; y < ICON_HEIGHT; y++) 247 - for(int x = 0; x < ICON_WIDTH; x++) 248 - sony_icon[y * ICON_WIDTH + x] = 0xf81f; 249 - } 250 - 251 - int main(int argc, char **argv) 252 - { 253 - /* make sure backlight is on and we are running the standard lcd mode */ 254 - int fb_fd = nwz_fb_open(true); 255 - if(fb_fd >= 0) 256 - { 257 - struct nwz_fb_brightness bl; 258 - nwz_fb_get_brightness(fb_fd, &bl); 259 - bl.level = NWZ_FB_BL_MAX_LEVEL; 260 - nwz_fb_set_brightness(fb_fd, &bl); 261 - nwz_fb_set_standard_mode(fb_fd); 262 - /* get resolution */ 263 - /* we also need to get the native resolution */ 264 - if(nwz_fb_get_resolution(fb_fd, &width, &height, &bpp) != 0) 265 - { 266 - /* safe one */ 267 - width = 240; 268 - height = 320; 269 - bpp = 16; 270 - } 271 - nwz_fb_close(fb_fd); 272 - } 273 - /* extract logo */ 274 - if(!extract_sony_logo()) 275 - create_sony_logo(); 276 - /* run all tools menu */ 277 - enum boot_mode mode = get_boot_mode(); 278 - if(mode == BOOT_TOOLS) 279 - { 280 - /* run tools and then run OF */ 281 - NWZ_TOOL_MAIN(all_tools)(argc, argv); 282 - } 283 - else if(mode == BOOT_ROCKBOX) 284 - { 285 - /* Rockbox expects /.rockbox to contain themes, rocks, etc, but we 286 - * cannot easily create this symlink because the root filesystem is 287 - * mounted read-only. Although we could remount it read-write temporarily, 288 - * this is neededlessly complicated and we defer this job to the dualboot 289 - * install script */ 290 - execvp("/contents/.rockbox/rockbox.sony", boot_rb_argv); 291 - /* fallback to OF in case of failure */ 292 - error_screen("Cannot boot Rockbox"); 293 - sleep(5); 294 - } 295 - /* boot OF */ 296 - execvp("/usr/local/bin/SpiderApp.of", argv); 297 - error_screen("Cannot boot OF"); 298 - sleep(5); 299 - /* if we reach this point, everything failed, so return an error so that 300 - * sysmgrd knows something is wrong */ 301 - return 1; 302 - }
+9 -4
utils/nwztools/plattools/nwz_adc.h firmware/target/hosted/sonynwz/adc-target.h
··· 7 7 * \/ \/ \/ \/ \/ 8 8 * $Id$ 9 9 * 10 - * Copyright (C) 2016 Amaury Pouly 10 + * Copyright (C) 2016 by Amaury Pouly 11 11 * 12 12 * This program is free software; you can redistribute it and/or 13 13 * modify it under the terms of the GNU General Public License ··· 18 18 * KIND, either express or implied. 19 19 * 20 20 ****************************************************************************/ 21 - #ifndef __NWZ_ADC_H__ 22 - #define __NWZ_ADC_H__ 21 + #ifndef _ADC_NWZ_H_ 22 + #define _ADC_NWZ_H_ 23 + 24 + #include "adc.h" 23 25 24 26 #define NWZ_ADC_DEV "/dev/icx_adc" 25 27 ··· 39 41 40 42 #define NWZ_ADC_GET_VAL(chan) _IOR(NWZ_ADC_TYPE, chan, unsigned char) 41 43 42 - #endif /* __NWZ_ADC_H__ */ 44 + /* Return channel name */ 45 + const char *adc_name(int channel); 46 + 47 + #endif
+15 -8
utils/nwztools/plattools/nwz_fb.h firmware/target/hosted/sonynwz/lcd-target.h
··· 5 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 7 * \/ \/ \/ \/ \/ 8 - * $Id$ 9 8 * 10 9 * Copyright (C) 2016 Amaury Pouly 11 10 * ··· 18 17 * KIND, either express or implied. 19 18 * 20 19 ****************************************************************************/ 21 - #ifndef __NWZ_FB_H__ 22 - #define __NWZ_FB_H__ 20 + 21 + #ifndef __LCD_TARGET_H__ 22 + #define __LCD_TARGET_H__ 23 + 24 + extern fb_data *nwz_framebuffer; /* see lcd-nwz.c */ 25 + #define LCD_FRAMEBUF_ADDR(col, row) (nwz_framebuffer + (row)*LCD_WIDTH + (col)) 23 26 24 27 #define NWZ_FB_LCD_DEV "/dev/fb/0" 25 28 #define NWZ_FB_TV_DEV "/dev/fb/1" ··· 62 65 * 63 66 * FIXME I don't know what the timer is, it seems irrelevant for the LCD but 64 67 * the OF uses it for TV, maybe this controls the refresh rate of the TV output? 68 + * Also it only exists on early version (up to generation x60 roughly) 65 69 * 66 70 * On a side note, this information only applies to a subset of LCD types (the 67 71 * LCD type can be gathered from icx_sysinfo): ··· 126 130 127 131 /* NOTE: I renamed those from Sony's header, because their original names were 128 132 * pure crap */ 129 - /* FIXME: Sony uses _IOR for NWZ_FB_WAIT_REFRESH but it should be _IORW */ 130 - #define NWZ_FB_WAIT_REFRESH _IORW(NWZ_FB_TYPE, 0x00, struct nwz_fb_status) 133 + #define NWZ_FB_WAIT_REFRESH _IOR(NWZ_FB_TYPE, 0x00, struct nwz_fb_status) 131 134 #define NWZ_FB_UPDATE _IOW(NWZ_FB_TYPE, 0x01, struct nwz_fb_image_info) 132 135 #define NWZ_FB_SET_MODE _IOW(NWZ_FB_TYPE, 0x02, struct nwz_fb_image_info) 133 136 #define NWZ_FB_GET_MODE _IOR(NWZ_FB_TYPE, 0x03, struct nwz_fb_image_info) 137 + /* the timer only exits on MP200, it disappeared in EMXX and the ioctl fails */ 134 138 #define NWZ_FB_UPDATE_TIMER _IOR(NWZ_FB_TYPE, 0x04, struct nwz_fb_update_timer) 135 - #define NWZ_FB_SET_BRIGHTNESS _IOW(NWZ_FB_TYPE, 0x07, struct nwz_fb_brightness) 136 - #define NWZ_FB_GET_BRIGHTNESS _IOR(NWZ_FB_TYPE, 0x08, struct nwz_fb_brightness) 139 + /* unfortnately, Sony change the ioctl numbers of those between MP200 and EMXX */ 140 + #define NWZ_FB_SET_BRIGHTNESS_MP200 _IOW(NWZ_FB_TYPE, 0x07, struct nwz_fb_brightness) 141 + #define NWZ_FB_GET_BRIGHTNESS_MP200 _IOR(NWZ_FB_TYPE, 0x08, struct nwz_fb_brightness) 142 + #define NWZ_FB_SET_BRIGHTNESS_EMXX _IOW(NWZ_FB_TYPE, 0x10, struct nwz_fb_brightness) 143 + #define NWZ_FB_GET_BRIGHTNESS_EMXX _IOR(NWZ_FB_TYPE, 0x11, struct nwz_fb_brightness) 137 144 145 + #endif /* __LCD_TARGET_H__ */ 138 146 139 - #endif /* __NWZ_FB_H__ */
+3 -2
utils/nwztools/plattools/nwz_keys.h firmware/target/hosted/sonynwz/nwz_keys.h
··· 21 21 #ifndef __NWZ_KEYS_H__ 22 22 #define __NWZ_KEYS_H__ 23 23 24 - #define NWZ_KEY_NAME "icx_key" 25 - 26 24 /* The Sony icx_key driver reports keys via the /dev/input/event0 device and 27 25 * abuses the standard struct input_event. The input_event.code is split into 28 26 * two parts: ··· 31 29 * The status of the HOLD can be queried at any time by reading the state of 32 30 * the first LED. 33 31 */ 32 + 33 + /* device name */ 34 + #define NWZ_KEY_NAME "icx_key" 34 35 35 36 /* key code and mask */ 36 37 #define NWZ_KEY_MASK 0x1f
-777
utils/nwztools/plattools/nwz_lib.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_db.h" 23 - 24 - int nwz_run(const char *file, const char *args[], bool wait) 25 - { 26 - pid_t child_pid = fork(); 27 - if(child_pid != 0) 28 - { 29 - if(wait) 30 - { 31 - int status; 32 - waitpid(child_pid, &status, 0); 33 - return status; 34 - } 35 - else 36 - return 0; 37 - } 38 - else 39 - { 40 - execvp(file, (char * const *)args); 41 - _exit(1); 42 - } 43 - } 44 - 45 - char *nwz_run_pipe(const char *file, const char *args[], int *status) 46 - { 47 - int pipe_fds[2]; 48 - pipe(pipe_fds); 49 - pid_t child_pid = fork(); 50 - if(child_pid == 0) 51 - { 52 - dup2(pipe_fds[1], 1); /* redirect stdout */ 53 - dup2(pipe_fds[1], 2); /* redirect stderr */ 54 - close(pipe_fds[0]); /* close reading */ 55 - close(pipe_fds[1]); /* close writing */ 56 - execvp(file, (char * const *)args); 57 - _exit(1); 58 - } 59 - else 60 - { 61 - close(pipe_fds[1]); /* close writing */ 62 - char buffer[1024]; 63 - char *output = malloc(1); 64 - ssize_t count; 65 - size_t size = 0; 66 - while((count = read(pipe_fds[0], buffer, sizeof(buffer))) > 0) 67 - { 68 - output = realloc(output, size + count + 1); 69 - memcpy(output + size, buffer, count); 70 - size += count; 71 - } 72 - close(pipe_fds[0]); 73 - output[size] = 0; 74 - waitpid(child_pid, status, 0); 75 - return output; 76 - } 77 - } 78 - 79 - void nwz_lcdmsg(bool clear, int x, int y, const char *msg) 80 - { 81 - const char *path_lcdmsg = "/usr/local/bin/lcdmsg"; 82 - const char *args[16]; 83 - int index = 0; 84 - char locate[32]; 85 - args[index++] = "lcdmsg"; 86 - if(clear) 87 - args[index++] = "-c"; 88 - args[index++] = "-f"; 89 - args[index++] = "/usr/local/bin/font_08x12.bmp"; 90 - args[index++] = "-l"; 91 - sprintf(locate, "%d,%d", x, y); 92 - args[index++] = locate; 93 - args[index++] = msg; 94 - args[index++] = NULL; 95 - /* wait for lcdmsg to finish to avoid any race conditions in framebuffer 96 - * accesses */ 97 - nwz_run(path_lcdmsg, args, true); 98 - } 99 - 100 - void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...) 101 - { 102 - char buffer[1024]; 103 - va_list args; 104 - va_start(args, format); 105 - vsprintf(buffer, format, args); 106 - va_end(args); 107 - nwz_lcdmsg(clear, x, y, buffer); 108 - } 109 - 110 - #define NWZ_COLOR_RGB(col) \ 111 - NWZ_COLOR_RED(col), NWZ_COLOR_GREEN(col), NWZ_COLOR_BLUE(col) 112 - 113 - void nwz_display_clear(nwz_color_t color) 114 - { 115 - const char *path_display = "/usr/local/bin/display"; 116 - const char *args[16]; 117 - int index = 0; 118 - char col[32]; 119 - args[index++] = "display"; 120 - args[index++] = "lcd"; 121 - args[index++] = "clear"; 122 - sprintf(col, "%d,%d,%d", NWZ_COLOR_RGB(color)); 123 - args[index++] = col; 124 - args[index++] = NULL; 125 - /* wait for lcdmsg to finish to avoid any race conditions in framebuffer 126 - * accesses */ 127 - nwz_run(path_display, args, true); 128 - } 129 - 130 - void nwz_display_text(int x, int y, bool big_font, nwz_color_t foreground_col, 131 - nwz_color_t background_col, int alpha, const char *text) 132 - { 133 - const char *path_display = "/usr/local/bin/display"; 134 - const char *args[16]; 135 - int index = 0; 136 - char fg[32],bg[32], pos[32], transp[16]; 137 - args[index++] = "display"; 138 - args[index++] = "lcd"; 139 - args[index++] = "text"; 140 - sprintf(pos, "%d,%d", x, y); 141 - args[index++] = pos; 142 - if(big_font) 143 - args[index++] = "/usr/local/bin/font_14x24.bmp"; 144 - else 145 - args[index++] = "/usr/local/bin/font_08x12.bmp"; 146 - sprintf(fg, "%d,%d,%d", NWZ_COLOR_RGB(foreground_col)); 147 - args[index++] = fg; 148 - sprintf(bg, "%d,%d,%d", NWZ_COLOR_RGB(background_col)); 149 - args[index++] = bg; 150 - sprintf(transp, "%d", alpha); 151 - args[index++] = transp; 152 - args[index++] = text; 153 - args[index++] = NULL; 154 - /* wait for lcdmsg to finish to avoid any race conditions in framebuffer 155 - * accesses */ 156 - nwz_run(path_display, args, true); 157 - } 158 - 159 - void nwz_display_text_center(int width, int y, bool big_font, nwz_color_t fg, 160 - nwz_color_t bg, int alpha, const char *text) 161 - { 162 - int txt_w = NWZ_FONT_W(big_font) * strlen(text); 163 - nwz_display_text((width - txt_w) / 2, y, big_font, fg, bg, alpha, text); 164 - } 165 - 166 - void nwz_display_textf(int x, int y, bool big_font, nwz_color_t foreground_col, 167 - nwz_color_t background_col, int alpha, const char *fmt, ...) 168 - { 169 - char buffer[1024]; 170 - va_list args; 171 - va_start(args, fmt); 172 - vsprintf(buffer, fmt, args); 173 - va_end(args); 174 - nwz_display_text(x, y, big_font, foreground_col, background_col, alpha, buffer); 175 - } 176 - 177 - void nwz_display_textf_center(int width, int y, bool big_font, nwz_color_t fg, 178 - nwz_color_t bg, int alpha, const char *fmt, ...) 179 - { 180 - char buffer[1024]; 181 - va_list args; 182 - va_start(args, fmt); 183 - vsprintf(buffer, fmt, args); 184 - va_end(args); 185 - nwz_display_text_center(width, y, big_font, fg, bg, alpha, buffer); 186 - } 187 - 188 - void nwz_display_bitmap(int x, int y, const char *file, int left, int top, 189 - int width, int height, nwz_color_t key_col, int bmp_alpha) 190 - { 191 - const char *path_display = "/usr/local/bin/display"; 192 - const char *args[16]; 193 - int index = 0; 194 - char pos[32], topleft[32], dim[32], key[32], transp[16]; 195 - args[index++] = "display"; 196 - args[index++] = "lcd"; 197 - args[index++] = "bitmap"; 198 - sprintf(pos, "%d,%d", x, y); 199 - args[index++] = pos; 200 - args[index++] = file; 201 - sprintf(topleft, "%d,%d", left, top); 202 - args[index++] = topleft; 203 - sprintf(dim, "%d,%d", width, height); 204 - args[index++] = dim; 205 - if(key_col == NWZ_COLOR_NO_KEY) 206 - sprintf(key, "no"); 207 - else 208 - sprintf(key, "%d,%d,%d", NWZ_COLOR_RGB(key_col)); 209 - args[index++] = key; 210 - sprintf(transp, "%d", bmp_alpha); 211 - args[index++] = transp; 212 - args[index++] = NULL; 213 - /* wait for lcdmsg to finish to avoid any race conditions in framebuffer 214 - * accesses */ 215 - nwz_run(path_display, args, true); 216 - } 217 - 218 - int nwz_input_open(const char *requested_name) 219 - { 220 - /* try all /dev/input/eventX, there can't a lot of them */ 221 - for(int index = 0; index < 8; index++) 222 - { 223 - char buffer[32]; 224 - sprintf(buffer, "/dev/input/event%d", index); 225 - int fd = open(buffer, O_RDWR); 226 - if(fd < 0) 227 - continue; /* try next one */ 228 - /* query name */ 229 - char name[256]; 230 - if(ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0 && 231 - strcmp(name, requested_name) == 0) 232 - return fd; 233 - close(fd); 234 - } 235 - return -1; 236 - } 237 - 238 - int nwz_key_open(void) 239 - { 240 - return nwz_input_open(NWZ_KEY_NAME); 241 - } 242 - 243 - void nwz_key_close(int fd) 244 - { 245 - close(fd); 246 - } 247 - 248 - int nwz_key_get_hold_status(int fd) 249 - { 250 - unsigned long led_hold = 0; 251 - if(ioctl(fd, EVIOCGLED(sizeof(led_hold)), &led_hold) < 0) 252 - return -1; 253 - return led_hold; 254 - } 255 - 256 - int nwz_key_wait_event(int fd, long tmo_us) 257 - { 258 - return nwz_wait_fds(&fd, 1, tmo_us); 259 - } 260 - 261 - int nwz_key_read_event(int fd, struct input_event *evt) 262 - { 263 - int ret = read(fd, evt, sizeof(struct input_event)); 264 - if(ret != sizeof(struct input_event)) 265 - return -1; 266 - return 1; 267 - } 268 - 269 - int nwz_key_event_get_keycode(struct input_event *evt) 270 - { 271 - return evt->code & NWZ_KEY_MASK; 272 - } 273 - 274 - bool nwz_key_event_is_press(struct input_event *evt) 275 - { 276 - return evt->value == 0; 277 - } 278 - 279 - bool nwz_key_event_get_hold_status(struct input_event *evt) 280 - { 281 - return !!(evt->code & NWZ_KEY_HOLD_MASK); 282 - } 283 - 284 - static const char *nwz_keyname[NWZ_KEY_MASK + 1] = 285 - { 286 - [0 ... NWZ_KEY_MASK] = "unknown", 287 - [NWZ_KEY_PLAY] = "PLAY", 288 - [NWZ_KEY_RIGHT] = "RIGHT", 289 - [NWZ_KEY_LEFT] = "LEFT", 290 - [NWZ_KEY_UP] = "UP", 291 - [NWZ_KEY_DOWN] = "DOWN", 292 - [NWZ_KEY_ZAPPIN] = "ZAPPIN", 293 - [NWZ_KEY_AD0_6] = "AD0_6", 294 - [NWZ_KEY_AD0_7] = "AD0_7", 295 - [NWZ_KEY_NONE] = "NONE", 296 - [NWZ_KEY_VOL_DOWN] = "VOL DOWN", 297 - [NWZ_KEY_VOL_UP] = "VOL UP", 298 - [NWZ_KEY_BACK] = "BACK", 299 - [NWZ_KEY_OPTION] = "OPTION", 300 - [NWZ_KEY_BT] = "BT", 301 - [NWZ_KEY_AD1_5] = "AD1_5", 302 - [NWZ_KEY_AD1_6] = "AD1_6", 303 - [NWZ_KEY_AD1_7] = "AD1_7", 304 - }; 305 - 306 - const char *nwz_key_get_name(int keycode) 307 - { 308 - if(keycode <0 || keycode > NWZ_KEY_MASK) 309 - return "invalid"; 310 - else 311 - return nwz_keyname[keycode]; 312 - } 313 - 314 - int nwz_fb_open(bool lcd) 315 - { 316 - return open(lcd ? NWZ_FB_LCD_DEV : NWZ_FB_TV_DEV, O_RDWR); 317 - } 318 - 319 - void nwz_fb_close(int fd) 320 - { 321 - close(fd); 322 - } 323 - 324 - int nwz_fb_get_brightness(int fd, struct nwz_fb_brightness *bl) 325 - { 326 - if(ioctl(fd, NWZ_FB_GET_BRIGHTNESS, bl) < 0) 327 - return -1; 328 - else 329 - return 1; 330 - } 331 - 332 - int nwz_fb_set_brightness(int fd, struct nwz_fb_brightness *bl) 333 - { 334 - if(ioctl(fd, NWZ_FB_SET_BRIGHTNESS, bl) < 0) 335 - return -1; 336 - else 337 - return 1; 338 - } 339 - 340 - int nwz_fb_set_page(int fd, int page) 341 - { 342 - /* set page mode to no transparency and no rotation */ 343 - struct nwz_fb_image_info mode_info; 344 - mode_info.tc_enable = 0; 345 - mode_info.t_color = 0; 346 - mode_info.alpha = 0; 347 - mode_info.rot = 0; 348 - mode_info.page = page; 349 - mode_info.update = NWZ_FB_ONLY_2D_MODE; 350 - if(ioctl(fd, NWZ_FB_UPDATE, &mode_info) < 0) 351 - return -2; 352 - return 0; 353 - } 354 - 355 - int nwz_fb_set_standard_mode(int fd) 356 - { 357 - /* disable timer (apparently useless with LCD) */ 358 - struct nwz_fb_update_timer update_timer; 359 - update_timer.timerflag = NWZ_FB_TIMER_OFF; 360 - update_timer.timeout = NWZ_FB_DEFAULT_TIMEOUT; 361 - if(ioctl(fd, NWZ_FB_UPDATE_TIMER, &update_timer) < 0) 362 - return -1; 363 - return nwz_fb_set_page(fd, 0); 364 - } 365 - 366 - int nwz_fb_get_resolution(int fd, int *x, int *y, int *bpp) 367 - { 368 - struct fb_var_screeninfo vinfo; 369 - if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) 370 - return -1; 371 - if(x) 372 - *x = vinfo.xres; 373 - if(y) 374 - *y = vinfo.yres; 375 - if(bpp) 376 - *bpp = vinfo.bits_per_pixel; 377 - return 0; 378 - } 379 - 380 - void *nwz_fb_mmap(int fd, int offset, int size) 381 - { 382 - return mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)offset); 383 - } 384 - 385 - int nwz_adc_open(void) 386 - { 387 - return open(NWZ_ADC_DEV, O_RDONLY); 388 - } 389 - 390 - void nwz_adc_close(int fd) 391 - { 392 - close(fd); 393 - } 394 - 395 - static const char *nwz_adc_name[] = 396 - { 397 - [NWZ_ADC_VCCBAT] = "VCCBAT", 398 - [NWZ_ADC_VCCVBUS] = "VCCVBUS", 399 - [NWZ_ADC_ADIN3] = "ADIN3", 400 - [NWZ_ADC_ADIN4] = "ADIN4", 401 - [NWZ_ADC_ADIN5] = "ADIN5", 402 - [NWZ_ADC_ADIN6] = "ADIN6", 403 - [NWZ_ADC_ADIN7] = "ADIN7", 404 - [NWZ_ADC_ADIN8] = "ADIN8", 405 - }; 406 - 407 - const char *nwz_adc_get_name(int ch) 408 - { 409 - return nwz_adc_name[ch]; 410 - } 411 - 412 - int nwz_adc_get_val(int fd, int ch) 413 - { 414 - unsigned char val; 415 - if(ioctl(fd, NWZ_ADC_GET_VAL(ch), &val) < 0) 416 - return -1; 417 - else 418 - return val; 419 - } 420 - 421 - int nwz_ts_open(void) 422 - { 423 - return nwz_input_open(NWZ_TS_NAME); 424 - } 425 - 426 - void nwz_ts_close(int fd) 427 - { 428 - close(fd); 429 - } 430 - 431 - int nwz_ts_state_init(int fd, struct nwz_ts_state_t *state) 432 - { 433 - memset(state, 0, sizeof(struct nwz_ts_state_t)); 434 - struct input_absinfo info; 435 - if(ioctl(fd, EVIOCGABS(ABS_X), &info) < 0) 436 - return -1; 437 - state->max_x = info.maximum; 438 - if(ioctl(fd, EVIOCGABS(ABS_Y), &info) < 0) 439 - return -1; 440 - state->max_y = info.maximum; 441 - if(ioctl(fd, EVIOCGABS(ABS_PRESSURE), &info) < 0) 442 - return -1; 443 - state->max_pressure = info.maximum; 444 - if(ioctl(fd, EVIOCGABS(ABS_TOOL_WIDTH), &info) < 0) 445 - return -1; 446 - state->max_tool_width = info.maximum; 447 - return 1; 448 - } 449 - 450 - int nwz_ts_state_update(struct nwz_ts_state_t *state, struct input_event *evt) 451 - { 452 - switch(evt->type) 453 - { 454 - case EV_SYN: 455 - return 1; 456 - case EV_REL: 457 - if(evt->code == REL_RX) 458 - state->flick_x = evt->value; 459 - else if(evt->code == REL_RY) 460 - state->flick_y = evt->value; 461 - else 462 - return -1; 463 - state->flick = true; 464 - break; 465 - case EV_ABS: 466 - if(evt->code == ABS_X) 467 - state->x = evt->value; 468 - else if(evt->code == ABS_Y) 469 - state->y = evt->value; 470 - else if(evt->code == ABS_PRESSURE) 471 - state->pressure = evt->value; 472 - else if(evt->code == ABS_TOOL_WIDTH) 473 - state->tool_width = evt->value; 474 - else 475 - return -1; 476 - break; 477 - case EV_KEY: 478 - if(evt->code == BTN_TOUCH) 479 - state->touch = evt->value; 480 - else 481 - return -1; 482 - break; 483 - default: 484 - return -1; 485 - } 486 - return 0; 487 - } 488 - 489 - int nwz_ts_state_post_syn(struct nwz_ts_state_t *state) 490 - { 491 - state->flick = false; 492 - return 1; 493 - } 494 - 495 - int nwz_ts_read_events(int fd, struct input_event *evts, int nr_evts) 496 - { 497 - int ret = read(fd, evts, nr_evts * sizeof(struct input_event)); 498 - if(ret < 0) 499 - return -1; 500 - return ret / sizeof(struct input_event); 501 - } 502 - 503 - long nwz_wait_fds(int *fds, int nr_fds, long tmo_us) 504 - { 505 - fd_set rfds; 506 - struct timeval tv; 507 - struct timeval *tv_ptr = NULL; 508 - /* watch the input device */ 509 - FD_ZERO(&rfds); 510 - int max_fd = 0; 511 - for(int i = 0; i < nr_fds; i++) 512 - { 513 - FD_SET(fds[i], &rfds); 514 - if(fds[i] > max_fd) 515 - max_fd = fds[i]; 516 - } 517 - /* setup timeout */ 518 - if(tmo_us >= 0) 519 - { 520 - tv.tv_sec = 0; 521 - tv.tv_usec = tmo_us; 522 - tv_ptr = &tv; 523 - } 524 - int ret = select(max_fd + 1, &rfds, NULL, NULL, tv_ptr); 525 - if(ret <= 0) 526 - return ret; 527 - long bitmap = 0; 528 - for(int i = 0; i < nr_fds; i++) 529 - if(FD_ISSET(fds[i], &rfds)) 530 - bitmap |= 1 << i; 531 - return bitmap; 532 - } 533 - 534 - int nwz_power_open(void) 535 - { 536 - return open(NWZ_POWER_DEV, O_RDWR); 537 - } 538 - 539 - void nwz_power_close(int fd) 540 - { 541 - close(fd); 542 - } 543 - 544 - int nwz_power_get_status(int fd) 545 - { 546 - int status; 547 - if(ioctl(fd, NWZ_POWER_GET_STATUS, &status) < 0) 548 - return -1; 549 - return status; 550 - } 551 - 552 - static int nwz_power_adval_to_mv(int adval, int ad_base) 553 - { 554 - if(adval == -1) 555 - return -1; 556 - /* the AD base corresponds to the millivolt value if adval was 255 */ 557 - return (adval * ad_base) / 255; 558 - } 559 - 560 - int nwz_power_get_vbus_adval(int fd) 561 - { 562 - int status; 563 - if(ioctl(fd, NWZ_POWER_GET_VBUS_ADVAL, &status) < 0) 564 - return -1; 565 - return status; 566 - } 567 - 568 - int nwz_power_get_vbus_voltage(int fd) 569 - { 570 - return nwz_power_adval_to_mv(nwz_power_get_vbus_adval(fd), NWZ_POWER_AD_BASE_VBUS); 571 - } 572 - 573 - int nwz_power_get_vbus_limit(int fd) 574 - { 575 - int status; 576 - if(ioctl(fd, NWZ_POWER_GET_VBUS_LIMIT, &status) < 0) 577 - return -1; 578 - return status; 579 - } 580 - 581 - int nwz_power_get_charge_switch(int fd) 582 - { 583 - int status; 584 - if(ioctl(fd, NWZ_POWER_GET_CHARGE_SWITCH, &status) < 0) 585 - return -1; 586 - return status; 587 - } 588 - 589 - int nwz_power_get_charge_current(int fd) 590 - { 591 - int status; 592 - if(ioctl(fd, NWZ_POWER_GET_CHARGE_CURRENT, &status) < 0) 593 - return -1; 594 - return status; 595 - } 596 - 597 - int nwz_power_get_battery_gauge(int fd) 598 - { 599 - int status; 600 - if(ioctl(fd, NWZ_POWER_GET_BAT_GAUGE, &status) < 0) 601 - return -1; 602 - return status; 603 - } 604 - 605 - int nwz_power_get_battery_adval(int fd) 606 - { 607 - int status; 608 - if(ioctl(fd, NWZ_POWER_GET_BAT_ADVAL, &status) < 0) 609 - return -1; 610 - return status; 611 - } 612 - 613 - int nwz_power_get_battery_voltage(int fd) 614 - { 615 - return nwz_power_adval_to_mv(nwz_power_get_battery_adval(fd), NWZ_POWER_AD_BASE_VBAT); 616 - } 617 - 618 - int nwz_power_get_vbat_adval(int fd) 619 - { 620 - int status; 621 - if(ioctl(fd, NWZ_POWER_GET_VBAT_ADVAL, &status) < 0) 622 - return -1; 623 - return status; 624 - } 625 - 626 - int nwz_power_get_vbat_voltage(int fd) 627 - { 628 - return nwz_power_adval_to_mv(nwz_power_get_vbat_adval(fd), NWZ_POWER_AD_BASE_VBAT); 629 - } 630 - 631 - int nwz_power_get_sample_count(int fd) 632 - { 633 - int status; 634 - if(ioctl(fd, NWZ_POWER_GET_SAMPLE_COUNT, &status) < 0) 635 - return -1; 636 - return status; 637 - } 638 - 639 - int nwz_power_get_vsys_adval(int fd) 640 - { 641 - int status; 642 - if(ioctl(fd, NWZ_POWER_GET_VSYS_ADVAL, &status) < 0) 643 - return -1; 644 - return status; 645 - } 646 - 647 - int nwz_power_get_vsys_voltage(int fd) 648 - { 649 - return nwz_power_adval_to_mv(nwz_power_get_vsys_adval(fd), NWZ_POWER_AD_BASE_VSYS); 650 - } 651 - 652 - int nwz_power_get_acc_charge_mode(int fd) 653 - { 654 - int status; 655 - if(ioctl(fd, NWZ_POWER_GET_ACCESSARY_CHARGE_MODE, &status) < 0) 656 - return -1; 657 - return status; 658 - } 659 - 660 - int nwz_power_is_fully_charged(int fd) 661 - { 662 - int status; 663 - if(ioctl(fd, NWZ_POWER_IS_FULLY_CHARGED, &status) < 0) 664 - return -1; 665 - return status; 666 - } 667 - 668 - int nwz_pminfo_open(void) 669 - { 670 - return open(NWZ_PMINFO_DEV, O_RDONLY); 671 - } 672 - 673 - void nwz_pminfo_close(int fd) 674 - { 675 - close(fd); 676 - } 677 - 678 - unsigned int nwz_pminfo_get_factor(int fd) 679 - { 680 - unsigned int val; 681 - if(ioctl(fd, NWZ_PMINFO_GET_FACTOR, &val) < 0) 682 - return 0; 683 - else 684 - return val; 685 - } 686 - 687 - static unsigned long find_model_id(void) 688 - { 689 - /* try with the environment variable */ 690 - const char *mid = getenv("ICX_MODEL_ID"); 691 - if(mid == NULL) 692 - return 0; 693 - char *end; 694 - unsigned long v = strtoul(mid, &end, 0); 695 - if(*end) 696 - return 0; 697 - else 698 - return v; 699 - } 700 - 701 - unsigned long nwz_get_model_id(void) 702 - { 703 - static unsigned long model_id = 0xffffffff; 704 - if(model_id == 0xffffffff) 705 - model_id = find_model_id(); 706 - return model_id; 707 - } 708 - 709 - const char *nwz_get_model_name() 710 - { 711 - for(int i = 0; i < NWZ_MODEL_COUNT; i++) 712 - if(nwz_model[i].mid == nwz_get_model_id()) 713 - return nwz_model[i].name; 714 - return NULL; 715 - } 716 - 717 - static int find_series(void) 718 - { 719 - for(int i = 0; i < NWZ_SERIES_COUNT; i++) 720 - for(int j = 0; j < nwz_series[i].mid_count; j++) 721 - if(nwz_series[i].mid[j] == nwz_get_model_id()) 722 - return i; 723 - return -1; 724 - } 725 - 726 - int nwz_get_series(void) 727 - { 728 - static int series = -2; 729 - if(series == -2) 730 - series = find_series(); 731 - return series; 732 - } 733 - 734 - static nwz_nvp_index_t *get_nvp_index(void) 735 - { 736 - static nwz_nvp_index_t *index = 0; 737 - if(index == 0) 738 - { 739 - int series = nwz_get_series(); 740 - index = series < 0 ? 0 : nwz_series[series].nvp_index; 741 - } 742 - return index; 743 - } 744 - 745 - int nwz_nvp_read(enum nwz_nvp_node_t node, void *data) 746 - { 747 - int size = nwz_nvp[node].size; 748 - if(data == 0) 749 - return size; 750 - nwz_nvp_index_t *index = get_nvp_index(); 751 - if(index == 0 || (*index)[node] == NWZ_NVP_INVALID) 752 - return -1; 753 - char nvp_path[32]; 754 - snprintf(nvp_path, sizeof(nvp_path), "/dev/icx_nvp/%03d", (*index)[node]); 755 - int fd = open(nvp_path, O_RDONLY); 756 - if(fd < 0) 757 - return -1; 758 - int cnt = read(fd, data, size); 759 - close(fd); 760 - return cnt == size ? size : -1; 761 - } 762 - 763 - int nwz_nvp_write(enum nwz_nvp_node_t node, void *data) 764 - { 765 - int size = nwz_nvp[node].size; 766 - nwz_nvp_index_t *index = get_nvp_index(); 767 - if(index == 0 || (*index)[node] == NWZ_NVP_INVALID) 768 - return -1; 769 - char nvp_path[32]; 770 - snprintf(nvp_path, sizeof(nvp_path), "/dev/icx_nvp/%03d", (*index)[node]); 771 - int fd = open(nvp_path, O_WRONLY); 772 - if(fd < 0) 773 - return -1; 774 - int cnt = write(fd, data, size); 775 - close(fd); 776 - return cnt == size ? 0 : -1; 777 - }
-220
utils/nwztools/plattools/nwz_lib.h
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 _NWZLIB_H_ 22 - #define _NWZLIB_H_ 23 - 24 - #include <stdio.h> 25 - #include <stdbool.h> 26 - #include <stdarg.h> 27 - #include <unistd.h> 28 - #include <sys/types.h> 29 - #include <sys/wait.h> 30 - #include <linux/input.h> 31 - #include <linux/fb.h> 32 - #include <fcntl.h> 33 - #include <string.h> 34 - #include <stdlib.h> 35 - #include <sys/mman.h> 36 - 37 - #include "nwz_keys.h" 38 - #include "nwz_fb.h" 39 - #include "nwz_adc.h" 40 - #include "nwz_ts.h" 41 - #include "nwz_power.h" 42 - #include "nwz_db.h" 43 - 44 - /* get model ID, either from ICX_MODEL_ID env var or using nvpflag, return 0 45 - * in case of error; note that the result is cached so this function is only 46 - * expensive the first time it is called */ 47 - unsigned long nwz_get_model_id(void); 48 - /* get series (index into nwz_series, or -1 on error) */ 49 - int nwz_get_series(void); 50 - /* get model name, or null on error */ 51 - const char *nwz_get_model_name(void); 52 - 53 - /* run a program and exit with nonzero status in case of error 54 - * argument list must be NULL terminated */ 55 - int nwz_run(const char *file, const char *args[], bool wait); 56 - /* run a program and return program output */ 57 - char *nwz_run_pipe(const char *file, const char *args[], int *status); 58 - 59 - /* invoke /usr/local/bin/lcdmsg to display a message using the small font, optionally 60 - * clearing the screen before */ 61 - void nwz_lcdmsg(bool clear, int x, int y, const char *msg); 62 - void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...); 63 - /* invoke /usr/local/bin/display to do various things: 64 - * - clear screen 65 - * - display text 66 - * - display bitmap 67 - * Currently all operations are performed on the LCD only. 68 - * The small text font is 8x12 and the big one is 14x24 */ 69 - typedef int nwz_color_t; 70 - #define NWZ_COLOR(r, g, b) /* each component between 0 and 255 */ \ 71 - ((r) << 16 | (g) << 8 | (b)) 72 - #define NWZ_COLOR_RED(col) ((col) >> 16) 73 - #define NWZ_COLOR_GREEN(col) (((col) >> 8) & 0xff) 74 - #define NWZ_COLOR_BLUE(col) ((col) & 0xff) 75 - #define NWZ_COLOR_NO_KEY (1 << 24) 76 - 77 - #define NWZ_FONT_W(big_font) ((big_font) ? 14 : 8) 78 - #define NWZ_FONT_H(big_font) ((big_font) ? 24 : 14) 79 - 80 - void nwz_display_clear(nwz_color_t color); 81 - void nwz_display_text(int x, int y, bool big_font, nwz_color_t foreground_col, 82 - nwz_color_t background_col, int background_alpha, const char *text); 83 - void nwz_display_text_center(int width, int y, bool big_font, nwz_color_t foreground_col, 84 - nwz_color_t background_col, int background_alpha, const char *text); 85 - void nwz_display_textf(int x, int y, bool big_font, nwz_color_t foreground_col, 86 - nwz_color_t background_col, int background_alpha, const char *fmt, ...); 87 - void nwz_display_textf_center(int width, int y, bool big_font, nwz_color_t foreground_col, 88 - nwz_color_t background_col, int background_alpha, const char *fmt, ...); 89 - void nwz_display_bitmap(int x, int y, const char *file, int left, int top, 90 - int width, int height, nwz_color_t key, int bmp_alpha); 91 - 92 - /* open icx_key input device and return file descriptor */ 93 - int nwz_key_open(void); 94 - void nwz_key_close(int fd); 95 - /* return HOLD status: 0 or 1, or -1 on error */ 96 - int nwz_key_get_hold_status(int fd); 97 - /* wait for an input event (and return 1), or a timeout (return 0), or error (-1) 98 - * set the timeout to -1 to block */ 99 - int nwz_key_wait_event(int fd, long tmo_us); 100 - /* read an event from the device (may block unless you waited for an event before), 101 - * return 1 on success, <0 on error */ 102 - int nwz_key_read_event(int fd, struct input_event *evt); 103 - /* return keycode from event */ 104 - int nwz_key_event_get_keycode(struct input_event *evt); 105 - /* return press/released status from event */ 106 - bool nwz_key_event_is_press(struct input_event *evt); 107 - /* return HOLD status from event */ 108 - bool nwz_key_event_get_hold_status(struct input_event *evt); 109 - /* get keycode name */ 110 - const char *nwz_key_get_name(int keycode); 111 - 112 - /* open framebuffer device */ 113 - int nwz_fb_open(bool lcd); 114 - /* close framebuffer device */ 115 - void nwz_fb_close(int fb); 116 - /* get screen resolution, parameters are allowed to be NULL */ 117 - int nwz_fb_get_resolution(int fd, int *x, int *y, int *bpp); 118 - /* get backlight brightness (return -1 on error, 1 on success) */ 119 - int nwz_fb_get_brightness(int fd, struct nwz_fb_brightness *bl); 120 - /* set backlight brightness (return -1 on error, 1 on success) */ 121 - int nwz_fb_set_brightness(int fd, struct nwz_fb_brightness *bl); 122 - /* setup framebuffer to its standard mode: LCD output, page 0, no transparency 123 - * and no rotation, 2D only updates */ 124 - int nwz_fb_set_standard_mode(int fd); 125 - /* change framebuffer page and update screen */ 126 - int nwz_fb_set_page(int fd, int page); 127 - /* map framebuffer */ 128 - void *nwz_fb_mmap(int fd, int offset, int size); 129 - 130 - /* open adc device */ 131 - int nwz_adc_open(void); 132 - /* close adc device */ 133 - void nwz_adc_close(int fd); 134 - /* get channel name */ 135 - const char *nwz_adc_get_name(int ch); 136 - /* read channel value, return -1 on error */ 137 - int nwz_adc_get_val(int fd, int ch); 138 - 139 - /* open touchscreen device */ 140 - int nwz_ts_open(void); 141 - /* close touchscreen device */ 142 - void nwz_ts_close(int fd); 143 - /* structure to track touch state */ 144 - struct nwz_ts_state_t 145 - { 146 - int x, y; /* current position (valid is touch is true) */ 147 - int max_x, max_y; /* maximum possible values */ 148 - int pressure, tool_width; /* current pressure and tool width */ 149 - int max_pressure, max_tool_width; /* maximum possible values */ 150 - bool touch; /* is the user touching the screen? */ 151 - bool flick; /* was the action a flick? */ 152 - int flick_x, flick_y; /* if so, this is the flick direction */ 153 - }; 154 - /* get touchscreen information and init state, return -1 on error, 1 on success */ 155 - int nwz_ts_state_init(int fd, struct nwz_ts_state_t *state); 156 - /* update state with an event, return -1 on unhandled event, >=0 on handled: 157 - * 1 if sync event, 0 otherwise */ 158 - int nwz_ts_state_update(struct nwz_ts_state_t *state, struct input_event *evt); 159 - /* update state after a sync event to prepare for next round of events */ 160 - int nwz_ts_state_post_syn(struct nwz_ts_state_t *state); 161 - /* read at most N events from touch screen, and return the number of events */ 162 - int nwz_ts_read_events(int fd, struct input_event *evts, int nr_evts); 163 - 164 - /* wait for events on several file descriptors, return a bitmap of active ones 165 - * or 0 on timeout, the timeout can be -1 to block */ 166 - long nwz_wait_fds(int *fds, int nr_fds, long timeout_us); 167 - 168 - /* open power device */ 169 - int nwz_power_open(void); 170 - /* close power device */ 171 - void nwz_power_close(int fd); 172 - /* get power status (return -1 on error, bitmap on success) */ 173 - int nwz_power_get_status(int fd); 174 - /* get vbus adval (or -1 on error) */ 175 - int nwz_power_get_vbus_adval(int fd); 176 - /* get vbus voltage in mV (or -1 on error) */ 177 - int nwz_power_get_vbus_voltage(int fd); 178 - /* get vbus current limit (or -1 on error) */ 179 - int nwz_power_get_vbus_limit(int fd); 180 - /* get charge switch (or -1 on error) */ 181 - int nwz_power_get_charge_switch(int fd); 182 - /* get charge current (or -1 on error) */ 183 - int nwz_power_get_charge_current(int fd); 184 - /* get battery gauge (or -1 on error) */ 185 - int nwz_power_get_battery_gauge(int fd); 186 - /* get battery adval (or -1 on error) */ 187 - int nwz_power_get_battery_adval(int fd); 188 - /* get battery voltage in mV (or -1 on error) */ 189 - int nwz_power_get_battery_voltage(int fd); 190 - /* get vbat adval (or -1 on error) */ 191 - int nwz_power_get_vbat_adval(int fd); 192 - /* get vbat voltage (or -1 on error) */ 193 - int nwz_power_get_vbat_voltage(int fd); 194 - /* get sample count (or -1 on error) */ 195 - int nwz_power_get_sample_count(int fd); 196 - /* get vsys adval (or -1 on error) */ 197 - int nwz_power_get_vsys_adval(int fd); 198 - /* get vsys voltage in mV (or -1 on error) */ 199 - int nwz_power_get_vsys_voltage(int fd); 200 - /* get accessory charge mode */ 201 - int nwz_power_get_acc_charge_mode(int fd); 202 - /* is battery fully charged? (or -1 on error) */ 203 - int nwz_power_is_fully_charged(int fd); 204 - 205 - /* open pminfo device */ 206 - int nwz_pminfo_open(void); 207 - /* close pminfo device */ 208 - void nwz_pminfo_close(int fd); 209 - /* get pminfo factor (or 0 on error) */ 210 - unsigned int nwz_pminfo_get_factor(int fd); 211 - 212 - /* read a nvp node and return its size, if the data pointer is null, then simply 213 - * return the size, return -1 on error */ 214 - int nwz_nvp_read(enum nwz_nvp_node_t node, void *data); 215 - /* write a nvp node, return 0 on success and -1 on error, the size of the buffer 216 - * must be the one returned by nwz_nvp_read */ 217 - int nwz_nvp_write(enum nwz_nvp_node_t node, void *data); 218 - 219 - 220 - #endif /* _NWZLIB_H_ */
+17 -13
utils/nwztools/plattools/nwz_plattools.h rbutil/mknwzboot/mknwzboot.h
··· 9 9 * 10 10 * Copyright (C) 2011 by Amaury Pouly 11 11 * 12 - * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing 13 - * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach 14 - * 15 12 * This program is free software; you can redistribute it and/or 16 13 * modify it under the terms of the GNU General Public License 17 14 * as published by the Free Software Foundation; either version 2 ··· 21 18 * KIND, either express or implied. 22 19 * 23 20 ****************************************************************************/ 24 - #ifndef __NWZ_PLATTOOLS_H__ 25 - #define __NWZ_PLATTOOLS_H__ 26 21 27 - /** Platform tools can be either built individually, or be included in a 28 - * single build (or even dualboot code) for easy testing. Thus, each tool must 29 - * use the following macros to support all scenarios. */ 22 + #ifndef MKIMXBOOT_H 23 + #define MKIMXBOOT_H 30 24 31 - #ifdef NWZ_EMBED_TOOLS 32 - #define NWZ_TOOL_MAIN(tool) tool##_main 33 - #else 34 - #define NWZ_TOOL_MAIN(tool) main 25 + #include <stdbool.h> 26 + #include <stdint.h> 27 + #include <sys/types.h> 28 + 29 + #ifdef __cplusplus 30 + extern "C" { 35 31 #endif 36 32 37 - #endif /* __NWZ_PLATTOOLS_H__ */ 33 + void dump_nwz_dev_info(const char *prefix); 34 + /* return 0 on success */ 35 + int mknwzboot(const char *bootfile, const char *outfile, bool debug); 36 + 37 + #ifdef __cplusplus 38 + } 39 + #endif 40 + #endif 41 +
+43 -3
utils/nwztools/plattools/nwz_power.h firmware/target/hosted/sonynwz/power-nwz.h
··· 18 18 * KIND, either express or implied. 19 19 * 20 20 ****************************************************************************/ 21 - #ifndef __NWZ_POWER_H__ 22 - #define __NWZ_POWER_H__ 21 + #ifndef __POWER_NWZ_H__ 22 + #define __POWER_NWZ_H__ 23 + 24 + #include "power.h" 23 25 24 26 /** power */ 25 27 ··· 112 114 #define ICX_PMINFO_FACTOR_KEY_PAD 0x00001000 /* keypad */ 113 115 #define ICX_PMINFO_FACTOR_KEY_CODE 0x00000FFF /* keycode */ 114 116 115 - #endif /* __NWZ_POWER_H__ */ 117 + void power_init(void); 118 + /* get power status (return -1 on error, bitmap on success) */ 119 + int nwz_power_get_status(void); 120 + /* get vbus adval (or -1 on error) */ 121 + int nwz_power_get_vbus_adval(void); 122 + /* get vbus voltage in mV (or -1 on error) */ 123 + int nwz_power_get_vbus_voltage(void); 124 + /* get vbus current limit (or -1 on error) */ 125 + int nwz_power_get_vbus_limit(void); 126 + /* get charge switch (or -1 on error) */ 127 + int nwz_power_get_charge_switch(void); 128 + /* get charge current (or -1 on error) */ 129 + int nwz_power_get_charge_current(void); 130 + /* get battery gauge (or -1 on error) */ 131 + int nwz_power_get_battery_gauge(void); 132 + /* get battery adval (or -1 on error) */ 133 + int nwz_power_get_battery_adval(void); 134 + /* get battery voltage in mV (or -1 on error) */ 135 + int nwz_power_get_battery_voltage(void); 136 + /* get vbat adval (or -1 on error) */ 137 + int nwz_power_get_vbat_adval(void); 138 + /* get vbat voltage (or -1 on error) */ 139 + int nwz_power_get_vbat_voltage(void); 140 + /* get sample count (or -1 on error) */ 141 + int nwz_power_get_sample_count(void); 142 + /* get vsys adval (or -1 on error) */ 143 + int nwz_power_get_vsys_adval(void); 144 + /* get vsys voltage in mV (or -1 on error) */ 145 + int nwz_power_get_vsys_voltage(void); 146 + /* get accessory charge mode */ 147 + int nwz_power_get_acc_charge_mode(void); 148 + /* is battery fully charged? (or -1 on error) */ 149 + int nwz_power_is_fully_charged(void); 150 + /* change power state (-1 on error, 0 otherwise)*/ 151 + int nwz_power_suspend(void); 152 + int nwz_power_shutdown(void); 153 + int nwz_power_restart(void); 154 + 155 + #endif /* __POWER_NWZ_H__ */
utils/nwztools/plattools/nwz_ts.h firmware/target/hosted/sonynwz/nwz_ts.h
-67
utils/nwztools/plattools/test_adc.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - int NWZ_TOOL_MAIN(test_adc)(int argc, char **argv) 25 - { 26 - /* clear screen and display welcome message */ 27 - nwz_lcdmsg(true, 0, 0, "test_adc"); 28 - nwz_lcdmsg(false, 0, 2, "BACK: quit"); 29 - /* open input device */ 30 - int input_fd = nwz_key_open(); 31 - if(input_fd < 0) 32 - { 33 - nwz_lcdmsg(false, 3, 4, "Cannot open input device"); 34 - sleep(2); 35 - return 1; 36 - } 37 - /* open adc device */ 38 - int adc_fd = nwz_adc_open(); 39 - if(adc_fd < 0) 40 - { 41 - nwz_key_close(input_fd); 42 - nwz_lcdmsg(false, 3, 4, "Cannot open adc device"); 43 - sleep(2); 44 - return 1; 45 - } 46 - /* display input state in a loop */ 47 - while(1) 48 - { 49 - /* print channels */ 50 - for(int i = NWZ_ADC_MIN_CHAN; i <= NWZ_ADC_MAX_CHAN; i++) 51 - nwz_lcdmsgf(false, 1, 4 + i, "%s: %d ", nwz_adc_get_name(i), 52 - nwz_adc_get_val(adc_fd, i)); 53 - /* wait for event (10ms) */ 54 - int ret = nwz_key_wait_event(input_fd, 10000); 55 - if(ret != 1) 56 - continue; 57 - struct input_event evt; 58 - if(nwz_key_read_event(input_fd, &evt) != 1) 59 - continue; 60 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt)) 61 - break; 62 - } 63 - /* finish nicely */ 64 - nwz_key_close(input_fd); 65 - nwz_adc_close(adc_fd); 66 - return 0; 67 - }
-112
utils/nwztools/plattools/test_bl.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - int NWZ_TOOL_MAIN(test_bl)(int argc, char **argv) 25 - { 26 - /* clear screen and display welcome message */ 27 - nwz_lcdmsg(true, 0, 0, "test_bl"); 28 - nwz_lcdmsg(false, 0, 2, "LEFT/RIGHT: level"); 29 - nwz_lcdmsg(false, 0, 3, "UP/DOWN: step"); 30 - nwz_lcdmsg(false, 0, 4, "VOL UP/DOWN: period"); 31 - nwz_lcdmsg(false, 0, 5, "BACK: quit"); 32 - /* open input and framebuffer device */ 33 - int input_fd = nwz_key_open(); 34 - if(input_fd < 0) 35 - { 36 - nwz_lcdmsg(false, 3, 7, "Cannot open input device"); 37 - sleep(2); 38 - return 1; 39 - } 40 - int fb_fd = nwz_fb_open(true); 41 - if(fb_fd < 0) 42 - { 43 - nwz_key_close(input_fd); 44 - nwz_lcdmsg(false, 3, 7, "Cannot open framebuffer device"); 45 - sleep(2); 46 - return 1; 47 - } 48 - /* display input state in a loop */ 49 - while(1) 50 - { 51 - struct nwz_fb_brightness bl; 52 - if(nwz_fb_get_brightness(fb_fd, &bl) == 1) 53 - { 54 - nwz_lcdmsgf(false, 1, 7, "level: %d ", bl.level); 55 - nwz_lcdmsgf(false, 1, 8, "step: %d ", bl.step); 56 - nwz_lcdmsgf(false, 1, 9, "period: %d ", bl.period); 57 - } 58 - /* wait for event */ 59 - int ret = nwz_key_wait_event(input_fd, -1); 60 - if(ret != 1) 61 - continue; 62 - struct input_event evt; 63 - if(nwz_key_read_event(input_fd, &evt) != 1) 64 - continue; 65 - int code = nwz_key_event_get_keycode(&evt); 66 - bool press = nwz_key_event_is_press(&evt); 67 - /* only act on release */ 68 - if(press) 69 - continue; 70 - if(code == NWZ_KEY_BACK) 71 - break; /* quit */ 72 - bool change_bl = false; 73 - if(code == NWZ_KEY_RIGHT && bl.level < NWZ_FB_BL_MAX_LEVEL) 74 - { 75 - change_bl = true; 76 - bl.level++; 77 - } 78 - else if(code == NWZ_KEY_LEFT && bl.level > NWZ_FB_BL_MIN_LEVEL) 79 - { 80 - change_bl = true; 81 - bl.level--; 82 - } 83 - else if(code == NWZ_KEY_UP && bl.step < NWZ_FB_BL_MAX_STEP) 84 - { 85 - change_bl = true; 86 - bl.step++; 87 - } 88 - else if(code == NWZ_KEY_DOWN && bl.step > NWZ_FB_BL_MIN_STEP) 89 - { 90 - change_bl = true; 91 - bl.step--; 92 - } 93 - else if(code == NWZ_KEY_VOL_UP && bl.period < 100) /* artificial bound on period */ 94 - { 95 - change_bl = true; 96 - bl.period++; 97 - } 98 - else if(code == NWZ_KEY_VOL_DOWN && bl.period > NWZ_FB_BL_MIN_PERIOD) 99 - { 100 - change_bl = true; 101 - bl.period--; 102 - } 103 - /* change bl */ 104 - if(change_bl) 105 - nwz_fb_set_brightness(fb_fd, &bl); 106 - } 107 - /* close input device */ 108 - nwz_key_close(input_fd); 109 - nwz_fb_close(fb_fd); 110 - /* finish nicely */ 111 - return 0; 112 - }
-67
utils/nwztools/plattools/test_display.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - int NWZ_TOOL_MAIN(test_display)(int argc, char **argv) 25 - { 26 - /* clear screen and display welcome message */ 27 - nwz_display_clear(NWZ_COLOR(128, 128, 0)); 28 - nwz_display_text(0, 0, true, NWZ_COLOR(255, 0, 0), NWZ_COLOR(0, 0, 255), 0, 29 - "Hello"); 30 - nwz_display_text(0, 30, false, NWZ_COLOR(255, 0, 0), NWZ_COLOR(0, 0, 255), 128, 31 - "BACK: quit"); 32 - nwz_display_text(0, 50, false, NWZ_COLOR(255, 0, 0), NWZ_COLOR(0, 0, 255), 255, 33 - "BACK: quit"); 34 - /* display /contents/display.bmp if any */ 35 - const char *bmp_fname = "/contents/display.bmp"; 36 - if(access(bmp_fname, R_OK) != -1) 37 - { 38 - nwz_display_bitmap(10, 70, bmp_fname, 0, 0, 200, 200, NWZ_COLOR_NO_KEY, 255); 39 - } 40 - else 41 - { 42 - nwz_display_text(0, 70, false, NWZ_COLOR(255, 0, 0), NWZ_COLOR(0, 0, 0), 0, 43 - "Cannot find display.bmp"); 44 - } 45 - /* wait for key */ 46 - int input_fd = nwz_key_open(); 47 - if(input_fd < 0) 48 - { 49 - sleep(2); 50 - return 1; 51 - } 52 - while(1) 53 - { 54 - /* wait for event */ 55 - int ret = nwz_key_wait_event(input_fd, 1000000); 56 - if(ret != 1) 57 - continue; 58 - struct input_event evt; 59 - if(nwz_key_read_event(input_fd, &evt) != 1) 60 - continue; 61 - /* handle quit */ 62 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt)) 63 - break; 64 - } 65 - nwz_key_close(input_fd); 66 - return 0; 67 - }
-152
utils/nwztools/plattools/test_fb.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 10 - * Copyright (C) 2011 by Amaury Pouly 11 - * 12 - * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing 13 - * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach 14 - * 15 - * This program is free software; you can redistribute it and/or 16 - * modify it under the terms of the GNU General Public License 17 - * as published by the Free Software Foundation; either version 2 18 - * of the License, or (at your option) any later version. 19 - * 20 - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 - * KIND, either express or implied. 22 - * 23 - ****************************************************************************/ 24 - #include "nwz_lib.h" 25 - #include "nwz_plattools.h" 26 - #include <linux/fb.h> 27 - #include <stdint.h> 28 - #include <sys/mman.h> 29 - 30 - static struct fb_fix_screeninfo finfo; 31 - static struct fb_var_screeninfo vinfo; 32 - static uint8_t *framebuffer; 33 - 34 - static inline uint32_t read32(uint8_t *p) 35 - { 36 - return *p | *(p + 1) << 8 | *(p + 2) << 16 | *(p + 3) << 24; 37 - } 38 - 39 - static inline void write32(uint8_t *p, uint32_t val) 40 - { 41 - *p++ = val & 0xff; val >>= 8; 42 - *p++ = val & 0xff; val >>= 8; 43 - *p++ = val & 0xff; val >>= 8; 44 - *p++ = val; 45 - } 46 - 47 - /* assume lsb and little-endian */ 48 - static inline void put_pix_mask(uint8_t *location, int offset, int len, uint8_t pix) 49 - { 50 - /* adjust pixel */ 51 - pix >>= 8 - len; 52 - uint32_t mask = ((1 << len) - 1) << offset; 53 - uint32_t val = read32(location); 54 - val = ((val) & ~mask) | pix << offset; 55 - write32(location, val); 56 - } 57 - 58 - static inline void put_pix(int x, int y, uint8_t r, uint8_t g, uint8_t b) 59 - { 60 - x += vinfo.xoffset; 61 - y += vinfo.yoffset; 62 - uint8_t *location = framebuffer + x * (vinfo.bits_per_pixel / 8) + y * finfo.line_length; 63 - put_pix_mask(location, vinfo.red.offset, vinfo.red.length, r); 64 - put_pix_mask(location, vinfo.green.offset, vinfo.green.length, g); 65 - put_pix_mask(location, vinfo.blue.offset, vinfo.blue.length, b); 66 - } 67 - 68 - static void dump_fb(FILE *out, const char *path) 69 - { 70 - fprintf(out, "%s:\n", path); 71 - int fd = open(path, O_RDWR); 72 - if(fd < 0) 73 - { 74 - fprintf(out, " cannot open"); 75 - return; 76 - } 77 - /* get fixed info */ 78 - if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) 79 - { 80 - fprintf(out, " ioctl failed (fix info)"); 81 - close(fd); 82 - return; 83 - } 84 - fprintf(out, " identification: %s\n", finfo.id); 85 - fprintf(out, " type: %d\n", finfo.type); 86 - fprintf(out, " visual: %d\n", finfo.visual); 87 - fprintf(out, " accel: %d\n", finfo.accel); 88 - fprintf(out, " line length: %d\n", finfo.line_length); 89 - fprintf(out, " mem length: %d\n", finfo.smem_len); 90 - /* get variable info */ 91 - if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) 92 - { 93 - close(fd); 94 - fprintf(out, " ioctl failed (var info)"); 95 - return; 96 - } 97 - fprintf(out, " xres: %d\n", vinfo.xres); 98 - fprintf(out, " yres: %d\n", vinfo.yres); 99 - fprintf(out, " xoff: %d\n", vinfo.xoffset); 100 - fprintf(out, " yoff: %d\n", vinfo.yoffset); 101 - fprintf(out, " bbp: %d\n", vinfo.bits_per_pixel); 102 - fprintf(out, " red: %d-%d\n", vinfo.red.offset + vinfo.red.length - 1, vinfo.red.offset); 103 - fprintf(out, " green: %d-%d\n", vinfo.green.offset + vinfo.green.length - 1, vinfo.green.offset); 104 - fprintf(out, " blue: %d-%d\n", vinfo.blue.offset + vinfo.blue.length - 1, vinfo.blue.offset); 105 - /* get mode info */ 106 - struct nwz_fb_image_info mode_info; 107 - nwz_fb_set_standard_mode(fd); 108 - if(ioctl(fd, NWZ_FB_GET_MODE, &mode_info) < 0) 109 - { 110 - close(fd); 111 - fprintf(out, " ioctl failed (get mode)\n"); 112 - return; 113 - } 114 - fprintf(out, " tc_enable: %d\n", mode_info.tc_enable); 115 - fprintf(out, " t_color: %d\n", mode_info.t_color); 116 - fprintf(out, " alpha: %d\n", mode_info.alpha); 117 - fprintf(out, " rot: %d\n", mode_info.rot); 118 - fprintf(out, " page: %d\n", mode_info.page); 119 - fprintf(out, " update: %d\n", mode_info.update); 120 - /* mmap device (but avoid TV) */ 121 - if(vinfo.xres != 720) 122 - { 123 - long screensize = vinfo.yres_virtual * finfo.line_length; 124 - framebuffer = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0); 125 - if(framebuffer == 0) 126 - { 127 - close(fd); 128 - fprintf(out, " mmap failed"); 129 - return; 130 - } 131 - for(int y = 0; y < 10; y++) 132 - for(int x = 0; x < 10; x++) 133 - { 134 - put_pix(x, y, 0xff, 0, 0); 135 - put_pix(x + 10, y, 0, 0xff, 0); 136 - put_pix(x + 20, y, 0, 0, 0xff); 137 - } 138 - } 139 - sleep(3); 140 - close(fd); 141 - } 142 - 143 - int NWZ_TOOL_MAIN(test_fb)(int argc, char **argv) 144 - { 145 - FILE *f = fopen("/contents/fb.txt", "w"); 146 - if(!f) 147 - f = stdout; 148 - dump_fb(f, "/dev/fb/0"); 149 - if(f) 150 - fclose(f); 151 - return 0; 152 - }
-105
utils/nwztools/plattools/test_keys.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - int NWZ_TOOL_MAIN(test_keys)(int argc, char **argv) 25 - { 26 - /* clear screen and display welcome message */ 27 - nwz_lcdmsg(true, 0, 0, "test_keys"); 28 - nwz_lcdmsg(false, 0, 2, "BACK: hold 3 seconds to quit"); 29 - /* open input device */ 30 - int input_fd = nwz_key_open(); 31 - if(input_fd < 0) 32 - { 33 - nwz_lcdmsg(false, 3, 4, "Cannot open input device"); 34 - sleep(2); 35 - return 1; 36 - } 37 - /* display input state in a loop */ 38 - int back_pressed = 0; /* 0 = no pressed, >0 = number of seconds pressed - 1 */ 39 - #define FIRST_LINE 7 40 - #define LAST_LINE 17 41 - int event_line = FIRST_LINE; 42 - int prev_evt_line = -1; 43 - while(1) 44 - { 45 - /* display HOLD status */ 46 - nwz_lcdmsgf(false, 2, 5, "HOLD: %d", nwz_key_get_hold_status(input_fd)); 47 - /* wait for event */ 48 - int ret = nwz_key_wait_event(input_fd, 1000000); 49 - if(ret != 1) 50 - { 51 - if(back_pressed > 0) 52 - back_pressed++; 53 - if(back_pressed >= 4) 54 - break; 55 - continue; 56 - } 57 - struct input_event evt; 58 - if(nwz_key_read_event(input_fd, &evt) != 1) 59 - continue; 60 - /* erase last '>' indicator */ 61 - if(prev_evt_line != -1) 62 - nwz_lcdmsg(false, 0, prev_evt_line, " "); 63 - prev_evt_line = event_line; 64 - char buffer[32]; 65 - int len = sprintf(buffer, "> %s %s (HOLD=%d)", 66 - nwz_key_get_name(nwz_key_event_get_keycode(&evt)), 67 - nwz_key_event_is_press(&evt) ? "pressed" : "released", 68 - nwz_key_event_get_hold_status(&evt)); 69 - /* pad with spaces to erase old stuff */ 70 - while(len + 1 < sizeof(buffer)) 71 - buffer[len++] = ' '; 72 - buffer[len] = 0; 73 - /* print line */ 74 - nwz_lcdmsg(false, 0, event_line, buffer); 75 - /* compute next line */ 76 - event_line++; 77 - if(event_line == LAST_LINE) 78 - event_line = FIRST_LINE; 79 - /* handle quit */ 80 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && nwz_key_event_is_press(&evt)) 81 - back_pressed = 1; 82 - else 83 - back_pressed = 0; 84 - } 85 - /* wait until back is released, to avoid messing with all_tools (if embedded) */ 86 - nwz_lcdmsg(true, 0, 0, "test_keys"); 87 - nwz_lcdmsg(false, 0, 2, "BACK: release to quit"); 88 - while(1) 89 - { 90 - /* wait for event */ 91 - int ret = nwz_key_wait_event(input_fd, 1000000); 92 - if(ret != 1) 93 - continue; 94 - struct input_event evt; 95 - if(nwz_key_read_event(input_fd, &evt) != 1) 96 - continue; 97 - /* handle quit */ 98 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt)) 99 - break; 100 - } 101 - /* close input device */ 102 - nwz_key_close(input_fd); 103 - /* finish nicely */ 104 - return 0; 105 - }
-152
utils/nwztools/plattools/test_power.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - static const char *charge_status_name(int chgstat) 25 - { 26 - switch(chgstat) 27 - { 28 - case NWZ_POWER_STATUS_CHARGE_STATUS_CHARGING: return "charging"; 29 - case NWZ_POWER_STATUS_CHARGE_STATUS_SUSPEND: return "suspend"; 30 - case NWZ_POWER_STATUS_CHARGE_STATUS_TIMEOUT: return "timeout"; 31 - case NWZ_POWER_STATUS_CHARGE_STATUS_NORMAL: return "normal"; 32 - default: return "unknown"; 33 - } 34 - } 35 - 36 - static const char *get_batt_gauge_name(int gauge) 37 - { 38 - switch(gauge) 39 - { 40 - case NWZ_POWER_BAT_NOBAT: return "no batt"; 41 - case NWZ_POWER_BAT_VERYLOW: return "very low"; 42 - case NWZ_POWER_BAT_LOW: return "low"; 43 - case NWZ_POWER_BAT_GAUGE0: return "____"; 44 - case NWZ_POWER_BAT_GAUGE1: return "O___"; 45 - case NWZ_POWER_BAT_GAUGE2: return "OO__"; 46 - case NWZ_POWER_BAT_GAUGE3: return "OOO_"; 47 - case NWZ_POWER_BAT_GAUGE4: return "OOOO"; 48 - default: return "unknown"; 49 - } 50 - } 51 - 52 - static const char *acc_charge_mode_name(int mode) 53 - { 54 - switch(mode) 55 - { 56 - case NWZ_POWER_ACC_CHARGE_NONE: return "none"; 57 - case NWZ_POWER_ACC_CHARGE_VBAT: return "vbat"; 58 - case NWZ_POWER_ACC_CHARGE_VSYS: return "vsys"; 59 - default: return "unknown"; 60 - } 61 - } 62 - 63 - int NWZ_TOOL_MAIN(test_power)(int argc, char **argv) 64 - { 65 - /* clear screen and display welcome message */ 66 - nwz_lcdmsg(true, 0, 0, "test_power"); 67 - nwz_lcdmsg(false, 0, 2, "BACK: quit"); 68 - /* open input device */ 69 - int input_fd = nwz_key_open(); 70 - if(input_fd < 0) 71 - { 72 - nwz_lcdmsg(false, 3, 4, "Cannot open input device"); 73 - sleep(2); 74 - return 1; 75 - } 76 - /* open adc device */ 77 - int power_fd = nwz_power_open(); 78 - if(power_fd < 0) 79 - { 80 - nwz_key_close(input_fd); 81 - nwz_lcdmsg(false, 3, 4, "Cannot open power device"); 82 - sleep(2); 83 - return 1; 84 - } 85 - /* open pminfo device */ 86 - int pminfo_fd = nwz_pminfo_open(); 87 - if(pminfo_fd < 0) 88 - { 89 - nwz_key_close(power_fd); 90 - nwz_key_close(input_fd); 91 - nwz_lcdmsg(false, 3, 4, "Cannot open pminfo device"); 92 - sleep(2); 93 - return 1; 94 - } 95 - /* display input state in a loop */ 96 - while(1) 97 - { 98 - /* print status */ 99 - int line = 4; 100 - int status = nwz_power_get_status(power_fd); 101 - int chgstat = status & NWZ_POWER_STATUS_CHARGE_STATUS; 102 - int acc_chg_mode = nwz_power_get_acc_charge_mode(power_fd); 103 - nwz_lcdmsgf(false, 0, line++, "ac detected: %s ", 104 - (status & NWZ_POWER_STATUS_AC_DET) ? "yes" : "no"); 105 - nwz_lcdmsgf(false, 0, line++, "vbus detected: %s ", 106 - (status & NWZ_POWER_STATUS_VBUS_DET) ? "yes" : "no"); 107 - nwz_lcdmsgf(false, 0, line++, "vbus voltage: %d mV (AD=%d) ", 108 - nwz_power_get_vbus_voltage(power_fd), nwz_power_get_vbus_adval(power_fd)); 109 - nwz_lcdmsgf(false, 0, line++, "vbus limit: %d mA ", 110 - nwz_power_get_vbus_limit(power_fd)); 111 - nwz_lcdmsgf(false, 0, line++, "vsys voltage: %d mV (AD=%d) ", 112 - nwz_power_get_vsys_voltage(power_fd), nwz_power_get_vsys_adval(power_fd)); 113 - nwz_lcdmsgf(false, 0, line++, "charge switch: %s ", 114 - nwz_power_get_charge_switch(power_fd) ? "on" : "off"); 115 - nwz_lcdmsgf(false, 0, line++, "full voltage: %s V ", 116 - (status & NWZ_POWER_STATUS_CHARGE_LOW) ? "4.1" : "4.2"); 117 - nwz_lcdmsgf(false, 0, line++, "current limit: %d mA ", 118 - nwz_power_get_charge_current(power_fd)); 119 - nwz_lcdmsgf(false, 0, line++, "charge status: %s (%x) ", 120 - charge_status_name(chgstat), chgstat); 121 - nwz_lcdmsgf(false, 0, line++, "battery full: %s ", 122 - nwz_power_is_fully_charged(power_fd) ? "yes" : "no"); 123 - nwz_lcdmsgf(false, 0, line++, "bat gauge: %s (%d) ", 124 - get_batt_gauge_name(nwz_power_get_battery_gauge(power_fd)), 125 - nwz_power_get_battery_gauge(power_fd)); 126 - nwz_lcdmsgf(false, 0, line++, "avg voltage: %d mV (AD=%d) ", 127 - nwz_power_get_battery_voltage(power_fd), nwz_power_get_battery_adval(power_fd)); 128 - nwz_lcdmsgf(false, 0, line++, "sample count: %d ", 129 - nwz_power_get_sample_count(power_fd)); 130 - nwz_lcdmsgf(false, 0, line++, "raw voltage: %d mV (AD=%d) ", 131 - nwz_power_get_vbat_voltage(power_fd), nwz_power_get_vbat_adval(power_fd)); 132 - nwz_lcdmsgf(false, 0, line++, "acc charge mode: %s (%d) ", 133 - acc_charge_mode_name(acc_chg_mode), acc_chg_mode); 134 - /* pminfo */ 135 - line++; 136 - nwz_lcdmsgf(false, 0, line++, "pminfo: %#x ", nwz_pminfo_get_factor(pminfo_fd)); 137 - /* wait for event (1s) */ 138 - int ret = nwz_key_wait_event(input_fd, 1000000); 139 - if(ret != 1) 140 - continue; 141 - struct input_event evt; 142 - if(nwz_key_read_event(input_fd, &evt) != 1) 143 - continue; 144 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && !nwz_key_event_is_press(&evt)) 145 - break; 146 - } 147 - /* finish nicely */ 148 - nwz_key_close(power_fd); 149 - nwz_key_close(input_fd); 150 - nwz_pminfo_close(pminfo_fd); 151 - return 0; 152 - }
-98
utils/nwztools/plattools/test_ts.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 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 - #include "nwz_lib.h" 22 - #include "nwz_plattools.h" 23 - 24 - int NWZ_TOOL_MAIN(test_ts)(int argc, char **argv) 25 - { 26 - /* clear screen and display welcome message */ 27 - nwz_lcdmsg(true, 0, 0, "test_ts"); 28 - nwz_lcdmsg(false, 0, 2, "BACK: quit"); 29 - /* open input device */ 30 - int key_fd = nwz_key_open(); 31 - if(key_fd < 0) 32 - { 33 - nwz_lcdmsg(false, 3, 4, "Cannot open key device"); 34 - sleep(2); 35 - return 1; 36 - } 37 - int ts_fd = nwz_ts_open(); 38 - if(ts_fd < 0) 39 - { 40 - nwz_key_close(key_fd); 41 - nwz_lcdmsg(false, 3, 4, "Cannot open touch screen device"); 42 - sleep(2); 43 - return 1; 44 - } 45 - /* init state and print maximum information */ 46 - struct nwz_ts_state_t ts_state; 47 - if(nwz_ts_state_init(ts_fd, &ts_state) < 0) 48 - { 49 - nwz_key_close(key_fd); 50 - nwz_ts_close(ts_fd); 51 - nwz_lcdmsg(false, 3, 4, "Cannot init touch screen device"); 52 - sleep(2); 53 - return 1; 54 - } 55 - /* display static information */ 56 - nwz_lcdmsgf(false, 1, 6, "size: %d, %d ", ts_state.max_x, ts_state.max_y); 57 - /* display input state in a loop */ 58 - while(1) 59 - { 60 - /* wait for event */ 61 - int fds[2] = {key_fd, ts_fd}; 62 - int ret = nwz_wait_fds(fds, 2, -1); 63 - if(ret & 1) /* key_fd */ 64 - { 65 - struct input_event evt; 66 - if(nwz_key_read_event(key_fd, &evt) == 1) 67 - { 68 - if(nwz_key_event_get_keycode(&evt) == NWZ_KEY_BACK && 69 - nwz_key_event_is_press(&evt)) 70 - break; /* quit */ 71 - } 72 - } 73 - if(ret & 2) /* ts_fd */ 74 - { 75 - #define NR_TS_EVTS 16 76 - struct input_event evts[NR_TS_EVTS]; 77 - int nr = nwz_ts_read_events(ts_fd, evts, NR_TS_EVTS); 78 - for(int i = 0; i < nr; i++) 79 - if(nwz_ts_state_update(&ts_state, &evts[i]) == 1) 80 - { 81 - nwz_lcdmsgf(false, 1, 7, "touch: %s ", ts_state.touch ? "yes" : "no"); 82 - nwz_lcdmsgf(false, 1, 8, "pos: %d, %d ", ts_state.x, ts_state.y); 83 - nwz_lcdmsgf(false, 1, 9, "pressure: %d ", ts_state.pressure); 84 - nwz_lcdmsgf(false, 1, 10, "width: %d ", ts_state.tool_width); 85 - nwz_lcdmsgf(false, 1, 11, "flick: %s ", ts_state.flick ? "yes" : "no"); 86 - nwz_lcdmsgf(false, 1, 12, "flick vec: %d, %d ", ts_state.flick_x, ts_state.flick_y); 87 - /* process touch */ 88 - nwz_ts_state_post_syn(&ts_state); 89 - } 90 - #undef NR_TS_EVTS 91 - } 92 - } 93 - /* close input device */ 94 - nwz_key_close(key_fd); 95 - nwz_ts_close(ts_fd); 96 - /* finish nicely */ 97 - return 0; 98 - }
+4 -2
utils/nwztools/scripts/install_dualboot.sh
··· 36 36 . /install_script/constant.txt 37 37 _UPDATE_FN_=`nvpstr ufn` 38 38 ROOTFS_TMP_DIR=/tmp/rootfs 39 - ROCKBOX_NAME=Rockbox 40 - ROCKBOX_PATH=$ROOTFS_TMP_DIR/usr/local/bin/$ROCKBOX_NAME 41 39 SPIDERAPP_PATH=$ROOTFS_TMP_DIR/usr/local/bin/SpiderApp 42 40 43 41 # mount root partition ··· 51 49 52 50 # NOTE some platforms use ext4 with a custom mount program 53 51 # (/usr/local/bin/icx_mount.ext4), some probably use an mtd too 52 + # try ext3 and if it fails, try ext2 54 53 mount -t ext3 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR 54 + if [ "$?" != 0 ]; then 55 + mount -t ext2 $COMMON_ROOTFS_PARTITION $ROOTFS_TMP_DIR 56 + fi 55 57 if [ "$?" != 0 ]; then 56 58 lcdmsg -f /usr/local/bin/font_08x12.bmp -l 0,15 "ERROR: mount failed" 57 59 sleep 3
+2 -2
utils/nwztools/scsitools/Makefile
··· 3 3 PREFIX?= 4 4 CC=$(PREFIX)gcc 5 5 LD=$(PREFIX)gcc 6 - NWZ_DB_DIR=../database 6 + NWZ_DB_DIR=../../../firmware/target/hosted/sonynwz 7 7 INCLUDES=-I$(NWZ_DB_DIR) -I$(SCSI_DIR) 8 8 CFLAGS=-std=c99 -Wall $(DEFINES) $(INCLUDES) 9 9 LDFLAGS=-L$(SCSI_DIR) -lrbscsi ··· 11 11 12 12 all: $(BINS) 13 13 14 - scsitool: scsitool.c misc.c para_noise.c $(NWZ_DB_DIR)/nwz_db.c 14 + scsitool: scsitool.c misc.c para_noise.c $(NWZ_DB_DIR)/nwz-db.c 15 15 $(MAKE) -C $(SCSI_DIR) 16 16 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 17 17
+1 -1
utils/nwztools/scsitools/scsitool.c
··· 34 34 #include "rbscsi.h" 35 35 #include "misc.h" 36 36 #include "para_noise.h" 37 - #include "nwz_db.h" 37 + #include "nwz-db.h" 38 38 39 39 bool g_debug = false; 40 40 const char *g_force_series = NULL;