MityDSP Documentation Index
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
MityDSP::tcDspCameraLink Class Reference

Instances of this class handle. More...

#include <core/DspCameraLink.h>

List of all members.

Classes

struct  tsFrameDataNotify
 This structure is the mailbox message structure passed up by the FrameCapture logic to calling applications. More...
union  tuFrameData
 This union represents the camera link FIFO data. More...

Public Member Functions

 tcDspCameraLink (void *apAddress, int anThreadPrio=8, int anFrameRows=1, int anFrameCols=1024)
 This constructor is used to open a DspCameraLink interface with the specified settings (optional).
virtual ~tcDspCameraLink ()
 This destructor is used to close up and free the resources tied to the associated Camera Link interface.
virtual int SetImageSize (int anFrameRows, int anFrameCols)
 Sets the Frame/Image size for subsequent captures expected on the LVDS link.
virtual int CaptureFrames (char *apCaptureBuffer, unsigned int anBufferSize, MBX_Handle ahCapturePost, int anNumFrames, int anNumFramesPerSemPost, void *apUserData=NULL)
 Initiate a frame capture cycle.
virtual int AbortCapture (bool abFlush=false)
 Aborts an ongoing frame capture cycle.
virtual int GetFIFODepth (void)
 Retrieves the current number of 32 bit samples available on the receive FIFO for the camera link interface.
virtual void GetImageSize (int &arFrameRows, int &arFrameCols)
 Get the current image size.
virtual int SetPacked (bool IsPacked)
 Sets the Camera Link interface to packing mode for data samples less than 16 bits in width.
virtual bool GetPacked (void)
 Gets the current packing mode of the camera link interface.
virtual int SetFrameBitsMask (bool ApplyMask)
 This method allows data words to have the frame and line strobe bits masked to zero in the FIFO data words.
virtual bool GetFrameBitsMasked (void)
 Returns the Frame and Line bits masking state of the camera link interface.
virtual bool IsFIFOEmpty (void)
 Determine the FIFO empty status.
virtual int GetNumPixelsPerFrame (void)
 Returns number of pixels capture per frame as seen on link interface.
virtual int GetNumTicksPerFrame (void)
 Returns period in EMIF clocks / 50 (nominally 1 usec) between successive Frame Start strobes on the LVDS camera link.
virtual int InvertDataValid (bool abInvert)
 This function can be used to invert the data valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been encountered with certain Hitachi products).
virtual int InvertLineValid (bool abInvert)
 This function can be used to invert the line valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been reported with certain products).
virtual int InvertFrameValid (bool abInvert)
 This function can be used to invert the frame valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been reported with certain products).
virtual int SetAltFIFOAddress (void *apAltFIFOAddr)
 This function can be used to instruct the DspCameraLink core that the read FIFO has been memory mapped to an alternate location of the FPGA.
virtual int SetFrameDecimation (int anDecimation)
 Sets the frame decimation factor to use when running camera link engine.
virtual int SetBitDepth (int anDepth)
 This function can be used to set the bit depth for a camera.
virtual int GetBitDepth (void)
 This function can be used to set the bit depth for a camera.
virtual int SetHorizontalSkip (int anSkip)
 This function can be used to set horizontal timing controls for the camera.
virtual int GetHorizontalSkip (void)
 This function can be used to get the horizontal timing controls for the camera.
virtual int SetVerticalSkip (int anSkip)
 This function can be used to set vertical timing controls for the camera.
virtual int GetVerticalSkip (void)
 This function can be used to get the vertical timing controls for the camera.

Static Public Member Functions

static int interrupt_dispatch (Arg arMyObject)
 Static interrupt dispatch routine.

Public Attributes

unsigned int mnInterruptCount
 ISR counter (debug).

Protected Types

enum  teFIFOLevel {
  eeEmpty, eeOneQ, eeHalf, eeThreeQ,
  eeFull, eeDMALevel
}
 The teFIFOLevel enumeration defines the various FIFO levels that may be checked for the tcDspAdcBase class. More...

Protected Member Functions

virtual void CaptureThread (void)
 Main capture thread.
virtual bool DrainFIFO (void)
 This routine will drain the FIFO on the engine.
virtual void LinkInterrupt (void)
 Interrupt service routine for the ADC cores.
virtual void Enable (bool abEnable)
 Enables the capture engine for the Camera Link Interface.
virtual bool IsEnabled (void)
 Returns the enabled state of the capture engine.
virtual void DisableFIFOInterrupts (void)
 Disables all FIFO interrupt enables.
virtual void SetFIFOInterruptLevel (teFIFOLevel aeLevel)
 Enables interrupts for the specified level.
virtual bool IsFpgaDmaCapable (void)
 Determines if the camera link core is capable of writing camera data directly to attached RAM (rather than requiring DSP to read from FIFO).
virtual bool IsDmaRollEnabled (void)
 Checks to see if the camera link DMA engine is configured to treat the SDRAM buffer as circular (and roll over when the top is reached).
virtual void ConfigureDmaBuffers (unsigned int *apStartAddr, unsigned int *apEndAddr, unsigned int anBytesPerInt, bool abSetRollOver)
 Set up a SDRAM shared buffer for the Camera Link Core to DMA to during image capture.

Static Protected Member Functions

static int CaptureThreadDispatch (Arg arMyObject)
 This method is a utility function to dispatch the CaptureThread method.

Protected Attributes

volatile unsigned int * mpBaseAddr
unsigned short mnMyIntMask
 core interrupt mask.
int mnMyIntLevel
 core interrupt level.
int mnMyIntVector
 core interrupt vector.
int mnFrameRows
 number of rows in a camera link frame
int mnFrameCols
 number of cols in a camera link frame
int mnNumFrames
 number of frames requested
int mnNumFramesPerMbx
 number of frames to report per message box
int mnTotalFrames
 total number of frames captured
MBX_Handle mhMailBox
 mailbox handle for frame report message
SEM_Handle mhDataSem
 DMA data transfer complete semaphore.
int mnBufferSize
 size of the working data buffer
int mnThreadPrio
 DMA receiver thread priority.
char * mpCaptureBuffer
 DMA data buffer to transfer to.
volatile bool mbStopCapture
 when true, abort capturing process
volatile int mnNextDMAStartAddr
 offset (character) to next location for DMA transfers
int mnHalfFifoSize
 1/2 size of the FIFO (DMA transfer size)
CACHE_L2Mode msL2Mode
 used for flushing the cache
bool mbIsPacked
 when true, pixels are packed into 2 16 bit words
int mnFifoFull
 very, very bad
void * mpUserData
 passed back to the user from data payload
volatile unsigned int * mpFIFOAddr
 holds address to use for FIFO access
volatile bool mbFpgaDmaEnabled
 true when direct DMA transfer is being used
volatile unsigned int mnNumFpgaDmaWords
 number of dma words FPGA will transfer

Detailed Description

Instances of this class handle.

See also:
tcDspCameraLink Page

Member Enumeration Documentation

The teFIFOLevel enumeration defines the various FIFO levels that may be checked for the tcDspAdcBase class.

Enumerator:
eeEmpty 

FIFO is empty.

eeOneQ 

FIFO is at least one quarter full.

eeHalf 

FIFO is at least one half full.

eeThreeQ 

FIFO is at least three quarters full.

eeFull 

FIFO is full.

eeDMALevel 

Direct FPGA DMA transfer count hit.


Constructor & Destructor Documentation

tcDspCameraLink::tcDspCameraLink ( void *  apAddress,
int  anThreadPrio = 8,
int  anFrameRows = 1,
int  anFrameCols = 1024 
)

This constructor is used to open a DspCameraLink interface with the specified settings (optional).

The interface is not yet enabled for capture following construction.

Parameters:
[in]apAddressBase Address of ADC core
[in]anThreadPrioPriority to run capture thread, used to parse DMA data from link.
[in]anFrameRowsNumber of rows per frame
[in]anFrameColsNumber of cols per frame
Returns:
None.
See also:
DspCameraLink.h
tcDspCameraLink::~tcDspCameraLink ( )
virtual

This destructor is used to close up and free the resources tied to the associated Camera Link interface.

Returns:
None.
See also:
DspCameraLink.h

Member Function Documentation

int tcDspCameraLink::SetImageSize ( int  anFrameRows,
int  anFrameCols 
)
virtual

Sets the Frame/Image size for subsequent captures expected on the LVDS link.

The camera link must be idle (no Frame Captures in process) for this command to execute.

Note:
These parameters must match the output of the camera link interface for proper operation.
Parameters:
anFrameRowsNumber of rows expected in subsequent images
anFrameColsNumber of cols expected in subsequent images
Returns:
0 on succes, -1 if camera is currently active
int tcDspCameraLink::CaptureFrames ( char *  apCaptureBuffer,
unsigned int  anBufferSize,
MBX_Handle  ahCaptureMbx,
int  anNumFrames,
int  anNumFramesPerMbx,
void *  apUserData = NULL 
)
virtual

Initiate a frame capture cycle.

This routine will enable the Camera Link FIFO capture logic and begin capturing Frames of data of size specified by SetImageSize() to the apCaptureBuffer memory.

The routine is designed to support buffering of multiple frames of data so that calling software may pipeline process one or more images while more are transferred from the link to memory. The user provided data is treated as a circular buffer window. The capture logic always starts at the zeroth offset for the first frame.

If the buffer is not an even multiple of anNumFramesPerMbx the "remainder" of the capture buffer will not be used; the capture process will roll over to the beginning of the capture buffer so as to gauranteee continuous frame data in memory.

Parameters:
[out]apCaptureBufferBuffered Memory, should be a minimum of 2xRowsxColsxanNumFramesPerMbx elements. Must by 4 byte aligned.
[in]anBufferSizesize of buffer in bytes.
[in]ahCaptureMbxMailbox handle that will be used to post tsFrameDataNotify mailbox messages.
[in]anNumFramesTotal number of frames to collect before stopping. If < 1, capture will run continuously until aborted with AbortCapture.
[in]anNumFramesPerMbxPost Number of frames collected per mailbox msg
[in]apUserDataoptional user pointer returned in mailbox msg, default NULL.
Warning:
it is the callers responsibility to ensure that he has preformed whatever processing is necessary on the incoming data before the capture code overwrites it. This is why the capture buffer should be a minimum of 2 times the amount of data recieved per semaphore post.
If number of pixels per frame is odd and you are packing, then you must specify an even number of frames per mailbox for transfer
Returns:
0 on success, -1 if camera is currently active or parameter error is detected.
int tcDspCameraLink::AbortCapture ( bool  abFlush = false)
virtual

Aborts an ongoing frame capture cycle.

Parameters:
[in]abFlush- indicates whether to flush the mailbox queue after the capture is aborted.
Returns:
0 on success (and camera is aborted), -1 if camera is not currently active

drain the mailbox queue of any extra camera information We drain it here so we know that the camera is shut down and we know that another command has not started.

int tcDspCameraLink::GetFIFODepth ( void  )
virtual

Retrieves the current number of 32 bit samples available on the receive FIFO for the camera link interface.

Returns:
none
void tcDspCameraLink::GetImageSize ( int &  arFrameRows,
int &  arFrameCols 
)
virtual

Get the current image size.

Parameters:
[out]arFrameRowssize of the frame in vertical direction
[out]arFrameColssize of the frame in the horizontal direction
Returns:
None.
int tcDspCameraLink::SetPacked ( bool  IsPacked)
virtual

Sets the Camera Link interface to packing mode for data samples less than 16 bits in width.

Parameters:
IsPackedwhen true, data should be packed
Returns:
non-zero on error
bool tcDspCameraLink::GetPacked ( void  )
virtual

Gets the current packing mode of the camera link interface.

Returns:
true if data packing is enabled.
int tcDspCameraLink::SetFrameBitsMask ( bool  ApplyMask)
virtual

This method allows data words to have the frame and line strobe bits masked to zero in the FIFO data words.

This may be useful for large data processing where individually masking the frame/line bits may be prohibitive for performance purposes. Use this feature with care.

Parameters:
ApplyMaskwhen true Frame and Line Valid bits will be disabled.
Returns:
non-zero on error.
bool tcDspCameraLink::GetFrameBitsMasked ( void  )
virtual

Returns the Frame and Line bits masking state of the camera link interface.

Returns:
true when masking is enabled.
bool tcDspCameraLink::IsFIFOEmpty ( void  )
virtual

Determine the FIFO empty status.

Returns:
true if Camera Link FIFO is empty.
See also:
DspCameraLink.h
int tcDspCameraLink::GetNumPixelsPerFrame ( void  )
virtual

Returns number of pixels capture per frame as seen on link interface.

Returns:
number of pixels per frame.
int tcDspCameraLink::GetNumTicksPerFrame ( void  )
virtual

Returns period in EMIF clocks / 50 (nominally 1 usec) between successive Frame Start strobes on the LVDS camera link.

Returns:
number of ticks
int tcDspCameraLink::InvertDataValid ( bool  abInvert)
virtual

This function can be used to invert the data valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been encountered with certain Hitachi products).

Parameters:
[in]abInvertwhen true, data valid line should be inverted.
Returns:
0
int tcDspCameraLink::InvertLineValid ( bool  abInvert)
virtual

This function can be used to invert the line valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been reported with certain products).

Parameters:
[in]abInvertwhen true, line valid line should be inverted.
Returns:
0
int tcDspCameraLink::InvertFrameValid ( bool  abInvert)
virtual

This function can be used to invert the frame valid strobe on cameras that do not assert this strobe (not technically compliant with camera link, but condition has been reported with certain products).

Parameters:
[in]abInvertwhen true, frame valid line should be inverted.
Returns:
0
int tcDspCameraLink::SetAltFIFOAddress ( void *  apAltFIFOAddr)
virtual

This function can be used to instruct the DspCameraLink core that the read FIFO has been memory mapped to an alternate location of the FPGA.

This may be useful for scenarios requiring high bus bandwidth, and the FPGA designer chooses to route the output FIFO to CE2 space with lower latency wait state configuration (or a configuration supporting synchronous burst RAM access, etc.) Once the default pointer to the FIFO has been overridden, the original pointer cannot be restored.

Parameters:
[in]apAltFIFOAddrpointer to alternate data FIFO location.
Returns:
0
int tcDspCameraLink::SetFrameDecimation ( int  anDecimation)
virtual

Sets the frame decimation factor to use when running camera link engine.

This specifies the number of frames to skip between capture cycles, allowing reduction of frame streaming rate into the DSP.

Parameters:
[in]anDecimationNumber of frames to skip between captures (range 0 to 15).
Returns:
0.
See also:
DspCameraLink.h
int tcDspCameraLink::SetBitDepth ( int  anDepth)
virtual

This function can be used to set the bit depth for a camera.

The FPGA core 0's bits above this in the frame buffer

Parameters:
[in]anDepth- bit depth (0-15).
Returns:
0
int tcDspCameraLink::GetBitDepth ( void  )
virtual

This function can be used to set the bit depth for a camera.

The FPGA core 0's bits above this in the frame buffer

Returns:
Bit Depth
int tcDspCameraLink::SetHorizontalSkip ( int  anSkip)
virtual

This function can be used to set horizontal timing controls for the camera.

Parameters:
[in]anSkip- Frame grabber skips this many pixels at the start of a line.
Returns:
0
int tcDspCameraLink::GetHorizontalSkip ( void  )
virtual

This function can be used to get the horizontal timing controls for the camera.

Returns:
Horizontal Skip
int tcDspCameraLink::SetVerticalSkip ( int  anSkip)
virtual

This function can be used to set vertical timing controls for the camera.

Parameters:
[in]anSkip- Frame grabber skips this many rows at the start of a frame.
Returns:
0
int tcDspCameraLink::GetVerticalSkip ( void  )
virtual

This function can be used to get the vertical timing controls for the camera.

Returns:
Frame grabber skips this many rows at the start of a frame.
int tcDspCameraLink::interrupt_dispatch ( Arg  ahMyObject)
static

Static interrupt dispatch routine.

Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.

Parameters:
[in]ahMyObjectThe "this->" pointer for the instance of tcDspAdcBase associated with this ISR.
Returns:
0
int tcDspCameraLink::CaptureThreadDispatch ( Arg  arMyObject)
staticprotected

This method is a utility function to dispatch the CaptureThread method.

Returns:
0
See also:
DspCameraLink.h
void tcDspCameraLink::CaptureThread ( void  )
protectedvirtual

Main capture thread.

This thread will capture incoming QDMA'd data from the camera link ISR. If there is enough frame data to post a mailbox message to the waiting client thread than it will do so. If more data is expected then the FIFO interrupts will be re-enabled.

See also:
DspCameraLink.h
bool tcDspCameraLink::DrainFIFO ( void  )
protectedvirtual

This routine will drain the FIFO on the engine.

It is useful when a clearing operation is require or after initialization.

Returns:
true if operation completed successfully.
See also:
DspCameraLink.h
void tcDspCameraLink::LinkInterrupt ( void  )
protectedvirtual

Interrupt service routine for the ADC cores.

The ISR reads and clears any pending interrupts. If any of the pending interrupts has a callback registered for it, the routine is called.

"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.

void tcDspCameraLink::Enable ( bool  abEnable)
protectedvirtual

Enables the capture engine for the Camera Link Interface.

Parameters:
[in]abEnableWhen true, capture is enabled.
Returns:
none.
See also:
DspCameraLink.h
bool tcDspCameraLink::IsEnabled ( void  )
protectedvirtual

Returns the enabled state of the capture engine.

Returns:
the pointer (this is a 32 bit word)
See also:
DspCameraLink.h
void tcDspCameraLink::DisableFIFOInterrupts ( void  )
protectedvirtual

Disables all FIFO interrupt enables.

