Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28461451 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab
Browse files

[media] v4l: omap3isp: Use the new media graph walk interface



The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.

Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 106b9907
Loading
Loading
Loading
Loading
+39 −24
Original line number Original line Diff line number Diff line
@@ -683,14 +683,14 @@ static irqreturn_t isp_isr(int irq, void *_isp)
 *
 *
 * Return the total number of users of all video device nodes in the pipeline.
 * Return the total number of users of all video device nodes in the pipeline.
 */
 */
static int isp_pipeline_pm_use_count(struct media_entity *entity)
static int isp_pipeline_pm_use_count(struct media_entity *entity,
	struct media_entity_graph *graph)
{
{
	struct media_entity_graph graph;
	int use = 0;
	int use = 0;


	media_entity_graph_walk_start(&graph, entity);
	media_entity_graph_walk_start(graph, entity);


	while ((entity = media_entity_graph_walk_next(&graph))) {
	while ((entity = media_entity_graph_walk_next(graph))) {
		if (is_media_entity_v4l2_io(entity))
		if (is_media_entity_v4l2_io(entity))
			use += entity->use_count;
			use += entity->use_count;
	}
	}
@@ -742,27 +742,27 @@ static int isp_pipeline_pm_power_one(struct media_entity *entity, int change)
 *
 *
 * Return 0 on success or a negative error code on failure.
 * Return 0 on success or a negative error code on failure.
 */
 */
static int isp_pipeline_pm_power(struct media_entity *entity, int change)
static int isp_pipeline_pm_power(struct media_entity *entity, int change,
	struct media_entity_graph *graph)
{
{
	struct media_entity_graph graph;
	struct media_entity *first = entity;
	struct media_entity *first = entity;
	int ret = 0;
	int ret = 0;


	if (!change)
	if (!change)
		return 0;
		return 0;


	media_entity_graph_walk_start(&graph, entity);
	media_entity_graph_walk_start(graph, entity);


	while (!ret && (entity = media_entity_graph_walk_next(&graph)))
	while (!ret && (entity = media_entity_graph_walk_next(graph)))
		if (is_media_entity_v4l2_subdev(entity))
		if (is_media_entity_v4l2_subdev(entity))
			ret = isp_pipeline_pm_power_one(entity, change);
			ret = isp_pipeline_pm_power_one(entity, change);


	if (!ret)
	if (!ret)
		return 0;
		return ret;


	media_entity_graph_walk_start(&graph, first);
	media_entity_graph_walk_start(graph, first);


	while ((first = media_entity_graph_walk_next(&graph))
	while ((first = media_entity_graph_walk_next(graph))
	       && first != entity)
	       && first != entity)
		if (is_media_entity_v4l2_subdev(first))
		if (is_media_entity_v4l2_subdev(first))
			isp_pipeline_pm_power_one(first, -change);
			isp_pipeline_pm_power_one(first, -change);
@@ -782,7 +782,8 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change)
 * off is assumed to never fail. No failure can occur when the use parameter is
 * off is assumed to never fail. No failure can occur when the use parameter is
 * set to 0.
 * set to 0.
 */
 */
int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
			     struct media_entity_graph *graph)
{
{
	int change = use ? 1 : -1;
	int change = use ? 1 : -1;
	int ret;
	int ret;
@@ -794,7 +795,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
	WARN_ON(entity->use_count < 0);
	WARN_ON(entity->use_count < 0);


	/* Apply power change to connected non-nodes. */
	/* Apply power change to connected non-nodes. */
	ret = isp_pipeline_pm_power(entity, change);
	ret = isp_pipeline_pm_power(entity, change, graph);
	if (ret < 0)
	if (ret < 0)
		entity->use_count -= change;
		entity->use_count -= change;


@@ -820,35 +821,49 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
static int isp_pipeline_link_notify(struct media_link *link, u32 flags,
static int isp_pipeline_link_notify(struct media_link *link, u32 flags,
				    unsigned int notification)
				    unsigned int notification)
{
{
	struct media_entity_graph *graph =
		&container_of(link->graph_obj.mdev, struct isp_device,
			      media_dev)->pm_count_graph;
	struct media_entity *source = link->source->entity;
	struct media_entity *source = link->source->entity;
	struct media_entity *sink = link->sink->entity;
	struct media_entity *sink = link->sink->entity;
	int source_use = isp_pipeline_pm_use_count(source);
	int source_use;
	int sink_use = isp_pipeline_pm_use_count(sink);
	int sink_use;
	int ret;
	int ret = 0;

	if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
		ret = media_entity_graph_walk_init(graph,
						   link->graph_obj.mdev);
		if (ret)
			return ret;
	}

	source_use = isp_pipeline_pm_use_count(source, graph);
	sink_use = isp_pipeline_pm_use_count(sink, graph);


	if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
	if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
	    !(flags & MEDIA_LNK_FL_ENABLED)) {
	    !(flags & MEDIA_LNK_FL_ENABLED)) {
		/* Powering off entities is assumed to never fail. */
		/* Powering off entities is assumed to never fail. */
		isp_pipeline_pm_power(source, -sink_use);
		isp_pipeline_pm_power(source, -sink_use, graph);
		isp_pipeline_pm_power(sink, -source_use);
		isp_pipeline_pm_power(sink, -source_use, graph);
		return 0;
		return 0;
	}
	}


	if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
	if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
		(flags & MEDIA_LNK_FL_ENABLED)) {
		(flags & MEDIA_LNK_FL_ENABLED)) {


		ret = isp_pipeline_pm_power(source, sink_use);
		ret = isp_pipeline_pm_power(source, sink_use, graph);
		if (ret < 0)
		if (ret < 0)
			return ret;
			return ret;


		ret = isp_pipeline_pm_power(sink, source_use);
		ret = isp_pipeline_pm_power(sink, source_use, graph);
		if (ret < 0)
		if (ret < 0)
			isp_pipeline_pm_power(source, -sink_use);
			isp_pipeline_pm_power(source, -sink_use, graph);

		return ret;
	}
	}


