Synergy Software Package User's Manual

Driver for the JPEG CODEC. More...

Data Structures

struct  jpeg_decode_instance_ctrl_t
 

Functions

ssp_err_t R_JPEG_Decode_Open (jpeg_decode_ctrl_t *const p_api_ctrl, jpeg_decode_cfg_t const *const p_cfg)
 Initialize the JPEG Codec module. This function configures the JPEG Codec for decoding operation, sets up the registers for data format and pixel format based on user-supplied configuration parameters. Interrupts are enabled to support image size read operation and callback functions. More...
 
ssp_err_t R_JPEG_Decode_OutputBufferSet (jpeg_decode_ctrl_t *p_api_ctrl, void *p_output_buffer, uint32_t output_buffer_size)
 Assign output buffer to the JPEG Codec for storing output data. More...
 
ssp_err_t R_JPEG_Decode_LinesDecodedGet (jpeg_decode_ctrl_t *p_api_ctrl, uint32_t *p_lines)
 Returns the number of lines decoded into the output buffer. More...
 
ssp_err_t R_JPEG_Decode_InputBufferSet (jpeg_decode_ctrl_t *const p_api_ctrl, void *p_data_buffer, uint32_t data_buffer_size)
 Assign input data buffer to JPEG codec for processing. More...
 
ssp_err_t R_JPEG_Decode_ImageSubsampleSet (jpeg_decode_ctrl_t *const p_api_ctrl, jpeg_decode_subsample_t horizontal_subsample, jpeg_decode_subsample_t vertical_subsample)
 Configure horizontal and vertical subsample. More...
 
ssp_err_t R_JPEG_Decode_HorizontalStrideSet (jpeg_decode_ctrl_t *p_api_ctrl, uint32_t horizontal_stride)
 Configure horizontal stride setting. More...
 
ssp_err_t R_JPEG_Decode_Close (jpeg_decode_ctrl_t *p_api_ctrl)
 Cancel an outstanding JPEG codec operation and close the device. More...
 
ssp_err_t R_JPEG_Decode_ImageSizeGet (jpeg_decode_ctrl_t *p_api_ctrl, uint16_t *p_horizontal_size, uint16_t *p_vertical_size)
 Obtain the size of the image. This operation is valid during JPEG decoding operation. More...
 
ssp_err_t R_JPEG_Decode_StatusGet (jpeg_decode_ctrl_t *p_api_ctrl, jpeg_decode_status_t *p_status)
 Get the status of the JPEG codec. This function can also be used to poll the device. More...
 
ssp_err_t R_JPEG_Decode_PixelFormatGet (jpeg_decode_ctrl_t *p_api_ctrl, jpeg_decode_color_space_t *p_color_space)
 Get the input pixel format. More...
 
ssp_err_t R_JPEG_Decode_VersionGet (ssp_version_t *p_version)
 Get version of the display interface and GLCD HAL code. More...
 

Detailed Description

Driver for the JPEG CODEC.

Function Documentation

◆ R_JPEG_Decode_Close()

ssp_err_t R_JPEG_Decode_Close ( jpeg_decode_ctrl_t p_api_ctrl)

Cancel an outstanding JPEG codec operation and close the device.

Return values
SSP_SUCCESSThe input data buffer is properly assigned to JPEG Codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_NOT_OPENJPEG not opened.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Clear JPEG JINTE0 interrupt and JINTE1 interrupt.

Disable JEDI and JDTI at NVIC

Power off the JPEG codec.

Reset the jpeg status flag in the driver.

Unlock module at BSP level.

◆ R_JPEG_Decode_HorizontalStrideSet()

ssp_err_t R_JPEG_Decode_HorizontalStrideSet ( jpeg_decode_ctrl_t p_api_ctrl,
uint32_t  horizontal_stride 
)

Configure horizontal stride setting.

Note
Use when the horizontal stride needs to match the image width and the image size is unknown when opening the JPEG driver. (If the image size is known prior to the open call, pass the horizontal stride value in the jpef_cfg_t structure.) After the image size becomes available, use this function to update the horizontal stride value. If the driver must decode one line at a time, the horizontal stride can be set to zero.
Return values
SSP_SUCCESSHorizontal Stride value is properly configured.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_INVALID_ALIGNMENTHorizontal stride is zero or not 8-byte aligned.
SSP_ERR_NOT_OPENJPEG not opened.

Record the horizontal stride value in the control block

Set the horizontal stride.

If the parameters all are set, resume the core to decode.

For the given buffer size, compute number of lines to decode.

◆ R_JPEG_Decode_ImageSizeGet()

ssp_err_t R_JPEG_Decode_ImageSizeGet ( jpeg_decode_ctrl_t p_api_ctrl,
uint16_t *  p_horizontal_size,
uint16_t *  p_vertical_size 
)

Obtain the size of the image. This operation is valid during JPEG decoding operation.

Return values
SSP_SUCCESSThe image size is available and the horizontal and vertical values are stored in the memory pointed to by p_horizontal_size and p_vertical_size.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_IMAGE_SIZE_UNKNOWNThe image size is unknown. More input data may be needed.
SSP_ERR_INVALID_MODEJPEG Codec module is not decoding.
SSP_ERR_NOT_OPENJPEG is not opened.

◆ R_JPEG_Decode_ImageSubsampleSet()

ssp_err_t R_JPEG_Decode_ImageSubsampleSet ( jpeg_decode_ctrl_t *const  p_api_ctrl,
jpeg_decode_subsample_t  horizontal_subsample,
jpeg_decode_subsample_t  vertical_subsample 
)

Configure horizontal and vertical subsample.

Note
Use for scaling the decoded image.
Return values
SSP_SUCCESSHorizontal Stride value is properly configured.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_INVALID_ARGUMENTSub-sample setting is invalid.
SSP_ERR_NOT_OPENJPEG not opened.

Update horizontal sub-sample setting.

◆ R_JPEG_Decode_InputBufferSet()

ssp_err_t R_JPEG_Decode_InputBufferSet ( jpeg_decode_ctrl_t *const  p_api_ctrl,
void *  p_data_buffer,
uint32_t  data_buffer_size 
)

Assign input data buffer to JPEG codec for processing.

Note
After the amount of data is processed, the JPEG driver triggers a callback function with the flag JPEG_OPERATION_INPUT_PAUSE set. The application supplies the next chunk of data to the driver so JPEG decoding can resume.

The JPEG decoding operation automatically starts after both the input buffer and the output buffer are set, and the output buffer is big enough to hold at least one line of decoded image data.

Return values
SSP_SUCCESSThe input data buffer is properly assigned to JPEG Codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL, or the pointer to the input_buffer is NULL, or the input_buffer_size is 0.
SSP_ERR_INVALID_ALIGNMENTBuffer starting address is not 8-byte aligned.
SSP_ERR_NOT_OPENJPEG not opened.

Configure the input buffer address.

If the system is idle, start the JPEG engine. This allows the system to obtain image information (image size and input pixel format). This information is needed to drive the decode process later on.

Based on buffer size, detect the in count mode setting. The driver is able to read input data in chunks. However the size of each chunk is limited to BUFFER_MAX_SIZE. Therefore, if the input data size is larger than BUFFER_MAX_SIZE, the driver assumes the entire input data is present, and can be decoded without additional input data. Otherwise, the driver enables input stream feature. This works even if the entire input size is smaller than BUFFER_MAX_SIZE.

◆ R_JPEG_Decode_LinesDecodedGet()

ssp_err_t R_JPEG_Decode_LinesDecodedGet ( jpeg_decode_ctrl_t p_api_ctrl,
uint32_t *  p_lines 
)

Returns the number of lines decoded into the output buffer.

Note
Use this function to retrieve number of image lines written to the output buffer after JPEG decoded a partial image. Combined with the horizontal stride settings and the output pixel format, the application can compute the amount of data to read from the output buffer.
Return values
SSP_SUCCESSThe output buffer is properly assigned to JPEG codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL, or the pointer to the output_buffer. is NULL, or the output_buffer_size is 0.
SSP_ERR_NOT_OPENJPEG not opened.

◆ R_JPEG_Decode_Open()

ssp_err_t R_JPEG_Decode_Open ( jpeg_decode_ctrl_t *const  p_api_ctrl,
jpeg_decode_cfg_t const *const  p_cfg 
)

Initialize the JPEG Codec module. This function configures the JPEG Codec for decoding operation, sets up the registers for data format and pixel format based on user-supplied configuration parameters. Interrupts are enabled to support image size read operation and callback functions.

Return values
SSP_SUCCESSJPEG Codec module is properly configured and is ready to take input data.
SSP_ERR_IN_USEJPEG Codec is already in use.
SSP_ERR_ASSERTIONPointer to the control block or the configuration structure is NULL.
SSP_ERR_HW_LOCKEDJPEG Codec resource is locked.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

