Get rid of bit fields in union
[pcsx_rearmed.git] / plugins / gpulib / gpu.h
CommitLineData
56f08d83 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
6f2ee2be 13#ifdef __cplusplus
14extern "C" {
15#endif
16
56f08d83 17#define CMD_BUFFER_LEN 1024
18
f23b103c
PC
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
56f08d83 29struct psx_gpu {
56f08d83 30 uint32_t cmd_buffer[CMD_BUFFER_LEN];
31 uint32_t regs[16];
9ee0fd5b 32 uint16_t *vram;
f23b103c 33 uint32_t status;
6e9bdaef 34 uint32_t gp0;
35 uint32_t ex_regs[8];
56f08d83 36 struct {
8dd855cd 37 int hres, vres;
56f08d83 38 int x, y, w, h;
8dd855cd 39 int x1, x2;
56f08d83 40 int y1, y2;
41 } screen;
42 struct {
43 int x, y, w, h;
05740673 44 short int offset, is_read;
45 } dma, dma_start;
56f08d83 46 int cmd_len;
56f08d83 47 uint32_t zero;
fc84f618 48 struct {
49 uint32_t fb_dirty:1;
5440b88e 50 uint32_t old_interlace:1;
51 uint32_t allow_interlace:2;
aafcb4dd 52 uint32_t blanked:1;
0b02eb77 53 uint32_t enhancement_enable:1;
54 uint32_t enhancement_active:1;
3ece2f0c 55 uint32_t *frame_count;
56 uint32_t *hcnt; /* hsync count */
deb18d24 57 struct {
58 uint32_t addr;
1c72b1c2 59 uint32_t cycles;
deb18d24 60 uint32_t frame;
61 uint32_t hcnt;
62 } last_list;
5440b88e 63 uint32_t last_vram_read_frame;
fc84f618 64 } state;
65 struct {
9fe27e25 66 int32_t set:3; /* -1 auto, 0 off, 1-3 fixed */
67 int32_t cnt:3; /* amount skipped in a row */
fc84f618 68 uint32_t active:1;
fb4c6fba 69 uint32_t allow:1;
fc84f618 70 uint32_t frame_ready:1;
71 const int *advice;
fb4c6fba 72 uint32_t last_flip_frame;
fbb4bfff 73 uint32_t pending_fill[3];
fc84f618 74 } frameskip;
a8be0deb 75 uint16_t *(*get_enhancement_bufer)
fa56d360 76 (int *x, int *y, int *w, int *h, int *vram_h);
9ee0fd5b 77 void *(*mmap)(unsigned int size);
78 void (*munmap)(void *ptr, unsigned int size);
56f08d83 79};
80
81extern struct psx_gpu gpu;
82
83extern const unsigned char cmd_lengths[256];
84
b243416b 85int do_cmd_list(uint32_t *list, int count, int *last_cmd);
56f08d83 86
914455e6 87struct rearmed_cbs;
88
9394ada5 89int renderer_init(void);
e929dec5 90void renderer_finish(void);
5b745e5b 91void renderer_sync_ecmds(uint32_t * ecmds);
05740673 92void renderer_update_caches(int x, int y, int w, int h);
9394ada5 93void renderer_flush_queues(void);
5440b88e 94void renderer_set_interlace(int enable, int is_odd);
914455e6 95void renderer_set_config(const struct rearmed_cbs *config);
e929dec5 96void renderer_notify_res_change(void);
9394ada5 97
5440b88e 98int vout_init(void);
99int vout_finish(void);
100void vout_update(void);
aafcb4dd 101void vout_blank(void);
5440b88e 102void vout_set_config(const struct rearmed_cbs *config);
6f2ee2be 103
096ec49b 104/* listing these here for correct linkage if rasterizer uses c++ */
105struct GPUFreeze;
096ec49b 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);
72e5023f 120void GPUvBlank(int is_vblank, int lcf);
096ec49b 121void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_);
122
6f2ee2be 123#ifdef __cplusplus
124}
125#endif