All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: mchehab@osg.samsung.com, hans.verkuil@cisco.com,
	laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com,
	tiwai@suse.de, pawel@osciak.com, m.szyprowski@samsung.com,
	kyungmin.park@samsung.com, perex@perex.cz,
	stefanr@s5r6.in-berlin.de, crope@iki.fi,
	dan.carpenter@oracle.com, tskd08@gmail.com,
	ruchandani.tina@gmail.com, arnd@arndb.de, chehabrafael@gmail.com,
	prabhakar.csengg@gmail.com, Julia.Lawall@lip6.fr,
	elfring@users.sourceforge.net, ricardo.ribalda@gmail.com,
	chris.j.arges@canonical.com,
	pierre-louis.bossart@linux.intel.com, gtmkramer@xs4all.nl,
	clemens@ladisch.de, misterpib@gmail.com, takamichiho@gmail.com,
	pmatilai@laiskiainen.org, damien@zamaudio.com, daniel@zonque.org,
	vladcatoi@gmail.com, normalperson@yhbt.net, joe@oampo.co.uk,
	bugzilla.frnkcg@spamgourmet.com, jussi@sonarnerd.net
Cc: Shuah Khan <shuahkh@osg.samsung.com>,
	linux-media@vger.kernel.org, alsa-devel@alsa-project.org
Subject: [PATCH v3 13/21] media: Change v4l-core to check for tuner availability
Date: Tue, 22 Sep 2015 11:19:32 -0600	[thread overview]
Message-ID: <2fd0fa2d594d7b67023e6484b08ef645925d77b8.1442937669.git.shuahkh@osg.samsung.com> (raw)
In-Reply-To: <cover.1442937669.git.shuahkh@osg.samsung.com>
In-Reply-To: <cover.1442937669.git.shuahkh@osg.samsung.com>

Change s_input, s_fmt, s_tuner, s_frequency, querystd,
s_hw_freq_seek, and vb2_internal_streamon interfaces that
alter the tuner configuration to check for tuner availability
by calling v4l_enable_media_tuner(). If tuner isn't free,
return -EBUSY. v4l_disable_media_tuner() is called from
v4l2_fh_exit() to release the tuner.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 drivers/media/v4l2-core/v4l2-fh.c        |  1 +
 drivers/media/v4l2-core/v4l2-ioctl.c     | 29 +++++++++++++++++++++++++++++
 drivers/media/v4l2-core/videobuf2-core.c |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index c97067a..538db62 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -92,6 +92,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
 {
 	if (fh->vdev == NULL)
 		return;
+	v4l_disable_media_tuner(fh->vdev);
 	v4l2_event_unsubscribe_all(fh);
 	fh->vdev = NULL;
 }
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 85de455..deffc1b 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1035,6 +1035,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
 				struct file *file, void *fh, void *arg)
 {
+	struct video_device *vfd = video_devdata(file);
+	int ret;
+
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	return ops->vidioc_s_input(file, fh, *(unsigned int *)arg);
 }
 
