2 * FM Driver for Connectivity chip of Texas Instruments.
3 * This sub-module of FM driver implements FM RX functionality.
5 * Copyright (C) 2011 Texas Instruments
6 * Author: Raja Mani <raja_mani@ti.com>
7 * Author: Manjunatha Halli <manjunatha_halli@ti.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "fmdrv_common.h"
28 void fm_rx_reset_rds_cache(struct fmdev
*fmdev
)
30 fmdev
->rx
.rds
.flag
= FM_RDS_DISABLE
;
31 fmdev
->rx
.rds
.last_blk_idx
= 0;
32 fmdev
->rx
.rds
.wr_idx
= 0;
33 fmdev
->rx
.rds
.rd_idx
= 0;
35 if (fmdev
->rx
.af_mode
== FM_RX_RDS_AF_SWITCH_MODE_ON
)
36 fmdev
->irq_info
.mask
|= FM_LEV_EVENT
;
39 void fm_rx_reset_station_info(struct fmdev
*fmdev
)
41 fmdev
->rx
.stat_info
.picode
= FM_NO_PI_CODE
;
42 fmdev
->rx
.stat_info
.afcache_size
= 0;
43 fmdev
->rx
.stat_info
.af_list_max
= 0;
46 int fm_rx_set_freq(struct fmdev
*fmdev
, u32 freq
)
48 unsigned long timeleft
;
49 u16 payload
, curr_frq
, intr_flag
;
54 if (freq
< fmdev
->rx
.region
.bot_freq
|| freq
> fmdev
->rx
.region
.top_freq
) {
55 fmerr("Invalid frequency %d\n", freq
);
59 /* Set audio enable */
60 payload
= FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG
;
62 ret
= fmc_send_cmd(fmdev
, AUDIO_ENABLE_SET
, REG_WR
, &payload
,
63 sizeof(payload
), NULL
, NULL
);
67 /* Set hilo to automatic selection */
68 payload
= FM_RX_IFFREQ_HILO_AUTOMATIC
;
69 ret
= fmc_send_cmd(fmdev
, HILO_SET
, REG_WR
, &payload
,
70 sizeof(payload
), NULL
, NULL
);
74 /* Calculate frequency index and set*/
75 payload
= (freq
- fmdev
->rx
.region
.bot_freq
) / FM_FREQ_MUL
;
77 ret
= fmc_send_cmd(fmdev
, FREQ_SET
, REG_WR
, &payload
,
78 sizeof(payload
), NULL
, NULL
);
82 /* Read flags - just to clear any pending interrupts if we had */
83 ret
= fmc_send_cmd(fmdev
, FLAG_GET
, REG_RD
, NULL
, 2, NULL
, NULL
);
87 /* Enable FR, BL interrupts */
88 intr_flag
= fmdev
->irq_info
.mask
;
89 fmdev
->irq_info
.mask
= (FM_FR_EVENT
| FM_BL_EVENT
);
90 payload
= fmdev
->irq_info
.mask
;
91 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
92 sizeof(payload
), NULL
, NULL
);
97 payload
= FM_TUNER_PRESET_MODE
;
98 ret
= fmc_send_cmd(fmdev
, TUNER_MODE_SET
, REG_WR
, &payload
,
99 sizeof(payload
), NULL
, NULL
);
103 /* Wait for tune ended interrupt */
104 init_completion(&fmdev
->maintask_comp
);
105 timeleft
= wait_for_completion_timeout(&fmdev
->maintask_comp
,
108 fmerr("Timeout(%d sec),didn't get tune ended int\n",
109 jiffies_to_msecs(FM_DRV_TX_TIMEOUT
) / 1000);
114 /* Read freq back to confirm */
115 ret
= fmc_send_cmd(fmdev
, FREQ_SET
, REG_RD
, NULL
, 2, &curr_frq
, &resp_len
);
119 curr_frq
= be16_to_cpu((__force __be16
)curr_frq
);
120 curr_frq_in_khz
= (fmdev
->rx
.region
.bot_freq
+ ((u32
)curr_frq
* FM_FREQ_MUL
));
122 if (curr_frq_in_khz
!= freq
) {
123 pr_info("Frequency is set to (%d) but "
124 "requested freq is (%d)\n", curr_frq_in_khz
, freq
);
127 /* Update local cache */
128 fmdev
->rx
.freq
= curr_frq_in_khz
;
130 /* Re-enable default FM interrupts */
131 fmdev
->irq_info
.mask
= intr_flag
;
132 payload
= fmdev
->irq_info
.mask
;
133 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
134 sizeof(payload
), NULL
, NULL
);
138 /* Reset RDS cache and current station pointers */
139 fm_rx_reset_rds_cache(fmdev
);
140 fm_rx_reset_station_info(fmdev
);
145 static int fm_rx_set_channel_spacing(struct fmdev
*fmdev
, u32 spacing
)
150 if (spacing
> 0 && spacing
<= 50000)
151 spacing
= FM_CHANNEL_SPACING_50KHZ
;
152 else if (spacing
> 50000 && spacing
<= 100000)
153 spacing
= FM_CHANNEL_SPACING_100KHZ
;
155 spacing
= FM_CHANNEL_SPACING_200KHZ
;
157 /* set channel spacing */
159 ret
= fmc_send_cmd(fmdev
, CHANL_BW_SET
, REG_WR
, &payload
,
160 sizeof(payload
), NULL
, NULL
);
164 fmdev
->rx
.region
.chanl_space
= spacing
* FM_FREQ_MUL
;
169 int fm_rx_seek(struct fmdev
*fmdev
, u32 seek_upward
,
170 u32 wrap_around
, u32 spacing
)
173 u16 curr_frq
, next_frq
, last_frq
;
174 u16 payload
, int_reason
, intr_flag
;
175 u16 offset
, space_idx
;
176 unsigned long timeleft
;
179 /* Set channel spacing */
180 ret
= fm_rx_set_channel_spacing(fmdev
, spacing
);
182 fmerr("Failed to set channel spacing\n");
186 /* Read the current frequency from chip */
187 ret
= fmc_send_cmd(fmdev
, FREQ_SET
, REG_RD
, NULL
,
188 sizeof(curr_frq
), &curr_frq
, &resp_len
);
192 curr_frq
= be16_to_cpu((__force __be16
)curr_frq
);
193 last_frq
= (fmdev
->rx
.region
.top_freq
- fmdev
->rx
.region
.bot_freq
) / FM_FREQ_MUL
;
195 /* Check the offset in order to be aligned to the channel spacing*/
196 space_idx
= fmdev
->rx
.region
.chanl_space
/ FM_FREQ_MUL
;
197 offset
= curr_frq
% space_idx
;
199 next_frq
= seek_upward
? curr_frq
+ space_idx
/* Seek Up */ :
200 curr_frq
- space_idx
/* Seek Down */ ;
203 * Add or subtract offset in order to stay aligned to the channel
206 if ((short)next_frq
< 0)
207 next_frq
= last_frq
- offset
;
208 else if (next_frq
> last_frq
)
209 next_frq
= 0 + offset
;
212 /* Set calculated next frequency to perform seek */
214 ret
= fmc_send_cmd(fmdev
, FREQ_SET
, REG_WR
, &payload
,
215 sizeof(payload
), NULL
, NULL
);
219 /* Set search direction (0:Seek Down, 1:Seek Up) */
220 payload
= (seek_upward
? FM_SEARCH_DIRECTION_UP
: FM_SEARCH_DIRECTION_DOWN
);
221 ret
= fmc_send_cmd(fmdev
, SEARCH_DIR_SET
, REG_WR
, &payload
,
222 sizeof(payload
), NULL
, NULL
);
226 /* Read flags - just to clear any pending interrupts if we had */
227 ret
= fmc_send_cmd(fmdev
, FLAG_GET
, REG_RD
, NULL
, 2, NULL
, NULL
);
231 /* Enable FR, BL interrupts */
232 intr_flag
= fmdev
->irq_info
.mask
;
233 fmdev
->irq_info
.mask
= (FM_FR_EVENT
| FM_BL_EVENT
);
234 payload
= fmdev
->irq_info
.mask
;
235 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
236 sizeof(payload
), NULL
, NULL
);
241 payload
= FM_TUNER_AUTONOMOUS_SEARCH_MODE
;
242 ret
= fmc_send_cmd(fmdev
, TUNER_MODE_SET
, REG_WR
, &payload
,
243 sizeof(payload
), NULL
, NULL
);
247 /* Wait for tune ended/band limit reached interrupt */
248 init_completion(&fmdev
->maintask_comp
);
249 timeleft
= wait_for_completion_timeout(&fmdev
->maintask_comp
,
250 FM_DRV_RX_SEEK_TIMEOUT
);
252 fmerr("Timeout(%d sec),didn't get tune ended int\n",
253 jiffies_to_msecs(FM_DRV_RX_SEEK_TIMEOUT
) / 1000);
257 int_reason
= fmdev
->irq_info
.flag
& (FM_TUNE_COMPLETE
| FM_BAND_LIMIT
);
259 /* Re-enable default FM interrupts */
260 fmdev
->irq_info
.mask
= intr_flag
;
261 payload
= fmdev
->irq_info
.mask
;
262 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
263 sizeof(payload
), NULL
, NULL
);
267 if (int_reason
& FM_BL_EVENT
) {
268 if (wrap_around
== 0) {
269 fmdev
->rx
.freq
= seek_upward
?
270 fmdev
->rx
.region
.top_freq
:
271 fmdev
->rx
.region
.bot_freq
;
273 fmdev
->rx
.freq
= seek_upward
?
274 fmdev
->rx
.region
.bot_freq
:
275 fmdev
->rx
.region
.top_freq
;
276 /* Calculate frequency index to write */
277 next_frq
= (fmdev
->rx
.freq
-
278 fmdev
->rx
.region
.bot_freq
) / FM_FREQ_MUL
;
282 /* Read freq to know where operation tune operation stopped */
283 ret
= fmc_send_cmd(fmdev
, FREQ_SET
, REG_RD
, NULL
, 2,
284 &curr_frq
, &resp_len
);
288 curr_frq
= be16_to_cpu((__force __be16
)curr_frq
);
289 fmdev
->rx
.freq
= (fmdev
->rx
.region
.bot_freq
+
290 ((u32
)curr_frq
* FM_FREQ_MUL
));
293 /* Reset RDS cache and current station pointers */
294 fm_rx_reset_rds_cache(fmdev
);
295 fm_rx_reset_station_info(fmdev
);
300 int fm_rx_set_volume(struct fmdev
*fmdev
, u16 vol_to_set
)
305 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
308 if (vol_to_set
> FM_RX_VOLUME_MAX
) {
309 fmerr("Volume is not within(%d-%d) range\n",
310 FM_RX_VOLUME_MIN
, FM_RX_VOLUME_MAX
);
313 vol_to_set
*= FM_RX_VOLUME_GAIN_STEP
;
315 payload
= vol_to_set
;
316 ret
= fmc_send_cmd(fmdev
, VOLUME_SET
, REG_WR
, &payload
,
317 sizeof(payload
), NULL
, NULL
);
321 fmdev
->rx
.volume
= vol_to_set
;
326 int fm_rx_get_volume(struct fmdev
*fmdev
, u16
*curr_vol
)
328 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
331 if (curr_vol
== NULL
) {
332 fmerr("Invalid memory\n");
336 *curr_vol
= fmdev
->rx
.volume
/ FM_RX_VOLUME_GAIN_STEP
;
341 /* To get current band's bottom and top frequency */
342 int fm_rx_get_band_freq_range(struct fmdev
*fmdev
, u32
*bot_freq
, u32
*top_freq
)
344 if (bot_freq
!= NULL
)
345 *bot_freq
= fmdev
->rx
.region
.bot_freq
;
347 if (top_freq
!= NULL
)
348 *top_freq
= fmdev
->rx
.region
.top_freq
;
353 /* Returns current band index (0-Europe/US; 1-Japan) */
354 void fm_rx_get_region(struct fmdev
*fmdev
, u8
*region
)
356 *region
= fmdev
->rx
.region
.fm_band
;
359 /* Sets band (0-Europe/US; 1-Japan) */
360 int fm_rx_set_region(struct fmdev
*fmdev
, u8 region_to_set
)
366 if (region_to_set
!= FM_BAND_EUROPE_US
&&
367 region_to_set
!= FM_BAND_JAPAN
) {
368 fmerr("Invalid band\n");
372 if (fmdev
->rx
.region
.fm_band
== region_to_set
) {
373 fmerr("Requested band is already configured\n");
377 /* Send cmd to set the band */
378 payload
= (u16
)region_to_set
;
379 ret
= fmc_send_cmd(fmdev
, BAND_SET
, REG_WR
, &payload
,
380 sizeof(payload
), NULL
, NULL
);
384 fmc_update_region_info(fmdev
, region_to_set
);
386 /* Check whether current RX frequency is within band boundary */
387 if (fmdev
->rx
.freq
< fmdev
->rx
.region
.bot_freq
)
388 new_frq
= fmdev
->rx
.region
.bot_freq
;
389 else if (fmdev
->rx
.freq
> fmdev
->rx
.region
.top_freq
)
390 new_frq
= fmdev
->rx
.region
.top_freq
;
393 fmdbg("Current freq is not within band limit boundary,"
394 "switching to %d KHz\n", new_frq
);
395 /* Current RX frequency is not in range. So, update it */
396 ret
= fm_rx_set_freq(fmdev
, new_frq
);
402 /* Reads current mute mode (Mute Off/On/Attenuate)*/
403 int fm_rx_get_mute_mode(struct fmdev
*fmdev
, u8
*curr_mute_mode
)
405 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
408 if (curr_mute_mode
== NULL
) {
409 fmerr("Invalid memory\n");
413 *curr_mute_mode
= fmdev
->rx
.mute_mode
;
418 static int fm_config_rx_mute_reg(struct fmdev
*fmdev
)
420 u16 payload
, muteval
;
424 switch (fmdev
->rx
.mute_mode
) {
426 muteval
= FM_RX_AC_MUTE_MODE
;
430 muteval
= FM_RX_UNMUTE_MODE
;
433 case FM_MUTE_ATTENUATE
:
434 muteval
= FM_RX_SOFT_MUTE_FORCE_MODE
;
437 if (fmdev
->rx
.rf_depend_mute
== FM_RX_RF_DEPENDENT_MUTE_ON
)
438 muteval
|= FM_RX_RF_DEP_MODE
;
440 muteval
&= ~FM_RX_RF_DEP_MODE
;
443 ret
= fmc_send_cmd(fmdev
, MUTE_STATUS_SET
, REG_WR
, &payload
,
444 sizeof(payload
), NULL
, NULL
);
451 /* Configures mute mode (Mute Off/On/Attenuate) */
452 int fm_rx_set_mute_mode(struct fmdev
*fmdev
, u8 mute_mode_toset
)
457 if (fmdev
->rx
.mute_mode
== mute_mode_toset
)
460 org_state
= fmdev
->rx
.mute_mode
;
461 fmdev
->rx
.mute_mode
= mute_mode_toset
;
463 ret
= fm_config_rx_mute_reg(fmdev
);
465 fmdev
->rx
.mute_mode
= org_state
;
472 /* Gets RF dependent soft mute mode enable/disable status */
473 int fm_rx_get_rfdepend_softmute(struct fmdev
*fmdev
, u8
*curr_mute_mode
)
475 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
478 if (curr_mute_mode
== NULL
) {
479 fmerr("Invalid memory\n");
483 *curr_mute_mode
= fmdev
->rx
.rf_depend_mute
;
488 /* Sets RF dependent soft mute mode */
489 int fm_rx_set_rfdepend_softmute(struct fmdev
*fmdev
, u8 rfdepend_mute
)
494 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
497 if (rfdepend_mute
!= FM_RX_RF_DEPENDENT_MUTE_ON
&&
498 rfdepend_mute
!= FM_RX_RF_DEPENDENT_MUTE_OFF
) {
499 fmerr("Invalid RF dependent soft mute\n");
502 if (fmdev
->rx
.rf_depend_mute
== rfdepend_mute
)
505 org_state
= fmdev
->rx
.rf_depend_mute
;
506 fmdev
->rx
.rf_depend_mute
= rfdepend_mute
;
508 ret
= fm_config_rx_mute_reg(fmdev
);
510 fmdev
->rx
.rf_depend_mute
= org_state
;
517 /* Returns the signal strength level of current channel */
518 int fm_rx_get_rssi_level(struct fmdev
*fmdev
, u16
*rssilvl
)
520 __be16 curr_rssi_lel
;
524 if (rssilvl
== NULL
) {
525 fmerr("Invalid memory\n");
528 /* Read current RSSI level */
529 ret
= fmc_send_cmd(fmdev
, RSSI_LVL_GET
, REG_RD
, NULL
, 2,
530 &curr_rssi_lel
, &resp_len
);
534 *rssilvl
= be16_to_cpu(curr_rssi_lel
);
540 * Sets the signal strength level that once reached
541 * will stop the auto search process
543 int fm_rx_set_rssi_threshold(struct fmdev
*fmdev
, short rssi_lvl_toset
)
548 if (rssi_lvl_toset
< FM_RX_RSSI_THRESHOLD_MIN
||
549 rssi_lvl_toset
> FM_RX_RSSI_THRESHOLD_MAX
) {
550 fmerr("Invalid RSSI threshold level\n");
553 payload
= (u16
)rssi_lvl_toset
;
554 ret
= fmc_send_cmd(fmdev
, SEARCH_LVL_SET
, REG_WR
, &payload
,
555 sizeof(payload
), NULL
, NULL
);
559 fmdev
->rx
.rssi_threshold
= rssi_lvl_toset
;
564 /* Returns current RX RSSI threshold value */
565 int fm_rx_get_rssi_threshold(struct fmdev
*fmdev
, short *curr_rssi_lvl
)
567 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
570 if (curr_rssi_lvl
== NULL
) {
571 fmerr("Invalid memory\n");
575 *curr_rssi_lvl
= fmdev
->rx
.rssi_threshold
;
580 /* Sets RX stereo/mono modes */
581 int fm_rx_set_stereo_mono(struct fmdev
*fmdev
, u16 mode
)
586 if (mode
!= FM_STEREO_MODE
&& mode
!= FM_MONO_MODE
) {
587 fmerr("Invalid mode\n");
591 /* Set stereo/mono mode */
593 ret
= fmc_send_cmd(fmdev
, MOST_MODE_SET
, REG_WR
, &payload
,
594 sizeof(payload
), NULL
, NULL
);
598 /* Set stereo blending mode */
599 payload
= FM_STEREO_SOFT_BLEND
;
600 ret
= fmc_send_cmd(fmdev
, MOST_BLEND_SET
, REG_WR
, &payload
,
601 sizeof(payload
), NULL
, NULL
);
608 /* Gets current RX stereo/mono mode */
609 int fm_rx_get_stereo_mono(struct fmdev
*fmdev
, u16
*mode
)
616 fmerr("Invalid memory\n");
620 ret
= fmc_send_cmd(fmdev
, MOST_MODE_SET
, REG_RD
, NULL
, 2,
621 &curr_mode
, &resp_len
);
625 *mode
= be16_to_cpu(curr_mode
);
630 /* Choose RX de-emphasis filter mode (50us/75us) */
631 int fm_rx_set_deemphasis_mode(struct fmdev
*fmdev
, u16 mode
)
636 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
639 if (mode
!= FM_RX_EMPHASIS_FILTER_50_USEC
&&
640 mode
!= FM_RX_EMPHASIS_FILTER_75_USEC
) {
641 fmerr("Invalid rx de-emphasis mode (%d)\n", mode
);
646 ret
= fmc_send_cmd(fmdev
, DEMPH_MODE_SET
, REG_WR
, &payload
,
647 sizeof(payload
), NULL
, NULL
);
651 fmdev
->rx
.deemphasis_mode
= mode
;
656 /* Gets current RX de-emphasis filter mode */
657 int fm_rx_get_deemph_mode(struct fmdev
*fmdev
, u16
*curr_deemphasis_mode
)
659 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
662 if (curr_deemphasis_mode
== NULL
) {
663 fmerr("Invalid memory\n");
667 *curr_deemphasis_mode
= fmdev
->rx
.deemphasis_mode
;
672 /* Enable/Disable RX RDS */
673 int fm_rx_set_rds_mode(struct fmdev
*fmdev
, u8 rds_en_dis
)
678 if (rds_en_dis
!= FM_RDS_ENABLE
&& rds_en_dis
!= FM_RDS_DISABLE
) {
679 fmerr("Invalid rds option\n");
683 if (rds_en_dis
== FM_RDS_ENABLE
684 && fmdev
->rx
.rds
.flag
== FM_RDS_DISABLE
) {
685 /* Turn on RX RDS and RDS circuit */
686 payload
= FM_RX_PWR_SET_FM_AND_RDS_BLK_ON
;
687 ret
= fmc_send_cmd(fmdev
, POWER_SET
, REG_WR
, &payload
,
688 sizeof(payload
), NULL
, NULL
);
692 /* Clear and reset RDS FIFO */
693 payload
= FM_RX_RDS_FLUSH_FIFO
;
694 ret
= fmc_send_cmd(fmdev
, RDS_CNTRL_SET
, REG_WR
, &payload
,
695 sizeof(payload
), NULL
, NULL
);
699 /* Read flags - just to clear any pending interrupts. */
700 ret
= fmc_send_cmd(fmdev
, FLAG_GET
, REG_RD
, NULL
, 2,
705 /* Set RDS FIFO threshold value */
706 payload
= FM_RX_RDS_FIFO_THRESHOLD
;
707 ret
= fmc_send_cmd(fmdev
, RDS_MEM_SET
, REG_WR
, &payload
,
708 sizeof(payload
), NULL
, NULL
);
712 /* Enable RDS interrupt */
713 fmdev
->irq_info
.mask
|= FM_RDS_EVENT
;
714 payload
= fmdev
->irq_info
.mask
;
715 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
716 sizeof(payload
), NULL
, NULL
);
718 fmdev
->irq_info
.mask
&= ~FM_RDS_EVENT
;
722 /* Update our local flag */
723 fmdev
->rx
.rds
.flag
= FM_RDS_ENABLE
;
724 } else if (rds_en_dis
== FM_RDS_DISABLE
725 && fmdev
->rx
.rds
.flag
== FM_RDS_ENABLE
) {
726 /* Turn off RX RDS */
727 payload
= FM_RX_PWR_SET_FM_ON_RDS_OFF
;
728 ret
= fmc_send_cmd(fmdev
, POWER_SET
, REG_WR
, &payload
,
729 sizeof(payload
), NULL
, NULL
);
733 /* Reset RDS pointers */
734 fmdev
->rx
.rds
.last_blk_idx
= 0;
735 fmdev
->rx
.rds
.wr_idx
= 0;
736 fmdev
->rx
.rds
.rd_idx
= 0;
737 fm_rx_reset_station_info(fmdev
);
739 /* Update RDS local cache */
740 fmdev
->irq_info
.mask
&= ~(FM_RDS_EVENT
);
741 fmdev
->rx
.rds
.flag
= FM_RDS_DISABLE
;
747 /* Returns current RX RDS enable/disable status */
748 int fm_rx_get_rds_mode(struct fmdev
*fmdev
, u8
*curr_rds_en_dis
)
750 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
753 if (curr_rds_en_dis
== NULL
) {
754 fmerr("Invalid memory\n");
758 *curr_rds_en_dis
= fmdev
->rx
.rds
.flag
;
763 /* Sets RDS operation mode (RDS/RDBS) */
764 int fm_rx_set_rds_system(struct fmdev
*fmdev
, u8 rds_mode
)
769 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
772 if (rds_mode
!= FM_RDS_SYSTEM_RDS
&& rds_mode
!= FM_RDS_SYSTEM_RBDS
) {
773 fmerr("Invalid rds mode\n");
776 /* Set RDS operation mode */
777 payload
= (u16
)rds_mode
;
778 ret
= fmc_send_cmd(fmdev
, RDS_SYSTEM_SET
, REG_WR
, &payload
,
779 sizeof(payload
), NULL
, NULL
);
783 fmdev
->rx
.rds_mode
= rds_mode
;
788 /* Configures Alternate Frequency switch mode */
789 int fm_rx_set_af_switch(struct fmdev
*fmdev
, u8 af_mode
)
794 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
797 if (af_mode
!= FM_RX_RDS_AF_SWITCH_MODE_ON
&&
798 af_mode
!= FM_RX_RDS_AF_SWITCH_MODE_OFF
) {
799 fmerr("Invalid af mode\n");
802 /* Enable/disable low RSSI interrupt based on af_mode */
803 if (af_mode
== FM_RX_RDS_AF_SWITCH_MODE_ON
)
804 fmdev
->irq_info
.mask
|= FM_LEV_EVENT
;
806 fmdev
->irq_info
.mask
&= ~FM_LEV_EVENT
;
808 payload
= fmdev
->irq_info
.mask
;
809 ret
= fmc_send_cmd(fmdev
, INT_MASK_SET
, REG_WR
, &payload
,
810 sizeof(payload
), NULL
, NULL
);
814 fmdev
->rx
.af_mode
= af_mode
;
819 /* Returns Alternate Frequency switch status */
820 int fm_rx_get_af_switch(struct fmdev
*fmdev
, u8
*af_mode
)
822 if (fmdev
->curr_fmmode
!= FM_MODE_RX
)
825 if (af_mode
== NULL
) {
826 fmerr("Invalid memory\n");
830 *af_mode
= fmdev
->rx
.af_mode
;