1 // SPDX-License-Identifier: GPL-2.0
4 * media_device_open.c - Media Controller Device Open Test
6 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
7 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
12 * This file adds a test for Media Controller API.
13 * This test should be run as root and should not be
14 * included in the Kselftest run. This test should be
15 * run when hardware and driver that makes use Media
16 * Controller API are present in the system.
18 * This test opens user specified Media Device and calls
19 * MEDIA_IOC_DEVICE_INFO ioctl, closes the file, and exits.
22 * sudo ./media_device_open -d /dev/mediaX
24 * Run this test is a loop and run bind/unbind on the driver.
33 #include <sys/ioctl.h>
35 #include <linux/media.h>
37 #include "../kselftest.h"
39 int main(int argc
, char **argv
)
42 char media_device
[256];
44 struct media_device_info mdi
;
49 printf("Usage: %s [-d </dev/mediaX>]\n", argv
[0]);
53 /* Process arguments */
54 while ((opt
= getopt(argc
, argv
, "d:")) != -1) {
57 strncpy(media_device
, optarg
, sizeof(media_device
) - 1);
58 media_device
[sizeof(media_device
)-1] = '\0';
61 printf("Usage: %s [-d </dev/mediaX>]\n", argv
[0]);
67 ksft_exit_skip("Please run the test as root - Exiting.\n");
69 /* Open Media device and keep it open */
70 fd
= open(media_device
, O_RDWR
);
72 printf("Media Device open errno %s\n", strerror(errno
));
76 ret
= ioctl(fd
, MEDIA_IOC_DEVICE_INFO
, &mdi
);
78 printf("Media Device Info errno %s\n", strerror(errno
));
80 printf("Media device model %s driver %s\n",
81 mdi
.model
, mdi
.driver
);