Mercurial > mplayer.hg
annotate vidix/drivers/nvidia_vid.c @ 11783:c2e36b3193a1
Fix "panning" display
Ease multibuffer.
Cosmetics.
author | lumag |
---|---|
date | Mon, 12 Jan 2004 13:43:30 +0000 |
parents | 972d1998bde9 |
children | d9489d5581d0 |
rev | line source |
---|---|
10954 | 1 /* |
2 nvidia_vid - VIDIX based video driver for NVIDIA chips | |
3 Copyrights 2003 Sascha Sommer. This file is based on sources from | |
4 RIVATV (rivatv.sf.net) | |
5 Licence: GPL | |
11159 | 6 WARNING: THIS DRIVER IS IN BETA STAGE |
10954 | 7 |
11086 | 8 multi buffer support and TNT2 fixes by Dmitry Baryshkov |
10954 | 9 */ |
10 | |
11 | |
12 #include <errno.h> | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 #include <string.h> | |
16 #include <inttypes.h> | |
17 #include <unistd.h> | |
18 | |
19 | |
20 #include "../vidix.h" | |
21 #include "../fourcc.h" | |
22 #include "../../libdha/libdha.h" | |
23 #include "../../libdha/pci_ids.h" | |
24 #include "../../libdha/pci_names.h" | |
25 #include "../../config.h" | |
26 #include "../../bswap.h" | |
27 | |
28 | |
29 pciinfo_t pci_info; | |
30 | |
31 | |
32 #define MAX_FRAMES 3 | |
33 #define NV04_BES_SIZE 1024*2000*4 | |
34 | |
35 | |
36 static vidix_capability_t nvidia_cap = { | |
37 "NVIDIA RIVA OVERLAY DRIVER", | |
38 "Sascha Sommer <saschasommer@freenet.de>", | |
39 TYPE_OUTPUT, | |
40 { 0, 0, 0, 0 }, | |
10957
4d4d0c1c7142
according to xfree cvs maximum overlay size is only 2046x2046
atmos4
parents:
10954
diff
changeset
|
41 2046, |
4d4d0c1c7142
according to xfree cvs maximum overlay size is only 2046x2046
atmos4
parents:
10954
diff
changeset
|
42 2046, |
10954 | 43 4, |
44 4, | |
45 -1, | |
46 FLAG_UPSCALER|FLAG_DOWNSCALER, | |
47 VENDOR_NVIDIA2, | |
48 -1, | |
49 { 0, 0, 0, 0 } | |
50 }; | |
51 | |
52 | |
53 unsigned int vixGetVersion(void){ | |
54 return(VIDIX_VERSION); | |
55 } | |
56 | |
57 | |
58 #define NV_ARCH_03 0x03 | |
59 #define NV_ARCH_04 0x04 | |
60 #define NV_ARCH_10 0x10 | |
61 #define NV_ARCH_20 0x20 | |
62 #define NV_ARCH_30 0x30 | |
63 | |
64 struct nvidia_cards { | |
65 unsigned short chip_id; | |
66 unsigned short arch; | |
67 }; | |
68 | |
69 | |
70 static struct nvidia_cards nvidia_card_ids[] = { | |
11073 | 71 /*NV03*/ |
10954 | 72 {DEVICE_NVIDIA2_RIVA128, NV_ARCH_03}, |
11073 | 73 {DEVICE_NVIDIA2_RIVA128ZX,NV_ARCH_03}, |
74 /*NV04*/ | |
75 {DEVICE_NVIDIA_NV4_RIVA_TNT,NV_ARCH_04}, | |
76 {DEVICE_NVIDIA_NV5_RIVA_TNT2,NV_ARCH_04}, | |
77 {DEVICE_NVIDIA_NV5_RIVA_TNT22,NV_ARCH_04}, | |
78 {DEVICE_NVIDIA_NV5_RIVA_TNT23,NV_ARCH_04}, | |
79 {DEVICE_NVIDIA_NV5_RIVA_TNT24,NV_ARCH_04}, | |
80 {DEVICE_NVIDIA_NV6_VANTA,NV_ARCH_04}, | |
10954 | 81 {DEVICE_NVIDIA_RIVA_TNT2_MODEL,NV_ARCH_04}, |
11073 | 82 {DEVICE_NVIDIA_NV6_VANTA2,NV_ARCH_04}, |
83 {DEVICE_NVIDIA_NV6_VANTA3,NV_ARCH_04}, | |
84 {DEVICE_NVIDIA_NV5_RIVA_TNT25,NV_ARCH_04}, | |
10954 | 85 {DEVICE_NVIDIA2_TNT,NV_ARCH_04}, |
11073 | 86 {DEVICE_NVIDIA2_TNT2,NV_ARCH_04}, |
87 {DEVICE_NVIDIA2_VTNT2,NV_ARCH_04}, | |
10954 | 88 {DEVICE_NVIDIA2_UTNT2 ,NV_ARCH_04}, |
89 {DEVICE_NVIDIA2_ITNT2,NV_ARCH_04}, | |
11073 | 90 /*NV10*/ |
91 {DEVICE_NVIDIA_NV10_GEFORCE_256,NV_ARCH_10}, | |
92 {DEVICE_NVIDIA_NV10_GEFORCE_2562,NV_ARCH_10}, | |
93 {DEVICE_NVIDIA_NV11_GEFORCE2_MX,NV_ARCH_10}, | |
94 {DEVICE_NVIDIA_NV11_GEFORCE2_MX2,NV_ARCH_10}, | |
95 {DEVICE_NVIDIA_NV11_GEFORCE2_GO,NV_ARCH_10}, | |
96 {DEVICE_NVIDIA_NV11_GEFORCE2_MXR ,NV_ARCH_10}, | |
97 {DEVICE_NVIDIA_NV15_GEFORCE2_GTS,NV_ARCH_10}, | |
98 {DEVICE_NVIDIA_NV15_GEFORCE2_TI,NV_ARCH_10}, | |
99 {DEVICE_NVIDIA_NV15_GEFORCE2_ULTRA,NV_ARCH_10}, | |
100 {DEVICE_NVIDIA_NV17_GEFORCE4_MX460,NV_ARCH_10}, | |
101 {DEVICE_NVIDIA_NV17_GEFORCE4_MX440,NV_ARCH_10}, | |
102 {DEVICE_NVIDIA_NV17_GEFORCE4_MX420,NV_ARCH_10}, | |
103 {DEVICE_NVIDIA_NV17_GEFORCE4_440,NV_ARCH_10}, | |
104 {DEVICE_NVIDIA_NV17_GEFORCE4_420,NV_ARCH_10}, | |
105 {DEVICE_NVIDIA_NV17_GEFORCE4_4202,NV_ARCH_10}, | |
106 {DEVICE_NVIDIA_NV17_GEFORCE4_4402,NV_ARCH_10}, | |
107 {DEVICE_NVIDIA_NV18_GEFORCE4_MX440,NV_ARCH_10}, | |
108 {DEVICE_NVIDIA_NV15_GEFORCE2,NV_ARCH_10}, | |
109 /*NV20*/ | |
110 {DEVICE_NVIDIA_NV20_GEFORCE3,NV_ARCH_20}, | |
111 {DEVICE_NVIDIA_NV20_GEFORCE3_TI200,NV_ARCH_20}, | |
112 {DEVICE_NVIDIA_NV20_GEFORCE3_TI500,NV_ARCH_20}, | |
113 {DEVICE_NVIDIA_NV25_GEFORCE4_TI4600,NV_ARCH_20}, | |
114 {DEVICE_NVIDIA_NV25_GEFORCE4_TI4400,NV_ARCH_20}, | |
115 {DEVICE_NVIDIA_NV25_GEFORCE4_TI4200,NV_ARCH_20}, | |
10954 | 116 }; |
117 | |
118 | |
119 static int find_chip(unsigned chip_id){ | |
120 unsigned i; | |
121 for(i = 0;i < sizeof(nvidia_card_ids)/sizeof(struct nvidia_cards);i++) | |
122 { | |
123 if(chip_id == nvidia_card_ids[i].chip_id)return i; | |
124 } | |
125 return -1; | |
126 } | |
127 | |
128 int vixProbe(int verbose, int force){ | |
129 pciinfo_t lst[MAX_PCI_DEVICES]; | |
130 unsigned i,num_pci; | |
131 int err; | |
132 | |
133 if (force) | |
134 printf("[nvidia_vid]: warning: forcing not supported yet!\n"); | |
135 err = pci_scan(lst,&num_pci); | |
136 if(err){ | |
11678
972d1998bde9
occured --> occurred typo patch by Clinton Roy <croy@dstc.edu.au>
diego
parents:
11233
diff
changeset
|
137 printf("[nvidia_vid] Error occurred during pci scan: %s\n",strerror(err)); |
10954 | 138 return err; |
139 } | |
140 else { | |
141 err = ENXIO; | |
142 for(i=0; i < num_pci; i++){ | |
143 if(lst[i].vendor == VENDOR_NVIDIA2 || lst[i].vendor == VENDOR_NVIDIA){ | |
144 int idx; | |
145 const char *dname; | |
146 idx = find_chip(lst[i].device); | |
147 if(idx == -1) | |
148 continue; | |
149 dname = pci_device_name(lst[i].vendor, lst[i].device); | |
150 dname = dname ? dname : "Unknown chip"; | |
151 printf("[nvidia_vid] Found chip: %s\n", dname); | |
152 if ((lst[i].command & PCI_COMMAND_IO) == 0){ | |
153 printf("[nvidia_vid] Device is disabled, ignoring\n"); | |
154 continue; | |
155 } | |
156 nvidia_cap.device_id = lst[i].device; | |
157 err = 0; | |
158 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t)); | |
159 break; | |
160 } | |
161 } | |
162 } | |
163 if(err && verbose) printf("[nvidia_vid] Can't find chip\n"); | |
164 return err; | |
165 } | |
166 | |
167 | |
168 | |
169 | |
170 /* | |
171 * PCI-Memory IO access macros. | |
172 */ | |
173 #define VID_WR08(p,i,val) (((uint8_t *)(p))[(i)]=(val)) | |
174 #define VID_RD08(p,i) (((uint8_t *)(p))[(i)]) | |
175 | |
176 #define VID_WR32(p,i,val) (((uint32_t *)(p))[(i)/4]=(val)) | |
177 #define VID_RD32(p,i) (((uint32_t *)(p))[(i)/4]) | |
178 | |
179 #ifndef USE_RMW_CYCLES | |
180 /* | |
181 * Can be used to inhibit READ-MODIFY-WRITE cycles. On by default. | |
182 */ | |
183 | |
184 #define MEM_BARRIER() __asm__ __volatile__ ("" : : : "memory") | |
185 | |
186 #undef VID_WR08 | |
187 #define VID_WR08(p,i,val) ({ MEM_BARRIER(); ((uint8_t *)(p))[(i)]=(val); }) | |
188 #undef VID_RD08 | |
189 #define VID_RD08(p,i) ({ MEM_BARRIER(); ((uint8_t *)(p))[(i)]; }) | |
190 | |
191 #undef VID_WR32 | |
192 #define VID_WR32(p,i,val) ({ MEM_BARRIER(); ((uint32_t *)(p))[(i)/4]=(val); }) | |
193 #undef VID_RD32 | |
194 #define VID_RD32(p,i) ({ MEM_BARRIER(); ((uint32_t *)(p))[(i)/4]; }) | |
195 #endif /* USE_RMW_CYCLES */ | |
196 | |
197 #define VID_AND32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)&(val)) | |
198 #define VID_OR32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)|(val)) | |
199 #define VID_XOR32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)^(val)) | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 struct rivatv_chip { | |
207 volatile uint32_t *PMC; /* general control */ | |
208 volatile uint32_t *PME; /* multimedia port */ | |
209 volatile uint32_t *PFB; /* framebuffer control */ | |
210 volatile uint32_t *PVIDEO; /* overlay control */ | |
211 volatile uint8_t *PCIO; /* SVGA (CRTC, ATTR) registers */ | |
212 volatile uint8_t *PVIO; /* SVGA (MISC, GRAPH, SEQ) registers */ | |
213 volatile uint32_t *PRAMIN; /* instance memory */ | |
214 volatile uint32_t *PRAMHT; /* hash table */ | |
215 volatile uint32_t *PRAMFC; /* fifo context table */ | |
216 volatile uint32_t *PRAMRO; /* fifo runout table */ | |
217 volatile uint32_t *PFIFO; /* fifo control region */ | |
218 volatile uint32_t *FIFO; /* fifo channels (USER) */ | |
219 volatile uint32_t *PGRAPH; /* graphics engine */ | |
220 | |
221 unsigned long fbsize; /* framebuffer size */ | |
222 int arch; /* compatible NV_ARCH_XX define */ | |
223 int realarch; /* real architecture */ | |
224 void (* lock) (struct rivatv_chip *, int); | |
225 }; | |
226 typedef struct rivatv_chip rivatv_chip; | |
227 | |
228 | |
11086 | 229 struct rivatv_info { |
230 unsigned int use_colorkey; | |
10954 | 231 unsigned int colorkey; /* saved xv colorkey*/ |
232 unsigned int vidixcolorkey; /*currently used colorkey*/ | |
233 unsigned int depth; | |
234 unsigned int format; | |
235 unsigned int pitch; | |
236 unsigned int width,height; | |
237 unsigned int d_width,d_height; /*scaled width && height*/ | |
238 unsigned int wx,wy; /*window x && y*/ | |
239 unsigned int screen_x; /*screen width*/ | |
11085 | 240 unsigned int screen_y; /*screen height*/ |
10954 | 241 unsigned long buffer_size; /* size of the image buffer */ |
242 struct rivatv_chip chip; /* NV architecture structure */ | |
243 void* video_base; /* virtual address of control region */ | |
244 void* control_base; /* virtual address of fb region */ | |
245 unsigned long picture_base; /* direct pointer to video picture */ | |
246 unsigned long picture_offset; /* offset of video picture in frame buffer */ | |
247 // struct rivatv_dma dma; /* DMA structure */ | |
11783 | 248 unsigned int cur_frame; |
10954 | 249 unsigned int num_frames; /* number of buffers */ |
11783 | 250 int bps; /* bytes per line */ |
10954 | 251 }; |
252 typedef struct rivatv_info rivatv_info; | |
253 | |
254 //framebuffer size funcs | |
255 static unsigned long rivatv_fbsize_nv03 (struct rivatv_chip *chip){ | |
256 if (VID_RD32 (chip->PFB, 0) & 0x00000020) { | |
257 if (((VID_RD32 (chip->PMC, 0) & 0xF0) == 0x20) | |
258 && ((VID_RD32 (chip->PMC, 0) & 0x0F) >= 0x02)) { | |
259 /* SDRAM 128 ZX. */ | |
260 return ((1 << (VID_RD32 (chip->PFB, 0) & 0x03)) * 1024 * 1024); | |
261 } | |
262 else { | |
263 return 1024 * 1024 * 8; | |
264 } | |
265 } | |
266 else { | |
267 /* SGRAM 128. */ | |
268 switch (chip->PFB[0x00000000] & 0x00000003) { | |
269 case 0: | |
270 return 1024 * 1024 * 8; | |
271 break; | |
272 case 2: | |
273 return 1024 * 1024 * 4; | |
274 break; | |
275 default: | |
276 return 1024 * 1024 * 2; | |
277 break; | |
278 } | |
279 } | |
280 } | |
281 static unsigned long rivatv_fbsize_nv04 (struct rivatv_chip *chip){ | |
282 if (VID_RD32 (chip->PFB, 0) & 0x00000100) { | |
283 return ((VID_RD32 (chip->PFB, 0) >> 12) & 0x0F) * 1024 * 1024 * 2 | |
284 + 1024 * 1024 * 2; | |
285 } else { | |
286 switch (VID_RD32 (chip->PFB, 0) & 0x00000003) { | |
287 case 0: | |
288 return 1024 * 1024 * 32; | |
289 break; | |
290 case 1: | |
291 return 1024 * 1024 * 4; | |
292 break; | |
293 case 2: | |
294 return 1024 * 1024 * 8; | |
295 break; | |
296 case 3: | |
297 default: | |
298 return 1024 * 1024 * 16; | |
299 break; | |
300 } | |
301 } | |
302 } | |
303 | |
304 static unsigned long rivatv_fbsize_nv10 (struct rivatv_chip *chip){ | |
305 return ((VID_RD32 (chip->PFB, 0x20C) >> 20) & 0x000000FF) * 1024 * 1024; | |
306 } | |
307 | |
308 //lock funcs | |
309 static void rivatv_lock_nv03 (struct rivatv_chip *chip, int LockUnlock){ | |
310 VID_WR08 (chip->PVIO, 0x3C4, 0x06); | |
311 VID_WR08 (chip->PVIO, 0x3C5, LockUnlock ? 0x99 : 0x57); | |
312 } | |
313 | |
314 static void rivatv_lock_nv04 (struct rivatv_chip *chip, int LockUnlock){ | |
315 VID_WR08 (chip->PCIO, 0x3C4, 0x06); | |
316 VID_WR08 (chip->PCIO, 0x3C5, LockUnlock ? 0x99 : 0x57); | |
317 VID_WR08 (chip->PCIO, 0x3D4, 0x1F); | |
318 VID_WR08 (chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57); | |
319 } | |
320 | |
321 | |
322 | |
323 | |
324 /* Enable PFB (Framebuffer), PVIDEO (Overlay unit) and PME (Mediaport) if neccessary. */ | |
325 static void rivatv_enable_PMEDIA (struct rivatv_info *info){ | |
326 uint32_t reg; | |
327 | |
328 /* switch off interrupts once for a while */ | |
329 // VID_WR32 (info->chip.PME, 0x200140, 0x00); | |
330 // VID_WR32 (info->chip.PMC, 0x000140, 0x00); | |
331 | |
332 reg = VID_RD32 (info->chip.PMC, 0x000200); | |
333 | |
334 /* NV3 (0x10100010): NV03_PMC_ENABLE_PMEDIA, NV03_PMC_ENABLE_PFB, NV03_PMC_ENABLE_PVIDEO */ | |
335 | |
336 if ((reg & 0x10100010) != 0x10100010) { | |
337 printf("PVIDEO and PFB disabled, enabling...\n"); | |
338 VID_OR32 (info->chip.PMC, 0x000200, 0x10100010); | |
339 } | |
340 | |
341 /* save the current colorkey */ | |
342 switch (info->chip.arch ) { | |
343 case NV_ARCH_10: | |
344 case NV_ARCH_20: | |
345 case NV_ARCH_30: | |
346 /* NV_PVIDEO_COLOR_KEY */ | |
347 info->colorkey = VID_RD32 (info->chip.PVIDEO, 0xB00); | |
348 break; | |
349 case NV_ARCH_03: | |
350 case NV_ARCH_04: | |
351 /* NV_PVIDEO_KEY */ | |
352 info->colorkey = VID_RD32 (info->chip.PVIDEO, 0x240); | |
353 break; | |
354 } | |
355 | |
356 | |
357 /* re-enable interrupts again */ | |
358 // VID_WR32 (info->chip.PMC, 0x000140, 0x01); | |
359 // VID_WR32 (info->chip.PME, 0x200140, 0x01); | |
360 } | |
361 | |
362 /* Stop overlay video. */ | |
363 void rivatv_overlay_stop (struct rivatv_info *info) { | |
364 switch (info->chip.arch ) { | |
365 case NV_ARCH_10: | |
366 case NV_ARCH_20: | |
367 case NV_ARCH_30: | |
368 /* NV_PVIDEO_COLOR_KEY */ | |
369 /* Xv-Extension-Hack: Restore previously saved value. */ | |
370 VID_WR32 (info->chip.PVIDEO, 0xB00, info->colorkey); | |
371 /* NV_PVIDEO_STOP */ | |
372 VID_OR32 (info->chip.PVIDEO, 0x704, 0x11); | |
373 /* NV_PVIDEO_BUFFER */ | |
374 VID_AND32 (info->chip.PVIDEO, 0x700, ~0x11); | |
375 /* NV_PVIDEO_INTR_EN_BUFFER */ | |
11086 | 376 // VID_AND32 (info->chip.PVIDEO, 0x140, ~0x11); |
10954 | 377 break; |
378 case NV_ARCH_03: | |
379 case NV_ARCH_04: | |
380 /* NV_PVIDEO_KEY */ | |
381 VID_WR32 (info->chip.PVIDEO, 0x240, info->colorkey); | |
382 /* NV_PVIDEO_OVERLAY_VIDEO_OFF */ | |
383 VID_AND32 (info->chip.PVIDEO, 0x244, ~0x01); | |
384 /* NV_PVIDEO_INTR_EN_0_NOTIFY */ | |
11086 | 385 // VID_AND32 (info->chip.PVIDEO, 0x140, ~0x01); |
10954 | 386 /* NV_PVIDEO_OE_STATE */ |
387 VID_WR32 (info->chip.PVIDEO, 0x224, 0); | |
388 /* NV_PVIDEO_SU_STATE */ | |
389 VID_WR32 (info->chip.PVIDEO, 0x228, 0); | |
390 /* NV_PVIDEO_RM_STATE */ | |
391 VID_WR32 (info->chip.PVIDEO, 0x22C, 0); | |
392 break; | |
393 } | |
394 } | |
395 | |
396 /* Get pan offset of the physical screen. */ | |
397 static uint32_t rivatv_overlay_pan (struct rivatv_info *info){ | |
398 uint32_t pan; | |
399 info->chip.lock (&info->chip, 0); | |
400 VID_WR08 (info->chip.PCIO, 0x3D4, 0x0D); | |
401 pan = VID_RD08 (info->chip.PCIO, 0x3D5); | |
402 VID_WR08 (info->chip.PCIO, 0x3D4, 0x0C); | |
403 pan |= VID_RD08 (info->chip.PCIO, 0x3D5) << 8; | |
404 VID_WR08 (info->chip.PCIO, 0x3D4, 0x19); | |
405 pan |= (VID_RD08 (info->chip.PCIO, 0x3D5) & 0x1F) << 16; | |
406 VID_WR08 (info->chip.PCIO, 0x3D4, 0x2D); | |
407 pan |= (VID_RD08 (info->chip.PCIO, 0x3D5) & 0x60) << 16; | |
408 return pan << 2; | |
409 } | |
410 | |
411 /* Compute and set colorkey depending on the colour depth. */ | |
412 static void rivatv_overlay_colorkey (rivatv_info* info, unsigned int chromakey){ | |
413 uint32_t r, g, b, key = 0; | |
11159 | 414 |
10954 | 415 r = (chromakey & 0x00FF0000) >> 16; |
416 g = (chromakey & 0x0000FF00) >> 8; | |
417 b = chromakey & 0x000000FF; | |
418 switch (info->depth) { | |
419 case 15: | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
420 key = ((r >> 3) << 10) | ((g >> 3) << 5) | ((b >> 3)); |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
421 #ifndef WIN32 |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
422 key = key | 0x00008000; |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
423 #endif |
10954 | 424 break; |
11118
344052fdfc4a
Fix colorkey for xvidix, tested on Riva128 4MB X@15/16/24bpp (aka 15/15/32 in nvidia_vid)
atmos4
parents:
11086
diff
changeset
|
425 case 16: // XXX unchecked |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
426 key = ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3)); |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
427 #ifndef WIN32 |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
428 key = key | 0x00008000; |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
429 #endif |
10954 | 430 break; |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
431 case 24: // XXX unchecked, maybe swap order of masking - FIXME Can the card be in 24 bit mode anyway? |
11118
344052fdfc4a
Fix colorkey for xvidix, tested on Riva128 4MB X@15/16/24bpp (aka 15/15/32 in nvidia_vid)
atmos4
parents:
11086
diff
changeset
|
432 key = (chromakey & 0x00FFFFFF) | 0x00800000; |
10954 | 433 break; |
434 case 32: | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
435 key = chromakey; |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
436 #ifndef WIN32 |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
437 key = key | 0x80000000; |
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
438 #endif |
10954 | 439 break; |
440 } | |
11118
344052fdfc4a
Fix colorkey for xvidix, tested on Riva128 4MB X@15/16/24bpp (aka 15/15/32 in nvidia_vid)
atmos4
parents:
11086
diff
changeset
|
441 //printf("[nvidia_vid] depth=%d %08X \n", info->depth, chromakey); |
10954 | 442 switch (info->chip.arch) { |
443 case NV_ARCH_10: | |
444 case NV_ARCH_20: | |
445 case NV_ARCH_30: | |
446 VID_WR32 (info->chip.PVIDEO, 0xB00, key); | |
447 break; | |
448 case NV_ARCH_03: | |
449 case NV_ARCH_04: | |
450 VID_WR32 (info->chip.PVIDEO, 0x240, key); | |
451 break; | |
452 } | |
453 } | |
454 | |
11085 | 455 static void nv_getscreenproperties(struct rivatv_info *info){ |
456 uint32_t bpp=0; | |
457 info->chip.lock(&info->chip, 0); | |
458 /*get screen depth*/ | |
459 VID_WR08(info->chip.PCIO, 0x03D4,0x28); | |
11783 | 460 bpp = VID_RD08(info->chip.PCIO,0x03D5)&0x3; |
11085 | 461 if(bpp==3)bpp=4; |
462 if((bpp == 2) && (info->chip.PVIDEO[0x00000600/4] & 0x00001000) == 0x0)info->depth=15; | |
463 else info->depth = bpp*8; | |
464 /*get screen width*/ | |
465 VID_WR08(info->chip.PCIO, 0x03D4, 0x1); | |
466 info->screen_x = (1 + VID_RD08(info->chip.PCIO, 0x3D5)) * 8; | |
467 /*get screen height*/ | |
468 /* get first 8 bits in VT_DISPLAY_END*/ | |
469 VID_WR08(info->chip.PCIO, 0x03D4, 0x12); | |
470 info->screen_y = VID_RD08(info->chip.PCIO,0x03D5); | |
471 VID_WR08(info->chip.PCIO,0x03D4,0x07); | |
472 /* get 9th bit in CRTC_OVERFLOW*/ | |
473 info->screen_y |= (VID_RD08(info->chip.PCIO,0x03D5) &0x02)<<7; | |
474 /* and the 10th in CRTC_OVERFLOW*/ | |
475 info->screen_y |=(VID_RD08(info->chip.PCIO,0x03D5) &0x40)<<3; | |
476 ++info->screen_y; | |
477 } | |
478 | |
479 | |
480 | |
10954 | 481 |
482 /* Start overlay video. */ | |
483 void rivatv_overlay_start (struct rivatv_info *info,int bufno){ | |
11085 | 484 uint32_t base, size, offset, xscale, yscale, pan; |
11086 | 485 uint32_t value; |
11233 | 486 int x=info->wx?info->wx:8, y=info->wy?info->wy:8; |
10954 | 487 int lwidth=info->d_width, lheight=info->d_height; |
488 int bps; | |
11783 | 489 int i; |
10954 | 490 |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
491 size = info->buffer_size; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
492 base = info->picture_offset; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
493 offset = bufno*size; |
10954 | 494 /*update depth & dimensions here because it may change with vo vesa or vo fbdev*/ |
11085 | 495 nv_getscreenproperties(info); |
496 | |
497 if(info->depth){ | |
11783 | 498 // bps = info->screen_x * ((info->depth+1)/8); |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
499 /* get pan offset of the physical screen */ |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
500 pan = rivatv_overlay_pan (info); |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
501 /* adjust window position depending on the pan offset */ |
11783 | 502 bps = 0; |
503 info->chip.lock (&info->chip, 0); | |
504 for (i = 0; (i < 1024) && (bps == 0); i++) | |
505 { | |
506 if (info->chip.arch != NV_ARCH_03) | |
507 bps = info->chip.PGRAPH[0x00000670/4]; | |
508 else | |
509 bps = info->chip.PGRAPH[0x00000650/4]; | |
510 } | |
511 if (bps == 0) | |
512 { | |
513 fprintf(stderr, "[nvidia_vid] reading bps returned 0!!!\n"); | |
514 if (info->bps != 0) | |
515 bps = info->bps; | |
516 } | |
517 else | |
518 { | |
519 info->bps = bps; | |
520 } | |
521 | |
522 if (bps != 0) | |
523 { | |
524 x = info->wx - (pan % bps) * 8 / info->depth; | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
525 y = info->wy - (pan / bps); |
11783 | 526 } |
527 } | |
528 | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
529 /* adjust negative output window variables */ |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
530 if (x < 0) { |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
531 lwidth = info->d_width + x; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
532 offset += (-x * info->width / info->d_width) << 1; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
533 // offset += (-window->x * port->vld_width / window->width) << 1; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
534 x = 0; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
535 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
536 if (y < 0) { |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
537 lheight = info->d_height + y; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
538 offset += (-y * info->height / info->d_height * info->width) << 1; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
539 // offset += (-window->y * port->vld_height / window->height * port->org_width) << 1; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
540 y = 0; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
541 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
542 |
10954 | 543 switch (info->chip.arch) { |
544 case NV_ARCH_10: | |
545 case NV_ARCH_20: | |
546 case NV_ARCH_30: | |
547 | |
548 /* NV_PVIDEO_BASE */ | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
549 VID_WR32 (info->chip.PVIDEO, 0x900 + 0, base + offset); |
10954 | 550 //VID_WR32 (info->chip.PVIDEO, 0x900 + 4, base); |
551 /* NV_PVIDEO_LIMIT */ | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
552 VID_WR32 (info->chip.PVIDEO, 0x908 + 0, base + offset + size - 1); |
10954 | 553 //VID_WR32 (info->chip.PVIDEO, 0x908 + 4, base + size - 1); |
554 | |
555 /* extra code for NV20 && NV30 architectures */ | |
556 if (info->chip.arch == NV_ARCH_20 || info->chip.arch == NV_ARCH_30) { | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
557 VID_WR32 (info->chip.PVIDEO, 0x800 + 0, base + offset); |
10954 | 558 //VID_WR32 (info->chip.PVIDEO, 0x800 + 4, base); |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
559 VID_WR32 (info->chip.PVIDEO, 0x808 + 0, base + offset + size - 1); |
10954 | 560 //VID_WR32 (info->chip.PVIDEO, 0x808 + 4, base + size - 1); |
561 } | |
562 | |
563 /* NV_PVIDEO_LUMINANCE */ | |
564 VID_WR32 (info->chip.PVIDEO, 0x910 + 0, 0x00001000); | |
565 //VID_WR32 (info->chip.PVIDEO, 0x910 + 4, 0x00001000); | |
566 /* NV_PVIDEO_CHROMINANCE */ | |
567 VID_WR32 (info->chip.PVIDEO, 0x918 + 0, 0x00001000); | |
568 //VID_WR32 (info->chip.PVIDEO, 0x918 + 4, 0x00001000); | |
569 | |
570 /* NV_PVIDEO_OFFSET */ | |
11160
b5a3ef555164
double buffering fix for cards > NV04 && windows colorkeying fix
faust3
parents:
11159
diff
changeset
|
571 VID_WR32 (info->chip.PVIDEO, 0x920 + 0, 0x0); |
10954 | 572 //VID_WR32 (info->chip.PVIDEO, 0x920 + 4, offset + pitch); |
573 /* NV_PVIDEO_SIZE_IN */ | |
574 VID_WR32 (info->chip.PVIDEO, 0x928 + 0, ((info->height) << 16) | info->width); | |
575 //VID_WR32 (info->chip.PVIDEO, 0x928 + 4, ((port->org_height/2) << 16) | port->org_width); | |
576 /* NV_PVIDEO_POINT_IN */ | |
577 VID_WR32 (info->chip.PVIDEO, 0x930 + 0, 0x00000000); | |
578 //VID_WR32 (info->chip.PVIDEO, 0x930 + 4, 0x00000000); | |
579 /* NV_PVIDEO_DS_DX_RATIO */ | |
580 VID_WR32 (info->chip.PVIDEO, 0x938 + 0, (info->width << 20) / info->d_width); | |
581 //VID_WR32 (info->chip.PVIDEO, 0x938 + 4, (port->org_width << 20) / window->width); | |
582 /* NV_PVIDEO_DT_DY_RATIO */ | |
583 VID_WR32 (info->chip.PVIDEO, 0x940 + 0, ((info->height) << 20) / info->d_height); | |
584 //VID_WR32 (info->chip.PVIDEO, 0x940 + 4, ((port->org_height/2) << 20) / window->height); | |
585 | |
586 /* NV_PVIDEO_POINT_OUT */ | |
587 VID_WR32 (info->chip.PVIDEO, 0x948 + 0, ((y + 0) << 16) | x); | |
588 //VID_WR32 (info->chip.PVIDEO, 0x948 + 4, ((y + 0) << 16) | x); | |
589 /* NV_PVIDEO_SIZE_OUT */ | |
590 VID_WR32 (info->chip.PVIDEO, 0x950 + 0, (lheight << 16) | lwidth); | |
591 //VID_WR32 (info->chip.PVIDEO, 0x950 + 4, (height << 16) | width); | |
592 | |
593 /* NV_PVIDEO_FORMAT */ | |
11086 | 594 value = info->pitch; |
595 if(info->use_colorkey)value |= 1 << 20; | |
596 if(info->format == IMGFMT_YUY2)value |= 1 << 16; | |
597 VID_WR32 (info->chip.PVIDEO, 0x958 + 0, value); | |
598 //VID_WR32 (info->chip.PVIDEO, 0x958 + 4, (pitch << 1) | 0x00100000); | |
10954 | 599 |
600 /* NV_PVIDEO_INTR_EN_BUFFER */ | |
11086 | 601 // VID_OR32 (info->chip.PVIDEO, 0x140, 0x01/*0x11*/); |
10954 | 602 /* NV_PVIDEO_STOP */ |
11086 | 603 VID_WR32 (info->chip.PVIDEO, 0x704,0x0); |
10954 | 604 /* NV_PVIDEO_BUFFER */ |
11086 | 605 VID_WR32 (info->chip.PVIDEO, 0x700, 0x01/*0x11*/); |
10954 | 606 break; |
607 | |
608 case NV_ARCH_03: | |
609 case NV_ARCH_04: | |
610 | |
611 | |
612 /* NV_PVIDEO_OE_STATE */ | |
613 VID_WR32 (info->chip.PVIDEO, 0x224, 0); | |
614 /* NV_PVIDEO_SU_STATE */ | |
615 VID_WR32 (info->chip.PVIDEO, 0x228, 0); | |
616 /* NV_PVIDEO_RM_STATE */ | |
617 VID_WR32 (info->chip.PVIDEO, 0x22C, 0); | |
618 | |
619 /* NV_PVIDEO_BUFF0_START_ADDRESS */ | |
620 VID_WR32 (info->chip.PVIDEO, 0x20C + 0, base + offset + 0); | |
621 VID_WR32 (info->chip.PVIDEO, 0x20C + 4, base + offset + 0); | |
622 /* NV_PVIDEO_BUFF0_PITCH_LENGTH */ | |
623 VID_WR32 (info->chip.PVIDEO, 0x214 + 0, info->pitch); | |
624 VID_WR32 (info->chip.PVIDEO, 0x214 + 4, info->pitch); | |
625 | |
626 /* NV_PVIDEO_WINDOW_START */ | |
627 VID_WR32 (info->chip.PVIDEO, 0x230, (y << 16) | x); | |
628 /* NV_PVIDEO_WINDOW_SIZE */ | |
629 VID_WR32 (info->chip.PVIDEO, 0x234, (lheight << 16) | lwidth); | |
630 /* NV_PVIDEO_STEP_SIZE */ | |
631 yscale = ((info->height - 1) << 11) / (info->d_height - 1); | |
632 xscale = ((info->width - 1) << 11) / (info->d_width - 1); | |
633 VID_WR32 (info->chip.PVIDEO, 0x200, (yscale << 16) | xscale); | |
634 | |
635 /* NV_PVIDEO_RED_CSC_OFFSET */ | |
636 VID_WR32 (info->chip.PVIDEO, 0x280, 0x69); | |
637 /* NV_PVIDEO_GREEN_CSC_OFFSET */ | |
638 VID_WR32 (info->chip.PVIDEO, 0x284, 0x3e); | |
639 /* NV_PVIDEO_BLUE_CSC_OFFSET */ | |
640 VID_WR32 (info->chip.PVIDEO, 0x288, 0x89); | |
641 /* NV_PVIDEO_CSC_ADJUST */ | |
642 VID_WR32 (info->chip.PVIDEO, 0x28C, 0x00000); /* No colour correction! */ | |
643 | |
644 /* NV_PVIDEO_CONTROL_Y (BLUR_ON, LINE_HALF) */ | |
645 VID_WR32 (info->chip.PVIDEO, 0x204, 0x001); | |
646 /* NV_PVIDEO_CONTROL_X (WEIGHT_HEAVY, SHARPENING_ON, SMOOTHING_ON) */ | |
11086 | 647 VID_WR32 (info->chip.PVIDEO, 0x208, 0x111); /*directx overlay 0x110 */ |
10954 | 648 |
649 /* NV_PVIDEO_FIFO_BURST_LENGTH */ | |
650 VID_WR32 (info->chip.PVIDEO, 0x23C, 0x03); | |
651 /* NV_PVIDEO_FIFO_THRES_SIZE */ | |
652 VID_WR32 (info->chip.PVIDEO, 0x238, 0x38); /*windows uses 0x40*/ | |
653 | |
654 /* NV_PVIDEO_BUFF0_OFFSET */ | |
655 VID_WR32 (info->chip.PVIDEO, 0x21C + 0, 0); | |
656 VID_WR32 (info->chip.PVIDEO, 0x21C + 4, 0); | |
657 | |
658 /* NV_PVIDEO_INTR_EN_0_NOTIFY_ENABLED */ | |
659 // VID_OR32 (info->chip.PVIDEO, 0x140, 0x01); | |
11086 | 660 |
10954 | 661 /* NV_PVIDEO_OVERLAY (KEY_ON, VIDEO_ON, FORMAT_CCIR) */ |
11086 | 662 value = 0x1; /*video on*/ |
663 if(info->format==IMGFMT_YUY2)value |= 0x100; | |
664 if(info->use_colorkey)value |=0x10; | |
665 VID_WR32 (info->chip.PVIDEO, 0x244, value); | |
666 | |
10954 | 667 /* NV_PVIDEO_SU_STATE */ |
668 VID_XOR32 (info->chip.PVIDEO, 0x228, 1 << 16); | |
669 break; | |
670 } | |
671 /*set colorkey*/ | |
672 rivatv_overlay_colorkey(info,info->vidixcolorkey); | |
673 | |
674 } | |
675 | |
676 | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
677 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
678 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
679 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
680 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
681 |
10954 | 682 static rivatv_info* info; |
683 | |
684 | |
685 | |
686 | |
687 int vixInit(void){ | |
688 int mtrr; | |
689 info = (rivatv_info*)calloc(1,sizeof(rivatv_info)); | |
690 info->control_base = map_phys_mem(pci_info.base0, 0x00C00000 + 0x00008000); | |
691 info->chip.arch = nvidia_card_ids[find_chip(pci_info.device)].arch; | |
692 printf("[nvidia_vid] arch %x register base %x\n",info->chip.arch,(unsigned int)info->control_base); | |
693 info->chip.PFIFO = (uint32_t *) (info->control_base + 0x00002000); | |
694 info->chip.FIFO = (uint32_t *) (info->control_base + 0x00800000); | |
695 info->chip.PMC = (uint32_t *) (info->control_base + 0x00000000); | |
696 info->chip.PFB = (uint32_t *) (info->control_base + 0x00100000); | |
697 info->chip.PME = (uint32_t *) (info->control_base + 0x00000000); | |
698 info->chip.PCIO = (uint8_t *) (info->control_base + 0x00601000); | |
699 info->chip.PVIO = (uint8_t *) (info->control_base + 0x000C0000); | |
700 info->chip.PGRAPH = (uint32_t *) (info->control_base + 0x00400000); | |
701 /* setup chip specific functions */ | |
702 switch (info->chip.arch) { | |
703 case NV_ARCH_03: | |
704 info->chip.lock = rivatv_lock_nv03; | |
705 info->chip.fbsize = rivatv_fbsize_nv03 (&info->chip); | |
706 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00680000); | |
707 break; | |
708 case NV_ARCH_04: | |
709 info->chip.lock = rivatv_lock_nv04; | |
710 info->chip.fbsize = rivatv_fbsize_nv04 (&info->chip); | |
711 info->chip.PRAMIN = (uint32_t *) (info->control_base + 0x00700000); | |
712 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00680000); | |
713 break; | |
714 case NV_ARCH_10: | |
715 case NV_ARCH_20: | |
716 case NV_ARCH_30: | |
717 info->chip.lock = rivatv_lock_nv04; | |
718 info->chip.fbsize = rivatv_fbsize_nv10 (&info->chip); | |
719 info->chip.PRAMIN = (uint32_t *) (info->control_base + 0x00700000); | |
720 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00008000); | |
721 break; | |
722 } | |
723 switch (info->chip.arch) { | |
724 case NV_ARCH_03: | |
725 { | |
726 /* This maps framebuffer @6MB, thus 2MB are left for video. */ | |
727 info->video_base = map_phys_mem(pci_info.base1, info->chip.fbsize); | |
728 /* This may trash your screen for resolutions greater than 1024x768, sorry. */ | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
729 info->picture_offset = 1024*768* 4 * ((info->chip.fbsize > 4194304)?2:1); |
10954 | 730 info->picture_base = (uint32_t) info->video_base + info->picture_offset; |
731 info->chip.PRAMIN = (uint32_t *) (info->video_base + 0x00C00000); | |
732 break; | |
733 } | |
734 case NV_ARCH_04: | |
735 case NV_ARCH_10: | |
736 case NV_ARCH_20: | |
737 case NV_ARCH_30: | |
738 { | |
739 info->video_base = map_phys_mem(pci_info.base1, info->chip.fbsize); | |
740 info->picture_offset = info->chip.fbsize - NV04_BES_SIZE; | |
741 // info->picture_base = (unsigned long)map_phys_mem(pci_info.base1+info->picture_offset,NV04_BES_SIZE); | |
742 info->picture_base = (uint32_t) info->video_base + info->picture_offset; | |
743 break; | |
744 } | |
745 } | |
746 | |
747 printf("[nvidia_vid] detected memory size %u MB\n",(uint32_t)(info->chip.fbsize /1024/1024)); | |
748 | |
749 if ((mtrr = mtrr_set_type(pci_info.base1, info->chip.fbsize, MTRR_TYPE_WRCOMB))!= 0) | |
11085 | 750 printf("[nvidia_vid] unable to setup MTRR: %s\n", strerror(mtrr)); |
10954 | 751 else |
11085 | 752 printf("[nvidia_vid] MTRR set up\n"); |
10954 | 753 |
11085 | 754 nv_getscreenproperties(info); |
755 if(!info->depth)printf("[nvidia_vid] text mode: %ux%u\n",info->screen_x,info->screen_y); | |
756 else printf("[nvidia_vid] video mode: %ux%u@%u\n",info->screen_x,info->screen_y, info->depth); | |
757 | |
10954 | 758 |
759 rivatv_enable_PMEDIA(info); | |
11783 | 760 info->cur_frame = 0; |
11159 | 761 info->use_colorkey = 0; |
11783 | 762 |
10954 | 763 return 0; |
764 } | |
765 | |
766 void vixDestroy(void){ | |
767 unmap_phys_mem(info->control_base ,0x00C00000 + 0x00008000); | |
768 unmap_phys_mem(info->video_base, info->chip.fbsize); | |
769 free(info); | |
770 } | |
771 | |
772 int vixGetCapability(vidix_capability_t *to){ | |
773 memcpy(to, &nvidia_cap, sizeof(vidix_capability_t)); | |
774 return 0; | |
775 } | |
776 | |
777 inline static int is_supported_fourcc(uint32_t fourcc) | |
778 { | |
11086 | 779 if (fourcc == IMGFMT_UYVY || fourcc == IMGFMT_YUY2) |
10954 | 780 return 1; |
781 else | |
782 return 0; | |
783 } | |
784 | |
785 int vixQueryFourcc(vidix_fourcc_t *to){ | |
786 if(is_supported_fourcc(to->fourcc)){ | |
787 to->depth = VID_DEPTH_1BPP | VID_DEPTH_2BPP | | |
788 VID_DEPTH_4BPP | VID_DEPTH_8BPP | | |
789 VID_DEPTH_12BPP| VID_DEPTH_15BPP| | |
790 VID_DEPTH_16BPP| VID_DEPTH_24BPP| | |
791 VID_DEPTH_32BPP; | |
792 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; | |
793 return 0; | |
794 } | |
795 else to->depth = to->flags = 0; | |
796 return ENOSYS; | |
797 } | |
798 | |
799 int vixConfigPlayback(vidix_playback_t *vinfo){ | |
800 uint32_t i; | |
801 printf("called %s\n", __FUNCTION__); | |
802 if (! is_supported_fourcc(vinfo->fourcc)) | |
803 return ENOSYS; | |
804 | |
805 info->width = vinfo->src.w; | |
806 info->height = vinfo->src.h; | |
807 | |
808 info->d_width = vinfo->dest.w; | |
809 info->d_height = vinfo->dest.h; | |
810 info->wx = vinfo->dest.x; | |
811 info->wy = vinfo->dest.y; | |
812 info->format = vinfo->fourcc; | |
813 | |
814 printf("[nvidia_vid] setting up a %dx%d-%dx%d video window (src %dx%d), format 0x%X\n", | |
815 info->d_width, info->d_height, info->wx, info->wy, info->width, info->height, vinfo->fourcc); | |
816 | |
817 | |
818 vinfo->dga_addr=(void*)(info->picture_base); | |
819 | |
820 switch (vinfo->fourcc) | |
821 { | |
822 case IMGFMT_YUY2: | |
823 case IMGFMT_UYVY: | |
824 | |
11086 | 825 vinfo->dest.pitch.y = 16; |
10954 | 826 vinfo->dest.pitch.u = 0; |
827 vinfo->dest.pitch.v = 0; | |
828 | |
829 vinfo->offset.y = 0; | |
830 vinfo->offset.v = 0; | |
831 vinfo->offset.u = 0; | |
832 | |
833 info->pitch = info->width << 1; | |
834 vinfo->frame_size = info->pitch * info->height; | |
835 break; | |
836 case IMGFMT_YV12: | |
837 vinfo->dest.pitch.y = 1; | |
838 vinfo->dest.pitch.u = 1; | |
839 vinfo->dest.pitch.v = 1; | |
840 | |
841 vinfo->offset.y = 0; | |
842 vinfo->offset.v = (info->width) * info->height; | |
843 vinfo->offset.u = vinfo->offset.v * 5 / 4; | |
844 | |
845 info->pitch = info->width + (info->width >> 1); | |
846 vinfo->frame_size = info->pitch * info->height; | |
847 break; | |
848 } | |
849 info->buffer_size = vinfo->frame_size; | |
850 info->num_frames = vinfo->num_frames= (info->chip.fbsize - info->picture_offset)/vinfo->frame_size; | |
851 if(vinfo->num_frames > MAX_FRAMES)vinfo->num_frames = MAX_FRAMES; | |
852 // vinfo->num_frames = 1; | |
853 // printf("[nvidia_vid] Number of frames %i\n",vinfo->num_frames); | |
854 for(i=0;i <vinfo->num_frames;i++)vinfo->offsets[i] = vinfo->frame_size*i; | |
855 return 0; | |
856 } | |
857 | |
858 int vixPlaybackOn(void){ | |
11783 | 859 rivatv_overlay_start(info,info->cur_frame); |
10954 | 860 return 0; |
861 } | |
862 | |
863 int vixPlaybackOff(void){ | |
864 rivatv_overlay_stop(info); | |
865 return 0; | |
866 } | |
867 | |
868 int vixSetGrKeys( const vidix_grkey_t * grkey){ | |
11159 | 869 if (grkey->ckey.op == CKEY_FALSE) |
870 { | |
871 info->use_colorkey = 0; | |
872 printf("[nvidia_vid] colorkeying disabled\n"); | |
873 } | |
11165 | 874 else { |
11159 | 875 info->use_colorkey = 1; |
10954 | 876 info->vidixcolorkey = ((grkey->ckey.red<<16)|(grkey->ckey.green<<8)|grkey->ckey.blue); |
877 printf("[nvidia_vid] set colorkey 0x%x\n",info->vidixcolorkey); | |
11165 | 878 } |
11210 | 879 if(info->d_width && info->d_height)rivatv_overlay_start(info,0); |
10954 | 880 return 0; |
881 } | |
882 | |
883 int vixPlaybackFrameSelect(unsigned int frame){ | |
884 // printf("selecting buffer %d\n", frame); | |
885 rivatv_overlay_start(info, frame); | |
886 if (info->num_frames >= 1) | |
11783 | 887 info->cur_frame = frame/*(frame+1)%info->num_frames*/; |
10954 | 888 return 0; |
889 } |