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