@@ -1433,6 +1439,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
 	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
 	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	v4l_sanitize_format(p);
 
 	switch (p->type) {
@@ -1612,7 +1621,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
 {
 	struct video_device *vfd = video_devdata(file);
 	struct v4l2_tuner *p = arg;
+	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
 			V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 	return ops->vidioc_s_tuner(file, fh, p);
@@ -1650,7 +1663,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,
 	struct video_device *vfd = video_devdata(file);
 	const struct v4l2_frequency *p = arg;
 	enum v4l2_tuner_type type;
+	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	if (vfd->vfl_type == VFL_TYPE_SDR) {
 		if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
 			return -EINVAL;
@@ -1705,7 +1722,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops,
 {
 	struct video_device *vfd = video_devdata(file);
 	v4l2_std_id id = *(v4l2_std_id *)arg, norm;
+	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	norm = id & vfd->tvnorms;
 	if (vfd->tvnorms && !norm)	/* Check if std is supported */
 		return -EINVAL;
@@ -1719,7 +1740,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
 {
 	struct video_device *vfd = video_devdata(file);
 	v4l2_std_id *p = arg;
+	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	/*
 	 * If no signal is detected, then the driver should return
 	 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
@@ -1738,7 +1763,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,
 	struct video_device *vfd = video_devdata(file);
 	struct v4l2_hw_freq_seek *p = arg;
 	enum v4l2_tuner_type type;
+	int ret;
 
+	ret = v4l_enable_media_tuner(vfd);
+	if (ret)
+		return ret;
 	/* s_hw_freq_seek is not supported for SDR for now */
 	if (vfd->vfl_type == VFL_TYPE_SDR)
 		return -EINVAL;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index d835814..f7304d8 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2251,6 +2251,9 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 	 * are available.
 	 */
 	if (q->queued_count >= q->min_buffers_needed) {
+		ret = v4l_enable_media_tuner(q->owner->vdev);
+		if (ret)
+			return ret;
 		ret = vb2_start_streaming(q);
 		if (ret) {
 			__vb2_queue_cancel(q);
-- 
2.1.4


  parent reply	other threads:[~2015-09-22 17:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 17:19 [PATCH v3 00/21] Update ALSA, and au0828 drivers to use Managed Media Controller API Shuah Khan
2015-09-22 17:19 ` [PATCH v3 01/21] Revert "[media] media: media controller entity framework enhancements for ALSA" Shuah Khan
2015-09-22 17:19 ` [PATCH v3 02/21] media: Media Controller register/unregister entity_notify API Shuah Khan
2015-09-22 17:19 ` [PATCH v3 03/21] media: Add ALSA Media Controller devnodes Shuah Khan
2015-09-22 17:19 ` [PATCH v3 04/21] media: Media Controller enable/disable source handler API Shuah Khan
2015-09-22 17:19 ` [PATCH v3 05/21] media: Media Controller fix to not let stream_count go negative Shuah Khan
2015-09-22 17:19 ` [PATCH v3 06/21] media: Media Controller export non locking __media_entity_setup_link() Shuah Khan
2015-09-22 17:19 ` [PATCH v3 07/21] media: Media Controller non-locking __media_entity_pipeline_start/stop() Shuah Khan
2015-09-22 17:19 ` [PATCH v3 08/21] media: v4l-core add v4l_enable/disable_media_tuner() helper functions Shuah Khan
2015-09-22 17:19 ` [PATCH v3 09/21] media: Move au8522_media_pads enum to au8522.h from au8522_priv.h Shuah Khan
2015-09-22 17:19 ` [PATCH v3 10/21] media: au8522 change to create MC pad for ALSA Audio Out Shuah Khan
2015-09-22 17:19 ` [PATCH v3 11/21] media: au0828 Use au8522_media_pads enum for pad defines Shuah Khan
2015-09-22 17:19 ` [PATCH v3 12/21] media: au0828 fix au0828_create_media_graph() entity checks Shuah Khan
2015-09-22 17:19 ` Shuah Khan [this message]
2015-09-22 17:19 ` [PATCH v3 14/21] media: dvb-frontend invoke enable/disable_source handlers Shuah Khan
2015-09-22 17:19 ` [PATCH v3 15/21] media: au0828 video remove au0828_enable_analog_tuner() Shuah Khan
2015-09-22 17:19 ` [PATCH v3 16/21] media: au0828 video change to use v4l_enable_media_tuner() Shuah Khan
2015-09-22 17:19 ` [PATCH v3 17/21] media: au0828 change to use Managed Media Controller API Shuah Khan
2015-09-22 17:19 ` [PATCH v3 18/21] media: au0828 change to register/unregister entity_notify hook Shuah Khan
2015-09-22 17:19 ` [PATCH v3 19/21] media: au0828 implement enable_source and disable_source handlers Shuah Khan
2015-09-22 17:19 ` [PATCH v3 20/21] media: media: dvb-frontend fix enable_source error legs Shuah Khan
2015-09-22 17:19 ` [PATCH v3 21/21] sound/usb: Update ALSA driver to use Managed Media Controller API Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fd0fa2d594d7b67023e6484b08ef645925d77b8.1442937669.git.shuahkh@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=Julia.Lawall@lip6.fr \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=bugzilla.frnkcg@spamgourmet.com \
    --cc=chehabrafael@gmail.com \
    --cc=chris.j.arges@canonical.com \
    --cc=clemens@ladisch.de \
    --cc=crope@iki.fi \
    --cc=damien@zamaudio.com \
    --cc=dan.carpenter@oracle.com \
    --cc=daniel@zonque.org \
    --cc=elfring@users.sourceforge.net \
    --cc=gtmkramer@xs4all.nl \
    --cc=hans.verkuil@cisco.com \
    --cc=joe@oampo.co.uk \
    --cc=jussi@sonarnerd.net \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@osg.samsung.com \
    --cc=misterpib@gmail.com \
    --cc=normalperson@yhbt.net \
    --cc=pawel@osciak.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=pmatilai@laiskiainen.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=ricardo.ribalda@gmail.com \
    --cc=ruchandani.tina@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=takamichiho@gmail.com \
    --cc=tiwai@suse.de \
    --cc=tskd08@gmail.com \
    --cc=vladcatoi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.