TRAVEO™ T2G MCU: Integrating JPEG decoder with a graphics application – KBA235787
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Version: **
This KBA describes the steps to integrate the JPEG decoder driver into a graphics application project. The steps are demonstrated through the integration of the JPEG decoder driver into a sample graphics project available in the TVII-GraphicsDriver\04_sample\basic_graphics folder.
Software environment used:
- Green Hills MULTI 2017.14
- TRAVEO™ T2G graphics driver v1e.1.0
- JPEG decoder driver v1.2.0
Reference documents
- 002-24601 CYT4DN datasheet
- 002-32059 JPEG decoder user guide
- 002-25800 TRAVEO™ T2G automotive cluster 2D family architecture technical reference manual (TRM)
- 002-25923 TRAVEO™ T2G automotive cluster 2D family registers technical reference manual (TRM) (TVII-C-2D-6M)
Step 1: Install the JPEG decoder
The JPEG decoder driver comes with two installers: JPEG driver (SW-TVII-JPEG_DRV_V1.2.0.zip) and a JPEG sample application (SW-TVII-JPEG-SAMPLE_V0e.3.0.zip).
Install the JPEG decoder driver. Once installed, the following files are created in the installation folder:
Step 2: Build the JPEG decoder library
- Go to the <TVII_JPEG_Driver>\Build\GHS\jpeg_driver\prj folder and open the jpeg_driver.gpj project.
- Click the Build icon.
Figure 1 Build the JPEG decoder library
The library file is generated in the <TVII_Graphics_Driver>\04_sample\basic_graphics\<Project>\TVII_JPEG_Driver\Bin\arm-none-ghs\production\bin folder.
Step 3: Integrate the include files and JPEG decoder
1. Create a new folder (TVII_JPEG_decoder) in the 04_Sample/<GFX_Application> folder and copy the contents of the JPEG decoder driver to this folder.
Figure 2 Project file structure showing JPEG driver folders
2. Open the tviic2d6m_common.gpj file and add a new macro variable to reference the TVII_JPEG_decoder folder. The variable JPGDRV_FOLDER_REL_PATH is used in the project files to link the JPEG decoder library.
Figure 3 Adding a macro to reference TVII_JPEG_decoder folder in tviic2d6m_common.gpj
3. Open the program.gpj file and add the LIB file, libjpeg_driver_cm7.a. Adding this line tells the build system to integrate the library and link the library when creating the final binary.
Figure 4 Adding the library reference to program.gpj
You can also perform this using the MULTI IDE.
1. Right-click program.gpj and select Set build options.
Figure 5 Setting the build options in program.gpj
2. Add the path to the folder that contains the library file.
Figure 5 Adding the path to the library
3. JPEG decoder requires a few memory sections configured to allocate the memory-mapped register structures, code, and global variables that are part of the driver. This can be done be adding the required section in a separate linker file (for example: JPEGDEC_register_map.ld)
The following diagram shows the register map from the linker file. The address and size are derived from the Section 21, “JPEGDEC” of the register TRM (002-25923).
Figure 7 Section 21, “JPEGDEC” from the Register TRM
The following code snippet shows sample contents of the linker descriptor file JPEGDEC_register_map.ld. The addresses and size are derived from the TRM.
Code Listing 1 Sample linker file configuration
DEFAULTS
{
// Constants
jpegdec_ctl_addr = 0x40B10000
jpegdec_hfstruct_addr = 0x40B11000
jpegdec_decstruct_addr = 0x40B11800
jpegdec_ctl_size = 4
jpegdec_hfstruct_size = 0x100
jpegdec_decstruct_size = 0x800
}
SECTIONS {
.reg_jpeg_ctl jpegdec_ctl_addr ALIGN(4) :
.reg_jpeg_hf_struct jpegdec_hfstruct_addr ALIGN(4) :
.reg_jpeg_dec_struct jpegdec_decstruct_addr ALIGN(4) :
}
MEMORY
{
JPEGDEC_CTL : ORIGIN = jpegdec_ctl_addr, LENGTH = jpegdec_ctl_size
JPEGDEC_HFSTRUCT : ORIGIN = jpegdec_hfstruct_addr, LENGTH = jpegdec_hfstruct_size
JPEGDEC_DECSTRUCT : ORIGIN = jpegdec_decstruct_addr, LENGTH = jpegdec_decstruct_size
}
4. Apart from the register map, you need to declare a few memory sections to allocate the global and const variables in the decoder library.
.cyjpg_rodata and .cyjpg_text to the ROM area.
.cyjpg_data and .cyjpg_bss to the RAM area.
1.1 Set up the interrupt handler
Map the system interrupt 156 ‘jpegdec.interrupt_jpeg’ to one of the core interrupts.
Figure 8 Section 14, “Interrupts”, Table 14.1 from the CYT4DN datasheet (002-24601)
Code Listing 2 Code sample for IRQ configuration
/* IRQ Configuration for JPEGDEC */
001: static const cy_stc_sysint_irq_t irq_cfg_jpeg =
{
//JPEGDEC_INTERRUPT_JPEG_HANDLER
.sysIntSrc = jpegdec_interrupt_jpeg_IRQn, //156
.intIdx = CPUIntIdx3_IRQn,
.isEnabled = true
};
Code Listing 3 Code sample to initialize the interrupt
/* Initialize JPEG interrupts */
001: Cy_SysInt_InitIRQ(&irq_cfg_jpeg);
/* Set Handlers */
002: Cy_SysInt_SetSystemIrqVector(irq_cfg_jpeg.sysIntSrc, JpegDec_InterruptHandler);
003: uint32_t irq_prio = 0;
004: NVIC_SetPriority(CPUIntIdx3_IRQn, irq_prio);
005: NVIC_ClearPendingIRQ(CPUIntIdx3_IRQn);
006: NVIC_EnableIRQ(CPUIntIdx3_IRQn);
This integrates the JPEG driver to the folder structure; JPEG driver APIs can be invoked now on. See the sample JPEG application and the JPEG driver user guide for more information.
1.2 Hints
All address and lengths that are given as inputs to CyJpg_StartDecoding should be multiples of 64.
See CYJPG_JPGINFO_S in JPEG decoder manual.
The decoded image would be in semi-planar YUV422 format. This would require surfaces to be assigned with two pointers, Y buffer and the UV buffer. This is done by setting the CYGFX_SM_ATTR_VIRT_ADDRESS and CYGFX_SM_ATTR_VIRT_ADDRESS_SEC attributes for Y and UV respectively.
This KBA applies to the following series of TRAVEO™ MCUs:
- TRAVEO™ T2G cluster CYT4D series