Mercurial > mplayer.hg
annotate vidix/drivers/nvidia_vid.c @ 11090:97aaafac1458
typo
author | nauj27 |
---|---|
date | Sun, 12 Oct 2003 23:12:05 +0000 |
parents | 7f659e7b7ce1 |
children | 344052fdfc4a |
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 | |
6 WARNING: THIS DRIVER IS IN BETTA STAGE | |
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){ | |
137 printf("[nvidia_vid] Error occured during pci scan: %s\n",strerror(err)); | |
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 */ | |
248 unsigned int next_frame; | |
249 unsigned int num_frames; /* number of buffers */ | |
250 }; | |
251 typedef struct rivatv_info rivatv_info; | |
252 | |
253 //framebuffer size funcs | |
254 static unsigned long rivatv_fbsize_nv03 (struct rivatv_chip *chip){ | |
255 if (VID_RD32 (chip->PFB, 0) & 0x00000020) { | |
256 if (((VID_RD32 (chip->PMC, 0) & 0xF0) == 0x20) | |
257 && ((VID_RD32 (chip->PMC, 0) & 0x0F) >= 0x02)) { | |
258 /* SDRAM 128 ZX. */ | |
259 return ((1 << (VID_RD32 (chip->PFB, 0) & 0x03)) * 1024 * 1024); | |
260 } | |
261 else { | |
262 return 1024 * 1024 * 8; | |
263 } | |
264 } | |
265 else { | |
266 /* SGRAM 128. */ | |
267 switch (chip->PFB[0x00000000] & 0x00000003) { | |
268 case 0: | |
269 return 1024 * 1024 * 8; | |
270 break; | |
271 case 2: | |
272 return 1024 * 1024 * 4; | |
273 break; | |
274 default: | |
275 return 1024 * 1024 * 2; | |
276 break; | |
277 } | |
278 } | |
279 } | |
280 static unsigned long rivatv_fbsize_nv04 (struct rivatv_chip *chip){ | |
281 if (VID_RD32 (chip->PFB, 0) & 0x00000100) { | |
282 return ((VID_RD32 (chip->PFB, 0) >> 12) & 0x0F) * 1024 * 1024 * 2 | |
283 + 1024 * 1024 * 2; | |
284 } else { | |
285 switch (VID_RD32 (chip->PFB, 0) & 0x00000003) { | |
286 case 0: | |
287 return 1024 * 1024 * 32; | |
288 break; | |
289 case 1: | |
290 return 1024 * 1024 * 4; | |
291 break; | |
292 case 2: | |
293 return 1024 * 1024 * 8; | |
294 break; | |
295 case 3: | |
296 default: | |
297 return 1024 * 1024 * 16; | |
298 break; | |
299 } | |
300 } | |
301 } | |
302 | |
303 static unsigned long rivatv_fbsize_nv10 (struct rivatv_chip *chip){ | |
304 return ((VID_RD32 (chip->PFB, 0x20C) >> 20) & 0x000000FF) * 1024 * 1024; | |
305 } | |
306 | |
307 //lock funcs | |
308 static void rivatv_lock_nv03 (struct rivatv_chip *chip, int LockUnlock){ | |
309 VID_WR08 (chip->PVIO, 0x3C4, 0x06); | |
310 VID_WR08 (chip->PVIO, 0x3C5, LockUnlock ? 0x99 : 0x57); | |
311 } | |
312 | |
313 static void rivatv_lock_nv04 (struct rivatv_chip *chip, int LockUnlock){ | |
314 VID_WR08 (chip->PCIO, 0x3C4, 0x06); | |
315 VID_WR08 (chip->PCIO, 0x3C5, LockUnlock ? 0x99 : 0x57); | |
316 VID_WR08 (chip->PCIO, 0x3D4, 0x1F); | |
317 VID_WR08 (chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57); | |
318 } | |
319 | |
320 | |
321 | |
322 | |
323 /* Enable PFB (Framebuffer), PVIDEO (Overlay unit) and PME (Mediaport) if neccessary. */ | |
324 static void rivatv_enable_PMEDIA (struct rivatv_info *info){ | |
325 uint32_t reg; | |
326 | |
327 /* switch off interrupts once for a while */ | |
328 // VID_WR32 (info->chip.PME, 0x200140, 0x00); | |
329 // VID_WR32 (info->chip.PMC, 0x000140, 0x00); | |
330 | |
331 reg = VID_RD32 (info->chip.PMC, 0x000200); | |
332 | |
333 /* NV3 (0x10100010): NV03_PMC_ENABLE_PMEDIA, NV03_PMC_ENABLE_PFB, NV03_PMC_ENABLE_PVIDEO */ | |
334 | |
335 if ((reg & 0x10100010) != 0x10100010) { | |
336 printf("PVIDEO and PFB disabled, enabling...\n"); | |
337 VID_OR32 (info->chip.PMC, 0x000200, 0x10100010); | |
338 } | |
339 | |
340 /* save the current colorkey */ | |
341 switch (info->chip.arch ) { | |
342 case NV_ARCH_10: | |
343 case NV_ARCH_20: | |
344 case NV_ARCH_30: | |
345 /* NV_PVIDEO_COLOR_KEY */ | |
346 info->colorkey = VID_RD32 (info->chip.PVIDEO, 0xB00); | |
347 break; | |
348 case NV_ARCH_03: | |
349 case NV_ARCH_04: | |
350 /* NV_PVIDEO_KEY */ | |
351 info->colorkey = VID_RD32 (info->chip.PVIDEO, 0x240); | |
352 break; | |
353 } | |
354 | |
355 | |
356 /* re-enable interrupts again */ | |
357 // VID_WR32 (info->chip.PMC, 0x000140, 0x01); | |
358 // VID_WR32 (info->chip.PME, 0x200140, 0x01); | |
359 } | |
360 | |
361 /* Stop overlay video. */ | |
362 void rivatv_overlay_stop (struct rivatv_info *info) { | |
363 switch (info->chip.arch ) { | |
364 case NV_ARCH_10: | |
365 case NV_ARCH_20: | |
366 case NV_ARCH_30: | |
367 /* NV_PVIDEO_COLOR_KEY */ | |
368 /* Xv-Extension-Hack: Restore previously saved value. */ | |
369 VID_WR32 (info->chip.PVIDEO, 0xB00, info->colorkey); | |
370 /* NV_PVIDEO_STOP */ | |
371 VID_OR32 (info->chip.PVIDEO, 0x704, 0x11); | |
372 /* NV_PVIDEO_BUFFER */ | |
373 VID_AND32 (info->chip.PVIDEO, 0x700, ~0x11); | |
374 /* NV_PVIDEO_INTR_EN_BUFFER */ | |
11086 | 375 // VID_AND32 (info->chip.PVIDEO, 0x140, ~0x11); |
10954 | 376 break; |
377 case NV_ARCH_03: | |
378 case NV_ARCH_04: | |
379 /* NV_PVIDEO_KEY */ | |
380 VID_WR32 (info->chip.PVIDEO, 0x240, info->colorkey); | |
381 /* NV_PVIDEO_OVERLAY_VIDEO_OFF */ | |
382 VID_AND32 (info->chip.PVIDEO, 0x244, ~0x01); | |
383 /* NV_PVIDEO_INTR_EN_0_NOTIFY */ | |
11086 | 384 // VID_AND32 (info->chip.PVIDEO, 0x140, ~0x01); |
10954 | 385 /* NV_PVIDEO_OE_STATE */ |
386 VID_WR32 (info->chip.PVIDEO, 0x224, 0); | |
387 /* NV_PVIDEO_SU_STATE */ | |
388 VID_WR32 (info->chip.PVIDEO, 0x228, 0); | |
389 /* NV_PVIDEO_RM_STATE */ | |
390 VID_WR32 (info->chip.PVIDEO, 0x22C, 0); | |
391 break; | |
392 } | |
393 } | |
394 | |
395 /* Get pan offset of the physical screen. */ | |
396 static uint32_t rivatv_overlay_pan (struct rivatv_info *info){ | |
397 uint32_t pan; | |
398 info->chip.lock (&info->chip, 0); | |
399 VID_WR08 (info->chip.PCIO, 0x3D4, 0x0D); | |
400 pan = VID_RD08 (info->chip.PCIO, 0x3D5); | |
401 VID_WR08 (info->chip.PCIO, 0x3D4, 0x0C); | |
402 pan |= VID_RD08 (info->chip.PCIO, 0x3D5) << 8; | |
403 VID_WR08 (info->chip.PCIO, 0x3D4, 0x19); | |
404 pan |= (VID_RD08 (info->chip.PCIO, 0x3D5) & 0x1F) << 16; | |
405 VID_WR08 (info->chip.PCIO, 0x3D4, 0x2D); | |
406 pan |= (VID_RD08 (info->chip.PCIO, 0x3D5) & 0x60) << 16; | |
407 return pan << 2; | |
408 } | |
409 | |
410 /* Compute and set colorkey depending on the colour depth. */ | |
411 static void rivatv_overlay_colorkey (rivatv_info* info, unsigned int chromakey){ | |
412 uint32_t r, g, b, key = 0; | |
413 r = (chromakey & 0x00FF0000) >> 16; | |
414 g = (chromakey & 0x0000FF00) >> 8; | |
415 b = chromakey & 0x000000FF; | |
416 switch (info->depth) { | |
417 case 15: | |
418 key = ((r >> 3) << 10) | ((g >> 3) << 5) | ((b >> 3)); | |
419 break; | |
420 case 16: | |
421 key = ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3)); | |
422 break; | |
423 case 24: | |
424 key = chromakey & 0x00FFFFFF; | |
425 break; | |
426 case 32: | |
427 key = chromakey; | |
428 break; | |
429 } | |
11086 | 430 if(!info->use_colorkey)return; |
10954 | 431 switch (info->chip.arch) { |
432 case NV_ARCH_10: | |
433 case NV_ARCH_20: | |
434 case NV_ARCH_30: | |
435 VID_WR32 (info->chip.PVIDEO, 0xB00, key); | |
436 break; | |
437 case NV_ARCH_03: | |
438 case NV_ARCH_04: | |
439 VID_WR32 (info->chip.PVIDEO, 0x240, key); | |
440 break; | |
441 } | |
442 } | |
443 | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
444 static void nv_waitidle(struct rivatv_info *info ){ |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
445 while (info->chip.PGRAPH[0x1C0] & 1) {} |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
446 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
447 |
11085 | 448 static void nv_getscreenproperties(struct rivatv_info *info){ |
449 uint32_t bpp=0; | |
450 info->chip.lock(&info->chip, 0); | |
451 /*get screen depth*/ | |
452 VID_WR08(info->chip.PCIO, 0x03D4,0x28); | |
453 bpp = VID_RD08(info->chip.PCIO,0x03D5); | |
454 if(bpp==3)bpp=4; | |
455 if((bpp == 2) && (info->chip.PVIDEO[0x00000600/4] & 0x00001000) == 0x0)info->depth=15; | |
456 else info->depth = bpp*8; | |
457 /*get screen width*/ | |
458 VID_WR08(info->chip.PCIO, 0x03D4, 0x1); | |
459 info->screen_x = (1 + VID_RD08(info->chip.PCIO, 0x3D5)) * 8; | |
460 /*get screen height*/ | |
461 /* get first 8 bits in VT_DISPLAY_END*/ | |
462 VID_WR08(info->chip.PCIO, 0x03D4, 0x12); | |
463 info->screen_y = VID_RD08(info->chip.PCIO,0x03D5); | |
464 VID_WR08(info->chip.PCIO,0x03D4,0x07); | |
465 /* get 9th bit in CRTC_OVERFLOW*/ | |
466 info->screen_y |= (VID_RD08(info->chip.PCIO,0x03D5) &0x02)<<7; | |
467 /* and the 10th in CRTC_OVERFLOW*/ | |
468 info->screen_y |=(VID_RD08(info->chip.PCIO,0x03D5) &0x40)<<3; | |
469 ++info->screen_y; | |
470 } | |
471 | |
472 | |
473 | |
10954 | 474 |
475 /* Start overlay video. */ | |
476 void rivatv_overlay_start (struct rivatv_info *info,int bufno){ | |
11085 | 477 uint32_t base, size, offset, xscale, yscale, pan; |
11086 | 478 uint32_t value; |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
479 int x=8, y=8; |
10954 | 480 int lwidth=info->d_width, lheight=info->d_height; |
481 int bps; | |
482 | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
483 size = info->buffer_size; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
484 base = info->picture_offset; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
485 offset = bufno*size; |
10954 | 486 /*update depth & dimensions here because it may change with vo vesa or vo fbdev*/ |
11085 | 487 nv_getscreenproperties(info); |
488 | |
489 if(info->depth){ | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
490 bps = info->screen_x * ((info->depth+1)/8); |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
491 /* 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
|
492 pan = rivatv_overlay_pan (info); |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
493 /* adjust window position depending on the pan offset */ |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
494 x = info->wx - (pan % bps) * 8 / info->depth; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
495 y = info->wy - (pan / bps); |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
496 /* adjust negative output window variables */ |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
497 if (x < 0) { |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
498 lwidth = info->d_width + x; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
499 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
|
500 // 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
|
501 x = 0; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
502 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
503 if (y < 0) { |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
504 lheight = info->d_height + y; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
505 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
|
506 // 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
|
507 y = 0; |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
508 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
509 } |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
510 |
10954 | 511 switch (info->chip.arch) { |
512 case NV_ARCH_10: | |
513 case NV_ARCH_20: | |
514 case NV_ARCH_30: | |
515 | |
516 /* NV_PVIDEO_BASE */ | |
517 VID_WR32 (info->chip.PVIDEO, 0x900 + 0, base); | |
518 //VID_WR32 (info->chip.PVIDEO, 0x900 + 4, base); | |
519 /* NV_PVIDEO_LIMIT */ | |
520 VID_WR32 (info->chip.PVIDEO, 0x908 + 0, base + size - 1); | |
521 //VID_WR32 (info->chip.PVIDEO, 0x908 + 4, base + size - 1); | |
522 | |
523 /* extra code for NV20 && NV30 architectures */ | |
524 if (info->chip.arch == NV_ARCH_20 || info->chip.arch == NV_ARCH_30) { | |
525 VID_WR32 (info->chip.PVIDEO, 0x800 + 0, base); | |
526 //VID_WR32 (info->chip.PVIDEO, 0x800 + 4, base); | |
527 VID_WR32 (info->chip.PVIDEO, 0x808 + 0, base + size - 1); | |
528 //VID_WR32 (info->chip.PVIDEO, 0x808 + 4, base + size - 1); | |
529 } | |
530 | |
531 /* NV_PVIDEO_LUMINANCE */ | |
532 VID_WR32 (info->chip.PVIDEO, 0x910 + 0, 0x00001000); | |
533 //VID_WR32 (info->chip.PVIDEO, 0x910 + 4, 0x00001000); | |
534 /* NV_PVIDEO_CHROMINANCE */ | |
535 VID_WR32 (info->chip.PVIDEO, 0x918 + 0, 0x00001000); | |
536 //VID_WR32 (info->chip.PVIDEO, 0x918 + 4, 0x00001000); | |
537 | |
538 /* NV_PVIDEO_OFFSET */ | |
539 VID_WR32 (info->chip.PVIDEO, 0x920 + 0, offset + 0); | |
540 //VID_WR32 (info->chip.PVIDEO, 0x920 + 4, offset + pitch); | |
541 /* NV_PVIDEO_SIZE_IN */ | |
542 VID_WR32 (info->chip.PVIDEO, 0x928 + 0, ((info->height) << 16) | info->width); | |
543 //VID_WR32 (info->chip.PVIDEO, 0x928 + 4, ((port->org_height/2) << 16) | port->org_width); | |
544 /* NV_PVIDEO_POINT_IN */ | |
545 VID_WR32 (info->chip.PVIDEO, 0x930 + 0, 0x00000000); | |
546 //VID_WR32 (info->chip.PVIDEO, 0x930 + 4, 0x00000000); | |
547 /* NV_PVIDEO_DS_DX_RATIO */ | |
548 VID_WR32 (info->chip.PVIDEO, 0x938 + 0, (info->width << 20) / info->d_width); | |
549 //VID_WR32 (info->chip.PVIDEO, 0x938 + 4, (port->org_width << 20) / window->width); | |
550 /* NV_PVIDEO_DT_DY_RATIO */ | |
551 VID_WR32 (info->chip.PVIDEO, 0x940 + 0, ((info->height) << 20) / info->d_height); | |
552 //VID_WR32 (info->chip.PVIDEO, 0x940 + 4, ((port->org_height/2) << 20) / window->height); | |
553 | |
554 /* NV_PVIDEO_POINT_OUT */ | |
555 VID_WR32 (info->chip.PVIDEO, 0x948 + 0, ((y + 0) << 16) | x); | |
556 //VID_WR32 (info->chip.PVIDEO, 0x948 + 4, ((y + 0) << 16) | x); | |
557 /* NV_PVIDEO_SIZE_OUT */ | |
558 VID_WR32 (info->chip.PVIDEO, 0x950 + 0, (lheight << 16) | lwidth); | |
559 //VID_WR32 (info->chip.PVIDEO, 0x950 + 4, (height << 16) | width); | |
560 | |
561 /* NV_PVIDEO_FORMAT */ | |
11086 | 562 value = info->pitch; |
563 if(info->use_colorkey)value |= 1 << 20; | |
564 if(info->format == IMGFMT_YUY2)value |= 1 << 16; | |
565 VID_WR32 (info->chip.PVIDEO, 0x958 + 0, value); | |
566 //VID_WR32 (info->chip.PVIDEO, 0x958 + 4, (pitch << 1) | 0x00100000); | |
10954 | 567 |
568 /* NV_PVIDEO_INTR_EN_BUFFER */ | |
11086 | 569 // VID_OR32 (info->chip.PVIDEO, 0x140, 0x01/*0x11*/); |
10954 | 570 /* NV_PVIDEO_STOP */ |
11086 | 571 VID_WR32 (info->chip.PVIDEO, 0x704,0x0); |
10954 | 572 /* NV_PVIDEO_BUFFER */ |
11086 | 573 VID_WR32 (info->chip.PVIDEO, 0x700, 0x01/*0x11*/); |
10954 | 574 break; |
575 | |
576 case NV_ARCH_03: | |
577 case NV_ARCH_04: | |
578 | |
579 | |
580 /* NV_PVIDEO_OE_STATE */ | |
581 VID_WR32 (info->chip.PVIDEO, 0x224, 0); | |
582 /* NV_PVIDEO_SU_STATE */ | |
583 VID_WR32 (info->chip.PVIDEO, 0x228, 0); | |
584 /* NV_PVIDEO_RM_STATE */ | |
585 VID_WR32 (info->chip.PVIDEO, 0x22C, 0); | |
586 | |
587 /* NV_PVIDEO_BUFF0_START_ADDRESS */ | |
588 VID_WR32 (info->chip.PVIDEO, 0x20C + 0, base + offset + 0); | |
589 VID_WR32 (info->chip.PVIDEO, 0x20C + 4, base + offset + 0); | |
590 /* NV_PVIDEO_BUFF0_PITCH_LENGTH */ | |
591 VID_WR32 (info->chip.PVIDEO, 0x214 + 0, info->pitch); | |
592 VID_WR32 (info->chip.PVIDEO, 0x214 + 4, info->pitch); | |
593 | |
594 /* NV_PVIDEO_WINDOW_START */ | |
595 VID_WR32 (info->chip.PVIDEO, 0x230, (y << 16) | x); | |
596 /* NV_PVIDEO_WINDOW_SIZE */ | |
597 VID_WR32 (info->chip.PVIDEO, 0x234, (lheight << 16) | lwidth); | |
598 /* NV_PVIDEO_STEP_SIZE */ | |
599 yscale = ((info->height - 1) << 11) / (info->d_height - 1); | |
600 xscale = ((info->width - 1) << 11) / (info->d_width - 1); | |
601 VID_WR32 (info->chip.PVIDEO, 0x200, (yscale << 16) | xscale); | |
602 | |
603 /* NV_PVIDEO_RED_CSC_OFFSET */ | |
604 VID_WR32 (info->chip.PVIDEO, 0x280, 0x69); | |
605 /* NV_PVIDEO_GREEN_CSC_OFFSET */ | |
606 VID_WR32 (info->chip.PVIDEO, 0x284, 0x3e); | |
607 /* NV_PVIDEO_BLUE_CSC_OFFSET */ | |
608 VID_WR32 (info->chip.PVIDEO, 0x288, 0x89); | |
609 /* NV_PVIDEO_CSC_ADJUST */ | |
610 VID_WR32 (info->chip.PVIDEO, 0x28C, 0x00000); /* No colour correction! */ | |
611 | |
612 /* NV_PVIDEO_CONTROL_Y (BLUR_ON, LINE_HALF) */ | |
613 VID_WR32 (info->chip.PVIDEO, 0x204, 0x001); | |
614 /* NV_PVIDEO_CONTROL_X (WEIGHT_HEAVY, SHARPENING_ON, SMOOTHING_ON) */ | |
11086 | 615 VID_WR32 (info->chip.PVIDEO, 0x208, 0x111); /*directx overlay 0x110 */ |
10954 | 616 |
617 /* NV_PVIDEO_FIFO_BURST_LENGTH */ | |
618 VID_WR32 (info->chip.PVIDEO, 0x23C, 0x03); | |
619 /* NV_PVIDEO_FIFO_THRES_SIZE */ | |
620 VID_WR32 (info->chip.PVIDEO, 0x238, 0x38); /*windows uses 0x40*/ | |
621 | |
622 /* NV_PVIDEO_BUFF0_OFFSET */ | |
623 VID_WR32 (info->chip.PVIDEO, 0x21C + 0, 0); | |
624 VID_WR32 (info->chip.PVIDEO, 0x21C + 4, 0); | |
625 | |
626 /* NV_PVIDEO_INTR_EN_0_NOTIFY_ENABLED */ | |
627 // VID_OR32 (info->chip.PVIDEO, 0x140, 0x01); | |
11086 | 628 |
10954 | 629 /* NV_PVIDEO_OVERLAY (KEY_ON, VIDEO_ON, FORMAT_CCIR) */ |
11086 | 630 value = 0x1; /*video on*/ |
631 if(info->format==IMGFMT_YUY2)value |= 0x100; | |
632 if(info->use_colorkey)value |=0x10; | |
633 VID_WR32 (info->chip.PVIDEO, 0x244, value); | |
634 | |
10954 | 635 /* NV_PVIDEO_SU_STATE */ |
636 VID_XOR32 (info->chip.PVIDEO, 0x228, 1 << 16); | |
637 break; | |
638 } | |
639 /*set colorkey*/ | |
640 rivatv_overlay_colorkey(info,info->vidixcolorkey); | |
641 | |
642 } | |
643 | |
644 | |
10977
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
645 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
646 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
647 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
648 |
3da6b1de1c33
make it work in textmode again && support for nv03 with 4MB RAM
faust3
parents:
10970
diff
changeset
|
649 |
10954 | 650 static rivatv_info* info; |
651 | |
652 | |
653 | |
654 | |
655 int vixInit(void){ | |
656 int mtrr; | |
657 info = (rivatv_info*)calloc(1,sizeof(rivatv_info)); | |
658 info->control_base = map_phys_mem(pci_info.base0, 0x00C00000 + 0x00008000); | |
659 info->chip.arch = nvidia_card_ids[find_chip(pci_info.device)].arch; | |
660 printf("[nvidia_vid] arch %x register base %x\n",info->chip.arch,(unsigned int)info->control_base); | |
661 info->chip.PFIFO = (uint32_t *) (info->control_base + 0x00002000); | |
662 info->chip.FIFO = (uint32_t *) (info->control_base + 0x00800000); | |
663 info->chip.PMC = (uint32_t *) (info->control_base + 0x00000000); | |
664 info->chip.PFB = (uint32_t *) (info->control_base + 0x00100000); | |
665 info->chip.PME = (uint32_t *) (info->control_base + 0x00000000); | |
666 info->chip.PCIO = (uint8_t *) (info->control_base + 0x00601000); | |
667 info->chip.PVIO = (uint8_t *) (info->control_base + 0x000C0000); | |
668 info->chip.PGRAPH = (uint32_t *) (info->control_base + 0x00400000); | |
669 /* setup chip specific functions */ | |
670 switch (info->chip.arch) { | |
671 case NV_ARCH_03: | |
672 info->chip.lock = rivatv_lock_nv03; | |
673 info->chip.fbsize = rivatv_fbsize_nv03 (&info->chip); | |
674 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00680000); | |
675 break; | |
676 case NV_ARCH_04: | |
677 info->chip.lock = rivatv_lock_nv04; | |
678 info->chip.fbsize = rivatv_fbsize_nv04 (&info->chip); | |
679 info->chip.PRAMIN = (uint32_t *) (info->control_base + 0x00700000); | |
680 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00680000); | |
681 break; | |
682 case NV_ARCH_10: | |
683 case NV_ARCH_20: | |
684 case NV_ARCH_30: | |
685 info->chip.lock = rivatv_lock_nv04; | |
686 info->chip.fbsize = rivatv_fbsize_nv10 (&info->chip); | |
687 info->chip.PRAMIN = (uint32_t *) (info->control_base + 0x00700000); | |
688 info->chip.PVIDEO = (uint32_t *) (info->control_base + 0x00008000); | |
689 break; | |
690 } | |
691 switch (info->chip.arch) { | |
692 case NV_ARCH_03: | |
693 { | |
694 /* This maps framebuffer @6MB, thus 2MB are left for video. */ | |
695 info->video_base = map_phys_mem(pci_info.base1, info->chip.fbsize); | |
696 /* 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
|
697 info->picture_offset = 1024*768* 4 * ((info->chip.fbsize > 4194304)?2:1); |
10954 | 698 info->picture_base = (uint32_t) info->video_base + info->picture_offset; |
699 info->chip.PRAMIN = (uint32_t *) (info->video_base + 0x00C00000); | |
700 break; | |
701 } | |
702 case NV_ARCH_04: | |
703 case NV_ARCH_10: | |
704 case NV_ARCH_20: | |
705 case NV_ARCH_30: | |
706 { | |
707 info->video_base = map_phys_mem(pci_info.base1, info->chip.fbsize); | |
708 info->picture_offset = info->chip.fbsize - NV04_BES_SIZE; | |
709 // info->picture_base = (unsigned long)map_phys_mem(pci_info.base1+info->picture_offset,NV04_BES_SIZE); | |
710 info->picture_base = (uint32_t) info->video_base + info->picture_offset; | |
711 break; | |
712 } | |
713 } | |
714 | |
715 printf("[nvidia_vid] detected memory size %u MB\n",(uint32_t)(info->chip.fbsize /1024/1024)); | |
716 | |
717 if ((mtrr = mtrr_set_type(pci_info.base1, info->chip.fbsize, MTRR_TYPE_WRCOMB))!= 0) | |
11085 | 718 printf("[nvidia_vid] unable to setup MTRR: %s\n", strerror(mtrr)); |
10954 | 719 else |
11085 | 720 printf("[nvidia_vid] MTRR set up\n"); |
10954 | 721 |
11085 | 722 nv_getscreenproperties(info); |
723 if(!info->depth)printf("[nvidia_vid] text mode: %ux%u\n",info->screen_x,info->screen_y); | |
724 else printf("[nvidia_vid] video mode: %ux%u@%u\n",info->screen_x,info->screen_y, info->depth); | |
725 | |
10954 | 726 |
727 rivatv_enable_PMEDIA(info); | |
728 info->next_frame = 0; | |
11086 | 729 info->use_colorkey = 1; |
10954 | 730 return 0; |
731 } | |
732 | |
733 void vixDestroy(void){ | |
734 unmap_phys_mem(info->control_base ,0x00C00000 + 0x00008000); | |
735 unmap_phys_mem(info->video_base, info->chip.fbsize); | |
736 free(info); | |
737 } | |
738 | |
739 int vixGetCapability(vidix_capability_t *to){ | |
740 memcpy(to, &nvidia_cap, sizeof(vidix_capability_t)); | |
741 return 0; | |
742 } | |
743 | |
744 inline static int is_supported_fourcc(uint32_t fourcc) | |
745 { | |
11086 | 746 if (fourcc == IMGFMT_UYVY || fourcc == IMGFMT_YUY2) |
10954 | 747 return 1; |
748 else | |
749 return 0; | |
750 } | |
751 | |
752 int vixQueryFourcc(vidix_fourcc_t *to){ | |
753 if(is_supported_fourcc(to->fourcc)){ | |
754 to->depth = VID_DEPTH_1BPP | VID_DEPTH_2BPP | | |
755 VID_DEPTH_4BPP | VID_DEPTH_8BPP | | |
756 VID_DEPTH_12BPP| VID_DEPTH_15BPP| | |
757 VID_DEPTH_16BPP| VID_DEPTH_24BPP| | |
758 VID_DEPTH_32BPP; | |
759 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; | |
760 return 0; | |
761 } | |
762 else to->depth = to->flags = 0; | |
763 return ENOSYS; | |
764 } | |
765 | |
766 int vixConfigPlayback(vidix_playback_t *vinfo){ | |
767 uint32_t i; | |
768 printf("called %s\n", __FUNCTION__); | |
769 if (! is_supported_fourcc(vinfo->fourcc)) | |
770 return ENOSYS; | |
771 | |
772 info->width = vinfo->src.w; | |
773 info->height = vinfo->src.h; | |
774 | |
775 info->d_width = vinfo->dest.w; | |
776 info->d_height = vinfo->dest.h; | |
777 info->wx = vinfo->dest.x; | |
778 info->wy = vinfo->dest.y; | |
779 info->format = vinfo->fourcc; | |
780 | |
781 printf("[nvidia_vid] setting up a %dx%d-%dx%d video window (src %dx%d), format 0x%X\n", | |
782 info->d_width, info->d_height, info->wx, info->wy, info->width, info->height, vinfo->fourcc); | |
783 | |
784 | |
785 vinfo->dga_addr=(void*)(info->picture_base); | |
786 | |
787 switch (vinfo->fourcc) | |
788 { | |
789 case IMGFMT_YUY2: | |
790 case IMGFMT_UYVY: | |
791 | |
11086 | 792 vinfo->dest.pitch.y = 16; |
10954 | 793 vinfo->dest.pitch.u = 0; |
794 vinfo->dest.pitch.v = 0; | |
795 | |
796 vinfo->offset.y = 0; | |
797 vinfo->offset.v = 0; | |
798 vinfo->offset.u = 0; | |
799 | |
800 info->pitch = info->width << 1; | |
801 vinfo->frame_size = info->pitch * info->height; | |
802 break; | |
803 case IMGFMT_YV12: | |
804 vinfo->dest.pitch.y = 1; | |
805 vinfo->dest.pitch.u = 1; | |
806 vinfo->dest.pitch.v = 1; | |
807 | |
808 vinfo->offset.y = 0; | |
809 vinfo->offset.v = (info->width) * info->height; | |
810 vinfo->offset.u = vinfo->offset.v * 5 / 4; | |
811 | |
812 info->pitch = info->width + (info->width >> 1); | |
813 vinfo->frame_size = info->pitch * info->height; | |
814 break; | |
815 } | |
816 info->buffer_size = vinfo->frame_size; | |
817 info->num_frames = vinfo->num_frames= (info->chip.fbsize - info->picture_offset)/vinfo->frame_size; | |
818 if(vinfo->num_frames > MAX_FRAMES)vinfo->num_frames = MAX_FRAMES; | |
819 // vinfo->num_frames = 1; | |
820 // printf("[nvidia_vid] Number of frames %i\n",vinfo->num_frames); | |
821 for(i=0;i <vinfo->num_frames;i++)vinfo->offsets[i] = vinfo->frame_size*i; | |
822 return 0; | |
823 } | |
824 | |
825 int vixPlaybackOn(void){ | |
826 rivatv_overlay_start(info,info->next_frame); | |
827 return 0; | |
828 } | |
829 | |
830 int vixPlaybackOff(void){ | |
831 rivatv_overlay_stop(info); | |
832 return 0; | |
833 } | |
834 | |
835 int vixSetGrKeys( const vidix_grkey_t * grkey){ | |
836 info->vidixcolorkey = ((grkey->ckey.red<<16)|(grkey->ckey.green<<8)|grkey->ckey.blue); | |
837 printf("[nvidia_vid] set colorkey 0x%x\n",info->vidixcolorkey); | |
838 rivatv_overlay_colorkey(info,info->vidixcolorkey); | |
839 return 0; | |
840 } | |
841 | |
842 int vixPlaybackFrameSelect(unsigned int frame){ | |
843 // printf("selecting buffer %d\n", frame); | |
844 rivatv_overlay_start(info, frame); | |
845 if (info->num_frames >= 1) | |
846 info->next_frame = (frame+1)%info->num_frames; | |
847 return 0; | |
848 } |