PMSIS API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Data Structures

struct  pi_cpi_conf
 CPI device configuration structure. More...
 

Enumerations

enum  pi_cpi_format_e
 Image format identifier. More...
 

Functions

void pi_cpi_conf_init (struct pi_cpi_conf *conf)
 Initialize a CPI configuration with default values. More...
 
int pi_cpi_open (struct pi_device *device)
 Open a CPI device. More...
 
void pi_cpi_close (struct pi_device *device)
 Close an opened CPI device. More...
 
void pi_cpi_capture (struct pi_device *device, void *buffer, int32_t bufferlen)
 Capture a sequence of samples. More...
 
void pi_cpi_capture_async (struct pi_device *device, void *buffer, int32_t bufferlen, pi_task_t *task)
 Capture a sequence of samples asynchronously. More...
 
static void pi_cpi_control_start (struct pi_device *device)
 Start capturing samples. More...
 
static void pi_cpi_control_stop (struct pi_device *device)
 Stop capturing samples. More...
 
static void pi_cpi_set_format (struct pi_device *device, pi_cpi_format_e format)
 Set frame format. More...
 
static void pi_cpi_set_rowlen (struct pi_device *device, uint16_t rowlen)
 Set frame row length. More...
 
static void pi_cpi_set_frame_drop (struct pi_device *device, uint32_t nb_frame_dropped)
 Configure frame drop. More...
 
static void pi_cpi_set_filter (struct pi_device *device, uint32_t r_coeff, uint32_t g_coeff, uint32_t b_coeff, uint32_t shift)
 Configure frame filtering. (ONLY available in GAP8) More...
 
static void pi_cpi_set_rgb_sequence (struct pi_device *device, uint8_t rgb_seq)
 Configure RGB Sequence. More...
 
static void pi_cpi_set_slice (struct pi_device *device, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 Configure frame slicing. More...
 
static void pi_cpi_set_sync_polarity (struct pi_device *device, uint8_t vsync_pol_ena, uint8_t hsync_pol_ena)
 Configure vsync/hsync polarity. More...
 

Description

This API provides support for capturing images from an image sensor through the Camera Parallel Interface (CPI) and processing them.

Enumeration Type Documentation

This can be used to describe the format of the image going through the interface.

Enumerator
PI_CPI_FORMAT_RGB565 

RGB565 format.

PI_CPI_FORMAT_RGB555 

RGB555 format.

PI_CPI_FORMAT_RGB444 

RGB444 format.

PI_CPI_FORMAT_RGB888 

YUV422 format.

PI_CPI_FORMAT_BYPASS_LITEND 

Only least significant byte is kept.

PI_CPI_FORMAT_BYPASS_BIGEND 

Only most significant byte is kept.

Function Documentation

void pi_cpi_capture ( struct pi_device *  device,
void *  buffer,
int32_t  bufferlen 
)

Queue a buffer that will receive samples from the CPI interface. This function is synchronous and will block the caller until the specified amount of bytes is received. The buffer will receive samples only if the interface is started. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceA pointer to the structure describing the device.
bufferThe memory buffer where the captured samples will be transferred.
bufferlenThe size in bytes of the memory buffer.
void pi_cpi_capture_async ( struct pi_device *  device,
void *  buffer,
int32_t  bufferlen,
pi_task_t *  task 
)

Queue a buffer that will receive samples from the CPI interface. This function is asynchronous and will not block the caller. It is possible to call it several times in order to queue several buffers. At a minimum 2 buffers should be queued to ensure that no data sampled is lost. This is also the most efficient way to retrieve data from the CPI device. You should always make sure that at least 2 buffers are always queued, by queuing a new one as soon as the current one is full. The buffer will receive samples only if the interface is started. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
deviceA pointer to the structure describing the device.
bufferThe memory buffer where the captured samples will be transferred.
bufferlenThe size in bytes of the memory buffer.
taskThe task used to notify the end of transfer. See the documentation of pi_task for more details.
void pi_cpi_close ( struct pi_device *  device)

This function can be called to close an opened CPI device once it is not needed anymore in order to free all allocated resources. Once this function is called, the device is not accessible anymore and must be opened again before being used.

Parameters
deviceA pointer to the structure describing the device.
void pi_cpi_conf_init ( struct pi_cpi_conf conf)

The structure containing the configuration must be kept alive until the camera device is opened.

Parameters
confA pointer to the CPI configuration.
static void pi_cpi_control_start ( struct pi_device *  device)
inlinestatic

The samples arriving at the CPI interface are dropped until the interface is started by calling this function. Once started, the sampling will start at the next beginning of frame.

Parameters
deviceA pointer to the structure describing the device.
static void pi_cpi_control_stop ( struct pi_device *  device)
inlinestatic

The samples arriving at the CPI interface are dropped after this call.

Parameters
deviceA pointer to the structure describing the device.
int pi_cpi_open ( struct pi_device *  device)

This function must be called before the CPI device can be used. It configures the specified device that can then be used to refer to the opened device when calling other functions.

Parameters
deviceA pointer to the structure describing the device. This structure muts be allocated by the caller and kept alive until the device is closed.
Returns
0 if it succeeded or -1 if it failed.
static void pi_cpi_set_filter ( struct pi_device *  device,
uint32_t  r_coeff,
uint32_t  g_coeff,
uint32_t  b_coeff,
uint32_t  shift 
)
inlinestatic

Configure how to filter the input pixels to produce the 8bits output pixels. Each channel is multiplied by a coefficient. They are then summed together and shifted right to obtain an 8 bit pixel.

Parameters
deviceA pointer to the structure describing the device.
r_coeffRed channel is multipled by this coefficient.
g_coeffGreen channel is multipled by this coefficient.
b_coeffBlue channel is multipled by this coefficient.
shiftThe sum of all channels multiplied by their coefficient is shifted right by this value to fit an 8 bit pixel.
static void pi_cpi_set_format ( struct pi_device *  device,
pi_cpi_format_e  format 
)
inlinestatic

This can be used either when filtering is not active to specify which part of the samples to keep, or when filtering is active, to specify what is the input format, to be able to properly convert the image.

Parameters
deviceA pointer to the structure describing the device.
formatThe format of the input frame.
static void pi_cpi_set_frame_drop ( struct pi_device *  device,
uint32_t  nb_frame_dropped 
)
inlinestatic

For each sampled frame, the specified number of frames will be dropped before the next frame is sampled.

Parameters
deviceA pointer to the structure describing the device.
nb_frame_droppedNumber of frames to drop. Can be set to 0 to deactivate this feature.
static void pi_cpi_set_rgb_sequence ( struct pi_device *  device,
uint8_t  rgb_seq 
)
inlinestatic

Configure how the RGB be saved to L2 memory. (ONLY available in GAP9)

Parameters
deviceA pointer to the structure describing the device.
rgb_seqSequence of RGB: 3'h0 - RGB, 3'h1 - RBG, 3'h2 - GRB, 3'h3 - GBR, 3'h4 - BRG, 3'h5 - BGR,
static void pi_cpi_set_rowlen ( struct pi_device *  device,
uint16_t  rowlen 
)
inlinestatic

Set the row length of each frame, should be the same as the camera output. Will be set at the beginning of cpi open.

Parameters
deviceA pointer to the structure describing the device.
rowlenThe rowlen of each frame, should be divide by the datasize of CPI. For example, if the picture size is 320*240, cpi transfer datasize is 16bits, the rowlen should be: 320/2 (bytes).
static void pi_cpi_set_slice ( struct pi_device *  device,
uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h 
)
inlinestatic

Configure how to extract a window slice out of the input frame.

Parameters
deviceA pointer to the structure describing the device.
xx position of the window to extract.
yy position of the window to extract.
wWidth of the window to extract.
hHeight of the window to extract.
static void pi_cpi_set_sync_polarity ( struct pi_device *  device,
uint8_t  vsync_pol_ena,
uint8_t  hsync_pol_ena 
)
inlinestatic

Configure to reverse the vsync and/or hsync polarity. (ONLY available in GAP9)

Parameters
deviceA pointer to the structure describing the device.
vsync_pol_enaEnable the vsync polarity reversal.
hsync_pol_enaEnable the hsync polarity reversal.