📄 skeletonfb.c
字号:
/* goto error path */ } par = info->par; /* * Here we set the screen_base to the virtual memory address * for the framebuffer. Usually we obtain the resource address * from the bus layer and then translate it to virtual memory * space via ioremap. Consult ioport.h. */ info->screen_base = framebuffer_virtual_memory; info->fbops = &xxxfb_ops; info->fix = xxxfb_fix; /* this will be the only time xxxfb_fix will be * used, so mark it as __devinitdata */ info->pseudo_palette = pseudo_palette; /* The pseudopalette is an * 16-member array */ /* * Set up flags to indicate what sort of acceleration your * driver can provide (pan/wrap/copyarea/etc.) and whether it * is a module -- see FBINFO_* in include/linux/fb.h * * If your hardware can support any of the hardware accelerated functions * fbcon performance will improve if info->flags is set properly. * * FBINFO_HWACCEL_COPYAREA - hardware moves * FBINFO_HWACCEL_FILLRECT - hardware fills * FBINFO_HWACCEL_IMAGEBLIT - hardware mono->color expansion * FBINFO_HWACCEL_YPAN - hardware can pan display in y-axis * FBINFO_HWACCEL_YWRAP - hardware can wrap display in y-axis * FBINFO_HWACCEL_DISABLED - supports hardware accels, but disabled * FBINFO_READS_FAST - if set, prefer moves over mono->color expansion * FBINFO_MISC_TILEBLITTING - hardware can do tile blits * * NOTE: These are for fbcon use only. */ info->flags = FBINFO_DEFAULT;/********************* This stage is optional ******************************/ /* * The struct pixmap is a scratch pad for the drawing functions. This * is where the monochrome bitmap is constructed by the higher layers * and then passed to the accelerator. For drivers that uses * cfb_imageblit, you can skip this part. For those that have a more * rigorous requirement, this stage is needed */ /* PIXMAP_SIZE should be small enough to optimize drawing, but not * large enough that memory is wasted. A safe size is * (max_xres * max_font_height/8). max_xres is driver dependent, * max_font_height is 32. */ info->pixmap.addr = kmalloc(PIXMAP_SIZE, GFP_KERNEL); if (!info->pixmap.addr) { /* goto error */ } info->pixmap.size = PIXMAP_SIZE; /* * FB_PIXMAP_SYSTEM - memory is in system ram * FB_PIXMAP_IO - memory is iomapped * FB_PIXMAP_SYNC - if set, will call fb_sync() per access to pixmap, * usually if FB_PIXMAP_IO is set. * * Currently, FB_PIXMAP_IO is unimplemented. */ info->pixmap.flags = FB_PIXMAP_SYSTEM; /* * scan_align is the number of padding for each scanline. It is in bytes. * Thus for accelerators that need padding to the next u32, put 4 here. */ info->pixmap.scan_align = 4; /* * buf_align is the amount to be padded for the buffer. For example, * the i810fb needs a scan_align of 2 but expects it to be fed with * dwords, so a buf_align = 4 is required. */ info->pixmap.buf_align = 4; /* access_align is how many bits can be accessed from the framebuffer * ie. some epson cards allow 16-bit access only. Most drivers will * be safe with u32 here. * * NOTE: This field is currently unused. */ info->pixmap.access_align = 32;/***************************** End optional stage ***************************/ /* * This should give a reasonable default video mode. The following is * done when we can set a video mode. */ if (!mode_option) mode_option = "640x480@60"; retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); if (!retval || retval == 4) return -EINVAL; /* This has to been done !!! */ fb_alloc_cmap(&info->cmap, cmap_len, 0); /* * The following is done in the case of having hardware with a static * mode. If we are setting the mode ourselves we don't call this. */ info->var = xxxfb_var; /* * For drivers that can... */ xxxfb_check_var(&info->var, info); /* * Does a call to fb_set_par() before register_framebuffer needed? This * will depend on you and the hardware. If you are sure that your driver * is the only device in the system, a call to fb_set_par() is safe. * * Hardware in x86 systems has a VGA core. Calling set_par() at this * point will corrupt the VGA console, so it might be safer to skip a * call to set_par here and just allow fbcon to do it for you. */ /* xxxfb_set_par(info); */ if (register_framebuffer(info) < 0) return -EINVAL; printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); pci_set_drvdata(dev, info); /* or platform_set_drvdata(pdev, info) */ return 0;} /* * Cleanup *//* static void __devexit xxxfb_remove(struct platform_device *pdev) */static void __devexit xxxfb_remove(struct pci_dev *dev){ struct fb_info *info = pci_get_drvdata(dev); /* or platform_get_drvdata(pdev); */ if (info) { unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); /* ... */ framebuffer_release(info); }}#ifdef CONFIG_PCI#ifdef CONFIG_PM/** * xxxfb_suspend - Optional but recommended function. Suspend the device. * @dev: PCI device * @msg: the suspend event code. * * See Documentation/power/devices.txt for more information */static int xxxfb_suspend(struct pci_dev *dev, pm_message_t msg){ struct fb_info *info = pci_get_drvdata(dev); struct xxxfb_par *par = info->par; /* suspend here */ return 0;}/** * xxxfb_resume - Optional but recommended function. Resume the device. * @dev: PCI device * * See Documentation/power/devices.txt for more information */static int xxxfb_resume(struct pci_dev *dev){ struct fb_info *info = pci_get_drvdata(dev); struct xxxfb_par *par = info->par; /* resume here */ return 0;}#else#define xxxfb_suspend NULL#define xxxfb_resume NULL#endif /* CONFIG_PM */static struct pci_device_id xxxfb_id_table[] = { { PCI_VENDOR_ID_XXX, PCI_DEVICE_ID_XXX, PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, PCI_CLASS_MASK, 0 }, { 0, }};/* For PCI drivers */static struct pci_driver xxxfb_driver = { .name = "xxxfb", .id_table = xxxfb_id_table, .probe = xxxfb_probe, .remove = __devexit_p(xxxfb_remove), .suspend = xxxfb_suspend, /* optional but recommended */ .resume = xxxfb_resume, /* optional but recommended */};MODULE_DEVICE_TABLE(pci, xxxfb_id_table);int __init xxxfb_init(void){ /* * For kernel boot options (in 'video=xxxfb:<options>' format) */#ifndef MODULE char *option = NULL; if (fb_get_options("xxxfb", &option)) return -ENODEV; xxxfb_setup(option);#endif return pci_register_driver(&xxxfb_driver);}static void __exit xxxfb_exit(void){ pci_unregister_driver(&xxxfb_driver);}#else /* non PCI, platform drivers */#include <linux/platform_device.h>/* for platform devices */#ifdef CONFIG_PM/** * xxxfb_suspend - Optional but recommended function. Suspend the device. * @dev: platform device * @msg: the suspend event code. * * See Documentation/power/devices.txt for more information */static int xxxfb_suspend(struct platform_device *dev, pm_message_t msg){ struct fb_info *info = platform_get_drvdata(dev); struct xxxfb_par *par = info->par; /* suspend here */ return 0;}/** * xxxfb_resume - Optional but recommended function. Resume the device. * @dev: platform device * * See Documentation/power/devices.txt for more information */static int xxxfb_resume(struct platform_dev *dev){ struct fb_info *info = platform_get_drvdata(dev); struct xxxfb_par *par = info->par; /* resume here */ return 0;}#else#define xxxfb_suspend NULL#define xxxfb_resume NULL#endif /* CONFIG_PM */static struct platform_device_driver xxxfb_driver = { .probe = xxxfb_probe, .remove = xxxfb_remove, .suspend = xxxfb_suspend, /* optional but recommended */ .resume = xxxfb_resume, /* optional but recommended */ .driver = { .name = "xxxfb", },};static struct platform_device *xxxfb_device;#ifndef MODULE /* * Setup *//* * Only necessary if your driver takes special options, * otherwise we fall back on the generic fb_setup(). */int __init xxxfb_setup(char *options){ /* Parse user speficied options (`video=xxxfb:') */}#endif /* MODULE */static int __init xxxfb_init(void){ int ret; /* * For kernel boot options (in 'video=xxxfb:<options>' format) */#ifndef MODULE char *option = NULL; if (fb_get_options("xxxfb", &option)) return -ENODEV; xxxfb_setup(option);#endif ret = platform_driver_register(&xxxfb_driver); if (!ret) { xxxfb_device = platform_device_register_simple("xxxfb", 0, NULL, 0); if (IS_ERR(xxxfb_device)) { platform_driver_unregister(&xxxfb_driver); ret = PTR_ERR(xxxfb_device); } } return ret;}static void __exit xxxfb_exit(void){ platform_device_unregister(xxxfb_device); platform_driver_unregister(&xxxfb_driver);}#endif /* CONFIG_PCI *//* ------------------------------------------------------------------------- */ /* * Modularization */module_init(xxxfb_init);module_exit(xxxfb_remove);MODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -