2009-12-09 19:39:58 +08:00
|
|
|
/*
|
|
|
|
* Media device
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
|
|
* Sakari Ailus <sakari.ailus@iki.fi>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MEDIA_DEVICE_H
|
|
|
|
#define _MEDIA_DEVICE_H
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
2010-03-08 02:04:59 +08:00
|
|
|
#include <linux/mutex.h>
|
2009-12-09 19:40:00 +08:00
|
|
|
#include <linux/spinlock.h>
|
2009-12-09 19:39:58 +08:00
|
|
|
|
|
|
|
#include <media/media-devnode.h>
|
2009-12-09 19:40:00 +08:00
|
|
|
#include <media/media-entity.h>
|
2009-12-09 19:39:58 +08:00
|
|
|
|
2012-01-31 00:46:54 +08:00
|
|
|
struct device;
|
|
|
|
|
2009-12-09 19:39:58 +08:00
|
|
|
/**
|
|
|
|
* struct media_device - Media device
|
|
|
|
* @dev: Parent device
|
|
|
|
* @devnode: Media device node
|
|
|
|
* @model: Device model name
|
|
|
|
* @serial: Device serial number (optional)
|
|
|
|
* @bus_info: Unique and stable device location identifier
|
|
|
|
* @hw_revision: Hardware device revision
|
|
|
|
* @driver_version: Device driver version
|
2015-08-14 23:47:48 +08:00
|
|
|
* @entity_id: Unique ID used on the last entity registered
|
2015-08-14 23:50:08 +08:00
|
|
|
* @pad_id: Unique ID used on the last pad registered
|
2015-08-14 23:54:36 +08:00
|
|
|
* @link_id: Unique ID used on the last link registered
|
2015-08-20 20:07:34 +08:00
|
|
|
* @intf_devnode_id: Unique ID used on the last interface devnode registered
|
2009-12-09 19:40:00 +08:00
|
|
|
* @entities: List of registered entities
|
2015-08-21 20:23:22 +08:00
|
|
|
* @interfaces: List of registered interfaces
|
2015-08-23 19:00:33 +08:00
|
|
|
* @pads: List of registered pads
|
|
|
|
* @links: List of registered links
|
2009-12-09 19:40:00 +08:00
|
|
|
* @lock: Entities list lock
|
2010-03-08 02:04:59 +08:00
|
|
|
* @graph_mutex: Entities graph operation lock
|
2013-05-31 21:37:26 +08:00
|
|
|
* @link_notify: Link state change notification callback
|
2009-12-09 19:39:58 +08:00
|
|
|
*
|
|
|
|
* This structure represents an abstract high-level media device. It allows easy
|
|
|
|
* access to entities and provides basic media device-level support. The
|
|
|
|
* structure can be allocated directly or embedded in a larger structure.
|
|
|
|
*
|
|
|
|
* The parent @dev is a physical device. It must be set before registering the
|
|
|
|
* media device.
|
|
|
|
*
|
|
|
|
* @model is a descriptive model name exported through sysfs. It doesn't have to
|
|
|
|
* be unique.
|
|
|
|
*/
|
|
|
|
struct media_device {
|
|
|
|
/* dev->driver_data points to this struct. */
|
|
|
|
struct device *dev;
|
|
|
|
struct media_devnode devnode;
|
|
|
|
|
|
|
|
char model[32];
|
|
|
|
char serial[40];
|
|
|
|
char bus_info[32];
|
|
|
|
u32 hw_revision;
|
|
|
|
u32 driver_version;
|
2009-12-09 19:40:00 +08:00
|
|
|
|
|
|
|
u32 entity_id;
|
2015-08-14 23:50:08 +08:00
|
|
|
u32 pad_id;
|
2015-08-14 23:54:36 +08:00
|
|
|
u32 link_id;
|
2015-08-20 20:07:34 +08:00
|
|
|
u32 intf_devnode_id;
|
2015-08-14 23:47:48 +08:00
|
|
|
|
2009-12-09 19:40:00 +08:00
|
|
|
struct list_head entities;
|
2015-08-21 20:23:22 +08:00
|
|
|
struct list_head interfaces;
|
2015-08-23 19:00:33 +08:00
|
|
|
struct list_head pads;
|
|
|
|
struct list_head links;
|
2009-12-09 19:40:00 +08:00
|
|
|
|
|
|
|
/* Protects the entities list */
|
|
|
|
spinlock_t lock;
|
2010-03-08 02:04:59 +08:00
|
|
|
/* Serializes graph operations. */
|
|
|
|
struct mutex graph_mutex;
|
2009-12-09 19:40:03 +08:00
|
|
|
|
2013-05-31 21:37:26 +08:00
|
|
|
int (*link_notify)(struct media_link *link, u32 flags,
|
|
|
|
unsigned int notification);
|
2009-12-09 19:39:58 +08:00
|
|
|
};
|
|
|
|
|
2015-06-06 04:11:54 +08:00
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
|
2013-05-31 21:37:26 +08:00
|
|
|
/* Supported link_notify @notification values. */
|
|
|
|
#define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0
|
|
|
|
#define MEDIA_DEV_NOTIFY_POST_LINK_CH 1
|
|
|
|
|
2009-12-09 19:39:58 +08:00
|
|
|
/* media_devnode to media_device */
|
|
|
|
#define to_media_device(node) container_of(node, struct media_device, devnode)
|
|
|
|
|
2013-12-12 23:38:17 +08:00
|
|
|
int __must_check __media_device_register(struct media_device *mdev,
|
|
|
|
struct module *owner);
|
|
|
|
#define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
|
2009-12-09 19:39:58 +08:00
|
|
|
void media_device_unregister(struct media_device *mdev);
|
|
|
|
|
2009-12-09 19:40:00 +08:00
|
|
|
int __must_check media_device_register_entity(struct media_device *mdev,
|
|
|
|
struct media_entity *entity);
|
|
|
|
void media_device_unregister_entity(struct media_entity *entity);
|
2015-06-03 23:12:53 +08:00
|
|
|
struct media_device *media_device_get_devres(struct device *dev);
|
|
|
|
struct media_device *media_device_find_devres(struct device *dev);
|
2009-12-09 19:40:00 +08:00
|
|
|
|
|
|
|
/* Iterate over all entities. */
|
|
|
|
#define media_device_for_each_entity(entity, mdev) \
|
2015-08-23 18:51:33 +08:00
|
|
|
list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)
|
2009-12-09 19:40:00 +08:00
|
|
|
|
2015-08-23 18:51:22 +08:00
|
|
|
/* Iterate over all interfaces. */
|
|
|
|
#define media_device_for_each_intf(intf, mdev) \
|
2015-08-23 18:51:33 +08:00
|
|
|
list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)
|
2015-08-23 18:51:22 +08:00
|
|
|
|
2015-08-23 19:00:33 +08:00
|
|
|
/* Iterate over all pads. */
|
|
|
|
#define media_device_for_each_pad(pad, mdev) \
|
|
|
|
list_for_each_entry(pad, &(mdev)->pads, graph_obj.list)
|
|
|
|
|
|
|
|
/* Iterate over all links. */
|
|
|
|
#define media_device_for_each_link(link, mdev) \
|
|
|
|
list_for_each_entry(link, &(mdev)->links, graph_obj.list)
|
|
|
|
|
2015-08-23 18:51:22 +08:00
|
|
|
|
2015-06-06 04:11:54 +08:00
|
|
|
#else
|
|
|
|
static inline int media_device_register(struct media_device *mdev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void media_device_unregister(struct media_device *mdev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline int media_device_register_entity(struct media_device *mdev,
|
|
|
|
struct media_entity *entity)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void media_device_unregister_entity(struct media_entity *entity)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline struct media_device *media_device_get_devres(struct device *dev)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
static inline struct media_device *media_device_find_devres(struct device *dev)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_MEDIA_CONTROLLER */
|
2009-12-09 19:39:58 +08:00
|
|
|
#endif
|