refactor plat.h, add gamma
[libpicofe.git] / plat.h
CommitLineData
2d3fa877 1#ifndef LIBPICOFE_PLAT_H
2#define LIBPICOFE_PLAT_H
3
24b24674 4#ifdef __cplusplus
5extern "C" {
6#endif
7
2d3fa877 8/* target device, everything is optional */
9struct plat_target {
10 int (*cpu_clock_get)(void);
11 int (*cpu_clock_set)(int clock);
a1b30e1a 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;
2d3fa877 18};
b5bfb864 19
2d3fa877 20extern struct plat_target plat_target;
21int plat_target_init(void);
22void plat_target_finish(void);
23void plat_target_setup_input(void);
93c18cb4 24
a1b30e1a 25/* CPU clock in MHz */
26static __inline int plat_target_cpu_clock_get(void)
2d3fa877 27{
a1b30e1a 28 if (plat_target.cpu_clock_get)
29 return plat_target.cpu_clock_get();
30 return -1;
2d3fa877 31}
d572cbad 32
a1b30e1a 33static __inline int plat_target_cpu_clock_set(int mhz)
2d3fa877 34{
a1b30e1a 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) */
41static __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 */
49static __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 */
57static __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 */
65static __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 */
73static __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;
2d3fa877 78}
388947f3 79
24b24674 80/* menu: enter (switch bpp, etc), begin/end drawing */
81void plat_video_menu_enter(int is_rom_loaded);
82void plat_video_menu_begin(void);
83void plat_video_menu_end(void);
95a2ec38 84void plat_video_menu_leave(void);
24b24674 85
b188c2b6 86void plat_video_flip(void);
b5bfb864 87void plat_video_wait_vsync(void);
b188c2b6 88
2d3fa877 89/* return the dir/ where configs, saves, bios, etc. are found */
90int plat_get_root_dir(char *dst, int len);
fa8d1331 91
049a6b3e 92int plat_is_dir(const char *path);
4ab30ad4 93int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
94void plat_sleep_ms(int ms);
049a6b3e 95
5e417de5 96void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
97void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
98void plat_munmap(void *ptr, size_t size);
99
8ced8d2b 100/* timers, to be used for time diff and must refer to the same clock */
b5bfb864 101unsigned int plat_get_ticks_ms(void);
102unsigned int plat_get_ticks_us(void);
103void plat_wait_till_us(unsigned int us);
4ab30ad4 104
93c18cb4 105void plat_debug_cat(char *str);
049a6b3e 106
24b24674 107#ifdef __cplusplus
108} // extern "C"
109#endif
110
2d3fa877 111#endif /* LIBPICOFE_PLAT_H */