diff options
Diffstat (limited to 'firmware/target')
20 files changed, 1081 insertions, 2 deletions
diff --git a/firmware/target/hosted/agptek/adc-target.h b/firmware/target/hosted/agptek/adc-target.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/firmware/target/hosted/agptek/adc-target.h | |||
diff --git a/firmware/target/hosted/agptek/backlight-agptek.c b/firmware/target/hosted/agptek/backlight-agptek.c new file mode 100644 index 0000000000..2f00787f72 --- /dev/null +++ b/firmware/target/hosted/agptek/backlight-agptek.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___ | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 <sys/types.h> | ||
21 | #include <sys/stat.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <stdbool.h> | ||
24 | #include <unistd.h> | ||
25 | #include <string.h> | ||
26 | #include <stdio.h> | ||
27 | #include "config.h" | ||
28 | #include "backlight-target.h" | ||
29 | #include "sysfs.h" | ||
30 | #include "panic.h" | ||
31 | |||
32 | static const char * const sysfs_bl_brightness = | ||
33 | "/sys/class/backlight/pwm-backlight.0/brightness"; | ||
34 | |||
35 | static const char * const sysfs_bl_power = | ||
36 | "/sys/class/backlight/pwm-backlight.0/bl_power"; | ||
37 | |||
38 | bool backlight_hw_init(void) | ||
39 | { | ||
40 | backlight_hw_on(); | ||
41 | backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); | ||
42 | return true; | ||
43 | } | ||
44 | |||
45 | void backlight_hw_on(void) | ||
46 | { | ||
47 | sysfs_set_int(sysfs_bl_power, 0); | ||
48 | } | ||
49 | |||
50 | void backlight_hw_off(void) | ||
51 | { | ||
52 | sysfs_set_int(sysfs_bl_power, 1); | ||
53 | } | ||
54 | |||
55 | void backlight_hw_brightness(int brightness) | ||
56 | { | ||
57 | /* cap range, just in case */ | ||
58 | if (brightness > MAX_BRIGHTNESS_SETTING) | ||
59 | brightness = MAX_BRIGHTNESS_SETTING; | ||
60 | if (brightness < MIN_BRIGHTNESS_SETTING) | ||
61 | brightness = MIN_BRIGHTNESS_SETTING; | ||
62 | |||
63 | sysfs_set_int(sysfs_bl_brightness, brightness); | ||
64 | } | ||
diff --git a/firmware/target/hosted/agptek/backlight-target.h b/firmware/target/hosted/agptek/backlight-target.h new file mode 100644 index 0000000000..e3b8a7bd78 --- /dev/null +++ b/firmware/target/hosted/agptek/backlight-target.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___ | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 _BACKLIGHT_TARGET_H_ | ||
22 | #define _BACKLIGHT_TARGET_H_ | ||
23 | |||
24 | |||
25 | #include <stdbool.h> | ||
26 | |||
27 | |||
28 | /* See backlight.c */ | ||
29 | bool backlight_hw_init(void); | ||
30 | void backlight_hw_on(void); | ||
31 | void backlight_hw_off(void); | ||
32 | void backlight_hw_brightness(int brightness); | ||
33 | |||
34 | |||
35 | #endif | ||
36 | |||
diff --git a/firmware/target/hosted/agptek/button-agptek.c b/firmware/target/hosted/agptek/button-agptek.c new file mode 100644 index 0000000000..a8b5debee5 --- /dev/null +++ b/firmware/target/hosted/agptek/button-agptek.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___ | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 <poll.h> | ||
21 | //#include <dir.h> | ||
22 | #include <errno.h> | ||
23 | #include <unistd.h> | ||
24 | #include <sys/types.h> | ||
25 | #include <linux/input.h> | ||
26 | #include <fcntl.h> | ||
27 | #include <string.h> | ||
28 | #include <stdlib.h> | ||
29 | |||
30 | #include "sysfs.h" | ||
31 | #include "button.h" | ||
32 | #include "button-target.h" | ||
33 | #include "panic.h" | ||
34 | |||
35 | #define NR_POLL_DESC 2 | ||
36 | static struct pollfd poll_fds[NR_POLL_DESC]; | ||
37 | |||
38 | static int button_map(int keycode) | ||
39 | { | ||
40 | switch(keycode) | ||
41 | { | ||
42 | case KEY_LEFT: | ||
43 | return BUTTON_LEFT; | ||
44 | |||
45 | case KEY_RIGHT: | ||
46 | return BUTTON_RIGHT; | ||
47 | |||
48 | case KEY_UP: | ||
49 | return BUTTON_UP; | ||
50 | |||
51 | case KEY_DOWN: | ||
52 | return BUTTON_DOWN; | ||
53 | |||
54 | case KEY_PLAYPAUSE: | ||
55 | return BUTTON_SELECT; | ||
56 | |||
57 | case KEY_VOLUMEUP: | ||
58 | return BUTTON_VOLUP; | ||
59 | |||
60 | case KEY_VOLUMEDOWN: | ||
61 | return BUTTON_VOLDOWN; | ||
62 | |||
63 | case KEY_POWER: | ||
64 | return BUTTON_POWER; | ||
65 | |||
66 | default: | ||
67 | return 0; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void button_init_device(void) | ||
72 | { | ||
73 | const char * const input_devs[] = { | ||
74 | "/dev/input/event0", | ||
75 | "/dev/input/event1" | ||
76 | }; | ||
77 | |||
78 | for(int i = 0; i < NR_POLL_DESC; i++) | ||
79 | { | ||
80 | int fd = open(input_devs[i], O_RDWR); | ||
81 | |||
82 | if(fd < 0) | ||
83 | { | ||
84 | panicf("Cannot open input device: %s\n", input_devs[i]); | ||
85 | } | ||
86 | |||
87 | poll_fds[i].fd = fd; | ||
88 | poll_fds[i].events = POLLIN; | ||
89 | poll_fds[i].revents = 0; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | int button_read_device(void) | ||
94 | { | ||
95 | static int button_bitmap = 0; | ||
96 | struct input_event event; | ||
97 | |||
98 | /* check if there are any events pending and process them */ | ||
99 | while(poll(poll_fds, NR_POLL_DESC, 0)) | ||
100 | { | ||
101 | for(int i = 0; i < NR_POLL_DESC; i++) | ||
102 | { | ||
103 | /* read only if non-blocking */ | ||
104 | if(poll_fds[i].revents & POLLIN) | ||
105 | { | ||
106 | int size = read(poll_fds[i].fd, &event, sizeof(event)); | ||
107 | if(size == (int)sizeof(event)) | ||
108 | { | ||
109 | int keycode = event.code; | ||
110 | /* event.value == 0x10000 means press | ||
111 | * event.value == 0 means release | ||
112 | */ | ||
113 | bool press = event.value ? true : false; | ||
114 | |||
115 | /* map linux event code to rockbox button bitmap */ | ||
116 | if(press) | ||
117 | { | ||
118 | button_bitmap |= button_map(keycode); | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | button_bitmap &= ~button_map(keycode); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | return button_bitmap; | ||
130 | } | ||
131 | |||
132 | bool headphones_inserted(void) | ||
133 | { | ||
134 | int status = 0; | ||
135 | const char * const sysfs_hp_switch = "/sys/devices/switch/headset/status"; | ||
136 | sysfs_get_int(sysfs_hp_switch, &status); | ||
137 | |||
138 | return status ? true : false; | ||
139 | } | ||
140 | |||
141 | void button_close_device(void) | ||
142 | { | ||
143 | /* close descriptors */ | ||
144 | for(int i = 0; i < NR_POLL_DESC; i++) | ||
145 | { | ||
146 | close(poll_fds[i].fd); | ||
147 | } | ||
148 | } | ||
149 | |||
diff --git a/firmware/target/hosted/agptek/button-target.h b/firmware/target/hosted/agptek/button-target.h new file mode 100644 index 0000000000..b08c055895 --- /dev/null +++ b/firmware/target/hosted/agptek/button-target.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 by Marcin Bukat | ||
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 _BUTTON_TARGET_H_ | ||
21 | #define _BUTTON_TARGET_H_ | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | /* Main unit's buttons */ | ||
27 | #define BUTTON_LEFT 0x00000001 | ||
28 | #define BUTTON_RIGHT 0x00000002 | ||
29 | #define BUTTON_UP 0x00000004 | ||
30 | #define BUTTON_DOWN 0x00000008 | ||
31 | #define BUTTON_SELECT 0x00000010 | ||
32 | #define BUTTON_VOLDOWN 0x00000020 | ||
33 | #define BUTTON_VOLUP 0x00000040 | ||
34 | #define BUTTON_POWER 0x00000080 | ||
35 | |||
36 | #define BUTTON_MAIN 0x000000ff | ||
37 | |||
38 | /* Software power-off */ | ||
39 | #define POWEROFF_BUTTON BUTTON_POWER | ||
40 | #define POWEROFF_COUNT 10 | ||
41 | |||
42 | #endif /* _BUTTON_TARGET_H_ */ | ||
43 | |||
diff --git a/firmware/target/hosted/agptek/debug-agptek.c b/firmware/target/hosted/agptek/debug-agptek.c new file mode 100644 index 0000000000..33f3ac4b97 --- /dev/null +++ b/firmware/target/hosted/agptek/debug-agptek.c | |||
@@ -0,0 +1,6 @@ | |||
1 | #include <stdbool.h> | ||
2 | |||
3 | bool debug_hw_info(void) | ||
4 | { | ||
5 | return false; | ||
6 | } | ||
diff --git a/firmware/target/hosted/agptek/lcd-agptek.c b/firmware/target/hosted/agptek/lcd-agptek.c new file mode 100644 index 0000000000..abf89ea9e3 --- /dev/null +++ b/firmware/target/hosted/agptek/lcd-agptek.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 <stdlib.h> | ||
23 | #include <unistd.h> | ||
24 | #include <stdio.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 | #include "panic.h" | ||
33 | |||
34 | static int fd = -1; | ||
35 | static struct fb_var_screeninfo vinfo; | ||
36 | fb_data *framebuffer = 0; /* global variable, see lcd-target.h */ | ||
37 | |||
38 | void lcd_init_device(void) | ||
39 | { | ||
40 | const char * const fb_dev = "/dev/fb0"; | ||
41 | fd = open(fb_dev, O_RDWR); | ||
42 | if(fd < 0) | ||
43 | { | ||
44 | panicf("Cannot open framebuffer: %s\n", fb_dev); | ||
45 | } | ||
46 | |||
47 | /* get fixed and variable information */ | ||
48 | struct fb_fix_screeninfo finfo; | ||
49 | if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) | ||
50 | { | ||
51 | panicf("Cannot read framebuffer fixed information"); | ||
52 | } | ||
53 | |||
54 | if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) | ||
55 | { | ||
56 | panicf("Cannot read framebuffer variable information"); | ||
57 | } | ||
58 | |||
59 | #if 0 | ||
60 | /* check resolution and framebuffer size */ | ||
61 | if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH) | ||
62 | { | ||
63 | panicf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres, | ||
64 | vinfo.yres, vinfo.bits_per_pixel); | ||
65 | } | ||
66 | #endif | ||
67 | /* Note: we use a framebuffer size of width*height*bbp. We cannot trust the | ||
68 | * values returned by the driver for line_length */ | ||
69 | |||
70 | /* map framebuffer */ | ||
71 | framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | ||
72 | if((void *)framebuffer == MAP_FAILED) | ||
73 | { | ||
74 | panicf("Cannot map framebuffer"); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | static void redraw(void) | ||
79 | { | ||
80 | ioctl(fd, FBIOPAN_DISPLAY, &vinfo); | ||
81 | } | ||
82 | |||
83 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | ||
84 | int width, int height); | ||
85 | |||
86 | void lcd_update(void) | ||
87 | { | ||
88 | /* Copy the Rockbox framebuffer to the second framebuffer */ | ||
89 | lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0), | ||
90 | LCD_WIDTH*LCD_HEIGHT, 1); | ||
91 | redraw(); | ||
92 | } | ||
93 | |||
94 | void lcd_update_rect(int x, int y, int width, int height) | ||
95 | { | ||
96 | fb_data *dst = LCD_FRAMEBUF_ADDR(x, y); | ||
97 | fb_data * src = FBADDR(x,y); | ||
98 | |||
99 | /* Copy part of the Rockbox framebuffer to the second framebuffer */ | ||
100 | if (width < LCD_WIDTH) | ||
101 | { | ||
102 | /* Not full width - do line-by-line */ | ||
103 | lcd_copy_buffer_rect(dst, src, width, height); | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | /* Full width - copy as one line */ | ||
108 | lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1); | ||
109 | } | ||
110 | redraw(); | ||
111 | } | ||
diff --git a/firmware/target/hosted/agptek/lcd-target.h b/firmware/target/hosted/agptek/lcd-target.h new file mode 100644 index 0000000000..346644bdfc --- /dev/null +++ b/firmware/target/hosted/agptek/lcd-target.h | |||
@@ -0,0 +1,26 @@ | |||
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 | #ifndef __LCD_TARGET_H__ | ||
22 | #define __LCD_TARGET_H__ | ||
23 | |||
24 | extern fb_data *framebuffer; /* see lcd-nwz.c */ | ||
25 | #define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col)) | ||
26 | #endif /* __LCD_TARGET_H__ */ | ||
diff --git a/firmware/target/hosted/agptek/power-agptek.c b/firmware/target/hosted/agptek/power-agptek.c new file mode 100644 index 0000000000..7403801681 --- /dev/null +++ b/firmware/target/hosted/agptek/power-agptek.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 by Marcin Bukat | ||
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 <sys/types.h> | ||
21 | #include <fcntl.h> | ||
22 | #include <string.h> | ||
23 | #include <unistd.h> | ||
24 | #include <stdio.h> | ||
25 | |||
26 | #include "system.h" | ||
27 | #include "power-agptek.h" | ||
28 | #include "power.h" | ||
29 | #include "panic.h" | ||
30 | #include "sysfs.h" | ||
31 | |||
32 | const char * const sysfs_bat_voltage = | ||
33 | "/sys/class/power_supply/battery/voltage_now"; | ||
34 | |||
35 | const char * const sysfs_bat_status = | ||
36 | "/sys/class/power_supply/battery/status"; | ||
37 | |||
38 | unsigned int agptek_power_get_status(void) | ||
39 | { | ||
40 | char buf[12] = {0}; | ||
41 | sysfs_get_string(sysfs_bat_status, buf, sizeof(buf)); | ||
42 | |||
43 | if (strncmp(buf, "Charging", 8) == 0) | ||
44 | { | ||
45 | return POWER_INPUT_USB_CHARGER; | ||
46 | } | ||
47 | else | ||
48 | { | ||
49 | return POWER_INPUT_NONE; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | unsigned int agptek_power_get_battery_voltage(void) | ||
54 | { | ||
55 | int battery_voltage; | ||
56 | sysfs_get_int(sysfs_bat_voltage, &battery_voltage); | ||
57 | |||
58 | return battery_voltage/1000; | ||
59 | } | ||
diff --git a/firmware/target/hosted/agptek/power-agptek.h b/firmware/target/hosted/agptek/power-agptek.h new file mode 100644 index 0000000000..16f32b76ad --- /dev/null +++ b/firmware/target/hosted/agptek/power-agptek.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 by Marcin Bukat | ||
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 _POWER_AGPTEK_H_ | ||
21 | #define _POWER_AGPTEK_H_ | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | unsigned int agptek_power_get_status(void); | ||
27 | unsigned int agptek_power_get_battery_voltage(void); | ||
28 | #endif /* _POWER_AGPTEK_H_ */ | ||
29 | |||
diff --git a/firmware/target/hosted/agptek/powermgmt-agptek.c b/firmware/target/hosted/agptek/powermgmt-agptek.c new file mode 100644 index 0000000000..3371d1e793 --- /dev/null +++ b/firmware/target/hosted/agptek/powermgmt-agptek.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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-agptek.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 | 3400 | ||
33 | }; | ||
34 | |||
35 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled | ||
36 | * NOTE: not calibrated simple linear scale for now | ||
37 | */ | ||
38 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
39 | { | ||
40 | { 3400, 3480, 3560, 3640, 3720, 3800, 3880, 3960, 4040, 4120, 4200 } | ||
41 | }; | ||
42 | |||
43 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
44 | const unsigned short const percent_to_volt_charge[11] = | ||
45 | { | ||
46 | 3450, 3670, 3721, 3751, 3782, 3821, 3876, 3941, 4034, 4125, 4200 | ||
47 | }; | ||
48 | |||
49 | unsigned int power_input_status(void) | ||
50 | { | ||
51 | /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */ | ||
52 | return agptek_power_get_status(); | ||
53 | } | ||
54 | |||
55 | int _battery_voltage(void) | ||
56 | { | ||
57 | return agptek_power_get_battery_voltage(); | ||
58 | } | ||
59 | |||
60 | bool charging_state(void) | ||
61 | { | ||
62 | return agptek_power_get_status() == POWER_INPUT_USB_CHARGER; | ||
63 | } | ||
diff --git a/firmware/target/hosted/agptek/rocker.make b/firmware/target/hosted/agptek/rocker.make new file mode 100644 index 0000000000..1e8faaac0d --- /dev/null +++ b/firmware/target/hosted/agptek/rocker.make | |||
@@ -0,0 +1,48 @@ | |||
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 | ifneq (,$(findstring bootloader,$(APPSDIR))) | ||
25 | # bootloader build | ||
26 | |||
27 | $(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS) | ||
28 | $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ | ||
29 | -L$(BUILDDIR)/firmware -lfirmware \ | ||
30 | -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ | ||
31 | $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map | ||
32 | |||
33 | $(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf | ||
34 | |||
35 | else | ||
36 | # rockbox app build | ||
37 | |||
38 | $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) | ||
39 | $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ | ||
40 | -L$(BUILDDIR)/firmware -lfirmware \ | ||
41 | -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ | ||
42 | -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ | ||
43 | $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map | ||
44 | |||
45 | $(BUILDDIR)/rockbox.rocker : $(BUILDDIR)/rockbox.elf | ||
46 | $(call PRINTS,OC $(@F))$(call objcopy,$^,$@) | ||
47 | |||
48 | endif | ||
diff --git a/firmware/target/hosted/agptek/sysfs.c b/firmware/target/hosted/agptek/sysfs.c new file mode 100644 index 0000000000..ad4635ac57 --- /dev/null +++ b/firmware/target/hosted/agptek/sysfs.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___ | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50 | ||
10 | * Copyright (C) 2014 by Mario Basister: iBasso DX90 port | ||
11 | * Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features | ||
12 | * Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | |||
25 | #include <stdio.h> | ||
26 | #include <string.h> | ||
27 | |||
28 | #include "config.h" | ||
29 | #include "debug.h" | ||
30 | #include "sysfs.h" | ||
31 | |||
32 | |||
33 | static FILE* open_read(const char *file_name) | ||
34 | { | ||
35 | FILE *f = fopen(file_name, "r"); | ||
36 | if(f == NULL) | ||
37 | { | ||
38 | DEBUGF("ERROR %s: Can not open %s for reading.", __func__, file_name); | ||
39 | } | ||
40 | |||
41 | return f; | ||
42 | } | ||
43 | |||
44 | |||
45 | static FILE* open_write(const char* file_name) | ||
46 | { | ||
47 | FILE *f = fopen(file_name, "w"); | ||
48 | if(f == NULL) | ||
49 | { | ||
50 | DEBUGF("ERROR %s: Can not open %s for writing.", __func__, file_name); | ||
51 | } | ||
52 | |||
53 | return f; | ||
54 | } | ||
55 | |||
56 | |||
57 | bool sysfs_get_int(const char *path, int *value) | ||
58 | { | ||
59 | *value = -1; | ||
60 | |||
61 | FILE *f = open_read(path); | ||
62 | if(f == NULL) | ||
63 | { | ||
64 | return false; | ||
65 | } | ||
66 | |||
67 | bool success = true; | ||
68 | if(fscanf(f, "%d", value) == EOF) | ||
69 | { | ||
70 | DEBUGF("ERROR %s: Read failed for %s.", __func__, path); | ||
71 | success = false; | ||
72 | } | ||
73 | |||
74 | fclose(f); | ||
75 | return success; | ||
76 | } | ||
77 | |||
78 | |||
79 | bool sysfs_set_int(const char *path, int value) | ||
80 | { | ||
81 | FILE *f = open_write(path); | ||
82 | if(f == NULL) | ||
83 | { | ||
84 | return false; | ||
85 | } | ||
86 | |||
87 | bool success = true; | ||
88 | if(fprintf(f, "%d", value) < 1) | ||
89 | { | ||
90 | DEBUGF("ERROR %s: Write failed for %s.", __func__, path); | ||
91 | success = false; | ||
92 | } | ||
93 | |||
94 | fclose(f); | ||
95 | return success; | ||
96 | } | ||
97 | |||
98 | |||
99 | bool sysfs_get_char(const char *path, char *value) | ||
100 | { | ||
101 | *value = '\0'; | ||
102 | FILE *f = open_read(path); | ||
103 | if(f == NULL) | ||
104 | { | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | bool success = true; | ||
109 | if(fscanf(f, "%c", value) == EOF) | ||
110 | { | ||
111 | DEBUGF("ERROR %s: Read failed for %s.", __func__, path); | ||
112 | success = false; | ||
113 | } | ||
114 | |||
115 | fclose(f); | ||
116 | return success; | ||
117 | } | ||
118 | |||
119 | |||
120 | bool sysfs_set_char(const char *path, char value) | ||
121 | { | ||
122 | FILE *f = open_write(path); | ||
123 | if(f == NULL) | ||
124 | { | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | bool success = true; | ||
129 | if(fprintf(f, "%c", value) < 1) | ||
130 | { | ||
131 | DEBUGF("ERROR %s: Write failed for %s.", __func__, path); | ||
132 | success = false; | ||
133 | } | ||
134 | |||
135 | fclose(f); | ||
136 | return success; | ||
137 | } | ||
138 | |||
139 | |||
140 | bool sysfs_get_string(const char *path, char *value, int size) | ||
141 | { | ||
142 | value[0] = '\0'; | ||
143 | FILE *f = open_read(path); | ||
144 | if(f == NULL) | ||
145 | { | ||
146 | return false; | ||
147 | } | ||
148 | |||
149 | bool success = true; | ||
150 | if(fgets(value, size, f) == NULL) | ||
151 | { | ||
152 | DEBUGF("ERROR %s: Read failed for %s.", __func__, path); | ||
153 | success = false; | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | size_t length = strlen(value); | ||
158 | if((length > 0) && value[length - 1] == '\n') | ||
159 | { | ||
160 | value[length - 1] = '\0'; | ||
161 | } | ||
162 | } | ||
163 | |||
164 | fclose(f); | ||
165 | return success; | ||
166 | } | ||
167 | |||
168 | |||
169 | bool sysfs_set_string(const char *path, char *value) | ||
170 | { | ||
171 | FILE *f = open_write(path); | ||
172 | if(f == NULL) | ||
173 | { | ||
174 | return false; | ||
175 | } | ||
176 | |||
177 | bool success = true; | ||
178 | if(fprintf(f, "%s", value) < 1) | ||
179 | { | ||
180 | DEBUGF("ERROR %s: Write failed for %s.", __func__, path); | ||
181 | success = false; | ||
182 | } | ||
183 | |||
184 | fclose(f); | ||
185 | return success; | ||
186 | } | ||
diff --git a/firmware/target/hosted/agptek/sysfs.h b/firmware/target/hosted/agptek/sysfs.h new file mode 100644 index 0000000000..639cc1c409 --- /dev/null +++ b/firmware/target/hosted/agptek/sysfs.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___ | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50 | ||
10 | * Copyright (C) 2014 by Mario Basister: iBasso DX90 port | ||
11 | * Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features | ||
12 | * Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | |||
26 | bool sysfs_get_int(const char *path, int *value); | ||
27 | bool sysfs_set_int(const char *path, int value); | ||
28 | bool sysfs_get_char(const char *path, char *value); | ||
29 | bool sysfs_set_char(const char *path, char value); | ||
30 | bool sysfs_get_string(const char *path, char *value, int size); | ||
31 | bool sysfs_set_string(const char *path, char *value); | ||
diff --git a/firmware/target/hosted/agptek/system-agptek.c b/firmware/target/hosted/agptek/system-agptek.c new file mode 100644 index 0000000000..7f0949daf2 --- /dev/null +++ b/firmware/target/hosted/agptek/system-agptek.c | |||
@@ -0,0 +1,184 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 <unistd.h> | ||
22 | #include <signal.h> | ||
23 | #include <string.h> | ||
24 | #include <ucontext.h> | ||
25 | #include <backtrace.h> | ||
26 | |||
27 | #include "system.h" | ||
28 | #include "mv.h" | ||
29 | #include "font.h" | ||
30 | #include "power.h" | ||
31 | #include "button.h" | ||
32 | #include "backlight-target.h" | ||
33 | #include "lcd.h" | ||
34 | |||
35 | /* to make thread-internal.h happy */ | ||
36 | uintptr_t *stackbegin; | ||
37 | uintptr_t *stackend; | ||
38 | |||
39 | static void sig_handler(int sig, siginfo_t *siginfo, void *context) | ||
40 | { | ||
41 | /* safe guard variable - we call backtrace() only on first | ||
42 | * UIE call. This prevent endless loop if backtrace() touches | ||
43 | * memory regions which cause abort | ||
44 | */ | ||
45 | static bool triggered = false; | ||
46 | |||
47 | lcd_set_backdrop(NULL); | ||
48 | lcd_set_drawmode(DRMODE_SOLID); | ||
49 | lcd_set_foreground(LCD_BLACK); | ||
50 | lcd_set_background(LCD_WHITE); | ||
51 | unsigned line = 0; | ||
52 | |||
53 | lcd_setfont(FONT_SYSFIXED); | ||
54 | lcd_set_viewport(NULL); | ||
55 | lcd_clear_display(); | ||
56 | |||
57 | /* get context info */ | ||
58 | ucontext_t *uc = (ucontext_t *)context; | ||
59 | unsigned long pc = uc->uc_mcontext.pc; | ||
60 | unsigned long sp = uc->uc_mcontext.gregs[29]; | ||
61 | |||
62 | lcd_putsf(0, line++, "%s at %08x", strsignal(sig), pc); | ||
63 | |||
64 | if(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) | ||
65 | lcd_putsf(0, line++, "address 0x%08x", siginfo->si_addr); | ||
66 | |||
67 | if(!triggered) | ||
68 | { | ||
69 | triggered = true; | ||
70 | rb_backtrace(pc, sp, &line); | ||
71 | } | ||
72 | |||
73 | #ifdef ROCKBOX_HAS_LOGF | ||
74 | lcd_putsf(0, line++, "logf:"); | ||
75 | logf_panic_dump(&line); | ||
76 | #endif | ||
77 | |||
78 | lcd_update(); | ||
79 | |||
80 | system_exception_wait(); /* If this returns, try to reboot */ | ||
81 | system_reboot(); | ||
82 | while (1); /* halt */ | ||
83 | } | ||
84 | |||
85 | void power_off(void) | ||
86 | { | ||
87 | system("/sbin/poweroff"); | ||
88 | } | ||
89 | |||
90 | void system_init(void) | ||
91 | { | ||
92 | int *s; | ||
93 | /* fake stack, to make thread-internal.h happy */ | ||
94 | stackbegin = stackend = (uintptr_t*)&s; | ||
95 | /* catch some signals for easier debugging */ | ||
96 | struct sigaction sa; | ||
97 | sigfillset(&sa.sa_mask); | ||
98 | sa.sa_flags = SA_SIGINFO; | ||
99 | sa.sa_sigaction = &sig_handler; | ||
100 | sigaction(SIGILL, &sa, NULL); | ||
101 | sigaction(SIGABRT, &sa, NULL); | ||
102 | sigaction(SIGFPE, &sa, NULL); | ||
103 | sigaction(SIGSEGV, &sa, NULL); | ||
104 | sigaction(SIGPIPE, &sa, NULL); | ||
105 | sigaction(SIGTERM, &sa, NULL); | ||
106 | sigaction(SIGBUS, &sa, NULL); | ||
107 | sigaction(SIGTERM, &sa, NULL); | ||
108 | } | ||
109 | |||
110 | void system_reboot(void) | ||
111 | { | ||
112 | system("/sbin/reboot"); | ||
113 | } | ||
114 | |||
115 | void system_exception_wait(void) | ||
116 | { | ||
117 | backlight_hw_on(); | ||
118 | backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); | ||
119 | /* wait until button press and release */ | ||
120 | while(button_read_device() != 0) {} | ||
121 | while(button_read_device() == 0) {} | ||
122 | while(button_read_device() != 0) {} | ||
123 | while(button_read_device() == 0) {} | ||
124 | } | ||
125 | |||
126 | bool hostfs_removable(IF_MD_NONVOID(int drive)) | ||
127 | { | ||
128 | #ifdef HAVE_MULTIDRIVE | ||
129 | if (drive > 0) /* Active LOW */ | ||
130 | return true; | ||
131 | else | ||
132 | #endif | ||
133 | return false; /* internal: always present */ | ||
134 | } | ||
135 | |||
136 | bool hostfs_present(IF_MD_NONVOID(int drive)) | ||
137 | { | ||
138 | #ifdef HAVE_MULTIDRIVE | ||
139 | if (drive > 0) /* Active LOW */ | ||
140 | return true; //FIXME | ||
141 | else | ||
142 | #endif | ||
143 | return true; /* internal: always present */ | ||
144 | } | ||
145 | |||
146 | #ifdef HAVE_MULTIDRIVE | ||
147 | int volume_drive(int drive) | ||
148 | { | ||
149 | return drive; | ||
150 | } | ||
151 | #endif /* HAVE_MULTIDRIVE */ | ||
152 | |||
153 | #ifdef CONFIG_STORAGE_MULTI | ||
154 | int hostfs_driver_type(int drive) | ||
155 | { | ||
156 | return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM; | ||
157 | } | ||
158 | #endif /* CONFIG_STORAGE_MULTI */ | ||
159 | |||
160 | int hostfs_init(void) | ||
161 | { | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | int hostfs_flush(void) | ||
166 | { | ||
167 | sync(); | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | #ifdef HAVE_HOTSWAP | ||
172 | bool volume_removable(int volume) | ||
173 | { | ||
174 | /* don't support more than one partition yet, so volume == drive */ | ||
175 | return hostfs_removable(volume); | ||
176 | } | ||
177 | |||
178 | bool volume_present(int volume) | ||
179 | { | ||
180 | /* don't support more than one partition yet, so volume == drive */ | ||
181 | return hostfs_present(volume); | ||
182 | } | ||
183 | #endif | ||
184 | |||
diff --git a/firmware/target/hosted/agptek/system-target.h b/firmware/target/hosted/agptek/system-target.h new file mode 100644 index 0000000000..830f19fde4 --- /dev/null +++ b/firmware/target/hosted/agptek/system-target.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2017 Marcin Bukat | ||
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 __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 | #endif /* __SYSTEM_TARGET_H__ */ | ||
diff --git a/firmware/target/hosted/alsa-controls.c b/firmware/target/hosted/alsa-controls.c index 1d6d73e751..19de7aea44 100644 --- a/firmware/target/hosted/alsa-controls.c +++ b/firmware/target/hosted/alsa-controls.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * | 8 | * |
9 | * Copyright (C) 2016 Amaury Pouly | 9 | * Copyright (C) 2016 Amaury Pouly |
diff --git a/firmware/target/hosted/alsa-controls.h b/firmware/target/hosted/alsa-controls.h index 870797c5b8..a08fc46e14 100644 --- a/firmware/target/hosted/alsa-controls.h +++ b/firmware/target/hosted/alsa-controls.h | |||
@@ -1,10 +1,19 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | <<<<<<< 9a9c7f2b7c63a9db203084a3485988c07f17b86c | ||
2 | * __________ __ ___. | 3 | * __________ __ ___. |
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | 4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 8 | * \/ \/ \/ \/ \/ |
9 | ======= | ||
10 | * __________ __ ___. | ||
11 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
12 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
13 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
14 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
15 | * \/ \/ \/ \/ \/ | ||
16 | >>>>>>> Agptek rocker port initial commit | ||
8 | * | 17 | * |
9 | * Copyright (C) 2016 Amaury Pouly | 18 | * Copyright (C) 2016 Amaury Pouly |
10 | * | 19 | * |
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c index 64ce9f41bc..4f1019c7a1 100644 --- a/firmware/target/hosted/filesystem-app.c +++ b/firmware/target/hosted/filesystem-app.c | |||
@@ -48,7 +48,8 @@ static const char rbhome[] = HOME_DIR; | |||
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ | 50 | #if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ |
51 | defined(SONY_NWZ_LINUX) || defined(DX90)) && !defined(__PCTOOL__) | 51 | defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER)) && \ |
52 | !defined(__PCTOOL__) | ||
52 | /* Special dirs are user-accessible (and user-writable) dirs which take priority | 53 | /* Special dirs are user-accessible (and user-writable) dirs which take priority |
53 | * over the ones where Rockbox is installed to. Classic example would be | 54 | * over the ones where Rockbox is installed to. Classic example would be |
54 | * $HOME/.config/rockbox.org vs /usr/share/rockbox */ | 55 | * $HOME/.config/rockbox.org vs /usr/share/rockbox */ |
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h index d14f70bf99..1ac124c881 100644 --- a/firmware/target/hosted/sdl/sim-ui-defines.h +++ b/firmware/target/hosted/sdl/sim-ui-defines.h | |||
@@ -515,6 +515,12 @@ | |||
515 | #define UI_LCD_POSX 78 | 515 | #define UI_LCD_POSX 78 |
516 | #define UI_LCD_POSY 92 | 516 | #define UI_LCD_POSY 92 |
517 | 517 | ||
518 | #elif defined(AGPTEK_ROCKER) | ||
519 | #define UI_TITLE "Agptek Rocker" | ||
520 | #define UI_WIDTH 186 | ||
521 | #define UI_HEIGHT 380 | ||
522 | #define UI_LCD_POSX 29 | ||
523 | #define UI_LCD_POSY 25 | ||
518 | #elif defined(SIMULATOR) | 524 | #elif defined(SIMULATOR) |
519 | #error no UI defines | 525 | #error no UI defines |
520 | #endif | 526 | #endif |