mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
ports/all: Use private CSI resolution table.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
parent
1a1cf29673
commit
cb50ad479a
@ -216,11 +216,11 @@ static int alif_clk_set_frequency(omv_clk_t *clk, uint32_t frequency) {
|
||||
static uint32_t omv_csi_get_fb_offset(omv_csi_t *csi) {
|
||||
uint32_t offset = 0;
|
||||
uint32_t bytes_per_pixel = omv_csi_get_src_bpp(csi);
|
||||
uint32_t line_size_bytes = resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
uint32_t line_size_bytes = csi->resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
|
||||
// Offset the pixels buffer for debayering.
|
||||
if (csi->raw_output && csi->pixformat == PIXFORMAT_RGB565) {
|
||||
offset += line_size_bytes * resolution[csi->framesize][1];
|
||||
offset += line_size_bytes * csi->resolution[csi->framesize][1];
|
||||
}
|
||||
|
||||
return offset;
|
||||
@ -239,7 +239,7 @@ int alif_csi_snapshot(omv_csi_t *csi, image_t *dst_image, uint32_t flags) {
|
||||
// and there are no pending buffers (from non-blocking capture).
|
||||
if (!alif_csi_is_active(csi) && !framebuffer_readable(fb)) {
|
||||
uint32_t bytes_per_pixel = omv_csi_get_src_bpp(csi);
|
||||
uint32_t line_size_bytes = resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
uint32_t line_size_bytes = csi->resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
|
||||
// Acquire a buffer from the free queue.
|
||||
buffer = framebuffer_acquire(fb, FB_FLAG_FREE | FB_FLAG_PEEK);
|
||||
@ -278,7 +278,7 @@ int alif_csi_snapshot(omv_csi_t *csi, image_t *dst_image, uint32_t flags) {
|
||||
cpi->CAM_VIDEO_FCFG &= ~CAM_VIDEO_FCFG_DATA_Msk;
|
||||
cpi->CAM_VIDEO_FCFG = line_size_bytes;
|
||||
cpi->CAM_VIDEO_FCFG &= ~CAM_VIDEO_FCFG_ROW_Msk;
|
||||
cpi->CAM_VIDEO_FCFG |= ((resolution[csi->framesize][1] - 1) << CAM_VIDEO_FCFG_ROW_Pos);
|
||||
cpi->CAM_VIDEO_FCFG |= ((csi->resolution[csi->framesize][1] - 1) << CAM_VIDEO_FCFG_ROW_Pos);
|
||||
cpi->CAM_FRAME_ADDR = LocalToGlobal(buffer->data + omv_csi_get_fb_offset(csi));
|
||||
|
||||
// Configure and enable CSI interrupts.
|
||||
@ -362,8 +362,8 @@ int alif_csi_snapshot(omv_csi_t *csi, image_t *dst_image, uint32_t flags) {
|
||||
image_t src_cimage = *dst_image;
|
||||
image_t dst_cimage = *dst_image;
|
||||
|
||||
src_cimage.w = resolution[csi->framesize][0];
|
||||
src_cimage.h = resolution[csi->framesize][1];
|
||||
src_cimage.w = csi->resolution[csi->framesize][0];
|
||||
src_cimage.h = csi->resolution[csi->framesize][1];
|
||||
|
||||
// Offset the pixels buffer for the debayer code.
|
||||
if (csi->pixformat == PIXFORMAT_RGB565) {
|
||||
|
@ -134,7 +134,7 @@ void omv_csi_sof_callback(omv_csi_t *csi) {
|
||||
|
||||
if (buffer == NULL) {
|
||||
omv_csi_abort(csi, false, true);
|
||||
} else if (buffer->offset < resolution[csi->framesize][1]) {
|
||||
} else if (buffer->offset < csi->resolution[csi->framesize][1]) {
|
||||
// Missed a few lines, reset buffer state and continue.
|
||||
framebuffer_reset(buffer);
|
||||
}
|
||||
@ -240,7 +240,7 @@ void omv_csi_line_callback(omv_csi_t *csi, uint32_t addr) {
|
||||
}
|
||||
|
||||
if (csi->drop_frame) {
|
||||
if (++buffer->offset == resolution[csi->framesize][1]) {
|
||||
if (++buffer->offset == csi->resolution[csi->framesize][1]) {
|
||||
buffer->offset = 0;
|
||||
CSI_REG_CR3(CSI) &= ~CSI_CR3_DMA_REQ_EN_RFF_MASK;
|
||||
}
|
||||
@ -274,7 +274,7 @@ void omv_csi_line_callback(omv_csi_t *csi, uint32_t addr) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (++buffer->offset == resolution[csi->framesize][1]) {
|
||||
if (++buffer->offset == csi->resolution[csi->framesize][1]) {
|
||||
// Release the current framebuffer.
|
||||
framebuffer_release(fb, FB_FLAG_FREE | FB_FLAG_CHECK_LAST);
|
||||
CSI_REG_CR3(CSI) &= ~CSI_CR3_DMA_REQ_EN_RFF_MASK;
|
||||
@ -333,7 +333,7 @@ int imx_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
// and there are no pending buffers (from non-blocking capture).
|
||||
if (!(CSI->CR18 & CSI_CR18_CSI_ENABLE_MASK) && !framebuffer_readable(fb)) {
|
||||
uint32_t bytes_per_pixel = omv_csi_get_src_bpp(csi);
|
||||
uint32_t dma_line_bytes = resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
uint32_t dma_line_bytes = csi->resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
uint32_t length = dma_line_bytes * fb->v;
|
||||
|
||||
// Error out if the transfer size is not compatible with DMA transfer restrictions.
|
||||
|
@ -359,7 +359,7 @@ int omv_csi_set_vsync_callback(omv_csi_t *csi, omv_csi_cb_t cb) {
|
||||
static uint32_t get_dcmi_hw_crop(omv_csi_t *csi, uint32_t bytes_per_pixel) {
|
||||
framebuffer_t *fb = csi->fb;
|
||||
uint32_t byte_x_offset = (fb->x * bytes_per_pixel) % 4;
|
||||
uint32_t width_remainder = (resolution[csi->framesize][0] - (fb->x + fb->u)) * bytes_per_pixel;
|
||||
uint32_t width_remainder = (csi->resolution[csi->framesize][0] - (fb->x + fb->u)) * bytes_per_pixel;
|
||||
|
||||
if (byte_x_offset && (width_remainder >= (4 - byte_x_offset))) {
|
||||
return byte_x_offset;
|
||||
@ -558,7 +558,7 @@ static int stm_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
// Setup the size and address of the transfer
|
||||
uint32_t bytes_per_pixel = omv_csi_get_src_bpp(csi);
|
||||
uint32_t x_crop = get_dcmi_hw_crop(csi, bytes_per_pixel);
|
||||
uint32_t line_width = resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
uint32_t line_width = csi->resolution[csi->framesize][0] * bytes_per_pixel;
|
||||
|
||||
// Shrink the captured pixel count by one word to allow cropping to fix alignment.
|
||||
if (x_crop) {
|
||||
|
Loading…
Reference in New Issue
Block a user