MY TRAIAL (1)
Dependencies: FATFileSystem GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP mbed-rtos mbed
Fork of GR-PEACH_NTSC_in_2ch_MOD_try by
I put an OVERVIEW in the blow URL. https://developer.mbed.org/users/digiponta/notebook/my-trial-ar--vr-2-eyes-display-goes-by-a-gr-peach/
Diff: main.cpp
- Revision:
- 2:e59e938472ac
- Parent:
- 0:f8cb87301ad8
- Child:
- 3:1daadbe91b49
--- a/main.cpp Mon Aug 08 12:59:36 2016 +0000 +++ b/main.cpp Thu Aug 25 04:57:15 2016 +0000 @@ -44,10 +44,6 @@ #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32BIT) #endif -/* The size of the video input is adjusted to the LCD size. */ -#define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH -#define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT - /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128 in accordance with the frame buffer burst transfer mode. */ /* FRAME BUFFER Parameter GRAPHICS_LAYER_0 */ @@ -142,8 +138,12 @@ } } -static void Start_Video(DisplayBase::video_input_channel_t ch, uint8_t * p_buf) { +static void Start_Video(DisplayBase::video_input_channel_t ch, uint8_t * p_frame_buffer, + uint16_t pos_x, uint16_t pos_y, uint16_t width, uint16_t height) { DisplayBase::graphics_error_t error; + uint8_t * p_buf; + + p_buf = p_frame_buffer + (FRAME_BUFFER_BYTE_PER_PIXEL * pos_x) + (FRAME_BUFFER_STRIDE * pos_y); /* Video capture setting (progressive form fixed) */ error = Display.Video_Write_Setting( @@ -153,8 +153,8 @@ FRAME_BUFFER_STRIDE, VIDEO_FORMAT, WR_RD_WRSWA, - VIDEO_PIXEL_VW, - VIDEO_PIXEL_HW / 2 + (height & ~7u), /* A multiple of 8 */ + (width & ~15u) /* A multiple of 16 */ ); if (error != DisplayBase::GRAPHICS_OK) { printf("Line %d, error %d\n", __LINE__, error); @@ -183,6 +183,18 @@ } } +/****** Cache control ******/ +static void dcache_clean(void * p_buf, uint32_t size){ + uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0; + uint32_t end_addr = (uint32_t)p_buf + size; + uint32_t addr; + + /* Data cache clean */ + for (addr = start_addr; addr < end_addr; addr += 0x20) { + __v7_clean_dcache_mva((void *)addr); + } +} + /****** main ******/ int main(void) { /* Initialization of LCD */ @@ -192,11 +204,35 @@ Init_Video(); /* Initialization memory */ - memset(user_frame_buffer0, 0, (FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT)); +#if VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 + for (int i = 0; i < sizeof(user_frame_buffer0); i += 2) { + user_frame_buffer0[i + 0] = 0x10; + user_frame_buffer0[i + 1] = 0x80; + } +#else + memset(user_frame_buffer0, 0, sizeof(user_frame_buffer0)); +#endif + dcache_clean(user_frame_buffer0, sizeof(user_frame_buffer0)); - /* Start of Video */ - Start_Video(DisplayBase::VIDEO_INPUT_CHANNEL_0, &user_frame_buffer0[0]); - Start_Video(DisplayBase::VIDEO_INPUT_CHANNEL_1, &user_frame_buffer0[FRAME_BUFFER_STRIDE / 2]); + /* Start of Video ch0 */ + Start_Video( + DisplayBase::VIDEO_INPUT_CHANNEL_0, /* Video input channe */ + user_frame_buffer0, /* Output buffer */ + 0, /* The x coordinate of the upper-left corner */ + 0, /* The y coordinate of the upper-left corner */ + (LCD_PIXEL_WIDTH / 2), /* width (A multiple of 16) */ + LCD_PIXEL_HEIGHT /* height (A multiple of 8) */ + ); + + /* Start of Video ch1 */ + Start_Video( + DisplayBase::VIDEO_INPUT_CHANNEL_1, /* Video input channe */ + user_frame_buffer0, /* Output buffer */ + (LCD_PIXEL_WIDTH / 2), /* The x coordinate of the upper-left corner */ + 0, /* The y coordinate of the upper-left corner */ + (LCD_PIXEL_WIDTH / 2), /* width (A multiple of 16) */ + LCD_PIXEL_HEIGHT /* height (A multiple of 8) */ + ); /* Start of LCD */ Start_LCD_Display(&user_frame_buffer0[0]);