drivers/video: add timestamp support

Add support for timestamp and change in related drivers

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
This commit is contained in:
Peter Bee 2023-02-06 17:08:31 +08:00 committed by Xiang Xiao
parent 74ce3b81d3
commit 2ebccd82b6
4 changed files with 23 additions and 9 deletions

View File

@ -373,7 +373,7 @@ static void cisif_callback_for_intlev(uint8_t code)
/* Notify and get next addr */
g_cxd56_cisif_complete_capture(0, size);
g_cxd56_cisif_complete_capture(0, size, NULL);
g_jpgint_receive = false;
@ -413,7 +413,7 @@ static void cisif_ycc_axi_trdn_int(uint8_t code)
else
{
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
g_cxd56_cisif_complete_capture(0, size);
g_cxd56_cisif_complete_capture(0, size, NULL);
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
}
}
@ -463,7 +463,7 @@ static void cisif_jpg_axi_trdn_int(uint8_t code)
else
{
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
g_cxd56_cisif_complete_capture(0, size);
g_cxd56_cisif_complete_capture(0, size, NULL);
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
}
}
@ -495,7 +495,7 @@ static void cisif_ycc_err_int(uint8_t code)
#endif
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
g_cxd56_cisif_complete_capture(code, size);
g_cxd56_cisif_complete_capture(code, size, NULL);
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
g_errint_receive = true;
}
@ -513,7 +513,7 @@ static void cisif_jpg_err_int(uint8_t code)
#endif
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
g_cxd56_cisif_complete_capture(code, size);
g_cxd56_cisif_complete_capture(code, size, NULL);
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
g_errint_receive = true;
}

View File

@ -46,6 +46,7 @@ typedef struct
imgdata_capture_t capture_cb;
uint32_t buf_size;
uint8_t *next_buf;
struct timeval *next_ts;
struct host_video_dev_s *vdev;
} sim_video_priv_t;
@ -336,6 +337,8 @@ int sim_video_uninitialize(void)
void sim_video_loop(void)
{
sim_video_priv_t *priv = &g_sim_video_priv;
struct timespec ts;
struct timeval tv;
int ret;
if (priv->next_buf)
@ -343,7 +346,9 @@ void sim_video_loop(void)
ret = host_video_dqbuf(priv->vdev, priv->next_buf, priv->buf_size);
if (ret > 0)
{
priv->capture_cb(0, ret);
clock_gettime(CLOCK_MONOTONIC, &ts);
TIMESPEC_TO_TIMEVAL(&tv, &ts);
priv->capture_cb(0, ret, &tv);
}
}
}

View File

@ -216,7 +216,8 @@ static bool is_sem_waited(FAR sem_t *sem);
static int save_scene_param(enum v4l2_scene_mode mode,
uint32_t id,
struct v4l2_ext_control *control);
static int video_complete_capture(uint8_t err_code, uint32_t datasize);
static int video_complete_capture(uint8_t err_code, uint32_t datasize,
FAR const struct timeval *ts);
static int validate_frame_setting(enum v4l2_buf_type type,
uint8_t nr_fmt,
FAR video_format_t *vfmt,
@ -3226,7 +3227,8 @@ static int video_unregister(FAR video_mng_t *priv)
/* Callback function which device driver call when capture has done. */
static int video_complete_capture(uint8_t err_code, uint32_t datasize)
static int video_complete_capture(uint8_t err_code, uint32_t datasize,
FAR const struct timeval *ts)
{
FAR video_mng_t *vmng = (FAR video_mng_t *)g_video_handler;
FAR video_type_inf_t *type_inf;
@ -3260,6 +3262,11 @@ static int video_complete_capture(uint8_t err_code, uint32_t datasize)
}
type_inf->bufinf.vbuf_curr->buf.bytesused = datasize;
if (ts != NULL)
{
type_inf->bufinf.vbuf_curr->buf.timestamp = *ts;
}
video_framebuff_capture_done(&type_inf->bufinf);
if (is_sem_waited(&type_inf->wait_capture.dqbuf_wait_flg))

View File

@ -26,6 +26,7 @@
****************************************************************************/
#include <sys/types.h>
#include <sys/time.h>
/****************************************************************************
* Pre-processor Definitions
@ -81,7 +82,8 @@ typedef struct imgdata_interval_s
uint32_t denominator;
} imgdata_interval_t;
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size);
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size,
FAR const struct timeval *ts);
/* Structure for Data Control I/F */