?? display_drivers.html
字號:
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Android - Porting Guide</title><script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=internal-codesite" type="text/javascript"></script><script src="http://code.google.com/js/jquery.js" type="text/javascript"></script><script type="text/javascript">var _tocPath_ = 'http://code.google.com/android/_toc.ezt';</script><script src="http://code.google.com/js/codesite.pack.01312008.js" type="text/javascript"></script><script language="JavaScript">function resizeHeight() { if(document.getElementById && !(document.all)) { height= document.getElementById('doxygen').contentDocument.body.scrollHeight + 20; document.getElementById('doxygen').style.height = height; } else if(document.all) { height= document.frames('doxygen').document.body.scrollHeight + 20; document.all.doxygen.style.height = height; }}</script><link href="http://code.google.com/css/codesite.pack.01312008.css" type="text/css" rel="stylesheet"></link><!--[if IE]><link rel="stylesheet" type="text/css" href="/css/iehacks.css" /><![endif]--><script src="http://code.google.com/android/assets/search_autocomplete.js"></script><link rel="stylesheet" type="text/css" href="http://code.google.com/css/semantic_headers.css" /><link rel="stylesheet" type="text/css" href="http://code.google.com/android/assets/style.css" /><script> jQuery(document).ready(function() { jQuery("pre").addClass("prettyprint"); }); </script><style type="text/css"><!--h1,h2,h3 { color: #000000;}--></style></head><body class="gc-documentation"><div id="gc-container"><a name="top"></a><div id="skipto"> </div><div id="langpref"> <!--<a class="dropdown" href="/">English</a> <span>|</span> <a href="/more/">Site Directory</a> --></div><div id="gc-header"> <div id="logo"><a href="http://code.google.com/android/index.html"><img src="http://code.google.com/android/images/logo_android.gif" alt="Android"/></a></div> <div id="search" style="inline"> <div id="searchForm" class="searchForm" style="height: 44px;"> <!--previously form was here--> </div> <!-- end searchForm --> <noscript> <style type="text/css"> .searchForm { display : none !important; } .searchForm2 { display : inline !important; } </style> </noscript> <div id="searchForm2" class="searchForm2" style="display:none"> <form id="searchbox_001456098540849067467:6whlsytkdqg" action="http://www.google.com/cse"> <input type="hidden" name="cx" value="001456098540849067467:6whlsytkdqg" /> <input type="hidden" name="cof" value="FORID:0" /> <input type="text" name="q" maxlength="2048" size="41" autocomplete="off" title="Google Code Search"/> <input type="submit" name="sa" value="Search" title="Search"/> <br/> <div class="greytext">e.g. "ajax apis" or "open source"</div> </form> </div> <!-- end searchForm2 --> </div> <!-- end search --></div><!-- end gc-header --><div id="searchControl" class="search-control"></div><!--[if IE]><iframe id="backiFrame" name="backiFrame" src='/dummy.html' style="display:none"></iframe><![endif]--><div id="codesiteContent"><a name="gc-topnav-anchor"></a><div id="gc-topnav"> <h1>Android Platform Development Kit</h1> <ul class="gc-topnav-tabs"> <li id="sdk_link"> <a href="http://code.google.com/android/index.html" title="Android Software Development Kit">SDK</a> </li> <li id="docs_link"> <a href="index.html" title="Official Android documentation">Docs</a> </li> <li id="faq_link"> <a href="http://code.google.com/android/kb/index.html" title="Answers to frequently asked questions about Android">FAQ</a> </li> <li> <a href="http://android-developers.blogspot.com/" title="Official Android blog">Blog</a> </li> <li> <a href="http://code.google.com/android/groups.html" title="Android developer forum">Group</a> </li> <li> <a href="http://code.google.com/android/terms.html" title="Android terms of service">Terms</a> </li> <li> <a href="mailto:android-pdk-feedback@google.com?subject=PDK%20Feedback&body=(filed%20from:%20display_drivers.html%20v0.6%20-%2025%20November%202008)%0D%0A%0D%0ASUMMARY:%0D%0A%0D%0A%0D%0A%0D%0ASTEPS%20TO%20REPRODUCE:%0D%0A%0D%0A%0D%0A%0D%0AADDITIONAL%20NOTES:">Report a Problem</a> </li> </ul></div><!-- end gc-topnav --><div class="g-section g-tpl-180"><a name="gc-toc"></a><div class="g-unit g-first" id="gc-toc"> <ul> <li> <h1><a href="index.html">Documentation</a></h1> <ul> <li> <strong>Introduction</strong> <ul> <li><a href="system_requirements.html">Device Requirements</a></li> </ul> </li> <li> <strong>Dev Environment Setup</strong> <ul> <li><a href="build_system.html">Build System</a></li> </ul> </li> <li> <strong>Basic Bring up</strong> <ul> <li><a href="build_new_device.html">Building New Device</a></li> <li><a href="bring_up.html">Bring up</a></li> <li><a href="keymaps_keyboard_input.html">Keymaps and Keyboard</a></li> <li><a href="display_drivers.html">Display Drivers</a></li> </ul> </li> <li> <strong>Multimedia</strong> <ul> <li><a href="audio_sub_system.html">Audio</a></li> <li><a href="camera.html">Camera</a></li> </ul> </li> <li> <strong>Power Management</strong> <ul> <li><a href="power_management.html">Power Management</a></li> </ul> </li> <li> <strong>Networking</strong> <ul> <li><a href="wifi.html">Wi-Fi</a></li> <li><a href="gps.html">GPS</a></li> <li><a href="bluetooth.html">Bluetooth</a></li> </ul> </li> <li> <strong>Telephony</strong> <ul> <li><a href="telephony.html">Radio Interface Layer</a></li> </ul> </li> <li> <strong>Testing</strong> <ul> <li><a href="instrumentation_testing.html">Instrumentation Testing</a></li> </ul> </li> </ul> </li> </ul></div><a name="gc-pagecontent"></a><div class="g-unit" id="gc-pagecontent"><div id="jd-content"><div class="jd-descr"><a name="androidDisplayDriversTitle"></a><h1>Display Drivers</h1><a name="toc"/><div style="padding:10px"><a href="#androidDisplayDriverIntroduction">Introduction</a><br/><a href="#androidDisplayDriverFunctionality">Functionality</a><br/><a href="#androidDisplayDriversSourceTemplate">Implementing Your Own Driver (Driver Template)</a><br/><a href="#androidDisplayDriversTroubleshooting">Troubleshooting</a><br/></div></font></div><a name="androidDisplayDriverIntroduction"></a><h2>Introduction</h2><p>This section describes how the display driver functions and offers a functional template designed to help you build your own device-specific driver.</p><p>Android relies on the standard frame buffer device (<code>/dev/fb0</code> or <code>/dev/graphics/fb0</code>) and driver as described in the <code>linux/fb.h</code> kernel header file. For more information regarding the standard Linux frame buffer, please see <a href="http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.24.y.git;a=blob;f=Documentation/fb/framebuffer.txt">The Frame Buffer Device</a> at <a href="http://kernel.org">http://kernel.org</a>.<a name="androidDisplayDriverFunctionality"></a><h2>Functionality</h2><p>In Android, every window gets implemented with an underlying Surface object, an object that gets placed on the framebuffer by SurfaceFlinger, the system-wide screen composer. Each Surface is double-buffered. The back buffer is where drawing takes place and the front buffer is used for composition. </p><p> When <code>unlockCanvas()</code> is called, the back buffer is posted, which means that it gets displayed and becomes available again. Android flips the front and back buffers, ensuring a minimal amount of buffer copying and that there is always a buffer for SurfaceFlinger to use for composition (which ensures that the screen never flickers or shows artifacts).</p><p>Android makes two requirements of the driver: a linear address space of mappable memory that it can write to directly and support for the rgb_565 pixel format. A typical frame display includes:</p><ul> <li>accessing the driver by calling open on <code>/dev/fb0</code></li> <li>using the <code>FBIOGET_FSCREENINFO</code> and <code>FBIOGET_VSCREENINFO</code> Input / Output Control (ioctl) calls to retrieve information about the screen</li> <li>using <code>FBIOPUT_VSCREENINFO</code> ioctl to attempt to create a virtual display twice the size of the physical screen and to set the pixel format to rgb_565. If this succeeds, double buffering is accomplished with video memory. </li></ul><p>When a page flip is required, Android makes another <code>FBIOPUT_VSCREENINFO</code> ioctl call with a new y-offset pointing to the other buffer in video memory. This ioctl, in turn, invokes the driver's <code>.fb_pan_display</code> function in order to do the actual flip. If there isn't sufficient video memory, regular memory is used and is just copied into the video memory when it is time do the flip. After allocating the video memory and setting the pixel format, Android uses <code>mmap()</code> to map the memory into the process's address space. All writes to the frame buffer are done through this mmaped memory.</p><p>To maintain adequate performance, framebuffer memory should be cacheable. If you use write-back, flush the cache before the frame buffer is written from DMA to the LCD. If that isn't possible, you may use write-through. As a last resort, you can also use uncached memory with the write-bugger enabled, but performance will suffer.</p><a name="androidDisplayDriversSourceTemplate"></a><h2>Implementing Your Own Driver (Driver Template)</h2><p>The following sample driver offers a functional example to help you build your own display driver. Modify <code>PGUIDE_FB...</code> macros as desired to match the requirements of your own device hardware.</p><pre class="prettyprint">/* * pguidefb.c * * Copyright 2007, Google Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. *//* * ANDROID PORTING GUIDE: FRAME BUFFER DRIVER TEMPLATE * * This template is designed to provide the minimum frame buffer * functionality necessary for Android to display properly on a new * device. The PGUIDE_FB macros are meant as pointers indicating * where to implement the hardware specific code necessary for the new * device. The existence of the macros is not meant to trivialize the * work required, just as an indication of where the work needs to be * done. */#include <linux/module.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/slab.h>#include <linux/delay.h>#include <linux/mm.h>#include <linux/fb.h>#include <linux/init.h>#include <linux/platform_device.h>/* Android currently only uses rgb565 in the hardware framebuffer */#define ANDROID_BYTES_PER_PIXEL 2/* Android will use double buffer in video if there is enough */#define ANDROID_NUMBER_OF_BUFFERS 2/* Modify these macros to suit the hardware */#define PGUIDE_FB_ROTATE /* Do what is necessary to cause the rotation */#define PGUIDE_FB_PAN /* Do what is necessary to cause the panning */#define PGUIDE_FB_PROBE_FIRST /* Do any early hardware initialization */#define PGUIDE_FB_PROBE_SECOND /* Do any later hardware initialization */#define PGUIDE_FB_WIDTH 320 /* Return the width of the screen */#define PGUIDE_FB_HEIGHT 240 /* Return the heighth of the screen */#define PGUIDE_FB_SCREEN_BASE 0 /* Return the virtual address of the start of fb memory */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -