From 76413791a03f8fd8a3d793db135e19b6c2239664 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Sun, 21 Feb 2016 13:25:09 -0300 Subject: [media] v4l: Add generic pipeline power management code When the Media controller framework was merged, it was decided not to add pipeline power management code for it was not seen generic. As a result, a number of drivers have copied the same piece of code, with same bugfixes done to them at different points of time (or not at all). Add these functions to V4L2. Their use is optional for drivers. [mchehab@osg.samsung.com: Fix merge conflicts] Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mc.h | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index f9477b88014d..406f845034b9 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -2,6 +2,8 @@ * v4l2-mc.h - Media Controller V4L2 types and prototypes * * Copyright (C) 2016 Mauro Carvalho Chehab + * Copyright (C) 2006-2010 Nokia Corporation + * Copyright (c) 2016 Intel Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +21,7 @@ #include #include +#include /** * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER @@ -165,6 +168,45 @@ void v4l_disable_media_source(struct video_device *vdev); */ int v4l_vb2q_enable_media_source(struct vb2_queue *q); + +/** + * v4l2_pipeline_pm_use - Update the use count of an entity + * @entity: The entity + * @use: Use (1) or stop using (0) the entity + * + * Update the use count of all entities in the pipeline and power entities on or + * off accordingly. + * + * This function is intended to be called in video node open (use == + * 1) and release (use == 0). It uses struct media_entity.use_count to + * track the power status. The use of this function should be paired + * with v4l2_pipeline_link_notify(). + * + * Return 0 on success or a negative error code on failure. Powering entities + * off is assumed to never fail. No failure can occur when the use parameter is + * set to 0. + */ +int v4l2_pipeline_pm_use(struct media_entity *entity, int use); + + +/** + * v4l2_pipeline_link_notify - Link management notification callback + * @link: The link + * @flags: New link flags that will be applied + * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*) + * + * React to link management on powered pipelines by updating the use count of + * all entities in the source and sink sides of the link. Entities are powered + * on or off accordingly. The use of this function should be paired + * with v4l2_pipeline_pm_use(). + * + * Return 0 on success or a negative error code on failure. Powering entities + * off is assumed to never fail. This function will not fail for disconnection + * events. + */ +int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, + unsigned int notification); + #else static inline int v4l2_mc_create_media_graph(struct media_device *mdev) @@ -186,6 +228,5 @@ static int v4l_vb2q_enable_media_source(struct vb2_queue *q) { return 0; } - #endif #endif /* _V4L2_MC_H */ -- cgit v1.2.3-58-ga151