camera: used wd timer to process loop event

used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
This commit is contained in:
yezhonghui 2025-04-14 14:59:29 +08:00 committed by Xiang Xiao
parent 954122641a
commit e2ca205f12
3 changed files with 23 additions and 20 deletions

View file

@ -26,6 +26,7 @@
#include <errno.h>
#include <string.h>
#include <nuttx/wdog.h>
#include <nuttx/video/imgsensor.h>
#include <nuttx/video/imgdata.h>
#include <nuttx/video/video.h>
@ -37,6 +38,8 @@
* Pre-processor Definitions
****************************************************************************/
#define SIM_CAMERA_PERIOD MSEC2TICK(CONFIG_SIM_LOOP_INTERVAL)
/****************************************************************************
* Private Types
****************************************************************************/
@ -51,6 +54,7 @@ typedef struct
uint8_t *next_buf;
struct timeval *next_ts;
struct host_video_dev_s *vdev;
struct wdog_s wdog;
} sim_camera_priv_t;
/****************************************************************************
@ -345,22 +349,9 @@ static int sim_camera_data_stop_capture(struct imgdata_s *data)
return host_video_stop_capture(priv->vdev);
}
/****************************************************************************
* Public Functions
****************************************************************************/
int sim_camera_initialize(void)
static void sim_camera_interrupt(wdparm_t arg)
{
sim_camera_priv_t *priv = &g_sim_camera_priv;
imgsensor_register(&priv->sensor);
imgdata_register(&priv->data);
return 0;
}
void sim_camera_loop(void)
{
sim_camera_priv_t *priv = &g_sim_camera_priv;
sim_camera_priv_t *priv = (sim_camera_priv_t *)arg;
struct timespec ts;
struct timeval tv;
int ret;
@ -375,4 +366,21 @@ void sim_camera_loop(void)
priv->capture_cb(0, ret, &tv, priv->capture_arg);
}
}
wd_start_next(&priv->wdog, SIM_CAMERA_PERIOD, sim_camera_interrupt, arg);
}
/****************************************************************************
* Public Functions
****************************************************************************/
int sim_camera_initialize(void)
{
sim_camera_priv_t *priv = &g_sim_camera_priv;
imgsensor_register(&priv->sensor);
imgdata_register(&priv->data);
wd_start(&priv->wdog, 0, sim_camera_interrupt, (wdparm_t)priv);
return 0;
}

View file

@ -224,10 +224,6 @@ static int sim_loop_task(int argc, char **argv)
sched_lock();
#ifdef CONFIG_SIM_CAMERA
sim_camera_loop();
#endif
#ifdef CONFIG_SIM_USB_DEV
sim_usbdev_loop();
#endif

View file

@ -475,7 +475,6 @@ int sim_spi_uninitialize(struct spi_dev_s *dev);
#ifdef CONFIG_SIM_CAMERA
int sim_camera_initialize(void);
void sim_camera_loop(void);
#endif
#ifdef CONFIG_SIM_VIDEO_DECODER