Commit | Line | Data |
---|---|---|
2d3fa877 | 1 | #ifndef LIBPICOFE_PLAT_H |
2 | #define LIBPICOFE_PLAT_H | |
3 | ||
e22d791c | 4 | #include <stdlib.h> |
5 | ||
24b24674 | 6 | #ifdef __cplusplus |
7 | extern "C" { | |
8 | #endif | |
9 | ||
ff8abddd | 10 | // platform dependend color handling |
11 | #if defined(USE_BGR555) | |
12 | #define PXMAKE(r,g,b) ((((b)<<7) & 0x7c00)|(((g)<<2) & 0x03e0)|((r)>>3)) | |
13 | #define PXMASKL(t,c) ((t) & (((1<<(c))-1)*0x04210421)) | |
14 | #define PXMASKH(t,c) ((t) & ~(((1<<(c))-1)*0x04210421) & 0x7fff) | |
15 | #define PXGETR(t) (((t) & 0x001f)<<3) | |
16 | #define PXGETG(t) (((t) & 0x03e0)>>2) | |
17 | #define PXGETB(t) (((t) & 0x7c00)>>7) | |
18 | #elif defined(USE_BGR565) | |
19 | #define PXMAKE(r,g,b) ((((b)<<8) & 0xf800)|(((g)<<3) & 0x07e0)|((r)>>3)) | |
20 | #define PXMASKL(t,c) ((t) & (((1<<(c))-1)*0x08210821)) | |
21 | #define PXMASKH(t,c) ((t) & ~(((1<<(c))-1)*0x08210821)) | |
22 | #define PXGETR(t) (((t) & 0x001f)<<3) | |
23 | #define PXGETG(t) (((t) & 0x07e0)>>3) | |
24 | #define PXGETB(t) (((t) & 0xf800)>>8) | |
25 | #else // RGB565 | |
26 | #define PXMAKE(r,g,b) ((((r)<<8) & 0xf800)|(((g)<<3) & 0x07e0)|((b)>>3)) | |
27 | #define PXMASKL(t,c) ((t) & (((1<<(c))-1)*0x08210821)) | |
28 | #define PXMASKH(t,c) ((t) & ~(((1<<(c))-1)*0x08210821)) | |
29 | #define PXGETR(t) (((t) & 0xf800)>>8) | |
30 | #define PXGETG(t) (((t) & 0x07e0)>>3) | |
31 | #define PXGETB(t) (((t) & 0x001f)<<3) | |
32 | #endif | |
33 | ||
2d3fa877 | 34 | /* target device, everything is optional */ |
35 | struct plat_target { | |
36 | int (*cpu_clock_get)(void); | |
37 | int (*cpu_clock_set)(int clock); | |
a1b30e1a | 38 | int (*bat_capacity_get)(void); |
39 | int (*hwfilter_set)(int which); | |
40 | int (*lcdrate_set)(int is_pal); | |
41 | int (*gamma_set)(int val, int black_level); | |
7ceadd99 | 42 | int (*step_volume)(int *volume, int diff); |
1bc471eb | 43 | int (*switch_layer)(int which, int enable); |
e81b987f | 44 | const char **vout_methods; |
45 | int vout_method; | |
46 | int vout_fullscreen; | |
47 | const char **hwfilters; | |
48 | int hwfilter; | |
82b48547 | 49 | const int *sound_rates; |
50 | int sound_rate; | |
2d3fa877 | 51 | }; |
b5bfb864 | 52 | |
2d3fa877 | 53 | extern struct plat_target plat_target; |
54 | int plat_target_init(void); | |
55 | void plat_target_finish(void); | |
56 | void plat_target_setup_input(void); | |
93c18cb4 | 57 | |
a1b30e1a | 58 | /* CPU clock in MHz */ |
59 | static __inline int plat_target_cpu_clock_get(void) | |
2d3fa877 | 60 | { |
a1b30e1a | 61 | if (plat_target.cpu_clock_get) |
62 | return plat_target.cpu_clock_get(); | |
63 | return -1; | |
2d3fa877 | 64 | } |
d572cbad | 65 | |
a1b30e1a | 66 | static __inline int plat_target_cpu_clock_set(int mhz) |
2d3fa877 | 67 | { |
a1b30e1a | 68 | if (plat_target.cpu_clock_set) |
69 | return plat_target.cpu_clock_set(mhz); | |
70 | return -1; | |
71 | } | |
72 | ||
73 | /* battery capacity (0-100) */ | |
74 | static __inline int plat_target_bat_capacity_get(void) | |
75 | { | |
76 | if (plat_target.bat_capacity_get) | |
77 | return plat_target.bat_capacity_get(); | |
78 | return -1; | |
79 | } | |
80 | ||
81 | /* set some hardware-specific video filter, 0 for none */ | |
82 | static __inline int plat_target_hwfilter_set(int which) | |
83 | { | |
84 | if (plat_target.hwfilter_set) | |
85 | return plat_target.hwfilter_set(which); | |
86 | return -1; | |
87 | } | |
88 | ||
89 | /* set device LCD rate, is_pal 0 for NTSC, 1 for PAL compatible */ | |
90 | static __inline int plat_target_lcdrate_set(int is_pal) | |
91 | { | |
92 | if (plat_target.lcdrate_set) | |
93 | return plat_target.lcdrate_set(is_pal); | |
94 | return -1; | |
95 | } | |
96 | ||
97 | /* set device LCD rate, is_pal 0 for NTSC, 1 for PAL compatible */ | |
98 | static __inline int plat_target_gamma_set(int val, int black_level) | |
99 | { | |
100 | if (plat_target.gamma_set) | |
101 | return plat_target.gamma_set(val, black_level); | |
102 | return -1; | |
103 | } | |
104 | ||
105 | /* step sound volume up or down */ | |
7ceadd99 | 106 | static __inline int plat_target_step_volume(int *volume, int diff) |
a1b30e1a | 107 | { |
108 | if (plat_target.step_volume) | |
7ceadd99 | 109 | return plat_target.step_volume(volume, diff); |
a1b30e1a | 110 | return -1; |
2d3fa877 | 111 | } |
388947f3 | 112 | |
1bc471eb | 113 | /* switch device graphics layers/overlays */ |
114 | static __inline int plat_target_switch_layer(int which, int enable) | |
115 | { | |
116 | if (plat_target.switch_layer) | |
117 | return plat_target.switch_layer(which, enable); | |
118 | return -1; | |
119 | } | |
120 | ||
24b24674 | 121 | /* menu: enter (switch bpp, etc), begin/end drawing */ |
fbbf5e3f | 122 | void plat_video_menu_update(void); |
24b24674 | 123 | void plat_video_menu_enter(int is_rom_loaded); |
124 | void plat_video_menu_begin(void); | |
125 | void plat_video_menu_end(void); | |
95a2ec38 | 126 | void plat_video_menu_leave(void); |
24b24674 | 127 | |
b188c2b6 | 128 | void plat_video_flip(void); |
b5bfb864 | 129 | void plat_video_wait_vsync(void); |
b188c2b6 | 130 | |
2d3fa877 | 131 | /* return the dir/ where configs, saves, bios, etc. are found */ |
132 | int plat_get_root_dir(char *dst, int len); | |
fa8d1331 | 133 | |
c52e6628 PC |
134 | /* return the dir/ where skin files are found */ |
135 | int plat_get_skin_dir(char *dst, int len); | |
136 | ||
a23a278d | 137 | /* return the top level dir for image files */ |
138 | int plat_get_data_dir(char *dst, int len); | |
139 | ||
049a6b3e | 140 | int plat_is_dir(const char *path); |
4ab30ad4 | 141 | int plat_wait_event(int *fds_hnds, int count, int timeout_ms); |
142 | void plat_sleep_ms(int ms); | |
049a6b3e | 143 | |
5e417de5 | 144 | void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed); |
145 | void *plat_mremap(void *ptr, size_t oldsize, size_t newsize); | |
146 | void plat_munmap(void *ptr, size_t size); | |
6282e17e | 147 | int plat_mem_set_exec(void *ptr, size_t size); |
5e417de5 | 148 | |
8ced8d2b | 149 | /* timers, to be used for time diff and must refer to the same clock */ |
b5bfb864 | 150 | unsigned int plat_get_ticks_ms(void); |
151 | unsigned int plat_get_ticks_us(void); | |
152 | void plat_wait_till_us(unsigned int us); | |
4ab30ad4 | 153 | |
93c18cb4 | 154 | void plat_debug_cat(char *str); |
049a6b3e | 155 | |
24b24674 | 156 | #ifdef __cplusplus |
157 | } // extern "C" | |
158 | #endif | |
159 | ||
2d3fa877 | 160 | #endif /* LIBPICOFE_PLAT_H */ |