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


##########
arch/sim/src/sim/posix/sim_host_v4l2.c:
##########
@@ -0,0 +1,356 @@
+/****************************************************************************
+ * arch/sim/src/sim/posix/sim_host_v4l2.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 <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <linux/videodev2.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include "sim_hostvideo.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define MAX_REQBUFS 3
+
+#define WARN(fmt, ...) \
+        syslog(LOG_WARNING, "sim_host_video: " fmt "\n", ##__VA_ARGS__)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct host_video_dev_s
+{
+  int fd;
+  void *addrs[MAX_REQBUFS];
+  size_t buflen[MAX_REQBUFS];
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int host_video_ioctl(int fd, int request, void *arg)
+{
+  int r;
+
+  do
+    {
+      r = ioctl(fd, request, arg);
+    }
+  while (-1 == r && EINTR == errno);
+
+  return r;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+bool host_video_is_available(const char *host_video_dev_path)
+{
+  return access(host_video_dev_path, F_OK) == 0;
+}
+
+struct host_video_dev_s *host_video_init(const char *host_video_dev_path)
+{
+  int fd;
+  struct host_video_dev_s *vdev;
+
+  fd = open(host_video_dev_path, O_RDWR | O_NONBLOCK);
+  if (fd < 0)
+    {
+      perror(host_video_dev_path);
+      return NULL;
+    }
+
+  vdev = calloc(1, sizeof(*vdev));

Review Comment:
   fixed



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