Graphics framework for GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependents:   ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample GR-PEACH_LCD_4_3inch_Save_to_USB ... more

License

When you use this library, we judge you have agreed to the following contents.

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Note

If you import the GraphicsFramework library, please import GR-PEACH_video library and R_BSP library together.



JPEG Converter

The JPEG Converter driver implements encode and decode functionality which uses the JCU of the RZ/A Series.

Hello World!

Import programJCU_HelloWorld

Hello World for JCU(JPEG Codec Unit). JCU is JPEG codec unit of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

API

Import library

Data Structures

struct bitmap_buff_info_t
Bitmap data setting struct. More...
struct encode_options_t
Encode option setting. More...

Public Types

enum jpeg_conv_error_t {
JPEG_CONV_OK = 0, JPEG_CONV_JCU_ERR = -1, JPEG_CONV_FORMA_ERR = -2, JPEG_CONV_PARAM_ERR = -3,
JPEG_CONV_BUSY = -4, JPEG_CONV_PARAM_RANGE_ERR = -7
}

Error codes.

More...
enum wr_rd_swa_t {
WR_RD_WRSWA_NON = 0, WR_RD_WRSWA_8BIT = 1, WR_RD_WRSWA_16BIT = 2, WR_RD_WRSWA_16_8BIT = 3,
WR_RD_WRSWA_32BIT = 4, WR_RD_WRSWA_32_8BIT = 5, WR_RD_WRSWA_32_16BIT = 6, WR_RD_WRSWA_32_16_8BIT = 7
}

Write/Read image pixcel frame buffer swap setting.

More...
enum wr_rd_format_t { WR_RD_YCbCr422 = 0x00, WR_RD_ARGB8888 = 0x01, WR_RD_RGB565 = 0x02 }

Write/Read image pixcel format selects.

More...
enum sub_sampling_t { SUB_SAMPLING_1_1 = 0x00, SUB_SAMPLING_1_2 = 0x01, SUB_SAMPLING_1_4 = 0x02, SUB_SAMPLING_1_8 = 0x03 }

Thinning output image selects.

More...
enum cbcr_offset_t { CBCR_OFFSET_0 = 0x00, CBCR_OFFSET_128 = 0x01 }

Cb/Cr range selects for decode.

More...

Public Member Functions

JPEG_Converter ()
Constructor method of JPEG converter(encode/decode)
virtual ~JPEG_Converter ()
Destructor method of JPEG converter(encode/decode)
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff)
Decode JPEG to rinear data.
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff, decode_options_t *pOptions)
JPEG data decode to bitmap.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize)
Encode rinear data to JPEG.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize, encode_options_t *pOptions)
Bitmap data encode to JPEG.
JPEG_Converter::jpeg_conv_error_t SetQuality (const uint8_t qual)
Set encode quality.

Correspondence file

A correspondence file of JPEG Converter is as the following table.

JPEGCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr444, YCbCr422, YCbCr420, YCbCr411
BitmapCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr422

Notice

You run JPEG converter once destruction each time.

You set whether these JPEG files aren't input, or it check error setting decode(set in "flag" = true). The JPEG file which becomes correspondence outside will be the following condition.

  • File besides the above-mentioned correspondence file.
  • As information in the JPEG file, WIDTH or HEIGHT is larger than output buffer setting.

Buffer area is used encode/decode, set 8 bytes align and non-cash memory area. The output buffer when decoding, is made beyond the size decided in the size of the JPEG file, the format, setting of thinning out. You make output buffer for decode/encode to enough big size in order to stock this result. JPEG Converter, if you do not particularly perform specified, does not check size against the output data at the time of encoding and decoding. You set the output buffer so that there is no effect of corruption by the output data.

Color format

Color format in case to be converted from Bitmap to JPEG is either ARGB8888 or RGB555, YCbCr422. Color format of the If you want to convert from JPEG file to Bitmap file is YCbCr422. You correct "alpha(member of decode_options_t)" of setting and "output_cb_cr_offset(member of decode_options_t)" according to color format when decoding.

  • example
    decode to ARGB8888(WR_RD_ARGB8888 set in format member of bitmap_buff_info_t)
    alpha = 0x01-0xFF
    output_cb_cr_offset = CBCR_OFFSET_0

    decode to YCbCr422(WR_RD_YCbCr422 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0 or CBCR_OFFSET_128

    decode to RGB565(WR_RD_RGB565 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0

Decode/encode settings are optional

If omitted encode/decode settings, it will work with the following settings.
[Decode option setting (member of decode_options_t)]

  • Vertical sub sampling is thinning output image to 1/1.
  • Horizontal sub sampling is thinning output image to 1/1.
  • Output data of Cb/Cr range is -128 to 127.
  • Output data of swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • Alpha value of 0.
  • JPEG format correspondence outside error check.
  • It decode in a synchronous function.

[Encode option setting (member of encode_options_t)]

  • DRI value is 0.
  • Encoding JPEG file start width offset is 0.
  • Encoding JPEG file start height offset is 0.
  • Input data of Cb/Cr range of input data is -128 to 127.
  • Input data swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • It don't check encode size.
  • Quantization Y use default table(Quality75).
  • Quantization C use default table(Quality75).
  • Huffman Y DC use default table.
  • Huffman C DC use default table.
  • Huffman Y AC use default table.
  • Huffman C AC use default table.
  • It encode in a synchronous function.

Synchronous/asynchronous switching

Decoding and encoding setting to operate asynchronously by setting a callback function(decode_options_t and encode_options_t).

Quality

Quality changes are possible. If you want to change the Quality, please specify the table made of Quality you want to change the address of the setting. If you do not want to change the Quality, it will operate at Quality75.

RGA

The RGA library implements fast drawing functionality which uses the RGA of the RZ/A Series.
Supporting compiler is ARMCC, GCC ARM and IAR.

Hello World!

Import programRGA_HelloWorld

Hello World for RGA(Renesas Graphics Architecture). RGA is the Graphics Library of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Committer:
dkato
Date:
Mon Apr 24 08:16:23 2017 +0000
Revision:
13:1ee2176ef13f
Parent:
0:37e1e6a45ced
Add "SetQuality()" to JCU.
; Bug fixes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:37e1e6a45ced 1 /*******************************************************************************
dkato 0:37e1e6a45ced 2 * DISCLAIMER
dkato 0:37e1e6a45ced 3 * This software is supplied by Renesas Electronics Corporation and is only
dkato 0:37e1e6a45ced 4 * intended for use with Renesas products. No other uses are authorized. This
dkato 0:37e1e6a45ced 5 * software is owned by Renesas Electronics Corporation and is protected under
dkato 0:37e1e6a45ced 6 * all applicable laws, including copyright laws.
dkato 0:37e1e6a45ced 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
dkato 0:37e1e6a45ced 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
dkato 0:37e1e6a45ced 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
dkato 0:37e1e6a45ced 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
dkato 0:37e1e6a45ced 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
dkato 0:37e1e6a45ced 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
dkato 0:37e1e6a45ced 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
dkato 0:37e1e6a45ced 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
dkato 0:37e1e6a45ced 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
dkato 0:37e1e6a45ced 16 * Renesas reserves the right, without notice, to make changes to this software
dkato 0:37e1e6a45ced 17 * and to discontinue the availability of this software. By using this software,
dkato 0:37e1e6a45ced 18 * you agree to the additional terms and conditions found by accessing the
dkato 0:37e1e6a45ced 19 * following link:
dkato 0:37e1e6a45ced 20 * http://www.renesas.com/disclaimer
dkato 0:37e1e6a45ced 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
dkato 0:37e1e6a45ced 22 *******************************************************************************/
dkato 0:37e1e6a45ced 23 /*******************************************************************************
dkato 0:37e1e6a45ced 24 * $FileName: jcu_reg.c $
dkato 0:37e1e6a45ced 25 * $Module: JCU $ $PublicVersion: 1.00 $ (=JCU_VERSION)
dkato 0:37e1e6a45ced 26 * $Rev: 35 $
dkato 0:37e1e6a45ced 27 * $Date:: 2014-02-26 13:18:53 +0900#$
dkato 0:37e1e6a45ced 28 * Description : JCU driver setting register
dkato 0:37e1e6a45ced 29 ******************************************************************************/
dkato 0:37e1e6a45ced 30
dkato 0:37e1e6a45ced 31 /******************************************************************************
dkato 0:37e1e6a45ced 32 Includes <System Includes> , "Project Includes"
dkato 0:37e1e6a45ced 33 ******************************************************************************/
dkato 0:37e1e6a45ced 34 #include <r_typedefs.h>
dkato 0:37e1e6a45ced 35 #include <iodefine.h>
dkato 0:37e1e6a45ced 36 #include <r_jcu_api.h>
dkato 0:37e1e6a45ced 37 #include <r_jcu_local.h>
dkato 0:37e1e6a45ced 38 #include <r_jcu_user.h>
dkato 0:37e1e6a45ced 39
dkato 0:37e1e6a45ced 40 /******************************************************************************
dkato 0:37e1e6a45ced 41 Typedef definitions
dkato 0:37e1e6a45ced 42 ******************************************************************************/
dkato 0:37e1e6a45ced 43
dkato 0:37e1e6a45ced 44 /******************************************************************************
dkato 0:37e1e6a45ced 45 Macro definitions
dkato 0:37e1e6a45ced 46 ******************************************************************************/
dkato 0:37e1e6a45ced 47 #define NUMBER_OF_QUANTIZATION_TABLE_DATA (64)
dkato 0:37e1e6a45ced 48 #define NUMBER_OF_HUFFMAN_TABLE_DATA_DC (28)
dkato 0:37e1e6a45ced 49 #define NUMBER_OF_HUFFMAN_TABLE_DATA_AC (178)
dkato 0:37e1e6a45ced 50
dkato 0:37e1e6a45ced 51 #define CBCR_OFFSET_NUM (2u)
dkato 0:37e1e6a45ced 52
dkato 0:37e1e6a45ced 53 #define SWAP_NORMAL (0u)
dkato 0:37e1e6a45ced 54 #define SWAP_16BIT_OUTPUT (1u)
dkato 0:37e1e6a45ced 55 #define SWAP_32BIT_OUTPUT (2u)
dkato 0:37e1e6a45ced 56
dkato 0:37e1e6a45ced 57 #define KIND_COLOR_FORMAT (3u)
dkato 0:37e1e6a45ced 58 #define KIND_LINEOFFSET (2u)
dkato 0:37e1e6a45ced 59 #define KIND_TABLE (4u)
dkato 0:37e1e6a45ced 60
dkato 0:37e1e6a45ced 61
dkato 0:37e1e6a45ced 62 /******************************************************************************
dkato 0:37e1e6a45ced 63 Imported global variables and functions (from other files)
dkato 0:37e1e6a45ced 64 ******************************************************************************/
dkato 0:37e1e6a45ced 65
dkato 0:37e1e6a45ced 66 /******************************************************************************
dkato 0:37e1e6a45ced 67 Exported global variables and functions (to be accessed by other files)
dkato 0:37e1e6a45ced 68 ******************************************************************************/
dkato 0:37e1e6a45ced 69
dkato 0:37e1e6a45ced 70 /******************************************************************************
dkato 0:37e1e6a45ced 71 Private global variables and functions
dkato 0:37e1e6a45ced 72 ******************************************************************************/
dkato 0:37e1e6a45ced 73 STATIC_INLINE uint8_t GET_UPPER_BYTE( uint32_t const value );
dkato 0:37e1e6a45ced 74 STATIC_INLINE uint8_t GET_LOWER_BYTE( uint32_t const value );
dkato 0:37e1e6a45ced 75 static void JCU_GetRegisterForGetErrorInfo(jcu_detail_error_t *const errorCode);
dkato 0:37e1e6a45ced 76
dkato 0:37e1e6a45ced 77
dkato 0:37e1e6a45ced 78 /**************************************************************************//**
dkato 0:37e1e6a45ced 79 * Function Name: [GET_UPPER_BYTE]
dkato 0:37e1e6a45ced 80 * @brief GET_UPPER_BYTE
dkato 0:37e1e6a45ced 81 * @retval Byte
dkato 0:37e1e6a45ced 82 ******************************************************************************/
dkato 0:37e1e6a45ced 83 STATIC_INLINE uint8_t GET_UPPER_BYTE( uint32_t const value )
dkato 0:37e1e6a45ced 84 {
dkato 0:37e1e6a45ced 85 enum { num_8 = 8 }; /* SEC M1.10.1, QAC-3132 */
dkato 0:37e1e6a45ced 86 return (uint8_t)( value >> num_8 );
dkato 0:37e1e6a45ced 87 }
dkato 0:37e1e6a45ced 88
dkato 0:37e1e6a45ced 89 /**************************************************************************//**
dkato 0:37e1e6a45ced 90 * Function Name: [GET_LOWER_BYTE]
dkato 0:37e1e6a45ced 91 * @brief GET_LOWER_BYTE
dkato 0:37e1e6a45ced 92 * @retval Byte
dkato 0:37e1e6a45ced 93 ******************************************************************************/
dkato 0:37e1e6a45ced 94 STATIC_INLINE uint8_t GET_LOWER_BYTE( uint32_t const value )
dkato 0:37e1e6a45ced 95 {
dkato 0:37e1e6a45ced 96 return (uint8_t)( value );
dkato 0:37e1e6a45ced 97 }
dkato 0:37e1e6a45ced 98
dkato 0:37e1e6a45ced 99 /**************************************************************************//**
dkato 0:37e1e6a45ced 100 * Function Name: [JCU_SetRegisterForInitialize]
dkato 0:37e1e6a45ced 101 * @brief SetRegisterForInitialize
dkato 0:37e1e6a45ced 102 * @retval jcu_errorcode_t
dkato 0:37e1e6a45ced 103 ******************************************************************************/
dkato 0:37e1e6a45ced 104 jcu_errorcode_t JCU_SetRegisterForInitialize(
dkato 0:37e1e6a45ced 105 void)
dkato 0:37e1e6a45ced 106 {
dkato 0:37e1e6a45ced 107 return JCU_ERROR_OK;
dkato 0:37e1e6a45ced 108 }
dkato 0:37e1e6a45ced 109
dkato 0:37e1e6a45ced 110 /**************************************************************************//**
dkato 0:37e1e6a45ced 111 * Function Name: [JCU_SetRegisterForCodec]
dkato 0:37e1e6a45ced 112 * @brief SetRegisterForCodec
dkato 0:37e1e6a45ced 113 * @param[out] codec
dkato 0:37e1e6a45ced 114 * @retval None
dkato 0:37e1e6a45ced 115 ******************************************************************************/
dkato 0:37e1e6a45ced 116 void JCU_SetRegisterForCodec(
dkato 0:37e1e6a45ced 117 const jcu_codec_t codec)
dkato 0:37e1e6a45ced 118 {
dkato 0:37e1e6a45ced 119 volatile uint8_t DummyRead;
dkato 0:37e1e6a45ced 120
dkato 0:37e1e6a45ced 121 /* Reset this IP */
dkato 0:37e1e6a45ced 122 R_SET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST, REG_F_SET );
dkato 0:37e1e6a45ced 123 DummyRead = R_GET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST );
dkato 0:37e1e6a45ced 124 R_UNREFERENCED_VARIABLE( DummyRead );
dkato 0:37e1e6a45ced 125
dkato 0:37e1e6a45ced 126 R_SET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST, REG_F_CLR );
dkato 0:37e1e6a45ced 127 DummyRead = R_GET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST );
dkato 0:37e1e6a45ced 128 R_UNREFERENCED_VARIABLE( DummyRead );
dkato 0:37e1e6a45ced 129
dkato 0:37e1e6a45ced 130 R_SET_REG_BIT_FIELD( JCU.JCCMD, BRST, REG_F_SET);
dkato 0:37e1e6a45ced 131
dkato 0:37e1e6a45ced 132 /* Enable interrupts in registers (Interrupt lines in INTC are still disabled) */
dkato 0:37e1e6a45ced 133 /* This registers are set to 0 by reset this IP */
dkato 0:37e1e6a45ced 134 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 135
dkato 0:37e1e6a45ced 136 JCU.JINTE1 = JCU_JINTS1_ALL;
dkato 0:37e1e6a45ced 137 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 138
dkato 0:37e1e6a45ced 139 /* Clear the all of count mode settings */
dkato 0:37e1e6a45ced 140 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINLC, REG_F_CLR );
dkato 0:37e1e6a45ced 141 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRINI, REG_F_CLR );
dkato 0:37e1e6a45ced 142 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 143 JCU.JIFESLC = LINES_CLEAR;
dkato 0:37e1e6a45ced 144 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 145
dkato 0:37e1e6a45ced 146 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTC, REG_F_CLR );
dkato 0:37e1e6a45ced 147 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRINI, REG_F_CLR );
dkato 0:37e1e6a45ced 148 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 149 JCU.JIFEDDC = JDATAS_CLEAR;
dkato 0:37e1e6a45ced 150 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 151
dkato 0:37e1e6a45ced 152 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINC, REG_F_CLR );
dkato 0:37e1e6a45ced 153 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRINI, REG_F_CLR );
dkato 0:37e1e6a45ced 154 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 155 JCU.JIFDSDC = JDATAS_CLEAR;
dkato 0:37e1e6a45ced 156 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 157
dkato 0:37e1e6a45ced 158 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTLC, REG_F_CLR );
dkato 0:37e1e6a45ced 159 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRINI, REG_F_CLR );
dkato 0:37e1e6a45ced 160 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 161 JCU.JIFDDLC = LINES_CLEAR;
dkato 0:37e1e6a45ced 162 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 163
dkato 0:37e1e6a45ced 164 /* Set the which process is select */
dkato 0:37e1e6a45ced 165 R_SET_REG_BIT_FIELD( JCU.JCMOD, DSP, codec );
dkato 0:37e1e6a45ced 166 return;
dkato 0:37e1e6a45ced 167 }
dkato 0:37e1e6a45ced 168
dkato 0:37e1e6a45ced 169 /**************************************************************************//**
dkato 0:37e1e6a45ced 170 * Function Name: [JCU_ClearInterruptFlag]
dkato 0:37e1e6a45ced 171 * @brief ClearInterruptFlag
dkato 0:37e1e6a45ced 172 * @retval None
dkato 0:37e1e6a45ced 173 ******************************************************************************/
dkato 0:37e1e6a45ced 174 void JCU_ClearInterruptFlag(
dkato 0:37e1e6a45ced 175 void)
dkato 0:37e1e6a45ced 176 {
dkato 0:37e1e6a45ced 177 /* Interrupt request clear */
dkato 0:37e1e6a45ced 178 R_SET_REG_BIT_FIELD( JCU.JCCMD, JEND, REG_F_SET);
dkato 0:37e1e6a45ced 179
dkato 0:37e1e6a45ced 180 /* Clear the JEDI interrupt source flag */
dkato 0:37e1e6a45ced 181 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 182 JCU.JINTS0 = (uint8_t) 0u; /* Write 0 only */
dkato 0:37e1e6a45ced 183 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 184
dkato 0:37e1e6a45ced 185 /* Clear the JDTI interrupt source flag */
dkato 0:37e1e6a45ced 186 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 187 JCU.JINTS1 &= ~JCU_JINTS1_ALL;
dkato 0:37e1e6a45ced 188 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 189 return;
dkato 0:37e1e6a45ced 190 }
dkato 0:37e1e6a45ced 191
dkato 0:37e1e6a45ced 192 /**************************************************************************//**
dkato 0:37e1e6a45ced 193 * Function Name: [JCU_SetRegisterForStart]
dkato 0:37e1e6a45ced 194 * @brief SetRegisterForStart
dkato 0:37e1e6a45ced 195 * @retval None
dkato 0:37e1e6a45ced 196 ******************************************************************************/
dkato 0:37e1e6a45ced 197 void JCU_SetRegisterForStart(
dkato 0:37e1e6a45ced 198 const jcu_int_detail_error_t error_filter)
dkato 0:37e1e6a45ced 199 {
dkato 0:37e1e6a45ced 200 uint32_t reg_jinte0;
dkato 0:37e1e6a45ced 201 reg_jinte0 = (uint32_t)JCU.JINTE0 & (uint32_t)(~JCU_INT_ERROR_ALL);
dkato 0:37e1e6a45ced 202 JCU.JINTE0 = (uint8_t)( reg_jinte0 | (uint32_t)error_filter );
dkato 0:37e1e6a45ced 203 R_SET_REG_BIT_FIELD( JCU.JCCMD, JSRT, REG_F_SET );
dkato 0:37e1e6a45ced 204 return;
dkato 0:37e1e6a45ced 205 }
dkato 0:37e1e6a45ced 206
dkato 0:37e1e6a45ced 207 /**************************************************************************//**
dkato 0:37e1e6a45ced 208 * Function Name: [JCU_SetRegisterForSetCountMode]
dkato 0:37e1e6a45ced 209 * @brief SetRegisterForSetCountMode
dkato 0:37e1e6a45ced 210 * @param[in] buffer
dkato 0:37e1e6a45ced 211 * @retval None
dkato 0:37e1e6a45ced 212 ******************************************************************************/
dkato 0:37e1e6a45ced 213 void JCU_SetRegisterForSetCountMode(
dkato 0:37e1e6a45ced 214 const jcu_count_mode_param_t *const buffer)
dkato 0:37e1e6a45ced 215 {
dkato 0:37e1e6a45ced 216 jcu_internal_information_t *const self = R_JCU_GetInternalInformation();
dkato 0:37e1e6a45ced 217
dkato 0:37e1e6a45ced 218 IF (buffer == NULL) {
dkato 0:37e1e6a45ced 219 goto fin;
dkato 0:37e1e6a45ced 220 } /* end if */
dkato 0:37e1e6a45ced 221
dkato 0:37e1e6a45ced 222 IF_DQ ( self == NULL ) {
dkato 0:37e1e6a45ced 223 goto fin;
dkato 0:37e1e6a45ced 224 } /* end if */
dkato 0:37e1e6a45ced 225
dkato 0:37e1e6a45ced 226 switch(self->Codec) {
dkato 0:37e1e6a45ced 227 case JCU_STATUS_ENCODE:
dkato 0:37e1e6a45ced 228 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 229 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRINI, buffer->inputBuffer.isInitAddress );
dkato 0:37e1e6a45ced 230 if ((buffer->inputBuffer.isEnable != false) && (buffer->inputBuffer.isInitAddress != false)) {
dkato 0:37e1e6a45ced 231 JCU.JIFESA = (uint32_t)(buffer->inputBuffer.restartAddress);
dkato 0:37e1e6a45ced 232 } /* end if */
dkato 0:37e1e6a45ced 233 JCU.JIFESLC = ( LINES_MASK & (buffer->inputBuffer.dataCount) );
dkato 0:37e1e6a45ced 234
dkato 0:37e1e6a45ced 235 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRINI ,buffer->outputBuffer.isInitAddress );
dkato 0:37e1e6a45ced 236 if ((buffer->outputBuffer.isEnable != false) && (buffer->outputBuffer.isInitAddress != false)) {
dkato 0:37e1e6a45ced 237 JCU.JIFEDA = (uint32_t)(buffer->outputBuffer.restartAddress);
dkato 0:37e1e6a45ced 238 } /* end if */
dkato 0:37e1e6a45ced 239 JCU.JIFEDDC = ( JDATAS_MASK & ( buffer->outputBuffer.dataCount ) );
dkato 0:37e1e6a45ced 240 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 241
dkato 0:37e1e6a45ced 242 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINLC ,buffer->inputBuffer.isEnable );
dkato 0:37e1e6a45ced 243 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTC ,buffer->outputBuffer.isEnable );
dkato 0:37e1e6a45ced 244 break;
dkato 0:37e1e6a45ced 245
dkato 0:37e1e6a45ced 246 case JCU_STATUS_DECODE:
dkato 0:37e1e6a45ced 247 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 248 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRINI ,buffer->inputBuffer.isInitAddress );
dkato 0:37e1e6a45ced 249 if ((buffer->inputBuffer.isEnable != false) && (buffer->inputBuffer.isInitAddress != false)) {
dkato 0:37e1e6a45ced 250 JCU.JIFDSA = (uint32_t)(buffer->inputBuffer.restartAddress);
dkato 0:37e1e6a45ced 251 } /* end if */
dkato 0:37e1e6a45ced 252 JCU.JIFDSDC = ( JDATAS_MASK & (buffer->inputBuffer.dataCount ) );
dkato 0:37e1e6a45ced 253
dkato 0:37e1e6a45ced 254 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRINI, buffer->outputBuffer.isInitAddress );
dkato 0:37e1e6a45ced 255 if ((buffer->outputBuffer.isEnable != false) && (buffer->outputBuffer.isInitAddress != false)) {
dkato 0:37e1e6a45ced 256 JCU.JIFDDA = (uint32_t)(buffer->outputBuffer.restartAddress);
dkato 0:37e1e6a45ced 257 } /* end if */
dkato 0:37e1e6a45ced 258 JCU.JIFDDLC = ( LINES_MASK & ( buffer->outputBuffer.dataCount ) );
dkato 0:37e1e6a45ced 259 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 260
dkato 0:37e1e6a45ced 261 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINC, buffer->inputBuffer.isEnable );
dkato 0:37e1e6a45ced 262 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTLC, buffer->outputBuffer.isEnable );
dkato 0:37e1e6a45ced 263 break;
dkato 0:37e1e6a45ced 264
dkato 0:37e1e6a45ced 265 case JCU_CODEC_NOT_SELECTED:
dkato 0:37e1e6a45ced 266 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */
dkato 0:37e1e6a45ced 267 default:
dkato 0:37e1e6a45ced 268 /* <-QAC 2018 */
dkato 0:37e1e6a45ced 269 R_NOOP(); /* NOT REACHED */
dkato 0:37e1e6a45ced 270 break;
dkato 0:37e1e6a45ced 271 } /* end switch */
dkato 0:37e1e6a45ced 272 fin:
dkato 0:37e1e6a45ced 273 return;
dkato 0:37e1e6a45ced 274 }
dkato 0:37e1e6a45ced 275
dkato 0:37e1e6a45ced 276 /**************************************************************************//**
dkato 0:37e1e6a45ced 277 * Function Name: [JCU_SetRegisterForContinue]
dkato 0:37e1e6a45ced 278 * @brief SetRegisterForContinue
dkato 0:37e1e6a45ced 279 * @param[in] type
dkato 0:37e1e6a45ced 280 * @retval None
dkato 0:37e1e6a45ced 281 ******************************************************************************/
dkato 0:37e1e6a45ced 282 void JCU_SetRegisterForContinue(
dkato 0:37e1e6a45ced 283 const jcu_continue_type_t type)
dkato 0:37e1e6a45ced 284 {
dkato 0:37e1e6a45ced 285 jcu_internal_information_t *const self = R_JCU_GetInternalInformation();
dkato 0:37e1e6a45ced 286
dkato 0:37e1e6a45ced 287 IF_DQ ( self == NULL ) {
dkato 0:37e1e6a45ced 288 goto fin;
dkato 0:37e1e6a45ced 289 } /* end if */
dkato 0:37e1e6a45ced 290
dkato 0:37e1e6a45ced 291 /* Restart register setting */
dkato 0:37e1e6a45ced 292 switch (type) {
dkato 0:37e1e6a45ced 293 case JCU_INPUT_BUFFER:
dkato 0:37e1e6a45ced 294 if (self->Codec == JCU_STATUS_DECODE) {
dkato 0:37e1e6a45ced 295 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRCMD, REG_F_SET );
dkato 0:37e1e6a45ced 296 } else {
dkato 0:37e1e6a45ced 297 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRCMD, REG_F_SET );
dkato 0:37e1e6a45ced 298 } /* end if */
dkato 0:37e1e6a45ced 299 break;
dkato 0:37e1e6a45ced 300
dkato 0:37e1e6a45ced 301 case JCU_OUTPUT_BUFFER:
dkato 0:37e1e6a45ced 302 if (self->Codec == JCU_STATUS_DECODE) {
dkato 0:37e1e6a45ced 303 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRCMD, REG_F_SET );
dkato 0:37e1e6a45ced 304 } else {
dkato 0:37e1e6a45ced 305 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRCMD, REG_F_SET );
dkato 0:37e1e6a45ced 306 } /* end if */
dkato 0:37e1e6a45ced 307 break;
dkato 0:37e1e6a45ced 308
dkato 0:37e1e6a45ced 309 case JCU_IMAGE_INFO:
dkato 0:37e1e6a45ced 310 R_SET_REG_BIT_FIELD( JCU.JCCMD, JRST, REG_F_SET );
dkato 0:37e1e6a45ced 311 break;
dkato 0:37e1e6a45ced 312
dkato 0:37e1e6a45ced 313 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */
dkato 0:37e1e6a45ced 314 default:
dkato 0:37e1e6a45ced 315 /* <-QAC 2018 */
dkato 0:37e1e6a45ced 316 R_NOOP(); /* NOT REACHED */
dkato 0:37e1e6a45ced 317 break;
dkato 0:37e1e6a45ced 318 } /* end switch */
dkato 0:37e1e6a45ced 319
dkato 0:37e1e6a45ced 320 fin:
dkato 0:37e1e6a45ced 321 return;
dkato 0:37e1e6a45ced 322 }
dkato 0:37e1e6a45ced 323
dkato 0:37e1e6a45ced 324 /**************************************************************************//**
dkato 0:37e1e6a45ced 325 * Function Name: [JCU_SetRegisterForSetDecodePrm]
dkato 0:37e1e6a45ced 326 * @brief SetRegisterForSetDecod
dkato 0:37e1e6a45ced 327 * @param[in] decode
dkato 0:37e1e6a45ced 328 * @param[in] buffer
dkato 0:37e1e6a45ced 329 * @param[in] interruptKind
dkato 0:37e1e6a45ced 330 * @retval None
dkato 0:37e1e6a45ced 331 ******************************************************************************/
dkato 0:37e1e6a45ced 332 void JCU_SetRegisterForSetDecodePrm(
dkato 0:37e1e6a45ced 333 const jcu_decode_param_t *const decode,
dkato 0:37e1e6a45ced 334 const jcu_buffer_param_t *const buffer)
dkato 0:37e1e6a45ced 335 {
dkato 0:37e1e6a45ced 336 const uint32_t byteSize[KIND_COLOR_FORMAT] =
dkato 0:37e1e6a45ced 337 /* ->SEC M1.10.1 Table data. */
dkato 0:37e1e6a45ced 338 {
dkato 0:37e1e6a45ced 339 2u, /* JCU_OUTPUT_YCbCr422 */
dkato 0:37e1e6a45ced 340 4u, /* JCU_OUTPUT_ARGB8888 */
dkato 0:37e1e6a45ced 341 2u /* JCU_OUTPUT_RGB565 */
dkato 0:37e1e6a45ced 342 };
dkato 0:37e1e6a45ced 343 /* <-SEC M1.10.1 */
dkato 0:37e1e6a45ced 344
dkato 0:37e1e6a45ced 345 if ((decode == NULL) || (buffer == NULL)) {
dkato 0:37e1e6a45ced 346 goto fin;
dkato 0:37e1e6a45ced 347 } /* end if */
dkato 0:37e1e6a45ced 348
dkato 0:37e1e6a45ced 349 /* Settings for the cull */
dkato 0:37e1e6a45ced 350 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, VINTER, decode->verticalSubSampling );
dkato 0:37e1e6a45ced 351 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, HINTER, decode->horizontalSubSampling );
dkato 0:37e1e6a45ced 352 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, OPF, decode->decodeFormat );
dkato 0:37e1e6a45ced 353 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINSWAP, buffer->source.swapSetting );
dkato 0:37e1e6a45ced 354 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTSWAP, buffer->destination.swapSetting );
dkato 0:37e1e6a45ced 355
dkato 0:37e1e6a45ced 356 /* Settings for input jpeg file information */
dkato 0:37e1e6a45ced 357 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 358 JCU.JIFDSA = (uint32_t)(buffer->source.address);
dkato 0:37e1e6a45ced 359 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 360 /* Settings for output image data information */
dkato 0:37e1e6a45ced 361 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 362 JCU.JIFDDA = (uint32_t)(buffer->destination.address);
dkato 0:37e1e6a45ced 363 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 364 R_SET_REG_BIT_FIELD( JCU.JIFDDOFST, DDMW, ((uint32_t)buffer->lineOffset * (uint32_t)(byteSize[decode->decodeFormat])) );
dkato 0:37e1e6a45ced 365 R_SET_REG_BIT_FIELD( JCU.JIFDADT, ALPHA, (uint32_t)(decode->alpha) );
dkato 0:37e1e6a45ced 366
dkato 0:37e1e6a45ced 367
dkato 0:37e1e6a45ced 368 /* Setting for Cb/Cr offset */
dkato 0:37e1e6a45ced 369 R_SET_REG_BIT_FIELD( JCU.JIFESHSZ, DOUTYCHG, decode->outputCbCrOffset );
dkato 0:37e1e6a45ced 370 fin:
dkato 0:37e1e6a45ced 371 return;
dkato 0:37e1e6a45ced 372
dkato 0:37e1e6a45ced 373 }
dkato 0:37e1e6a45ced 374
dkato 0:37e1e6a45ced 375 /**************************************************************************//**
dkato 0:37e1e6a45ced 376 * Function Name: [JCU_SetRegisterForSetQtTable]
dkato 0:37e1e6a45ced 377 * @brief SetRegisterForSetQtTable
dkato 0:37e1e6a45ced 378 * @param[in] tableNo
dkato 0:37e1e6a45ced 379 * @param[in] table
dkato 0:37e1e6a45ced 380 * @retval None
dkato 0:37e1e6a45ced 381 ******************************************************************************/
dkato 0:37e1e6a45ced 382 void JCU_SetRegisterForSetQtTable(
dkato 0:37e1e6a45ced 383 const jcu_table_no_t tableNo,
dkato 0:37e1e6a45ced 384 const uint8_t *const table)
dkato 0:37e1e6a45ced 385 {
dkato 0:37e1e6a45ced 386 volatile uint8_t *tableAtRegister;
dkato 0:37e1e6a45ced 387 int_fast32_t counter;
dkato 0:37e1e6a45ced 388
dkato 0:37e1e6a45ced 389 /* Select the destination of the Quantization table */
dkato 0:37e1e6a45ced 390 switch (tableNo) {
dkato 0:37e1e6a45ced 391 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 392 case JCU_TABLE_NO_0:
dkato 0:37e1e6a45ced 393 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL0;
dkato 0:37e1e6a45ced 394 break;
dkato 0:37e1e6a45ced 395 case JCU_TABLE_NO_1:
dkato 0:37e1e6a45ced 396 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL1;
dkato 0:37e1e6a45ced 397 break;
dkato 0:37e1e6a45ced 398 case JCU_TABLE_NO_2:
dkato 0:37e1e6a45ced 399 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL2;
dkato 0:37e1e6a45ced 400 break;
dkato 0:37e1e6a45ced 401 case JCU_TABLE_NO_3:
dkato 0:37e1e6a45ced 402 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL3;
dkato 0:37e1e6a45ced 403 break;
dkato 0:37e1e6a45ced 404 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */
dkato 0:37e1e6a45ced 405 default:
dkato 0:37e1e6a45ced 406 /* <-QAC 2018 */
dkato 0:37e1e6a45ced 407 /* NOT REACHED */
dkato 0:37e1e6a45ced 408 return;
dkato 0:37e1e6a45ced 409 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 410 } /* end switch */
dkato 0:37e1e6a45ced 411
dkato 0:37e1e6a45ced 412 IF ((tableAtRegister == NULL) || (table == NULL)) {
dkato 0:37e1e6a45ced 413 goto fin;
dkato 0:37e1e6a45ced 414 } /* end if */
dkato 0:37e1e6a45ced 415
dkato 0:37e1e6a45ced 416 /* Update the quantization table data */
dkato 0:37e1e6a45ced 417 for (counter = 0; counter < NUMBER_OF_QUANTIZATION_TABLE_DATA; counter++) {
dkato 0:37e1e6a45ced 418 tableAtRegister[ counter ] = table[ counter ];
dkato 0:37e1e6a45ced 419 } /* end for */
dkato 0:37e1e6a45ced 420 fin:
dkato 0:37e1e6a45ced 421 return;
dkato 0:37e1e6a45ced 422 }
dkato 0:37e1e6a45ced 423
dkato 0:37e1e6a45ced 424 /**************************************************************************//**
dkato 0:37e1e6a45ced 425 * Function Name: [JCU_SetRegisterForSetHuffTbl]
dkato 0:37e1e6a45ced 426 * @brief SetRegisterForSetHuffTbl
dkato 0:37e1e6a45ced 427 * @param[in] tableNo
dkato 0:37e1e6a45ced 428 * @param[in] type
dkato 0:37e1e6a45ced 429 * @param[in] table
dkato 0:37e1e6a45ced 430 * @retval None
dkato 0:37e1e6a45ced 431 ******************************************************************************/
dkato 0:37e1e6a45ced 432 void JCU_SetRegisterForSetHuffTbl(
dkato 0:37e1e6a45ced 433 const jcu_table_no_t tableNo,
dkato 0:37e1e6a45ced 434 const jcu_huff_t type,
dkato 0:37e1e6a45ced 435 const uint8_t *table)
dkato 0:37e1e6a45ced 436 {
dkato 0:37e1e6a45ced 437 volatile uint8_t *tableAtRegister;
dkato 0:37e1e6a45ced 438 int_fast32_t copyCount;
dkato 0:37e1e6a45ced 439 int_fast32_t counter;
dkato 0:37e1e6a45ced 440
dkato 0:37e1e6a45ced 441 /* Select the destination Huffman table and the size of copy data */
dkato 0:37e1e6a45ced 442 if (tableNo == JCU_TABLE_NO_0) {
dkato 0:37e1e6a45ced 443 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 444 if (type == JCU_HUFFMAN_DC) {
dkato 0:37e1e6a45ced 445 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBD0;
dkato 0:37e1e6a45ced 446 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_DC;
dkato 0:37e1e6a45ced 447 } else {
dkato 0:37e1e6a45ced 448 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBA0;
dkato 0:37e1e6a45ced 449 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_AC;
dkato 0:37e1e6a45ced 450 } /* end if */
dkato 0:37e1e6a45ced 451 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 452 } else {
dkato 0:37e1e6a45ced 453 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 454 if (type == JCU_HUFFMAN_DC) {
dkato 0:37e1e6a45ced 455 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBD1;
dkato 0:37e1e6a45ced 456 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_DC;
dkato 0:37e1e6a45ced 457 } else {
dkato 0:37e1e6a45ced 458 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBA1;
dkato 0:37e1e6a45ced 459 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_AC;
dkato 0:37e1e6a45ced 460 } /* end if */
dkato 0:37e1e6a45ced 461 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 462 } /* end if */
dkato 0:37e1e6a45ced 463
dkato 0:37e1e6a45ced 464 IF(table == NULL) {
dkato 0:37e1e6a45ced 465 goto fin;
dkato 0:37e1e6a45ced 466 } /* end if */
dkato 0:37e1e6a45ced 467
dkato 0:37e1e6a45ced 468 /* Update the Huffman table */
dkato 0:37e1e6a45ced 469 for (counter = 0; counter < copyCount; counter++) {
dkato 0:37e1e6a45ced 470 tableAtRegister[ counter ] = table[ counter ];
dkato 0:37e1e6a45ced 471 } /* end for */
dkato 0:37e1e6a45ced 472 fin:
dkato 0:37e1e6a45ced 473 return;
dkato 0:37e1e6a45ced 474 }
dkato 0:37e1e6a45ced 475
dkato 0:37e1e6a45ced 476 /**************************************************************************//**
dkato 0:37e1e6a45ced 477 * Function Name: [JCU_SetRegisterForSetEncodePrm]
dkato 0:37e1e6a45ced 478 * @brief SetRegisterForSetEncode
dkato 0:37e1e6a45ced 479 * @param[in] encode
dkato 0:37e1e6a45ced 480 * @param[in] buffer
dkato 0:37e1e6a45ced 481 * @retval None
dkato 0:37e1e6a45ced 482 ******************************************************************************/
dkato 0:37e1e6a45ced 483 void JCU_SetRegisterForSetEncodePrm(
dkato 0:37e1e6a45ced 484 const jcu_encode_param_t *const encode,
dkato 0:37e1e6a45ced 485 const jcu_buffer_param_t *const buffer)
dkato 0:37e1e6a45ced 486 {
dkato 0:37e1e6a45ced 487 jcu_jpeg_format_t encodeFormatTemp;
dkato 0:37e1e6a45ced 488 const uint32_t byteSize[KIND_LINEOFFSET] =
dkato 0:37e1e6a45ced 489 /* ->SEC M1.10.1 Table data. */
dkato 0:37e1e6a45ced 490 {
dkato 0:37e1e6a45ced 491 0u, /* Reserved */
dkato 0:37e1e6a45ced 492 2u /* JCU_JPEG_YCbCr422 */
dkato 0:37e1e6a45ced 493 };
dkato 0:37e1e6a45ced 494 /* <-SEC M1.10.1 */
dkato 0:37e1e6a45ced 495
dkato 0:37e1e6a45ced 496 IF ((encode == NULL) || (buffer == NULL)) {
dkato 0:37e1e6a45ced 497 goto fin;
dkato 0:37e1e6a45ced 498 } /* end if */
dkato 0:37e1e6a45ced 499
dkato 0:37e1e6a45ced 500 /* Settings for the input image format */
dkato 0:37e1e6a45ced 501 R_SET_REG_BIT_FIELD( JCU.JCMOD, REDU, encode->encodeFormat );
dkato 0:37e1e6a45ced 502
dkato 0:37e1e6a45ced 503 /* Settings for the quantization table */
dkato 0:37e1e6a45ced 504 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT1, encode->QuantizationTable[JCU_ELEMENT_Y] );
dkato 0:37e1e6a45ced 505 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT2, encode->QuantizationTable[JCU_ELEMENT_Cb] );
dkato 0:37e1e6a45ced 506 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT3, encode->QuantizationTable[JCU_ELEMENT_Cr] );
dkato 0:37e1e6a45ced 507
dkato 0:37e1e6a45ced 508 /* Settings for the Huffman table */
dkato 0:37e1e6a45ced 509 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA1, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Y]) );
dkato 0:37e1e6a45ced 510 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD1, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Y]) );
dkato 0:37e1e6a45ced 511 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA2, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cb]) );
dkato 0:37e1e6a45ced 512 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD2, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cb]) );
dkato 0:37e1e6a45ced 513 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA3, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cr]) );
dkato 0:37e1e6a45ced 514 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD3, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cr]) );
dkato 0:37e1e6a45ced 515
dkato 0:37e1e6a45ced 516 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 517 JCU.JCDRIU = GET_UPPER_BYTE(encode->DRI_value);
dkato 0:37e1e6a45ced 518 JCU.JCDRID = GET_LOWER_BYTE(encode->DRI_value);
dkato 0:37e1e6a45ced 519 /* Settings for the image size */
dkato 0:37e1e6a45ced 520 /* width setting */
dkato 0:37e1e6a45ced 521 JCU.JCHSZU = GET_UPPER_BYTE(encode->width);
dkato 0:37e1e6a45ced 522 JCU.JCHSZD = GET_LOWER_BYTE(encode->width);
dkato 0:37e1e6a45ced 523 /* height setting */
dkato 0:37e1e6a45ced 524 JCU.JCVSZU = GET_UPPER_BYTE(encode->height);
dkato 0:37e1e6a45ced 525 JCU.JCVSZD = GET_LOWER_BYTE(encode->height);
dkato 0:37e1e6a45ced 526 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 527
dkato 0:37e1e6a45ced 528
dkato 0:37e1e6a45ced 529 /* Settings for input jpeg file information */
dkato 0:37e1e6a45ced 530 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINSWAP, buffer->source.swapSetting );
dkato 0:37e1e6a45ced 531
dkato 0:37e1e6a45ced 532 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 533 JCU.JIFESA = (uint32_t)(buffer->source.address);
dkato 0:37e1e6a45ced 534 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 535
dkato 0:37e1e6a45ced 536 /* Settings for output image data information */
dkato 0:37e1e6a45ced 537 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTSWAP, buffer->destination.swapSetting );
dkato 0:37e1e6a45ced 538
dkato 0:37e1e6a45ced 539 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 540 JCU.JIFEDA = (uint32_t)(buffer->destination.address);
dkato 0:37e1e6a45ced 541 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 542
dkato 0:37e1e6a45ced 543 encodeFormatTemp = encode->encodeFormat;
dkato 0:37e1e6a45ced 544 if((encodeFormatTemp != JCU_JPEG_YCbCr444) && (encodeFormatTemp != JCU_JPEG_YCbCr422)) {
dkato 0:37e1e6a45ced 545 encodeFormatTemp = JCU_JPEG_YCbCr444;
dkato 0:37e1e6a45ced 546 } /* end if */
dkato 0:37e1e6a45ced 547
dkato 0:37e1e6a45ced 548 R_SET_REG_BIT_FIELD( JCU.JIFESOFST, ESMW, ((uint32_t)buffer->lineOffset * (uint32_t)(byteSize[encodeFormatTemp])) );
dkato 0:37e1e6a45ced 549
dkato 0:37e1e6a45ced 550 /* Setting for Cb/Cr offset */
dkato 0:37e1e6a45ced 551 R_SET_REG_BIT_FIELD( JCU.JIFESVSZ, DINYCHG, encode->inputCbCrOffset );
dkato 0:37e1e6a45ced 552 fin:
dkato 0:37e1e6a45ced 553 return;
dkato 0:37e1e6a45ced 554
dkato 0:37e1e6a45ced 555 }
dkato 0:37e1e6a45ced 556
dkato 0:37e1e6a45ced 557 /**************************************************************************//**
dkato 0:37e1e6a45ced 558 * Function Name: [JCU_SetRegisterForSetPause]
dkato 0:37e1e6a45ced 559 * @brief
dkato 0:37e1e6a45ced 560 * @param[out] is_stop
dkato 0:37e1e6a45ced 561 * @retval None
dkato 0:37e1e6a45ced 562 ******************************************************************************/
dkato 0:37e1e6a45ced 563 void JCU_SetRegisterForSetPause( const bool_t is_pause, const jcu_int_detail_errors_t filter )
dkato 0:37e1e6a45ced 564 {
dkato 0:37e1e6a45ced 565 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 566 if ( IS( is_pause ) ) {
dkato 0:37e1e6a45ced 567 JCU.JINTE0 = filter | INT3_MASK;
dkato 0:37e1e6a45ced 568 } else {
dkato 0:37e1e6a45ced 569 JCU.JINTE0 = filter;
dkato 0:37e1e6a45ced 570 }
dkato 0:37e1e6a45ced 571 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 572 }
dkato 0:37e1e6a45ced 573
dkato 0:37e1e6a45ced 574 /**************************************************************************//**
dkato 0:37e1e6a45ced 575 * Function Name: [JCU_GetRegisterForGetImageInfo]
dkato 0:37e1e6a45ced 576 * @brief Get "jcu_image_info_t" type value
dkato 0:37e1e6a45ced 577 * @param[out] buffer :jcu_image_info_t
dkato 0:37e1e6a45ced 578 * @retval None
dkato 0:37e1e6a45ced 579 ******************************************************************************/
dkato 0:37e1e6a45ced 580 void JCU_GetRegisterForGetImageInfo(
dkato 0:37e1e6a45ced 581 jcu_image_info_t *const buffer)
dkato 0:37e1e6a45ced 582 {
dkato 0:37e1e6a45ced 583 if (buffer == NULL) {
dkato 0:37e1e6a45ced 584 goto fin;
dkato 0:37e1e6a45ced 585 } /* end if */
dkato 0:37e1e6a45ced 586
dkato 0:37e1e6a45ced 587 /* Set the register value to the variables */
dkato 0:37e1e6a45ced 588 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 589 buffer->width = ((uint32_t)JCU.JCHSZU << SHIFT_8BITS);
dkato 0:37e1e6a45ced 590 buffer->width |= (uint32_t)JCU.JCHSZD;
dkato 0:37e1e6a45ced 591 buffer->height = ((uint32_t)JCU.JCVSZU << SHIFT_8BITS);
dkato 0:37e1e6a45ced 592 buffer->height |= (uint32_t)JCU.JCVSZD;
dkato 0:37e1e6a45ced 593 buffer->encodedFormat = (jcu_jpeg_format_t)R_GET_REG_BIT_FIELD( JCU.JCMOD, REDU );
dkato 0:37e1e6a45ced 594 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 595
dkato 0:37e1e6a45ced 596 fin:
dkato 0:37e1e6a45ced 597 return;
dkato 0:37e1e6a45ced 598 }
dkato 0:37e1e6a45ced 599
dkato 0:37e1e6a45ced 600 /**************************************************************************//**
dkato 0:37e1e6a45ced 601 * Function Name: [JCU_GetRegisterForGetErrorInfo]
dkato 0:37e1e6a45ced 602 * @brief Get "jcu_detail_error_t" type value
dkato 0:37e1e6a45ced 603 * @param[out] errorCode
dkato 0:37e1e6a45ced 604 * @retval None
dkato 0:37e1e6a45ced 605 ******************************************************************************/
dkato 0:37e1e6a45ced 606 static void JCU_GetRegisterForGetErrorInfo(
dkato 0:37e1e6a45ced 607 jcu_detail_error_t *const errorCode)
dkato 0:37e1e6a45ced 608 {
dkato 0:37e1e6a45ced 609 if (errorCode != NULL) {
dkato 0:37e1e6a45ced 610 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 611 uint8_t const code = R_GET_REG_BIT_FIELD( JCU.JCDERR, ERR );
dkato 0:37e1e6a45ced 612 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 613
dkato 0:37e1e6a45ced 614 if ( (uint_fast8_t) code == 0u ) {
dkato 0:37e1e6a45ced 615 *errorCode = JCU_JCDERR_OK;
dkato 0:37e1e6a45ced 616 } else {
dkato 0:37e1e6a45ced 617 *errorCode = (jcu_detail_error_t)( (int_t) code + E_CATEGORY_JCU_JCDERR );
dkato 0:37e1e6a45ced 618 }
dkato 0:37e1e6a45ced 619 } /* end if */
dkato 0:37e1e6a45ced 620 return;
dkato 0:37e1e6a45ced 621 }
dkato 0:37e1e6a45ced 622
dkato 0:37e1e6a45ced 623 /**************************************************************************//**
dkato 0:37e1e6a45ced 624 * Function Name: [JCU_GetEncodedSize]
dkato 0:37e1e6a45ced 625 * @brief GetEncodedSize
dkato 0:37e1e6a45ced 626 * @param[out] out_Size
dkato 0:37e1e6a45ced 627 * @retval None
dkato 0:37e1e6a45ced 628 ******************************************************************************/
dkato 0:37e1e6a45ced 629 void JCU_GetEncodedSize(
dkato 0:37e1e6a45ced 630 size_t *const out_Size)
dkato 0:37e1e6a45ced 631 {
dkato 0:37e1e6a45ced 632 if (out_Size != NULL) {
dkato 0:37e1e6a45ced 633 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 634 *out_Size = (((uint32_t)JCU.JCDTCU) << SHIFT_16BITS);
dkato 0:37e1e6a45ced 635 *out_Size |= (((uint32_t)JCU.JCDTCM) << SHIFT_8BITS);
dkato 0:37e1e6a45ced 636 *out_Size |= ((uint32_t)JCU.JCDTCD);
dkato 0:37e1e6a45ced 637 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 638 } /* end if */
dkato 0:37e1e6a45ced 639 return;
dkato 0:37e1e6a45ced 640 }
dkato 0:37e1e6a45ced 641
dkato 0:37e1e6a45ced 642 /**************************************************************************//**
dkato 0:37e1e6a45ced 643 * Function Name: [R_JCU_OnInterrupting]
dkato 0:37e1e6a45ced 644 * @brief Operations on interrupting
dkato 0:37e1e6a45ced 645 * @retval Error code, 0=No error
dkato 0:37e1e6a45ced 646 ******************************************************************************/
dkato 0:37e1e6a45ced 647 errnum_t R_JCU_OnInterrupting( const r_ospl_interrupt_t *const InterruptSource )
dkato 0:37e1e6a45ced 648 {
dkato 0:37e1e6a45ced 649 errnum_t e;
dkato 0:37e1e6a45ced 650 uint32_t flags0;
dkato 0:37e1e6a45ced 651 uint32_t flags1;
dkato 0:37e1e6a45ced 652 jcu_internal_information_t *const self = R_JCU_GetInternalInformation();
dkato 0:37e1e6a45ced 653
dkato 0:37e1e6a45ced 654 R_UNREFERENCED_VARIABLE( InterruptSource );
dkato 0:37e1e6a45ced 655 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 656 e=E_OTHERS;
dkato 0:37e1e6a45ced 657 goto fin;
dkato 0:37e1e6a45ced 658 }
dkato 0:37e1e6a45ced 659
dkato 0:37e1e6a45ced 660 ASSERT_R( self->AsyncStatus.Status == JCU_STATUS_INTERRUPTING, e=E_STATE; goto fin );
dkato 0:37e1e6a45ced 661
dkato 0:37e1e6a45ced 662 /* Get interrupt status */
dkato 0:37e1e6a45ced 663 /* ->QAC 0306 */
dkato 0:37e1e6a45ced 664 flags0 = JCU.JINTS0;
dkato 0:37e1e6a45ced 665 flags1 = JCU.JINTS1;
dkato 0:37e1e6a45ced 666 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptFlags, flags0 );
dkato 0:37e1e6a45ced 667 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptFlags, flags1 << JCU_SHIFT_JINTS1 );
dkato 0:37e1e6a45ced 668
dkato 0:37e1e6a45ced 669 /* Clear interrupt status "JINTS0" */
dkato 0:37e1e6a45ced 670 if ( flags0 != 0u ) {
dkato 0:37e1e6a45ced 671 R_SET_REG_BIT_FIELD( JCU.JCCMD, JEND, 1u );
dkato 0:37e1e6a45ced 672 JCU.JINTS0 = (uint8_t) 0u; /* Write 0 only */
dkato 0:37e1e6a45ced 673 }
dkato 0:37e1e6a45ced 674
dkato 0:37e1e6a45ced 675 /* Clear interrupt status "JINTS1" */
dkato 0:37e1e6a45ced 676 JCU.JINTS1 = ~flags1 & JCU_JINTS1_ALL;
dkato 0:37e1e6a45ced 677 /* <-QAC 0306 */
dkato 0:37e1e6a45ced 678
dkato 0:37e1e6a45ced 679 /* Set state */
dkato 0:37e1e6a45ced 680 self->AsyncStatus.Status = JCU_STATUS_INTERRUPTED;
dkato 0:37e1e6a45ced 681
dkato 0:37e1e6a45ced 682 e=0;
dkato 0:37e1e6a45ced 683 fin:
dkato 0:37e1e6a45ced 684 return e;
dkato 0:37e1e6a45ced 685 }
dkato 0:37e1e6a45ced 686
dkato 0:37e1e6a45ced 687 /**************************************************************************//**
dkato 0:37e1e6a45ced 688 * Function Name: [R_JCU_OnInterrupted]
dkato 0:37e1e6a45ced 689 * @brief Bottom half operations on interrupting
dkato 0:37e1e6a45ced 690 * @retval Error code, 0=No error
dkato 0:37e1e6a45ced 691 ******************************************************************************/
dkato 0:37e1e6a45ced 692 errnum_t R_JCU_OnInterrupted(void)
dkato 0:37e1e6a45ced 693 {
dkato 0:37e1e6a45ced 694 bit_flags32_t const sub_status_bits =
dkato 0:37e1e6a45ced 695 ( INS3_MASK ) |
dkato 0:37e1e6a45ced 696 ( JINF_MASK << JCU_SHIFT_JINTS1 ) |
dkato 0:37e1e6a45ced 697 ( DOUTLF_MASK << JCU_SHIFT_JINTS1 ) |
dkato 0:37e1e6a45ced 698 ( DINLF_MASK << JCU_SHIFT_JINTS1 ) |
dkato 0:37e1e6a45ced 699 ( JOUTF_MASK << JCU_SHIFT_JINTS1 );
dkato 0:37e1e6a45ced 700
dkato 0:37e1e6a45ced 701 errnum_t e;
dkato 0:37e1e6a45ced 702 uint32_t cancel_flag;
dkato 0:37e1e6a45ced 703 uint32_t interrupt_flags;
dkato 0:37e1e6a45ced 704 bool_t was_enabled = false;
dkato 0:37e1e6a45ced 705 bool_t is_end;
dkato 0:37e1e6a45ced 706 bool_t or;
dkato 0:37e1e6a45ced 707 jcu_errorcode_t ej;
dkato 0:37e1e6a45ced 708 r_ospl_async_t *notify_async_1 = NULL;
dkato 0:37e1e6a45ced 709 r_ospl_async_t *notify_async_2 = NULL;
dkato 0:37e1e6a45ced 710 jcu_i_lock_t *const i_lock = R_JCU_GetILockObject();
dkato 0:37e1e6a45ced 711 jcu_internal_information_t *const self = R_JCU_GetInternalInformation();
dkato 0:37e1e6a45ced 712
dkato 0:37e1e6a45ced 713 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 714 e=E_OTHERS;
dkato 0:37e1e6a45ced 715 goto fin;
dkato 0:37e1e6a45ced 716 }
dkato 0:37e1e6a45ced 717
dkato 0:37e1e6a45ced 718 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 719
dkato 0:37e1e6a45ced 720 ASSERT_R( self->AsyncStatus.Status != JCU_STATUS_UNDEF, e=E_STATE; goto fin );
dkato 0:37e1e6a45ced 721
dkato 0:37e1e6a45ced 722 interrupt_flags = R_OSPL_FLAG32_GetAndClear( &self->AsyncStatus.InterruptFlags );
dkato 0:37e1e6a45ced 723
dkato 0:37e1e6a45ced 724
dkato 0:37e1e6a45ced 725 if ( IS_ANY_BITS_SET( interrupt_flags, sub_status_bits ) ) {
dkato 0:37e1e6a45ced 726 if ( IS_BIT_NOT_SET( interrupt_flags, INS6_MASK ) ) {
dkato 0:37e1e6a45ced 727 self->AsyncStatus.IsPaused = true;
dkato 0:37e1e6a45ced 728 self->AsyncStatus.SubStatusFlags = interrupt_flags & sub_status_bits;
dkato 0:37e1e6a45ced 729 }
dkato 0:37e1e6a45ced 730 }
dkato 0:37e1e6a45ced 731
dkato 0:37e1e6a45ced 732
dkato 0:37e1e6a45ced 733 if ( IS_ANY_BITS_SET( interrupt_flags, INS6_MASK ) ) {
dkato 0:37e1e6a45ced 734 is_end = true;
dkato 0:37e1e6a45ced 735 } else {
dkato 0:37e1e6a45ced 736 is_end = false;
dkato 0:37e1e6a45ced 737 }
dkato 0:37e1e6a45ced 738
dkato 0:37e1e6a45ced 739
dkato 0:37e1e6a45ced 740 or = ( (is_end) || (self->AsyncStatus.IsPaused) );
dkato 0:37e1e6a45ced 741 if (!or) {
dkato 0:37e1e6a45ced 742 or = IS_BIT_SET( interrupt_flags, INS5_MASK );
dkato 0:37e1e6a45ced 743 }
dkato 0:37e1e6a45ced 744 if (IS( or )) {
dkato 0:37e1e6a45ced 745 /* Set "AsyncStatus" */
dkato 0:37e1e6a45ced 746 R_OSPL_FLAG32_Clear( &self->AsyncStatus.InterruptEnables, JCU_INTERRUPT_LINE_ALL );
dkato 0:37e1e6a45ced 747 self->AsyncStatus.Status = JCU_STATUS_READY;
dkato 0:37e1e6a45ced 748 notify_async_1 = self->InterruptCallbackCaller.Async;
dkato 0:37e1e6a45ced 749 } else {
dkato 0:37e1e6a45ced 750 self->AsyncStatus.Status = JCU_STATUS_RUN;
dkato 0:37e1e6a45ced 751 }
dkato 0:37e1e6a45ced 752
dkato 0:37e1e6a45ced 753
dkato 0:37e1e6a45ced 754 IF ( IS_BIT_SET( interrupt_flags, INS5_MASK ) ) {
dkato 0:37e1e6a45ced 755 jcu_detail_error_t ed;
dkato 0:37e1e6a45ced 756
dkato 0:37e1e6a45ced 757 JCU_GetRegisterForGetErrorInfo( &ed );
dkato 0:37e1e6a45ced 758 e = ed;
dkato 0:37e1e6a45ced 759 goto fin;
dkato 0:37e1e6a45ced 760 }
dkato 0:37e1e6a45ced 761
dkato 0:37e1e6a45ced 762
dkato 0:37e1e6a45ced 763 if ( notify_async_1 != NULL ) {
dkato 0:37e1e6a45ced 764 cancel_flag = R_OSPL_FLAG32_Get( &self->AsyncStatus.CancelFlags );
dkato 0:37e1e6a45ced 765 if ( IS_BIT_SET( cancel_flag, R_OSPL_FINALIZE_REQUEST ) ) {
dkato 0:37e1e6a45ced 766 notify_async_2 = self->AsyncForFinalize;
dkato 0:37e1e6a45ced 767 ej= R_JCU_TerminateStep2();
dkato 0:37e1e6a45ced 768 IF ( ej != JCU_ERROR_OK ) {
dkato 0:37e1e6a45ced 769 e=E_OTHERS;
dkato 0:37e1e6a45ced 770 goto fin;
dkato 0:37e1e6a45ced 771 }
dkato 0:37e1e6a45ced 772 }
dkato 0:37e1e6a45ced 773 }
dkato 0:37e1e6a45ced 774
dkato 0:37e1e6a45ced 775 e=0;
dkato 0:37e1e6a45ced 776 fin:
dkato 0:37e1e6a45ced 777 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 778 /* ->QAC 3353 : "self" is always assigned, if "was_enabled" is true */
dkato 0:37e1e6a45ced 779 IF_DQ( self == NULL ) {} /* QAC 3353 raises SEC R3.2.2 */
dkato 0:37e1e6a45ced 780 else {
dkato 0:37e1e6a45ced 781 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 782
dkato 0:37e1e6a45ced 783 if ( IS( self->Is_I_LockMaster ) ) {
dkato 0:37e1e6a45ced 784 IF_DQ( i_lock == NULL ) {}
dkato 0:37e1e6a45ced 785 else {
dkato 0:37e1e6a45ced 786 if ( IS( i_lock->IsRequestedFinalize ) ) {
dkato 0:37e1e6a45ced 787 R_JCU_I_LOCK_Finalize();
dkato 0:37e1e6a45ced 788 }
dkato 0:37e1e6a45ced 789 }
dkato 0:37e1e6a45ced 790 }
dkato 0:37e1e6a45ced 791 }
dkato 0:37e1e6a45ced 792 /* <-QAC 3353 */
dkato 0:37e1e6a45ced 793 }
dkato 0:37e1e6a45ced 794
dkato 0:37e1e6a45ced 795 if ( notify_async_1 != NULL ) {
dkato 0:37e1e6a45ced 796 R_OSPL_EVENT_Set( notify_async_1->A_Thread, notify_async_1->A_EventValue );
dkato 0:37e1e6a45ced 797 }
dkato 0:37e1e6a45ced 798 if ( notify_async_2 != NULL ) {
dkato 0:37e1e6a45ced 799 R_OSPL_EVENT_Set( notify_async_2->A_Thread, notify_async_2->A_EventValue );
dkato 0:37e1e6a45ced 800 }
dkato 0:37e1e6a45ced 801
dkato 0:37e1e6a45ced 802 return e;
dkato 0:37e1e6a45ced 803 }
dkato 0:37e1e6a45ced 804