diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-09-06 23:30:15 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-09-17 00:02:00 +0200 |
commit | f22ccabac339925dbb004bd035307480fca9d2f7 (patch) | |
tree | 5ab22e5ede1a182b9cd4f240f1671202071e919c | |
parent | 0291db372edbf5c2b589cbb5d5d01fdc1763cd62 (diff) | |
download | rockbox-f22ccabac339925dbb004bd035307480fca9d2f7.tar.gz rockbox-f22ccabac339925dbb004bd035307480fca9d2f7.zip |
sonynwz: fix various drivers, notably touchscreen related
Change-Id: If43087ec9ad405ee6eeae8bedba8d221f8fb142f
-rw-r--r-- | firmware/target/hosted/sonynwz/button-nwz.c | 64 | ||||
-rw-r--r-- | firmware/target/hosted/sonynwz/lcd-nwz.c | 2 | ||||
-rw-r--r-- | firmware/target/hosted/sonynwz/system-nwz.c | 14 |
3 files changed, 44 insertions, 36 deletions
diff --git a/firmware/target/hosted/sonynwz/button-nwz.c b/firmware/target/hosted/sonynwz/button-nwz.c index 0cbb3c5869..3be74fc924 100644 --- a/firmware/target/hosted/sonynwz/button-nwz.c +++ b/firmware/target/hosted/sonynwz/button-nwz.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <string.h> | 36 | #include <string.h> |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <system.h> | ||
38 | 39 | ||
39 | /* device types */ | 40 | /* device types */ |
40 | #define DEV_KEY 0 /* icx_keys driver */ | 41 | #define DEV_KEY 0 /* icx_keys driver */ |
@@ -70,64 +71,64 @@ static bool touch_detect; | |||
70 | /* get touchscreen information and init state */ | 71 | /* get touchscreen information and init state */ |
71 | int ts_init_state(int fd) | 72 | int ts_init_state(int fd) |
72 | { | 73 | { |
73 | memset(state, 0, sizeof(struct nwz_ts_state_t)); | 74 | memset(&ts_state, 0, sizeof(ts_state)); |
74 | struct input_absinfo info; | 75 | struct input_absinfo info; |
75 | if(ioctl(fd, EVIOCGABS(ABS_X), &info) < 0) | 76 | if(ioctl(fd, EVIOCGABS(ABS_X), &info) < 0) |
76 | return -1; | 77 | return -1; |
77 | state->max_x = info.maximum; | 78 | ts_state.max_x = info.maximum; |
78 | if(ioctl(fd, EVIOCGABS(ABS_Y), &info) < 0) | 79 | if(ioctl(fd, EVIOCGABS(ABS_Y), &info) < 0) |
79 | return -1; | 80 | return -1; |
80 | state->max_y = info.maximum; | 81 | ts_state.max_y = info.maximum; |
81 | if(ioctl(fd, EVIOCGABS(ABS_PRESSURE), &info) < 0) | 82 | if(ioctl(fd, EVIOCGABS(ABS_PRESSURE), &info) < 0) |
82 | return -1; | 83 | return -1; |
83 | state->max_pressure = info.maximum; | 84 | ts_state.max_pressure = info.maximum; |
84 | if(ioctl(fd, EVIOCGABS(ABS_TOOL_WIDTH), &info) < 0) | 85 | if(ioctl(fd, EVIOCGABS(ABS_TOOL_WIDTH), &info) < 0) |
85 | return -1; | 86 | return -1; |
86 | state->max_tool_width = info.maximum; | 87 | ts_state.max_tool_width = info.maximum; |
87 | touch_detect = false; | 88 | touch_detect = false; |
88 | return 0; | 89 | return 0; |
89 | } | 90 | } |
90 | 91 | ||
91 | void handle_touch(struct input_event *evt) | 92 | void handle_touch(struct input_event evt) |
92 | { | 93 | { |
93 | switch(evt->type) | 94 | switch(evt.type) |
94 | { | 95 | { |
95 | case EV_SYN: | 96 | case EV_SYN: |
96 | /* on SYN, we copy the state to the rockbox state */ | 97 | /* on SYN, we copy the state to the rockbox state */ |
97 | touch_x = ts_state->x; | 98 | touch_x = ts_state.x; |
98 | touch_y = ts_state->y; | 99 | touch_y = ts_state.y; |
99 | /* map coordinate to screen */ | 100 | /* map coordinate to screen */ |
100 | x = x * LCD_WIDTH / ts_state->max_x; | 101 | touch_x = touch_x * LCD_WIDTH / ts_state.max_x; |
101 | y = y * LCD_HEIGHT / ts_state->max_y; | 102 | touch_y = touch_y * LCD_HEIGHT / ts_state.max_y; |
102 | /* don't trust driver reported ranges */ | 103 | /* don't trust driver reported ranges */ |
103 | x = MAX(0, MIN(x, LCD_WIDTH - 1)); | 104 | touch_x = MAX(0, MIN(touch_x, LCD_WIDTH - 1)); |
104 | y = MAX(0, MIN(y, LCD_HEIGHT - 1)); | 105 | touch_y = MAX(0, MIN(touch_y, LCD_HEIGHT - 1)); |
105 | touch_detect = ts_state->touch; | 106 | touch_detect = ts_state.touch; |
106 | /* reset flick */ | 107 | /* reset flick */ |
107 | state->flick = false; | 108 | ts_state.flick = false; |
108 | break; | 109 | break; |
109 | case EV_REL: | 110 | case EV_REL: |
110 | if(evt->code == REL_RX) | 111 | if(evt.code == REL_RX) |
111 | state->flick_x = evt->value; | 112 | ts_state.flick_x = evt.value; |
112 | else if(evt->code == REL_RY) | 113 | else if(evt.code == REL_RY) |
113 | state->flick_y = evt->value; | 114 | ts_state.flick_y = evt.value; |
114 | else | 115 | else |
115 | break; | 116 | break; |
116 | state->flick = true; | 117 | ts_state.flick = true; |
117 | break; | 118 | break; |
118 | case EV_ABS: | 119 | case EV_ABS: |
119 | if(evt->code == ABS_X) | 120 | if(evt.code == ABS_X) |
120 | state->x = evt->value; | 121 | ts_state.x = evt.value; |
121 | else if(evt->code == ABS_Y) | 122 | else if(evt.code == ABS_Y) |
122 | state->y = evt->value; | 123 | ts_state.y = evt.value; |
123 | else if(evt->code == ABS_PRESSURE) | 124 | else if(evt.code == ABS_PRESSURE) |
124 | state->pressure = evt->value; | 125 | ts_state.pressure = evt.value; |
125 | else if(evt->code == ABS_TOOL_WIDTH) | 126 | else if(evt.code == ABS_TOOL_WIDTH) |
126 | state->tool_width = evt->value; | 127 | ts_state.tool_width = evt.value; |
127 | break; | 128 | break; |
128 | case EV_KEY: | 129 | case EV_KEY: |
129 | if(evt->code == BTN_TOUCH) | 130 | if(evt.code == BTN_TOUCH) |
130 | state->touch = evt->value; | 131 | ts_state.touch = evt.value; |
131 | break; | 132 | break; |
132 | default: | 133 | default: |
133 | break; | 134 | break; |
@@ -296,7 +297,8 @@ int button_read_device( | |||
296 | } | 297 | } |
297 | } | 298 | } |
298 | #ifdef HAVE_TOUCHSCREEN | 299 | #ifdef HAVE_TOUCHSCREEN |
299 | button_bitmap |= touchscreen_to_pixels(touch_x, touch_y, data); | 300 | if(touch_detect) |
301 | button_bitmap |= touchscreen_to_pixels(touch_x, touch_y, data); | ||
300 | #endif | 302 | #endif |
301 | return hold_status ? 0 : button_bitmap; | 303 | return hold_status ? 0 : button_bitmap; |
302 | } | 304 | } |
diff --git a/firmware/target/hosted/sonynwz/lcd-nwz.c b/firmware/target/hosted/sonynwz/lcd-nwz.c index bfcde3a76a..93a426f78b 100644 --- a/firmware/target/hosted/sonynwz/lcd-nwz.c +++ b/firmware/target/hosted/sonynwz/lcd-nwz.c | |||
@@ -47,7 +47,7 @@ void identify_fb(const char *id) | |||
47 | nwz_fb_type = FB_EMXX; | 47 | nwz_fb_type = FB_EMXX; |
48 | else | 48 | else |
49 | nwz_fb_type = FB_OTHER; | 49 | nwz_fb_type = FB_OTHER; |
50 | printf("lcd: fb id = '%s -> type = %d\n", id, nwz_fb_type); | 50 | printf("lcd: fb id = '%s' -> type = %d\n", id, nwz_fb_type); |
51 | } | 51 | } |
52 | 52 | ||
53 | /* select which page (0 or 1) to display, disable DSP, transparency and rotation */ | 53 | /* select which page (0 or 1) to display, disable DSP, transparency and rotation */ |
diff --git a/firmware/target/hosted/sonynwz/system-nwz.c b/firmware/target/hosted/sonynwz/system-nwz.c index c804c5ab66..5ef660be8c 100644 --- a/firmware/target/hosted/sonynwz/system-nwz.c +++ b/firmware/target/hosted/sonynwz/system-nwz.c | |||
@@ -167,15 +167,21 @@ void system_reboot(void) | |||
167 | power_off(); | 167 | power_off(); |
168 | } | 168 | } |
169 | 169 | ||
170 | #ifdef HAVE_BUTTON_DATA | ||
171 | #define IF_DATA(data) data | ||
172 | #else | ||
173 | #define IF_DATA(data) | ||
174 | #endif | ||
170 | void system_exception_wait(void) | 175 | void system_exception_wait(void) |
171 | { | 176 | { |
172 | backlight_hw_on(); | 177 | backlight_hw_on(); |
173 | backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); | 178 | backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING); |
174 | /* wait until button press and release */ | 179 | /* wait until button press and release */ |
175 | while(button_read_device() != 0) {} | 180 | IF_DATA(int data); |
176 | while(button_read_device() == 0) {} | 181 | while(button_read_device(IF_DATA(&data)) != 0) {} |
177 | while(button_read_device() != 0) {} | 182 | while(button_read_device(IF_DATA(&data)) == 0) {} |
178 | while(button_read_device() == 0) {} | 183 | while(button_read_device(IF_DATA(&data)) != 0) {} |
184 | while(button_read_device(IF_DATA(&data)) == 0) {} | ||
179 | } | 185 | } |
180 | 186 | ||
181 | int hostfs_init(void) | 187 | int hostfs_init(void) |