diff options
author | Helen Fornazier <helen.koike@collabora.com> | 2017-06-19 13:00:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-06-23 08:12:07 -0400 |
commit | 4a29b70907496aa9da79112ec31cf9cf2b972c3f (patch) | |
tree | 9be42df7b467e369899f96e2e4d2e25869bf42f8 /drivers/media/platform/vimc/vimc-common.h | |
parent | 535d296f4841ffbd7f773ff2a559daa6e117f315 (diff) |
[media] vimc: Subdevices as modules
Change the core structure for adding subdevices in the topology.
Instead of calling the specific create function for each subdevice,
inject a child platform_device with the driver's name.
Each type of node in the topology (sensor, capture, debayer, scaler)
will register a platform_driver with the corresponding name through the
component subsystem.
Implementing a new subdevice type doesn't require vimc-core to be altered.
This facilitates future implementation of dynamic entities, where
hotpluging an entity in the topology is just a matter of
registering/unregistering a platform_device in the system.
It also facilitates other implementations of different nodes without
touching the core code and remove the need of a header file for each
type of node.
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/vimc/vimc-common.h')
-rw-r--r-- | drivers/media/platform/vimc/vimc-common.h | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/media/platform/vimc/vimc-common.h b/drivers/media/platform/vimc/vimc-common.h index fb3463c06185..a9c1cfdc0dff 100644 --- a/drivers/media/platform/vimc/vimc-common.h +++ b/drivers/media/platform/vimc/vimc-common.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * vimc-ccommon.h Virtual Media Controller Driver | 2 | * vimc-common.h Virtual Media Controller Driver |
3 | * | 3 | * |
4 | * Copyright (C) 2015-2017 Helen Koike <helen.fornazier@gmail.com> | 4 | * Copyright (C) 2015-2017 Helen Koike <helen.fornazier@gmail.com> |
5 | * | 5 | * |
@@ -54,6 +54,21 @@ do { \ | |||
54 | } while (0) | 54 | } while (0) |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * struct vimc_platform_data - platform data to components | ||
58 | * | ||
59 | * @entity_name: The name of the entity to be created | ||
60 | * | ||
61 | * Board setup code will often provide additional information using the device's | ||
62 | * platform_data field to hold additional information. | ||
63 | * When injecting a new platform_device in the component system the core needs | ||
64 | * to provide to the corresponding submodules the name of the entity that should | ||
65 | * be used when registering the subdevice in the Media Controller system. | ||
66 | */ | ||
67 | struct vimc_platform_data { | ||
68 | char entity_name[32]; | ||
69 | }; | ||
70 | |||
71 | /** | ||
57 | * struct vimc_pix_map - maps media bus code with v4l2 pixel format | 72 | * struct vimc_pix_map - maps media bus code with v4l2 pixel format |
58 | * | 73 | * |
59 | * @code: media bus format code defined by MEDIA_BUS_FMT_* macros | 74 | * @code: media bus format code defined by MEDIA_BUS_FMT_* macros |
@@ -74,7 +89,6 @@ struct vimc_pix_map { | |||
74 | * | 89 | * |
75 | * @ent: the pointer to struct media_entity for the node | 90 | * @ent: the pointer to struct media_entity for the node |
76 | * @pads: the list of pads of the node | 91 | * @pads: the list of pads of the node |
77 | * @destroy: callback to destroy the node | ||
78 | * @process_frame: callback send a frame to that node | 92 | * @process_frame: callback send a frame to that node |
79 | * @vdev_get_format: callback that returns the current format a pad, used | 93 | * @vdev_get_format: callback that returns the current format a pad, used |
80 | * only when is_media_entity_v4l2_video_device(ent) returns | 94 | * only when is_media_entity_v4l2_video_device(ent) returns |
@@ -91,7 +105,6 @@ struct vimc_pix_map { | |||
91 | struct vimc_ent_device { | 105 | struct vimc_ent_device { |
92 | struct media_entity *ent; | 106 | struct media_entity *ent; |
93 | struct media_pad *pads; | 107 | struct media_pad *pads; |
94 | void (*destroy)(struct vimc_ent_device *); | ||
95 | void (*process_frame)(struct vimc_ent_device *ved, | 108 | void (*process_frame)(struct vimc_ent_device *ved, |
96 | struct media_pad *sink, const void *frame); | 109 | struct media_pad *sink, const void *frame); |
97 | void (*vdev_get_format)(struct vimc_ent_device *ved, | 110 | void (*vdev_get_format)(struct vimc_ent_device *ved, |
@@ -176,7 +189,6 @@ const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat); | |||
176 | * @num_pads: number of pads to initialize | 189 | * @num_pads: number of pads to initialize |
177 | * @pads_flag: flags to use in each pad | 190 | * @pads_flag: flags to use in each pad |
178 | * @sd_ops: pointer to &struct v4l2_subdev_ops. | 191 | * @sd_ops: pointer to &struct v4l2_subdev_ops. |
179 | * @sd_destroy: callback to destroy the node | ||
180 | * | 192 | * |
181 | * Helper function initialize and register the struct vimc_ent_device and struct | 193 | * Helper function initialize and register the struct vimc_ent_device and struct |
182 | * v4l2_subdev which represents a subdev node in the topology | 194 | * v4l2_subdev which represents a subdev node in the topology |
@@ -188,14 +200,13 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved, | |||
188 | u32 function, | 200 | u32 function, |
189 | u16 num_pads, | 201 | u16 num_pads, |
190 | const unsigned long *pads_flag, | 202 | const unsigned long *pads_flag, |
191 | const struct v4l2_subdev_ops *sd_ops, | 203 | const struct v4l2_subdev_ops *sd_ops); |
192 | void (*sd_destroy)(struct vimc_ent_device *)); | ||
193 | 204 | ||
194 | /** | 205 | /** |
195 | * vimc_ent_sd_register - initialize and register a subdev node | 206 | * vimc_ent_sd_unregister - cleanup and unregister a subdev node |
196 | * | 207 | * |
197 | * @ved: the vimc_ent_device struct to be initialize | 208 | * @ved: the vimc_ent_device struct to be cleaned up |
198 | * @sd: the v4l2_subdev struct to be initialize and registered | 209 | * @sd: the v4l2_subdev struct to be unregistered |
199 | * | 210 | * |
200 | * Helper function cleanup and unregister the struct vimc_ent_device and struct | 211 | * Helper function cleanup and unregister the struct vimc_ent_device and struct |
201 | * v4l2_subdev which represents a subdev node in the topology | 212 | * v4l2_subdev which represents a subdev node in the topology |