media: media-entity: Add media_pad_is_streaming() helper function
Add a function to test if a pad is part of a pipeline currently streaming, and use it through drivers to replace direct access to the stream_count field. This will help reworking pipeline start/stop without disturbing drivers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
parent
472377febf
commit
f17bc788f7
@ -834,7 +834,8 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
|
|||||||
sink = link->sink->entity;
|
sink = link->sink->entity;
|
||||||
|
|
||||||
if (!(link->flags & MEDIA_LNK_FL_DYNAMIC) &&
|
if (!(link->flags & MEDIA_LNK_FL_DYNAMIC) &&
|
||||||
(source->stream_count || sink->stream_count))
|
(media_entity_is_streaming(source) ||
|
||||||
|
media_entity_is_streaming(sink)))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
mdev = source->graph_obj.mdev;
|
mdev = source->graph_obj.mdev;
|
||||||
|
@ -10,7 +10,10 @@
|
|||||||
#include <media/drv-intf/exynos-fimc.h>
|
#include <media/drv-intf/exynos-fimc.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
/* Called with the media graph mutex held or entity->stream_count > 0. */
|
/*
|
||||||
|
* Called with the media graph mutex held or media_entity_is_streaming(entity)
|
||||||
|
* true.
|
||||||
|
*/
|
||||||
struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity)
|
struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity)
|
||||||
{
|
{
|
||||||
struct media_pad *pad = &entity->pads[0];
|
struct media_pad *pad = &entity->pads[0];
|
||||||
|
@ -226,7 +226,7 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sd->entity.stream_count == 0) {
|
if (!media_entity_is_streaming(&sd->entity)) {
|
||||||
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
|
if (fmt->pad == FIMC_ISP_SD_PAD_SINK) {
|
||||||
struct v4l2_subdev_format format = *fmt;
|
struct v4l2_subdev_format format = *fmt;
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd,
|
|||||||
mutex_lock(&fimc->lock);
|
mutex_lock(&fimc->lock);
|
||||||
|
|
||||||
if ((atomic_read(&fimc->out_path) == FIMC_IO_ISP &&
|
if ((atomic_read(&fimc->out_path) == FIMC_IO_ISP &&
|
||||||
sd->entity.stream_count > 0) ||
|
media_entity_is_streaming(&sd->entity)) ||
|
||||||
(atomic_read(&fimc->out_path) == FIMC_IO_DMA &&
|
(atomic_read(&fimc->out_path) == FIMC_IO_DMA &&
|
||||||
vb2_is_busy(&fimc->vb_queue))) {
|
vb2_is_busy(&fimc->vb_queue))) {
|
||||||
mutex_unlock(&fimc->lock);
|
mutex_unlock(&fimc->lock);
|
||||||
@ -1197,8 +1197,8 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdev *sd, int on)
|
|||||||
* Find sensor subdev linked to FIMC-LITE directly or through
|
* Find sensor subdev linked to FIMC-LITE directly or through
|
||||||
* MIPI-CSIS. This is required for configuration where FIMC-LITE
|
* MIPI-CSIS. This is required for configuration where FIMC-LITE
|
||||||
* is used as a subdev only and feeds data internally to FIMC-IS.
|
* is used as a subdev only and feeds data internally to FIMC-IS.
|
||||||
* The pipeline links are protected through entity.stream_count
|
* The pipeline links are protected through entity.pipe so there is no
|
||||||
* so there is no need to take the media graph mutex here.
|
* need to take the media graph mutex here.
|
||||||
*/
|
*/
|
||||||
fimc->sensor = fimc_find_remote_sensor(&sd->entity);
|
fimc->sensor = fimc_find_remote_sensor(&sd->entity);
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ static int rvin_csi2_link_notify(struct media_link *link, u32 flags,
|
|||||||
* running streams.
|
* running streams.
|
||||||
*/
|
*/
|
||||||
media_device_for_each_entity(entity, &group->mdev)
|
media_device_for_each_entity(entity, &group->mdev)
|
||||||
if (entity->stream_count)
|
if (media_entity_is_streaming(entity))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
mutex_lock(&group->lock);
|
mutex_lock(&group->lock);
|
||||||
|
@ -858,6 +858,18 @@ struct media_link *media_entity_find_link(struct media_pad *source,
|
|||||||
*/
|
*/
|
||||||
struct media_pad *media_entity_remote_pad(const struct media_pad *pad);
|
struct media_pad *media_entity_remote_pad(const struct media_pad *pad);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* media_entity_is_streaming - Test if an entity is part of a streaming pipeline
|
||||||
|
* @entity: The entity
|
||||||
|
*
|
||||||
|
* Return: True if the entity is part of a pipeline started with the
|
||||||
|
* media_pipeline_start() function, false otherwise.
|
||||||
|
*/
|
||||||
|
static inline bool media_entity_is_streaming(const struct media_entity *entity)
|
||||||
|
{
|
||||||
|
return entity->stream_count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* media_entity_get_fwnode_pad - Get pad number from fwnode
|
* media_entity_get_fwnode_pad - Get pad number from fwnode
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user