Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Ondrej Zary and committed by
Mauro Carvalho Chehab
d9ec089e 9291682e

+17 -8
+17 -8
drivers/media/radio/radio-sf16fmi.c
··· 50 50 struct video_device vdev; 51 51 int io; 52 52 bool mute; 53 - unsigned long curfreq; /* freq in kHz */ 53 + u32 curfreq; /* freq in kHz */ 54 54 struct mutex lock; 55 55 }; 56 56 ··· 118 118 return (res & 2) ? 0 : 0xFFFF; 119 119 } 120 120 121 + static void fmi_set_freq(struct fmi *fmi) 122 + { 123 + fmi->curfreq = clamp(fmi->curfreq, RSF16_MINFREQ, RSF16_MAXFREQ); 124 + /* rounding in steps of 800 to match the freq 125 + that will be used */ 126 + lm7000_set_freq((fmi->curfreq / 800) * 800, fmi, fmi_set_pins); 127 + } 128 + 121 129 static int vidioc_querycap(struct file *file, void *priv, 122 130 struct v4l2_capability *v) 123 131 { ··· 166 158 const struct v4l2_frequency *f) 167 159 { 168 160 struct fmi *fmi = video_drvdata(file); 169 - unsigned freq = f->frequency; 170 161 171 162 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) 172 163 return -EINVAL; 173 - clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ); 174 - /* rounding in steps of 800 to match the freq 175 - that will be used */ 176 - lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins); 164 + 165 + fmi->curfreq = f->frequency; 166 + fmi_set_freq(fmi); 167 + 177 168 return 0; 178 169 } 179 170 ··· 349 342 350 343 mutex_init(&fmi->lock); 351 344 352 - /* mute card - prevents noisy bootups */ 353 - fmi_mute(fmi); 345 + /* mute card and set default frequency */ 346 + fmi->mute = 1; 347 + fmi->curfreq = RSF16_MINFREQ; 348 + fmi_set_freq(fmi); 354 349 355 350 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 356 351 v4l2_ctrl_handler_free(hdl);