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