src/framebuffer.c File Reference

This file contains Frame Buffer Nuggets for Init, image display, and plotting of pixels. More...

#include <string.h>
#include "framebuffer.h"
#include "lq035q1dh02.h"
#include "bf52x_uart.h"
#include "tll_config.h"

Include dependency graph for framebuffer.c:


Enumerations

enum  { ACTIVEBUFFER1, ACTIVEBUFFER2 }

Functions

int fb_Init (fb_t *state, int devicenumber, enum fb_device_type devicetype, enum pixel_format pixFormat, isrDisp_t *pIsrDisp)
 Initialize the Frame Buffer System.
int fb_imageShow (fb_t *state)
 Image Display.
int fb_imageShowComplete (fb_t *state)
 Image Display Complete.
int fb_slackGet (fb_t *state)
 Slack Get.
int fb_statsGet (fb_t *state, unsigned int *nrUpdates, unsigned int *nrSame)
 statistic get
int fb_pixelPut (fb_t *state, unsigned char red, unsigned char green, unsigned char blue, unsigned short x_pos, unsigned short y_pos)
 Pixel Plot.
unsigned int fb_colorTargetGet (fb_t *state, unsigned char red, unsigned char green, unsigned char blue)
 return color in target format of display
void fb_pixelPutRaw (fb_t *state, unsigned int color, unsigned short x_pos, unsigned short y_pos)
 Pixel Plot.
int fb_qvgaRgb565TestPatternCreate (fb_t *state)
 function to fill color bar pattern
int fb_passiveBufferGet (fb_t *state, unsigned short **passiveBuffer)
 find passive buffer
int fb_Release (fb_t *state)
 Release the FB System.
int bb_isReady ()
 Background MDMA Ready.
static void bb_mdmaEnable (void)
static void bb_mdmaDisable (void)
static void mdmaInit (fb_t *state)
int bb_Init (fb_t *state)
 Initialize the Background Buffer System.
void bb_pixelPutRaw (unsigned int color, unsigned short x_pos, unsigned short y_pos)
 Background Pixel Plot.
int bb_pixelPut (unsigned char red, unsigned char green, unsigned char blue, unsigned short x_pos, unsigned short y_pos)
 Background Pixel Plot.
int bb_imageShow (unsigned short *displayBuffer)
 Background Image Display.
int bb_imageCommit ()
 Background Image Commit.
int bb_clearPassive ()
 Passive Buffer Clear.
void bb_imageWaitForReady ()
 Block until we are sure that the MDMA has finished copying the background for the provided foreground buffer.

Variables

static unsigned short qvgaDmaBuffer [FB_NUM_BUFFERS][320 *250]
static const short XLEN = 320
static const short YLEN = 240
static unsigned short backgroundBuffer1 [320 *240]
static unsigned short backgroundBuffer2 [320 *240]
static unsigned char bb_MDMA_isReady
static enum { ... }  bb_state

Detailed Description

This file contains Frame Buffer Nuggets for Init, image display, and plotting of pixels.

It also contains internal (non user exposed) functions. It sets up the appropriate device level system. It also manages the image buffers for used for creating an image (pixelPut) and displaying an image on the screen (imageShow). The functions available are:

Exposed Functions:

fb_Init : verifies input parameters and calls the appropriate device level Init function fb_pixelPut : Plots a pixel in the color and at coordinates given as input parameter fb_imageShow : displays, a test image or an image painted using pixelPut or a custom image transferred directly to SDRAM. It calls the appropriate device level function for actual display. fb_Release : Releases and Display related systems like DMA, PPI etc, via call to the device level Release function fb_qvgaRgb565TestPatternCreate : generates the color bar pattern for a QVGA screen fb_passiveBufferGet : retrieves the current passive buffer (the one not being displayed on the screen)

Version:
1.7
Date:
02/23/2013
Author:
C. Lavania
LastChange:
Id
framebuffer.c 1113 2013-03-29 02:43:10Z ovaskevi

