Lines Matching full:radio
3 * drivers/media/radio/si470x/radio-si470x-common.c
5 * Driver for radios with Silicon Labs Si470x FM Radio Receivers
43 * - renamed FMRADIO to RADIO to cut line length (checkpatch.pl)
49 * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified
82 * - add support for KWorld USB FM Radio FM700
83 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
85 * - add support for DealExtreme USB Radio
102 #include "radio-si470x.h"
179 static int si470x_set_band(struct si470x_device *radio, int band) in si470x_set_band() argument
181 if (radio->band == band) in si470x_set_band()
184 radio->band = band; in si470x_set_band()
185 radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_BAND; in si470x_set_band()
186 radio->registers[SYSCONFIG2] |= radio->band << 6; in si470x_set_band()
187 return radio->set_register(radio, SYSCONFIG2); in si470x_set_band()
193 static int si470x_set_chan(struct si470x_device *radio, unsigned short chan) in si470x_set_chan() argument
199 retval = radio->get_register(radio, POWERCFG); in si470x_set_chan()
203 if ((radio->registers[POWERCFG] & (POWERCFG_ENABLE|POWERCFG_DMUTE)) in si470x_set_chan()
209 radio->registers[CHANNEL] &= ~CHANNEL_CHAN; in si470x_set_chan()
210 radio->registers[CHANNEL] |= CHANNEL_TUNE | chan; in si470x_set_chan()
211 retval = radio->set_register(radio, CHANNEL); in si470x_set_chan()
216 reinit_completion(&radio->completion); in si470x_set_chan()
217 time_left = wait_for_completion_timeout(&radio->completion, in si470x_set_chan()
222 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) in si470x_set_chan()
223 dev_warn(&radio->videodev.dev, "tune does not complete\n"); in si470x_set_chan()
225 dev_warn(&radio->videodev.dev, in si470x_set_chan()
229 radio->registers[CHANNEL] &= ~CHANNEL_TUNE; in si470x_set_chan()
230 retval = radio->set_register(radio, CHANNEL); in si470x_set_chan()
239 static unsigned int si470x_get_step(struct si470x_device *radio) in si470x_get_step() argument
242 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) { in si470x_get_step()
259 static int si470x_get_freq(struct si470x_device *radio, unsigned int *freq) in si470x_get_freq() argument
264 retval = radio->get_register(radio, READCHAN); in si470x_get_freq()
265 chan = radio->registers[READCHAN] & READCHAN_READCHAN; in si470x_get_freq()
268 *freq = chan * si470x_get_step(radio) + bands[radio->band].rangelow; in si470x_get_freq()
277 int si470x_set_freq(struct si470x_device *radio, unsigned int freq) in si470x_set_freq() argument
281 freq = clamp(freq, bands[radio->band].rangelow, in si470x_set_freq()
282 bands[radio->band].rangehigh); in si470x_set_freq()
284 chan = (freq - bands[radio->band].rangelow) / si470x_get_step(radio); in si470x_set_freq()
286 return si470x_set_chan(radio, chan); in si470x_set_freq()
294 static int si470x_set_seek(struct si470x_device *radio, in si470x_set_seek() argument
314 if (radio->band != band) { in si470x_set_seek()
315 retval = si470x_get_freq(radio, &freq); in si470x_set_seek()
318 retval = si470x_set_band(radio, band); in si470x_set_seek()
321 retval = si470x_set_freq(radio, freq); in si470x_set_seek()
327 radio->registers[POWERCFG] |= POWERCFG_SEEK; in si470x_set_seek()
329 radio->registers[POWERCFG] &= ~POWERCFG_SKMODE; in si470x_set_seek()
331 radio->registers[POWERCFG] |= POWERCFG_SKMODE; in si470x_set_seek()
333 radio->registers[POWERCFG] |= POWERCFG_SEEKUP; in si470x_set_seek()
335 radio->registers[POWERCFG] &= ~POWERCFG_SEEKUP; in si470x_set_seek()
336 retval = radio->set_register(radio, POWERCFG); in si470x_set_seek()
341 reinit_completion(&radio->completion); in si470x_set_seek()
342 time_left = wait_for_completion_timeout(&radio->completion, in si470x_set_seek()
347 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) in si470x_set_seek()
348 dev_warn(&radio->videodev.dev, "seek does not complete\n"); in si470x_set_seek()
349 if (radio->registers[STATUSRSSI] & STATUSRSSI_SF) in si470x_set_seek()
350 dev_warn(&radio->videodev.dev, in si470x_set_seek()
354 radio->registers[POWERCFG] &= ~POWERCFG_SEEK; in si470x_set_seek()
355 retval = radio->set_register(radio, POWERCFG); in si470x_set_seek()
365 * si470x_start - switch on radio
367 int si470x_start(struct si470x_device *radio) in si470x_start() argument
372 radio->registers[POWERCFG] = in si470x_start()
374 retval = radio->set_register(radio, POWERCFG); in si470x_start()
379 radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDSIEN | SYSCONFIG1_STCIEN | in si470x_start()
381 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_GPIO2; in si470x_start()
382 radio->registers[SYSCONFIG1] |= SYSCONFIG1_GPIO2_INT; in si470x_start()
384 radio->registers[SYSCONFIG1] |= SYSCONFIG1_DE; in si470x_start()
385 retval = radio->set_register(radio, SYSCONFIG1); in si470x_start()
390 radio->registers[SYSCONFIG2] = in si470x_start()
392 ((radio->band << 6) & SYSCONFIG2_BAND) |/* BAND */ in si470x_start()
395 retval = radio->set_register(radio, SYSCONFIG2); in si470x_start()
400 retval = si470x_set_chan(radio, in si470x_start()
401 radio->registers[CHANNEL] & CHANNEL_CHAN); in si470x_start()
410 * si470x_stop - switch off radio
412 int si470x_stop(struct si470x_device *radio) in si470x_stop() argument
417 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS; in si470x_stop()
418 retval = radio->set_register(radio, SYSCONFIG1); in si470x_stop()
423 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE; in si470x_stop()
425 radio->registers[POWERCFG] |= POWERCFG_ENABLE | POWERCFG_DISABLE; in si470x_stop()
426 retval = radio->set_register(radio, POWERCFG); in si470x_stop()
437 static int si470x_rds_on(struct si470x_device *radio) in si470x_rds_on() argument
442 radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDS; in si470x_rds_on()
443 retval = radio->set_register(radio, SYSCONFIG1); in si470x_rds_on()
445 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS; in si470x_rds_on()
462 struct si470x_device *radio = video_drvdata(file); in si470x_fops_read() local
467 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) in si470x_fops_read()
468 si470x_rds_on(radio); in si470x_fops_read()
471 while (radio->wr_index == radio->rd_index) { in si470x_fops_read()
476 if (wait_event_interruptible(radio->read_queue, in si470x_fops_read()
477 radio->wr_index != radio->rd_index) < 0) { in si470x_fops_read()
488 if (radio->rd_index == radio->wr_index) in si470x_fops_read()
492 if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3)) in si470x_fops_read()
497 radio->rd_index += 3; in si470x_fops_read()
498 if (radio->rd_index >= radio->buf_size) in si470x_fops_read()
499 radio->rd_index = 0; in si470x_fops_read()
518 struct si470x_device *radio = video_drvdata(file); in si470x_fops_poll() local
524 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) in si470x_fops_poll()
525 si470x_rds_on(radio); in si470x_fops_poll()
527 poll_wait(file, &radio->read_queue, pts); in si470x_fops_poll()
529 if (radio->rd_index != radio->wr_index) in si470x_fops_poll()
539 struct si470x_device *radio = video_drvdata(file); in si470x_fops_open() local
541 return radio->fops_open(file); in si470x_fops_open()
550 struct si470x_device *radio = video_drvdata(file); in si470x_fops_release() local
552 return radio->fops_release(file); in si470x_fops_release()
577 struct si470x_device *radio = in si470x_s_ctrl() local
582 radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME; in si470x_s_ctrl()
583 radio->registers[SYSCONFIG2] |= ctrl->val; in si470x_s_ctrl()
584 return radio->set_register(radio, SYSCONFIG2); in si470x_s_ctrl()
587 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE; in si470x_s_ctrl()
589 radio->registers[POWERCFG] |= POWERCFG_DMUTE; in si470x_s_ctrl()
590 return radio->set_register(radio, POWERCFG); in si470x_s_ctrl()
603 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_g_tuner() local
609 if (!radio->status_rssi_auto_update) { in si470x_vidioc_g_tuner()
610 retval = radio->get_register(radio, STATUSRSSI); in si470x_vidioc_g_tuner()
626 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 0) in si470x_vidioc_g_tuner()
636 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0) in si470x_vidioc_g_tuner()
643 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI); in si470x_vidioc_g_tuner()
651 tuner->afc = (radio->registers[STATUSRSSI] & STATUSRSSI_AFCRL) ? 1 : 0; in si470x_vidioc_g_tuner()
663 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_s_tuner() local
671 radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */ in si470x_vidioc_s_tuner()
675 radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */ in si470x_vidioc_s_tuner()
679 return radio->set_register(radio, POWERCFG); in si470x_vidioc_s_tuner()
684 * si470x_vidioc_g_frequency - get tuner or modulator radio frequency
689 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_g_frequency() local
695 return si470x_get_freq(radio, &freq->frequency); in si470x_vidioc_g_frequency()
700 * si470x_vidioc_s_frequency - set tuner or modulator radio frequency
705 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_s_frequency() local
711 if (freq->frequency < bands[radio->band].rangelow || in si470x_vidioc_s_frequency()
712 freq->frequency > bands[radio->band].rangehigh) { in si470x_vidioc_s_frequency()
714 retval = si470x_set_band(radio, 1); in si470x_vidioc_s_frequency()
718 return si470x_set_freq(radio, freq->frequency); in si470x_vidioc_s_frequency()
728 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_s_hw_freq_seek() local
736 return si470x_set_seek(radio, seek); in si470x_vidioc_s_hw_freq_seek()
761 struct si470x_device *radio = video_drvdata(file); in si470x_vidioc_querycap() local
763 return radio->vidioc_querycap(file, priv, capability); in si470x_vidioc_querycap()
793 MODULE_DESCRIPTION("Core radio driver for Si470x FM Radio Receivers");