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 02/18] tlg2300: fix tuner and frequency handling of the radio device.
Date: Sun, 03 Feb 2013 22:46:58 -0500	[thread overview]
Message-ID: <510F2F32.2020901@gmail.com> (raw)
In-Reply-To: <b4d0a04e07ad8b07837096f2601fad0f6614acb2.1359627298.git.hans.verkuil@cisco.com>

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This driver now passes the tuner and frequency tests of v4l2-compliance.
>
> It's the usual bugs: frequency wasn't clamped to the valid frequency range,
> incorrect tuner capabilities and tuner fields not filled in, missing test
> for invalid tuner index, no initial frequency and incorrect error handling.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |   37 +++++++++++++++++++---------------
>  1 file changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 25eeb16..90dc1d1 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -18,8 +18,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency);
>  static int poseidon_fm_close(struct file *filp);
>  static int poseidon_fm_open(struct file *filp);
>  
> -#define TUNER_FREQ_MIN_FM 76000000
> -#define TUNER_FREQ_MAX_FM 108000000
> +#define TUNER_FREQ_MIN_FM 76000000U
> +#define TUNER_FREQ_MAX_FM 108000000U
>  
>  #define MAX_PREEMPHASIS (V4L2_PREEMPHASIS_75_uS + 1)
>  static int preemphasis[MAX_PREEMPHASIS] = {
> @@ -170,13 +170,14 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  		return -EINVAL;
>  
>  	vt->type	= V4L2_TUNER_RADIO;
> -	vt->capability	= V4L2_TUNER_CAP_STEREO;
> -	vt->rangelow	= TUNER_FREQ_MIN_FM / 62500;
> -	vt->rangehigh	= TUNER_FREQ_MAX_FM / 62500;
> +	vt->capability	= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
> +	vt->rangelow	= TUNER_FREQ_MIN_FM * 2 / 125;
> +	vt->rangehigh	= TUNER_FREQ_MAX_FM * 2 / 125;
>  	vt->rxsubchans	= V4L2_TUNER_SUB_STEREO;
>  	vt->audmode	= V4L2_TUNER_MODE_STEREO;
>  	vt->signal	= 0;
>  	vt->afc 	= 0;
> +	strlcpy(vt->name, "Radio", sizeof(vt->name));
>  
>  	mutex_lock(&p->lock);
>  	ret = send_get_req(p, TUNER_STATUS, TLG_MODE_FM_RADIO,
> @@ -207,6 +208,8 @@ static int fm_get_freq(struct file *file, void *priv,
>  {
>  	struct poseidon *p = file->private_data;
>  
> +	if (argp->tuner)
> +		return -EINVAL;
>  	argp->frequency = p->radio_data.fm_freq;
>  	return 0;
>  }
> @@ -221,11 +224,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
>  	ret = send_set_req(p, TUNER_AUD_ANA_STD,
>  				p->radio_data.pre_emphasis, &status);
>  
> -	freq =  (frequency * 125) * 500 / 1000;/* kHZ */
> -	if (freq < TUNER_FREQ_MIN_FM/1000 || freq > TUNER_FREQ_MAX_FM/1000) {
> -		ret = -EINVAL;
> -		goto error;
> -	}
> +	freq = (frequency * 125) / 2; /* Hz */
> +	freq = clamp(freq, TUNER_FREQ_MIN_FM, TUNER_FREQ_MAX_FM);
>  
>  	ret = send_set_req(p, TUNE_FREQ_SELECT, freq, &status);
>  	if (ret < 0)
> @@ -240,7 +240,7 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
>  				TLG_TUNE_PLAY_SVC_START, &status);
>  		p->radio_data.is_radio_streaming = 1;
>  	}
> -	p->radio_data.fm_freq = frequency;
> +	p->radio_data.fm_freq = freq * 2 / 125;
>  error:
>  	mutex_unlock(&p->lock);
>  	return ret;
> @@ -251,7 +251,9 @@ static int fm_set_freq(struct file *file, void *priv,
>  {
>  	struct poseidon *p = file->private_data;
>  
> -	p->file_for_stream  = file;
> +	if (argp->tuner)
> +		return -EINVAL;
> +	p->file_for_stream = file;
>  #ifdef CONFIG_PM
>  	p->pm_suspend = pm_fm_suspend;
>  	p->pm_resume  = pm_fm_resume;
> @@ -401,16 +403,19 @@ static struct video_device poseidon_fm_template = {
>  int poseidon_fm_init(struct poseidon *p)
>  {
>  	struct video_device *fm_dev;
> +	int err;
>  
>  	fm_dev = vdev_init(p, &poseidon_fm_template);
>  	if (fm_dev == NULL)
> -		return -1;
> +		return -ENOMEM;
>  
> -	if (video_register_device(fm_dev, VFL_TYPE_RADIO, -1) < 0) {
> +	p->radio_data.fm_dev = fm_dev;
> +	set_frequency(p, TUNER_FREQ_MIN_FM);
> +	err = video_register_device(fm_dev, VFL_TYPE_RADIO, -1);
> +	if (err < 0) {
>  		video_device_release(fm_dev);
> -		return -1;
> +		return err;
>  	}
> -	p->radio_data.fm_dev = fm_dev;
>  	return 0;
>  }
>  
thanks.

Acked-by: Huang Shijie <shijie8@gmail.com>




  reply	other threads:[~2013-02-03 14:43 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 [this message]
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
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=510F2F32.2020901@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.