LCOV - code coverage report
Current view: top level - udev/v4l_id - v4l_id.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 0 40 0.0 %
Date: 2019-08-23 13:36:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 29 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0+ */
       2                 :            : /*
       3                 :            :  * Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
       4                 :            :  *
       5                 :            :  * This program is free software; you can redistribute it and/or
       6                 :            :  * modify it under the terms of the GNU General Public License as
       7                 :            :  * published by the Free Software Foundation; either version 2 of the
       8                 :            :  * License, or (at your option) any later version.
       9                 :            :  *
      10                 :            :  * This program is distributed in the hope that it will be useful, but
      11                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13                 :            :  * General Public License for more details:
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <ctype.h>
      17                 :            : #include <errno.h>
      18                 :            : #include <fcntl.h>
      19                 :            : #include <getopt.h>
      20                 :            : #include <stdio.h>
      21                 :            : #include <stdlib.h>
      22                 :            : #include <string.h>
      23                 :            : #include <sys/ioctl.h>
      24                 :            : #include <sys/time.h>
      25                 :            : #include <sys/types.h>
      26                 :            : #include <unistd.h>
      27                 :            : #include <linux/videodev2.h>
      28                 :            : 
      29                 :            : #include "fd-util.h"
      30                 :            : #include "util.h"
      31                 :            : 
      32                 :          0 : int main(int argc, char *argv[]) {
      33                 :            :         static const struct option options[] = {
      34                 :            :                 { "help", no_argument, NULL, 'h' },
      35                 :            :                 {}
      36                 :            :         };
      37                 :          0 :         _cleanup_close_ int fd = -1;
      38                 :            :         char *device;
      39                 :            :         struct v4l2_capability v2cap;
      40                 :            :         int c;
      41                 :            : 
      42         [ #  # ]:          0 :         while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
      43                 :            : 
      44      [ #  #  # ]:          0 :                 switch (c) {
      45                 :          0 :                 case 'h':
      46                 :          0 :                         printf("%s [-h,--help] <device file>\n\n"
      47                 :            :                                "Video4Linux device identification.\n\n"
      48                 :            :                                "  -h  Print this message\n"
      49                 :            :                                , program_invocation_short_name);
      50                 :          0 :                         return 0;
      51                 :          0 :                 case '?':
      52                 :          0 :                         return -EINVAL;
      53                 :            : 
      54                 :          0 :                 default:
      55                 :          0 :                         assert_not_reached("Unhandled option");
      56                 :            :                 }
      57                 :            : 
      58                 :          0 :         device = argv[optind];
      59         [ #  # ]:          0 :         if (!device)
      60                 :          0 :                 return 2;
      61                 :            : 
      62                 :          0 :         fd = open(device, O_RDONLY);
      63         [ #  # ]:          0 :         if (fd < 0)
      64                 :          0 :                 return 3;
      65                 :            : 
      66         [ #  # ]:          0 :         if (ioctl(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
      67                 :            :                 int capabilities;
      68                 :          0 :                 printf("ID_V4L_VERSION=2\n");
      69                 :          0 :                 printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
      70                 :          0 :                 printf("ID_V4L_CAPABILITIES=:");
      71         [ #  # ]:          0 :                 if (v2cap.capabilities & V4L2_CAP_DEVICE_CAPS)
      72                 :          0 :                         capabilities = v2cap.device_caps;
      73                 :            :                 else
      74                 :          0 :                         capabilities = v2cap.capabilities;
      75         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0 ||
      76         [ #  # ]:          0 :                     (capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) > 0)
      77                 :          0 :                         printf("capture:");
      78         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0 ||
      79         [ #  # ]:          0 :                     (capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE) > 0)
      80                 :          0 :                         printf("video_output:");
      81         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0)
      82                 :          0 :                         printf("video_overlay:");
      83         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_AUDIO) > 0)
      84                 :          0 :                         printf("audio:");
      85         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_TUNER) > 0)
      86                 :          0 :                         printf("tuner:");
      87         [ #  # ]:          0 :                 if ((capabilities & V4L2_CAP_RADIO) > 0)
      88                 :          0 :                         printf("radio:");
      89                 :          0 :                 printf("\n");
      90                 :            :         }
      91                 :            : 
      92                 :          0 :         return 0;
      93                 :            : }

Generated by: LCOV version 1.14