Lines Matching +full:switch +full:- +full:frequency +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0-only
29 /* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
43 return -EIO; in fm_v4l2_fops_read()
46 if (mutex_lock_interruptible(&fmdev->mutex)) in fm_v4l2_fops_read()
47 return -ERESTARTSYS; in fm_v4l2_fops_read()
67 mutex_unlock(&fmdev->mutex); in fm_v4l2_fops_read()
80 rds.text[sizeof(rds.text) - 1] = '\0'; in fm_v4l2_fops_write()
84 return -EFAULT; in fm_v4l2_fops_write()
87 if (mutex_lock_interruptible(&fmdev->mutex)) in fm_v4l2_fops_write()
88 return -ERESTARTSYS; in fm_v4l2_fops_write()
91 mutex_unlock(&fmdev->mutex); in fm_v4l2_fops_write()
102 mutex_lock(&fmdev->mutex); in fm_v4l2_fops_poll()
104 mutex_unlock(&fmdev->mutex); in fm_v4l2_fops_poll()
123 return -EBUSY; in fm_v4l2_fops_open()
128 if (mutex_lock_interruptible(&fmdev->mutex)) in fm_v4l2_fops_open()
129 return -ERESTARTSYS; in fm_v4l2_fops_open()
146 mutex_unlock(&fmdev->mutex); in fm_v4l2_fops_open()
161 mutex_lock(&fmdev->mutex); in fm_v4l2_fops_release()
176 mutex_unlock(&fmdev->mutex); in fm_v4l2_fops_release()
184 strscpy(capability->driver, FM_DRV_NAME, sizeof(capability->driver)); in fm_v4l2_vidioc_querycap()
185 strscpy(capability->card, FM_DRV_CARD_SHORT_NAME, in fm_v4l2_vidioc_querycap()
186 sizeof(capability->card)); in fm_v4l2_vidioc_querycap()
187 sprintf(capability->bus_info, "UART"); in fm_v4l2_vidioc_querycap()
193 struct fmdev *fmdev = container_of(ctrl->handler, in fm_g_volatile_ctrl()
196 switch (ctrl->id) { in fm_g_volatile_ctrl()
198 ctrl->val = fm_tx_get_tune_cap_val(fmdev); in fm_g_volatile_ctrl()
201 fmwarn("%s: Unknown IOCTL: %d\n", __func__, ctrl->id); in fm_g_volatile_ctrl()
210 struct fmdev *fmdev = container_of(ctrl->handler, in fm_v4l2_s_ctrl()
213 switch (ctrl->id) { in fm_v4l2_s_ctrl()
215 return fm_rx_set_volume(fmdev, (u16)ctrl->val); in fm_v4l2_s_ctrl()
218 return fmc_set_mute_mode(fmdev, (u8)ctrl->val); in fm_v4l2_s_ctrl()
221 /* set TX power level - ext control */ in fm_v4l2_s_ctrl()
222 return fm_tx_set_pwr_lvl(fmdev, (u8)ctrl->val); in fm_v4l2_s_ctrl()
225 return fm_tx_set_preemph_filter(fmdev, (u8) ctrl->val); in fm_v4l2_s_ctrl()
228 return -EINVAL; in fm_v4l2_s_ctrl()
236 strscpy(audio->name, "Radio", sizeof(audio->name)); in fm_v4l2_vidioc_g_audio()
237 audio->capability = V4L2_AUDCAP_STEREO; in fm_v4l2_vidioc_g_audio()
245 if (audio->index != 0) in fm_v4l2_vidioc_s_audio()
246 return -EINVAL; in fm_v4l2_vidioc_s_audio()
262 if (tuner->index != 0) in fm_v4l2_vidioc_g_tuner()
263 return -EINVAL; in fm_v4l2_vidioc_g_tuner()
265 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_v4l2_vidioc_g_tuner()
266 return -EPERM; in fm_v4l2_vidioc_g_tuner()
280 strscpy(tuner->name, "FM", sizeof(tuner->name)); in fm_v4l2_vidioc_g_tuner()
281 tuner->type = V4L2_TUNER_RADIO; in fm_v4l2_vidioc_g_tuner()
282 /* Store rangelow and rangehigh freq in unit of 62.5 Hz */ in fm_v4l2_vidioc_g_tuner()
283 tuner->rangelow = bottom_freq * 16; in fm_v4l2_vidioc_g_tuner()
284 tuner->rangehigh = top_freq * 16; in fm_v4l2_vidioc_g_tuner()
285 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO | in fm_v4l2_vidioc_g_tuner()
286 ((fmdev->rx.rds.flag == FM_RDS_ENABLE) ? V4L2_TUNER_SUB_RDS : 0); in fm_v4l2_vidioc_g_tuner()
287 tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS | in fm_v4l2_vidioc_g_tuner()
291 tuner->audmode = (stereo_mono_mode ? in fm_v4l2_vidioc_g_tuner()
295 * Actual rssi value lies in between -128 to +127. in fm_v4l2_vidioc_g_tuner()
304 tuner->signal = rssilvl * 257; in fm_v4l2_vidioc_g_tuner()
305 tuner->afc = 0; in fm_v4l2_vidioc_g_tuner()
323 if (tuner->index != 0) in fm_v4l2_vidioc_s_tuner()
324 return -EINVAL; in fm_v4l2_vidioc_s_tuner()
326 aud_mode = (tuner->audmode == V4L2_TUNER_MODE_STEREO) ? in fm_v4l2_vidioc_s_tuner()
328 rds_mode = (tuner->rxsubchans & V4L2_TUNER_SUB_RDS) ? in fm_v4l2_vidioc_s_tuner()
331 if (fmdev->curr_fmmode != FM_MODE_RX) { in fm_v4l2_vidioc_s_tuner()
352 /* Get tuner or modulator radio frequency */
359 ret = fmc_get_freq(fmdev, &freq->frequency); in fm_v4l2_vidioc_g_freq()
361 fmerr("Failed to get frequency\n"); in fm_v4l2_vidioc_g_freq()
365 /* Frequency unit of 62.5 Hz*/ in fm_v4l2_vidioc_g_freq()
366 freq->frequency = (u32) freq->frequency * 16; in fm_v4l2_vidioc_g_freq()
371 /* Set tuner or modulator radio frequency */
378 * As V4L2_TUNER_CAP_LOW is set 1 user sends the frequency in fm_v4l2_vidioc_s_freq()
379 * in units of 62.5 Hz. in fm_v4l2_vidioc_s_freq()
381 return fmc_set_freq(fmdev, freq->frequency / 16); in fm_v4l2_vidioc_s_freq()
384 /* Set hardware frequency seek. If current mode is NOT RX, set it RX. */
391 if (file->f_flags & O_NONBLOCK) in fm_v4l2_vidioc_s_hw_freq_seek()
392 return -EWOULDBLOCK; in fm_v4l2_vidioc_s_hw_freq_seek()
394 if (fmdev->curr_fmmode != FM_MODE_RX) { in fm_v4l2_vidioc_s_hw_freq_seek()
402 ret = fm_rx_seek(fmdev, seek->seek_upward, seek->wrap_around, in fm_v4l2_vidioc_s_hw_freq_seek()
403 seek->spacing); in fm_v4l2_vidioc_s_hw_freq_seek()
405 fmerr("RX seek failed - %d\n", ret); in fm_v4l2_vidioc_s_hw_freq_seek()
415 if (mod->index != 0) in fm_v4l2_vidioc_g_modulator()
416 return -EINVAL; in fm_v4l2_vidioc_g_modulator()
418 if (fmdev->curr_fmmode != FM_MODE_TX) in fm_v4l2_vidioc_g_modulator()
419 return -EPERM; in fm_v4l2_vidioc_g_modulator()
421 mod->txsubchans = ((fmdev->tx_data.aud_mode == FM_STEREO_MODE) ? in fm_v4l2_vidioc_g_modulator()
423 ((fmdev->tx_data.rds.flag == FM_RDS_ENABLE) ? in fm_v4l2_vidioc_g_modulator()
426 mod->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS | in fm_v4l2_vidioc_g_modulator()
441 if (mod->index != 0) in fm_v4l2_vidioc_s_modulator()
442 return -EINVAL; in fm_v4l2_vidioc_s_modulator()
444 if (fmdev->curr_fmmode != FM_MODE_TX) { in fm_v4l2_vidioc_s_modulator()
452 aud_mode = (mod->txsubchans & V4L2_TUNER_SUB_STEREO) ? in fm_v4l2_vidioc_s_modulator()
454 rds_mode = (mod->txsubchans & V4L2_TUNER_SUB_RDS) ? in fm_v4l2_vidioc_s_modulator()
521 strscpy(fmdev->v4l2_dev.name, FM_DRV_NAME, in fm_v4l2_init_video_device()
522 sizeof(fmdev->v4l2_dev.name)); in fm_v4l2_init_video_device()
523 ret = v4l2_device_register(NULL, &fmdev->v4l2_dev); in fm_v4l2_init_video_device()
528 mutex_init(&fmdev->mutex); in fm_v4l2_init_video_device()
535 gradio_dev.lock = &fmdev->mutex; in fm_v4l2_init_video_device()
536 gradio_dev.v4l2_dev = &fmdev->v4l2_dev; in fm_v4l2_init_video_device()
540 v4l2_device_unregister(&fmdev->v4l2_dev); in fm_v4l2_init_video_device()
542 return -ENOMEM; in fm_v4l2_init_video_device()
545 fmdev->radio_dev = &gradio_dev; in fm_v4l2_init_video_device()
548 fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler; in fm_v4l2_init_video_device()
550 ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 5); in fm_v4l2_init_video_device()
553 v4l2_ctrl_handler_free(&fmdev->ctrl_handler); in fm_v4l2_init_video_device()
554 video_unregister_device(fmdev->radio_dev); in fm_v4l2_init_video_device()
555 v4l2_device_unregister(&fmdev->v4l2_dev); in fm_v4l2_init_video_device()
556 return -EBUSY; in fm_v4l2_init_video_device()
563 v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops, in fm_v4l2_init_video_device()
567 v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops, in fm_v4l2_init_video_device()
570 v4l2_ctrl_new_std_menu(&fmdev->ctrl_handler, &fm_ctrl_ops, in fm_v4l2_init_video_device()
574 v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops, in fm_v4l2_init_video_device()
578 ctrl = v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops, in fm_v4l2_init_video_device()
583 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in fm_v4l2_init_video_device()
596 v4l2_ctrl_handler_free(&fmdev->ctrl_handler); in fm_v4l2_deinit_video_device()
601 v4l2_device_unregister(&fmdev->v4l2_dev); in fm_v4l2_deinit_video_device()