ports: Move copy_transposed_line to sensor.h.

This commit is contained in:
Kwabena W. Agyeman 2024-02-01 17:40:23 -08:00
parent bd6bfa3e72
commit 018f2eaed1
3 changed files with 22 additions and 37 deletions

View File

@ -14,6 +14,18 @@
#include "omv_i2c.h"
#include "imlib.h"
#define copy_transposed_line(dstp, srcp) \
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) { \
*dstp = *srcp++; \
dstp += h; \
}
#define copy_transposed_line_rev16(dstp, srcp) \
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) { \
*dstp = __REV16(*srcp++); \
dstp += h; \
}
#define OV2640_SLV_ADDR (0x60)
#define OV5640_SLV_ADDR (0x78)
#define OV7725_SLV_ADDR (0x42)

View File

@ -36,18 +36,6 @@ static bool drop_frame = false;
| CSI_CR1_FB1_DMA_DONE_INTEN_MASK)
//CSI_CR1_RF_OR_INTEN_MASK
#define copy_line(dstp, srcp) \
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) { \
*dstp = *srcp++; \
dstp += h; \
}
#define copy_line_rev(dstp, srcp) \
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) { \
*dstp = __REV16(*srcp++); \
dstp += h; \
}
void sensor_init0() {
sensor_abort(true, false);
@ -315,7 +303,7 @@ void sensor_line_callback(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy(dst, src, MAIN_FB()->u);
} else {
copy_line(dst, src);
copy_transposed_line(dst, src);
}
#endif
break;
@ -328,14 +316,14 @@ void sensor_line_callback(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy(dst, src, MAIN_FB()->u);
} else {
copy_line(dst, src);
copy_transposed_line(dst, src);
}
} else {
// Extract Y channel from YUV.
if (!sensor.transpose) {
unaligned_2_to_1_memcpy(dst, src16, MAIN_FB()->u);
} else {
copy_line(dst, src16);
copy_transposed_line(dst, src16);
}
}
#endif
@ -350,13 +338,13 @@ void sensor_line_callback(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy_rev16(dst16, src16, MAIN_FB()->u);
} else {
copy_line_rev(dst16, src16);
copy_transposed_line_rev16(dst16, src16);
}
} else {
if (!sensor.transpose) {
unaligned_memcpy(dst16, src16, MAIN_FB()->u * sizeof(uint16_t));
} else {
copy_line(dst16, src16);
copy_transposed_line(dst16, src16);
}
}
#endif

View File

@ -596,10 +596,7 @@ void DCMI_DMAConvCpltUser(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy(dst, src, MAIN_FB()->u);
} else {
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) {
*dst = *src++;
dst += h;
}
copy_transposed_line(dst, src);
}
#endif
break;
@ -612,20 +609,14 @@ void DCMI_DMAConvCpltUser(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy(dst, src, MAIN_FB()->u);
} else {
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) {
*dst = *src++;
dst += h;
}
copy_transposed_line(dst, src);
}
} else {
// Extract Y channel from YUV.
if (!sensor.transpose) {
unaligned_2_to_1_memcpy(dst, src16, MAIN_FB()->u);
} else {
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) {
*dst = *src16++;
dst += h;
}
copy_transposed_line(dst, src16);
}
}
#endif
@ -640,19 +631,13 @@ void DCMI_DMAConvCpltUser(uint32_t addr) {
if (!sensor.transpose) {
unaligned_memcpy_rev16(dst16, src16, MAIN_FB()->u);
} else {
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) {
*dst16 = __REV16(*src16++);
dst16 += h;
}
copy_transposed_line_rev16(dst16, src16);
}
} else {
if (!sensor.transpose) {
unaligned_memcpy(dst16, src16, MAIN_FB()->u * sizeof(uint16_t));
} else {
for (int i = MAIN_FB()->u, h = MAIN_FB()->v; i; i--) {
*dst16 = *src16++;
dst16 += h;
}
copy_transposed_line(dst16, src16);
}
}
#endif