XqJv Copyright(c) 2010-2012 The Learning Labs,Inc. All Rights Reserved jVkB

Organization: The Learning Labs

Tested: Compiler bfin-elf-gcc; Output format Bare Metal Elf; Target TLL6527M V1.2

Revised: 20130328, Author: O. Vaskevich, Notes: Removed MDMA interrupt; added background buffer; added wait; fixed flickering bug

Revised: 20120331, Author: C. Lavania, Notes: Cleaned up

Revised: 20120329, Author: C. Lavania, Notes: Modified imageShow to remove addition of blanking lines since its taken care of by the passiveBuffer address returned from the device layer

Revised: 20120328, Author: C. Lavania, Notes: Modified, to read passive buffer from the device level state variable, used macros for QVGA width and QVGA height, and test pattern height

Revised: 20120327, Author: C. Lavania, Notes: Modified the exposed functions to use only 2 buffers instead of 3, introduced functions to create test pattern, and providing the passive buffer to the user code.

Revised: 20120322, Author: C. Lavania, Notes: Cleaned up the code, moved pixelPut from device level to FB level

Revised: 20120321, Author: C. Lavania, Notes: Added static arrays to use as DMA buffers, added functionality to fill the DMA buffers in imageShow function,added internal function to create test pattern

Created: 20120317, Author: C. Lavania, Notes: Created the Initial Version

References:

1. ADSP-BF52x Blackfin Processor Hardware Reference, Revision 1.0, March 2010


Enumeration Type Documentation

anonymous enum

Enumerator:
ACTIVEBUFFER1 
ACTIVEBUFFER2 


Function Documentation

int bb_clearPassive (  ) 

Passive Buffer Clear.

This function clears the current passive buffer

Note: Call this function to reset passive buffer

Pre-conditions:

Post conditions

int bb_imageCommit (  ) 

Background Image Commit.

This function switches between active and passive background buffers

Note: This function needs to be called to commit changes to the background buffer

Pre-conditions:

Post conditions

Returns:
int status (0 for success, -1 for failure)

int bb_imageShow ( unsigned short *  displayBuffer  ) 

Background Image Display.

This function loads image stored in the active background buffer onto the passive frame buffer.

Note : This function needs to be called each time the active frame buffer is changed

Pre-conditions:

Post conditions:

Parameters:

Parameters:
displayBuffer pointer to receiving buffer
Returns:
int status (0 for success, -1 for failure)

void bb_imageWaitForReady (  ) 

Block until we are sure that the MDMA has finished copying the background for the provided foreground buffer.

int bb_Init ( fb_t state  ) 

Initialize the Background Buffer System.

This function initializes the background overlay buffers

Pre-conditions:

Post conditions:

Parameters:

Returns:
int status (0 for success, -1 for failure)

int bb_isReady (  ) 

Background MDMA Ready.

This function checks if the MDMA used in the Background buffer is ready

Note: Call this function to check if a background buffer to frame buffer copy is taking place

Pre-conditions:

Post conditions

Returns:
int ready (0 for not ready, 1 for ready)

static void bb_mdmaDisable ( void   )  [static]

static void bb_mdmaEnable ( void   )  [static]

int bb_pixelPut ( unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned short  x_pos,
unsigned short  y_pos 
)

Background Pixel Plot.

This function plots a pixel at the given location with given color

Pre-conditions:

Post conditions:

Parameters:

Parameters:
red red value of the color
green green value of the color
blue blue value of the color
x_pos X Coordinate (in pixels)
y_pos Y Coordinate (in pixels)
Returns:
int status (0 for success, -1 for failure)

void bb_pixelPutRaw ( unsigned int  color,
unsigned short  x_pos,
unsigned short  y_pos 
) [inline]

Background Pixel Plot.

