annotate vidix/drivers/nvidia_vid.c @ 5540:80d8fed6e683

new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
author arpi
date Tue, 09 Apr 2002 14:02:55 +0000
parents 9bdf337bd078
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4126
5ee0a20cc791 started
alex
parents:
diff changeset
1 #include <errno.h>
5ee0a20cc791 started
alex
parents:
diff changeset
2 #include <stdio.h>
5ee0a20cc791 started
alex
parents:
diff changeset
3 #include <stdlib.h>
5ee0a20cc791 started
alex
parents:
diff changeset
4 #include <string.h>
5ee0a20cc791 started
alex
parents:
diff changeset
5 #include <math.h>
5ee0a20cc791 started
alex
parents:
diff changeset
6 #include <inttypes.h>
5ee0a20cc791 started
alex
parents:
diff changeset
7
5ee0a20cc791 started
alex
parents:
diff changeset
8 #include "../vidix.h"
5ee0a20cc791 started
alex
parents:
diff changeset
9 #include "../fourcc.h"
5ee0a20cc791 started
alex
parents:
diff changeset
10 #include "../../libdha/libdha.h"
5ee0a20cc791 started
alex
parents:
diff changeset
11 #include "../../libdha/pci_ids.h"
5ee0a20cc791 started
alex
parents:
diff changeset
12 #include "../../libdha/pci_names.h"
5ee0a20cc791 started
alex
parents:
diff changeset
13
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
14 #include "nvidia.h"
4126
5ee0a20cc791 started
alex
parents:
diff changeset
15
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
16 static void *ctrl_base = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
17 static void *fb_base = 0;
4126
5ee0a20cc791 started
alex
parents:
diff changeset
18 static int32_t overlay_offset = 0;
5ee0a20cc791 started
alex
parents:
diff changeset
19 static uint32_t ram_size = 0;
5ee0a20cc791 started
alex
parents:
diff changeset
20
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
21 static unsigned int *PFB;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
22 static unsigned int *PCIO;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
23 static unsigned int *PGRAPH;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
24 static unsigned int *PRAMIN;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
25 static unsigned int *FIFO;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
26 static unsigned int *PMC;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
27
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
28 typedef unsigned char U008;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
29
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
30 #define NV_WR08(p,i,d) (((U008 *)(p))[i]=(d))
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
31
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
32 unsigned int nv_fifo_space = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
33
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
34 void CRTCout(unsigned char index, unsigned char val)
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
35 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
36 NV_WR08(PCIO, 0x3d4, index);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
37 NV_WR08(PCIO, 0x3d5, val);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
38 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
39
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
40 volatile RivaScaledImage *ScaledImage;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
41
4175
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
42 #define CARD_FLAGS_NONE 0x00
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
43 #define CARD_FLAGS_NOTSUPPORTED 0x01
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
44
4126
5ee0a20cc791 started
alex
parents:
diff changeset
45 struct nv_card_id_s
5ee0a20cc791 started
alex
parents:
diff changeset
46 {
5ee0a20cc791 started
alex
parents:
diff changeset
47 const unsigned int id ;
4191
62a6135d090e + new features and possibility
nick
parents: 4175
diff changeset
48 const char name[32];
4175
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
49 const int core;
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
50 const int flags;
4126
5ee0a20cc791 started
alex
parents:
diff changeset
51 };
5ee0a20cc791 started
alex
parents:
diff changeset
52
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
53 static const struct nv_card_id_s nv_card_id;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
54
4126
5ee0a20cc791 started
alex
parents:
diff changeset
55 static const struct nv_card_id_s nv_card_ids[]=
5ee0a20cc791 started
alex
parents:
diff changeset
56 {
4175
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
57 { DEVICE_NVIDIA_RIVA_TNT2_NV5, "nVidia TNT2 (NV5) ", 5, CARD_FLAGS_NOTSUPPORTED},
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
58 { DEVICE_NVIDIA_VANTA_NV6, "nVidia Vanta (NV6.1)", 6, CARD_FLAGS_NOTSUPPORTED},
4191
62a6135d090e + new features and possibility
nick
parents: 4175
diff changeset
59 { DEVICE_NVIDIA_VANTA_NV62, "nVidia Vanta (NV6.2)", 6, CARD_FLAGS_NOTSUPPORTED}
4126
5ee0a20cc791 started
alex
parents:
diff changeset
60 };
5ee0a20cc791 started
alex
parents:
diff changeset
61
5ee0a20cc791 started
alex
parents:
diff changeset
62 static int find_chip(unsigned int chip_id)
5ee0a20cc791 started
alex
parents:
diff changeset
63 {
5ee0a20cc791 started
alex
parents:
diff changeset
64 unsigned int i;
5ee0a20cc791 started
alex
parents:
diff changeset
65
5ee0a20cc791 started
alex
parents:
diff changeset
66 for (i = 0; i < sizeof(nv_card_ids)/sizeof(struct nv_card_id_s); i++)
5ee0a20cc791 started
alex
parents:
diff changeset
67 if (chip_id == nv_card_ids[i].id)
5ee0a20cc791 started
alex
parents:
diff changeset
68 return(i);
5ee0a20cc791 started
alex
parents:
diff changeset
69 return(-1);
5ee0a20cc791 started
alex
parents:
diff changeset
70 }
5ee0a20cc791 started
alex
parents:
diff changeset
71
5ee0a20cc791 started
alex
parents:
diff changeset
72 static pciinfo_t pci_info;
5ee0a20cc791 started
alex
parents:
diff changeset
73 static int probed = 0;
5ee0a20cc791 started
alex
parents:
diff changeset
74
5ee0a20cc791 started
alex
parents:
diff changeset
75 /* VIDIX exports */
5ee0a20cc791 started
alex
parents:
diff changeset
76
5ee0a20cc791 started
alex
parents:
diff changeset
77 static vidix_capability_t nvidia_cap =
5ee0a20cc791 started
alex
parents:
diff changeset
78 {
5ee0a20cc791 started
alex
parents:
diff changeset
79 "NVIDIA driver for VIDIX",
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
80 "alex",
4126
5ee0a20cc791 started
alex
parents:
diff changeset
81 TYPE_OUTPUT,
4191
62a6135d090e + new features and possibility
nick
parents: 4175
diff changeset
82 { 0, 0, 0, 0 },
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
83 2046,
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
84 2047,
4126
5ee0a20cc791 started
alex
parents:
diff changeset
85 4,
5ee0a20cc791 started
alex
parents:
diff changeset
86 4,
5ee0a20cc791 started
alex
parents:
diff changeset
87 -1,
5ee0a20cc791 started
alex
parents:
diff changeset
88 FLAG_NONE,
5ee0a20cc791 started
alex
parents:
diff changeset
89 VENDOR_NVIDIA,
5ee0a20cc791 started
alex
parents:
diff changeset
90 0,
5ee0a20cc791 started
alex
parents:
diff changeset
91 { 0, 0, 0, 0 }
5ee0a20cc791 started
alex
parents:
diff changeset
92 };
5ee0a20cc791 started
alex
parents:
diff changeset
93
5ee0a20cc791 started
alex
parents:
diff changeset
94 unsigned int vixGetVersion(void)
5ee0a20cc791 started
alex
parents:
diff changeset
95 {
5ee0a20cc791 started
alex
parents:
diff changeset
96 return(VIDIX_VERSION);
5ee0a20cc791 started
alex
parents:
diff changeset
97 }
5ee0a20cc791 started
alex
parents:
diff changeset
98
4191
62a6135d090e + new features and possibility
nick
parents: 4175
diff changeset
99 int vixProbe(int verbose,int force)
4126
5ee0a20cc791 started
alex
parents:
diff changeset
100 {
5ee0a20cc791 started
alex
parents:
diff changeset
101 pciinfo_t lst[MAX_PCI_DEVICES];
5ee0a20cc791 started
alex
parents:
diff changeset
102 unsigned int i, num_pci;
5ee0a20cc791 started
alex
parents:
diff changeset
103 int err;
5ee0a20cc791 started
alex
parents:
diff changeset
104
5ee0a20cc791 started
alex
parents:
diff changeset
105 printf("[nvidia] probe\n");
5ee0a20cc791 started
alex
parents:
diff changeset
106
5ee0a20cc791 started
alex
parents:
diff changeset
107 err = pci_scan(lst, &num_pci);
5ee0a20cc791 started
alex
parents:
diff changeset
108 if (err)
5ee0a20cc791 started
alex
parents:
diff changeset
109 {
5ee0a20cc791 started
alex
parents:
diff changeset
110 printf("Error occured during pci scan: %s\n", strerror(err));
5ee0a20cc791 started
alex
parents:
diff changeset
111 return err;
5ee0a20cc791 started
alex
parents:
diff changeset
112 }
5ee0a20cc791 started
alex
parents:
diff changeset
113 else
5ee0a20cc791 started
alex
parents:
diff changeset
114 {
5ee0a20cc791 started
alex
parents:
diff changeset
115 err = ENXIO;
5ee0a20cc791 started
alex
parents:
diff changeset
116
5ee0a20cc791 started
alex
parents:
diff changeset
117 for (i = 0; i < num_pci; i++)
5ee0a20cc791 started
alex
parents:
diff changeset
118 {
5ee0a20cc791 started
alex
parents:
diff changeset
119 if (lst[i].vendor == VENDOR_NVIDIA)
5ee0a20cc791 started
alex
parents:
diff changeset
120 {
5ee0a20cc791 started
alex
parents:
diff changeset
121 int idx;
5ee0a20cc791 started
alex
parents:
diff changeset
122
5ee0a20cc791 started
alex
parents:
diff changeset
123 idx = find_chip(lst[i].device);
5ee0a20cc791 started
alex
parents:
diff changeset
124 if (idx == -1)
5ee0a20cc791 started
alex
parents:
diff changeset
125 continue;
4175
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
126 if (nv_card_ids[idx].flags & CARD_FLAGS_NOTSUPPORTED)
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
127 {
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
128 printf("Found chip: %s, but not supported!\n",
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
129 nv_card_ids[idx].name);
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
130 continue;
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
131 }
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
132 else
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
133
8110b321f2ca commited due to request of nexus
alex
parents: 4126
diff changeset
134 printf("Found chip: %s\n", nv_card_ids[idx].name);
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
135
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
136 memcpy(&nv_card_id, &nv_card_ids[idx], sizeof(struct nv_card_id_s));
4126
5ee0a20cc791 started
alex
parents:
diff changeset
137 nvidia_cap.device_id = nv_card_ids[idx].id;
5ee0a20cc791 started
alex
parents:
diff changeset
138 err = 0;
5ee0a20cc791 started
alex
parents:
diff changeset
139 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
5ee0a20cc791 started
alex
parents:
diff changeset
140 probed = 1;
5ee0a20cc791 started
alex
parents:
diff changeset
141
5ee0a20cc791 started
alex
parents:
diff changeset
142 printf("bus:card:func = %x:%x:%x\n",
5ee0a20cc791 started
alex
parents:
diff changeset
143 pci_info.bus, pci_info.card, pci_info.func);
5ee0a20cc791 started
alex
parents:
diff changeset
144 printf("vendor:device = %x:%x\n",
5ee0a20cc791 started
alex
parents:
diff changeset
145 pci_info.vendor, pci_info.device);
5ee0a20cc791 started
alex
parents:
diff changeset
146 printf("base0:base1:base2:baserom = %x:%x:%x:%x\n",
5ee0a20cc791 started
alex
parents:
diff changeset
147 pci_info.base0, pci_info.base1, pci_info.base2,
5ee0a20cc791 started
alex
parents:
diff changeset
148 pci_info.baserom);
5ee0a20cc791 started
alex
parents:
diff changeset
149 break;
5ee0a20cc791 started
alex
parents:
diff changeset
150 }
5ee0a20cc791 started
alex
parents:
diff changeset
151 }
5ee0a20cc791 started
alex
parents:
diff changeset
152 }
5ee0a20cc791 started
alex
parents:
diff changeset
153
5ee0a20cc791 started
alex
parents:
diff changeset
154 if (err)
5ee0a20cc791 started
alex
parents:
diff changeset
155 printf("No chip found\n");
5ee0a20cc791 started
alex
parents:
diff changeset
156 return(err);
5ee0a20cc791 started
alex
parents:
diff changeset
157 }
5ee0a20cc791 started
alex
parents:
diff changeset
158
5ee0a20cc791 started
alex
parents:
diff changeset
159 int vixInit(void)
5ee0a20cc791 started
alex
parents:
diff changeset
160 {
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
161 int card_option;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
162
4126
5ee0a20cc791 started
alex
parents:
diff changeset
163 printf("[nvidia] init\n");
5ee0a20cc791 started
alex
parents:
diff changeset
164
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
165 pci_config_read(pci_info.bus, pci_info.card, pci_info.func, 0x40,
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
166 4, &card_option);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
167 printf("card_option: %x\n", card_option);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
168
4126
5ee0a20cc791 started
alex
parents:
diff changeset
169 if (!probed)
5ee0a20cc791 started
alex
parents:
diff changeset
170 {
5ee0a20cc791 started
alex
parents:
diff changeset
171 printf("Driver was not probed but is being initialized\n");
5ee0a20cc791 started
alex
parents:
diff changeset
172 return(EINTR);
5ee0a20cc791 started
alex
parents:
diff changeset
173 }
5ee0a20cc791 started
alex
parents:
diff changeset
174
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
175 ctrl_base = map_phys_mem(pci_info.base0, 0x00800000);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
176 if (ctrl_base == (void *)-1)
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
177 return(ENOMEM);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
178 fb_base = map_phys_mem(pci_info.base1, 0x01000000);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
179 if (fb_base == (void *)-1)
4126
5ee0a20cc791 started
alex
parents:
diff changeset
180 return(ENOMEM);
5ee0a20cc791 started
alex
parents:
diff changeset
181
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
182 printf("ctrl_base: %p, fb_base: %p\n", ctrl_base, fb_base);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
183
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
184 PFB = ctrl_base+0x00100000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
185 PGRAPH = ctrl_base+0x00400000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
186 PRAMIN = ctrl_base+0x00710000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
187 FIFO = ctrl_base+0x00800000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
188 PCIO = ctrl_base+0x00601000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
189 PMC = ctrl_base+0x00000000;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
190 printf("pfb: %p, pgraph: %p, pramin: %p, fifo: %p, pcio: %p\n",
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
191 PFB, PGRAPH, PRAMIN, FIFO, PCIO);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
192
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
193 ScaledImage = FIFO+0x8000/4;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
194 printf("ScaledImage: %p\n", ScaledImage);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
195
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
196 /* unlock */
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
197 CRTCout(0x11, 0xff);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
198
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
199 printf("fifo_free: %d\n", ScaledImage->fifo_free);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
200
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
201 RIVA_FIFO_FREE(ScaledImage, 10);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
202
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
203 dump_scaledimage(ScaledImage);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
204
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
205 /* create scaled image object */
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
206 *(PRAMIN+0x518) = 0x0100A037;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
207 *(PRAMIN+0x519) = 0x00000C02;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
208
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
209 /* put scaled image object into subchannel */
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
210 *(FIFO+0x2000) = 0x80000011;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
211
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
212 /* ram size detection */
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
213 switch(nv_card_id.core)
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
214 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
215 case 5:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
216 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
217 if (*(PFB+0x0) & 0x00000100)
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
218 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
219 printf("first ver\n");
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
220 ram_size = ((*(PFB+0x0) >> 12) & 0x0f) * 1024 * 2 + 1024 * 2;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
221 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
222 else
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
223 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
224 printf("second ver (code: %d)\n",
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
225 *(PFB+0x0) & 0x00000003);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
226 switch(*(PFB+0x0) & 0x00000003)
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
227 {
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
228 case 0:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
229 ram_size = 1024*32;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
230 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
231 case 1:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
232 ram_size = 1024*4;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
233 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
234 case 2:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
235 ram_size = 1024*8;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
236 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
237 case 3:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
238 ram_size = 1024*16;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
239 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
240 default:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
241 printf("Unknown ram size code: %d\n",
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
242 *(PFB+0x0) & 0x00000003);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
243 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
244 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
245 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
246 break;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
247 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
248 default:
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
249 printf("Unknown core: %d\n", nv_card_id.core);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
250 }
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
251
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
252 printf("ram_size: %d\n", ram_size);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
253 return 0;
4126
5ee0a20cc791 started
alex
parents:
diff changeset
254 }
5ee0a20cc791 started
alex
parents:
diff changeset
255
5ee0a20cc791 started
alex
parents:
diff changeset
256 void vixDestroy(void)
5ee0a20cc791 started
alex
parents:
diff changeset
257 {
5ee0a20cc791 started
alex
parents:
diff changeset
258 printf("[nvidia] destory\n");
5ee0a20cc791 started
alex
parents:
diff changeset
259 }
5ee0a20cc791 started
alex
parents:
diff changeset
260
5ee0a20cc791 started
alex
parents:
diff changeset
261 int vixGetCapability(vidix_capability_t *to)
5ee0a20cc791 started
alex
parents:
diff changeset
262 {
5ee0a20cc791 started
alex
parents:
diff changeset
263 memcpy(to, &nvidia_cap, sizeof(vidix_capability_t));
5ee0a20cc791 started
alex
parents:
diff changeset
264 return(0);
5ee0a20cc791 started
alex
parents:
diff changeset
265 }
5ee0a20cc791 started
alex
parents:
diff changeset
266
5ee0a20cc791 started
alex
parents:
diff changeset
267 int vixQueryFourcc(vidix_fourcc_t *to)
5ee0a20cc791 started
alex
parents:
diff changeset
268 {
5ee0a20cc791 started
alex
parents:
diff changeset
269 printf("[nvidia] query fourcc (%x)\n", to->fourcc);
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
270 to->flags = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
271 to->depth = VID_DEPTH_32BPP;
4126
5ee0a20cc791 started
alex
parents:
diff changeset
272 return 0;
5ee0a20cc791 started
alex
parents:
diff changeset
273 }
5ee0a20cc791 started
alex
parents:
diff changeset
274
5ee0a20cc791 started
alex
parents:
diff changeset
275 int vixConfigPlayback(vidix_playback_t *info)
5ee0a20cc791 started
alex
parents:
diff changeset
276 {
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
277 int fb_pixel_size = 32/8;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
278 int fb_line_len = 1280*4;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
279 char buffer = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
280 int offset = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
281 int x,y,h,w;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
282 int bpp = 32 >> 3;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
283 int size;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
284
4126
5ee0a20cc791 started
alex
parents:
diff changeset
285 printf("[nvidia] config playback\n");
5ee0a20cc791 started
alex
parents:
diff changeset
286
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
287 x = info->src.x;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
288 y = info->src.y;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
289 h = info->src.h;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
290 w = info->src.w;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
291
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
292 w = (w + 1) & ~1;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
293
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
294 size = h * (((w << 1) + 63) & ~63) / bpp;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
295
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
296
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
297 PMC[(0x8900/4)+buffer] = offset;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
298 PMC[(0x8928/4)+buffer] = (h << 16) | w;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
299 PMC[(0x8930/4)+buffer] = ((y << 4) & 0xffff0000) | (x >> 12);
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
300 PMC[(0x8938/4)+buffer] = (w << 20) / info->dest.w;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
301 PMC[(0x8938/4)+buffer] = (h << 20) / info->dest.h;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
302
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
303 info->dga_addr = fb_base + (info->dest.w - info->src.w) * fb_pixel_size /
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
304 2 + (info->dest.h - info->src.h) * fb_line_len / 2;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
305
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
306 info->num_frames = 1;
4126
5ee0a20cc791 started
alex
parents:
diff changeset
307 info->frame_size = info->src.w*info->src.h+(info->src.w*info->src.h)/2;
4327
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
308 info->offsets[0] = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
309 info->offset.y = 0;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
310 info->offset.v = ((info->src.w + 31) & ~31) * info->src.h;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
311 info->offset.u = info->offset.v+((info->src.w + 31) & ~31) * info->src.h / 4;
9bdf337bd078 upgraded to newest vidix interface
alex
parents: 4191
diff changeset
312 // info->dga_addr = malloc(info->num_frames*info->frame_size);
4126
5ee0a20cc791 started
alex
parents:
diff changeset
313 return 0;
5ee0a20cc791 started
alex
parents:
diff changeset
314 }
5ee0a20cc791 started
alex
parents:
diff changeset
315
5ee0a20cc791 started
alex
parents:
diff changeset
316 int vixPlaybackOn(void)
5ee0a20cc791 started
alex
parents:
diff changeset
317 {
5ee0a20cc791 started
alex
parents:
diff changeset
318 printf("[nvidia] playback on\n");
5ee0a20cc791 started
alex
parents:
diff changeset
319 return 0;
5ee0a20cc791 started
alex
parents:
diff changeset
320 }
5ee0a20cc791 started
alex
parents:
diff changeset
321
5ee0a20cc791 started
alex
parents:
diff changeset
322 int vixPlaybackOff(void)
5ee0a20cc791 started
alex
parents:
diff changeset
323 {
5ee0a20cc791 started
alex
parents:
diff changeset
324 printf("[nvidia] playback off\n");
5ee0a20cc791 started
alex
parents:
diff changeset
325 return 0;
5ee0a20cc791 started
alex
parents:
diff changeset
326 }