annotate vidix/drivers/nvidia_vid.c @ 4319:2d64382e8dcf

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