Lines Matching +full:rx +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-only
4 * This sub-module of FM driver implements FM RX functionality.
17 fmdev->rx.rds.flag = FM_RDS_DISABLE; in fm_rx_reset_rds_cache()
18 fmdev->rx.rds.last_blk_idx = 0; in fm_rx_reset_rds_cache()
19 fmdev->rx.rds.wr_idx = 0; in fm_rx_reset_rds_cache()
20 fmdev->rx.rds.rd_idx = 0; in fm_rx_reset_rds_cache()
22 if (fmdev->rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON) in fm_rx_reset_rds_cache()
23 fmdev->irq_info.mask |= FM_LEV_EVENT; in fm_rx_reset_rds_cache()
28 fmdev->rx.stat_info.picode = FM_NO_PI_CODE; in fm_rx_reset_station_info()
29 fmdev->rx.stat_info.afcache_size = 0; in fm_rx_reset_station_info()
30 fmdev->rx.stat_info.af_list_max = 0; in fm_rx_reset_station_info()
41 if (freq < fmdev->rx.region.bot_freq || freq > fmdev->rx.region.top_freq) { in fm_rx_set_freq()
43 return -EINVAL; in fm_rx_set_freq()
46 /* Set audio enable */ in fm_rx_set_freq()
62 payload = (freq - fmdev->rx.region.bot_freq) / FM_FREQ_MUL; in fm_rx_set_freq()
69 /* Read flags - just to clear any pending interrupts if we had */ in fm_rx_set_freq()
74 /* Enable FR, BL interrupts */ in fm_rx_set_freq()
75 intr_flag = fmdev->irq_info.mask; in fm_rx_set_freq()
76 fmdev->irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT); in fm_rx_set_freq()
77 payload = fmdev->irq_info.mask; in fm_rx_set_freq()
91 init_completion(&fmdev->maintask_comp); in fm_rx_set_freq()
92 timeleft = wait_for_completion_timeout(&fmdev->maintask_comp, in fm_rx_set_freq()
97 ret = -ETIMEDOUT; in fm_rx_set_freq()
107 curr_frq_in_khz = (fmdev->rx.region.bot_freq + ((u32)curr_frq * FM_FREQ_MUL)); in fm_rx_set_freq()
115 fmdev->rx.freq = curr_frq_in_khz; in fm_rx_set_freq()
117 /* Re-enable default FM interrupts */ in fm_rx_set_freq()
118 fmdev->irq_info.mask = intr_flag; in fm_rx_set_freq()
119 payload = fmdev->irq_info.mask; in fm_rx_set_freq()
151 fmdev->rx.region.chanl_space = spacing * FM_FREQ_MUL; in fm_rx_set_channel_spacing()
180 last_frq = (fmdev->rx.region.top_freq - fmdev->rx.region.bot_freq) / FM_FREQ_MUL; in fm_rx_seek()
183 space_idx = fmdev->rx.region.chanl_space / FM_FREQ_MUL; in fm_rx_seek()
187 curr_frq - space_idx /* Seek Down */ ; in fm_rx_seek()
194 next_frq = last_frq - offset; in fm_rx_seek()
213 /* Read flags - just to clear any pending interrupts if we had */ in fm_rx_seek()
218 /* Enable FR, BL interrupts */ in fm_rx_seek()
219 intr_flag = fmdev->irq_info.mask; in fm_rx_seek()
220 fmdev->irq_info.mask = (FM_FR_EVENT | FM_BL_EVENT); in fm_rx_seek()
221 payload = fmdev->irq_info.mask; in fm_rx_seek()
235 init_completion(&fmdev->maintask_comp); in fm_rx_seek()
236 timeleft = wait_for_completion_timeout(&fmdev->maintask_comp, in fm_rx_seek()
241 return -ENODATA; in fm_rx_seek()
244 int_reason = fmdev->irq_info.flag & (FM_TUNE_COMPLETE | FM_BAND_LIMIT); in fm_rx_seek()
246 /* Re-enable default FM interrupts */ in fm_rx_seek()
247 fmdev->irq_info.mask = intr_flag; in fm_rx_seek()
248 payload = fmdev->irq_info.mask; in fm_rx_seek()
256 fmdev->rx.freq = seek_upward ? in fm_rx_seek()
257 fmdev->rx.region.top_freq : in fm_rx_seek()
258 fmdev->rx.region.bot_freq; in fm_rx_seek()
260 fmdev->rx.freq = seek_upward ? in fm_rx_seek()
261 fmdev->rx.region.bot_freq : in fm_rx_seek()
262 fmdev->rx.region.top_freq; in fm_rx_seek()
264 next_frq = (fmdev->rx.freq - in fm_rx_seek()
265 fmdev->rx.region.bot_freq) / FM_FREQ_MUL; in fm_rx_seek()
276 fmdev->rx.freq = (fmdev->rx.region.bot_freq + in fm_rx_seek()
292 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_set_volume()
293 return -EPERM; in fm_rx_set_volume()
296 fmerr("Volume is not within(%d-%d) range\n", in fm_rx_set_volume()
298 return -EINVAL; in fm_rx_set_volume()
308 fmdev->rx.volume = vol_to_set; in fm_rx_set_volume()
315 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_volume()
316 return -EPERM; in fm_rx_get_volume()
320 return -ENOMEM; in fm_rx_get_volume()
323 *curr_vol = fmdev->rx.volume / FM_RX_VOLUME_GAIN_STEP; in fm_rx_get_volume()
332 *bot_freq = fmdev->rx.region.bot_freq; in fm_rx_get_band_freq_range()
335 *top_freq = fmdev->rx.region.top_freq; in fm_rx_get_band_freq_range()
340 /* Returns current band index (0-Europe/US; 1-Japan) */
343 *region = fmdev->rx.region.fm_band; in fm_rx_get_region()
346 /* Sets band (0-Europe/US; 1-Japan) */
356 return -EINVAL; in fm_rx_set_region()
359 if (fmdev->rx.region.fm_band == region_to_set) { in fm_rx_set_region()
373 /* Check whether current RX frequency is within band boundary */ in fm_rx_set_region()
374 if (fmdev->rx.freq < fmdev->rx.region.bot_freq) in fm_rx_set_region()
375 new_frq = fmdev->rx.region.bot_freq; in fm_rx_set_region()
376 else if (fmdev->rx.freq > fmdev->rx.region.top_freq) in fm_rx_set_region()
377 new_frq = fmdev->rx.region.top_freq; in fm_rx_set_region()
382 /* Current RX frequency is not in range. So, update it */ in fm_rx_set_region()
392 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_mute_mode()
393 return -EPERM; in fm_rx_get_mute_mode()
397 return -ENOMEM; in fm_rx_get_mute_mode()
400 *curr_mute_mode = fmdev->rx.mute_mode; in fm_rx_get_mute_mode()
411 switch (fmdev->rx.mute_mode) { in fm_config_rx_mute_reg()
424 if (fmdev->rx.rf_depend_mute == FM_RX_RF_DEPENDENT_MUTE_ON) in fm_config_rx_mute_reg()
444 if (fmdev->rx.mute_mode == mute_mode_toset) in fm_rx_set_mute_mode()
447 org_state = fmdev->rx.mute_mode; in fm_rx_set_mute_mode()
448 fmdev->rx.mute_mode = mute_mode_toset; in fm_rx_set_mute_mode()
452 fmdev->rx.mute_mode = org_state; in fm_rx_set_mute_mode()
459 /* Gets RF dependent soft mute mode enable/disable status */
462 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_rfdepend_softmute()
463 return -EPERM; in fm_rx_get_rfdepend_softmute()
467 return -ENOMEM; in fm_rx_get_rfdepend_softmute()
470 *curr_mute_mode = fmdev->rx.rf_depend_mute; in fm_rx_get_rfdepend_softmute()
481 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_set_rfdepend_softmute()
482 return -EPERM; in fm_rx_set_rfdepend_softmute()
487 return -EINVAL; in fm_rx_set_rfdepend_softmute()
489 if (fmdev->rx.rf_depend_mute == rfdepend_mute) in fm_rx_set_rfdepend_softmute()
492 org_state = fmdev->rx.rf_depend_mute; in fm_rx_set_rfdepend_softmute()
493 fmdev->rx.rf_depend_mute = rfdepend_mute; in fm_rx_set_rfdepend_softmute()
497 fmdev->rx.rf_depend_mute = org_state; in fm_rx_set_rfdepend_softmute()
513 return -ENOMEM; in fm_rx_get_rssi_level()
538 return -EINVAL; in fm_rx_set_rssi_threshold()
546 fmdev->rx.rssi_threshold = rssi_lvl_toset; in fm_rx_set_rssi_threshold()
551 /* Returns current RX RSSI threshold value */
554 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_rssi_threshold()
555 return -EPERM; in fm_rx_get_rssi_threshold()
559 return -ENOMEM; in fm_rx_get_rssi_threshold()
562 *curr_rssi_lvl = fmdev->rx.rssi_threshold; in fm_rx_get_rssi_threshold()
567 /* Sets RX stereo/mono modes */
575 return -EINVAL; in fm_rx_set_stereo_mono()
595 /* Gets current RX stereo/mono mode */
604 return -ENOMEM; in fm_rx_get_stereo_mono()
617 /* Choose RX de-emphasis filter mode (50us/75us) */
623 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_set_deemphasis_mode()
624 return -EPERM; in fm_rx_set_deemphasis_mode()
628 fmerr("Invalid rx de-emphasis mode (%d)\n", mode); in fm_rx_set_deemphasis_mode()
629 return -EINVAL; in fm_rx_set_deemphasis_mode()
638 fmdev->rx.deemphasis_mode = mode; in fm_rx_set_deemphasis_mode()
643 /* Gets current RX de-emphasis filter mode */
646 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_deemph_mode()
647 return -EPERM; in fm_rx_get_deemph_mode()
651 return -ENOMEM; in fm_rx_get_deemph_mode()
654 *curr_deemphasis_mode = fmdev->rx.deemphasis_mode; in fm_rx_get_deemph_mode()
659 /* Enable/Disable RX RDS */
667 return -EINVAL; in fm_rx_set_rds_mode()
671 && fmdev->rx.rds.flag == FM_RDS_DISABLE) { in fm_rx_set_rds_mode()
672 /* Turn on RX RDS and RDS circuit */ in fm_rx_set_rds_mode()
686 /* Read flags - just to clear any pending interrupts. */ in fm_rx_set_rds_mode()
699 /* Enable RDS interrupt */ in fm_rx_set_rds_mode()
700 fmdev->irq_info.mask |= FM_RDS_EVENT; in fm_rx_set_rds_mode()
701 payload = fmdev->irq_info.mask; in fm_rx_set_rds_mode()
705 fmdev->irq_info.mask &= ~FM_RDS_EVENT; in fm_rx_set_rds_mode()
710 fmdev->rx.rds.flag = FM_RDS_ENABLE; in fm_rx_set_rds_mode()
712 && fmdev->rx.rds.flag == FM_RDS_ENABLE) { in fm_rx_set_rds_mode()
713 /* Turn off RX RDS */ in fm_rx_set_rds_mode()
721 fmdev->rx.rds.last_blk_idx = 0; in fm_rx_set_rds_mode()
722 fmdev->rx.rds.wr_idx = 0; in fm_rx_set_rds_mode()
723 fmdev->rx.rds.rd_idx = 0; in fm_rx_set_rds_mode()
727 fmdev->irq_info.mask &= ~(FM_RDS_EVENT); in fm_rx_set_rds_mode()
728 fmdev->rx.rds.flag = FM_RDS_DISABLE; in fm_rx_set_rds_mode()
734 /* Returns current RX RDS enable/disable status */
737 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_rds_mode()
738 return -EPERM; in fm_rx_get_rds_mode()
742 return -ENOMEM; in fm_rx_get_rds_mode()
745 *curr_rds_en_dis = fmdev->rx.rds.flag; in fm_rx_get_rds_mode()
756 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_set_rds_system()
757 return -EPERM; in fm_rx_set_rds_system()
761 return -EINVAL; in fm_rx_set_rds_system()
770 fmdev->rx.rds_mode = rds_mode; in fm_rx_set_rds_system()
781 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_set_af_switch()
782 return -EPERM; in fm_rx_set_af_switch()
787 return -EINVAL; in fm_rx_set_af_switch()
789 /* Enable/disable low RSSI interrupt based on af_mode */ in fm_rx_set_af_switch()
791 fmdev->irq_info.mask |= FM_LEV_EVENT; in fm_rx_set_af_switch()
793 fmdev->irq_info.mask &= ~FM_LEV_EVENT; in fm_rx_set_af_switch()
795 payload = fmdev->irq_info.mask; in fm_rx_set_af_switch()
801 fmdev->rx.af_mode = af_mode; in fm_rx_set_af_switch()
809 if (fmdev->curr_fmmode != FM_MODE_RX) in fm_rx_get_af_switch()
810 return -EPERM; in fm_rx_get_af_switch()
814 return -ENOMEM; in fm_rx_get_af_switch()
817 *af_mode = fmdev->rx.af_mode; in fm_rx_get_af_switch()