1 #ifndef LIBPICOFE_PLAT_H
2 #define LIBPICOFE_PLAT_H
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)
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)
34 /* target device, everything is optional */
36 int (*cpu_clock_get)(void);
37 int (*cpu_clock_set)(int clock);
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);
42 int (*step_volume)(int *volume, int diff);
43 int (*switch_layer)(int which, int enable);
44 const char **vout_methods;
47 const char **hwfilters;
49 const int *sound_rates;
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);
58 /* CPU clock in MHz */
59 static __inline int plat_target_cpu_clock_get(void)
61 if (plat_target.cpu_clock_get)
62 return plat_target.cpu_clock_get();
66 static __inline int plat_target_cpu_clock_set(int mhz)
68 if (plat_target.cpu_clock_set)
69 return plat_target.cpu_clock_set(mhz);
73 /* battery capacity (0-100) */
74 static __inline int plat_target_bat_capacity_get(void)
76 if (plat_target.bat_capacity_get)
77 return plat_target.bat_capacity_get();
81 /* set some hardware-specific video filter, 0 for none */
82 static __inline int plat_target_hwfilter_set(int which)
84 if (plat_target.hwfilter_set)
85 return plat_target.hwfilter_set(which);
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)
92 if (plat_target.lcdrate_set)
93 return plat_target.lcdrate_set(is_pal);
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)
100 if (plat_target.gamma_set)
101 return plat_target.gamma_set(val, black_level);
105 /* step sound volume up or down */
106 static __inline int plat_target_step_volume(int *volume, int diff)
108 if (plat_target.step_volume)
109 return plat_target.step_volume(volume, diff);
113 /* switch device graphics layers/overlays */
114 static __inline int plat_target_switch_layer(int which, int enable)
116 if (plat_target.switch_layer)
117 return plat_target.switch_layer(which, enable);
121 /* menu: enter (switch bpp, etc), begin/end drawing */
122 void plat_video_menu_update(void);
123 void plat_video_menu_enter(int is_rom_loaded);
124 void plat_video_menu_begin(void);
125 void plat_video_menu_end(void);
126 void plat_video_menu_leave(void);
128 void plat_video_flip(void);
129 void plat_video_wait_vsync(void);
131 /* return the dir/ where configs, saves, bios, etc. are found */
132 int plat_get_root_dir(char *dst, int len);
134 /* return the dir/ where skin files are found */
135 int plat_get_skin_dir(char *dst, int len);
137 /* return the top level dir for image files */
138 int plat_get_data_dir(char *dst, int len);
140 int plat_is_dir(const char *path);
141 int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
142 void plat_sleep_ms(int ms);
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);
147 int plat_mem_set_exec(void *ptr, size_t size);
149 /* timers, to be used for time diff and must refer to the same clock */
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);
154 void plat_debug_cat(char *str);
160 #endif /* LIBPICOFE_PLAT_H */