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