From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, Mike Isely <isely@isely.net>,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFCv4 PATCH 4/8] tuner-core: fix s_std and s_tuner.
Date: Sun, 12 Jun 2011 11:41:32 -0300 [thread overview]
Message-ID: <4DF4D01C.6040800@redhat.com> (raw)
In-Reply-To: <58e65d1d111ba7fa1d0610af92e77d7aefb75d11.1307875512.git.hans.verkuil@cisco.com>
Em 12-06-2011 07:59, Hans Verkuil escreveu:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Both s_std and s_tuner are broken because set_mode_freq is called before the
> new std (for s_std) and audmode (for s_tuner) are set.
>
> This patch splits set_mode_freq in a set_mode and a set_freq and in s_std
> first calls set_mode, and if that returns true (i.e. the mode is supported)
> then they set t->std/t->audmode and call set_freq.
>
> This fixes a bug where changing std or audmode would actually change it to
> the previous value.
>
> Discovered while testing analog TV standards for cx18 with a tda18271 tuner.
I need to better analyse and test this patch.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> drivers/media/video/tuner-core.c | 60 +++++++++++++++++++++-----------------
> 1 files changed, 33 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
> index 462a8f4..bf7fc33 100644
> --- a/drivers/media/video/tuner-core.c
> +++ b/drivers/media/video/tuner-core.c
> @@ -739,19 +739,15 @@ static bool supported_mode(struct tuner *t, enum v4l2_tuner_type mode)
> }
>
> /**
> - * set_mode_freq - Switch tuner to other mode.
> - * @client: struct i2c_client pointer
> + * set_mode - Switch tuner to other mode.
> * @t: a pointer to the module's internal struct_tuner
> * @mode: enum v4l2_type (radio or TV)
> - * @freq: frequency to set (0 means to use the previous one)
> *
> * If tuner doesn't support the needed mode (radio or TV), prints a
> * debug message and returns false, changing its state to standby.
> - * Otherwise, changes the state and sets frequency to the last value
> - * and returns true.
> + * Otherwise, changes the state and returns true.
> */
> -static bool set_mode_freq(struct i2c_client *client, struct tuner *t,
> - enum v4l2_tuner_type mode, unsigned int freq)
> +static bool set_mode(struct tuner *t, enum v4l2_tuner_type mode)
> {
> struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops;
>
> @@ -767,17 +763,27 @@ static bool set_mode_freq(struct i2c_client *client, struct tuner *t,
> t->mode = mode;
> tuner_dbg("Changing to mode %d\n", mode);
> }
> + return true;
> +}
> +
> +/**
> + * set_freq - Set the tuner to the desired frequency.
> + * @t: a pointer to the module's internal struct_tuner
> + * @freq: frequency to set (0 means to use the current frequency)
> + */
> +static void set_freq(struct tuner *t, unsigned int freq)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&t->sd);
> +
> if (t->mode == V4L2_TUNER_RADIO) {
> - if (freq)
> - t->radio_freq = freq;
> - set_radio_freq(client, t->radio_freq);
> + if (!freq)
> + freq = t->radio_freq;
> + set_radio_freq(client, freq);
> } else {
> - if (freq)
> - t->tv_freq = freq;
> - set_tv_freq(client, t->tv_freq);
> + if (!freq)
> + freq = t->tv_freq;
> + set_tv_freq(client, freq);
> }
> -
> - return true;
> }
>
> /*
> @@ -1034,9 +1040,9 @@ static void tuner_status(struct dvb_frontend *fe)
> static int tuner_s_radio(struct v4l2_subdev *sd)
> {
> struct tuner *t = to_tuner(sd);
> - struct i2c_client *client = v4l2_get_subdevdata(sd);
>
> - set_mode_freq(client, t, V4L2_TUNER_RADIO, 0);
> + if (set_mode(t, V4L2_TUNER_RADIO))
> + set_freq(t, 0);
> return 0;
> }
>
> @@ -1068,24 +1074,23 @@ static int tuner_s_power(struct v4l2_subdev *sd, int on)
> static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
> {
> struct tuner *t = to_tuner(sd);
> - struct i2c_client *client = v4l2_get_subdevdata(sd);
>
> - if (!set_mode_freq(client, t, V4L2_TUNER_ANALOG_TV, 0))
> + if (!set_mode(t, V4L2_TUNER_ANALOG_TV))
> return 0;
>
> t->std = tuner_fixup_std(t, std);
> if (t->std != std)
> tuner_dbg("Fixup standard %llx to %llx\n", std, t->std);
> -
> + set_freq(t, 0);
> return 0;
> }
>
> static int tuner_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
> {
> struct tuner *t = to_tuner(sd);
> - struct i2c_client *client = v4l2_get_subdevdata(sd);
>
> - set_mode_freq(client, t, f->type, f->frequency);
> + if (set_mode(t, f->type))
> + set_freq(t, f->frequency);
> return 0;
> }
>
> @@ -1154,13 +1159,14 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
> static int tuner_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
> {
> struct tuner *t = to_tuner(sd);
> - struct i2c_client *client = v4l2_get_subdevdata(sd);
>
> - if (!set_mode_freq(client, t, vt->type, 0))
> + if (!set_mode(t, vt->type))
> return 0;
>
> - if (t->mode == V4L2_TUNER_RADIO)
> + if (t->mode == V4L2_TUNER_RADIO) {
> t->audmode = vt->audmode;
> + set_freq(t, 0);
> + }
>
> return 0;
> }
> @@ -1195,8 +1201,8 @@ static int tuner_resume(struct i2c_client *c)
> tuner_dbg("resume\n");
>
> if (!t->standby)
> - set_mode_freq(c, t, t->type, 0);
> -
> + if (set_mode(t, t->type))
> + set_freq(t, 0);
> return 0;
> }
>
next prev parent reply other threads:[~2011-06-12 14:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-12 10:59 tuner-core: fix g_freq/s_std and g/s_tuner Hans Verkuil
2011-06-12 10:59 ` [RFCv4 PATCH 1/8] tuner-core: rename check_mode to supported_mode Hans Verkuil
2011-06-12 10:59 ` [RFCv4 PATCH 2/8] tuner-core: change return type of set_mode_freq to bool Hans Verkuil
2011-06-12 14:39 ` Mauro Carvalho Chehab
2011-06-12 10:59 ` [RFCv4 PATCH 3/8] tuner-core: simplify the standard fixup Hans Verkuil
2011-06-12 14:39 ` Mauro Carvalho Chehab
2011-06-12 10:59 ` [RFCv4 PATCH 4/8] tuner-core: fix s_std and s_tuner Hans Verkuil
2011-06-12 14:41 ` Mauro Carvalho Chehab [this message]
2011-06-12 10:59 ` [RFCv4 PATCH 5/8] tuner-core: fix tuner_resume: use t->mode instead of t->type Hans Verkuil
2011-06-12 14:42 ` Mauro Carvalho Chehab
2011-06-12 10:59 ` [RFCv4 PATCH 6/8] v4l2-ioctl.c: prefill tuner type for g_frequency and g/s_tuner Hans Verkuil
2011-06-12 12:41 ` Andy Walls
2011-06-12 14:36 ` Mauro Carvalho Chehab
2011-06-12 15:46 ` Hans Verkuil
2011-06-12 17:08 ` Mauro Carvalho Chehab
2011-06-12 19:41 ` Hans Verkuil
2011-06-12 21:52 ` Mauro Carvalho Chehab
2011-06-12 10:59 ` [RFCv4 PATCH 7/8] pvrusb2: fix g/s_tuner support Hans Verkuil
2011-06-12 14:43 ` Mauro Carvalho Chehab
2011-06-12 10:59 ` [RFCv4 PATCH 8/8] bttv: fix s_tuner for radio Hans Verkuil
2011-06-12 14:43 ` Mauro Carvalho Chehab
2011-06-12 14:37 ` [RFCv4 PATCH 1/8] tuner-core: rename check_mode to supported_mode Mauro Carvalho Chehab
2011-06-12 16:07 ` Hans Verkuil
2011-06-12 17:27 ` Mauro Carvalho Chehab
2011-06-12 17:32 ` Mauro Carvalho Chehab
2011-06-12 18:09 ` Hans Verkuil
2011-06-12 22:06 ` Mauro Carvalho Chehab
2011-06-13 10:23 ` Hans Verkuil
2011-06-13 11:45 ` Mauro Carvalho Chehab
2011-06-13 12:07 ` Hans Verkuil
2011-06-13 12:32 ` Mauro Carvalho Chehab
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=4DF4D01C.6040800@redhat.com \
--to=mchehab@redhat.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=isely@isely.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox