43
static struct fb_fix_screeninfo fb_finfo;
44
static struct fb_var_screeninfo fb_vinfo;
45
static uint32_t in_width, in_height, in_format, in_depth, in_s3_format,
42
typedef struct vga_type {
47
static vga_t *v = NULL;
49
static struct fb_fix_screeninfo fb_finfo;
50
static struct fb_var_screeninfo fb_vinfo;
51
static uint32_t in_width, in_height, in_format, in_depth, in_s3_format,
46
52
screenwidth, screenheight, screendepth, screenstride,
47
53
vidwidth, vidheight, vidx, vidy, page, offset, sreg;
48
static char *inpage, *inpage0, *smem = NULL;
49
static void (*alpha_func)();
54
static char *inpage, *inpage0, *smem = NULL;
55
static void (*alpha_func)();
51
57
static void clear_screen();
80
86
#define S3V_MMIO_REGSIZE 0x8000 /* 32KB */
81
87
#define S3_NEWMMIO_VGABASE (S3_NEWMMIO_REGBASE + 0x8000)
83
#define OUTREG(mmreg, value) *(unsigned int *)(&v.mmio[mmreg]) = value
85
typedef struct vga_type {
89
#define OUTREG(mmreg, value) *(unsigned int *)(&v->mmio[mmreg]) = value
90
91
int readcrtc(int reg) {
97
98
outb(value, 0x3d5);
100
int enable(vga_t *v) {
101
// enable S3 registers
106
v->cr38 = readcrtc(0x38);
107
v->cr39 = readcrtc(0x39);
108
v->cr53 = readcrtc(0x53);
109
writecrtc(0x38, 0x48);
110
writecrtc(0x39, 0xa5);
111
writecrtc(0x53, 0x08);
112
fd = open("/dev/mem", O_RDWR);
113
v->mmio = mmap(0, S3_NEWMMIO_REGSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
108
v = malloc(sizeof(vga_t));
110
if (ioperm(0x3d4, 2, 1) == 0) {
111
fd = open("/dev/mem", O_RDWR);
113
v->mmio = mmap(0, S3_NEWMMIO_REGSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
114
114
S3_MEMBASE + S3_NEWMMIO_REGBASE);
116
if (v->mmio != MAP_FAILED) {
117
v->cr38 = readcrtc(0x38);
118
v->cr39 = readcrtc(0x39);
119
v->cr53 = readcrtc(0x53);
120
writecrtc(0x38, 0x48);
121
writecrtc(0x39, 0xa5);
122
writecrtc(0x53, 0x08);
119
void disable(vga_t *v) {
120
writecrtc(0x53, v->cr53);
121
writecrtc(0x39, v->cr39);
122
writecrtc(0x38, v->cr38);
124
munmap(v->mmio, S3_NEWMMIO_REGSIZE);
135
writecrtc(0x53, v->cr53);
136
writecrtc(0x39, v->cr39);
137
writecrtc(0x38, v->cr38);
139
munmap(v->mmio, S3_NEWMMIO_REGSIZE);
127
145
int yuv_on(int format, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int crop, int xres, int yres, int line_length, int offset) {
128
146
int tmp, pitch, start, src_wc, src_hc, bpp;
131
148
if (format == 0 || format == 7)
140
157
pitch = src_w * bpp;
142
159
// video card memory layout:
143
// 0-n: visable screen memory, n = width * height * bytes per pixel
160
// 0-n: visible screen memory, n = width * height * bytes per pixel
144
161
// n-m: scaler source memory, n is aligned to a page boundary
145
162
// m+: scaler source memory for multiple buffers
151
168
// start is the top left viewable scaler input pixel
152
169
start = offset + crop * pitch + crop * bpp;
157
171
OUTREG(COL_CHROMA_KEY_CONTROL_REG, 0x47000000);
158
172
OUTREG(CHROMA_KEY_UPPER_BOUND_REG, 0x0);
159
173
OUTREG(BLEND_CONTROL_REG, 0x00000020);
191
205
writecrtc(0x93, (pitch + 7) / 8);
193
207
writecrtc(0x67, readcrtc(0x67) | 0x4);
205
213
writecrtc(0x67, readcrtc(0x67) & ~0xc);
206
memset(v.mmio + 0x8180, 0, 0x80);
214
memset(v->mmio + 0x8180, 0, 0x80);
207
215
OUTREG(0x81b8, 0x900);
208
216
OUTREG(0x81bc, 0x900);
209
217
OUTREG(0x81c8, 0x900);
263
270
smem = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
264
271
sreg = fb_finfo.smem_start;
266
if((long)smem == -1) {
273
if(smem == (void *)-1) {
267
274
mp_msg(MSGT_VO, MSGL_FATAL, "s3fb: Couldn't map memory areas: %s\n", strerror(errno));