📄 sample_ppi_driver.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#sample_ppi_driver" class="toc">Sample PPI Driver</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#init_function" class="toc">Init Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#file_operations_table" class="toc">File Operations Table</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#open_function" class="toc">Open Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#read_function" class="toc">Read Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#ppi_interrupt_function" class="toc">PPI Interrupt Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#ppi_error_interrupt_function" class="toc">PPI Error Interrupt Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#ioctl_code" class="toc">IOCTL Code</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#fasync_helper" class="toc">FASYNC Helper</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#helper_functions" class="toc">Helper functions</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#release_function" class="toc">Release Function</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#driver_removal" class="toc">Driver Removal</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#hardware_schematics" class="toc">Hardware Schematics</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="sample_ppi_driver" id="sample_ppi_driver">Sample PPI Driver</a></h2><div class="level2"><p> This driver can be used to capture video Frames from the PPI port. The source code can be found in the file <strong>linux-2.6.x/drivers/char/adsp-ppifcd.c</strong></p><p>The interface to the camera sensor is shown here. </p><p><a href="camera_sensor_interface.html" class="wikilink1" title="camera_sensor_interface.html">Camera Sensor Interface</a></p><p>Parts of that source are produced here but you will need to refer to the in kernel source for the full driver.</p><p> This driver also has the following features </p><ul><li class="level1"><div class="li"> High speed data input from the PPI device via DMA</div></li><li class="level1"><div class="li"> Configuration of the PPI device</div></li><li class="level1"><div class="li"> Interrupts Transfer Complete and Error Detection</div></li><li class="level1"><div class="li"> Fasync notification of Transfer Complete</div></li></ul><p>The PPI Input device has a number of configurable features, this driver uses the following: </p><ul><li class="level1"><div class="li"> POL_S - invert Frame Sync 1 and Frame Sync 2</div></li><li class="level1"><div class="li"> POL_C - invert Clock</div></li><li class="level1"><div class="li"> PPI_DATA_LEN - port width</div></li><li class="level1"><div class="li"> PPI_PACKING - Pack 2 8 bits words into a single 16 bit output</div></li><li class="level1"><div class="li"> CFG_GP_Input_3Syncs - Selects full ( Hsync, Vsync and Frame ) or single Frame Sync</div></li><li class="level1"><div class="li"> GP_Input_Mode - selects input mode </div></li></ul><p> The PPI Transfer can use a GPIO pin to start the transfer process</p><p> Two Camera Sensor Module Definitions are available as “preset modes” for the driver.</p><p>To start understanding this driver first search for the init function.</p></div><!-- SECTION [1-1314] --><h3><a name="init_function" id="init_function">Init Function</a></h3><div class="level3"><p> Here is the code for the init function</p><p>Note the following features </p><ul><li class="level1"><div class="li"> char device with PPI_MAJOR as a major number</div></li><li class="level1"><div class="li"> Uses ppi_fops for a file operations table</div></li><li class="level1"><div class="li"> Device name PPI_DEVNAME</div></li></ul><p> The major number and the device name are defined at the start of the driver source</p></div><!-- SECTION [1315-1788] --><h3><a name="file_operations_table" id="file_operations_table">File Operations Table</a></h3><div class="level3"><p> The file operations table shows the features available to the User code</p><p>Note that </p><ul><li class="level1"><div class="li"> Read Only , no Write</div></li><li class="level1"><div class="li"> fasync notification used to send SIGIO to the user code on read completion</div></li><li class="level1"><div class="li"> IOCTL used to configure the driver</div></li></ul></div><!-- SECTION [1789-2135] --><h3><a name="open_function" id="open_function">Open Function</a></h3><div class="level3"><p> The Open Function sets up the device for use with a user code function.</p><p>Note the following features</p><ul><li class="level1"><div class="li"> Minor Number Check</div></li><li class="level1"><div class="li"> Single user check ( only one user process at a time )</div></li><li class="level1"><div class="li"> NON BLOCKING operation available</div></li><li class="level1"><div class="li"> DMA channel requested with <strong>ppifcd_irq</strong> as an irq handler function</div></li><li class="level1"><div class="li"> PPI Error handler IRQ requested with <strong>ppifcd_irq_error</strong> as an irq handler function</div></li><li class="level1"><div class="li"> PPI device configured with the function <strong>ppifcd_reg_reset</strong></div></li></ul></div><!-- SECTION [2136-2694] --><h3><a name="read_function" id="read_function">Read Function</a></h3><div class="level3"><p> This function services the user request to read data from the device</p><p>Note the following </p><ul><li class="level1"><div class="li"> flush out the input memory data cache </div></li><li class="level1"><div class="li"> 2 dimensional DMA input </div></li><li class="level1"><div class="li"> 8 or 16 bit data input words</div></li><li class="level1"><div class="li"> use of gpio flags to trigger PPI</div></li><li class="level1"><div class="li"> this driver is writing directly into the user space buffer</div></li><li class="level1"><div class="li"> this can only be done on a MMUless system</div></li></ul></div><!-- SECTION [2695-3148] --><h3><a name="ppi_interrupt_function" id="ppi_interrupt_function">PPI Interrupt Function</a></h3><div class="level3"><p> This services the “data transfer complete” interrupt from the DMA controller</p><p>Note the following </p><ul><li class="level1"><div class="li"> Sends SIGIO to the user process </div></li><li class="level1"><div class="li"> sets a “read complete” condition</div></li><li class="level1"><div class="li"> wakes up a sleeping reader ( if there is one )</div></li></ul></div><!-- SECTION [3149-3495] --><h3><a name="ppi_error_interrupt_function" id="ppi_error_interrupt_function">PPI Error Interrupt Function</a></h3><div class="level3"><p> This services the “data transfer error” interrupt from the DMA controller In this example the Interrupt service function is the same as the data complete function. Normally additional error handling would be added to this driver.</p></div><!-- SECTION [3496-3863] --><h3><a name="ioctl_code" id="ioctl_code">IOCTL Code</a></h3><div class="level3"><p> This is used to set up the device for a particular operation. This driver is designed to interface to a Camera. The device can be “preset” for a particular camera if required but the IOCTL functions can modify the preset settings.</p><p>A list of the commands processed is here </p><ul><li class="level1"><div class="li"> CMD_PPI_SET_PIXELS_PER_LINE</div></li><li class="level1"><div class="li"> CMD_PPI_SET_LINES_PER_FRAME</div></li><li class="level1"><div class="li"> CMD_PPI_SET_PPICONTROL_REG</div></li><li class="level1"><div class="li"> CMD_PPI_SET_PPIDEALY_REG</div></li><li class="level1"><div class="li"> CMD_SET_TRIGGER_GPIO</div></li><li class="level1"><div class="li"> CMD_PPI_GET_ALLCONFIG</div></li><li class="level1"><div class="li"> CMD_PPI_GET_SYSTEMCLOCK</div></li></ul></div><!-- SECTION [3864-4451] --><h3><a name="fasync_helper" id="fasync_helper">FASYNC Helper</a></h3><div class="level3"><p> This is called when the user code sets up the device to deliver SIGIO signals.</p><p>It is needed by the inner kernel to associate the fasync wait queue with the user process.</p></div><!-- SECTION [4452-4737] --><h3><a name="helper_functions" id="helper_functions">Helper functions</a></h3><div class="level3"><p> This driver has a few helper functions to perform the following</p><ul><li class="level1"><div class="li"> get the system clock</div></li><li class="level1"><div class="li"> reset the ppi device</div></li></ul></div><h4><a name="ppi_get_sclk" id="ppi_get_sclk">ppi_get_sclk</a></h4><div class="level4"></div><h4><a name="ppifcd_reg_reset" id="ppifcd_reg_reset">ppifcd_reg_reset</a></h4><div class="level4"></div><!-- SECTION [4738-5117] --><h3><a name="release_function" id="release_function">Release Function</a></h3><div class="level3"><p> The Release function terminates the use of the device by the user function</p><p>NOTE PPI error IRQ is not released yet</p></div><!-- SECTION [5118-5351] --><h3><a name="driver_removal" id="driver_removal">Driver Removal</a></h3><div class="level3"><p> If the Driver is a module and not permanently compiled into the Kernel the following code will unregister the device and clean up the system.</p></div><!-- SECTION [5352-5612] --><h3><a name="hardware_schematics" id="hardware_schematics">Hardware Schematics</a></h3><div class="level3"><p> <a href="media/schematic_ppi_cmos_camera.jpg" class="media" target="_blank" title="schematic_ppi_cmos_camera.jpg"><img src="media/schematic_ppi_cmos_camera.jpg" class="media" alt="" /></a> </p></div><!-- SECTION [5613-] --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -