Lines Matching +full:reg +full:- +full:spacing

1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/media/radio/radio-si476x.c -- V4L2 driver for SI476X chips
19 #include <media/v4l2-common.h>
20 #include <media/v4l2-ioctl.h>
21 #include <media/v4l2-ctrls.h>
22 #include <media/v4l2-event.h>
23 #include <media/v4l2-device.h>
25 #include <media/drv-intf/si476x.h>
26 #include <linux/mfd/si476x-core.h>
40 #define DRIVER_NAME "si476x-radio"
157 * - Signal's SNR(in dBuV) must be lower than
159 * - Signal's RSSI(in dBuV) must be greater than
161 * - Signal's frequency deviation(in units of 2ppm) must not be
169 .min = -128,
178 .min = -128,
193 * #V4L2_CID_SI476X_HARMONICS_COUNT -- number of harmonics
194 * built-in power-line noise supression filter is to reject
195 * during AM-mode operation.
209 * #V4L2_CID_SI476X_DIVERSITY_MODE -- configuration which
212 * - #SI476X_IDX_PHDIV_DISABLED diversity mode disabled
213 * - #SI476X_IDX_PHDIV_PRIMARY_COMBINING diversity mode is
215 * - #SI476X_IDX_PHDIV_PRIMARY_ANTENNA diversity mode is
217 * - #SI476X_IDX_PHDIV_SECONDARY_ANTENNA diversity mode is
219 * - #SI476X_IDX_PHDIV_SECONDARY_COMBINING diversity mode is
229 .max = ARRAY_SIZE(phase_diversity_modes) - 1,
233 * #V4L2_CID_SI476X_INTERCHIP_LINK -- inter-chip link in
244 .name = "Inter-Chip Link",
254 * struct si476x_radio_ops - vtable of tuner functions
289 * struct si476x_radio - radio device
322 * si476x_vidioc_querycap - query device capabilities
329 strscpy(capability->driver, radio->v4l2dev.name, in si476x_radio_querycap()
330 sizeof(capability->driver)); in si476x_radio_querycap()
331 strscpy(capability->card, DRIVER_CARD, sizeof(capability->card)); in si476x_radio_querycap()
332 snprintf(capability->bus_info, sizeof(capability->bus_info), in si476x_radio_querycap()
333 "platform:%s", radio->v4l2dev.name); in si476x_radio_querycap()
343 if (band->tuner != 0) in si476x_radio_enum_freq_bands()
344 return -EINVAL; in si476x_radio_enum_freq_bands()
346 switch (radio->core->chip_id) { in si476x_radio_enum_freq_bands()
347 /* AM/FM tuners -- all bands are supported */ in si476x_radio_enum_freq_bands()
350 if (band->index < ARRAY_SIZE(si476x_bands)) { in si476x_radio_enum_freq_bands()
351 *band = si476x_bands[band->index]; in si476x_radio_enum_freq_bands()
354 err = -EINVAL; in si476x_radio_enum_freq_bands()
357 /* FM companion tuner chips -- only FM bands are in si476x_radio_enum_freq_bands()
360 if (band->index == SI476X_BAND_FM) { in si476x_radio_enum_freq_bands()
361 *band = si476x_bands[band->index]; in si476x_radio_enum_freq_bands()
364 err = -EINVAL; in si476x_radio_enum_freq_bands()
368 err = -EINVAL; in si476x_radio_enum_freq_bands()
389 if (tuner->index != 0) in si476x_radio_g_tuner()
390 return -EINVAL; in si476x_radio_g_tuner()
392 tuner->type = V4L2_TUNER_RADIO; in si476x_radio_g_tuner()
393 tuner->capability = V4L2_TUNER_CAP_LOW /* Measure frequencies in si476x_radio_g_tuner()
401 si476x_core_lock(radio->core); in si476x_radio_g_tuner()
403 if (si476x_core_is_a_secondary_tuner(radio->core)) { in si476x_radio_g_tuner()
404 strscpy(tuner->name, "FM (secondary)", sizeof(tuner->name)); in si476x_radio_g_tuner()
405 tuner->rxsubchans = 0; in si476x_radio_g_tuner()
406 tuner->rangelow = si476x_bands[SI476X_BAND_FM].rangelow; in si476x_radio_g_tuner()
407 } else if (si476x_core_has_am(radio->core)) { in si476x_radio_g_tuner()
408 if (si476x_core_is_a_primary_tuner(radio->core)) in si476x_radio_g_tuner()
409 strscpy(tuner->name, "AM/FM (primary)", in si476x_radio_g_tuner()
410 sizeof(tuner->name)); in si476x_radio_g_tuner()
412 strscpy(tuner->name, "AM/FM", sizeof(tuner->name)); in si476x_radio_g_tuner()
414 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO in si476x_radio_g_tuner()
416 tuner->capability |= V4L2_TUNER_CAP_RDS in si476x_radio_g_tuner()
420 tuner->rangelow = si476x_bands[SI476X_BAND_AM].rangelow; in si476x_radio_g_tuner()
422 strscpy(tuner->name, "FM", sizeof(tuner->name)); in si476x_radio_g_tuner()
423 tuner->rxsubchans = V4L2_TUNER_SUB_RDS; in si476x_radio_g_tuner()
424 tuner->capability |= V4L2_TUNER_CAP_RDS in si476x_radio_g_tuner()
427 tuner->rangelow = si476x_bands[SI476X_BAND_FM].rangelow; in si476x_radio_g_tuner()
430 tuner->audmode = radio->audmode; in si476x_radio_g_tuner()
432 tuner->afc = 1; in si476x_radio_g_tuner()
433 tuner->rangehigh = si476x_bands[SI476X_BAND_FM].rangehigh; in si476x_radio_g_tuner()
435 err = radio->ops->rsq_status(radio->core, in si476x_radio_g_tuner()
438 tuner->signal = 0; in si476x_radio_g_tuner()
441 * tuner->signal value range: 0x0000 .. 0xFFFF, in si476x_radio_g_tuner()
442 * report.rssi: -128 .. 127 in si476x_radio_g_tuner()
444 tuner->signal = (report.rssi + 128) * 257; in si476x_radio_g_tuner()
446 si476x_core_unlock(radio->core); in si476x_radio_g_tuner()
456 if (tuner->index != 0) in si476x_radio_s_tuner()
457 return -EINVAL; in si476x_radio_s_tuner()
459 if (tuner->audmode == V4L2_TUNER_MODE_MONO || in si476x_radio_s_tuner()
460 tuner->audmode == V4L2_TUNER_MODE_STEREO) in si476x_radio_s_tuner()
461 radio->audmode = tuner->audmode; in si476x_radio_s_tuner()
463 radio->audmode = V4L2_TUNER_MODE_STEREO; in si476x_radio_s_tuner()
495 radio->ops = &fm_ops; in si476x_radio_init_vtable()
499 radio->ops = &am_ops; in si476x_radio_init_vtable()
503 return -EINVAL; in si476x_radio_init_vtable()
523 args.freq = v4l2_to_si476x(radio->core, in si476x_radio_pretune()
525 retval = radio->ops->tune_freq(radio->core, &args); in si476x_radio_pretune()
528 args.freq = v4l2_to_si476x(radio->core, in si476x_radio_pretune()
530 retval = radio->ops->tune_freq(radio->core, &args); in si476x_radio_pretune()
534 retval = -EINVAL; in si476x_radio_pretune()
544 /* regcache_mark_dirty(radio->core->regmap); */ in si476x_radio_do_post_powerup_init()
545 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
551 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
557 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
567 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
573 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
580 if (si476x_core_has_diversity(radio->core)) { in si476x_radio_do_post_powerup_init()
581 err = si476x_core_cmd_fm_phase_diversity(radio->core, in si476x_radio_do_post_powerup_init()
582 radio->core->diversity_mode); in si476x_radio_do_post_powerup_init()
587 err = regcache_sync_region(radio->core->regmap, in si476x_radio_do_post_powerup_init()
608 if (func == radio->core->power_up_parameters.func) in si476x_radio_change_func()
612 err = si476x_core_stop(radio->core, soft); in si476x_radio_change_func()
619 err = si476x_core_stop(radio->core, soft); in si476x_radio_change_func()
626 radio->core->power_up_parameters.func = func; in si476x_radio_change_func()
628 err = si476x_core_start(radio->core, soft); in si476x_radio_change_func()
649 if (f->tuner != 0 || in si476x_radio_g_frequency()
650 f->type != V4L2_TUNER_RADIO) in si476x_radio_g_frequency()
651 return -EINVAL; in si476x_radio_g_frequency()
653 si476x_core_lock(radio->core); in si476x_radio_g_frequency()
655 if (radio->ops->rsq_status) { in si476x_radio_g_frequency()
665 err = radio->ops->rsq_status(radio->core, &args, &report); in si476x_radio_g_frequency()
667 f->frequency = si476x_to_v4l2(radio->core, in si476x_radio_g_frequency()
670 err = -EINVAL; in si476x_radio_g_frequency()
673 si476x_core_unlock(radio->core); in si476x_radio_g_frequency()
682 u32 freq = f->frequency; in si476x_radio_s_frequency()
693 if (f->tuner != 0 || in si476x_radio_s_frequency()
694 f->type != V4L2_TUNER_RADIO) in si476x_radio_s_frequency()
695 return -EINVAL; in si476x_radio_s_frequency()
697 si476x_core_lock(radio->core); in si476x_radio_s_frequency()
705 (!si476x_core_has_am(radio->core) || in si476x_radio_s_frequency()
706 si476x_core_is_a_secondary_tuner(radio->core))) { in si476x_radio_s_frequency()
707 err = -EINVAL; in si476x_radio_s_frequency()
718 args.freq = v4l2_to_si476x(radio->core, freq); in si476x_radio_s_frequency()
723 err = radio->ops->tune_freq(radio->core, &args); in si476x_radio_s_frequency()
726 si476x_core_unlock(radio->core); in si476x_radio_s_frequency()
735 u32 rangelow = seek->rangelow, rangehigh = seek->rangehigh; in si476x_radio_s_hw_freq_seek()
738 if (file->f_flags & O_NONBLOCK) in si476x_radio_s_hw_freq_seek()
739 return -EAGAIN; in si476x_radio_s_hw_freq_seek()
741 if (seek->tuner != 0 || in si476x_radio_s_hw_freq_seek()
742 seek->type != V4L2_TUNER_RADIO) in si476x_radio_s_hw_freq_seek()
743 return -EINVAL; in si476x_radio_s_hw_freq_seek()
745 si476x_core_lock(radio->core); in si476x_radio_s_hw_freq_seek()
748 err = regmap_read(radio->core->regmap, in si476x_radio_s_hw_freq_seek()
753 rangelow = si476x_to_v4l2(radio->core, rangelow); in si476x_radio_s_hw_freq_seek()
756 err = regmap_read(radio->core->regmap, in si476x_radio_s_hw_freq_seek()
761 rangehigh = si476x_to_v4l2(radio->core, rangehigh); in si476x_radio_s_hw_freq_seek()
765 err = -EINVAL; in si476x_radio_s_hw_freq_seek()
773 } else if (si476x_core_has_am(radio->core) && in si476x_radio_s_hw_freq_seek()
778 err = -EINVAL; in si476x_radio_s_hw_freq_seek()
786 if (seek->rangehigh) { in si476x_radio_s_hw_freq_seek()
787 err = regmap_write(radio->core->regmap, in si476x_radio_s_hw_freq_seek()
789 v4l2_to_si476x(radio->core, in si476x_radio_s_hw_freq_seek()
790 seek->rangehigh)); in si476x_radio_s_hw_freq_seek()
794 if (seek->rangelow) { in si476x_radio_s_hw_freq_seek()
795 err = regmap_write(radio->core->regmap, in si476x_radio_s_hw_freq_seek()
797 v4l2_to_si476x(radio->core, in si476x_radio_s_hw_freq_seek()
798 seek->rangelow)); in si476x_radio_s_hw_freq_seek()
802 if (seek->spacing) { in si476x_radio_s_hw_freq_seek()
803 err = regmap_write(radio->core->regmap, in si476x_radio_s_hw_freq_seek()
805 v4l2_to_si476x(radio->core, in si476x_radio_s_hw_freq_seek()
806 seek->spacing)); in si476x_radio_s_hw_freq_seek()
811 err = radio->ops->seek_start(radio->core, in si476x_radio_s_hw_freq_seek()
812 seek->seek_upward, in si476x_radio_s_hw_freq_seek()
813 seek->wrap_around); in si476x_radio_s_hw_freq_seek()
815 si476x_core_unlock(radio->core); in si476x_radio_s_hw_freq_seek()
825 struct si476x_radio *radio = v4l2_ctrl_handler_to_radio(ctrl->handler); in si476x_radio_g_volatile_ctrl()
827 si476x_core_lock(radio->core); in si476x_radio_g_volatile_ctrl()
829 switch (ctrl->id) { in si476x_radio_g_volatile_ctrl()
831 if (si476x_core_has_diversity(radio->core)) { in si476x_radio_g_volatile_ctrl()
832 if (radio->ops->phase_diversity) { in si476x_radio_g_volatile_ctrl()
833 retval = radio->ops->phase_div_status(radio->core); in si476x_radio_g_volatile_ctrl()
837 ctrl->val = !!SI476X_PHDIV_STATUS_LINK_LOCKED(retval); in si476x_radio_g_volatile_ctrl()
841 retval = -ENOTTY; in si476x_radio_g_volatile_ctrl()
845 retval = -EINVAL; in si476x_radio_g_volatile_ctrl()
848 retval = -EINVAL; in si476x_radio_g_volatile_ctrl()
851 si476x_core_unlock(radio->core); in si476x_radio_g_volatile_ctrl()
860 struct si476x_radio *radio = v4l2_ctrl_handler_to_radio(ctrl->handler); in si476x_radio_s_ctrl()
862 si476x_core_lock(radio->core); in si476x_radio_s_ctrl()
864 switch (ctrl->id) { in si476x_radio_s_ctrl()
866 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
869 ctrl->val); in si476x_radio_s_ctrl()
872 switch (ctrl->val) { in si476x_radio_s_ctrl()
874 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
880 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
886 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
892 retval = -EINVAL; in si476x_radio_s_ctrl()
897 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
899 ctrl->val); in si476x_radio_s_ctrl()
902 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
904 ctrl->val); in si476x_radio_s_ctrl()
907 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
909 ctrl->val); in si476x_radio_s_ctrl()
917 if (si476x_core_is_in_am_receiver_mode(radio->core)) in si476x_radio_s_ctrl()
918 regcache_cache_only(radio->core->regmap, true); in si476x_radio_s_ctrl()
920 if (ctrl->val) { in si476x_radio_s_ctrl()
921 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
923 radio->core->rds_fifo_depth); in si476x_radio_s_ctrl()
927 if (radio->core->client->irq) { in si476x_radio_s_ctrl()
928 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
936 retval = si476x_core_cmd_fm_rds_status(radio->core, in si476x_radio_s_ctrl()
944 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
949 retval = regmap_update_bits(radio->core->regmap, in si476x_radio_s_ctrl()
955 if (si476x_core_is_in_am_receiver_mode(radio->core)) in si476x_radio_s_ctrl()
956 regcache_cache_only(radio->core->regmap, false); in si476x_radio_s_ctrl()
959 retval = regmap_write(radio->core->regmap, in si476x_radio_s_ctrl()
961 ctrl->val); in si476x_radio_s_ctrl()
965 mode = si476x_phase_diversity_idx_to_mode(ctrl->val); in si476x_radio_s_ctrl()
967 if (mode == radio->core->diversity_mode) { in si476x_radio_s_ctrl()
972 if (si476x_core_is_in_am_receiver_mode(radio->core)) { in si476x_radio_s_ctrl()
977 radio->core->diversity_mode = mode; in si476x_radio_s_ctrl()
980 retval = radio->ops->phase_diversity(radio->core, mode); in si476x_radio_s_ctrl()
982 radio->core->diversity_mode = mode; in si476x_radio_s_ctrl()
987 retval = -EINVAL; in si476x_radio_s_ctrl()
991 si476x_core_unlock(radio->core); in si476x_radio_s_ctrl()
998 struct v4l2_dbg_register *reg) in si476x_radio_g_register() argument
1004 si476x_core_lock(radio->core); in si476x_radio_g_register()
1005 reg->size = 2; in si476x_radio_g_register()
1006 err = regmap_read(radio->core->regmap, in si476x_radio_g_register()
1007 (unsigned int)reg->reg, &value); in si476x_radio_g_register()
1008 reg->val = value; in si476x_radio_g_register()
1009 si476x_core_unlock(radio->core); in si476x_radio_g_register()
1014 const struct v4l2_dbg_register *reg) in si476x_radio_s_register() argument
1020 si476x_core_lock(radio->core); in si476x_radio_s_register()
1021 err = regmap_write(radio->core->regmap, in si476x_radio_s_register()
1022 (unsigned int)reg->reg, in si476x_radio_s_register()
1023 (unsigned int)reg->val); in si476x_radio_s_register()
1024 si476x_core_unlock(radio->core); in si476x_radio_s_register()
1040 si476x_core_lock(radio->core); in si476x_radio_fops_open()
1041 err = si476x_core_set_power_state(radio->core, in si476x_radio_fops_open()
1047 radio->core->power_up_parameters.func); in si476x_radio_fops_open()
1052 radio->core->power_up_parameters.func); in si476x_radio_fops_open()
1056 si476x_core_unlock(radio->core); in si476x_radio_fops_open()
1058 v4l2_ctrl_handler_setup(&radio->ctrl_handler); in si476x_radio_fops_open()
1064 si476x_core_set_power_state(radio->core, in si476x_radio_fops_open()
1067 si476x_core_unlock(radio->core); in si476x_radio_fops_open()
1078 atomic_read(&radio->core->is_alive)) in si476x_radio_fops_release()
1079 si476x_core_set_power_state(radio->core, in si476x_radio_fops_release()
1095 if (kfifo_is_empty(&radio->core->rds_fifo)) { in si476x_radio_fops_read()
1096 if (file->f_flags & O_NONBLOCK) in si476x_radio_fops_read()
1097 return -EWOULDBLOCK; in si476x_radio_fops_read()
1099 rval = wait_event_interruptible(radio->core->rds_read_queue, in si476x_radio_fops_read()
1100 (!kfifo_is_empty(&radio->core->rds_fifo) || in si476x_radio_fops_read()
1101 !atomic_read(&radio->core->is_alive))); in si476x_radio_fops_read()
1103 return -EINTR; in si476x_radio_fops_read()
1105 if (!atomic_read(&radio->core->is_alive)) in si476x_radio_fops_read()
1106 return -ENODEV; in si476x_radio_fops_read()
1109 fifo_len = kfifo_len(&radio->core->rds_fifo); in si476x_radio_fops_read()
1111 if (kfifo_to_user(&radio->core->rds_fifo, buf, in si476x_radio_fops_read()
1114 dev_warn(&radio->videodev.dev, in si476x_radio_fops_read()
1116 rval = -EIO; in si476x_radio_fops_read()
1132 if (atomic_read(&radio->core->is_alive)) in si476x_radio_fops_poll()
1133 poll_wait(file, &radio->core->rds_read_queue, pts); in si476x_radio_fops_poll()
1135 if (!atomic_read(&radio->core->is_alive)) in si476x_radio_fops_poll()
1138 if (!kfifo_is_empty(&radio->core->rds_fifo)) in si476x_radio_fops_poll()
1188 struct si476x_radio *radio = file->private_data; in si476x_radio_read_acf_blob()
1191 si476x_core_lock(radio->core); in si476x_radio_read_acf_blob()
1192 if (radio->ops->acf_status) in si476x_radio_read_acf_blob()
1193 err = radio->ops->acf_status(radio->core, &report); in si476x_radio_read_acf_blob()
1195 err = -ENOENT; in si476x_radio_read_acf_blob()
1196 si476x_core_unlock(radio->core); in si476x_radio_read_acf_blob()
1216 struct si476x_radio *radio = file->private_data; in si476x_radio_read_rds_blckcnt_blob()
1219 si476x_core_lock(radio->core); in si476x_radio_read_rds_blckcnt_blob()
1220 if (radio->ops->rds_blckcnt) in si476x_radio_read_rds_blckcnt_blob()
1221 err = radio->ops->rds_blckcnt(radio->core, true, in si476x_radio_read_rds_blckcnt_blob()
1224 err = -ENOENT; in si476x_radio_read_rds_blckcnt_blob()
1225 si476x_core_unlock(radio->core); in si476x_radio_read_rds_blckcnt_blob()
1245 struct si476x_radio *radio = file->private_data; in si476x_radio_read_agc_blob()
1248 si476x_core_lock(radio->core); in si476x_radio_read_agc_blob()
1249 if (radio->ops->rds_blckcnt) in si476x_radio_read_agc_blob()
1250 err = radio->ops->agc_status(radio->core, &report); in si476x_radio_read_agc_blob()
1252 err = -ENOENT; in si476x_radio_read_agc_blob()
1253 si476x_core_unlock(radio->core); in si476x_radio_read_agc_blob()
1273 struct si476x_radio *radio = file->private_data; in si476x_radio_read_rsq_blob()
1283 si476x_core_lock(radio->core); in si476x_radio_read_rsq_blob()
1284 if (radio->ops->rds_blckcnt) in si476x_radio_read_rsq_blob()
1285 err = radio->ops->rsq_status(radio->core, &args, &report); in si476x_radio_read_rsq_blob()
1287 err = -ENOENT; in si476x_radio_read_rsq_blob()
1288 si476x_core_unlock(radio->core); in si476x_radio_read_rsq_blob()
1308 struct si476x_radio *radio = file->private_data; in si476x_radio_read_rsq_primary_blob()
1318 si476x_core_lock(radio->core); in si476x_radio_read_rsq_primary_blob()
1319 if (radio->ops->rds_blckcnt) in si476x_radio_read_rsq_primary_blob()
1320 err = radio->ops->rsq_status(radio->core, &args, &report); in si476x_radio_read_rsq_primary_blob()
1322 err = -ENOENT; in si476x_radio_read_rsq_primary_blob()
1323 si476x_core_unlock(radio->core); in si476x_radio_read_rsq_primary_blob()
1341 radio->debugfs = debugfs_create_dir(dev_name(radio->v4l2dev.dev), NULL); in si476x_radio_init_debugfs()
1343 debugfs_create_file("acf", S_IRUGO, radio->debugfs, radio, in si476x_radio_init_debugfs()
1346 debugfs_create_file("rds_blckcnt", S_IRUGO, radio->debugfs, radio, in si476x_radio_init_debugfs()
1349 debugfs_create_file("agc", S_IRUGO, radio->debugfs, radio, in si476x_radio_init_debugfs()
1352 debugfs_create_file("rsq", S_IRUGO, radio->debugfs, radio, in si476x_radio_init_debugfs()
1355 debugfs_create_file("rsq_primary", S_IRUGO, radio->debugfs, radio, in si476x_radio_init_debugfs()
1366 ctrl = v4l2_ctrl_new_custom(&radio->ctrl_handler, in si476x_radio_add_new_custom()
1369 rval = radio->ctrl_handler.error; in si476x_radio_add_new_custom()
1371 dev_err(radio->v4l2dev.dev, in si476x_radio_add_new_custom()
1386 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL); in si476x_radio_probe()
1388 return -ENOMEM; in si476x_radio_probe()
1390 radio->core = i2c_mfd_cell_to_core(&pdev->dev); in si476x_radio_probe()
1392 v4l2_device_set_name(&radio->v4l2dev, DRIVER_NAME, &instance); in si476x_radio_probe()
1394 rval = v4l2_device_register(&pdev->dev, &radio->v4l2dev); in si476x_radio_probe()
1396 dev_err(&pdev->dev, "Cannot register v4l2_device.\n"); in si476x_radio_probe()
1400 memcpy(&radio->videodev, &si476x_viddev_template, in si476x_radio_probe()
1403 radio->videodev.v4l2_dev = &radio->v4l2dev; in si476x_radio_probe()
1404 radio->videodev.ioctl_ops = &si4761_ioctl_ops; in si476x_radio_probe()
1405 radio->videodev.device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO | in si476x_radio_probe()
1408 si476x_core_lock(radio->core); in si476x_radio_probe()
1409 if (!si476x_core_is_a_secondary_tuner(radio->core)) in si476x_radio_probe()
1410 radio->videodev.device_caps |= V4L2_CAP_RDS_CAPTURE | in si476x_radio_probe()
1412 si476x_core_unlock(radio->core); in si476x_radio_probe()
1414 video_set_drvdata(&radio->videodev, radio); in si476x_radio_probe()
1418 radio->v4l2dev.ctrl_handler = &radio->ctrl_handler; in si476x_radio_probe()
1419 v4l2_ctrl_handler_init(&radio->ctrl_handler, in si476x_radio_probe()
1422 if (si476x_core_has_am(radio->core)) { in si476x_radio_probe()
1423 ctrl = v4l2_ctrl_new_std_menu(&radio->ctrl_handler, in si476x_radio_probe()
1428 rval = radio->ctrl_handler.error; in si476x_radio_probe()
1430 dev_err(&pdev->dev, "Could not initialize V4L2_CID_POWER_LINE_FREQUENCY control %d\n", in si476x_radio_probe()
1453 ctrl = v4l2_ctrl_new_std_menu(&radio->ctrl_handler, in si476x_radio_probe()
1457 rval = radio->ctrl_handler.error; in si476x_radio_probe()
1459 dev_err(&pdev->dev, "Could not initialize V4L2_CID_TUNE_DEEMPHASIS control %d\n", in si476x_radio_probe()
1464 ctrl = v4l2_ctrl_new_std(&radio->ctrl_handler, &si476x_ctrl_ops, in si476x_radio_probe()
1467 rval = radio->ctrl_handler.error; in si476x_radio_probe()
1469 dev_err(&pdev->dev, "Could not initialize V4L2_CID_RDS_RECEPTION control %d\n", in si476x_radio_probe()
1474 if (si476x_core_has_diversity(radio->core)) { in si476x_radio_probe()
1476 si476x_phase_diversity_mode_to_idx(radio->core->diversity_mode); in si476x_radio_probe()
1487 rval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, -1); in si476x_radio_probe()
1489 dev_err(&pdev->dev, "Could not register video device\n"); in si476x_radio_probe()
1497 v4l2_ctrl_handler_free(radio->videodev.ctrl_handler); in si476x_radio_probe()
1505 v4l2_ctrl_handler_free(radio->videodev.ctrl_handler); in si476x_radio_remove()
1506 video_unregister_device(&radio->videodev); in si476x_radio_remove()
1507 v4l2_device_unregister(&radio->v4l2dev); in si476x_radio_remove()
1508 debugfs_remove_recursive(radio->debugfs); in si476x_radio_remove()
1513 MODULE_ALIAS("platform:si476x-radio");