Skip to content

Commit 2ebccd8

Browse files
PeterBee97xiaoxiang781216
authored andcommitted
drivers/video: add timestamp support
Add support for timestamp and change in related drivers Signed-off-by: Peter Bee <[email protected]>
1 parent 74ce3b8 commit 2ebccd8

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

arch/arm/src/cxd56xx/cxd56_cisif.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static void cisif_callback_for_intlev(uint8_t code)
373373

374374
/* Notify and get next addr */
375375

376-
g_cxd56_cisif_complete_capture(0, size);
376+
g_cxd56_cisif_complete_capture(0, size, NULL);
377377

378378
g_jpgint_receive = false;
379379

@@ -413,7 +413,7 @@ static void cisif_ycc_axi_trdn_int(uint8_t code)
413413
else
414414
{
415415
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
416-
g_cxd56_cisif_complete_capture(0, size);
416+
g_cxd56_cisif_complete_capture(0, size, NULL);
417417
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
418418
}
419419
}
@@ -463,7 +463,7 @@ static void cisif_jpg_axi_trdn_int(uint8_t code)
463463
else
464464
{
465465
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
466-
g_cxd56_cisif_complete_capture(0, size);
466+
g_cxd56_cisif_complete_capture(0, size, NULL);
467467
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
468468
}
469469
}
@@ -495,7 +495,7 @@ static void cisif_ycc_err_int(uint8_t code)
495495
#endif
496496

497497
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
498-
g_cxd56_cisif_complete_capture(code, size);
498+
g_cxd56_cisif_complete_capture(code, size, NULL);
499499
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
500500
g_errint_receive = true;
501501
}
@@ -513,7 +513,7 @@ static void cisif_jpg_err_int(uint8_t code)
513513
#endif
514514

515515
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
516-
g_cxd56_cisif_complete_capture(code, size);
516+
g_cxd56_cisif_complete_capture(code, size, NULL);
517517
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
518518
g_errint_receive = true;
519519
}

arch/sim/src/sim/sim_video.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct
4646
imgdata_capture_t capture_cb;
4747
uint32_t buf_size;
4848
uint8_t *next_buf;
49+
struct timeval *next_ts;
4950
struct host_video_dev_s *vdev;
5051
} sim_video_priv_t;
5152

@@ -336,14 +337,18 @@ int sim_video_uninitialize(void)
336337
void sim_video_loop(void)
337338
{
338339
sim_video_priv_t *priv = &g_sim_video_priv;
340+
struct timespec ts;
341+
struct timeval tv;
339342
int ret;
340343

341344
if (priv->next_buf)
342345
{
343346
ret = host_video_dqbuf(priv->vdev, priv->next_buf, priv->buf_size);
344347
if (ret > 0)
345348
{
346-
priv->capture_cb(0, ret);
349+
clock_gettime(CLOCK_MONOTONIC, &ts);
350+
TIMESPEC_TO_TIMEVAL(&tv, &ts);
351+
priv->capture_cb(0, ret, &tv);
347352
}
348353
}
349354
}

drivers/video/video.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ static bool is_sem_waited(FAR sem_t *sem);
216216
static int save_scene_param(enum v4l2_scene_mode mode,
217217
uint32_t id,
218218
struct v4l2_ext_control *control);
219-
static int video_complete_capture(uint8_t err_code, uint32_t datasize);
219+
static int video_complete_capture(uint8_t err_code, uint32_t datasize,
220+
FAR const struct timeval *ts);
220221
static int validate_frame_setting(enum v4l2_buf_type type,
221222
uint8_t nr_fmt,
222223
FAR video_format_t *vfmt,
@@ -3226,7 +3227,8 @@ static int video_unregister(FAR video_mng_t *priv)
32263227

32273228
/* Callback function which device driver call when capture has done. */
32283229

3229-
static int video_complete_capture(uint8_t err_code, uint32_t datasize)
3230+
static int video_complete_capture(uint8_t err_code, uint32_t datasize,
3231+
FAR const struct timeval *ts)
32303232
{
32313233
FAR video_mng_t *vmng = (FAR video_mng_t *)g_video_handler;
32323234
FAR video_type_inf_t *type_inf;
@@ -3260,6 +3262,11 @@ static int video_complete_capture(uint8_t err_code, uint32_t datasize)
32603262
}
32613263

32623264
type_inf->bufinf.vbuf_curr->buf.bytesused = datasize;
3265+
if (ts != NULL)
3266+
{
3267+
type_inf->bufinf.vbuf_curr->buf.timestamp = *ts;
3268+
}
3269+
32633270
video_framebuff_capture_done(&type_inf->bufinf);
32643271

32653272
if (is_sem_waited(&type_inf->wait_capture.dqbuf_wait_flg))

include/nuttx/video/imgdata.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
****************************************************************************/
2727

2828
#include <sys/types.h>
29+
#include <sys/time.h>
2930

3031
/****************************************************************************
3132
* Pre-processor Definitions
@@ -81,7 +82,8 @@ typedef struct imgdata_interval_s
8182
uint32_t denominator;
8283
} imgdata_interval_t;
8384

84-
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size);
85+
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size,
86+
FAR const struct timeval *ts);
8587

8688
/* Structure for Data Control I/F */
8789

0 commit comments

Comments
 (0)