diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-08-20 08:07:34 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-01-11 09:18:44 -0500 |
commit | 27e543fa87deea308f0cc5224ab19e397b0a5ded (patch) | |
tree | 08663a0ad6f7dcedaed61874aeb7f661c108bc3f /drivers/media/media-entity.c | |
parent | a1d2510ebd7a14f0d1a89c138101beaeac076dd2 (diff) |
[media] media: add functions to allow creating interfaces
Interfaces are different than entities: they represent a
Kernel<->userspace interaction, while entities represent a
piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to
store the interfaces.
Later patches should change the existing drivers and logic
to split the current interface embedded inside the entity
structure (device nodes) into a separate object of the graph.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-entity.c')
-rw-r--r-- | drivers/media/media-entity.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 6ed4a19b0be9..160ce2cc0865 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c | |||
@@ -44,11 +44,41 @@ static inline const char *gobj_type(enum media_gobj_type type) | |||
44 | return "pad"; | 44 | return "pad"; |
45 | case MEDIA_GRAPH_LINK: | 45 | case MEDIA_GRAPH_LINK: |
46 | return "link"; | 46 | return "link"; |
47 | case MEDIA_GRAPH_INTF_DEVNODE: | ||
48 | return "intf-devnode"; | ||
47 | default: | 49 | default: |
48 | return "unknown"; | 50 | return "unknown"; |
49 | } | 51 | } |
50 | } | 52 | } |
51 | 53 | ||
54 | static inline const char *intf_type(struct media_interface *intf) | ||
55 | { | ||
56 | switch (intf->type) { | ||
57 | case MEDIA_INTF_T_DVB_FE: | ||
58 | return "frontend"; | ||
59 | case MEDIA_INTF_T_DVB_DEMUX: | ||
60 | return "demux"; | ||
61 | case MEDIA_INTF_T_DVB_DVR: | ||
62 | return "DVR"; | ||
63 | case MEDIA_INTF_T_DVB_CA: | ||
64 | return "CA"; | ||
65 | case MEDIA_INTF_T_DVB_NET: | ||
66 | return "dvbnet"; | ||
67 | case MEDIA_INTF_T_V4L_VIDEO: | ||
68 | return "video"; | ||
69 | case MEDIA_INTF_T_V4L_VBI: | ||
70 | return "vbi"; | ||
71 | case MEDIA_INTF_T_V4L_RADIO: | ||
72 | return "radio"; | ||
73 | case MEDIA_INTF_T_V4L_SUBDEV: | ||
74 | return "v4l2-subdev"; | ||
75 | case MEDIA_INTF_T_V4L_SWRADIO: | ||
76 | return "swradio"; | ||
77 | default: | ||
78 | return "unknown-intf"; | ||
79 | } | ||
80 | }; | ||
81 | |||
52 | static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) | 82 | static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) |
53 | { | 83 | { |
54 | #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) | 84 | #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) |
@@ -84,6 +114,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) | |||
84 | "%s: id 0x%08x pad#%d: '%s':%d\n", | 114 | "%s: id 0x%08x pad#%d: '%s':%d\n", |
85 | event_name, gobj->id, media_localid(gobj), | 115 | event_name, gobj->id, media_localid(gobj), |
86 | pad->entity->name, pad->index); | 116 | pad->entity->name, pad->index); |
117 | break; | ||
118 | } | ||
119 | case MEDIA_GRAPH_INTF_DEVNODE: | ||
120 | { | ||
121 | struct media_interface *intf = gobj_to_intf(gobj); | ||
122 | struct media_intf_devnode *devnode = intf_to_devnode(intf); | ||
123 | |||
124 | dev_dbg(gobj->mdev->dev, | ||
125 | "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n", | ||
126 | event_name, gobj->id, media_localid(gobj), | ||
127 | intf_type(intf), | ||
128 | devnode->major, devnode->minor); | ||
129 | break; | ||
87 | } | 130 | } |
88 | } | 131 | } |
89 | #endif | 132 | #endif |
@@ -119,6 +162,9 @@ void media_gobj_init(struct media_device *mdev, | |||
119 | case MEDIA_GRAPH_LINK: | 162 | case MEDIA_GRAPH_LINK: |
120 | gobj->id = media_gobj_gen_id(type, ++mdev->link_id); | 163 | gobj->id = media_gobj_gen_id(type, ++mdev->link_id); |
121 | break; | 164 | break; |
165 | case MEDIA_GRAPH_INTF_DEVNODE: | ||
166 | gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); | ||
167 | break; | ||
122 | } | 168 | } |
123 | dev_dbg_obj(__func__, gobj); | 169 | dev_dbg_obj(__func__, gobj); |
124 | } | 170 | } |
@@ -793,3 +839,40 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) | |||
793 | 839 | ||
794 | } | 840 | } |
795 | EXPORT_SYMBOL_GPL(media_entity_remote_pad); | 841 | EXPORT_SYMBOL_GPL(media_entity_remote_pad); |
842 | |||
843 | |||
844 | /* Functions related to the media interface via device nodes */ | ||
845 | |||
846 | struct media_intf_devnode *media_devnode_create(struct media_device *mdev, | ||
847 | u32 type, u32 flags, | ||
848 | u32 major, u32 minor, | ||
849 | gfp_t gfp_flags) | ||
850 | { | ||
851 | struct media_intf_devnode *devnode; | ||
852 | struct media_interface *intf; | ||
853 | |||
854 | devnode = kzalloc(sizeof(*devnode), gfp_flags); | ||
855 | if (!devnode) | ||
856 | return NULL; | ||
857 | |||
858 | intf = &devnode->intf; | ||
859 | |||
860 | intf->type = type; | ||
861 | intf->flags = flags; | ||
862 | |||
863 | devnode->major = major; | ||
864 | devnode->minor = minor; | ||
865 | |||
866 | media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE, | ||
867 | &devnode->intf.graph_obj); | ||
868 | |||
869 | return devnode; | ||
870 | } | ||
871 | EXPORT_SYMBOL_GPL(media_devnode_create); | ||
872 | |||
873 | void media_devnode_remove(struct media_intf_devnode *devnode) | ||
874 | { | ||
875 | media_gobj_remove(&devnode->intf.graph_obj); | ||
876 | kfree(devnode); | ||
877 | } | ||
878 | EXPORT_SYMBOL_GPL(media_devnode_remove); | ||