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.c | |
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.c')
-rw-r--r-- | drivers/media/platform/vimc/vimc-common.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/media/platform/vimc/vimc-common.c b/drivers/media/platform/vimc/vimc-common.c index b69805574c67..da7f2b7a2e58 100644 --- a/drivers/media/platform/vimc/vimc-common.c +++ b/drivers/media/platform/vimc/vimc-common.c | |||
@@ -15,6 +15,9 @@ | |||
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/module.h> | ||
20 | |||
18 | #include "vimc-common.h" | 21 | #include "vimc-common.h" |
19 | 22 | ||
20 | static const struct vimc_pix_map vimc_pix_map_list[] = { | 23 | static const struct vimc_pix_map vimc_pix_map_list[] = { |
@@ -151,6 +154,7 @@ const struct vimc_pix_map *vimc_pix_map_by_index(unsigned int i) | |||
151 | 154 | ||
152 | return &vimc_pix_map_list[i]; | 155 | return &vimc_pix_map_list[i]; |
153 | } | 156 | } |
157 | EXPORT_SYMBOL_GPL(vimc_pix_map_by_index); | ||
154 | 158 | ||
155 | const struct vimc_pix_map *vimc_pix_map_by_code(u32 code) | 159 | const struct vimc_pix_map *vimc_pix_map_by_code(u32 code) |
156 | { | 160 | { |
@@ -162,6 +166,7 @@ const struct vimc_pix_map *vimc_pix_map_by_code(u32 code) | |||
162 | } | 166 | } |
163 | return NULL; | 167 | return NULL; |
164 | } | 168 | } |
169 | EXPORT_SYMBOL_GPL(vimc_pix_map_by_code); | ||
165 | 170 | ||
166 | const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat) | 171 | const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat) |
167 | { | 172 | { |
@@ -173,6 +178,7 @@ const struct vimc_pix_map *vimc_pix_map_by_pixelformat(u32 pixelformat) | |||
173 | } | 178 | } |
174 | return NULL; | 179 | return NULL; |
175 | } | 180 | } |
181 | EXPORT_SYMBOL_GPL(vimc_pix_map_by_pixelformat); | ||
176 | 182 | ||
177 | int vimc_propagate_frame(struct media_pad *src, const void *frame) | 183 | int vimc_propagate_frame(struct media_pad *src, const void *frame) |
178 | { | 184 | { |
@@ -207,6 +213,7 @@ int vimc_propagate_frame(struct media_pad *src, const void *frame) | |||
207 | 213 | ||
208 | return 0; | 214 | return 0; |
209 | } | 215 | } |
216 | EXPORT_SYMBOL_GPL(vimc_propagate_frame); | ||
210 | 217 | ||
211 | /* Helper function to allocate and initialize pads */ | 218 | /* Helper function to allocate and initialize pads */ |
212 | struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag) | 219 | struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag) |
@@ -227,6 +234,7 @@ struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag) | |||
227 | 234 | ||
228 | return pads; | 235 | return pads; |
229 | } | 236 | } |
237 | EXPORT_SYMBOL_GPL(vimc_pads_init); | ||
230 | 238 | ||
231 | int vimc_pipeline_s_stream(struct media_entity *ent, int enable) | 239 | int vimc_pipeline_s_stream(struct media_entity *ent, int enable) |
232 | { | 240 | { |
@@ -242,14 +250,8 @@ int vimc_pipeline_s_stream(struct media_entity *ent, int enable) | |||
242 | /* Start the stream in the subdevice direct connected */ | 250 | /* Start the stream in the subdevice direct connected */ |
243 | pad = media_entity_remote_pad(&ent->pads[i]); | 251 | pad = media_entity_remote_pad(&ent->pads[i]); |
244 | 252 | ||
245 | /* | 253 | if (!is_media_entity_v4l2_subdev(pad->entity)) |
246 | * if this is a raw node from vimc-core, then there is | 254 | return -EINVAL; |
247 | * nothing to activate | ||
248 | * TODO: remove this when there are no more raw nodes in the | ||
249 | * core and return error instead | ||
250 | */ | ||
251 | if (pad->entity->obj_type == MEDIA_ENTITY_TYPE_BASE) | ||
252 | continue; | ||
253 | 255 | ||
254 | sd = media_entity_to_v4l2_subdev(pad->entity); | 256 | sd = media_entity_to_v4l2_subdev(pad->entity); |
255 | ret = v4l2_subdev_call(sd, video, s_stream, enable); | 257 | ret = v4l2_subdev_call(sd, video, s_stream, enable); |
@@ -259,6 +261,7 @@ int vimc_pipeline_s_stream(struct media_entity *ent, int enable) | |||
259 | 261 | ||
260 | return 0; | 262 | return 0; |
261 | } | 263 | } |
264 | EXPORT_SYMBOL_GPL(vimc_pipeline_s_stream); | ||
262 | 265 | ||
263 | static int vimc_get_mbus_format(struct media_pad *pad, | 266 | static int vimc_get_mbus_format(struct media_pad *pad, |
264 | struct v4l2_subdev_format *fmt) | 267 | struct v4l2_subdev_format *fmt) |
@@ -301,14 +304,6 @@ int vimc_link_validate(struct media_link *link) | |||
301 | struct v4l2_subdev_format source_fmt, sink_fmt; | 304 | struct v4l2_subdev_format source_fmt, sink_fmt; |
302 | int ret; | 305 | int ret; |
303 | 306 | ||
304 | /* | ||
305 | * if it is a raw node from vimc-core, ignore the link for now | ||
306 | * TODO: remove this when there are no more raw nodes in the | ||
307 | * core and return error instead | ||
308 | */ | ||
309 | if (link->source->entity->obj_type == MEDIA_ENTITY_TYPE_BASE) | ||
310 | return 0; | ||
311 | |||
312 | ret = vimc_get_mbus_format(link->source, &source_fmt); | 307 | ret = vimc_get_mbus_format(link->source, &source_fmt); |
313 | if (ret) | 308 | if (ret) |
314 | return ret; | 309 | return ret; |
@@ -378,6 +373,7 @@ int vimc_link_validate(struct media_link *link) | |||
378 | 373 | ||
379 | return 0; | 374 | return 0; |
380 | } | 375 | } |
376 | EXPORT_SYMBOL_GPL(vimc_link_validate); | ||
381 | 377 | ||
382 | static const struct media_entity_operations vimc_ent_sd_mops = { | 378 | static const struct media_entity_operations vimc_ent_sd_mops = { |
383 | .link_validate = vimc_link_validate, | 379 | .link_validate = vimc_link_validate, |
@@ -390,8 +386,7 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved, | |||
390 | u32 function, | 386 | u32 function, |
391 | u16 num_pads, | 387 | u16 num_pads, |
392 | const unsigned long *pads_flag, | 388 | const unsigned long *pads_flag, |
393 | const struct v4l2_subdev_ops *sd_ops, | 389 | const struct v4l2_subdev_ops *sd_ops) |
394 | void (*sd_destroy)(struct vimc_ent_device *)) | ||
395 | { | 390 | { |
396 | int ret; | 391 | int ret; |
397 | 392 | ||
@@ -401,7 +396,6 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved, | |||
401 | return PTR_ERR(ved->pads); | 396 | return PTR_ERR(ved->pads); |
402 | 397 | ||
403 | /* Fill the vimc_ent_device struct */ | 398 | /* Fill the vimc_ent_device struct */ |
404 | ved->destroy = sd_destroy; | ||
405 | ved->ent = &sd->entity; | 399 | ved->ent = &sd->entity; |
406 | 400 | ||
407 | /* Initialize the subdev */ | 401 | /* Initialize the subdev */ |
@@ -437,6 +431,7 @@ err_clean_pads: | |||
437 | vimc_pads_cleanup(ved->pads); | 431 | vimc_pads_cleanup(ved->pads); |
438 | return ret; | 432 | return ret; |
439 | } | 433 | } |
434 | EXPORT_SYMBOL_GPL(vimc_ent_sd_register); | ||
440 | 435 | ||
441 | void vimc_ent_sd_unregister(struct vimc_ent_device *ved, struct v4l2_subdev *sd) | 436 | void vimc_ent_sd_unregister(struct vimc_ent_device *ved, struct v4l2_subdev *sd) |
442 | { | 437 | { |
@@ -444,3 +439,8 @@ void vimc_ent_sd_unregister(struct vimc_ent_device *ved, struct v4l2_subdev *sd) | |||
444 | media_entity_cleanup(ved->ent); | 439 | media_entity_cleanup(ved->ent); |
445 | vimc_pads_cleanup(ved->pads); | 440 | vimc_pads_cleanup(ved->pads); |
446 | } | 441 | } |
442 | EXPORT_SYMBOL_GPL(vimc_ent_sd_unregister); | ||
443 | |||
444 | MODULE_DESCRIPTION("Virtual Media Controller Driver (VIMC) Common"); | ||
445 | MODULE_AUTHOR("Helen Koike <helen.fornazier@gmail.com>"); | ||
446 | MODULE_LICENSE("GPL"); | ||