All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Shijie <shijie8@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFC PATCH 07/18] tlg2300: switch to v4l2_fh.
Date: Sun, 03 Feb 2013 23:32:48 -0500	[thread overview]
Message-ID: <510F39F0.2040703@gmail.com> (raw)
In-Reply-To: <ba65d0385e9368b1c7d1d7bb8b8855893dc170d7.1359627298.git.hans.verkuil@cisco.com>

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This switch to v4l2_fh resolves the last v4l2_compliance issues with respect
> to control events and priority handling.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    1 -
>  drivers/media/usb/tlg2300/pd-main.c   |    3 ++-
>  drivers/media/usb/tlg2300/pd-radio.c  |   35 ++++++++++++++++++---------------
>  3 files changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index b26082a..67ad065 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -116,7 +116,6 @@ struct poseidon_audio {
>  
>  struct radio_data {
>  	__u32		fm_freq;
> -	int		users;
>  	unsigned int	is_radio_streaming;
>  	int		pre_emphasis;
>  	struct video_device fm_dev;
> diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
> index c4eb57a..5be5a73 100644
> --- a/drivers/media/usb/tlg2300/pd-main.c
> +++ b/drivers/media/usb/tlg2300/pd-main.c
> @@ -267,7 +267,8 @@ static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev)
>  static inline int get_autopm_ref(struct poseidon *pd)
>  {
>  	return  pd->video_data.users + pd->vbi_data.users + pd->audio.users
> -		+ atomic_read(&pd->dvb_data.users) + pd->radio_data.users;
> +		+ atomic_read(&pd->dvb_data.users) +
> +		!list_empty(&pd->radio_data.fm_dev.fh_list);
>  }
>  
>  /* fixup something for poseidon */
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 45b3d7a..854ffa0 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -9,6 +9,8 @@
>  #include <linux/mm.h>
>  #include <linux/mutex.h>
>  #include <media/v4l2-ioctl.h>
> +#include <media/v4l2-event.h>
> +#include <media/v4l2-fh.h>
>  #include <linux/sched.h>
>  
>  #include "pd-common.h"
> @@ -77,13 +79,9 @@ static int pm_fm_resume(struct poseidon *p)
>  
>  static int poseidon_fm_open(struct file *filp)
>  {
> -	struct video_device *vfd = video_devdata(filp);
> -	struct poseidon *p = video_get_drvdata(vfd);
> +	struct poseidon *p = video_drvdata(filp);
>  	int ret = 0;
>  
> -	if (!p)
> -		return -1;
> -
>  	mutex_lock(&p->lock);
>  	if (p->state & POSEIDON_STATE_DISCONNECT) {
>  		ret = -ENODEV;
> @@ -94,9 +92,14 @@ static int poseidon_fm_open(struct file *filp)
>  		ret = -EBUSY;
>  		goto out;
>  	}
> +	ret = v4l2_fh_open(filp);
> +	if (ret)
> +		goto out;
>  
>  	usb_autopm_get_interface(p->interface);
>  	if (0 == p->state) {
> +		struct video_device *vfd = &p->radio_data.fm_dev;
> +
>  		/* default pre-emphasis */
>  		if (p->radio_data.pre_emphasis == 0)
>  			p->radio_data.pre_emphasis = TLG_TUNE_ASTD_FM_EUR;
> @@ -109,9 +112,7 @@ static int poseidon_fm_open(struct file *filp)
>  		}
>  		p->state |= POSEIDON_STATE_FM;
>  	}
> -	p->radio_data.users++;
>  	kref_get(&p->kref);
> -	filp->private_data = p;
>  out:
>  	mutex_unlock(&p->lock);
>  	return ret;
> @@ -119,13 +120,12 @@ out:
>  
>  static int poseidon_fm_close(struct file *filp)
>  {
> -	struct poseidon *p = filp->private_data;
> +	struct poseidon *p = video_drvdata(filp);
>  	struct radio_data *fm = &p->radio_data;
>  	uint32_t status;
>  
>  	mutex_lock(&p->lock);
> -	fm->users--;
> -	if (0 == fm->users)
> +	if (v4l2_fh_is_singular_file(filp))
>  		p->state &= ~POSEIDON_STATE_FM;
>  
>  	if (fm->is_radio_streaming && filp == p->file_for_stream) {
> @@ -136,14 +136,13 @@ static int poseidon_fm_close(struct file *filp)
>  	mutex_unlock(&p->lock);
>  
>  	kref_put(&p->kref, poseidon_delete);
> -	filp->private_data = NULL;
> -	return 0;
> +	return v4l2_fh_release(filp);
>  }
>  
>  static int vidioc_querycap(struct file *file, void *priv,
>  			struct v4l2_capability *v)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
>  	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
> @@ -156,15 +155,16 @@ static const struct v4l2_file_operations poseidon_fm_fops = {
>  	.owner         = THIS_MODULE,
>  	.open          = poseidon_fm_open,
>  	.release       = poseidon_fm_close,
> +	.poll		= v4l2_ctrl_poll,
>  	.unlocked_ioctl = video_ioctl2,
>  };
>  
>  static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  				 struct v4l2_tuner *vt)
>  {
> +	struct poseidon *p = video_drvdata(file);
>  	struct tuner_fm_sig_stat_s fm_stat = {};
>  	int ret, status, count = 5;
> -	struct poseidon *p = file->private_data;
>  
>  	if (vt->index != 0)
>  		return -EINVAL;
> @@ -206,7 +206,7 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  static int fm_get_freq(struct file *file, void *priv,
>  		       struct v4l2_frequency *argp)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	if (argp->tuner)
>  		return -EINVAL;
> @@ -249,7 +249,7 @@ error:
>  static int fm_set_freq(struct file *file, void *priv,
>  		       struct v4l2_frequency *argp)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	if (argp->tuner)
>  		return -EINVAL;
> @@ -293,6 +293,8 @@ static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
>  	.vidioc_g_tuner     = tlg_fm_vidioc_g_tuner,
>  	.vidioc_g_frequency = fm_get_freq,
>  	.vidioc_s_frequency = fm_set_freq,
> +	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> +	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
>  };
>  
>  static struct video_device poseidon_fm_template = {
> @@ -320,6 +322,7 @@ int poseidon_fm_init(struct poseidon *p)
>  	}
>  	vfd->v4l2_dev = &p->v4l2_dev;
>  	vfd->ctrl_handler = hdl;
> +	set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
>  	video_set_drvdata(vfd, p);
>  	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
>  }
Acked-by: Huang Shijie <shijie8@gmail.com>

  reply	other threads:[~2013-02-03 15:29 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 10:25 [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Hans Verkuil
2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
2013-02-04  3:46     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl Hans Verkuil
2013-02-04  3:48     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
2013-02-04  4:16     ` Huang Shijie
2013-02-04  8:34       ` Hans Verkuil
2013-02-05  4:03     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it Hans Verkuil
2013-02-04  4:26     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 06/18] tlg2300: add control handler for radio device node Hans Verkuil
2013-02-04  4:47     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 07/18] tlg2300: switch to v4l2_fh Hans Verkuil
2013-02-04  4:32     ` Huang Shijie [this message]
2013-01-31 10:25   ` [RFC PATCH 08/18] tlg2300: fix radio querycap Hans Verkuil
2013-02-04  4:36     ` Huang Shijie
2013-02-04  8:38       ` Hans Verkuil
2013-02-05  4:07         ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 09/18] tlg2300: add missing video_unregister_device Hans Verkuil
2013-02-04  4:38     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 10/18] tlg2300: embed video_device Hans Verkuil
2013-02-04  4:39     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 11/18] tlg2300: fix querycap Hans Verkuil
2013-02-04  4:43     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 12/18] tlg2300: fix frequency handling Hans Verkuil
2013-02-04  4:44     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
2013-02-04  4:48     ` Huang Shijie
2013-02-04  8:39       ` Hans Verkuil
2013-02-05  4:07     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 14/18] tlg2300: implement the control framework Hans Verkuil
2013-02-04  4:46     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std Hans Verkuil
2013-02-04  4:51     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 16/18] tlg2300: allow multiple opens Hans Verkuil
2013-02-04  4:54     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 17/18] tlg2300: Remove logs() macro Hans Verkuil
2013-02-04  4:54     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 18/18] tlg2300: update MAINTAINERS file Hans Verkuil
2013-02-04  4:55     ` Huang Shijie
2013-02-04  8:40       ` Hans Verkuil
2013-02-04  2:40   ` [RFC PATCH 01/18] tlg2300: use correct device parent Huang Shijie
2013-02-04  8:40     ` Hans Verkuil
2013-02-01  2:22 ` [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Huang Shijie
2013-02-01  7:49   ` Hans Verkuil
2013-02-01  8:02     ` Huang Shijie
2013-02-01  8:07       ` Hans Verkuil

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=510F39F0.2040703@gmail.com \
    --to=shijie8@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /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.