Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: v4l2-dev: Add videodev wrappers for media pipelines

With the upcoming stream related improvements to the pipelines, the
pipelines are moved from media entities to media pads. As the drivers
currently use the pipelines with the entity based model, moving the
pipelines to pads will cause changes to the drivers.

However, most of the uses of media pipelines are related to a video
device (a DMA engine) with a single pad, and thus there's never a need
to support multiple pads in these use cases. We can avoid pushing the
complexities of the pad based model to the drivers by adding video
device wrappers for the pipeline related functions.

This patch adds a number of wrappers to media_pipeline functions, all of
which take a video_device as a parameter (instead of a media_entity),
and verify that there's just one pad.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Tomi Valkeinen and committed by
Mauro Carvalho Chehab
340eba47 72b60335

+149
+61
drivers/media/v4l2-core/v4l2-dev.c
··· 1095 1095 } 1096 1096 EXPORT_SYMBOL(video_unregister_device); 1097 1097 1098 + #if defined(CONFIG_MEDIA_CONTROLLER) 1099 + 1100 + __must_check int video_device_pipeline_start(struct video_device *vdev, 1101 + struct media_pipeline *pipe) 1102 + { 1103 + struct media_entity *entity = &vdev->entity; 1104 + 1105 + if (entity->num_pads != 1) 1106 + return -ENODEV; 1107 + 1108 + return media_pipeline_start(entity, pipe); 1109 + } 1110 + EXPORT_SYMBOL_GPL(video_device_pipeline_start); 1111 + 1112 + __must_check int __video_device_pipeline_start(struct video_device *vdev, 1113 + struct media_pipeline *pipe) 1114 + { 1115 + struct media_entity *entity = &vdev->entity; 1116 + 1117 + if (entity->num_pads != 1) 1118 + return -ENODEV; 1119 + 1120 + return __media_pipeline_start(entity, pipe); 1121 + } 1122 + EXPORT_SYMBOL_GPL(__video_device_pipeline_start); 1123 + 1124 + void video_device_pipeline_stop(struct video_device *vdev) 1125 + { 1126 + struct media_entity *entity = &vdev->entity; 1127 + 1128 + if (WARN_ON(entity->num_pads != 1)) 1129 + return; 1130 + 1131 + return media_pipeline_stop(entity); 1132 + } 1133 + EXPORT_SYMBOL_GPL(video_device_pipeline_stop); 1134 + 1135 + void __video_device_pipeline_stop(struct video_device *vdev) 1136 + { 1137 + struct media_entity *entity = &vdev->entity; 1138 + 1139 + if (WARN_ON(entity->num_pads != 1)) 1140 + return; 1141 + 1142 + return __media_pipeline_stop(entity); 1143 + } 1144 + EXPORT_SYMBOL_GPL(__video_device_pipeline_stop); 1145 + 1146 + struct media_pipeline *video_device_pipeline(struct video_device *vdev) 1147 + { 1148 + struct media_entity *entity = &vdev->entity; 1149 + 1150 + if (WARN_ON(entity->num_pads != 1)) 1151 + return NULL; 1152 + 1153 + return media_entity_pipeline(entity); 1154 + } 1155 + EXPORT_SYMBOL_GPL(video_device_pipeline); 1156 + 1157 + #endif /* CONFIG_MEDIA_CONTROLLER */ 1158 + 1098 1159 /* 1099 1160 * Initialise video for linux 1100 1161 */
+88
include/media/v4l2-dev.h
··· 539 539 return test_bit(V4L2_FL_REGISTERED, &vdev->flags); 540 540 } 541 541 542 + #if defined(CONFIG_MEDIA_CONTROLLER) 543 + 544 + /** 545 + * video_device_pipeline_start - Mark a pipeline as streaming 546 + * @vdev: Starting video device 547 + * @pipe: Media pipeline to be assigned to all entities in the pipeline. 548 + * 549 + * Mark all entities connected to a given video device through enabled links, 550 + * either directly or indirectly, as streaming. The given pipeline object is 551 + * assigned to every entity in the pipeline and stored in the media_entity pipe 552 + * field. 553 + * 554 + * Calls to this function can be nested, in which case the same number of 555 + * video_device_pipeline_stop() calls will be required to stop streaming. The 556 + * pipeline pointer must be identical for all nested calls to 557 + * video_device_pipeline_start(). 558 + * 559 + * The video device must contain a single pad. 560 + * 561 + * This is a convenience wrapper around media_pipeline_start(). 562 + */ 563 + __must_check int video_device_pipeline_start(struct video_device *vdev, 564 + struct media_pipeline *pipe); 565 + 566 + /** 567 + * __video_device_pipeline_start - Mark a pipeline as streaming 568 + * @vdev: Starting video device 569 + * @pipe: Media pipeline to be assigned to all entities in the pipeline. 570 + * 571 + * ..note:: This is the non-locking version of video_device_pipeline_start() 572 + * 573 + * The video device must contain a single pad. 574 + * 575 + * This is a convenience wrapper around __media_pipeline_start(). 576 + */ 577 + __must_check int __video_device_pipeline_start(struct video_device *vdev, 578 + struct media_pipeline *pipe); 579 + 580 + /** 581 + * video_device_pipeline_stop - Mark a pipeline as not streaming 582 + * @vdev: Starting video device 583 + * 584 + * Mark all entities connected to a given video device through enabled links, 585 + * either directly or indirectly, as not streaming. The media_entity pipe field 586 + * is reset to %NULL. 587 + * 588 + * If multiple calls to media_pipeline_start() have been made, the same 589 + * number of calls to this function are required to mark the pipeline as not 590 + * streaming. 591 + * 592 + * The video device must contain a single pad. 593 + * 594 + * This is a convenience wrapper around media_pipeline_stop(). 595 + */ 596 + void video_device_pipeline_stop(struct video_device *vdev); 597 + 598 + /** 599 + * __video_device_pipeline_stop - Mark a pipeline as not streaming 600 + * @vdev: Starting video device 601 + * 602 + * .. note:: This is the non-locking version of media_pipeline_stop() 603 + * 604 + * The video device must contain a single pad. 605 + * 606 + * This is a convenience wrapper around __media_pipeline_stop(). 607 + */ 608 + void __video_device_pipeline_stop(struct video_device *vdev); 609 + 610 + /** 611 + * video_device_pipeline - Get the media pipeline a video device is part of 612 + * @vdev: The video device 613 + * 614 + * This function returns the media pipeline that a video device has been 615 + * associated with when constructing the pipeline with 616 + * video_device_pipeline_start(). The pointer remains valid until 617 + * video_device_pipeline_stop() is called. 618 + * 619 + * Return: The media_pipeline the video device is part of, or NULL if the video 620 + * device is not part of any pipeline. 621 + * 622 + * The video device must contain a single pad. 623 + * 624 + * This is a convenience wrapper around media_entity_pipeline(). 625 + */ 626 + struct media_pipeline *video_device_pipeline(struct video_device *vdev); 627 + 628 + #endif /* CONFIG_MEDIA_CONTROLLER */ 629 + 542 630 #endif /* _V4L2_DEV_H */