]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.4.18-tridentfb.patch
- added description of djurban's branch
[packages/kernel.git] / linux-2.4.18-tridentfb.patch
1 --- linux.org/drivers/video/tridentfb.c Mon Feb 25 20:38:07 2002
2 +++ linux/drivers/video/tridentfb.c     Fri Mar  1 00:58:59 2002
3 @@ -3,7 +3,7 @@
4   *
5   * Copyright 2001,2002 - Jani Monoses   <jani@astechnix.ro>
6   *
7 - * $Id$
8 + * $Id$
9   *
10   * CREDITS:(in order of appearance)
11   *     skeletonfb.c by Geert Uytterhoeven and other fb code in drivers/video
12 @@ -35,7 +35,7 @@
13  
14  #include "tridentfb.h"
15  
16 -#define VERSION                "0.6.8"
17 +#define VERSION                "0.7.0"
18  
19  struct tridentfb_par {
20         struct fb_var_screeninfo var;
21 @@ -82,7 +82,6 @@
22  
23  static char * tridentfb_name = "Trident";
24  
25 -static int family;
26  static int pci_id;
27  
28  static int defaultaccel;
29 @@ -520,9 +519,8 @@
30         write3X4(CRTHiOrd, (read3X4(CRTHiOrd) & 0xF8) | (base & 0xE0000) >> 17);
31  }
32  
33 -
34 -#error "Floating point maths. This needs fixing before the driver is safe"
35 -#define calc_freq(n,m,k) ((NTSC * (n+8))/((m+2)*(1<<k)))
36 +/* Use 20.12 fixed-point for NTSC value and frequency calculation */
37 +#define calc_freq(n,m,k)  ( (unsigned long)0xE517 * (n+8) / ((m+2)*(1<<k)) )
38  
39  /* Set dotclock frequency */
40  static void set_vclk(int freq)
41 @@ -1098,68 +1096,29 @@
42         trident_set_disp
43  };
44  
45 -/* List of boards that we are trying to support */
46 -static struct almost_supported_board {
47 -       int pci_id;
48 -       int family;
49 -       struct accel_switch * acc;
50 -       char* board_name;
51 -       int accel;
52 -} asb[] __initdata = {
53 -       { BLADE3D,              BLADE,  &accel_blade, "Blade3D",        ACCEL   },
54 -       { CYBERBLADEi7, BLADE,  &accel_blade, "CyberBladei7",   ACCEL   },
55 -       { CYBERBLADEi7D,        BLADE,  &accel_blade, "CyberBladei7D",  ACCEL   },
56 -       { CYBERBLADEi1, BLADE,  &accel_blade, "CyberBladei1",   ACCEL   },
57 -       { CYBERBLADEi1D,        BLADE,  &accel_blade, "CyberBladei1D",  ACCEL   },
58 -       { CYBERBLADEAi1,        BLADE,  &accel_blade, "CyberBladeAi1",  ACCEL   },
59 -       { CYBERBLADEAi1D,       BLADE,  &accel_blade, "CyberBladeAi1D", ACCEL   },
60 -       { CYBERBLADEE4, BLADE,  &accel_blade, "CyberBladeE4",   ACCEL   },
61 -
62 -       { IMAGE975,     IMAGE,  &accel_image,   "IMAGE975",     NOACCEL },
63 -       { IMAGE985,     IMAGE,  &accel_image,   "IMAGE985",     NOACCEL },
64 -       { CYBER9320,    IMAGE,  &accel_image,   "Cyber9320",    NOACCEL },
65 -       { CYBER9388,    IMAGE,  &accel_image,   "Cyber9388",    NOACCEL },
66 -       { CYBER9520,    IMAGE,  &accel_image,   "Cyber9520",    NOACCEL },
67 -       { CYBER9525DVD, IMAGE,  &accel_image,   "Cyber9525DVD", NOACCEL },
68 -       { CYBER9397,    IMAGE,  &accel_image,   "Cyber9397",    NOACCEL },
69 -       { CYBER9397DVD, IMAGE,  &accel_image,   "Cyber9397DVD", NOACCEL },
70 -
71 -       { CYBERBLADEXPAi1,      XP,     &accel_blade,   "CyberBladeXPAi1",      NOACCEL },
72 -       { CYBERBLADEXPm8,       XP,     &accel_blade,   "CyberBladeXPm8",       NOACCEL },
73 -       { CYBERBLADEXPm16,      XP,     &accel_blade,   "CyberBladeXPm16",      NOACCEL },
74 -};
75 -
76 -static __init int trident_find_board(void)
77 +static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_device_id * id)
78  {
79 -       int i;
80 -       struct pci_dev * board;
81 +       int err;
82  
83 -       for (i = 0;i < ARRAY_SIZE(asb);i++) {
84 -               if ((board = pci_find_device(PCI_VENDOR_ID_TRIDENT,
85 -                                  asb[i].pci_id,
86 -                                  NULL))) {
87 -                       family = asb[i].family;
88 -                       acc = asb[i].acc;
89 -                       pci_id = asb[i].pci_id;
90 -                       defaultaccel = asb[i].accel;
91 -
92 -                       fb_info.io = pci_resource_start(board,1);
93 -                       fb_info.fbmem = pci_resource_start(board,0);
94 -                       output("%s board found\n", asb[i].board_name);
95 -                       return 1;
96 -               }
97 -       }
98 -       output("No Trident board found\n");
99 -       return 0;
100 -}
101 -
102 -int __init tridentfb_init(void)
103 -{
104 +       err = pci_enable_device(dev);
105 +       if (err)
106 +               return err;
107  
108 -       output("Trident framebuffer  %s initializing\n", VERSION);
109 +       pci_id = id->device;
110 +       if (is_xp(pci_id)) {
111 +               defaultaccel = NOACCEL;
112 +               acc = NULL;
113 +       } else 
114 +       if (is_blade(pci_id)) {
115 +               defaultaccel = ACCEL;
116 +               acc = &accel_blade;
117 +       } else {
118 +               defaultaccel = ACCEL;
119 +               acc = &accel_image;
120 +       }       
121  
122 -       if (!trident_find_board())
123 -               return -1;
124 +       fb_info.io = pci_resource_start(dev,1);
125 +       fb_info.fbmem = pci_resource_start(dev,0);
126  
127         if (!request_mem_region(fb_info.io, TRIDENT_IOSIZE, "tridentfb")) {
128                 debug("request_region failed!\n");
129 @@ -1188,6 +1147,7 @@
130                 return -1;
131         }
132  
133 +       output("%s board found\n", dev->name);
134         debug("Trident board found : mem = %X,io = %X, mem_v = %X, io_v = %X\n",
135                 fb_info.fbmem, fb_info.io, fb_info.fbmem_virt, fb_info.io_virt);
136  
137 @@ -1196,8 +1156,10 @@
138  
139         strcpy(fb_info.gen.info.modename, tridentfb_name);
140         displaytype = get_displaytype();
141 +
142         if(flatpanel)
143                 fb_info.nativex = get_nativex();
144 +
145         fb_info.gen.info.changevar = NULL;
146         fb_info.gen.info.node = NODEV;
147         fb_info.gen.info.fbops = &tridentfb_ops;
148 @@ -1213,6 +1175,7 @@
149  
150         /* This should give a reasonable default video mode */
151         fb_find_mode(&default_var,&fb_info.gen.info,mode,NULL,0,NULL,bpp);
152 +
153         /*
154          * Unless user explicitly requires accel/noaccel use
155          * per chip defaults.Accel has priority over noaccel.
156 @@ -1222,7 +1185,7 @@
157         else if (noaccel)
158                 defaultaccel = NOACCEL;
159  
160 -       if (defaultaccel == ACCEL)
161 +       if (defaultaccel == ACCEL && acc)
162                 default_var.accel_flags |= FB_ACCELF_TEXT;
163         else
164                 default_var.accel_flags &= ~FB_ACCELF_TEXT;
165 @@ -1243,13 +1206,60 @@
166         return 0;
167  }
168  
169 -void __exit tridentfb_exit(void)
170 +static void __devexit trident_pci_remove(struct pci_dev * dev)
171  {
172         unregister_framebuffer(&fb_info.gen.info);
173         iounmap((void *)fb_info.io_virt);
174         iounmap((void *)fb_info.fbmem_virt);
175 +       release_mem_region(fb_info.fbmem, fb_info.memsize);
176 +       release_region(fb_info.io, TRIDENT_IOSIZE);
177  }
178  
179 +/* List of boards that we are trying to support */
180 +static struct pci_device_id trident_devices[] __devinitdata = {
181 +       {PCI_VENDOR_ID_TRIDENT, BLADE3D, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
182 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
183 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7D, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
184 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
185 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1D, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
186 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
187 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1D, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
188 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEE4, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
189 +       {PCI_VENDOR_ID_TRIDENT, IMAGE975, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
190 +       {PCI_VENDOR_ID_TRIDENT, IMAGE985, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
191 +       {PCI_VENDOR_ID_TRIDENT, CYBER9320, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
192 +       {PCI_VENDOR_ID_TRIDENT, CYBER9388, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
193 +       {PCI_VENDOR_ID_TRIDENT, CYBER9520, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
194 +       {PCI_VENDOR_ID_TRIDENT, CYBER9525DVD, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
195 +       {PCI_VENDOR_ID_TRIDENT, CYBER9397, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
196 +       {PCI_VENDOR_ID_TRIDENT, CYBER9397DVD, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
197 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPAi1, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
198 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm8, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
199 +       {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm16, PCI_ANY_ID,PCI_ANY_ID,0,0,0},
200 +       {0,}
201 +};     
202 +       
203 +MODULE_DEVICE_TABLE(pci,trident_devices); 
204 +
205 +static struct pci_driver tridentfb_pci_driver = {
206 +       name:"tridentfb",
207 +       id_table:trident_devices,
208 +       probe:trident_pci_probe,
209 +       remove:__devexit_p(trident_pci_remove),
210 +};
211 +
212 +int __init tridentfb_init(void)
213 +{
214 +       output("Trident framebuffer  %s initializing\n", VERSION);
215 +       return pci_module_init(&tridentfb_pci_driver);
216 +}
217 +
218 +void __exit tridentfb_exit(void)
219 +{
220 +       pci_unregister_driver(&tridentfb_pci_driver);
221 +}
222 +
223 +
224  /*
225   * Parse user specified options (`video=trident:')
226   * example:
227 @@ -1260,8 +1270,8 @@
228         char * opt;
229         if (!options || !*options)
230                 return 0;
231 -       for(opt = strtok(options,",");opt;opt = strtok(NULL,",")){
232 -               if (!opt) continue;
233 +       while((opt = strsep(&options,",")) != NULL ) {
234 +               if (!*opt) continue;
235                 if (!strncmp(opt,"noaccel",7))
236                         noaccel = 1;
237                 else if (!strncmp(opt,"accel",5))
238 --- linux.org/drivers/video/tridentfb.h Mon Feb 25 20:38:07 2002
239 +++ linux/drivers/video/tridentfb.h     Tue Mar  5 11:37:58 2002
240 @@ -41,9 +41,19 @@
241  #define BLADE  1
242  #define XP     2
243  
244 -#define is_image()     (family == IMAGE)
245 -#define is_blade()     (family == BLADE)
246 -#define is_xp()                (family == XP)
247 +#define is_image(id)   
248 +#define is_xp(id)      ((id == CYBERBLADEXPAi1) ||\
249 +                        (id == CYBERBLADEXPm8) ||\
250 +                        (id == CYBERBLADEXPm16)) 
251 +
252 +#define is_blade(id)   ((id == BLADE3D) ||\
253 +                        (id == CYBERBLADEE4) ||\
254 +                        (id == CYBERBLADEi7) ||\
255 +                        (id == CYBERBLADEi7D) ||\
256 +                        (id == CYBERBLADEi1) ||\
257 +                        (id == CYBERBLADEi1D) ||\
258 +                        (id == CYBERBLADEAi1) ||\
259 +                        (id == CYBERBLADEAi1D))
260  
261  /* these defines are for 'lcd' variable */
262  #define LCD_STRETCH    0
263 @@ -60,15 +70,13 @@
264  #define NOACCEL        0
265  
266  #define TRIDENT_IOSIZE 0x20000
267 -#define NTSC 14.31818
268 -#define PAL  17.73448
269  
270  /* General Registers */
271  #define SPR    0x1F            /* Software Programming Register (videoram) */
272  
273  /* 3C4 */
274  #define RevisionID 0x09
275 -#define OldOrNew 0x0B
276 +#define OldOrNew 0x0B  
277  #define ConfPort1 0x0C
278  #define ConfPort2 0x0C
279  #define NewMode2 0x0D
This page took 0.730446 seconds and 3 git commands to generate.