📄 display_drivers.html
字号:
#define PGUIDE_FB_SMEM_START PGUIDE_FB_SCREEN_BASE /* Return the physical address of the start of fb memory */#define PGUIDE_FB_REMOVE /* Do any hardware shutdown */struct pguide_fb { int rotation; struct fb_info fb; u32 cmap[16];};static inline u32 convert_bitfield(int val, struct fb_bitfield *bf){ unsigned int mask = (1 << bf->length) - 1; return (val >> (16 - bf->length) & mask) << bf->offset;}/* set the software color map. Probably doesn't need modifying. */static intpguide_fb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info *info){ struct pguide_fb *fb = container_of(info, struct pguide_fb, fb); if (regno < 16) { fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) | convert_bitfield(blue, &fb->fb.var.blue) | convert_bitfield(green, &fb->fb.var.green) | convert_bitfield(red, &fb->fb.var.red); return 0; } else { return 1; }}/* check var to see if supported by this device. Probably doesn't * need modifying. */static int pguide_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info){ if((var->rotate & 1) != (info->var.rotate & 1)) { if((var->xres != info->var.yres) || (var->yres != info->var.xres) || (var->xres_virtual != info->var.yres) || (var->yres_virtual > info->var.xres * ANDROID_NUMBER_OF_BUFFERS) || (var->yres_virtual < info->var.xres )) { return -EINVAL; } } else { if((var->xres != info->var.xres) || (var->yres != info->var.yres) || (var->xres_virtual != info->var.xres) || (var->yres_virtual > info->var.yres * ANDROID_NUMBER_OF_BUFFERS) || (var->yres_virtual < info->var.yres )) { return -EINVAL; } } if((var->xoffset != info->var.xoffset) || (var->bits_per_pixel != info->var.bits_per_pixel) || (var->grayscale != info->var.grayscale)) { return -EINVAL; } return 0;}/* Handles screen rotation if device supports it. */static int pguide_fb_set_par(struct fb_info *info){ struct pguide_fb *fb = container_of(info, struct pguide_fb, fb); if(fb->rotation != fb->fb.var.rotate) { info->fix.line_length = info->var.xres * ANDROID_BYTES_PER_PIXEL; fb->rotation = fb->fb.var.rotate; PGUIDE_FB_ROTATE; } return 0;}/* Pan the display if device supports it. */static int pguide_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info){ struct pguide_fb *fb __attribute__ ((unused)) = container_of(info, struct pguide_fb, fb); /* Set the frame buffer base to something like: fb->fb.fix.smem_start + fb->fb.var.xres * ANDROID_BYTES_PER_PIXEL * var->yoffset */ PGUIDE_FB_PAN; return 0;}static struct fb_ops pguide_fb_ops = { .owner = THIS_MODULE, .fb_check_var = pguide_fb_check_var, .fb_set_par = pguide_fb_set_par, .fb_setcolreg = pguide_fb_setcolreg, .fb_pan_display = pguide_fb_pan_display, /* These are generic software based fb functions */ .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit,};static int pguide_fb_probe(struct platform_device *pdev){ int ret; struct pguide_fb *fb; size_t framesize; uint32_t width, height; fb = kzalloc(sizeof(*fb), GFP_KERNEL); if(fb == NULL) { ret = -ENOMEM; goto err_fb_alloc_failed; } platform_set_drvdata(pdev, fb); PGUIDE_FB_PROBE_FIRST; width = PGUIDE_FB_WIDTH; height = PGUIDE_FB_HEIGHT; fb->fb.fbops = &pguide_fb_ops; /* These modes are the ones currently required by Android */ fb->fb.flags = FBINFO_FLAG_DEFAULT; fb->fb.pseudo_palette = fb->cmap; fb->fb.fix.type = FB_TYPE_PACKED_PIXELS; fb->fb.fix.visual = FB_VISUAL_TRUECOLOR; fb->fb.fix.line_length = width * ANDROID_BYTES_PER_PIXEL; fb->fb.fix.accel = FB_ACCEL_NONE; fb->fb.fix.ypanstep = 1; fb->fb.var.xres = width; fb->fb.var.yres = height; fb->fb.var.xres_virtual = width; fb->fb.var.yres_virtual = height * ANDROID_NUMBER_OF_BUFFERS; fb->fb.var.bits_per_pixel = 16; fb->fb.var.activate = FB_ACTIVATE_NOW; fb->fb.var.height = height; fb->fb.var.width = width; fb->fb.var.red.offset = 11; fb->fb.var.red.length = 5; fb->fb.var.green.offset = 5; fb->fb.var.green.length = 6; fb->fb.var.blue.offset = 0; fb->fb.var.blue.length = 5; framesize = width * height * ANDROID_BYTES_PER_PIXEL * ANDROID_NUMBER_OF_BUFFERS; fb->fb.screen_base = PGUIDE_FB_SCREEN_BASE; fb->fb.fix.smem_start = PGUIDE_FB_SMEM_START; fb->fb.fix.smem_len = framesize; ret = fb_set_var(&fb->fb, &fb->fb.var); if(ret) goto err_fb_set_var_failed; PGUIDE_FB_PROBE_SECOND; ret = register_framebuffer(&fb->fb); if(ret) goto err_register_framebuffer_failed; return 0;err_register_framebuffer_failed:err_fb_set_var_failed: kfree(fb);err_fb_alloc_failed: return ret;}static int pguide_fb_remove(struct platform_device *pdev){ struct pguide_fb *fb = platform_get_drvdata(pdev); PGUIDE_FB_REMOVE; kfree(fb); return 0;}static struct platform_driver pguide_fb_driver = { .probe = pguide_fb_probe, .remove = pguide_fb_remove, .driver = { .name = "pguide_fb" }};static int __init pguide_fb_init(void){ return platform_driver_register(&pguide_fb_driver);}static void __exit pguide_fb_exit(void){ platform_driver_unregister(&pguide_fb_driver);}module_init(pguide_fb_init);module_exit(pguide_fb_exit);MODULE_LICENSE("GPL");</pre><a name="androidDisplayDriversTroubleshooting"></a><h2>Troubleshooting</h2><p>Both of the following problems have a similar cause:</p><ul> <li><strong>Number keys</strong>: In the dialer application, when a number key is pressed to dial a phone number, the number doesn't display on the screen until after the next number has been pressed. </li> <li><strong>Arrow keys</strong>: When an arrow key is pressed, the desired icon doesn't get highlighted. For example, if you browse through icons in the Applications menu, you might notice that icons aren't highlighted as expected when you use the arrow key to navigate between options.</li></ul><p>Both problems are caused by an incorrect implementation of the frame buffer's page flipping. Key events are captured, but the graphical interface appears to drop every other frame. </p><p>Android relies on a double buffer to smoothly render page flips (please see <a href="androidDisplayDriverFunctionality">Functionality</a> for details).<p><span class="lh2"><a name="androidFooter"></a></span> </div> </div> <!-- end gc-pagecontent --> </div> <!-- end gooey wrapper --> </div> <!-- end codesearchresults --> <div id="gc-footer" dir="ltr"> <div class="text"> ©2008 Google<!-- - <a href="/">Code Home</a> - <a href="http://www.google.com/accounts/TOS">Site Terms of Service</a> - <a href="http://www.google.com/privacy.html">Privacy Policy</a> - <a href="/more">Site Directory</a> --></div> </div> <!-- end gc-footer --></div><!-- end gc-containter --><script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script><script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-18071-1"); pageTracker._setAllowAnchor(true); pageTracker._initData(); pageTracker._trackPageview(); } catch(e) {}</script><div id="jd-build-id"> v0.6 - 25 November 2008</div></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -