Skip to content

Commit

Permalink
Merge branch 'hzy-remove-fb-rotation' into 'dev'
Browse files Browse the repository at this point in the history
remove framebuffer rotation

See merge request maix_sw/k230_canmv!234
  • Loading branch information
zzxcanaan committed May 21, 2024
2 parents ef18a67 + bc9b381 commit 9859a25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion micropython_port/media/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def buffer_init(cls):
cls.config_index += 1
# for VO writeback
cls.buf_config.comm_pool[cls.config_index].blk_size = 3117056
cls.buf_config.comm_pool[cls.config_index].blk_cnt = 5
cls.buf_config.comm_pool[cls.config_index].blk_cnt = 4
cls.buf_config.comm_pool[cls.config_index].mode = VB_REMAP_MODE_NOCACHE
cls.config_index += 1

Expand Down
16 changes: 13 additions & 3 deletions micropython_port/omv/ide_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ static uint32_t wbc_jpeg_size = 0;
static k_connector_type connector_type = 0;
static k_video_frame_info frame_info;
static int vo_func = K_VO_MIRROR_NONE;
#if ENABLE_BUFFER_ROTATION
static k_video_frame_info rotation_buffer;
#endif
static bool flag_vo_wbc_enabled = false;
#endif

Expand All @@ -285,6 +287,7 @@ int ide_dbg_vo_wbc_init(void) {
.height = vo_info.resolution.vdisplay
}
};
#if ENABLE_BUFFER_ROTATION
if (vo_func != K_VO_MIRROR_NONE) {
// allocate rotation buffer
k_vb_blk_handle handle = kd_mpi_vb_get_block(VB_INVALID_POOLID, 3117056, NULL);
Expand All @@ -308,6 +311,7 @@ int ide_dbg_vo_wbc_init(void) {
pr_info("set rotation buffer %08lx", rotation_buffer.v_frame.phys_addr[0]);
}
skip_rotation:
#endif
if (kd_mpi_vo_set_wbc_attr(&attr)) {
pr_err("[omv] kd_mpi_vo_set_wbc_attr error");
return -1;
Expand Down Expand Up @@ -338,6 +342,7 @@ int ide_dbg_vo_deinit(void) {
close(fd);
usleep(50000);
kd_mpi_vo_disable_wbc();
#if ENABLE_BUFFER_ROTATION
vo_func = K_VO_MIRROR_NONE;
if (rotation_buffer.v_frame.virt_addr[0]) {
unsigned ysize = rotation_buffer.v_frame.width * rotation_buffer.v_frame.height;
Expand All @@ -350,6 +355,7 @@ int ide_dbg_vo_deinit(void) {
rotation_buffer.v_frame.phys_addr[0] = 0;
}
#endif
#endif
return 0;
}

Expand All @@ -365,7 +371,7 @@ int ide_dbg_set_vo_func(int func) {
}
return 0;
}

#if ENABLE_BUFFER_ROTATION
static void rotation90_u8(uint8_t* __restrict dst, uint8_t* __restrict src, unsigned w, unsigned h) {
unsigned nw = h;
unsigned nh = w;
Expand Down Expand Up @@ -405,7 +411,7 @@ static void rotation270_u16(uint16_t* __restrict dst, uint16_t* __restrict src,
}
}
}

#endif
int hd_jpeg_encode(k_video_frame_info* frame, void** buffer, size_t size, int timeout, void*(*realloc)(void*, unsigned long));

static ide_dbg_status_t ide_dbg_update(ide_dbg_state_t* state, const uint8_t* data, size_t length) {
Expand Down Expand Up @@ -671,9 +677,10 @@ static ide_dbg_status_t ide_dbg_update(ide_dbg_state_t* state, const uint8_t* da
goto skip;
}
frame_info.v_frame.pixel_format = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
int ssize = 0;
#if ENABLE_BUFFER_ROTATION
unsigned ysize = frame_info.v_frame.width * frame_info.v_frame.height;
unsigned uvsize = ysize / 2;
int ssize = 0;
if (vo_func == K_ROTATION_90) {
// y
uint8_t* y = kd_mpi_sys_mmap_cached(frame_info.v_frame.phys_addr[0], ysize);
Expand Down Expand Up @@ -709,6 +716,9 @@ static ide_dbg_status_t ide_dbg_update(ide_dbg_state_t* state, const uint8_t* da
} else {
ssize = hd_jpeg_encode(&frame_info, &wbc_jpeg_buffer, wbc_jpeg_buffer_size, 1000, realloc);
}
#else
ssize = hd_jpeg_encode(&frame_info, &wbc_jpeg_buffer, wbc_jpeg_buffer_size, 1000, realloc);
#endif
kd_mpi_wbc_dump_release(&frame_info);
if (ssize <= 0) {
pr_verb("[omv] hardware JPEG error %d", ssize);
Expand Down

0 comments on commit 9859a25

Please sign in to comment.