Commit d9ec089e authored by Ondrej Zary's avatar Ondrej Zary Committed by Mauro Carvalho Chehab

[media] radio-sf16fmi: Set frequency during init

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: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9291682e
...@@ -50,7 +50,7 @@ struct fmi ...@@ -50,7 +50,7 @@ struct fmi
struct video_device vdev; struct video_device vdev;
int io; int io;
bool mute; bool mute;
unsigned long curfreq; /* freq in kHz */ u32 curfreq; /* freq in kHz */
struct mutex lock; struct mutex lock;
}; };
...@@ -118,6 +118,14 @@ static inline int fmi_getsigstr(struct fmi *fmi) ...@@ -118,6 +118,14 @@ static inline int fmi_getsigstr(struct fmi *fmi)
return (res & 2) ? 0 : 0xFFFF; 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, static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *v) struct v4l2_capability *v)
{ {
...@@ -158,14 +166,13 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -158,14 +166,13 @@ static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f) const struct v4l2_frequency *f)
{ {
struct fmi *fmi = video_drvdata(file); struct fmi *fmi = video_drvdata(file);
unsigned freq = f->frequency;
if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
return -EINVAL; return -EINVAL;
clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ);
/* rounding in steps of 800 to match the freq fmi->curfreq = f->frequency;
that will be used */ fmi_set_freq(fmi);
lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins);
return 0; return 0;
} }
...@@ -342,8 +349,10 @@ static int __init fmi_init(void) ...@@ -342,8 +349,10 @@ static int __init fmi_init(void)
mutex_init(&fmi->lock); mutex_init(&fmi->lock);
/* mute card - prevents noisy bootups */ /* mute card and set default frequency */
fmi_mute(fmi); fmi->mute = 1;
fmi->curfreq = RSF16_MINFREQ;
fmi_set_freq(fmi);
if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment