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