pkarashchenko commented on code in PR #7687:
URL: https://github.com/apache/nuttx/pull/7687#discussion_r1033019562


##########
drivers/video/video.c:
##########
@@ -62,6 +62,9 @@
 
 #define VIDEO_ID(x, y) (((x) << 16) | y)
 
+#define MAX_VIDEO_HEAP_SIZE CONFIG_VIDEO_HEAP_SIZE
+#define VMEM_HEAP(v,i) ((uint8_t*)v->vmem_heap + (i) * v->buf_size)

Review Comment:
   ```suggestion
   #define VMEM_HEAP(v,i) ((uint8_t *)(v)->vmem_heap + (i) * (v)->buf_size)
   ```



##########
drivers/video/video.c:
##########
@@ -62,6 +62,9 @@
 
 #define VIDEO_ID(x, y) (((x) << 16) | y)

Review Comment:
   ```suggestion
   #define VIDEO_ID(x, y) (((x) << 16) | (y))
   ```



##########
drivers/video/video.c:
##########
@@ -1161,6 +1290,24 @@ static int video_qbuf(FAR struct video_mng_s *vmng,
 
   memcpy(&container->buf, buf, sizeof(struct v4l2_buffer));
   video_framebuff_queue_container(&type_inf->bufinf, container);
+  if (g_video_data_ops->enq_buf)
+    {
+      if (buf->memory == V4L2_MEMORY_MMAP)
+        {
+          ret = g_video_data_ops->enq_buf(
+            VMEM_HEAP(vmng, buf->index), vmng->buf_size);
+        }
+      else
+        {
+          ret = g_video_data_ops->enq_buf(
+            (uint8_t *)(uintptr_t)buf->m.userptr, buf->length);

Review Comment:
   ```suggestion
               (FAR uint8_t *)(uintptr_t)buf->m.userptr, buf->length);
   ```



##########
include/nuttx/video/imgdata.h:
##########
@@ -73,6 +76,8 @@ struct imgdata_ops_s
 
   CODE int (*validate_buf)(uint8_t *addr, uint32_t size);
   CODE int (*set_buf)(uint8_t *addr, uint32_t size);
+  CODE int (*enq_buf)(uint8_t *addr, uint32_t size);
+  CODE int (*dq_buf)(uint8_t **addr, struct timeval *ts);

Review Comment:
   ```suggestion
     CODE int (*validate_buf)(FAR uint8_t *addr, uint32_t size);
     CODE int (*set_buf)(FAR uint8_t *addr, uint32_t size);
     CODE int (*enq_buf)(FAR uint8_t *addr, uint32_t size);
     CODE int (*dq_buf)(FAR uint8_t **addr, FAR struct timeval *ts);
   ```



##########
drivers/video/video.c:
##########
@@ -134,6 +137,9 @@ struct video_mng_s
   uint8_t            open_num;
   video_type_inf_t   video_inf;
   video_type_inf_t   still_inf;
+  void               *vmem_heap;   /* for V4L2_MEMORY_MMAP buffers */

Review Comment:
   ```suggestion
     FAR void           *vmem_heap;   /* for V4L2_MEMORY_MMAP buffers */
   ```



##########
include/nuttx/video/video.h:
##########
@@ -641,6 +1097,89 @@ struct v4l2_querymenu
   };
 };
 
+struct v4l2_input
+{
+    u_int32_t         index;       /*  Which input */
+    u_int8_t          name[32];    /*  Label */
+    u_int32_t         type;        /*  Type of input */
+    u_int32_t         audioset;    /*  Associated audios (bitfield) */
+    u_int32_t         tuner;       /*  enum v4l2_tuner_type */
+    v4l2_std_id  std;
+    u_int32_t         status;
+    u_int32_t         capabilities;
+    u_int32_t         reserved[3];

Review Comment:
   2 spaces alignment



##########
drivers/video/video.c:
##########
@@ -1468,6 +1631,22 @@ static int validate_frame_setting(enum v4l2_buf_type 
type,
   return g_video_data_ops->validate_frame_setting(nr_fmt, df, &di);
 }
 
+static size_t video_fmt_buf_size(video_format_t *vf)
+{
+  size_t ret = vf->width * vf->height;
+  switch (vf->pixelformat)
+    {
+      case V4L2_PIX_FMT_YUV420 :
+        return ret * 3 / 2;
+      case V4L2_PIX_FMT_YUYV :
+      case V4L2_PIX_FMT_UYVY :
+      case V4L2_PIX_FMT_RGB565 :
+      case V4L2_PIX_FMT_JPEG :

Review Comment:
   ```suggestion
         case V4L2_PIX_FMT_YUV420:
           return ret * 3 / 2;
         case V4L2_PIX_FMT_YUYV:
         case V4L2_PIX_FMT_UYVY:
         case V4L2_PIX_FMT_RGB565:
         case V4L2_PIX_FMT_JPEG:
   ```



##########
include/nuttx/video/video.h:
##########
@@ -305,6 +630,136 @@ struct v4l2_selection
   struct v4l2_rect r;  /* The selection rectangle. */
 };
 
+typedef u_int64_t v4l2_std_id;
+
+/* one bit for each */
+#define V4L2_STD_PAL_B          ((v4l2_std_id)0x00000001)
+#define V4L2_STD_PAL_B1         ((v4l2_std_id)0x00000002)
+#define V4L2_STD_PAL_G          ((v4l2_std_id)0x00000004)
+#define V4L2_STD_PAL_H          ((v4l2_std_id)0x00000008)
+#define V4L2_STD_PAL_I          ((v4l2_std_id)0x00000010)
+#define V4L2_STD_PAL_D          ((v4l2_std_id)0x00000020)
+#define V4L2_STD_PAL_D1         ((v4l2_std_id)0x00000040)
+#define V4L2_STD_PAL_K          ((v4l2_std_id)0x00000080)
+
+#define V4L2_STD_PAL_M          ((v4l2_std_id)0x00000100)
+#define V4L2_STD_PAL_N          ((v4l2_std_id)0x00000200)
+#define V4L2_STD_PAL_Nc         ((v4l2_std_id)0x00000400)
+#define V4L2_STD_PAL_60         ((v4l2_std_id)0x00000800)
+
+#define V4L2_STD_NTSC_M         ((v4l2_std_id)0x00001000)    /* BTSC */
+#define V4L2_STD_NTSC_M_JP      ((v4l2_std_id)0x00002000)    /* EIA-J */
+#define V4L2_STD_NTSC_443       ((v4l2_std_id)0x00004000)
+#define V4L2_STD_NTSC_M_KR      ((v4l2_std_id)0x00008000)    /* FM A2 */
+
+#define V4L2_STD_SECAM_B        ((v4l2_std_id)0x00010000)
+#define V4L2_STD_SECAM_D        ((v4l2_std_id)0x00020000)
+#define V4L2_STD_SECAM_G        ((v4l2_std_id)0x00040000)
+#define V4L2_STD_SECAM_H        ((v4l2_std_id)0x00080000)
+#define V4L2_STD_SECAM_K        ((v4l2_std_id)0x00100000)
+#define V4L2_STD_SECAM_K1       ((v4l2_std_id)0x00200000)
+#define V4L2_STD_SECAM_L        ((v4l2_std_id)0x00400000)
+#define V4L2_STD_SECAM_LC       ((v4l2_std_id)0x00800000)
+
+/* ATSC/HDTV */
+#define V4L2_STD_ATSC_8_VSB     ((v4l2_std_id)0x01000000)
+#define V4L2_STD_ATSC_16_VSB    ((v4l2_std_id)0x02000000)
+
+/* Some macros to merge video standards in order to make live easier for the
+ * drivers and V4L2 applications
+ */
+
+/* "Common" NTSC/M - It should be noticed that V4L2_STD_NTSC_443 is
+ * Missing here.
+ */
+#define V4L2_STD_NTSC           (V4L2_STD_NTSC_M    |\
+                 V4L2_STD_NTSC_M_JP     |\
+                 V4L2_STD_NTSC_M_KR)
+/* Secam macros */
+#define V4L2_STD_SECAM_DK          (V4L2_STD_SECAM_D    |\
+                 V4L2_STD_SECAM_K    |\
+                 V4L2_STD_SECAM_K1)
+/* All Secam Standards */
+#define V4L2_STD_SECAM        (V4L2_STD_SECAM_B    |\
+                 V4L2_STD_SECAM_G    |\
+                 V4L2_STD_SECAM_H    |\
+                 V4L2_STD_SECAM_DK    |\
+                 V4L2_STD_SECAM_L       |\
+                 V4L2_STD_SECAM_LC)
+/* PAL macros */
+#define V4L2_STD_PAL_BG        (V4L2_STD_PAL_B        |\
+                 V4L2_STD_PAL_B1    |\
+                 V4L2_STD_PAL_G)
+#define V4L2_STD_PAL_DK        (V4L2_STD_PAL_D        |\
+                 V4L2_STD_PAL_D1    |\
+                 V4L2_STD_PAL_K)
+
+/* "Common" PAL - This macro is there to be compatible with the old
+ * V4L1 concept of "PAL": /BGDKHI.
+ * Several PAL standards are missing here: /M, /N and /Nc
+ */
+
+#define V4L2_STD_PAL        (V4L2_STD_PAL_BG    |\
+                 V4L2_STD_PAL_DK    |\
+                 V4L2_STD_PAL_H        |\
+                 V4L2_STD_PAL_I)
+
+/* Chroma "agnostic" standards */
+
+#define V4L2_STD_B        (V4L2_STD_PAL_B        |\
+                 V4L2_STD_PAL_B1    |\
+                 V4L2_STD_SECAM_B)
+#define V4L2_STD_G        (V4L2_STD_PAL_G        |\
+                 V4L2_STD_SECAM_G)
+#define V4L2_STD_H        (V4L2_STD_PAL_H        |\
+                 V4L2_STD_SECAM_H)
+#define V4L2_STD_L        (V4L2_STD_SECAM_L    |\
+                 V4L2_STD_SECAM_LC)
+#define V4L2_STD_GH        (V4L2_STD_G        |\
+                 V4L2_STD_H)
+#define V4L2_STD_DK        (V4L2_STD_PAL_DK    |\
+                 V4L2_STD_SECAM_DK)
+#define V4L2_STD_BG        (V4L2_STD_B        |\
+                 V4L2_STD_G)
+#define V4L2_STD_MN        (V4L2_STD_PAL_M        |\
+                 V4L2_STD_PAL_N        |\
+                 V4L2_STD_PAL_Nc    |\
+                 V4L2_STD_NTSC)
+
+/* Standards where MTS/BTSC stereo could be found */
+#define V4L2_STD_MTS        (V4L2_STD_NTSC_M    |\
+                 V4L2_STD_PAL_M        |\
+                 V4L2_STD_PAL_N        |\
+                 V4L2_STD_PAL_Nc)
+
+/* Standards for Countries with 60Hz Line frequency */
+#define V4L2_STD_525_60        (V4L2_STD_PAL_M        |\
+                 V4L2_STD_PAL_60    |\
+                 V4L2_STD_NTSC        |\
+                 V4L2_STD_NTSC_443)
+/* Standards for Countries with 50Hz Line frequency */
+#define V4L2_STD_625_50        (V4L2_STD_PAL        |\
+                 V4L2_STD_PAL_N        |\
+                 V4L2_STD_PAL_Nc    |\
+                 V4L2_STD_SECAM)
+
+#define V4L2_STD_ATSC           (V4L2_STD_ATSC_8_VSB    |\
+                 V4L2_STD_ATSC_16_VSB)
+/* Macros with none and all analog standards */
+#define V4L2_STD_UNKNOWN        0
+#define V4L2_STD_ALL            (V4L2_STD_525_60    |\
+                 V4L2_STD_625_50)
+
+struct v4l2_standard
+{
+    u_int32_t             index;
+    v4l2_std_id           id;
+    u_int8_t              name[24];
+    struct v4l2_fract     frameperiod; /* Frames, not fields */
+    u_int32_t             framelines;
+    u_int32_t             reserved[4];

Review Comment:
   2 spaces alignement.
   Also why not using stdint.h types?



##########
drivers/video/video.c:
##########
@@ -1161,6 +1290,24 @@ static int video_qbuf(FAR struct video_mng_s *vmng,
 
   memcpy(&container->buf, buf, sizeof(struct v4l2_buffer));
   video_framebuff_queue_container(&type_inf->bufinf, container);
+  if (g_video_data_ops->enq_buf)

Review Comment:
   Optional
   ```suggestion
     if (g_video_data_ops->enq_buf != NULL)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to