annotate vidix/drivers/nvidia_vid.c @ 22356:37248dbbf6ff

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