misc: Format code.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-09-28 19:45:07 +02:00
parent 8233e03553
commit f8e110ca91
31 changed files with 243 additions and 208 deletions

View File

@ -78,6 +78,7 @@ typedef struct _i2c_dev {
static omv_i2c_t csi_i2c;
static omv_clk_t csi_clk;
// *INDENT-OFF*
// Standard resolution table;
static uint16_t csi_resolution[][2] = {
[OMV_CSI_FRAMESIZE_INVALID] = {0, 0},
@ -125,6 +126,7 @@ static uint16_t csi_resolution[][2] = {
[OMV_CSI_FRAMESIZE_WQXGA] = {2560, 1600},
[OMV_CSI_FRAMESIZE_WQXGA2] = {2592, 1944},
};
// *INDENT-ON*
omv_csi_t csi_all[OMV_CSI_MAX_DEVICES] = {0};
@ -313,8 +315,12 @@ __weak int omv_csi_reset(omv_csi_t *csi, bool hard) {
#endif // MICROPY_PY_IMU
csi->color_palette = rainbow_table;
csi->disable_full_flush = false;
csi->vsync_cb = (omv_csi_cb_t) { NULL, NULL };
csi->frame_cb = (omv_csi_cb_t) { NULL, NULL };
csi->vsync_cb = (omv_csi_cb_t) {
NULL, NULL
};
csi->frame_cb = (omv_csi_cb_t) {
NULL, NULL
};
// Restore shutdown state on reset.
if (!csi->power_on) {
@ -462,7 +468,9 @@ static size_t omv_csi_detect(omv_i2c_t *i2c, i2c_dev_t *dev_list) {
}
if (chip_id && dev_count < OMV_CSI_MAX_DEVICES) {
dev_list[dev_count++] = (i2c_dev_t) { slv_addr, chip_id };
dev_list[dev_count++] = (i2c_dev_t) {
slv_addr, chip_id
};
}
}
@ -520,7 +528,9 @@ int omv_csi_probe(omv_i2c_t *i2c) {
// Add special devices, such as SPI sensors, soft-CSI etc...
#if OMV_SOFTCSI_ENABLE
if (dev_count < OMV_CSI_MAX_DEVICES) {
dev_list[dev_count++] = (i2c_dev_t) { 0, SOFTCSI_ID };
dev_list[dev_count++] = (i2c_dev_t) {
0, SOFTCSI_ID
};
}
#endif
@ -529,7 +539,9 @@ int omv_csi_probe(omv_i2c_t *i2c) {
// Found PixArt PAJ6100
power_pol = OMV_CSI_ACTIVE_LOW;
reset_pol = OMV_CSI_ACTIVE_LOW;
dev_list[dev_count++] = (i2c_dev_t) { 0, PAJ6100_ID };
dev_list[dev_count++] = (i2c_dev_t) {
0, PAJ6100_ID
};
}
#endif

View File

@ -143,7 +143,9 @@ int tinyusb_debug_init(void) {
ctx.opcode = 0;
ctx.length = 0;
if (!ctx.ringbuf.buf) {
ctx.ringbuf = (ringbuf_t) { ctx.rawbuf, sizeof(ctx.rawbuf), 0, 0 };
ctx.ringbuf = (ringbuf_t) {
ctx.rawbuf, sizeof(ctx.rawbuf), 0, 0
};
}
return 0;
}

View File

@ -47,8 +47,7 @@ static int16_t readout_y = 0;
static enum {
MONO_CFA, RCCC_CFA, BAYER_CFA
}
cfa_type = MONO_CFA;
} cfa_type = MONO_CFA;
static bool is_mt9v0x2(omv_csi_t *csi) {
return (csi->chip_id == MT9V0X2_ID) || (csi->chip_id == MT9V0X2_C_ID);

View File

@ -115,7 +115,7 @@ extern int frogeye2020_init(omv_csi_t *csi);
#endif
extern int softcsi_init(omv_csi_t *csi);
// Sensor table
// Sensor table *INDENT-OFF*
static const sensor_config_t sensor_config_table[] = {
#if OMV_OV2640_ENABLE
{ OV2640_ID, OMV_OV2640_CLK_FREQ, ov2640_init },

View File

@ -27,8 +27,7 @@
typedef struct xylr {
int16_t x, y, l, r, t_l, b_l;
}
xylr_t;
} xylr_t;
static float sign(float x) {
return x / fabsf(x);

View File

@ -61,8 +61,7 @@ float fast_expf(float x) {
float fast_cbrtf(float x) {
union {
int ix; float x;
}
v;
} v;
v.x = x; // x can be viewed as int.
v.ix = v.ix / 4 + v.ix / 16; // Approximate divide by 3.
v.ix = v.ix + v.ix / 16;
@ -135,12 +134,10 @@ float fast_atan2f(float y, float x) {
float fast_log2(float x) {
union {
float f; uint32_t i;
}
vx = { x };
} vx = { x };
union {
uint32_t i; float f;
}
mx = { (vx.i & 0x007FFFFF) | 0x3f000000 };
} mx = { (vx.i & 0x007FFFFF) | 0x3f000000 };
float y = vx.i;
y *= 1.1920928955078125e-7f;
@ -155,8 +152,7 @@ float fast_log(float x) {
float fast_powf(float a, float b) {
union {
float d; int x;
}
u = { a };
} u = { a };
u.x = (int) ((b * (u.x - 1064866805)) + 1064866805);
return u.d;
}

View File

@ -78,8 +78,7 @@ static inline int fast_ceilf(float x) {
#else
union {
uint32_t i; float f;
}
max = { 0x3f7fffff };
} max = { 0x3f7fffff };
x += max.f;
__asm__ volatile (
"vcvt.S32.f32 %[r], %[x]\n"

View File

@ -172,8 +172,7 @@ typedef struct color_thresholds_list_lnk_data {
uint8_t LMin, LMax; // or grayscale
int8_t AMin, AMax;
int8_t BMin, BMax;
}
color_thresholds_list_lnk_data_t;
}color_thresholds_list_lnk_data_t;
#define COLOR_THRESHOLD_BINARY(pixel, threshold, invert) \
({ \

View File

@ -41,8 +41,7 @@ static void read_int_reset(ppm_read_settings_t *rs) {
static void read_int(FIL *fp, uint32_t *i, ppm_read_settings_t *rs) {
enum {
EAT_WHITESPACE, EAT_COMMENT, EAT_NUMBER
}
mode = EAT_WHITESPACE;
} mode = EAT_WHITESPACE;
for (*i = 0;;) {
if (!rs->read_int_c_valid) {
if (file_tell(fp) == file_size(fp)) {

View File

@ -1357,10 +1357,18 @@ static inline v4x_rows_t vcvt_u8_f32(v128_t v0) {
};
#else
return (v4x_rows_t) {
.r0 = (v128_t) { .f32 = { (float32_t) v0.u8[0] } },
.r1 = (v128_t) { .f32 = { (float32_t) v0.u8[1] } },
.r2 = (v128_t) { .f32 = { (float32_t) v0.u8[2] } },
.r3 = (v128_t) { .f32 = { (float32_t) v0.u8[3] } }
.r0 = (v128_t) {
.f32 = { (float32_t) v0.u8[0] }
},
.r1 = (v128_t) {
.f32 = { (float32_t) v0.u8[1] }
},
.r2 = (v128_t) {
.f32 = { (float32_t) v0.u8[2] }
},
.r3 = (v128_t) {
.f32 = { (float32_t) v0.u8[3] }
}
};
#endif
}
@ -1377,10 +1385,18 @@ static inline v4x_rows_t vcvt_s8_f32(v128_t v0) {
};
#else
return (v4x_rows_t) {
.r0 = (v128_t) { .f32 = { (float32_t) v0.s8[0] } },
.r1 = (v128_t) { .f32 = { (float32_t) v0.s8[1] } },
.r2 = (v128_t) { .f32 = { (float32_t) v0.s8[2] } },
.r3 = (v128_t) { .f32 = { (float32_t) v0.s8[3] } }
.r0 = (v128_t) {
.f32 = { (float32_t) v0.s8[0] }
},
.r1 = (v128_t) {
.f32 = { (float32_t) v0.s8[1] }
},
.r2 = (v128_t) {
.f32 = { (float32_t) v0.s8[2] }
},
.r3 = (v128_t) {
.f32 = { (float32_t) v0.s8[3] }
}
};
#endif
}
@ -1393,8 +1409,12 @@ static inline v2x_rows_t vcvt_u16_f32(v128_t v0) {
};
#else
return (v2x_rows_t) {
.r0 = (v128_t) { .f32 = { (float32_t) v0.u16[0] } },
.r1 = (v128_t) { .f32 = { (float32_t) v0.u16[1] } }
.r0 = (v128_t) {
.f32 = { (float32_t) v0.u16[0] }
},
.r1 = (v128_t) {
.f32 = { (float32_t) v0.u16[1] }
}
};
#endif
}
@ -1407,8 +1427,12 @@ static inline v2x_rows_t vcvt_s16_f32(v128_t v0) {
};
#else
return (v2x_rows_t) {
.r0 = (v128_t) { .f32 = { (float32_t) v0.s16[0] } },
.r1 = (v128_t) { .f32 = { (float32_t) v0.s16[1] } }
.r0 = (v128_t) {
.f32 = { (float32_t) v0.s16[0] }
},
.r1 = (v128_t) {
.f32 = { (float32_t) v0.s16[1] }
}
};
#endif
}

View File

@ -178,7 +178,9 @@ int ml_backend_init_model(py_ml_model_obj_t *model) {
const LL_Buffer_InfoTypeDef *model_outputs = ll_aton_reloc_get_output_buffers_info(&state->nn_inst, -1);
// Initialize the model's inputs.
for (model->inputs_size = 0; model_inputs[model->inputs_size].name != NULL; model->inputs_size++);
for (model->inputs_size = 0; model_inputs[model->inputs_size].name != NULL; model->inputs_size++) {
;
}
model->input_shape = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->inputs_size, NULL));
model->input_scale = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->inputs_size, NULL));
model->input_zero_point = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->inputs_size, NULL));
@ -205,7 +207,9 @@ int ml_backend_init_model(py_ml_model_obj_t *model) {
}
// Initialize the model's outputs.
for (model->outputs_size = 0; model_outputs[model->outputs_size].name != NULL; model->outputs_size++);
for (model->outputs_size = 0; model_outputs[model->outputs_size].name != NULL; model->outputs_size++) {
;
}
model->output_shape = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->outputs_size, NULL));
model->output_scale = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->outputs_size, NULL));
model->output_zero_point = (mp_obj_tuple_t *) MP_OBJ_TO_PTR(mp_obj_new_tuple(model->outputs_size, NULL));

View File

@ -287,7 +287,9 @@ static int stm_csi_abort(omv_csi_t *csi, bool fifo_flush, bool in_irq) {
if (!csi->mipi_if) {
DCMI->CR &= ~DCMI_CR_ENABLE;
while (DCMI->CR & DCMI_CR_ENABLE);
while (DCMI->CR & DCMI_CR_ENABLE) {
;
}
#if defined(STM32N6)
HAL_DMA_Abort(&csi->dma);