Get rid of bit fields in union
[pcsx_rearmed.git] / plugins / gpulib / gpu.h
... / ...
CommitLineData
1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11#include <stdint.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#define CMD_BUFFER_LEN 1024
18
19#define BIT(x) (1 << (x))
20
21#define PSX_GPU_STATUS_DHEIGHT BIT(19)
22#define PSX_GPU_STATUS_RGB24 BIT(21)
23#define PSX_GPU_STATUS_INTERLACE BIT(22)
24#define PSX_GPU_STATUS_BLANKING BIT(23)
25#define PSX_GPU_STATUS_IMG BIT(27)
26#define PSX_GPU_STATUS_DMA(x) ((x) << 29)
27#define PSX_GPU_STATUS_DMA_MASK (BIT(29) | BIT(30))
28
29struct psx_gpu {
30 uint32_t cmd_buffer[CMD_BUFFER_LEN];
31 uint32_t regs[16];
32 uint16_t *vram;
33 uint32_t status;
34 uint32_t gp0;
35 uint32_t ex_regs[8];
36 struct {
37 int hres, vres;
38 int x, y, w, h;
39 int x1, x2;
40 int y1, y2;
41 } screen;
42 struct {
43 int x, y, w, h;
44 short int offset, is_read;
45 } dma, dma_start;
46 int cmd_len;
47 uint32_t zero;
48 struct {
49 uint32_t fb_dirty:1;
50 uint32_t old_interlace:1;
51 uint32_t allow_interlace:2;
52 uint32_t blanked:1;
53 uint32_t enhancement_enable:1;
54 uint32_t enhancement_active:1;
55 uint32_t *frame_count;
56 uint32_t *hcnt; /* hsync count */
57 struct {
58 uint32_t addr;
59 uint32_t cycles;
60 uint32_t frame;
61 uint32_t hcnt;
62 } last_list;
63 uint32_t last_vram_read_frame;
64 } state;
65 struct {
66 int32_t set:3; /* -1 auto, 0 off, 1-3 fixed */
67 int32_t cnt:3; /* amount skipped in a row */
68 uint32_t active:1;
69 uint32_t allow:1;
70 uint32_t frame_ready:1;
71 const int *advice;
72 uint32_t last_flip_frame;
73 uint32_t pending_fill[3];
74 } frameskip;
75 uint16_t *(*get_enhancement_bufer)
76 (int *x, int *y, int *w, int *h, int *vram_h);
77 void *(*mmap)(unsigned int size);
78 void (*munmap)(void *ptr, unsigned int size);
79};
80
81extern struct psx_gpu gpu;
82
83extern const unsigned char cmd_lengths[256];
84
85int do_cmd_list(uint32_t *list, int count, int *last_cmd);
86
87struct rearmed_cbs;
88
89int renderer_init(void);
90void renderer_finish(void);
91void renderer_sync_ecmds(uint32_t * ecmds);
92void renderer_update_caches(int x, int y, int w, int h);
93void renderer_flush_queues(void);
94void renderer_set_interlace(int enable, int is_odd);
95void renderer_set_config(const struct rearmed_cbs *config);
96void renderer_notify_res_change(void);
97
98int vout_init(void);
99int vout_finish(void);
100void vout_update(void);
101void vout_blank(void);
102void vout_set_config(const struct rearmed_cbs *config);
103
104/* listing these here for correct linkage if rasterizer uses c++ */
105struct GPUFreeze;
106
107long GPUinit(void);
108long GPUshutdown(void);
109void GPUwriteDataMem(uint32_t *mem, int count);
110long GPUdmaChain(uint32_t *rambase, uint32_t addr);
111void GPUwriteData(uint32_t data);
112void GPUreadDataMem(uint32_t *mem, int count);
113uint32_t GPUreadData(void);
114uint32_t GPUreadStatus(void);
115void GPUwriteStatus(uint32_t data);
116long GPUfreeze(uint32_t type, struct GPUFreeze *freeze);
117void GPUupdateLace(void);
118long GPUopen(void **dpy);
119long GPUclose(void);
120void GPUvBlank(int is_vblank, int lcf);
121void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_);
122
123#ifdef __cplusplus
124}
125#endif