blob: a8390fe87e83fcd4ce59c61d0c7222717b8b531c [file] [log] [blame]
Laurent Pinchart176fb0d2009-12-09 08:39:58 -03001/*
2 * Media device
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
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.
12 *
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.
17 *
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
21 */
22
23#ifndef _MEDIA_DEVICE_H
24#define _MEDIA_DEVICE_H
25
26#include <linux/device.h>
27#include <linux/list.h>
Laurent Pinchart53e269c2009-12-09 08:40:00 -030028#include <linux/spinlock.h>
Laurent Pinchart176fb0d2009-12-09 08:39:58 -030029
30#include <media/media-devnode.h>
Laurent Pinchart53e269c2009-12-09 08:40:00 -030031#include <media/media-entity.h>
Laurent Pinchart176fb0d2009-12-09 08:39:58 -030032
33/**
34 * struct media_device - Media device
35 * @dev: Parent device
36 * @devnode: Media device node
37 * @model: Device model name
38 * @serial: Device serial number (optional)
39 * @bus_info: Unique and stable device location identifier
40 * @hw_revision: Hardware device revision
41 * @driver_version: Device driver version
Laurent Pinchart53e269c2009-12-09 08:40:00 -030042 * @entity_id: ID of the next entity to be registered
43 * @entities: List of registered entities
44 * @lock: Entities list lock
Laurent Pinchart176fb0d2009-12-09 08:39:58 -030045 *
46 * This structure represents an abstract high-level media device. It allows easy
47 * access to entities and provides basic media device-level support. The
48 * structure can be allocated directly or embedded in a larger structure.
49 *
50 * The parent @dev is a physical device. It must be set before registering the
51 * media device.
52 *
53 * @model is a descriptive model name exported through sysfs. It doesn't have to
54 * be unique.
55 */
56struct media_device {
57 /* dev->driver_data points to this struct. */
58 struct device *dev;
59 struct media_devnode devnode;
60
61 char model[32];
62 char serial[40];
63 char bus_info[32];
64 u32 hw_revision;
65 u32 driver_version;
Laurent Pinchart53e269c2009-12-09 08:40:00 -030066
67 u32 entity_id;
68 struct list_head entities;
69
70 /* Protects the entities list */
71 spinlock_t lock;
Laurent Pinchart176fb0d2009-12-09 08:39:58 -030072};
73
74/* media_devnode to media_device */
75#define to_media_device(node) container_of(node, struct media_device, devnode)
76
77int __must_check media_device_register(struct media_device *mdev);
78void media_device_unregister(struct media_device *mdev);
79
Laurent Pinchart53e269c2009-12-09 08:40:00 -030080int __must_check media_device_register_entity(struct media_device *mdev,
81 struct media_entity *entity);
82void media_device_unregister_entity(struct media_entity *entity);
83
84/* Iterate over all entities. */
85#define media_device_for_each_entity(entity, mdev) \
86 list_for_each_entry(entity, &(mdev)->entities, list)
87
Laurent Pinchart176fb0d2009-12-09 08:39:58 -030088#endif