Skip to content

Commit

Permalink
[media] radio-sf16fmi: Set frequency during init
Browse files Browse the repository at this point in the history
Set freqency during initialization to fix v4l2-compliance error.
This also fixes VIDIOC_G_FREQUENCY always returning zero (broken by me during LM7000 conversion).

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Ondrej Zary authored and Mauro Carvalho Chehab committed Jun 21, 2013
1 parent 9291682 commit d9ec089
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions drivers/media/radio/radio-sf16fmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct fmi
struct video_device vdev;
int io;
bool mute;
unsigned long curfreq; /* freq in kHz */
u32 curfreq; /* freq in kHz */
struct mutex lock;
};

Expand Down Expand Up @@ -118,6 +118,14 @@ static inline int fmi_getsigstr(struct fmi *fmi)
return (res & 2) ? 0 : 0xFFFF;
}

static void fmi_set_freq(struct fmi *fmi)
{
fmi->curfreq = clamp(fmi->curfreq, RSF16_MINFREQ, RSF16_MAXFREQ);
/* rounding in steps of 800 to match the freq
that will be used */
lm7000_set_freq((fmi->curfreq / 800) * 800, fmi, fmi_set_pins);
}

static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *v)
{
Expand Down Expand Up @@ -158,14 +166,13 @@ static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f)
{
struct fmi *fmi = video_drvdata(file);
unsigned freq = f->frequency;

if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
return -EINVAL;
clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ);
/* rounding in steps of 800 to match the freq
that will be used */
lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins);

fmi->curfreq = f->frequency;
fmi_set_freq(fmi);

return 0;
}

Expand Down Expand Up @@ -342,8 +349,10 @@ static int __init fmi_init(void)

mutex_init(&fmi->lock);

/* mute card - prevents noisy bootups */
fmi_mute(fmi);
/* mute card and set default frequency */
fmi->mute = 1;
fmi->curfreq = RSF16_MINFREQ;
fmi_set_freq(fmi);

if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_ctrl_handler_free(hdl);
Expand Down

0 comments on commit d9ec089

Please sign in to comment.