This function plots a pixel at the given location with given color

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
color in target format
x_pos X Coordinate (in pixels)
y_pos Y Coordinate (in pixels)
Returns:
int status (0 for success, -1 for failure)

unsigned int fb_colorTargetGet ( fb_t state,
unsigned char  red,
unsigned char  green,
unsigned char  blue 
)

return color in target format of display

int fb_imageShow ( fb_t state  ) 

Image Display.

This function displays an image stored in the passive buffer on the screen.

Note : This function needs to be called each time a new image needs to be displayed on the screen

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
Returns:
int status (0 for success, -1 for failure)

int fb_imageShowComplete ( fb_t state  ) 

Image Display Complete.

Blocks caller until last image show is completed. Returns immediately if no switch is pending.

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
Returns:
int status (0 for success, -1 for failure)

int fb_Init ( fb_t state,
int  devicenumber,
enum fb_device_type  devicetype,
enum pixel_format  pixFormat,
isrDisp_t pIsrDisp 
)

Initialize the Frame Buffer System.

This function initializes LCD System including related Timer, PPI, DMA Systems.

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
devicenumber to store the instance of the device being used (0 - 4)
devicetype the actual display device being accessed
pixFormat pixel is RGB565 or YUYV422
Returns:
int status (0 for success, -1 for failure)

int fb_passiveBufferGet ( fb_t state,
unsigned short **  passiveBuffer 
)

find passive buffer

This function stores the address of the passive buffer in the passed buffer parameter

Pre-conditions:

Post conditions:

Parameters:
state address of FB state variable
passiveBuffer stores the address of the pointer which will store the passiveBuffer starting point
Returns:
void

int fb_pixelPut ( fb_t state,
unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned short  x_pos,
unsigned short  y_pos 
)

Pixel Plot.

This function plots a pixel at the given location with given color

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
red red value of the color
green green value of the color
blue blue value of the color
x_pos X Coordinate (in pixels)
y_pos Y Coordinate (in pixels)
Returns:
int status (0 for success, -1 for failure)

void fb_pixelPutRaw ( fb_t state,
unsigned int  color,
unsigned short  x_pos,
unsigned short  y_pos 
) [inline]

Pixel Plot.

This function plots a pixel at the given location with given color

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
color in target format
x_pos X Coordinate (in pixels)
y_pos Y Coordinate (in pixels)
Returns:
int status (0 for success, -1 for failure)

int fb_qvgaRgb565TestPatternCreate ( fb_t state  ) 

function to fill color bar pattern

This function creates the color bar pattern in the passive DMA Buffer

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
Returns:
void

int fb_Release ( fb_t state  ) 

Release the FB System.

This function releases FB System including related Timer, PPI, DMA Systems.

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of FB state variable
Returns:
int status (0 for success, -1 for failure)

int fb_slackGet ( fb_t state  ) 

Slack Get.

Returns nanoSec until pending image switch is executed, 0 if no switch is pending.

Pre-conditions:

Post conditions:

Parameters:

Parameters:
state address of LCD state variable
Returns:
nanoseconds until pending switch occurs

int fb_statsGet ( fb_t state,
unsigned int *  nrUpdates,
unsigned int *  nrSame 
)

statistic get

gathers display statistics nrUpdates number of images updated nrSame number of identical images displayed

Pre-conditions:

Post condtions:

Parameters:

Parameters:
state address of LCD state variable
Returns:
int status (0 for success, -1 for failure)

static void mdmaInit ( fb_t state  )  [static]


Variable Documentation

unsigned short backgroundBuffer1[320 *240] [static]

unsigned short backgroundBuffer2[320 *240] [static]

unsigned char bb_MDMA_isReady [static]

enum { ... } bb_state [static]

unsigned short qvgaDmaBuffer[FB_NUM_BUFFERS][320 *250] [static]

const short XLEN = 320 [static]

const short YLEN = 240 [static]


Generated on 3 Mar 2014 for PAL bare-c Library by  doxygen 1.4.7