/*1* Media device2*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*/2122#ifndef _MEDIA_DEVICE_H23#define _MEDIA_DEVICE_H2425#include <linux/device.h>26#include <linux/list.h>27#include <linux/mutex.h>28#include <linux/spinlock.h>2930#include <media/media-devnode.h>31#include <media/media-entity.h>3233/**34* struct media_device - Media device35* @dev: Parent device36* @devnode: Media device node37* @model: Device model name38* @serial: Device serial number (optional)39* @bus_info: Unique and stable device location identifier40* @hw_revision: Hardware device revision41* @driver_version: Device driver version42* @entity_id: ID of the next entity to be registered43* @entities: List of registered entities44* @lock: Entities list lock45* @graph_mutex: Entities graph operation lock46*47* This structure represents an abstract high-level media device. It allows easy48* access to entities and provides basic media device-level support. The49* structure can be allocated directly or embedded in a larger structure.50*51* The parent @dev is a physical device. It must be set before registering the52* media device.53*54* @model is a descriptive model name exported through sysfs. It doesn't have to55* be unique.56*/57struct media_device {58/* dev->driver_data points to this struct. */59struct device *dev;60struct media_devnode devnode;6162char model[32];63char serial[40];64char bus_info[32];65u32 hw_revision;66u32 driver_version;6768u32 entity_id;69struct list_head entities;7071/* Protects the entities list */72spinlock_t lock;73/* Serializes graph operations. */74struct mutex graph_mutex;7576int (*link_notify)(struct media_pad *source,77struct media_pad *sink, u32 flags);78};7980/* media_devnode to media_device */81#define to_media_device(node) container_of(node, struct media_device, devnode)8283int __must_check media_device_register(struct media_device *mdev);84void media_device_unregister(struct media_device *mdev);8586int __must_check media_device_register_entity(struct media_device *mdev,87struct media_entity *entity);88void media_device_unregister_entity(struct media_entity *entity);8990/* Iterate over all entities. */91#define media_device_for_each_entity(entity, mdev) \92list_for_each_entry(entity, &(mdev)->entities, list)9394#endif959697