Commit d0a164f5 authored by Shuah Khan's avatar Shuah Khan Committed by Mauro Carvalho Chehab

[media] media: v4l-core add enable/disable source common interfaces

Add a new interfaces to be used by v4l-core to invoke enable
source and disable_source handlers in the media_device. The
enable_source helper function invokes the enable_source handler
to find media source entity connected to the entity and check
is it is available or busy. If source is available, link is
activated and pipeline is started. The disable_source helper
function invokes the disable_source handler to deactivate and
stop the pipeline.
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent fb49f204
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Media Controller ancillary functions * Media Controller ancillary functions
* *
* Copyright (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com> * Copyright (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* Copyright (C) 2016 Shuah Khan <shuahkh@osg.samsung.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -16,7 +17,10 @@ ...@@ -16,7 +17,10 @@
#include <linux/module.h> #include <linux/module.h>
#include <media/media-entity.h> #include <media/media-entity.h>
#include <media/media-device.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-mc.h> #include <media/v4l2-mc.h>
#include <media/videobuf2-core.h>
int v4l2_mc_create_media_graph(struct media_device *mdev) int v4l2_mc_create_media_graph(struct media_device *mdev)
...@@ -182,3 +186,34 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -182,3 +186,34 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph); EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph);
int v4l_enable_media_source(struct video_device *vdev)
{
struct media_device *mdev = vdev->entity.graph_obj.mdev;
int ret;
if (!mdev || !mdev->enable_source)
return 0;
ret = mdev->enable_source(&vdev->entity, &vdev->pipe);
if (ret)
return -EBUSY;
return 0;
}
EXPORT_SYMBOL_GPL(v4l_enable_media_source);
void v4l_disable_media_source(struct video_device *vdev)
{
struct media_device *mdev = vdev->entity.graph_obj.mdev;
if (mdev && mdev->disable_source)
mdev->disable_source(&vdev->entity);
}
EXPORT_SYMBOL_GPL(v4l_disable_media_source);
int v4l_vb2q_enable_media_source(struct vb2_queue *q)
{
struct v4l2_fh *fh = q->owner;
return v4l_enable_media_source(fh->vdev);
}
EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
...@@ -87,6 +87,7 @@ struct video_device ...@@ -87,6 +87,7 @@ struct video_device
#if defined(CONFIG_MEDIA_CONTROLLER) #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity; struct media_entity entity;
struct media_intf_devnode *intf_devnode; struct media_intf_devnode *intf_devnode;
struct media_pipeline pipe;
#endif #endif
/* device ops */ /* device ops */
const struct v4l2_file_operations *fops; const struct v4l2_file_operations *fops;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define _V4L2_MC_H #define _V4L2_MC_H
#include <media/media-device.h> #include <media/media-device.h>
#include <media/v4l2-dev.h>
/** /**
* enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
...@@ -116,11 +117,73 @@ struct usb_device; ...@@ -116,11 +117,73 @@ struct usb_device;
*/ */
int v4l2_mc_create_media_graph(struct media_device *mdev); int v4l2_mc_create_media_graph(struct media_device *mdev);
/**
* v4l_enable_media_source() - Hold media source for exclusive use
* if free
*
* @vdev - poniter to struct video_device
*
* This interface calls enable_source handler to determine if
* media source is free for use. The enable_source handler is
* responsible for checking is the media source is free and
* start a pipeline between the media source and the media
* entity associated with the video device. This interface
* should be called from v4l2-core and dvb-core interfaces
* that change the source configuration.
*
* Return: returns zero on success or a negative error code.
*/
int v4l_enable_media_source(struct video_device *vdev);
/**
* v4l_disable_media_source() - Release media source
*
* @vdev - poniter to struct video_device
*
* This interface calls disable_source handler to release
* the media source. The disable_source handler stops the
* active media pipeline between the media source and the
* media entity associated with the video device.
*
* Return: returns zero on success or a negative error code.
*/
void v4l_disable_media_source(struct video_device *vdev);
/*
* v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
* if free.
* @q - pointer to struct vb2_queue
*
* Wrapper for v4l_enable_media_source(). This function should
* be called from v4l2-core to enable the media source with
* pointer to struct vb2_queue as the input argument. Some
* v4l2-core interfaces don't have access to video device and
* this interface finds the struct video_device for the q and
* calls v4l_enable_media_source().
*/
int v4l_vb2q_enable_media_source(struct vb2_queue *q);
#else #else
static inline int v4l2_mc_create_media_graph(struct media_device *mdev) static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
{ {
return 0; return 0;
} }
static int v4l_enable_media_source(struct video_device *vdev)
{
return 0;
}
static void v4l_disable_media_source(struct video_device *vdev)
{
return;
}
static int v4l_vb2q_enable_media_source(struct vb2_queue *q)
{
return 0;
}
#endif #endif
#endif #endif /* _V4L2_MC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment