Merge branch 'staging-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[zen-stable.git] / include / media / media-devnode.h
blobf6caafc874cbdc28aa950b64103603c25d6c5e53
1 /*
2 * Media device node
4 * Copyright (C) 2010 Nokia Corporation
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * --
24 * Common functions for media-related drivers to register and unregister media
25 * device nodes.
28 #ifndef _MEDIA_DEVNODE_H
29 #define _MEDIA_DEVNODE_H
31 #include <linux/poll.h>
32 #include <linux/fs.h>
33 #include <linux/device.h>
34 #include <linux/cdev.h>
37 * Flag to mark the media_devnode struct as registered. Drivers must not touch
38 * this flag directly, it will be set and cleared by media_devnode_register and
39 * media_devnode_unregister.
41 #define MEDIA_FLAG_REGISTERED 0
43 struct media_file_operations {
44 struct module *owner;
45 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
46 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
47 unsigned int (*poll) (struct file *, struct poll_table_struct *);
48 long (*ioctl) (struct file *, unsigned int, unsigned long);
49 int (*open) (struct file *);
50 int (*release) (struct file *);
53 /**
54 * struct media_devnode - Media device node
55 * @parent: parent device
56 * @minor: device node minor number
57 * @flags: flags, combination of the MEDIA_FLAG_* constants
59 * This structure represents a media-related device node.
61 * The @parent is a physical device. It must be set by core or device drivers
62 * before registering the node.
64 struct media_devnode {
65 /* device ops */
66 const struct media_file_operations *fops;
68 /* sysfs */
69 struct device dev; /* media device */
70 struct cdev cdev; /* character device */
71 struct device *parent; /* device parent */
73 /* device info */
74 int minor;
75 unsigned long flags; /* Use bitops to access flags */
77 /* callbacks */
78 void (*release)(struct media_devnode *mdev);
81 /* dev to media_devnode */
82 #define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
84 int __must_check media_devnode_register(struct media_devnode *mdev);
85 void media_devnode_unregister(struct media_devnode *mdev);
87 static inline struct media_devnode *media_devnode_data(struct file *filp)
89 return filp->private_data;
92 static inline int media_devnode_is_registered(struct media_devnode *mdev)
94 return test_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);
97 #endif /* _MEDIA_DEVNODE_H */