aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-08-18 10:41:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 03:53:13 -0400
commit140d88165c25137e871f9559e67986ed89251105 (patch)
treec02891d72b0b85c03d4f493da4c5f37923c836c6 /drivers/media/media-device.c
parent503c3d829eaf48837dd5bff5d97ad66369bb955a (diff)
[media] media: Media device information query
Create the following ioctl and implement it at the media device level to query device information. - MEDIA_IOC_DEVICE_INFO: Query media device information The ioctl and its data structure are defined in the new kernel header linux/media.h available to userspace applications. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r--drivers/media/media-device.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index d2bc809d7a2a..92e0d4eb84b8 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -22,13 +22,70 @@
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/ioctl.h> 24#include <linux/ioctl.h>
25#include <linux/media.h>
25 26
26#include <media/media-device.h> 27#include <media/media-device.h>
27#include <media/media-devnode.h> 28#include <media/media-devnode.h>
28#include <media/media-entity.h> 29#include <media/media-entity.h>
29 30
31/* -----------------------------------------------------------------------------
32 * Userspace API
33 */
34
35static int media_device_open(struct file *filp)
36{
37 return 0;
38}
39
40static int media_device_close(struct file *filp)
41{
42 return 0;
43}
44
45static int media_device_get_info(struct media_device *dev,
46 struct media_device_info __user *__info)
47{
48 struct media_device_info info;
49
50 memset(&info, 0, sizeof(info));
51
52 strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
53 strlcpy(info.model, dev->model, sizeof(info.model));
54 strlcpy(info.serial, dev->serial, sizeof(info.serial));
55 strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
56
57 info.media_version = MEDIA_API_VERSION;
58 info.hw_revision = dev->hw_revision;
59 info.driver_version = dev->driver_version;
60
61 return copy_to_user(__info, &info, sizeof(*__info));
62}
63
64static long media_device_ioctl(struct file *filp, unsigned int cmd,
65 unsigned long arg)
66{
67 struct media_devnode *devnode = media_devnode_data(filp);
68 struct media_device *dev = to_media_device(devnode);
69 long ret;
70
71 switch (cmd) {
72 case MEDIA_IOC_DEVICE_INFO:
73 ret = media_device_get_info(dev,
74 (struct media_device_info __user *)arg);
75 break;
76
77 default:
78 ret = -ENOIOCTLCMD;
79 }
80
81 return ret;
82}
83
30static const struct media_file_operations media_device_fops = { 84static const struct media_file_operations media_device_fops = {
31 .owner = THIS_MODULE, 85 .owner = THIS_MODULE,
86 .open = media_device_open,
87 .ioctl = media_device_ioctl,
88 .release = media_device_close,
32}; 89};
33 90
34/* ----------------------------------------------------------------------------- 91/* -----------------------------------------------------------------------------