	return 0;
	if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH)
		media_entity_graph_walk_cleanup(graph);

	return ret;
}
}


/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
+3 −1
Original line number Original line Diff line number Diff line
@@ -176,6 +176,7 @@ struct isp_device {
	struct v4l2_device v4l2_dev;
	struct v4l2_device v4l2_dev;
	struct v4l2_async_notifier notifier;
	struct v4l2_async_notifier notifier;
	struct media_device media_dev;
	struct media_device media_dev;
	struct media_entity_graph pm_count_graph;
	struct device *dev;
	struct device *dev;
	u32 revision;
	u32 revision;


@@ -265,7 +266,8 @@ void omap3isp_subclk_enable(struct isp_device *isp,
void omap3isp_subclk_disable(struct isp_device *isp,
void omap3isp_subclk_disable(struct isp_device *isp,
			     enum isp_subclk_resource res);
			     enum isp_subclk_resource res);


int omap3isp_pipeline_pm_use(struct media_entity *entity, int use);
int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
			     struct media_entity_graph *graph);


int omap3isp_register_entities(struct platform_device *pdev,
int omap3isp_register_entities(struct platform_device *pdev,
			       struct v4l2_device *v4l2_dev);
			       struct v4l2_device *v4l2_dev);
+18 −2
Original line number Original line Diff line number Diff line
@@ -227,8 +227,15 @@ static int isp_video_get_graph_data(struct isp_video *video,
	struct media_entity *entity = &video->video.entity;
	struct media_entity *entity = &video->video.entity;
	struct media_device *mdev = entity->graph_obj.mdev;
	struct media_device *mdev = entity->graph_obj.mdev;
	struct isp_video *far_end = NULL;
	struct isp_video *far_end = NULL;
	int ret;


	mutex_lock(&mdev->graph_mutex);
	mutex_lock(&mdev->graph_mutex);
	ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
	if (ret) {
		mutex_unlock(&mdev->graph_mutex);
		return ret;
	}

	media_entity_graph_walk_start(&graph, entity);
	media_entity_graph_walk_start(&graph, entity);


	while ((entity = media_entity_graph_walk_next(&graph))) {
	while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -252,6 +259,8 @@ static int isp_video_get_graph_data(struct isp_video *video,


	mutex_unlock(&mdev->graph_mutex);
	mutex_unlock(&mdev->graph_mutex);


	media_entity_graph_walk_cleanup(&graph);

	if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
	if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
		pipe->input = far_end;
		pipe->input = far_end;
		pipe->output = video;
		pipe->output = video;
@@ -1244,7 +1253,12 @@ static int isp_video_open(struct file *file)
		goto done;
		goto done;
	}
	}


	ret = omap3isp_pipeline_pm_use(&video->video.entity, 1);
	ret = media_entity_graph_walk_init(&handle->graph,
					   &video->isp->media_dev);
	if (ret)
		goto done;

	ret = omap3isp_pipeline_pm_use(&video->video.entity, 1, &handle->graph);
	if (ret < 0) {
	if (ret < 0) {
		omap3isp_put(video->isp);
		omap3isp_put(video->isp);
		goto done;
		goto done;
@@ -1275,6 +1289,7 @@ static int isp_video_open(struct file *file)
done:
done:
	if (ret < 0) {
	if (ret < 0) {
		v4l2_fh_del(&handle->vfh);
		v4l2_fh_del(&handle->vfh);
		media_entity_graph_walk_cleanup(&handle->graph);
		kfree(handle);
		kfree(handle);
	}
	}


@@ -1294,7 +1309,8 @@ static int isp_video_release(struct file *file)
	vb2_queue_release(&handle->queue);
	vb2_queue_release(&handle->queue);
	mutex_unlock(&video->queue_lock);
	mutex_unlock(&video->queue_lock);


	omap3isp_pipeline_pm_use(&video->video.entity, 0);
	omap3isp_pipeline_pm_use(&video->video.entity, 0, &handle->graph);
	media_entity_graph_walk_cleanup(&handle->graph);


	/* Release the file handle. */
	/* Release the file handle. */
	v4l2_fh_del(vfh);
	v4l2_fh_del(vfh);
+1 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,7 @@ struct isp_video_fh {
	struct vb2_queue queue;
	struct vb2_queue queue;
	struct v4l2_format format;
	struct v4l2_format format;
	struct v4l2_fract timeperframe;
	struct v4l2_fract timeperframe;
	struct media_entity_graph graph;
};
};


#define to_isp_video_fh(fh)	container_of(fh, struct isp_video_fh, vfh)
#define to_isp_video_fh(fh)	container_of(fh, struct isp_video_fh, vfh)