PeterBee97 commented on code in PR #7798:
URL: https://github.com/apache/nuttx/pull/7798#discussion_r1041017521


##########
arch/sim/src/sim/sim_video.c:
##########
@@ -0,0 +1,354 @@
+/****************************************************************************
+ * arch/sim/src/sim/sim_video.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arch/board/board.h>
+#include <nuttx/config.h>
+#include <nuttx/semaphore.h>
+#include <nuttx/signal.h>
+#include <nuttx/video/imgsensor.h>
+#include <nuttx/video/imgdata.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include "sim_video_host.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define HOST_VIDEO_DEV_PATH  CONFIG_HOST_VIDEO_DEV_PATH
+#define ENQUEUE(q, addr, size) (q).addr[q.num] = addr; \
+                               (q).size[q.num++] = size;
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+typedef struct
+{
+  imgdata_capture_t capture_cb;
+  uint32_t buf_size;
+  uintptr_t next_buf;
+  bool is_streaming;
+} video_priv_t;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* video image sensor operations */
+
+static bool sim_video_is_available(void);
+static int sim_video_init(void);
+static int sim_video_uninit(void);
+static FAR const char *sim_video_get_driver_name(void);
+static int sim_video_validate_frame_setting(imgsensor_stream_type_t type,
+                                         uint8_t nr_datafmt,
+                                         FAR imgsensor_format_t *datafmts,

Review Comment:
   done



##########
arch/sim/src/sim/sim_video.c:
##########
@@ -0,0 +1,354 @@
+/****************************************************************************
+ * arch/sim/src/sim/sim_video.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arch/board/board.h>
+#include <nuttx/config.h>
+#include <nuttx/semaphore.h>
+#include <nuttx/signal.h>
+#include <nuttx/video/imgsensor.h>
+#include <nuttx/video/imgdata.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include "sim_video_host.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define HOST_VIDEO_DEV_PATH  CONFIG_HOST_VIDEO_DEV_PATH
+#define ENQUEUE(q, addr, size) (q).addr[q.num] = addr; \
+                               (q).size[q.num++] = size;
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+typedef struct
+{
+  imgdata_capture_t capture_cb;
+  uint32_t buf_size;
+  uintptr_t next_buf;
+  bool is_streaming;
+} video_priv_t;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* video image sensor operations */
+
+static bool sim_video_is_available(void);
+static int sim_video_init(void);
+static int sim_video_uninit(void);
+static FAR const char *sim_video_get_driver_name(void);
+static int sim_video_validate_frame_setting(imgsensor_stream_type_t type,
+                                         uint8_t nr_datafmt,
+                                         FAR imgsensor_format_t *datafmts,
+                                         FAR imgsensor_interval_t *interval);
+static int sim_video_start_capture(imgsensor_stream_type_t type,
+                                uint8_t nr_datafmt,
+                                FAR imgsensor_format_t *datafmts,
+                                FAR imgsensor_interval_t *interval);
+static int sim_video_stop_capture(imgsensor_stream_type_t type);
+static int sim_video_get_supported_value(uint32_t id,
+                                     FAR imgsensor_supported_value_t *value);
+static int sim_video_get_value(uint32_t id, uint32_t size,
+                            FAR imgsensor_value_t *value);
+static int sim_video_set_value(uint32_t id, uint32_t size,
+                            imgsensor_value_t value);
+
+/* video image data operations */
+
+static int sim_video_data_init(void);
+static int sim_video_data_uninit(void);
+static int sim_video_data_validate_frame_setting
+             (uint8_t nr_datafmt,
+              imgdata_format_t *datafmt,
+              imgdata_interval_t *interval);
+static int sim_video_data_start_capture
+             (uint8_t nr_datafmt,
+              imgdata_format_t *datafmt,
+              imgdata_interval_t *interval,
+              imgdata_capture_t callback);
+static int sim_video_data_stop_capture(void);
+static int sim_video_data_validate_buf(uint8_t *addr, uint32_t size);
+static int sim_video_data_set_buf(uint8_t *addr, uint32_t size);
+
+static uint32_t imgsensor_fmt_to_v4l2(uint32_t pixelformat);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct imgsensor_ops_s g_sim_video_ops =

Review Comment:
   done



-- 
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