4126
|
1 #include <errno.h>
|
|
2 #include <stdio.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <string.h>
|
|
5 #include <math.h>
|
|
6 #include <inttypes.h>
|
|
7
|
|
8 #include "../vidix.h"
|
|
9 #include "../fourcc.h"
|
|
10 #include "../../libdha/libdha.h"
|
|
11 #include "../../libdha/pci_ids.h"
|
|
12 #include "../../libdha/pci_names.h"
|
|
13
|
|
14 //#include "nvidia.h"
|
|
15
|
|
16 static void *mmio_base = 0;
|
|
17 static void *mem_base = 0;
|
|
18 static int32_t overlay_offset = 0;
|
|
19 static uint32_t ram_size = 0;
|
|
20
|
4175
|
21 #define CARD_FLAGS_NONE 0x00
|
|
22 #define CARD_FLAGS_NOTSUPPORTED 0x01
|
|
23
|
4126
|
24 struct nv_card_id_s
|
|
25 {
|
|
26 const unsigned int id ;
|
4191
|
27 const char name[32];
|
4175
|
28 const int core;
|
|
29 const int flags;
|
4126
|
30 };
|
|
31
|
|
32 static const struct nv_card_id_s nv_card_ids[]=
|
|
33 {
|
4175
|
34 { DEVICE_NVIDIA_RIVA_TNT2_NV5, "nVidia TNT2 (NV5) ", 5, CARD_FLAGS_NOTSUPPORTED},
|
|
35 { DEVICE_NVIDIA_VANTA_NV6, "nVidia Vanta (NV6.1)", 6, CARD_FLAGS_NOTSUPPORTED},
|
4191
|
36 { DEVICE_NVIDIA_VANTA_NV62, "nVidia Vanta (NV6.2)", 6, CARD_FLAGS_NOTSUPPORTED}
|
4126
|
37 };
|
|
38
|
|
39 static int find_chip(unsigned int chip_id)
|
|
40 {
|
|
41 unsigned int i;
|
|
42
|
|
43 for (i = 0; i < sizeof(nv_card_ids)/sizeof(struct nv_card_id_s); i++)
|
|
44 if (chip_id == nv_card_ids[i].id)
|
|
45 return(i);
|
|
46 return(-1);
|
|
47 }
|
|
48
|
|
49 static pciinfo_t pci_info;
|
|
50 static int probed = 0;
|
|
51
|
|
52 /* VIDIX exports */
|
|
53
|
|
54 static vidix_capability_t nvidia_cap =
|
|
55 {
|
|
56 "NVIDIA driver for VIDIX",
|
|
57 TYPE_OUTPUT,
|
4191
|
58 { 0, 0, 0, 0 },
|
4126
|
59 1024,
|
|
60 768,
|
|
61 4,
|
|
62 4,
|
|
63 -1,
|
|
64 FLAG_NONE,
|
|
65 VENDOR_NVIDIA,
|
|
66 0,
|
|
67 { 0, 0, 0, 0 }
|
|
68 };
|
|
69
|
|
70 unsigned int vixGetVersion(void)
|
|
71 {
|
|
72 return(VIDIX_VERSION);
|
|
73 }
|
|
74
|
4191
|
75 int vixProbe(int verbose,int force)
|
4126
|
76 {
|
|
77 pciinfo_t lst[MAX_PCI_DEVICES];
|
|
78 unsigned int i, num_pci;
|
|
79 int err;
|
|
80
|
|
81 printf("[nvidia] probe\n");
|
|
82
|
|
83 err = pci_scan(lst, &num_pci);
|
|
84 if (err)
|
|
85 {
|
|
86 printf("Error occured during pci scan: %s\n", strerror(err));
|
|
87 return err;
|
|
88 }
|
|
89 else
|
|
90 {
|
|
91 err = ENXIO;
|
|
92
|
|
93 for (i = 0; i < num_pci; i++)
|
|
94 {
|
|
95 if (lst[i].vendor == VENDOR_NVIDIA)
|
|
96 {
|
|
97 int idx;
|
|
98
|
|
99 idx = find_chip(lst[i].device);
|
|
100 if (idx == -1)
|
|
101 continue;
|
4175
|
102 if (nv_card_ids[idx].flags & CARD_FLAGS_NOTSUPPORTED)
|
|
103 {
|
|
104 printf("Found chip: %s, but not supported!\n",
|
|
105 nv_card_ids[idx].name);
|
|
106 continue;
|
|
107 }
|
|
108 else
|
|
109
|
|
110 printf("Found chip: %s\n", nv_card_ids[idx].name);
|
4126
|
111 nvidia_cap.device_id = nv_card_ids[idx].id;
|
|
112 err = 0;
|
|
113 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
|
|
114 probed = 1;
|
|
115
|
|
116 printf("bus:card:func = %x:%x:%x\n",
|
|
117 pci_info.bus, pci_info.card, pci_info.func);
|
|
118 printf("vendor:device = %x:%x\n",
|
|
119 pci_info.vendor, pci_info.device);
|
|
120 printf("base0:base1:base2:baserom = %x:%x:%x:%x\n",
|
|
121 pci_info.base0, pci_info.base1, pci_info.base2,
|
|
122 pci_info.baserom);
|
|
123 break;
|
|
124 }
|
|
125 }
|
|
126 }
|
|
127
|
|
128 if (err)
|
|
129 printf("No chip found\n");
|
|
130 return(err);
|
|
131 }
|
|
132
|
|
133 int vixInit(void)
|
|
134 {
|
|
135 printf("[nvidia] init\n");
|
|
136
|
|
137 if (!probed)
|
|
138 {
|
|
139 printf("Driver was not probed but is being initialized\n");
|
|
140 return(EINTR);
|
|
141 }
|
|
142
|
|
143 mmio_base = map_phys_mem(pci_info.base0, 0xFFFF);
|
|
144 if (mmio_base == (void *)-1)
|
|
145 return(ENOMEM);
|
|
146
|
|
147 printf("mmio_base: %p\n", mmio_base);
|
|
148 return ENXIO;
|
|
149 }
|
|
150
|
|
151 void vixDestroy(void)
|
|
152 {
|
|
153 printf("[nvidia] destory\n");
|
|
154 }
|
|
155
|
|
156 int vixGetCapability(vidix_capability_t *to)
|
|
157 {
|
|
158 memcpy(to, &nvidia_cap, sizeof(vidix_capability_t));
|
|
159 return(0);
|
|
160 }
|
|
161
|
|
162 int vixQueryFourcc(vidix_fourcc_t *to)
|
|
163 {
|
|
164 printf("[nvidia] query fourcc (%x)\n", to->fourcc);
|
|
165 return 0;
|
|
166 }
|
|
167
|
|
168 int vixConfigPlayback(vidix_playback_t *info)
|
|
169 {
|
|
170 printf("[nvidia] config playback\n");
|
|
171
|
|
172 info->num_frames = 2;
|
|
173 info->frame_size = info->src.w*info->src.h+(info->src.w*info->src.h)/2;
|
|
174 info->dga_addr = malloc(info->num_frames*info->frame_size);
|
|
175 return 0;
|
|
176 }
|
|
177
|
|
178 int vixPlaybackOn(void)
|
|
179 {
|
|
180 printf("[nvidia] playback on\n");
|
|
181 return 0;
|
|
182 }
|
|
183
|
|
184 int vixPlaybackOff(void)
|
|
185 {
|
|
186 printf("[nvidia] playback off\n");
|
|
187 return 0;
|
|
188 }
|