Verify JPEG Codec is not already used.

Update the common control parameter with the control and JEDI and JDTI callback handler for JPEG decode, the handlers will be called from r_jpeg_common, which implements JPEG JDTI and JEDI ISR for r_jpeg_decode and r_jpeg_encode driver.

Record the configuration settings.

Initialize horizontal stride value.

Initialize output buffer size.

Initialize total_lines_decoded

Initialize horizontal sub-sample setting.

Provide power to the JPEG module.

Clear the image horizontal and vertical size, before starting the JPEG decode

Perform bus reset

Reset the destination buffer address.

Reset the source buffer address.

Reset the horizontal stride.

Configure the JPEG module for decode operation.

Set image format for the decoded image.

If the output pixel format is ARGB8888, also configure the alpha value.

Set the alpha value for the decoded image.

Set the output data format.

The following interrupts are enabled: Interrupt on all errors Interrupt on Image Size

Record user supplied callback routine.

Set the driver status.

All done. Return success.

◆ R_JPEG_Decode_OutputBufferSet()

ssp_err_t R_JPEG_Decode_OutputBufferSet ( jpeg_decode_ctrl_t p_api_ctrl,
void *  p_output_buffer,
uint32_t  output_buffer_size 
)

Assign output buffer to the JPEG Codec for storing output data.

Note
The number of image lines to be decoded depends on the size of the buffer and the horizontal stride settings. Once the output buffer size is known, the horizontal stride value is known, and the input pixel format is known (the input pixel format is obtained by the JPEG decoder from the JPEG headers), the driver automatically computes the number of lines that can be decoded into the output buffer. After these lines are decoded, the JPEG engine pauses and a callback function is triggered, so the application is able to provide the next buffer for the JPEG module to resume the operation.

The JPEG decoding operation automatically starts after both the input buffer and the output buffer are set, and the output buffer is big enough to hold at least eight lines of decoded image data.

Return values
SSP_SUCCESSThe output buffer is properly assigned to JPEG codec device.
SSP_ERR_ASSERTIONPointer to the control block is NULL, or the pointer to the output_buffer. is NULL, or the output_buffer_size is 0.
SSP_ERR_INVALID_ALIGNMENTBuffer starting address is not 8-byte aligned.
SSP_ERR_NOT_OPENJPEG not opened.
SSP_ERR_JPEG_BUFFERSIZE_NOT_ENOUGHInvalid buffer size

Set the decoding destination address.

Record the size of the output buffer.

If the image size is not ready yet, the driver does not know the input pixel format. Without that information, the driver is unable to compute the number of lines of image to decode. In this case, the driver would record the output buffer size. Once all the information is ready, the driver would attempt to start the decoding process.

For a given buffer size, compute number of lines to decode if the image size acquisition is known.

If the driver status is IMAGE_SIZE_READY with no other flags, that means the driver just received IMAGE_SIZE. It has not started the decoding process yet.

If Input buffer is set, output buffer is set, and horizontal stride is set, the driver is able to determine the number of lines to decode, and start the decoding operation.

If the current status is OUTPUT_PAUSE, the driver needs to resume the operation.

◆ R_JPEG_Decode_PixelFormatGet()

ssp_err_t R_JPEG_Decode_PixelFormatGet ( jpeg_decode_ctrl_t p_api_ctrl,
jpeg_decode_color_space_t p_color_space 
)

Get the input pixel format.

Return values
SSP_SUCCESSThe status information is successfully retrieved.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_NOT_OPENJPEG is not opened.

HW does not report error. Return internal status information.

◆ R_JPEG_Decode_StatusGet()

ssp_err_t R_JPEG_Decode_StatusGet ( jpeg_decode_ctrl_t p_api_ctrl,
jpeg_decode_status_t p_status 
)

Get the status of the JPEG codec. This function can also be used to poll the device.

Return values
SSP_SUCCESSThe status information is successfully retrieved.
SSP_ERR_ASSERTIONPointer to the control block is NULL.
SSP_ERR_NOT_OPENJPEG is not opened.

HW does not report error. Return internal status information.

◆ R_JPEG_Decode_VersionGet()

ssp_err_t R_JPEG_Decode_VersionGet ( ssp_version_t p_version)

Get version of the display interface and GLCD HAL code.

Return values
SSP_SUCCESSVersion number
SSP_ERR_ASSERTIONThe parameter p_version is NULL.
Note
This function is reentrant.