Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device |
| 3 | * |
| 4 | * Modified to new api Jan 2001 by James Simmons (jsimmons@transvirtual.com) |
| 5 | * |
| 6 | * Created 28 Dec 1997 by Geert Uytterhoeven |
| 7 | * |
| 8 | * |
| 9 | * I have started rewriting this driver as a example of the upcoming new API |
| 10 | * The primary goal is to remove the console code from fbdev and place it |
| 11 | * into fbcon.c. This reduces the code and makes writing a new fbdev driver |
| 12 | * easy since the author doesn't need to worry about console internals. It |
| 13 | * also allows the ability to run fbdev without a console/tty system on top |
| 14 | * of it. |
| 15 | * |
| 16 | * First the roles of struct fb_info and struct display have changed. Struct |
| 17 | * display will go away. The way the the new framebuffer console code will |
| 18 | * work is that it will act to translate data about the tty/console in |
| 19 | * struct vc_data to data in a device independent way in struct fb_info. Then |
| 20 | * various functions in struct fb_ops will be called to store the device |
| 21 | * dependent state in the par field in struct fb_info and to change the |
| 22 | * hardware to that state. This allows a very clean separation of the fbdev |
| 23 | * layer from the console layer. It also allows one to use fbdev on its own |
| 24 | * which is a bounus for embedded devices. The reason this approach works is |
| 25 | * for each framebuffer device when used as a tty/console device is allocated |
| 26 | * a set of virtual terminals to it. Only one virtual terminal can be active |
| 27 | * per framebuffer device. We already have all the data we need in struct |
| 28 | * vc_data so why store a bunch of colormaps and other fbdev specific data |
| 29 | * per virtual terminal. |
| 30 | * |
| 31 | * As you can see doing this makes the con parameter pretty much useless |
| 32 | * for struct fb_ops functions, as it should be. Also having struct |
| 33 | * fb_var_screeninfo and other data in fb_info pretty much eliminates the |
| 34 | * need for get_fix and get_var. Once all drivers use the fix, var, and cmap |
| 35 | * fbcon can be written around these fields. This will also eliminate the |
| 36 | * need to regenerate struct fb_var_screeninfo, struct fb_fix_screeninfo |
| 37 | * struct fb_cmap every time get_var, get_fix, get_cmap functions are called |
| 38 | * as many drivers do now. |
| 39 | * |
| 40 | * This file is subject to the terms and conditions of the GNU General Public |
| 41 | * License. See the file COPYING in the main directory of this archive for |
| 42 | * more details. |
| 43 | */ |
| 44 | |
| 45 | #include <linux/module.h> |
| 46 | #include <linux/kernel.h> |
| 47 | #include <linux/errno.h> |
| 48 | #include <linux/string.h> |
| 49 | #include <linux/mm.h> |
| 50 | #include <linux/tty.h> |
| 51 | #include <linux/slab.h> |
| 52 | #include <linux/delay.h> |
| 53 | #include <linux/fb.h> |
| 54 | #include <linux/init.h> |
| 55 | |
| 56 | /* |
| 57 | * This is just simple sample code. |
| 58 | * |
| 59 | * No warranty that it actually compiles. |
| 60 | * Even less warranty that it actually works :-) |
| 61 | */ |
| 62 | |
| 63 | /* |
| 64 | * If your driver supports multiple boards, you should make the |
| 65 | * below data types arrays, or allocate them dynamically (using kmalloc()). |
| 66 | */ |
| 67 | |
| 68 | /* |
| 69 | * This structure defines the hardware state of the graphics card. Normally |
| 70 | * you place this in a header file in linux/include/video. This file usually |
| 71 | * also includes register information. That allows other driver subsystems |
| 72 | * and userland applications the ability to use the same header file to |
| 73 | * avoid duplicate work and easy porting of software. |
| 74 | */ |
| 75 | struct xxx_par; |
| 76 | |
| 77 | /* |
| 78 | * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo |
| 79 | * if we don't use modedb. If we do use modedb see xxxfb_init how to use it |
| 80 | * to get a fb_var_screeninfo. Otherwise define a default var as well. |
| 81 | */ |
| 82 | static struct fb_fix_screeninfo xxxfb_fix __initdata = { |
| 83 | .id = "FB's name", |
| 84 | .type = FB_TYPE_PACKED_PIXELS, |
| 85 | .visual = FB_VISUAL_PSEUDOCOLOR, |
| 86 | .xpanstep = 1, |
| 87 | .ypanstep = 1, |
| 88 | .ywrapstep = 1, |
| 89 | .accel = FB_ACCEL_NONE, |
| 90 | }; |
| 91 | |
| 92 | /* |
| 93 | * Modern graphical hardware not only supports pipelines but some |
| 94 | * also support multiple monitors where each display can have its |
| 95 | * its own unique data. In this case each display could be |
| 96 | * represented by a separate framebuffer device thus a separate |
| 97 | * struct fb_info. Now the struct xxx_par represents the graphics |
| 98 | * hardware state thus only one exist per card. In this case the |
| 99 | * struct xxx_par for each graphics card would be shared between |
| 100 | * every struct fb_info that represents a framebuffer on that card. |
| 101 | * This allows when one display changes it video resolution (info->var) |
| 102 | * the other displays know instantly. Each display can always be |
| 103 | * aware of the entire hardware state that affects it because they share |
| 104 | * the same xxx_par struct. The other side of the coin is multiple |
| 105 | * graphics cards that pass data around until it is finally displayed |
| 106 | * on one monitor. Such examples are the voodoo 1 cards and high end |
| 107 | * NUMA graphics servers. For this case we have a bunch of pars, each |
| 108 | * one that represents a graphics state, that belong to one struct |
| 109 | * fb_info. Their you would want to have *par point to a array of device |
| 110 | * states and have each struct fb_ops function deal with all those |
| 111 | * states. I hope this covers every possible hardware design. If not |
| 112 | * feel free to send your ideas at jsimmons@users.sf.net |
| 113 | */ |
| 114 | |
| 115 | /* |
| 116 | * If your driver supports multiple boards or it supports multiple |
| 117 | * framebuffers, you should make these arrays, or allocate them |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 118 | * dynamically using framebuffer_alloc() and free them with |
| 119 | * framebuffer_release(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | */ |
| 121 | static struct fb_info info; |
| 122 | |
| 123 | /* |
| 124 | * Each one represents the state of the hardware. Most hardware have |
| 125 | * just one hardware state. These here represent the default state(s). |
| 126 | */ |
| 127 | static struct xxx_par __initdata current_par; |
| 128 | |
| 129 | int xxxfb_init(void); |
| 130 | int xxxfb_setup(char*); |
| 131 | |
| 132 | /** |
| 133 | * xxxfb_open - Optional function. Called when the framebuffer is |
| 134 | * first accessed. |
| 135 | * @info: frame buffer structure that represents a single frame buffer |
| 136 | * @user: tell us if the userland (value=1) or the console is accessing |
| 137 | * the framebuffer. |
| 138 | * |
| 139 | * This function is the first function called in the framebuffer api. |
| 140 | * Usually you don't need to provide this function. The case where it |
| 141 | * is used is to change from a text mode hardware state to a graphics |
| 142 | * mode state. |
| 143 | * |
| 144 | * Returns negative errno on error, or zero on success. |
| 145 | */ |
| 146 | static int xxxfb_open(const struct fb_info *info, int user) |
| 147 | { |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * xxxfb_release - Optional function. Called when the framebuffer |
| 153 | * device is closed. |
| 154 | * @info: frame buffer structure that represents a single frame buffer |
| 155 | * @user: tell us if the userland (value=1) or the console is accessing |
| 156 | * the framebuffer. |
| 157 | * |
| 158 | * Thus function is called when we close /dev/fb or the framebuffer |
| 159 | * console system is released. Usually you don't need this function. |
| 160 | * The case where it is usually used is to go from a graphics state |
| 161 | * to a text mode state. |
| 162 | * |
| 163 | * Returns negative errno on error, or zero on success. |
| 164 | */ |
| 165 | static int xxxfb_release(const struct fb_info *info, int user) |
| 166 | { |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * xxxfb_check_var - Optional function. Validates a var passed in. |
| 172 | * @var: frame buffer variable screen structure |
| 173 | * @info: frame buffer structure that represents a single frame buffer |
| 174 | * |
| 175 | * Checks to see if the hardware supports the state requested by |
| 176 | * var passed in. This function does not alter the hardware state!!! |
| 177 | * This means the data stored in struct fb_info and struct xxx_par do |
| 178 | * not change. This includes the var inside of struct fb_info. |
| 179 | * Do NOT change these. This function can be called on its own if we |
| 180 | * intent to only test a mode and not actually set it. The stuff in |
| 181 | * modedb.c is a example of this. If the var passed in is slightly |
| 182 | * off by what the hardware can support then we alter the var PASSED in |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 183 | * to what we can do. |
| 184 | * |
| 185 | * For values that are off, this function must round them _up_ to the |
| 186 | * next value that is supported by the hardware. If the value is |
| 187 | * greater than the highest value supported by the hardware, then this |
| 188 | * function must return -EINVAL. |
| 189 | * |
| 190 | * Exception to the above rule: Some drivers have a fixed mode, ie, |
| 191 | * the hardware is already set at boot up, and cannot be changed. In |
| 192 | * this case, it is more acceptable that this function just return |
| 193 | * a copy of the currently working var (info->var). Better is to not |
| 194 | * implement this function, as the upper layer will do the copying |
| 195 | * of the current var for you. |
| 196 | * |
| 197 | * Note: This is the only function where the contents of var can be |
| 198 | * freely adjusted after the driver has been registered. If you find |
| 199 | * that you have code outside of this function that alters the content |
| 200 | * of var, then you are doing something wrong. Note also that the |
| 201 | * contents of info->var must be left untouched at all times after |
| 202 | * driver registration. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | * |
| 204 | * Returns negative errno on error, or zero on success. |
| 205 | */ |
| 206 | static int xxxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
| 207 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | /* ... */ |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * xxxfb_set_par - Optional function. Alters the hardware state. |
| 214 | * @info: frame buffer structure that represents a single frame buffer |
| 215 | * |
| 216 | * Using the fb_var_screeninfo in fb_info we set the resolution of the |
| 217 | * this particular framebuffer. This function alters the par AND the |
| 218 | * fb_fix_screeninfo stored in fb_info. It doesn't not alter var in |
| 219 | * fb_info since we are using that data. This means we depend on the |
| 220 | * data in var inside fb_info to be supported by the hardware. |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 221 | * |
| 222 | * This function is also used to recover/restore the hardware to a |
| 223 | * known working state. |
| 224 | * |
| 225 | * xxxfb_check_var is always called before xxxfb_set_par to ensure that |
| 226 | * the contents of var is always valid. |
| 227 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | * Again if you can't change the resolution you don't need this function. |
| 229 | * |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 230 | * However, even if your hardware does not support mode changing, |
| 231 | * a set_par might be needed to at least initialize the hardware to |
| 232 | * a known working state, especially if it came back from another |
| 233 | * process that also modifies the same hardware, such as X. |
| 234 | * |
| 235 | * If this is the case, a combination such as the following should work: |
| 236 | * |
| 237 | * static int xxxfb_check_var(struct fb_var_screeninfo *var, |
| 238 | * struct fb_info *info) |
| 239 | * { |
| 240 | * *var = info->var; |
| 241 | * return 0; |
| 242 | * } |
| 243 | * |
| 244 | * static int xxxfb_set_par(struct fb_info *info) |
| 245 | * { |
| 246 | * init your hardware here |
| 247 | * } |
| 248 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | * Returns negative errno on error, or zero on success. |
| 250 | */ |
| 251 | static int xxxfb_set_par(struct fb_info *info) |
| 252 | { |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 253 | struct xxx_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | /* ... */ |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * xxxfb_setcolreg - Optional function. Sets a color register. |
| 260 | * @regno: Which register in the CLUT we are programming |
| 261 | * @red: The red value which can be up to 16 bits wide |
| 262 | * @green: The green value which can be up to 16 bits wide |
| 263 | * @blue: The blue value which can be up to 16 bits wide. |
| 264 | * @transp: If supported, the alpha value which can be up to 16 bits wide. |
| 265 | * @info: frame buffer info structure |
| 266 | * |
| 267 | * Set a single color register. The values supplied have a 16 bit |
| 268 | * magnitude which needs to be scaled in this function for the hardware. |
| 269 | * Things to take into consideration are how many color registers, if |
| 270 | * any, are supported with the current color visual. With truecolor mode |
| 271 | * no color palettes are supported. Here a pseudo palette is created |
| 272 | * which we store the value in pseudo_palette in struct fb_info. For |
| 273 | * pseudocolor mode we have a limited color palette. To deal with this |
| 274 | * we can program what color is displayed for a particular pixel value. |
| 275 | * DirectColor is similar in that we can program each color field. If |
| 276 | * we have a static colormap we don't need to implement this function. |
| 277 | * |
| 278 | * Returns negative errno on error, or zero on success. |
| 279 | */ |
| 280 | static int xxxfb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 281 | unsigned blue, unsigned transp, |
| 282 | const struct fb_info *info) |
| 283 | { |
| 284 | if (regno >= 256) /* no. of hw registers */ |
| 285 | return -EINVAL; |
| 286 | /* |
| 287 | * Program hardware... do anything you want with transp |
| 288 | */ |
| 289 | |
| 290 | /* grayscale works only partially under directcolor */ |
| 291 | if (info->var.grayscale) { |
| 292 | /* grayscale = 0.30*R + 0.59*G + 0.11*B */ |
| 293 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; |
| 294 | } |
| 295 | |
| 296 | /* Directcolor: |
| 297 | * var->{color}.offset contains start of bitfield |
| 298 | * var->{color}.length contains length of bitfield |
| 299 | * {hardwarespecific} contains width of DAC |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 300 | * pseudo_palette[X] is programmed to (X << red.offset) | |
| 301 | * (X << green.offset) | |
| 302 | * (X << blue.offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | * RAMDAC[X] is programmed to (red, green, blue) |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 304 | * color depth = SUM(var->{color}.length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | * |
| 306 | * Pseudocolor: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | * var->{color}.offset is 0 |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 308 | * var->{color}.length contains width of DAC or the number of unique |
| 309 | * colors available (color depth) |
| 310 | * pseudo_palette is not used |
| 311 | * RAMDAC[X] is programmed to (red, green, blue) |
| 312 | * color depth = var->{color}.length |
| 313 | * |
| 314 | * Static pseudocolor: |
| 315 | * same as Pseudocolor, but the RAMDAC is not programmed (read-only) |
| 316 | * |
| 317 | * Mono01/Mono10: |
| 318 | * Has only 2 values, black on white or white on black (fg on bg), |
| 319 | * var->{color}.offset is 0 |
| 320 | * white = (1 << var->{color}.length) - 1, black = 0 |
| 321 | * pseudo_palette is not used |
| 322 | * RAMDAC does not exist |
| 323 | * color depth is always 2 |
| 324 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | * Truecolor: |
| 326 | * does not use RAMDAC (usually has 3 of them). |
| 327 | * var->{color}.offset contains start of bitfield |
| 328 | * var->{color}.length contains length of bitfield |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 329 | * pseudo_palette is programmed to (red << red.offset) | |
| 330 | * (green << green.offset) | |
| 331 | * (blue << blue.offset) | |
| 332 | * (transp << transp.offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | * RAMDAC does not exist |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 334 | * color depth = SUM(var->{color}.length}) |
| 335 | * |
| 336 | * The color depth is used by fbcon for choosing the logo and also |
| 337 | * for color palette transformation if color depth < 4 |
| 338 | * |
| 339 | * As can be seen from the above, the field bits_per_pixel is _NOT_ |
| 340 | * a criteria for describing the color visual. |
| 341 | * |
| 342 | * A common mistake is assuming that bits_per_pixel <= 8 is pseudocolor, |
| 343 | * and higher than that, true/directcolor. This is incorrect, one needs |
| 344 | * to look at the fix->visual. |
| 345 | * |
| 346 | * Another common mistake is using bits_per_pixel to calculate the color |
| 347 | * depth. The bits_per_pixel field does not directly translate to color |
| 348 | * depth. You have to compute for the color depth (using the color |
| 349 | * bitfields) and fix->visual as seen above. |
| 350 | */ |
| 351 | |
| 352 | /* |
| 353 | * This is the point where the color is converted to something that |
| 354 | * is acceptable by the hardware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | */ |
| 356 | #define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16) |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 357 | red = CNVT_TOHW(red, info->var.red.length); |
| 358 | green = CNVT_TOHW(green, info->var.green.length); |
| 359 | blue = CNVT_TOHW(blue, info->var.blue.length); |
| 360 | transp = CNVT_TOHW(transp, info->var.transp.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | #undef CNVT_TOHW |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 362 | /* |
| 363 | * This is the point where the function feeds the color to the hardware |
| 364 | * palette after converting the colors to something acceptable by |
| 365 | * the hardware. Note, only FB_VISUAL_DIRECTCOLOR and |
| 366 | * FB_VISUAL_PSEUDOCOLOR visuals need to write to the hardware palette. |
| 367 | * If you have code that writes to the hardware CLUT, and it's not |
| 368 | * any of the above visuals, then you are doing something wrong. |
| 369 | */ |
| 370 | if (info->fix.visual == FB_VISUAL_DIRECTCOLOR || |
| 371 | info->fix.visual == FB_VISUAL_TRUECOLOR) |
| 372 | write_{red|green|blue|transp}_to_clut(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 374 | /* This is the point were you need to fill up the contents of |
| 375 | * info->pseudo_palette. This structure is used _only_ by fbcon, thus |
| 376 | * it only contains 16 entries to match the number of colors supported |
| 377 | * by the console. The pseudo_palette is used only if the visual is |
| 378 | * in directcolor or truecolor mode. With other visuals, the |
| 379 | * pseudo_palette is not used. (This might change in the future.) |
| 380 | * |
| 381 | * The contents of the pseudo_palette is in raw pixel format. Ie, each |
| 382 | * entry can be written directly to the framebuffer without any conversion. |
| 383 | * The pseudo_palette is (void *). However, if using the generic |
| 384 | * drawing functions (cfb_imageblit, cfb_fillrect), the pseudo_palette |
| 385 | * must be casted to (u32 *) _regardless_ of the bits per pixel. If the |
| 386 | * driver is using its own drawing functions, then it can use whatever |
| 387 | * size it wants. |
| 388 | */ |
| 389 | if (info->fix.visual == FB_VISUAL_TRUECOLOR || |
| 390 | info->fix.visual == FB_VISUAL_DIRECTCOLOR) { |
| 391 | u32 v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 393 | if (regno >= 16) |
| 394 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 396 | v = (red << info->var.red.offset) | |
| 397 | (green << info->var.green.offset) | |
| 398 | (blue << info->var.blue.offset) | |
| 399 | (transp << info->var.transp.offset); |
| 400 | |
| 401 | ((u32*)(info->pseudo_palette))[regno] = v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | /* ... */ |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * xxxfb_pan_display - NOT a required function. Pans the display. |
| 410 | * @var: frame buffer variable screen structure |
| 411 | * @info: frame buffer structure that represents a single frame buffer |
| 412 | * |
| 413 | * Pan (or wrap, depending on the `vmode' field) the display using the |
| 414 | * `xoffset' and `yoffset' fields of the `var' structure. |
| 415 | * If the values don't fit, return -EINVAL. |
| 416 | * |
| 417 | * Returns negative errno on error, or zero on success. |
| 418 | */ |
| 419 | static int xxxfb_pan_display(struct fb_var_screeninfo *var, |
| 420 | const struct fb_info *info) |
| 421 | { |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 422 | /* |
| 423 | * If your hardware does not support panning, _do_ _not_ implement this |
| 424 | * function. Creating a dummy function will just confuse user apps. |
| 425 | */ |
| 426 | |
| 427 | /* |
| 428 | * Note that even if this function is fully functional, a setting of |
| 429 | * 0 in both xpanstep and ypanstep means that this function will never |
| 430 | * get called. |
| 431 | */ |
| 432 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | /* ... */ |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * xxxfb_blank - NOT a required function. Blanks the display. |
| 439 | * @blank_mode: the blank mode we want. |
| 440 | * @info: frame buffer structure that represents a single frame buffer |
| 441 | * |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 442 | * Blank the screen if blank_mode != FB_BLANK_UNBLANK, else unblank. |
| 443 | * Return 0 if blanking succeeded, != 0 if un-/blanking failed due to |
| 444 | * e.g. a video mode which doesn't support it. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | * |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 446 | * Implements VESA suspend and powerdown modes on hardware that supports |
| 447 | * disabling hsync/vsync: |
| 448 | * |
| 449 | * FB_BLANK_NORMAL = display is blanked, syncs are on. |
| 450 | * FB_BLANK_HSYNC_SUSPEND = hsync off |
| 451 | * FB_BLANK_VSYNC_SUSPEND = vsync off |
| 452 | * FB_BLANK_POWERDOWN = hsync and vsync off |
| 453 | * |
| 454 | * If implementing this function, at least support FB_BLANK_UNBLANK. |
| 455 | * Return !0 for any modes that are unimplemented. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | * |
| 457 | */ |
| 458 | static int xxxfb_blank(int blank_mode, const struct fb_info *info) |
| 459 | { |
| 460 | /* ... */ |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | /* ------------ Accelerated Functions --------------------- */ |
| 465 | |
| 466 | /* |
| 467 | * We provide our own functions if we have hardware acceleration |
| 468 | * or non packed pixel format layouts. If we have no hardware |
| 469 | * acceleration, we can use a generic unaccelerated function. If using |
| 470 | * a pack pixel format just use the functions in cfb_*.c. Each file |
| 471 | * has one of the three different accel functions we support. |
| 472 | */ |
| 473 | |
| 474 | /** |
| 475 | * xxxfb_fillrect - REQUIRED function. Can use generic routines if |
| 476 | * non acclerated hardware and packed pixel based. |
| 477 | * Draws a rectangle on the screen. |
| 478 | * |
| 479 | * @info: frame buffer structure that represents a single frame buffer |
| 480 | * @region: The structure representing the rectangular region we |
| 481 | * wish to draw to. |
| 482 | * |
| 483 | * This drawing operation places/removes a retangle on the screen |
| 484 | * depending on the rastering operation with the value of color which |
| 485 | * is in the current color depth format. |
| 486 | */ |
| 487 | void xxfb_fillrect(struct fb_info *p, const struct fb_fillrect *region) |
| 488 | { |
| 489 | /* Meaning of struct fb_fillrect |
| 490 | * |
| 491 | * @dx: The x and y corrdinates of the upper left hand corner of the |
| 492 | * @dy: area we want to draw to. |
| 493 | * @width: How wide the rectangle is we want to draw. |
| 494 | * @height: How tall the rectangle is we want to draw. |
| 495 | * @color: The color to fill in the rectangle with. |
| 496 | * @rop: The raster operation. We can draw the rectangle with a COPY |
| 497 | * of XOR which provides erasing effect. |
| 498 | */ |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * xxxfb_copyarea - REQUIRED function. Can use generic routines if |
| 503 | * non acclerated hardware and packed pixel based. |
| 504 | * Copies one area of the screen to another area. |
| 505 | * |
| 506 | * @info: frame buffer structure that represents a single frame buffer |
| 507 | * @area: Structure providing the data to copy the framebuffer contents |
| 508 | * from one region to another. |
| 509 | * |
| 510 | * This drawing operation copies a rectangular area from one area of the |
| 511 | * screen to another area. |
| 512 | */ |
| 513 | void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) |
| 514 | { |
| 515 | /* |
| 516 | * @dx: The x and y coordinates of the upper left hand corner of the |
| 517 | * @dy: destination area on the screen. |
| 518 | * @width: How wide the rectangle is we want to copy. |
| 519 | * @height: How tall the rectangle is we want to copy. |
| 520 | * @sx: The x and y coordinates of the upper left hand corner of the |
| 521 | * @sy: source area on the screen. |
| 522 | */ |
| 523 | } |
| 524 | |
| 525 | |
| 526 | /** |
| 527 | * xxxfb_imageblit - REQUIRED function. Can use generic routines if |
| 528 | * non acclerated hardware and packed pixel based. |
| 529 | * Copies a image from system memory to the screen. |
| 530 | * |
| 531 | * @info: frame buffer structure that represents a single frame buffer |
| 532 | * @image: structure defining the image. |
| 533 | * |
| 534 | * This drawing operation draws a image on the screen. It can be a |
| 535 | * mono image (needed for font handling) or a color image (needed for |
| 536 | * tux). |
| 537 | */ |
| 538 | void xxxfb_imageblit(struct fb_info *p, const struct fb_image *image) |
| 539 | { |
| 540 | /* |
| 541 | * @dx: The x and y coordinates of the upper left hand corner of the |
| 542 | * @dy: destination area to place the image on the screen. |
| 543 | * @width: How wide the image is we want to copy. |
| 544 | * @height: How tall the image is we want to copy. |
| 545 | * @fg_color: For mono bitmap images this is color data for |
| 546 | * @bg_color: the foreground and background of the image to |
| 547 | * write directly to the frmaebuffer. |
| 548 | * @depth: How many bits represent a single pixel for this image. |
| 549 | * @data: The actual data used to construct the image on the display. |
| 550 | * @cmap: The colormap used for color images. |
| 551 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 552 | |
| 553 | /* |
| 554 | * The generic function, cfb_imageblit, expects that the bitmap scanlines are |
| 555 | * padded to the next byte. Most hardware accelerators may require padding to |
| 556 | * the next u16 or the next u32. If that is the case, the driver can specify |
| 557 | * this by setting info->pixmap.scan_align = 2 or 4. See a more |
| 558 | * comprehensive description of the pixmap below. |
| 559 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | /** |
Antonino A. Daplas | c465e05 | 2005-11-07 01:00:35 -0800 | [diff] [blame] | 563 | * xxxfb_cursor - OPTIONAL. If your hardware lacks support |
| 564 | * for a cursor, leave this field NULL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | * |
| 566 | * @info: frame buffer structure that represents a single frame buffer |
| 567 | * @cursor: structure defining the cursor to draw. |
| 568 | * |
| 569 | * This operation is used to set or alter the properities of the |
| 570 | * cursor. |
| 571 | * |
| 572 | * Returns negative errno on error, or zero on success. |
| 573 | */ |
| 574 | int xxxfb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
| 575 | { |
| 576 | /* |
| 577 | * @set: Which fields we are altering in struct fb_cursor |
| 578 | * @enable: Disable or enable the cursor |
| 579 | * @rop: The bit operation we want to do. |
| 580 | * @mask: This is the cursor mask bitmap. |
| 581 | * @dest: A image of the area we are going to display the cursor. |
| 582 | * Used internally by the driver. |
| 583 | * @hot: The hot spot. |
| 584 | * @image: The actual data for the cursor image. |
| 585 | * |
| 586 | * NOTES ON FLAGS (cursor->set): |
| 587 | * |
| 588 | * FB_CUR_SETIMAGE - the cursor image has changed (cursor->image.data) |
| 589 | * FB_CUR_SETPOS - the cursor position has changed (cursor->image.dx|dy) |
| 590 | * FB_CUR_SETHOT - the cursor hot spot has changed (cursor->hot.dx|dy) |
| 591 | * FB_CUR_SETCMAP - the cursor colors has changed (cursor->fg_color|bg_color) |
| 592 | * FB_CUR_SETSHAPE - the cursor bitmask has changed (cursor->mask) |
| 593 | * FB_CUR_SETSIZE - the cursor size has changed (cursor->width|height) |
| 594 | * FB_CUR_SETALL - everything has changed |
| 595 | * |
| 596 | * NOTES ON ROPs (cursor->rop, Raster Operation) |
| 597 | * |
| 598 | * ROP_XOR - cursor->image.data XOR cursor->mask |
| 599 | * ROP_COPY - curosr->image.data AND cursor->mask |
| 600 | * |
| 601 | * OTHER NOTES: |
| 602 | * |
| 603 | * - fbcon only supports a 2-color cursor (cursor->image.depth = 1) |
| 604 | * - The fb_cursor structure, @cursor, _will_ always contain valid |
| 605 | * fields, whether any particular bitfields in cursor->set is set |
| 606 | * or not. |
| 607 | */ |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * xxxfb_rotate - NOT a required function. If your hardware |
| 612 | * supports rotation the whole screen then |
| 613 | * you would provide a hook for this. |
| 614 | * |
| 615 | * @info: frame buffer structure that represents a single frame buffer |
| 616 | * @angle: The angle we rotate the screen. |
| 617 | * |
| 618 | * This operation is used to set or alter the properities of the |
| 619 | * cursor. |
| 620 | */ |
| 621 | void xxxfb_rotate(struct fb_info *info, int angle) |
| 622 | { |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 623 | /* Will be deprecated */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | } |
| 625 | |
| 626 | /** |
| 627 | * xxxfb_poll - NOT a required function. The purpose of this |
| 628 | * function is to provide a way for some process |
| 629 | * to wait until a specific hardware event occurs |
| 630 | * for the framebuffer device. |
| 631 | * |
| 632 | * @info: frame buffer structure that represents a single frame buffer |
| 633 | * @wait: poll table where we store process that await a event. |
| 634 | */ |
| 635 | void xxxfb_poll(struct fb_info *info, poll_table *wait) |
| 636 | { |
| 637 | } |
| 638 | |
| 639 | /** |
| 640 | * xxxfb_sync - NOT a required function. Normally the accel engine |
| 641 | * for a graphics card take a specific amount of time. |
| 642 | * Often we have to wait for the accelerator to finish |
| 643 | * its operation before we can write to the framebuffer |
| 644 | * so we can have consistent display output. |
| 645 | * |
| 646 | * @info: frame buffer structure that represents a single frame buffer |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 647 | * |
| 648 | * If the driver has implemented its own hardware-based drawing function, |
| 649 | * implementing this function is highly recommended. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | */ |
| 651 | void xxxfb_sync(struct fb_info *info) |
| 652 | { |
| 653 | } |
| 654 | |
| 655 | /* |
| 656 | * Initialization |
| 657 | */ |
| 658 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 659 | /* static int __init xxfb_probe (struct device *device) -- for platform devs */ |
| 660 | static int __init xxxfb_probe(struct pci_dev *dev, |
| 661 | const_struct pci_device_id *ent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | { |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 663 | struct fb_info *info; |
| 664 | struct xxx_par *par; |
| 665 | struct device = &dev->dev; /* for pci drivers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | int cmap_len, retval; |
| 667 | |
| 668 | /* |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 669 | * Dynamically allocate info and par |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 671 | info = framebuffer_alloc(sizeof(struct xxx_par), device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 673 | if (!info) { |
| 674 | /* goto error path */ |
| 675 | } |
| 676 | |
| 677 | par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | |
| 679 | /* |
| 680 | * Here we set the screen_base to the virtual memory address |
| 681 | * for the framebuffer. Usually we obtain the resource address |
| 682 | * from the bus layer and then translate it to virtual memory |
| 683 | * space via ioremap. Consult ioport.h. |
| 684 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 685 | info->screen_base = framebuffer_virtual_memory; |
| 686 | info->fbops = &xxxfb_ops; |
| 687 | info->fix = xxxfb_fix; /* this will be the only time xxxfb_fix will be |
| 688 | * used, so mark it as __initdata |
| 689 | */ |
| 690 | info->pseudo_palette = pseudo_palette; /* The pseudopalette is an |
| 691 | * 16-member array |
| 692 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | /* |
| 694 | * Set up flags to indicate what sort of acceleration your |
| 695 | * driver can provide (pan/wrap/copyarea/etc.) and whether it |
| 696 | * is a module -- see FBINFO_* in include/linux/fb.h |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 697 | * |
| 698 | * If your hardware can support any of the hardware accelerated functions |
| 699 | * fbcon performance will improve if info->flags is set properly. |
| 700 | * |
| 701 | * FBINFO_HWACCEL_COPYAREA - hardware moves |
| 702 | * FBINFO_HWACCEL_FILLRECT - hardware fills |
| 703 | * FBINFO_HWACCEL_IMAGEBLIT - hardware mono->color expansion |
| 704 | * FBINFO_HWACCEL_YPAN - hardware can pan display in y-axis |
| 705 | * FBINFO_HWACCEL_YWRAP - hardware can wrap display in y-axis |
| 706 | * FBINFO_HWACCEL_DISABLED - supports hardware accels, but disabled |
| 707 | * FBINFO_READS_FAST - if set, prefer moves over mono->color expansion |
| 708 | * FBINFO_MISC_TILEBLITTING - hardware can do tile blits |
| 709 | * |
| 710 | * NOTE: These are for fbcon use only. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 712 | info->flags = FBINFO_DEFAULT; |
| 713 | |
| 714 | /********************* This stage is optional ******************************/ |
| 715 | /* |
| 716 | * The struct pixmap is a scratch pad for the drawing functions. This |
| 717 | * is where the monochrome bitmap is constructed by the higher layers |
| 718 | * and then passed to the accelerator. For drivers that uses |
| 719 | * cfb_imageblit, you can skip this part. For those that have a more |
| 720 | * rigorous requirement, this stage is needed |
| 721 | */ |
| 722 | |
| 723 | /* PIXMAP_SIZE should be small enough to optimize drawing, but not |
| 724 | * large enough that memory is wasted. A safe size is |
| 725 | * (max_xres * max_font_height/8). max_xres is driver dependent, |
| 726 | * max_font_height is 32. |
| 727 | */ |
| 728 | info->pixmap.addr = kmalloc(PIXMAP_SIZE, GFP_KERNEL); |
| 729 | if (!info->pixmap.addr) { |
| 730 | /* goto error */ |
| 731 | } |
| 732 | |
| 733 | info->pixmap.size = PIXMAP_SIZE; |
| 734 | |
| 735 | /* |
| 736 | * FB_PIXMAP_SYSTEM - memory is in system ram |
| 737 | * FB_PIXMAP_IO - memory is iomapped |
| 738 | * FB_PIXMAP_SYNC - if set, will call fb_sync() per access to pixmap, |
| 739 | * usually if FB_PIXMAP_IO is set. |
| 740 | * |
| 741 | * Currently, FB_PIXMAP_IO is unimplemented. |
| 742 | */ |
| 743 | info->pixmap.flags = FB_PIXMAP_SYSTEM; |
| 744 | |
| 745 | /* |
| 746 | * scan_align is the number of padding for each scanline. It is in bytes. |
| 747 | * Thus for accelerators that need padding to the next u32, put 4 here. |
| 748 | */ |
| 749 | info->pixmap.scan_align = 4; |
| 750 | |
| 751 | /* |
| 752 | * buf_align is the amount to be padded for the buffer. For example, |
| 753 | * the i810fb needs a scan_align of 2 but expects it to be fed with |
| 754 | * dwords, so a buf_align = 4 is required. |
| 755 | */ |
| 756 | info->pixmap.buf_align = 4; |
| 757 | |
| 758 | /* access_align is how many bits can be accessed from the framebuffer |
| 759 | * ie. some epson cards allow 16-bit access only. Most drivers will |
| 760 | * be safe with u32 here. |
| 761 | * |
| 762 | * NOTE: This field is currently unused. |
| 763 | */ |
| 764 | info->pixmap.scan_align = 32 |
| 765 | /***************************** End optional stage ***************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | |
| 767 | /* |
| 768 | * This should give a reasonable default video mode. The following is |
| 769 | * done when we can set a video mode. |
| 770 | */ |
| 771 | if (!mode_option) |
| 772 | mode_option = "640x480@60"; |
| 773 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 774 | retval = fb_find_mode(info->var, info, mode_option, NULL, 0, NULL, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
| 776 | if (!retval || retval == 4) |
| 777 | return -EINVAL; |
| 778 | |
| 779 | /* This has to been done !!! */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 780 | fb_alloc_cmap(info->cmap, cmap_len, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | |
| 782 | /* |
| 783 | * The following is done in the case of having hardware with a static |
| 784 | * mode. If we are setting the mode ourselves we don't call this. |
| 785 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 786 | info->var = xxxfb_var; |
| 787 | |
| 788 | /* |
| 789 | * For drivers that can... |
| 790 | */ |
| 791 | xxxfb_check_var(&info->var, info); |
| 792 | |
| 793 | /* |
| 794 | * Does a call to fb_set_par() before register_framebuffer needed? This |
| 795 | * will depend on you and the hardware. If you are sure that your driver |
| 796 | * is the only device in the system, a call to fb_set_par() is safe. |
| 797 | * |
| 798 | * Hardware in x86 systems has a VGA core. Calling set_par() at this |
| 799 | * point will corrupt the VGA console, so it might be safer to skip a |
| 800 | * call to set_par here and just allow fbcon to do it for you. |
| 801 | */ |
| 802 | /* xxxfb_set_par(info); */ |
| 803 | |
| 804 | if (register_framebuffer(info) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | return -EINVAL; |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 806 | printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, |
| 807 | info->fix.id); |
| 808 | pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | /* |
| 813 | * Cleanup |
| 814 | */ |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 815 | /* static void __exit xxxfb_remove(struct device *device) */ |
| 816 | static void __exit xxxfb_remove(struct pci_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | { |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 818 | struct fb_info *info = pci_get_drv_data(dev); |
| 819 | /* or dev_get_drv_data(device); */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 821 | if (info) { |
| 822 | unregister_framebuffer(info); |
| 823 | fb_dealloc_cmap(&info.cmap); |
| 824 | /* ... */ |
| 825 | framebuffer_release(info); |
| 826 | } |
| 827 | |
| 828 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | } |
| 830 | |
Antonino A. Daplas | d911233 | 2006-01-09 20:53:34 -0800 | [diff] [blame] | 831 | #if CONFIG_PCI |
| 832 | /* For PCI drivers */ |
| 833 | static struct pci_driver xxxfb_driver = { |
| 834 | .name = "xxxfb", |
| 835 | .id_table = xxxfb_devices, |
| 836 | .probe = xxxfb_probe, |
| 837 | .remove = __devexit_p(xxxfb_remove), |
| 838 | .suspend = xxxfb_suspend, /* optional */ |
| 839 | .resume = xxxfb_resume, /* optional */ |
| 840 | }; |
| 841 | |
| 842 | static int __init xxxfb_init(void) |
| 843 | { |
| 844 | /* |
| 845 | * For kernel boot options (in 'video=xxxfb:<options>' format) |
| 846 | */ |
| 847 | #ifndef MODULE |
| 848 | char *option = NULL; |
| 849 | |
| 850 | if (fb_get_options("xxxfb", &option)) |
| 851 | return -ENODEV; |
| 852 | xxxfb_setup(option); |
| 853 | #endif |
| 854 | |
| 855 | return pci_register_driver(&xxxfb_driver); |
| 856 | } |
| 857 | |
| 858 | static void __exit xxxfb_exit(void) |
| 859 | { |
| 860 | pci_unregister_driver(&xxxfb_driver); |
| 861 | } |
| 862 | #else |
| 863 | #include <linux/platform_device.h> |
| 864 | /* for platform devices */ |
| 865 | static struct device_driver xxxfb_driver = { |
| 866 | .name = "xxxfb", |
| 867 | .bus = &platform_bus_type, |
| 868 | .probe = xxxfb_probe, |
| 869 | .remove = xxxfb_remove, |
| 870 | .suspend = xxxfb_suspend, /* optional */ |
| 871 | .resume = xxxfb_resume, /* optional */ |
| 872 | }; |
| 873 | |
| 874 | static struct platform_device xxxfb_device = { |
| 875 | .name = "xxxfb", |
| 876 | }; |
| 877 | |
| 878 | static int __init xxxfb_init(void) |
| 879 | { |
| 880 | int ret; |
| 881 | /* |
| 882 | * For kernel boot options (in 'video=xxxfb:<options>' format) |
| 883 | */ |
| 884 | #ifndef MODULE |
| 885 | char *option = NULL; |
| 886 | |
| 887 | if (fb_get_options("xxxfb", &option)) |
| 888 | return -ENODEV; |
| 889 | xxxfb_setup(option); |
| 890 | #endif |
| 891 | ret = driver_register(&xxxfb_driver); |
| 892 | |
| 893 | if (!ret) { |
| 894 | ret = platform_device_register(&xxxfb_device); |
| 895 | if (ret) |
| 896 | driver_unregister(&xxxfb_driver); |
| 897 | } |
| 898 | |
| 899 | return ret; |
| 900 | } |
| 901 | |
| 902 | static void __exit xxxfb_exit(void) |
| 903 | { |
| 904 | platform_device_unregister(&xxxfb_device); |
| 905 | driver_unregister(&xxxfb_driver); |
| 906 | } |
| 907 | #endif |
| 908 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | /* |
| 910 | * Setup |
| 911 | */ |
| 912 | |
| 913 | /* |
| 914 | * Only necessary if your driver takes special options, |
| 915 | * otherwise we fall back on the generic fb_setup(). |
| 916 | */ |
| 917 | int __init xxxfb_setup(char *options) |
| 918 | { |
| 919 | /* Parse user speficied options (`video=xxxfb:') */ |
| 920 | } |
| 921 | |
| 922 | /* ------------------------------------------------------------------------- */ |
| 923 | |
| 924 | /* |
| 925 | * Frame buffer operations |
| 926 | */ |
| 927 | |
| 928 | static struct fb_ops xxxfb_ops = { |
| 929 | .owner = THIS_MODULE, |
| 930 | .fb_open = xxxfb_open, |
| 931 | .fb_read = xxxfb_read, |
| 932 | .fb_write = xxxfb_write, |
| 933 | .fb_release = xxxfb_release, |
| 934 | .fb_check_var = xxxfb_check_var, |
| 935 | .fb_set_par = xxxfb_set_par, |
| 936 | .fb_setcolreg = xxxfb_setcolreg, |
| 937 | .fb_blank = xxxfb_blank, |
| 938 | .fb_pan_display = xxxfb_pan_display, |
| 939 | .fb_fillrect = xxxfb_fillrect, /* Needed !!! */ |
| 940 | .fb_copyarea = xxxfb_copyarea, /* Needed !!! */ |
| 941 | .fb_imageblit = xxxfb_imageblit, /* Needed !!! */ |
Antonino A. Daplas | c465e05 | 2005-11-07 01:00:35 -0800 | [diff] [blame] | 942 | .fb_cursor = xxxfb_cursor, /* Optional !!! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | .fb_rotate = xxxfb_rotate, |
| 944 | .fb_poll = xxxfb_poll, |
| 945 | .fb_sync = xxxfb_sync, |
| 946 | .fb_ioctl = xxxfb_ioctl, |
| 947 | .fb_mmap = xxxfb_mmap, |
| 948 | }; |
| 949 | |
| 950 | /* ------------------------------------------------------------------------- */ |
| 951 | |
| 952 | |
| 953 | /* |
| 954 | * Modularization |
| 955 | */ |
| 956 | |
| 957 | module_init(xxxfb_init); |
| 958 | module_exit(xxxfb_cleanup); |
| 959 | |
| 960 | MODULE_LICENSE("GPL"); |