/*1* Media device node2*3* Copyright (C) 2010 Nokia Corporation4*5* Contacts: Laurent Pinchart <[email protected]>6* Sakari Ailus <[email protected]>7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License version 2 as10* published by the Free Software Foundation.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*21* --22*23* Common functions for media-related drivers to register and unregister media24* device nodes.25*/2627#ifndef _MEDIA_DEVNODE_H28#define _MEDIA_DEVNODE_H2930#include <linux/poll.h>31#include <linux/fs.h>32#include <linux/device.h>33#include <linux/cdev.h>3435/*36* Flag to mark the media_devnode struct as registered. Drivers must not touch37* this flag directly, it will be set and cleared by media_devnode_register and38* media_devnode_unregister.39*/40#define MEDIA_FLAG_REGISTERED 04142struct media_file_operations {43struct module *owner;44ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);45ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);46unsigned int (*poll) (struct file *, struct poll_table_struct *);47long (*ioctl) (struct file *, unsigned int, unsigned long);48int (*open) (struct file *);49int (*release) (struct file *);50};5152/**53* struct media_devnode - Media device node54* @parent: parent device55* @minor: device node minor number56* @flags: flags, combination of the MEDIA_FLAG_* constants57*58* This structure represents a media-related device node.59*60* The @parent is a physical device. It must be set by core or device drivers61* before registering the node.62*/63struct media_devnode {64/* device ops */65const struct media_file_operations *fops;6667/* sysfs */68struct device dev; /* media device */69struct cdev cdev; /* character device */70struct device *parent; /* device parent */7172/* device info */73int minor;74unsigned long flags; /* Use bitops to access flags */7576/* callbacks */77void (*release)(struct media_devnode *mdev);78};7980/* dev to media_devnode */81#define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)8283int __must_check media_devnode_register(struct media_devnode *mdev);84void media_devnode_unregister(struct media_devnode *mdev);8586static inline struct media_devnode *media_devnode_data(struct file *filp)87{88return filp->private_data;89}9091static inline int media_devnode_is_registered(struct media_devnode *mdev)92{93return test_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);94}9596#endif /* _MEDIA_DEVNODE_H */979899