Returns:
none
void tcDspCameraLink::SetFIFOInterruptLevel ( teFIFOLevel  aeLevel)
protectedvirtual

Enables interrupts for the specified level.

This routine will disable other level interrupts if they were previously enabled.

Parameters:
aeLevelLevel to Enable the Interrupt for
Returns:
none
bool tcDspCameraLink::IsFpgaDmaCapable ( void  )
protectedvirtual

Determines if the camera link core is capable of writing camera data directly to attached RAM (rather than requiring DSP to read from FIFO).

Returns:
true if FPGA DMA capable.
See also:
DspCameraLink.h
bool tcDspCameraLink::IsDmaRollEnabled ( void  )
protectedvirtual

Checks to see if the camera link DMA engine is configured to treat the SDRAM buffer as circular (and roll over when the top is reached).

Returns:
true if the engine will roll over to the beginning of the buffer
See also:
DspCameraLink.h
void tcDspCameraLink::ConfigureDmaBuffers ( unsigned int *  apStartAddr,
unsigned int *  apEndAddr,
unsigned int  anBytesPerInt,
bool  abSetRollOver 
)
protectedvirtual

Set up a SDRAM shared buffer for the Camera Link Core to DMA to during image capture.

This routine should only be used when the camera link core has been configured to support direct FPGA DMA to SDRAM.

Parameters:
[in]apStartAddrpointer to start address in SDRAM of buffer
[in]apEndAddrpointer to end address in SDRAM of buffer
[in]anBytesPerIntnumber of bytes between FPGA transfers per interrupt
[in]abSetRollOverwhen true, will true buffer as circular (continuous)
Note:
apStartAddr and apEndAddr must be 4 byte aligned.
anBytesPerInt must be a multiple of 4

If abSetRollOver is false, DMA activity will stop when the end address is reached.

Returns:
None.

Member Data Documentation

unsigned int MityDSP::tcDspCameraLink::mnInterruptCount

ISR counter (debug).

volatile unsigned int* MityDSP::tcDspCameraLink::mpBaseAddr
protected
unsigned short MityDSP::tcDspCameraLink::mnMyIntMask
protected

core interrupt mask.

int MityDSP::tcDspCameraLink::mnMyIntLevel
protected

core interrupt level.

int MityDSP::tcDspCameraLink::mnMyIntVector
protected

core interrupt vector.

int MityDSP::tcDspCameraLink::mnFrameRows
protected

number of rows in a camera link frame

int MityDSP::tcDspCameraLink::mnFrameCols
protected

number of cols in a camera link frame

int MityDSP::tcDspCameraLink::mnNumFrames
protected

number of frames requested

int MityDSP::tcDspCameraLink::mnNumFramesPerMbx
protected

number of frames to report per message box

int MityDSP::tcDspCameraLink::mnTotalFrames
protected

total number of frames captured

MBX_Handle MityDSP::tcDspCameraLink::mhMailBox
protected

mailbox handle for frame report message

SEM_Handle MityDSP::tcDspCameraLink::mhDataSem
protected

DMA data transfer complete semaphore.

int MityDSP::tcDspCameraLink::mnBufferSize
protected

size of the working data buffer

int MityDSP::tcDspCameraLink::mnThreadPrio
protected

DMA receiver thread priority.

char* MityDSP::tcDspCameraLink::mpCaptureBuffer
protected

DMA data buffer to transfer to.

volatile bool MityDSP::tcDspCameraLink::mbStopCapture
protected

when true, abort capturing process

volatile int MityDSP::tcDspCameraLink::mnNextDMAStartAddr
protected

offset (character) to next location for DMA transfers

int MityDSP::tcDspCameraLink::mnHalfFifoSize
protected

1/2 size of the FIFO (DMA transfer size)

CACHE_L2Mode MityDSP::tcDspCameraLink::msL2Mode
protected

used for flushing the cache

bool MityDSP::tcDspCameraLink::mbIsPacked
protected

when true, pixels are packed into 2 16 bit words

int MityDSP::tcDspCameraLink::mnFifoFull
protected

very, very bad

void* MityDSP::tcDspCameraLink::mpUserData
protected

passed back to the user from data payload

volatile unsigned int* MityDSP::tcDspCameraLink::mpFIFOAddr
protected

holds address to use for FIFO access

volatile bool MityDSP::tcDspCameraLink::mbFpgaDmaEnabled
protected

true when direct DMA transfer is being used

volatile unsigned int MityDSP::tcDspCameraLink::mnNumFpgaDmaWords
protected

number of dma words FPGA will transfer


  
Generated on Mon Apr 22 2013 11:33:03 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.