aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/media-device.h19
-rw-r--r--include/media/media-entity.h122
2 files changed, 141 insertions, 0 deletions
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 30857f7fc22..a8390fe87e8 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -25,8 +25,10 @@
25 25
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/spinlock.h>
28 29
29#include <media/media-devnode.h> 30#include <media/media-devnode.h>
31#include <media/media-entity.h>
30 32
31/** 33/**
32 * struct media_device - Media device 34 * struct media_device - Media device
@@ -37,6 +39,9 @@
37 * @bus_info: Unique and stable device location identifier 39 * @bus_info: Unique and stable device location identifier
38 * @hw_revision: Hardware device revision 40 * @hw_revision: Hardware device revision
39 * @driver_version: Device driver version 41 * @driver_version: Device driver version
42 * @entity_id: ID of the next entity to be registered
43 * @entities: List of registered entities
44 * @lock: Entities list lock
40 * 45 *
41 * This structure represents an abstract high-level media device. It allows easy 46 * This structure represents an abstract high-level media device. It allows easy
42 * access to entities and provides basic media device-level support. The 47 * access to entities and provides basic media device-level support. The
@@ -58,6 +63,12 @@ struct media_device {
58 char bus_info[32]; 63 char bus_info[32];
59 u32 hw_revision; 64 u32 hw_revision;
60 u32 driver_version; 65 u32 driver_version;
66
67 u32 entity_id;
68 struct list_head entities;
69
70 /* Protects the entities list */
71 spinlock_t lock;
61}; 72};
62 73
63/* media_devnode to media_device */ 74/* media_devnode to media_device */
@@ -66,4 +77,12 @@ struct media_device {
66int __must_check media_device_register(struct media_device *mdev); 77int __must_check media_device_register(struct media_device *mdev);
67void media_device_unregister(struct media_device *mdev); 78void media_device_unregister(struct media_device *mdev);
68 79
80int __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
69#endif 88#endif
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
new file mode 100644
index 00000000000..f6c856c9ac1
--- /dev/null
+++ b/include/media/media-entity.h
@@ -0,0 +1,122 @@
1/*
2 * Media entity
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_ENTITY_H
24#define _MEDIA_ENTITY_H
25
26#include <linux/list.h>
27
28#define MEDIA_ENT_TYPE_SHIFT 16
29#define MEDIA_ENT_TYPE_MASK 0x00ff0000
30#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
31
32#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT)
33#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1)
34#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
35#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
36#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
37
38#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT)
39#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
40#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
41#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
42
43#define MEDIA_ENT_FL_DEFAULT (1 << 0)
44
45#define MEDIA_LNK_FL_ENABLED (1 << 0)
46#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
47
48#define MEDIA_PAD_FL_SINK (1 << 0)
49#define MEDIA_PAD_FL_SOURCE (1 << 1)
50
51struct media_link {
52 struct media_pad *source; /* Source pad */
53 struct media_pad *sink; /* Sink pad */
54 struct media_link *reverse; /* Link in the reverse direction */
55 unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */
56};
57
58struct media_pad {
59 struct media_entity *entity; /* Entity this pad belongs to */
60 u16 index; /* Pad index in the entity pads array */
61 unsigned long flags; /* Pad flags (MEDIA_PAD_FL_*) */
62};
63
64struct media_entity {
65 struct list_head list;
66 struct media_device *parent; /* Media device this entity belongs to*/
67 u32 id; /* Entity ID, unique in the parent media
68 * device context */
69 const char *name; /* Entity name */
70 u32 type; /* Entity type (MEDIA_ENT_T_*) */
71 u32 revision; /* Entity revision, driver specific */
72 unsigned long flags; /* Entity flags (MEDIA_ENT_FL_*) */
73 u32 group_id; /* Entity group ID */
74
75 u16 num_pads; /* Number of sink and source pads */
76 u16 num_links; /* Number of existing links, both
77 * enabled and disabled */
78 u16 num_backlinks; /* Number of backlinks */
79 u16 max_links; /* Maximum number of links */
80
81 struct media_pad *pads; /* Pads array (num_pads elements) */
82 struct media_link *links; /* Links array (max_links elements)*/
83
84 union {
85 /* Node specifications */
86 struct {
87 u32 major;
88 u32 minor;
89 } v4l;
90 struct {
91 u32 major;
92 u32 minor;
93 } fb;
94 struct {
95 u32 card;
96 u32 device;
97 u32 subdevice;
98 } alsa;
99 int dvb;
100
101 /* Sub-device specifications */
102 /* Nothing needed yet */
103 };
104};
105
106static inline u32 media_entity_type(struct media_entity *entity)
107{
108 return entity->type & MEDIA_ENT_TYPE_MASK;
109}
110
111static inline u32 media_entity_subtype(struct media_entity *entity)
112{
113 return entity->type & MEDIA_ENT_SUBTYPE_MASK;
114}
115
116int media_entity_init(struct media_entity *entity, u16 num_pads,
117 struct media_pad *pads, u16 extra_links);
118void media_entity_cleanup(struct media_entity *entity);
119int media_entity_create_link(struct media_entity *source, u16 source_pad,
120 struct media_entity *sink, u16 sink_pad, u32 flags);
121
122#endif