diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-11-11 16:01:14 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2016-11-11 16:07:14 +0100 |
commit | c95e30b75d75b674f0d645b7c41377bbd0511213 (patch) | |
tree | 3a0d6253a0a5cab8cbc14b1258f0b2d7b4f74e0d /utils/nwztools/plattools/nwz_lib.h | |
parent | 44bb2856a59be53ef5ede154a39c54a59b1cc6d0 (diff) | |
download | rockbox-c95e30b75d75b674f0d645b7c41377bbd0511213.tar.gz rockbox-c95e30b75d75b674f0d645b7c41377bbd0511213.zip |
nwztools/plattools: use player database and rework stuff
Using the database, we can now safely read/write the NVP. I also add more
support for Sony's "display" tool.
Change-Id: I8439fe9bad391c7f29859d99f236781be7983625
Diffstat (limited to 'utils/nwztools/plattools/nwz_lib.h')
-rw-r--r-- | utils/nwztools/plattools/nwz_lib.h | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/utils/nwztools/plattools/nwz_lib.h b/utils/nwztools/plattools/nwz_lib.h index 9e7b8f16c2..18d7f9dd07 100644 --- a/utils/nwztools/plattools/nwz_lib.h +++ b/utils/nwztools/plattools/nwz_lib.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/wait.h> | 29 | #include <sys/wait.h> |
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
31 | #include <linux/fb.h> | ||
31 | #include <fcntl.h> | 32 | #include <fcntl.h> |
32 | #include <string.h> | 33 | #include <string.h> |
33 | #include <stdlib.h> | 34 | #include <stdlib.h> |
@@ -37,14 +38,16 @@ | |||
37 | #include "nwz_adc.h" | 38 | #include "nwz_adc.h" |
38 | #include "nwz_ts.h" | 39 | #include "nwz_ts.h" |
39 | #include "nwz_power.h" | 40 | #include "nwz_power.h" |
41 | #include "nwz_db.h" | ||
40 | 42 | ||
41 | struct nwz_dev_info_t | 43 | /* get model ID, either from ICX_MODEL_ID env var or using nvpflag, return 0 |
42 | { | 44 | * in case of error; note that the result is cached so this function is only |
43 | unsigned long model_id; | 45 | * expensive the first time it is called */ |
44 | const char *name; | 46 | unsigned long nwz_get_model_id(void); |
45 | }; | 47 | /* get series (index into nwz_series, or -1 on error) */ |
46 | 48 | int nwz_get_series(void); | |
47 | const char *nwz_get_model_name(unsigned long model_id); | 49 | /* get model name, or null on error */ |
50 | const char *nwz_get_model_name(void); | ||
48 | 51 | ||
49 | /* run a program and exit with nonzero status in case of error | 52 | /* run a program and exit with nonzero status in case of error |
50 | * argument list must be NULL terminated */ | 53 | * argument list must be NULL terminated */ |
@@ -52,10 +55,30 @@ int nwz_run(const char *file, const char *args[], bool wait); | |||
52 | /* run a program and return program output */ | 55 | /* run a program and return program output */ |
53 | char *nwz_run_pipe(const char *file, const char *args[], int *status); | 56 | char *nwz_run_pipe(const char *file, const char *args[], int *status); |
54 | 57 | ||
55 | /* invoke /usr/bin/lcdmsg to display a message using the small font, optionally | 58 | /* invoke /usr/local/bin/lcdmsg to display a message using the small font, optionally |
56 | * clearing the screen before */ | 59 | * clearing the screen before */ |
57 | void nwz_lcdmsg(bool clear, int x, int y, const char *msg); | 60 | void nwz_lcdmsg(bool clear, int x, int y, const char *msg); |
58 | void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...); | 61 | void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...); |
62 | /* invoke /usr/local/bin/display to do various things: | ||
63 | * - clear screen | ||
64 | * - display text | ||
65 | * - display bitmap | ||
66 | * Currently all operations are performed on the LCD only. | ||
67 | * The small text font is 8x12 and the big one is 14x24 */ | ||
68 | typedef int nwz_color_t; | ||
69 | #define NWZ_COLOR(r, g, b) /* each component between 0 and 255 */ \ | ||
70 | ((r) << 16 | (g) << 8 | (b)) | ||
71 | #define NWZ_COLOR_RED(col) ((col) >> 16) | ||
72 | #define NWZ_COLOR_GREEN(col) (((col) >> 8) & 0xff) | ||
73 | #define NWZ_COLOR_BLUE(col) ((col) & 0xff) | ||
74 | #define NWZ_COLOR_NO_KEY (1 << 24) | ||
75 | void nwz_display_clear(nwz_color_t color); | ||
76 | void nwz_display_text(int x, int y, bool big_font, nwz_color_t foreground_col, | ||
77 | nwz_color_t background_col, int background_alpha, const char *text); | ||
78 | void nwz_display_textf(int x, int y, bool big_font, nwz_color_t foreground_col, | ||
79 | nwz_color_t background_col, int background_alpha, const char *fmt, ...); | ||
80 | void nwz_display_bitmap(int x, int y, const char *file, int left, int top, | ||
81 | int width, int height, nwz_color_t key, int bmp_alpha); | ||
59 | 82 | ||
60 | /* open icx_key input device and return file descriptor */ | 83 | /* open icx_key input device and return file descriptor */ |
61 | int nwz_key_open(void); | 84 | int nwz_key_open(void); |
@@ -81,6 +104,8 @@ const char *nwz_key_get_name(int keycode); | |||
81 | int nwz_fb_open(bool lcd); | 104 | int nwz_fb_open(bool lcd); |
82 | /* close framebuffer device */ | 105 | /* close framebuffer device */ |
83 | void nwz_fb_close(int fb); | 106 | void nwz_fb_close(int fb); |
107 | /* get screen resolution, parameters are allowed to be NULL */ | ||
108 | int nwz_fb_get_resolution(int fd, int *x, int *y, int *bpp); | ||
84 | /* get backlight brightness (return -1 on error, 1 on success) */ | 109 | /* get backlight brightness (return -1 on error, 1 on success) */ |
85 | int nwz_fb_get_brightness(int fd, struct nwz_fb_brightness *bl); | 110 | int nwz_fb_get_brightness(int fd, struct nwz_fb_brightness *bl); |
86 | /* set backlight brightness (return -1 on error, 1 on success) */ | 111 | /* set backlight brightness (return -1 on error, 1 on success) */ |
@@ -171,4 +196,12 @@ void nwz_pminfo_close(int fd); | |||
171 | /* get pminfo factor (or 0 on error) */ | 196 | /* get pminfo factor (or 0 on error) */ |
172 | unsigned int nwz_pminfo_get_factor(int fd); | 197 | unsigned int nwz_pminfo_get_factor(int fd); |
173 | 198 | ||
199 | /* read a nvp node and return its size, if the data pointer is null, then simply | ||
200 | * return the size, return -1 on error */ | ||
201 | int nwz_nvp_read(enum nwz_nvp_node_t node, void *data); | ||
202 | /* write a nvp node, return 0 on success and -1 on error, the size of the buffer | ||
203 | * must be the one returned by nwz_nvp_read */ | ||
204 | int nwz_nvp_write(enum nwz_nvp_node_t node, void *data); | ||
205 | |||
206 | |||
174 | #endif /* _NWZLIB_H_ */ | 207 | #endif /* _NWZLIB_H_ */ |