fonts: add uyvy function
[libpicofe.git] / plat.h
1 #ifndef LIBPICOFE_PLAT_H
2 #define LIBPICOFE_PLAT_H
3
4 #include <stdlib.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 /* target device, everything is optional */
11 struct plat_target {
12         int (*cpu_clock_get)(void);
13         int (*cpu_clock_set)(int clock);
14         int (*bat_capacity_get)(void);
15         int (*hwfilter_set)(int which);
16         int (*lcdrate_set)(int is_pal);
17         int (*gamma_set)(int val, int black_level);
18         int (*step_volume)(int is_up);
19         char **hwfilters;
20 };
21
22 extern struct plat_target plat_target;
23 int  plat_target_init(void);
24 void plat_target_finish(void);
25 void plat_target_setup_input(void);
26
27 /* CPU clock in MHz */
28 static __inline int plat_target_cpu_clock_get(void)
29 {
30         if (plat_target.cpu_clock_get)
31                 return plat_target.cpu_clock_get();
32         return -1;
33 }
34
35 static __inline int plat_target_cpu_clock_set(int mhz)
36 {
37         if (plat_target.cpu_clock_set)
38                 return plat_target.cpu_clock_set(mhz);
39         return -1;
40 }
41
42 /* battery capacity (0-100) */
43 static __inline int plat_target_bat_capacity_get(void)
44 {
45         if (plat_target.bat_capacity_get)
46                 return plat_target.bat_capacity_get();
47         return -1;
48 }
49
50 /* set some hardware-specific video filter, 0 for none */
51 static __inline int plat_target_hwfilter_set(int which)
52 {
53         if (plat_target.hwfilter_set)
54                 return plat_target.hwfilter_set(which);
55         return -1;
56 }
57
58 /* set device LCD rate, is_pal 0 for NTSC, 1 for PAL compatible */
59 static __inline int plat_target_lcdrate_set(int is_pal)
60 {
61         if (plat_target.lcdrate_set)
62                 return plat_target.lcdrate_set(is_pal);
63         return -1;
64 }
65
66 /* set device LCD rate, is_pal 0 for NTSC, 1 for PAL compatible */
67 static __inline int plat_target_gamma_set(int val, int black_level)
68 {
69         if (plat_target.gamma_set)
70                 return plat_target.gamma_set(val, black_level);
71         return -1;
72 }
73
74 /* step sound volume up or down */
75 static __inline int plat_target_step_volume(int is_up)
76 {
77         if (plat_target.step_volume)
78                 return plat_target.step_volume(is_up);
79         return -1;
80 }
81
82 /* menu: enter (switch bpp, etc), begin/end drawing */
83 void plat_video_menu_enter(int is_rom_loaded);
84 void plat_video_menu_begin(void);
85 void plat_video_menu_end(void);
86 void plat_video_menu_leave(void);
87
88 void plat_video_flip(void);
89 void plat_video_wait_vsync(void);
90
91 /* return the dir/ where configs, saves, bios, etc. are found */
92 int  plat_get_root_dir(char *dst, int len);
93
94 int  plat_is_dir(const char *path);
95 int  plat_wait_event(int *fds_hnds, int count, int timeout_ms);
96 void plat_sleep_ms(int ms);
97
98 void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
99 void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
100 void  plat_munmap(void *ptr, size_t size);
101
102 /* timers, to be used for time diff and must refer to the same clock */
103 unsigned int plat_get_ticks_ms(void);
104 unsigned int plat_get_ticks_us(void);
105 void plat_wait_till_us(unsigned int us);
106
107 void plat_debug_cat(char *str);
108
109 #ifdef __cplusplus
110 } // extern "C"
111 #endif
112
113 #endif /* LIBPICOFE_PLAT_H */