2 * media_device_open.c - Media Controller Device Open Test
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * This file is released under the GPLv2.
11 * This file adds a test for Media Controller API.
12 * This test should be run as root and should not be
13 * included in the Kselftest run. This test should be
14 * run when hardware and driver that makes use Media
15 * Controller API are present in the system.
17 * This test opens user specified Media Device and calls
18 * MEDIA_IOC_DEVICE_INFO ioctl, closes the file, and exits.
21 * sudo ./media_device_open -d /dev/mediaX
23 * Run this test is a loop and run bind/unbind on the driver.
32 #include <sys/ioctl.h>
34 #include <linux/media.h>
36 int main(int argc, char **argv)
39 char media_device[256];
41 struct media_device_info mdi;
46 printf("Usage: %s [-d </dev/mediaX>]\n", argv[0]);
50 /* Process arguments */
51 while ((opt = getopt(argc, argv, "d:")) != -1) {
54 strncpy(media_device, optarg, sizeof(media_device) - 1);
55 media_device[sizeof(media_device)-1] = '\0';
58 printf("Usage: %s [-d </dev/mediaX>]\n", argv[0]);
64 printf("Please run the test as root - Exiting.\n");
68 /* Open Media device and keep it open */
69 fd = open(media_device, O_RDWR);
71 printf("Media Device open errno %s\n", strerror(errno));
75 ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi);
77 printf("Media Device Info errno %s\n", strerror(errno));
79 printf("Media device model %s driver %s\n",
80 mdi.model, mdi.driver);