Lines Matching +full:low +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0
23 #include <media/v4l2-ctrls.h>
24 #include <media/v4l2-device.h>
30 #define mxm_dbg(ctx, fmt, arg...) dev_dbg(&ctx->client->dev, fmt, ## arg)
31 #define mxm_err(ctx, fmt, arg...) dev_err(&ctx->client->dev, fmt, ## arg)
264 struct v4l2_subdev sd; /* Sub-device */
273 struct v4l2_ctrl *hsls; /* High-side/Low-side polarity */
288 bool am_hiz; /* AM Hi-Z filter */
321 ret = regmap_read(ctx->regmap, idx, ®val); in max2175_read()
334 ret = regmap_write(ctx->regmap, idx, val); in max2175_write()
355 int ret = regmap_update_bits(ctx->regmap, idx, GENMASK(msb, lsb), in max2175_write_bits()
375 return regmap_read_poll_timeout(ctx->regmap, idx, val, in max2175_poll_timeout()
455 ctx->decim_ratio = 36; in max2175_load_fmeu_1p2()
470 ctx->decim_ratio = 1; in max2175_load_dab_1p2()
495 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
496 mxm_dbg(ctx, "set_bbfilter AM: rom %d\n", ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
498 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
499 mxm_dbg(ctx, "set_bbfilter DAB: rom %d\n", ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
501 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
502 mxm_dbg(ctx, "set_bbfilter FM: rom %d\n", ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
593 int_desired = lo_freq / ctx->xtal_freq; in max2175_set_lo_freq()
594 frac_desired = div64_ul((u64)(lo_freq % ctx->xtal_freq) << 20, in max2175_set_lo_freq()
595 ctx->xtal_freq); in max2175_set_lo_freq()
625 return div_s64(dividend - divisor / 2, divisor); in max2175_round_closest()
630 s32 clock_rate = ctx->xtal_freq / ctx->decim_ratio; in max2175_set_nco_freq()
638 nco_val_desired = 2LL * (clock_rate - abs_nco_freq); in max2175_set_nco_freq()
640 nco_val_desired = -nco_val_desired; in max2175_set_nco_freq()
682 adj_freq = freq - low_if_freq; in max2175_set_rf_freq_non_am_bands()
688 return max2175_set_nco_freq(ctx, -low_if_freq); in max2175_set_rf_freq_non_am_bands()
717 mxm_dbg(ctx, "tune_rf_freq: old %u new %llu\n", ctx->freq, freq); in max2175_tune_rf_freq()
718 ctx->freq = freq; in max2175_tune_rf_freq()
745 if (!ctx->master) in max2175_set_eu_rx_mode()
760 if (!ctx->master) in max2175_set_na_rx_mode()
763 ctx->decim_ratio = 27; in max2175_set_na_rx_mode()
773 mxm_dbg(ctx, "set_rx_mode: %u am_hiz %u\n", rx_mode, ctx->am_hiz); in max2175_set_rx_mode()
774 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_set_rx_mode()
779 if (ctx->am_hiz) { in max2175_set_rx_mode()
791 max2175_set_hsls(ctx, ctx->hsls->cur.val); in max2175_set_rx_mode()
794 max2175_i2s_enable(ctx, ctx->i2s_en->cur.val); in max2175_set_rx_mode()
796 ctx->mode_resolved = true; in max2175_set_rx_mode()
807 for (i = 0; i <= ctx->rx_mode->maximum; i++) { in max2175_rx_mode_from_freq()
808 if (ctx->rx_modes[i].band == band) { in max2175_rx_mode_from_freq()
816 return -EINVAL; in max2175_rx_mode_from_freq()
824 return (ctx->rx_modes[mode].band == band); in max2175_freq_rx_mode_valid()
840 /* Execute on-chip power-up/calibration */ in max2175_init_power_manager()
857 /* ADC Re-calibration */ in max2175_recalibrate_adc()
894 ctx->rom_bbf_bw_am = data & 0x0f; in max2175_load_from_rom()
898 ctx->rom_bbf_bw_fm = data & 0x0f; in max2175_load_from_rom()
899 ctx->rom_bbf_bw_dab = data >> 4; in max2175_load_from_rom()
906 if (ctx->am_hiz) { in max2175_load_from_rom()
931 ctx->decim_ratio = 36; in max2175_load_full_fm_eu_1p0()
942 ctx->decim_ratio = 27; in max2175_load_full_fm_na_1p0()
950 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_core_init()
956 if (!ctx->master) in max2175_core_init()
985 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_core_init()
1008 mxm_dbg(ctx, "s_ctrl_rx_mode: %u curr freq %u\n", rx_mode, ctx->freq); in max2175_s_ctrl_rx_mode()
1011 if (max2175_freq_rx_mode_valid(ctx, rx_mode, ctx->freq)) in max2175_s_ctrl_rx_mode()
1012 max2175_tune_rf_freq(ctx, ctx->freq, ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1015 max2175_tune_rf_freq(ctx, ctx->rx_modes[rx_mode].freq, in max2175_s_ctrl_rx_mode()
1016 ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1021 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_s_ctrl()
1023 mxm_dbg(ctx, "s_ctrl: id 0x%x, val %u\n", ctrl->id, ctrl->val); in max2175_s_ctrl()
1024 switch (ctrl->id) { in max2175_s_ctrl()
1026 max2175_i2s_enable(ctx, ctrl->val); in max2175_s_ctrl()
1029 max2175_set_hsls(ctx, ctrl->val); in max2175_s_ctrl()
1032 max2175_s_ctrl_rx_mode(ctx, ctrl->val); in max2175_s_ctrl()
1057 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_g_volatile_ctrl()
1059 switch (ctrl->id) { in max2175_g_volatile_ctrl()
1061 ctrl->val = max2175_get_lna_gain(ctx); in max2175_g_volatile_ctrl()
1064 ctrl->val = max2175_read_bits(ctx, 49, 4, 0); in max2175_g_volatile_ctrl()
1067 ctrl->val = (max2175_read_bits(ctx, 60, 7, 6) == 3); in max2175_g_volatile_ctrl()
1088 ctx->rx_mode->cur.val = rx_mode; in max2175_set_freq_and_mode()
1091 return max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_set_freq_and_mode()
1102 vf->frequency, ctx->freq, ctx->mode_resolved); in max2175_s_frequency()
1104 if (vf->tuner != 0) in max2175_s_frequency()
1105 return -EINVAL; in max2175_s_frequency()
1107 freq = clamp(vf->frequency, ctx->bands_rf->rangelow, in max2175_s_frequency()
1108 ctx->bands_rf->rangehigh); in max2175_s_frequency()
1111 if (ctx->mode_resolved && in max2175_s_frequency()
1112 max2175_freq_rx_mode_valid(ctx, ctx->rx_mode->cur.val, freq)) in max2175_s_frequency()
1113 ret = max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_s_frequency()
1119 ret, ctx->freq, ctx->mode_resolved, ctx->rx_mode->cur.val); in max2175_s_frequency()
1130 if (vf->tuner != 0) in max2175_g_frequency()
1131 return -EINVAL; in max2175_g_frequency()
1134 vf->type = V4L2_TUNER_RF; in max2175_g_frequency()
1135 vf->frequency = ctx->freq; in max2175_g_frequency()
1145 if (band->tuner != 0 || band->index != 0) in max2175_enum_freq_bands()
1146 return -EINVAL; in max2175_enum_freq_bands()
1148 *band = *ctx->bands_rf; in max2175_enum_freq_bands()
1153 static int max2175_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) in max2175_g_tuner() argument
1157 if (vt->index > 0) in max2175_g_tuner()
1158 return -EINVAL; in max2175_g_tuner()
1160 strscpy(vt->name, "RF", sizeof(vt->name)); in max2175_g_tuner()
1161 vt->type = V4L2_TUNER_RF; in max2175_g_tuner()
1162 vt->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS; in max2175_g_tuner()
1163 vt->rangelow = ctx->bands_rf->rangelow; in max2175_g_tuner()
1164 vt->rangehigh = ctx->bands_rf->rangehigh; in max2175_g_tuner()
1169 static int max2175_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt) in max2175_s_tuner() argument
1172 if (vt->index > 0) in max2175_s_tuner()
1173 return -EINVAL; in max2175_s_tuner()
1197 * Refer to Documentation/userspace-api/media/drivers/max2175.rst for more details.
1213 * Refer to Documentation/userspace-api/media/drivers/max2175.rst for more details.
1229 * Refer to Documentation/userspace-api/media/drivers/max2175.rst for more details.
1246 .max = ARRAY_SIZE(max2175_ctrl_eu_rx_modes) - 1,
1256 .max = ARRAY_SIZE(max2175_ctrl_na_rx_modes) - 1,
1267 *bits = load / 10 - 1; in max2175_refout_load_to_bits()
1269 return -EINVAL; in max2175_refout_load_to_bits()
1288 np = of_parse_phandle(client->dev.of_node, "maxim,master", 0); in max2175_probe()
1294 fwnode = of_fwnode_handle(client->dev.of_node); in max2175_probe()
1295 if (fwnode_property_present(fwnode, "maxim,am-hiz-filter")) in max2175_probe()
1298 if (!fwnode_property_read_u32(fwnode, "maxim,refout-load", in max2175_probe()
1303 dev_err(&client->dev, "invalid refout_load %u\n", in max2175_probe()
1305 return -EINVAL; in max2175_probe()
1309 clk = devm_clk_get(&client->dev, NULL); in max2175_probe()
1312 dev_err(&client->dev, "cannot get clock %d\n", ret); in max2175_probe()
1319 dev_err(&client->dev, "regmap init failed %d\n", ret); in max2175_probe()
1320 return -ENODEV; in max2175_probe()
1324 ctx = devm_kzalloc(&client->dev, sizeof(*ctx), GFP_KERNEL); in max2175_probe()
1326 return -ENOMEM; in max2175_probe()
1328 sd = &ctx->sd; in max2175_probe()
1329 ctx->master = master; in max2175_probe()
1330 ctx->am_hiz = am_hiz; in max2175_probe()
1331 ctx->mode_resolved = false; in max2175_probe()
1332 ctx->regmap = regmap; in max2175_probe()
1333 ctx->xtal_freq = clk_get_rate(clk); in max2175_probe()
1334 dev_info(&client->dev, "xtal freq %luHz\n", ctx->xtal_freq); in max2175_probe()
1337 ctx->client = client; in max2175_probe()
1339 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in max2175_probe()
1342 hdl = &ctx->ctrl_hdl; in max2175_probe()
1347 ctx->lna_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1350 ctx->lna_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1352 ctx->if_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1355 ctx->if_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1357 ctx->pll_lock = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1360 ctx->pll_lock->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1362 ctx->i2s_en = v4l2_ctrl_new_custom(hdl, &max2175_i2s_en, NULL); in max2175_probe()
1363 ctx->hsls = v4l2_ctrl_new_custom(hdl, &max2175_hsls, NULL); in max2175_probe()
1365 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_probe()
1366 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1368 ctx->rx_modes = eu_rx_modes; in max2175_probe()
1369 ctx->bands_rf = &eu_bands_rf; in max2175_probe()
1371 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1373 ctx->rx_modes = na_rx_modes; in max2175_probe()
1374 ctx->bands_rf = &na_bands_rf; in max2175_probe()
1376 ctx->sd.ctrl_handler = &ctx->ctrl_hdl; in max2175_probe()
1379 ctx->freq = ctx->bands_rf->rangelow; in max2175_probe()
1384 dev_err(&client->dev, "register subdev failed\n"); in max2175_probe()
1402 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_probe()
1412 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_remove()