Mercurial > mplayer.hg
annotate vidix/cyberblade_vid.c @ 36838:7df9dd22f234
Don't set win32 as audio driver if none has been given.
Select from the list of audio drivers instead.
Having win32 as selected item in the combo box although
this isn't used by MPlayer by default is confusing as well.
Besides that, there seem to be issues with this driver
when changing from or to it during playback.
author | ib |
---|---|
date | Tue, 25 Feb 2014 13:16:35 +0000 |
parents | 945eab072c9d |
children | 3c5c93a30fb7 |
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 return ENOSYS; | |
229 } | |
230 | |
231 | |
232 static int frames[VID_PLAY_MAXFRAMES]; | |
233 | |
234 static vidix_grkey_t cyberblade_grkey; | |
235 | |
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
|
236 static int cyberblade_get_gkeys(vidix_grkey_t *grkey) |
22850 | 237 { |
238 memcpy(grkey, &cyberblade_grkey, sizeof(vidix_grkey_t)); | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26719
diff
changeset
|
239 return 0; |
22850 | 240 } |
241 | |
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
|
242 static int cyberblade_set_gkeys(const vidix_grkey_t *grkey) |
22850 | 243 { |
244 int pixfmt=CRINB(0x38); | |
245 int protect; | |
246 memcpy(&cyberblade_grkey, grkey, sizeof(vidix_grkey_t)); | |
247 | |
248 protect=SRINB(0x11); | |
249 SROUTB(0x11, 0x92); | |
250 | |
251 if(pixfmt&0x28) /* 32 or 24 bpp */ | |
252 { | |
253 SROUTB(0x50, cyberblade_grkey.ckey.blue); /* Colour Key */ | |
254 SROUTB(0x51, cyberblade_grkey.ckey.green); /* Colour Key */ | |
255 SROUTB(0x52, cyberblade_grkey.ckey.red); /* Colour Key */ | |
256 SROUTB(0x54, 0xff); /* Colour Key Mask */ | |
257 SROUTB(0x55, 0xff); /* Colour Key Mask */ | |
258 SROUTB(0x56, 0xff); /* Colour Key Mask */ | |
259 } | |
260 else | |
261 { | |
262 int tmp=((cyberblade_grkey.ckey.blue & 0xF8)>>3) | |
263 | ((cyberblade_grkey.ckey.green & 0xfc)<<3) | |
264 | ((cyberblade_grkey.ckey.red & 0xf8)<<8); | |
265 SROUTB(0x50, tmp&0xff); /* Colour Key */ | |
266 SROUTB(0x51, (tmp>>8)&0xff); /* Colour Key */ | |
267 SROUTB(0x52, 0); /* Colour Key */ | |
268 SROUTB(0x54, 0xff); /* Colour Key Mask */ | |
269 SROUTB(0x55, 0xff); /* Colour Key Mask */ | |
270 SROUTB(0x56, 0x00); /* Colour Key Mask */ | |
271 } | |
272 SROUTB(0x11,protect); | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26719
diff
changeset
|
273 return 0; |
22850 | 274 } |
275 | |
276 | |
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
|
277 static vidix_video_eq_t equal = |
22850 | 278 { |
279 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION | VEQ_CAP_HUE, | |
280 300, 100, 0, 0, 0, 0, 0, 0 | |
281 }; | |
282 | |
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
|
283 static int cyberblade_get_eq( vidix_video_eq_t * eq) |
22850 | 284 { |
285 memcpy(eq,&equal,sizeof(vidix_video_eq_t)); | |
286 return 0; | |
287 } | |
288 | |
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
|
289 static int cyberblade_set_eq( const vidix_video_eq_t * eq) |
22850 | 290 { |
291 int br,sat,cr,protect; | |
292 if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness; | |
293 if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast; | |
294 if(eq->cap & VEQ_CAP_SATURATION) equal.saturation = eq->saturation; | |
295 if(eq->cap & VEQ_CAP_HUE) equal.hue = eq->hue; | |
296 if(eq->cap & VEQ_CAP_RGB_INTENSITY) | |
297 { | |
298 equal.red_intensity = eq->red_intensity; | |
299 equal.green_intensity = eq->green_intensity; | |
300 equal.blue_intensity = eq->blue_intensity; | |
301 } | |
302 equal.flags = eq->flags; | |
303 | |
304 cr = (equal.contrast) * 31 / 2000; cr+=16; | |
305 if (cr < 0) cr = 0; if(cr > 7) cr = 7; | |
306 cr=cr<<4 | cr; | |
307 | |
308 br = (equal.brightness+1000) * 63 / 2000; | |
309 if (br < 0) br = 0; if(br > 63) br = 63; | |
310 if(br>32) br-=32; else br+=32; | |
311 | |
312 sat = (equal.saturation + 1000) * 16 / 2000; | |
313 if (sat < 0) sat = 0; if(sat > 31) sat = 31; | |
314 | |
315 protect=SRINB(0x11); | |
316 SROUTB(0x11, 0x92); | |
317 | |
318 SROUTB(0xBC,cr); | |
319 SROUTW(0xB0,(br<<10)|4); | |
320 | |
321 SROUTB(0x11, protect); | |
322 | |
323 return 0; | |
324 } | |
325 | |
326 | |
327 static int YOffs,UOffs,VOffs; | |
328 | |
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
|
329 static int cyberblade_config_playback(vidix_playback_t *info) |
22850 | 330 { |
331 int src_w, drw_w; | |
332 int src_h, drw_h; | |
333 int hscale,vscale; | |
334 long base0; | |
22871 | 335 int y_pitch = 0, uv_pitch = 0; |
22850 | 336 int protect=0; |
337 int layout=0; | |
338 unsigned int i; | |
339 | |
340 if(!is_supported_fourcc(info->fourcc)) | |
341 return -1; | |
342 | |
343 src_w = info->src.w; | |
344 src_h = info->src.h; | |
345 | |
346 drw_w = info->dest.w; | |
347 drw_h = info->dest.h; | |
348 | |
349 switch(info->fourcc) | |
350 { | |
351 case IMGFMT_YUY2: | |
352 case IMGFMT_BGR16: | |
353 y_pitch = (src_w*2 + 15) & ~15; | |
354 uv_pitch = 0; | |
355 YOffs=VOffs=UOffs=info->offset.y = info->offset.v = info->offset.u = 0; | |
356 info->frame_size = y_pitch*src_h; | |
357 layout=0x0; /* packed */ | |
358 break; | |
359 case IMGFMT_YV12: | |
360 case IMGFMT_I420: | |
361 y_pitch = (src_w+15) & ~15; | |
362 uv_pitch = ((src_w/2)+7) & ~7; | |
363 YOffs=info->offset.y = 0; | |
364 VOffs=info->offset.v = y_pitch*src_h; | |
365 UOffs=info->offset.u = info->offset.v+(uv_pitch)*(src_h/2); | |
366 info->frame_size = y_pitch*src_h + 2*uv_pitch*(src_h/2); | |
367 layout=0x1; /* planar, 4:1:1 */ | |
368 break; | |
369 case IMGFMT_YVU9: | |
370 y_pitch = (src_w+15) & ~15; | |
371 uv_pitch = ((src_w/4)+3) & ~3; | |
372 YOffs=info->offset.y = 0; | |
373 VOffs=info->offset.v = y_pitch*src_h; | |
374 UOffs=info->offset.u = info->offset.v+(uv_pitch)*(src_h/4); | |
375 info->frame_size = y_pitch*src_h + 2*uv_pitch*(src_h/4); | |
376 layout=0x51; /* planar, 16:1:1 */ | |
377 break; | |
378 } | |
379 | |
380 /* Assume we have 2 MB to play with */ | |
381 info->num_frames = 0x200000 / info->frame_size; | |
382 if(info->num_frames > VID_PLAY_MAXFRAMES) | |
383 info->num_frames = VID_PLAY_MAXFRAMES; | |
384 | |
385 /* Start at 6 MB. Let's hope it's not in use. */ | |
386 base0 = 0x600000; | |
387 info->dga_addr = cyberblade_mem + base0; | |
388 | |
389 info->dest.pitch.y = 16; | |
390 info->dest.pitch.u = 16; | |
391 info->dest.pitch.v = 16; | |
392 | |
393 for(i = 0; i < info->num_frames; i++) | |
394 { | |
395 info->offsets[i] = info->frame_size * i; | |
396 frames[i] = base0+info->offsets[i]; | |
397 } | |
398 | |
399 OUTPORT8(0x3d4,0x39); | |
400 OUTPORT8(0x3d5,INPORT(0x3d5)|1); | |
401 | |
402 SRINB(0x0b); /* Select new mode */ | |
403 | |
404 /* Unprotect hardware registers... */ | |
405 protect=SRINB(0x11); | |
406 SROUTB(0x11, 0x92); | |
407 | |
408 SROUTB(0x57, 0xc0); /* Playback key function */ | |
409 SROUTB(0x21, 0x34); /* Signature control */ | |
410 SROUTB(0x37, 0x30); /* Video key mode */ | |
411 | |
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
|
412 cyberblade_set_gkeys(&cyberblade_grkey); |
22850 | 413 |
414 /* compute_scale_factor(&src_w, &drw_w, &shrink, &zoom); */ | |
415 { | |
416 int HTotal,VTotal,HSync,VSync,Overflow,HDisp,VDisp; | |
417 int HWinStart,VWinStart; | |
418 int tx1,ty1,tx2,ty2; | |
419 | |
420 HTotal=CRINB(0x00); | |
421 HSync=CRINB(0x04); | |
422 VTotal=CRINB(0x06); | |
423 VSync=CRINB(0x10); | |
424 Overflow=CRINB(0x07); | |
425 HTotal <<=3; | |
426 HSync <<=3; | |
427 VTotal |= (Overflow & 1) <<8; | |
428 VTotal |= (Overflow & 0x20) <<4; | |
429 VTotal +=4; | |
430 VSync |= (Overflow & 4) <<6; | |
431 VSync |= (Overflow & 0x80) <<2; | |
432 | |
433 if(CRINB(0xd1)&0x80) | |
434 { | |
435 int TVHTotal,TVVTotal,TVHSyncStart,TVVSyncStart,TVOverflow; | |
436 LOGWRITE("[cyberblade] Using TV-CRTC\n"); | |
437 | |
438 HDisp=(1+CRINB(0x01))*8; | |
439 VDisp=1+CRINB(0x12); | |
440 Overflow=CRINB(0x07); | |
441 VDisp |= (Overflow & 2) <<7; | |
442 VDisp |= (Overflow & 0x40) << 3; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
443 |
22850 | 444 TVHTotal=CRINB(0xe0)*8; |
445 TVVTotal=CRINB(0xe6); | |
446 TVOverflow=CRINB(0xe7); | |
447 if(TVOverflow&0x20) TVVTotal|=512; | |
448 if(TVOverflow&0x01) TVVTotal|=256; | |
449 TVHTotal+=40; TVVTotal+=2; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
450 |
22850 | 451 TVHSyncStart=CRINB(0xe4)*8; |
452 TVVSyncStart=CRINB(0xf0); | |
453 if(TVOverflow&0x80) TVVSyncStart|=512; | |
454 if(TVOverflow&0x04) TVVSyncStart|=256; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
455 |
22850 | 456 HWinStart=(TVHTotal-HDisp)&15; |
457 HWinStart|=(HTotal-HDisp)&15; | |
458 HWinStart+=(TVHTotal-TVHSyncStart)-49; | |
459 } | |
460 else | |
461 { | |
462 LOGWRITE("[cyberblade] Using Standard CRTC\n"); | |
463 HWinStart=(HTotal-HSync)+15; | |
464 } | |
465 VWinStart=(VTotal-VSync)-8; | |
466 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
467 printf("[cyberblade] HTotal: 0x%x, HSStart: 0x%x\n",HTotal,HSync); |
22850 | 468 printf(" VTotal: 0x%x, VStart: 0x%x\n",VTotal,VSync); |
469 tx1=HWinStart+info->dest.x; | |
470 ty1=VWinStart+info->dest.y; | |
471 tx2=tx1+info->dest.w; | |
472 ty2=ty1+info->dest.h; | |
473 | |
474 CROUTW(0x86,tx1); | |
475 CROUTW(0x88,ty1); | |
476 CROUTW(0x8a,tx2); | |
477 CROUTW(0x8c,ty2+3); | |
478 } | |
479 | |
480 if(src_w==drw_w) | |
481 hscale=0; | |
482 else if(src_w<drw_w) | |
483 { | |
484 hscale=((src_w<<10)/(drw_w-2)) & 0x1fff; | |
485 } | |
486 else | |
487 { | |
488 hscale=0x8000 | ((((src_w/drw_w)-1)&7)<<10) | (((drw_w<<10)/src_w) & 0x3ff); | |
489 } | |
490 | |
491 vscale=(src_h<<10)/(drw_h); | |
492 if(drw_h<src_h) | |
493 vscale=0x8000|((drw_h<<10)/(src_h)); | |
494 | |
495 /* Write scale factors to hardware */ | |
496 | |
497 CROUTW(0x80,hscale); /* Horizontal Scale */ | |
498 CROUTW(0x82,vscale); /* Vertical Scale */ | |
499 | |
500 /* Now set the start address and data layout */ | |
501 { | |
502 int lb = (y_pitch+2) >> 2; | |
503 CROUTB(0x95, ((lb & 0x100)>>1) | 0x08 ); /* Linebuffer level bit 8 & threshold */ | |
504 CROUTB(0x96, (lb & 0xFF)); /* Linebuffer level */ | |
505 | |
506 CROUTB(0x97, 0x00); /* VDE Flags */ | |
507 CROUTB(0xBA, 0x00); /* Chroma key */ | |
508 CROUTB(0xBB, 0x00); /* Chroma key */ | |
509 CROUTB(0xBC, 0xFF); /* Chroma key */ | |
510 CROUTB(0xBD, 0xFF); /* Chroma key */ | |
511 CROUTB(0xBE, 0x04); /* Capture control */ | |
512 | |
513 if(src_w > 384) | |
514 layout|=4; /* 2x line buffers */ | |
515 SROUTB(0x97, layout); | |
516 | |
517 CROUTW(0x90,y_pitch); /* Y Bytes per row */ | |
518 SROUTW(0x9A,uv_pitch); /* UV Bytes per row */ | |
519 | |
520 switch(info->fourcc) | |
521 { | |
522 case IMGFMT_BGR16: | |
523 CROUTB(0x8F, 0x24); /* VDE Flags - Edge Recovery & CSC Bypass */ | |
524 CROUTB(0xBF, 0x02); /* Video format - RGB16 */ | |
525 SROUTB(0xBE, 0x0); /* HSCB disabled */ | |
526 break; | |
527 default: | |
528 CROUTB(0x8F, 0x20); /* VDE Flags - Edge Recovery */ | |
529 CROUTB(0xBF, 0x00); /* Video format - YUV */ | |
530 SROUTB(0xBE, 0x00); /* HSCB disable - was 0x03*/ | |
531 break; | |
532 } | |
533 | |
534 CROUTB(0x92, ((base0+info->offset.y) >> 3) &0xff); /* Lower 8 bits of start address */ | |
535 CROUTB(0x93, ((base0+info->offset.y) >> 11) &0xff); /* Mid 8 bits of start address */ | |
536 CROUTB(0x94, ((base0+info->offset.y) >> 19) &0xf); /* Upper 4 bits of start address */ | |
537 SROUTB(0x80, ((base0+info->offset.v) >> 3) &0xff); /* Lower 8 bits of start address */ | |
538 SROUTB(0x81, ((base0+info->offset.v) >> 11) &0xff); /* Mid 8 bits of start address */ | |
539 SROUTB(0x82, ((base0+info->offset.v) >> 19) &0xf); /* Upper 4 bits of start address */ | |
540 SROUTB(0x83, ((base0+info->offset.u) >> 3) &0xff); /* Lower 8 bits of start address */ | |
541 SROUTB(0x84, ((base0+info->offset.u) >> 11) &0xff); /* Mid 8 bits of start address */ | |
542 SROUTB(0x85, ((base0+info->offset.u) >> 19) &0xf); /* Upper 4 bits of start address */ | |
543 } | |
544 | |
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
|
545 cyberblade_set_eq(&equal); |
22850 | 546 |
547 /* Protect hardware registers again */ | |
548 SROUTB(0x11, protect); | |
549 return 0; | |
550 } | |
551 | |
552 | |
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
|
553 static int cyberblade_playback_on(void) |
22850 | 554 { |
555 LOGWRITE("Enable overlay\n"); | |
556 CROUTB(0x8E, 0xd4); /* VDE Flags*/ | |
557 | |
558 return 0; | |
559 } | |
560 | |
561 | |
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
|
562 static int cyberblade_playback_off(void) |
22850 | 563 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
564 LOGWRITE("Disable overlay\n"); |
22850 | 565 CROUTB(0x8E, 0xc4); /* VDE Flags*/ |
566 | |
567 return 0; | |
568 } | |
569 | |
570 | |
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
|
571 static int cyberblade_frame_sel(unsigned int frame) |
22850 | 572 { |
573 int protect; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27079
diff
changeset
|
574 LOGWRITE("Frame select\n"); |
22850 | 575 protect=SRINB(0x11); |
576 SROUTB(0x11, 0x92); | |
577 /* Set overlay address to that of selected frame */ | |
578 CROUTB(0x92, ((frames[frame]+YOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
579 CROUTB(0x93, ((frames[frame]+YOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
580 CROUTB(0x94, ((frames[frame]+YOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
581 SROUTB(0x80, ((frames[frame]+VOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
582 SROUTB(0x81, ((frames[frame]+VOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
583 SROUTB(0x82, ((frames[frame]+VOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
584 SROUTB(0x83, ((frames[frame]+UOffs) >> 3) &0xff); /* Lower 8 bits of start address */ | |
585 SROUTB(0x84, ((frames[frame]+UOffs) >> 11) &0xff); /* Mid 8 bits of start address */ | |
586 SROUTB(0x85, ((frames[frame]+UOffs) >> 19) &0xf); /* Upper 4 bits of start address */ | |
587 SROUTB(0x11, protect); | |
588 return 0; | |
589 } | |
590 | |
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
|
591 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
|
592 "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
|
593 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
|
594 .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
|
595 .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
|
596 .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
|
597 .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
|
598 .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
|
599 .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
|
600 .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
|
601 .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
|
602 .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
|
603 .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
|
604 .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
|
605 .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
|
606 .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
|
607 }; |