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