summaryrefslogtreecommitdiff
path: root/yavta.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2014-04-12 16:23:53 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-04-16 20:07:43 +0200
commit37aa7537eedea07bc68d28b672fdc6803547f27a (patch)
treea41b9f969d37d80c443639a76d2b1488ff9ae838 /yavta.c
parentb846edc8c55db1d270b6a0e629ac5d8402480368 (diff)
Separate device object initialisation and opening
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Diffstat (limited to 'yavta.c')
-rw-r--r--yavta.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/yavta.c b/yavta.c
index 739463d..c7ad7b4 100644
--- a/yavta.c
+++ b/yavta.c
@@ -220,17 +220,20 @@ static const char *v4l2_format_name(unsigned int fourcc)
return name;
}
-static int video_open(struct device *dev, const char *devname, int no_query)
+static void video_init(struct device *dev)
{
- struct v4l2_capability cap;
- unsigned int capabilities;
- int ret;
-
memset(dev, 0, sizeof *dev);
dev->fd = -1;
dev->memtype = V4L2_MEMORY_MMAP;
dev->buffers = NULL;
dev->type = (enum v4l2_buf_type)-1;
+}
+
+static int video_open(struct device *dev, const char *devname, int no_query)
+{
+ struct v4l2_capability cap;
+ unsigned int capabilities;
+ int ret;
dev->fd = open(devname, O_RDWR);
if (dev->fd < 0) {
@@ -1599,6 +1602,8 @@ int main(int argc, char *argv[])
unsigned int rt_priority = 1;
+ video_init(&dev);
+
opterr = 0;
while ((c = getopt_long(argc, argv, "c::Cd:f:F::hi:Iln:pq:r:R::s:t:uw:", opts, NULL)) != -1) {