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