summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/backlight-fiiom3k.c1
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c4
-rwxr-xr-xutils/fiio_m3k_tools/nand_patcher.py69
3 files changed, 3 insertions, 71 deletions
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/backlight-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/backlight-fiiom3k.c
index f02fcaaee8..a158f615e0 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/backlight-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/backlight-fiiom3k.c
@@ -43,7 +43,6 @@ bool backlight_hw_init(void)
43 pwm_enable(BL_BTN_CHN); 43 pwm_enable(BL_BTN_CHN);
44 backlight_hw_brightness(MAX_BRIGHTNESS_SETTING); 44 backlight_hw_brightness(MAX_BRIGHTNESS_SETTING);
45 buttonlight_hw_brightness(MAX_BRIGHTNESS_SETTING); 45 buttonlight_hw_brightness(MAX_BRIGHTNESS_SETTING);
46 /* TODO: avoid buttonlight flicker when powering up the machine */
47 return true; 46 return true;
48} 47}
49 48
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
index b5193152a2..85ccc5cf65 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
@@ -22,6 +22,7 @@
22#include "button.h" 22#include "button.h"
23#include "kernel.h" 23#include "kernel.h"
24#include "backlight.h" 24#include "backlight.h"
25#include "powermgmt.h"
25#include "panic.h" 26#include "panic.h"
26#include "axp173.h" 27#include "axp173.h"
27#include "gpio-x1000.h" 28#include "gpio-x1000.h"
@@ -313,6 +314,7 @@ static void ft_step_state(uint32_t t, int evt, int tx, int ty)
313 /* Poke the backlight */ 314 /* Poke the backlight */
314 backlight_on(); 315 backlight_on();
315 buttonlight_on(); 316 buttonlight_on();
317 reset_poweroff_timer();
316 318
317 fsm.orig_x = fsm.cur_x; 319 fsm.orig_x = fsm.cur_x;
318 fsm.orig_y = fsm.cur_y; 320 fsm.orig_y = fsm.cur_y;
@@ -481,7 +483,7 @@ int button_read_device(void)
481 return r; 483 return r;
482} 484}
483 485
484bool headphones_inserted() 486bool headphones_inserted(void)
485{ 487{
486 return hp_detect_reg & 0x40 ? true : false; 488 return hp_detect_reg & 0x40 ? true : false;
487} 489}
diff --git a/utils/fiio_m3k_tools/nand_patcher.py b/utils/fiio_m3k_tools/nand_patcher.py
deleted file mode 100755
index 261a4de678..0000000000
--- a/utils/fiio_m3k_tools/nand_patcher.py
+++ /dev/null
@@ -1,69 +0,0 @@
1#!/usr/bin/python3
2
3import sys
4
5IMAGE_SIZE = 128 * 1024 # image is an 128 KiB erase block
6SPL_SIZE = 12 * 1024 # SPL is at most 12 KiB
7BOOT_SIZE = 102 * 1024 # bootloader at most 102 KiB
8BOOT_OFF = 26 * 1024 # offset of bootloader in image
9BOOT_END = BOOT_OFF+BOOT_SIZE
10
11def patch(in_path, boot_path, spl_path, out_path):
12 # Open the input files
13 in_file = open(in_path, 'rb')
14 boot_file = open(boot_path, 'rb')
15 spl_file = open(spl_path, 'rb')
16
17 # Read the data
18 in_data = in_file.read()
19 boot_data = boot_file.read()
20 spl_data = spl_file.read()
21
22 # Close input files
23 in_file.close()
24 boot_file.close()
25 spl_file.close()
26
27 if len(in_data) != IMAGE_SIZE:
28 print("error: input image is %d bytes, expected %d" % (len(in_data), IMAGE_SIZE))
29 sys.exit(1)
30
31 if len(spl_data) > SPL_SIZE:
32 print("error: SPL is %d bytes, maximum is %d" % (len(spl_data), SPL_SIZE))
33 sys.exit(1)
34
35 if len(boot_data) > BOOT_SIZE:
36 print("error: bootloader is %d bytes, maximum is %d" % (len(boot_data), SPL_SIZE))
37 sys.exit(1)
38
39 print('Patching input image %s' % in_path)
40 print('- SPL size %d' % len(spl_data))
41 print('- Boot size %d' % len(boot_data))
42
43 # Construct output image
44 out_data = b''
45 out_data += spl_data
46 out_data += b'\xff' * (SPL_SIZE - len(spl_data))
47 out_data += in_data[SPL_SIZE:BOOT_OFF]
48 out_data += boot_data
49 out_data += b'\xff' * (BOOT_SIZE - len(boot_data))
50
51 # Sanity check
52 assert( len(out_data) == IMAGE_SIZE )
53
54 # Write output
55 print('Writing output image %s' % out_path)
56 out_file = open(out_path, 'wb')
57 out_file.write(out_data)
58 out_file.close()
59
60
61def main():
62 if len(sys.argv) != 5:
63 print("usage: nand_patcher.py IN_FILE BOOT_FILE SPL_FILE OUT_FILE")
64 sys.exit(1)
65
66 patch(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
67
68if __name__ == '__main__':
69 main()