Mercurial > mplayer.hg
annotate vidix/cyberblade_vid.c @ 35722:9cfa30063480
configure: Simplify liba52 check through helper functions.
author | diego |
---|---|
date | Mon, 21 Jan 2013 23:05:23 +0000 |
parents | 0f1b5b68af32 |
children | 945eab072c9d |
rev | line source |
---|---|
22850 | 1 /* |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
2 * VIDIX driver for VIA Cyberblade/i1 chipsets. |
26715 | 3 * Brightness/Contrast controls disabled for the time being - they were |
4 * seriously degrading picture quality, especially with TV-Out. | |
5 * | |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
6 * Copyright (C) 2002 Alastair M. Robinson |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
7 * http://www.blackfiveservices.co.uk/EPIAVidix.shtml |
26718
051b2632f121
consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents:
26715
diff
changeset
|
8 * based on Permedia 3 driver by Måns Rullgård |
051b2632f121
consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents:
26715
diff
changeset
|
9 * thanks to Gilles Frattini for bugfixes |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
10 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
11 * This file is part of MPlayer. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
12 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
13 * MPlayer is free software; you can redistribute it and/or modify |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
14 * it under the terms of the GNU General Public License as published by |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
15 * the Free Software Foundation; either version 2 of the License, or |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
16 * (at your option) any later version. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
17 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
18 * MPlayer is distributed in the hope that it will be useful, |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
21 * GNU General Public License for more details. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
22 * |
26719 | 23 * You should have received a copy of the GNU General Public License along |
24 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
26715 | 26 */ |
27 | |
28 /* To Do: | |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
29 * Implement Hue/Saturation controls |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
30 * Support / Test multiple frames |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
31 * Test colour-key code more extensively |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22905
diff
changeset
|
32 */ |
22850 | 33 |
34 #include <errno.h> | |
35 #include <stdio.h> | |
36 #include <stdlib.h> | |
37 #include <string.h> | |
38 #include <inttypes.h> | |
39 #include <unistd.h> | |
40 | |
26203 | 41 #include "config.h" |
22850 | 42 #include "vidix.h" |
43 #include "fourcc.h" | |
22901 | 44 #include "dha.h" |
22900
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
22871
diff
changeset
|
45 #include "pci_ids.h" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
22871
diff
changeset
|
46 #include "pci_names.h" |
22850 | 47 |
48 #include "cyberblade_regs.h" | |
49 | |
23050 | 50 static pciinfo_t pci_info; |
22850 | 51 |
23050 | 52 static char save_colourkey[6]; |
53 static char *cyberblade_mem; | |
22850 | 54 |
55 #ifdef DEBUG_LOGFILE | |
23050 | 56 static FILE *logfile=0; |
22850 | 57 #define LOGWRITE(x) {if(logfile) fprintf(logfile,x);} |
58 #else | |
59 #define LOGWRITE(x) | |
60 #endif | |
61 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
62 /* Helper functions for reading registers. */ |
22850 | 63 |
64 static void CROUTW(int reg,int val) | |
65 { | |
66 CROUTB(reg,val&255); | |
67 CROUTB(reg+1,(val>>8)&255); | |
68 } | |
69 | |
70 static void SROUTW(int reg,int val) | |
71 { | |
72 SROUTB(reg,val&255); | |
73 SROUTB(reg+1,(val>>8)&255); | |
74 } | |
75 | |
76 static vidix_capability_t cyberblade_cap = | |
77 { | |
78 "Trident CyberBlade i1 driver", | |
79 "Alastair M. Robinson <blackfive@fakenhamweb.co.uk>", | |
80 TYPE_OUTPUT, | |
81 { 0, 0, 0, 0 }, | |
82 1024, | |
83 1024, | |
84 4, | |
85 4, | |
86 -1, | |
87 FLAG_UPSCALER|FLAG_DOWNSCALER, | |
88 VENDOR_TRIDENT, | |
89 -1, | |
90 { 0, 0, 0, 0 } | |
91 }; | |
92 | |
93 static unsigned short cyberblade_card_ids[] = | |
94 { | |
95 DEVICE_TRIDENT_CYBERBLADE_I7, | |
96 DEVICE_TRIDENT_CYBERBLADE_I7D, | |
97 DEVICE_TRIDENT_CYBERBLADE_I1, | |
98 DEVICE_TRIDENT_CYBERBLADE_I12, | |
99 DEVICE_TRIDENT_CYBERBLADE_I13, | |
100 DEVICE_TRIDENT_CYBERBLADE_XPAI1 | |
101 }; | |
102 | |
103 | |
104 static int find_chip(unsigned chip_id) | |
105 { | |
106 unsigned i; | |
107 for(i = 0;i < sizeof(cyberblade_card_ids)/sizeof(unsigned short);i++) | |
108 { | |
109 if(chip_id == cyberblade_card_ids[i]) return i; | |
110 } | |
111 return -1; | |
112 } | |
113 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
114 static int cyberblade_probe(int verbose, int force) |
22850 | 115 { |
116 pciinfo_t lst[MAX_PCI_DEVICES]; | |
117 unsigned i,num_pci; | |
118 int err; | |
119 err = pci_scan(lst,&num_pci); | |
120 if(err) | |
121 { | |
122 printf("[cyberblade] Error occurred during pci scan: %s\n",strerror(err)); | |
123 return err; | |
124 } | |
125 else | |
126 { | |
127 err = ENXIO; | |
128 for(i=0; i < num_pci; i++) | |
129 { | |
130 if(lst[i].vendor == VENDOR_TRIDENT) | |
131 { | |
132 int idx; | |
133 const char *dname; | |
134 idx = find_chip(lst[i].device); | |
135 if(idx == -1) | |
136 continue; | |
137 dname = pci_device_name(VENDOR_TRIDENT, lst[i].device); | |
138 dname = dname ? dname : "Unknown chip"; | |
139 printf("[cyberblade] Found chip: %s\n", dname); | |
23167
2ab3eac7f6da
synced with upstream vidix, prevented some drivers to work on some configs/archs
ben
parents:
23052
diff
changeset
|
140 #if 0 |
2ab3eac7f6da
synced with upstream vidix, prevented some drivers to work on some configs/archs
ben
parents:
23052
diff
changeset
|
141 if ((lst[i].command & PCI_COMMAND_IO) == 0) |
22850 | 142 { |
143 printf("[cyberblade] Device is disabled, ignoring\n"); | |
144 continue; | |
145 } | |
23167
2ab3eac7f6da
synced with upstream vidix, prevented some drivers to work on some configs/archs
ben
parents:
23052
diff
changeset
|
146 #endif |
22850 | 147 cyberblade_cap.device_id = lst[i].device; |
148 err = 0; | |
149 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t)); | |
150 break; | |
151 } | |
152 } | |
153 } | |
154 | |
155 if(err && verbose) printf("[cyberblade] Can't find chip\n"); | |
156 return err; | |
157 } | |
158 | |
159 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
160 static int cyberblade_init(void) |
22850 | 161 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
162 cyberblade_mem = map_phys_mem(pci_info.base0, 0x800000); |
22850 | 163 enable_app_io(); |
164 save_colourkey[0]=SRINB(0x50); | |
165 save_colourkey[1]=SRINB(0x51); | |
166 save_colourkey[2]=SRINB(0x52); | |
167 save_colourkey[3]=SRINB(0x54); | |
168 save_colourkey[4]=SRINB(0x55); | |
169 save_colourkey[5]=SRINB(0x56); | |
170 #ifdef DEBUG_LOGFILE | |
171 logfile=fopen("/tmp/cyberblade_vidix.log","w"); | |
172 #endif | |
173 return 0; | |
174 } | |
175 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
176 static void cyberblade_destroy(void) |
22850 | 177 { |
178 int protect; | |
179 #ifdef DEBUG_LOGFILE | |
180 if(logfile) | |
181 fclose(logfile); | |
182 #endif | |
183 protect=SRINB(0x11); | |
184 SROUTB(0x11, 0x92); | |
185 CROUTB(0x8E, 0xc4); /* Disable overlay */ | |
186 SROUTB(0x50,save_colourkey[0]); | |
187 SROUTB(0x51,save_colourkey[1]); | |
188 SROUTB(0x52,save_colourkey[2]); | |
189 SROUTB(0x54,save_colourkey[3]); | |
190 SROUTB(0x55,save_colourkey[4]); | |
191 SROUTB(0x56,save_colourkey[5]); | |
192 SROUTB(0x11, protect); | |
193 disable_app_io(); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
194 unmap_phys_mem(cyberblade_mem, 0x800000); |
22850 | 195 } |
196 | |
197 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
198 static int cyberblade_get_caps(vidix_capability_t *to) |
22850 | 199 { |
200 memcpy(to, &cyberblade_cap, sizeof(vidix_capability_t)); | |
201 return 0; | |
202 } | |
203 | |
204 | |
205 static int is_supported_fourcc(uint32_t fourcc) | |
206 { | |
207 switch(fourcc) | |
208 { | |
209 case IMGFMT_YUY2: | |
210 case IMGFMT_YV12: | |
211 case IMGFMT_I420: | |
212 case IMGFMT_YVU9: | |
213 case IMGFMT_BGR16: | |
214 return 1; | |
215 default: | |
216 return 0; | |
217 } | |
218 } | |
219 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
220 static int cyberblade_query_fourcc(vidix_fourcc_t *to) |
22850 | 221 { |
222 if(is_supported_fourcc(to->fourcc)) | |
223 { | |
23049 | 224 to->depth = VID_DEPTH_ALL; |
22850 | 225 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; |
226 return 0; | |
227 } | |
228 to->depth = to->flags = 0; | |
229 return ENOSYS; | |
230 } | |
231 | |
232 | |
233 static int frames[VID_PLAY_MAXFRAMES]; | |
234 | |
235 static vidix_grkey_t cyberblade_grkey; | |
236 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
237 static int cyberblade_get_gkeys(vidix_grkey_t *grkey) |
22850 | 238 { |
239 memcpy(grkey, &cyberblade_grkey, sizeof(vidix_grkey_t)); | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26719
diff
changeset
|
240 return 0; |
22850 | 241 } |
242 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
243 static int cyberblade_set_gkeys(const vidix_grkey_t *grkey) |
22850 | 244 { |
245 int pixfmt=CRINB(0x38); | |
246 int protect; | |
247 memcpy(&cyberblade_grkey, grkey, sizeof(vidix_grkey_t)); | |
248 | |
249 protect=SRINB(0x11); | |
250 SROUTB(0x11, 0x92); | |
251 | |
252 if(pixfmt&0x28) /* 32 or 24 bpp */ | |
253 { | |
254 SROUTB(0x50, cyberblade_grkey.ckey.blue); /* Colour Key */ | |
255 SROUTB(0x51, cyberblade_grkey.ckey.green); /* Colour Key */ | |
256 SROUTB(0x52, cyberblade_grkey.ckey.red); /* Colour Key */ | |
257 SROUTB(0x54, 0xff); /* Colour Key Mask */ | |
258 SROUTB(0x55, 0xff); /* Colour Key Mask */ | |
259 SROUTB(0x56, 0xff); /* Colour Key Mask */ | |
260 } | |
261 else | |
262 { | |
263 int tmp=((cyberblade_grkey.ckey.blue & 0xF8)>>3) | |
264 | ((cyberblade_grkey.ckey.green & 0xfc)<<3) | |
265 | ((cyberblade_grkey.ckey.red & 0xf8)<<8); | |
266 SROUTB(0x50, tmp&0xff); /* Colour Key */ | |
267 SROUTB(0x51, (tmp>>8)&0xff); /* Colour Key */ | |
268 SROUTB(0x52, 0); /* Colour Key */ | |
269 SROUTB(0x54, 0xff); /* Colour Key Mask */ | |
270 SROUTB(0x55, 0xff); /* Colour Key Mask */ | |
271 SROUTB(0x56, 0x00); /* Colour Key Mask */ | |
272 } | |
273 SROUTB(0x11,protect); | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26719
diff
changeset
|
274 return 0; |
22850 | 275 } |
276 | |
277 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
278 static vidix_video_eq_t equal = |
22850 | 279 { |
280 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION | VEQ_CAP_HUE, | |
281 300, 100, 0, 0, 0, 0, 0, 0 | |
282 }; | |
283 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
284 static int cyberblade_get_eq( vidix_video_eq_t * eq) |
22850 | 285 { |
286 memcpy(eq,&equal,sizeof(vidix_video_eq_t)); | |
287 return 0; | |
288 } | |
289 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
290 static int cyberblade_set_eq( const vidix_video_eq_t * eq) |
22850 | 291 { |
292 int br,sat,cr,protect; | |
293 if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness; | |
294 if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast; | |
295 if(eq->cap & VEQ_CAP_SATURATION) equal.saturation = eq->saturation; | |
296 if(eq->cap & VEQ_CAP_HUE) equal.hue = eq->hue; | |
297 if(eq->cap & VEQ_CAP_RGB_INTENSITY) | |
298 { | |
299 equal.red_intensity = eq->red_intensity; | |
300 equal.green_intensity = eq->green_intensity; | |
301 equal.blue_intensity = eq->blue_intensity; | |
302 } | |
303 equal.flags = eq->flags; | |
304 | |
305 cr = (equal.contrast) * 31 / 2000; cr+=16; | |
306 if (cr < 0) cr = 0; if(cr > 7) cr = 7; | |
307 cr=cr<<4 | cr; | |
308 | |
309 br = (equal.brightness+1000) * 63 / 2000; | |
310 if (br < 0) br = 0; if(br > 63) br = 63; | |
311 if(br>32) br-=32; else br+=32; | |
312 | |
313 sat = (equal.saturation + 1000) * 16 / 2000; | |
314 if (sat < 0) sat = 0; if(sat > 31) sat = 31; | |
315 | |
316 protect=SRINB(0x11); | |
317 SROUTB(0x11, 0x92); | |
318 | |
319 SROUTB(0xBC,cr); | |
320 SROUTW(0xB0,(br<<10)|4); | |
321 | |
322 SROUTB(0x11, protect); | |
323 | |
324 return 0; | |
325 } | |
326 | |
327 | |
328 static int YOffs,UOffs,VOffs; | |
329 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
330 static int cyberblade_config_playback(vidix_playback_t *info) |
22850 | 331 { |
332 int src_w, drw_w; | |
333 int src_h, drw_h; | |
334 int hscale,vscale; | |
335 long base0; | |
22871 | 336 int y_pitch = 0, uv_pitch = 0; |
22850 | 337 int protect=0; |
338 int layout=0; | |
339 unsigned int i; | |
340 | |
341 if(!is_supported_fourcc(info->fourcc)) | |
342 return -1; | |
343 | |
344 src_w = info->src.w; | |
345 src_h = info->src.h; | |
346 | |
347 drw_w = info->dest.w; | |
348 drw_h = info->dest.h; | |
349 | |
350 switch(info->fourcc) | |
351 { | |
352 case IMGFMT_YUY2: | |
353 case IMGFMT_BGR16: | |
354 y_pitch = (src_w*2 + 15) & ~15; | |
355 uv_pitch = 0; | |
356 YOffs=VOffs=UOffs=info->offset.y = info->offset.v = info->offset.u = 0; | |
357 info->frame_size = y_pitch*src_h; | |
358 layout=0x0; /* packed */ | |
359 break; | |
360 case IMGFMT_YV12: | |
361 case IMGFMT_I420: | |
362 y_pitch = (src_w+15) & ~15; | |
363 uv_pitch = ((src_w/2)+7) & ~7; | |
364 YOffs=info->offset.y = 0; | |
365 VOffs=info->offset.v = y_pitch*src_h; | |
366 UOffs=info->offset.u = info->offset.v+(uv_pitch)*(src_h/2); | |
367 info->frame_size = y_pitch*src_h + 2*uv_pitch*(src_h/2); | |
368 layout=0x1; /* planar, 4:1:1 */ | |
369 break; | |
370 case IMGFMT_YVU9: | |
371 y_pitch = (src_w+15) & ~15; | |
372 uv_pitch = ((src_w/4)+3) & ~3; | |
373 YOffs=info->offset.y = 0; | |
374 VOffs=info->offset.v = y_pitch*src_h; | |
375 UOffs=info->offset.u = info->offset.v+(uv_pitch)*(src_h/4); | |
376 info->frame_size = y_pitch*src_h + 2*uv_pitch*(src_h/4); | |
377 layout=0x51; /* planar, 16:1:1 */ | |
378 break; | |
379 } | |
380 | |
381 /* Assume we have 2 MB to play with */ | |
382 info->num_frames = 0x200000 / info->frame_size; | |
383 if(info->num_frames > VID_PLAY_MAXFRAMES) | |
384 info->num_frames = VID_PLAY_MAXFRAMES; | |
385 | |
386 /* Start at 6 MB. Let's hope it's not in use. */ | |
387 base0 = 0x600000; | |
388 info->dga_addr = cyberblade_mem + base0; | |
389 | |
390 info->dest.pitch.y = 16; | |
391 info->dest.pitch.u = 16; | |
392 info->dest.pitch.v = 16; | |
393 | |
394 for(i = 0; i < info->num_frames; i++) | |
395 { | |
396 info->offsets[i] = info->frame_size * i; | |
397 frames[i] = base0+info->offsets[i]; | |
398 } | |
399 | |
400 OUTPORT8(0x3d4,0x39); | |
401 OUTPORT8(0x3d5,INPORT(0x3d5)|1); | |
402 | |
403 SRINB(0x0b); /* Select new mode */ | |
404 | |
405 /* Unprotect hardware registers... */ | |
406 protect=SRINB(0x11); | |
407 SROUTB(0x11, 0x92); | |
408 | |
409 SROUTB(0x57, 0xc0); /* Playback key function */ | |
410 SROUTB(0x21, 0x34); /* Signature control */ | |
411 SROUTB(0x37, 0x30); /* Video key mode */ | |
412 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
413 cyberblade_set_gkeys(&cyberblade_grkey); |
22850 | 414 |
415 /* compute_scale_factor(&src_w, &drw_w, &shrink, &zoom); */ | |
416 { | |
417 int HTotal,VTotal,HSync,VSync,Overflow,HDisp,VDisp; | |
418 int HWinStart,VWinStart; | |
419 int tx1,ty1,tx2,ty2; | |
420 | |
421 HTotal=CRINB(0x00); | |
422 HSync=CRINB(0x04); | |
423 VTotal=CRINB(0x06); | |
424 VSync=CRINB(0x10); | |
425 Overflow=CRINB(0x07); | |
426 HTotal <<=3; | |
427 HSync <<=3; | |
428 VTotal |= (Overflow & 1) <<8; | |
429 VTotal |= (Overflow & 0x20) <<4; | |
430 VTotal +=4; | |
431 VSync |= (Overflow & 4) <<6; | |
432 VSync |= (Overflow & 0x80) <<2; | |
433 | |
434 if(CRINB(0xd1)&0x80) | |
435 { | |
436 int TVHTotal,TVVTotal,TVHSyncStart,TVVSyncStart,TVOverflow; | |
437 LOGWRITE("[cyberblade] Using TV-CRTC\n"); | |
438 | |
439 HDisp=(1+CRINB(0x01))*8; | |
440 VDisp=1+CRINB(0x12); | |
441 Overflow=CRINB(0x07); | |
442 VDisp |= (Overflow & 2) <<7; | |
443 VDisp |= (Overflow & 0x40) << 3; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
444 |
22850 | 445 TVHTotal=CRINB(0xe0)*8; |
446 TVVTotal=CRINB(0xe6); | |
447 TVOverflow=CRINB(0xe7); | |
448 if(TVOverflow&0x20) TVVTotal|=512; | |
449 if(TVOverflow&0x01) TVVTotal|=256; | |
450 TVHTotal+=40; TVVTotal+=2; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
451 |
22850 | 452 TVHSyncStart=CRINB(0xe4)*8; |
453 TVVSyncStart=CRINB(0xf0); | |
454 if(TVOverflow&0x80) TVVSyncStart|=512; | |
455 if(TVOverflow&0x04) TVVSyncStart|=256; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
456 |
22850 | 457 HWinStart=(TVHTotal-HDisp)&15; |
458 HWinStart|=(HTotal-HDisp)&15; | |
459 HWinStart+=(TVHTotal-TVHSyncStart)-49; | |
460 } | |
461 else | |
462 { | |
463 LOGWRITE("[cyberblade] Using Standard CRTC\n"); | |
464 HWinStart=(HTotal-HSync)+15; | |
465 } | |
466 VWinStart=(VTotal-VSync)-8; | |
467 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
468 printf("[cyberblade] HTotal: 0x%x, HSStart: 0x%x\n",HTotal,HSync); |
22850 | 469 printf(" VTotal: 0x%x, VStart: 0x%x\n",VTotal,VSync); |
470 tx1=HWinStart+info->dest.x; | |
471 ty1=VWinStart+info->dest.y; | |
472 tx2=tx1+info->dest.w; | |
473 ty2=ty1+info->dest.h; | |
474 | |
475 CROUTW(0x86,tx1); | |
476 CROUTW(0x88,ty1); | |
477 CROUTW(0x8a,tx2); | |
478 CROUTW(0x8c,ty2+3); | |
479 } | |
480 | |
481 if(src_w==drw_w) | |
482 hscale=0; | |
483 else if(src_w<drw_w) | |
484 { | |
485 hscale=((src_w<<10)/(drw_w-2)) & 0x1fff; | |
486 } | |
487 else | |
488 { | |
489 hscale=0x8000 | ((((src_w/drw_w)-1)&7)<<10) | (((drw_w<<10)/src_w) & 0x3ff); | |
490 } | |
491 | |
492 vscale=(src_h<<10)/(drw_h); | |
493 if(drw_h<src_h) | |
494 vscale=0x8000|((drw_h<<10)/(src_h)); | |
495 | |
496 /* Write scale factors to hardware */ | |
497 | |
498 CROUTW(0x80,hscale); /* Horizontal Scale */ | |
499 CROUTW(0x82,vscale); /* Vertical Scale */ | |
500 | |
501 /* Now set the start address and data layout */ | |
502 { | |
503 int lb = (y_pitch+2) >> 2; | |
504 CROUTB(0x95, ((lb & 0x100)>>1) | 0x08 ); /* Linebuffer level bit 8 & threshold */ | |
505 CROUTB(0x96, (lb & 0xFF)); /* Linebuffer level */ | |
506 | |
507 CROUTB(0x97, 0x00); /* VDE Flags */ | |
508 CROUTB(0xBA, 0x00); /* Chroma key */ | |
509 CROUTB(0xBB, 0x00); /* Chroma key */ | |
510 CROUTB(0xBC, 0xFF); /* Chroma key */ | |
511 CROUTB(0xBD, 0xFF); /* Chroma key */ | |
512 CROUTB(0xBE, 0x04); /* Capture control */ | |
513 | |
514 if(src_w > 384) | |
515 layout|=4; /* 2x line buffers */ | |
516 SROUTB(0x97, layout); | |
517 | |
518 CROUTW(0x90,y_pitch); /* Y Bytes per row */ | |
519 SROUTW(0x9A,uv_pitch); /* UV Bytes per row */ | |
520 | |
521 switch(info->fourcc) | |
522 { | |
523 case IMGFMT_BGR16: | |
524 CROUTB(0x8F, 0x24); /* VDE Flags - Edge Recovery & CSC Bypass */ | |
525 CROUTB(0xBF, 0x02); /* Video format - RGB16 */ | |
526 SROUTB(0xBE, 0x0); /* HSCB disabled */ | |
527 break; | |
528 default: | |
529 CROUTB(0x8F, 0x20); /* VDE Flags - Edge Recovery */ | |
530 CROUTB(0xBF, 0x00); /* Video format - YUV */ | |
531 SROUTB(0xBE, 0x00); /* HSCB disable - was 0x03*/ | |
532 break; | |
533 } | |
534 | |
535 CROUTB(0x92, ((base0+info->offset.y) >> 3) &0xff); /* Lower 8 bits of start address */ | |
536 CROUTB(0x93, ((base0+info->offset.y) >> 11) &0xff); /* Mid 8 bits of start address */ | |
537 CROUTB(0x94, ((base0+info->offset.y) >> 19) &0xf); /* Upper 4 bits of start address */ | |
538 SROUTB(0x80, ((base0+info->offset.v) >> 3) &0xff); /* Lower 8 bits of start address */ | |
539 SROUTB(0x81, ((base0+info->offset.v) >> 11) &0xff); /* Mid 8 bits of start address */ | |
540 SROUTB(0x82, ((base0+info->offset.v) >> 19) &0xf); /* Upper 4 bits of start address */ | |
541 SROUTB(0x83, ((base0+info->offset.u) >> 3) &0xff); /* Lower 8 bits of start address */ | |
542 SROUTB(0x84, ((base0+info->offset.u) >> 11) &0xff); /* Mid 8 bits of start address */ | |
543 SROUTB(0x85, ((base0+info->offset.u) >> 19) &0xf); /* Upper 4 bits of start address */ | |
544 } | |
545 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
546 cyberblade_set_eq(&equal); |
22850 | 547 |
548 /* Protect hardware registers again */ | |
549 SROUTB(0x11, protect); | |
550 return 0; | |
551 } | |
552 | |
553 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
554 static int cyberblade_playback_on(void) |
22850 | 555 { |
556 LOGWRITE("Enable overlay\n"); | |
557 CROUTB(0x8E, 0xd4); /* VDE Flags*/ | |
558 | |
559 return 0; | |
560 } | |
561 | |
562 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
563 static int cyberblade_playback_off(void) |
22850 | 564 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
565 LOGWRITE("Disable overlay\n"); |
22850 | 566 CROUTB(0x8E, 0xc4); /* VDE Flags*/ |
567 | |
568 return 0; | |
569 } | |
570 | |
571 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
572 static int cyberblade_frame_sel(unsigned int frame) |
22850 | 573 { |
574 int protect; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
575 LOGWRITE("Frame select\n"); |
22850 | 576 protect=SRINB(0x11); |
577 SROUTB(0x11, 0x92); | |
578 /* Set overlay address to that of selected frame */ | |
579 CROUTB(0x92, ((frames[frame]+YOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
580 CROUTB(0x93, ((frames[frame]+YOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
581 CROUTB(0x94, ((frames[frame]+YOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
582 SROUTB(0x80, ((frames[frame]+VOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
583 SROUTB(0x81, ((frames[frame]+VOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
584 SROUTB(0x82, ((frames[frame]+VOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
585 SROUTB(0x83, ((frames[frame]+UOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
586 SROUTB(0x84, ((frames[frame]+UOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
587 SROUTB(0x85, ((frames[frame]+UOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
588 SROUTB(0x11, protect); | |
589 return 0; | |
590 } | |
591 | |
22857
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
592 VDXDriver cyberblade_drv = { |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
593 "cyberblade", |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
594 NULL, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
595 .probe = cyberblade_probe, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
596 .get_caps = cyberblade_get_caps, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
597 .query_fourcc = cyberblade_query_fourcc, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
598 .init = cyberblade_init, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
599 .destroy = cyberblade_destroy, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
600 .config_playback = cyberblade_config_playback, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
601 .playback_on = cyberblade_playback_on, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
602 .playback_off = cyberblade_playback_off, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
603 .frame_sel = cyberblade_frame_sel, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
604 .get_eq = cyberblade_get_eq, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
605 .set_eq = cyberblade_set_eq, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
606 .get_gkey = cyberblade_get_gkeys, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
607 .set_gkey = cyberblade_set_gkeys, |
77def5093daf
switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents:
22850
diff
changeset
|
608 }; |