Lines Matching refs:fmdev
68 static void fm_irq_send_flag_getcmd(struct fmdev *);
69 static void fm_irq_handle_flag_getcmd_resp(struct fmdev *);
70 static void fm_irq_handle_hw_malfunction(struct fmdev *);
71 static void fm_irq_handle_rds_start(struct fmdev *);
72 static void fm_irq_send_rdsdata_getcmd(struct fmdev *);
73 static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *);
74 static void fm_irq_handle_rds_finish(struct fmdev *);
75 static void fm_irq_handle_tune_op_ended(struct fmdev *);
76 static void fm_irq_handle_power_enb(struct fmdev *);
77 static void fm_irq_handle_low_rssi_start(struct fmdev *);
78 static void fm_irq_afjump_set_pi(struct fmdev *);
79 static void fm_irq_handle_set_pi_resp(struct fmdev *);
80 static void fm_irq_afjump_set_pimask(struct fmdev *);
81 static void fm_irq_handle_set_pimask_resp(struct fmdev *);
82 static void fm_irq_afjump_setfreq(struct fmdev *);
83 static void fm_irq_handle_setfreq_resp(struct fmdev *);
84 static void fm_irq_afjump_enableint(struct fmdev *);
85 static void fm_irq_afjump_enableint_resp(struct fmdev *);
86 static void fm_irq_start_afjump(struct fmdev *);
87 static void fm_irq_handle_start_afjump_resp(struct fmdev *);
88 static void fm_irq_afjump_rd_freq(struct fmdev *);
89 static void fm_irq_afjump_rd_freq_resp(struct fmdev *);
90 static void fm_irq_handle_low_rssi_finish(struct fmdev *);
91 static void fm_irq_send_intmsk_cmd(struct fmdev *);
92 static void fm_irq_handle_intmsk_cmd_resp(struct fmdev *);
170 static inline void fm_irq_call(struct fmdev *fmdev) in fm_irq_call() argument
172 fmdev->irq_info.handlers[fmdev->irq_info.stage](fmdev); in fm_irq_call()
176 static inline void fm_irq_call_stage(struct fmdev *fmdev, u8 stage) in fm_irq_call_stage() argument
178 fmdev->irq_info.stage = stage; in fm_irq_call_stage()
179 fm_irq_call(fmdev); in fm_irq_call_stage()
182 static inline void fm_irq_timeout_stage(struct fmdev *fmdev, u8 stage) in fm_irq_timeout_stage() argument
184 fmdev->irq_info.stage = stage; in fm_irq_timeout_stage()
185 mod_timer(&fmdev->irq_info.timer, jiffies + FM_DRV_TX_TIMEOUT); in fm_irq_timeout_stage()
240 void fmc_update_region_info(struct fmdev *fmdev, u8 region_to_set) in fmc_update_region_info() argument
242 fmdev->rx.region = region_configs[region_to_set]; in fmc_update_region_info()
251 struct fmdev *fmdev; in recv_tasklet() local
258 fmdev = from_tasklet(fmdev, t, tx_task); in recv_tasklet()
259 irq_info = &fmdev->irq_info; in recv_tasklet()
261 while ((skb = skb_dequeue(&fmdev->rx_q))) { in recv_tasklet()
276 if (!test_bit(FM_INTTASK_RUNNING, &fmdev->flag)) { in recv_tasklet()
277 set_bit(FM_INTTASK_RUNNING, &fmdev->flag); in recv_tasklet()
287 irq_info->handlers[irq_info->stage](fmdev); in recv_tasklet()
289 set_bit(FM_INTTASK_SCHEDULE_PENDING, &fmdev->flag); in recv_tasklet()
294 else if (evt_hdr->op == fmdev->pre_op && fmdev->resp_comp != NULL) { in recv_tasklet()
296 spin_lock_irqsave(&fmdev->resp_skb_lock, flags); in recv_tasklet()
297 fmdev->resp_skb = skb; in recv_tasklet()
298 spin_unlock_irqrestore(&fmdev->resp_skb_lock, flags); in recv_tasklet()
299 complete(fmdev->resp_comp); in recv_tasklet()
301 fmdev->resp_comp = NULL; in recv_tasklet()
302 atomic_set(&fmdev->tx_cnt, 1); in recv_tasklet()
305 else if (evt_hdr->op == fmdev->pre_op && fmdev->resp_comp == NULL) { in recv_tasklet()
306 if (fmdev->resp_skb != NULL) in recv_tasklet()
309 spin_lock_irqsave(&fmdev->resp_skb_lock, flags); in recv_tasklet()
310 fmdev->resp_skb = skb; in recv_tasklet()
311 spin_unlock_irqrestore(&fmdev->resp_skb_lock, flags); in recv_tasklet()
314 irq_info->handlers[irq_info->stage](fmdev); in recv_tasklet()
317 atomic_set(&fmdev->tx_cnt, 1); in recv_tasklet()
326 if (num_fm_hci_cmds && atomic_read(&fmdev->tx_cnt)) in recv_tasklet()
327 if (!skb_queue_empty(&fmdev->tx_q)) in recv_tasklet()
328 tasklet_schedule(&fmdev->tx_task); in recv_tasklet()
335 struct fmdev *fmdev; in send_tasklet() local
339 fmdev = from_tasklet(fmdev, t, tx_task); in send_tasklet()
341 if (!atomic_read(&fmdev->tx_cnt)) in send_tasklet()
345 if ((jiffies - fmdev->last_tx_jiffies) > FM_DRV_TX_TIMEOUT) { in send_tasklet()
347 atomic_set(&fmdev->tx_cnt, 1); in send_tasklet()
351 skb = skb_dequeue(&fmdev->tx_q); in send_tasklet()
355 atomic_dec(&fmdev->tx_cnt); in send_tasklet()
356 fmdev->pre_op = fm_cb(skb)->fm_op; in send_tasklet()
358 if (fmdev->resp_comp != NULL) in send_tasklet()
361 fmdev->resp_comp = fm_cb(skb)->completion; in send_tasklet()
367 fmdev->resp_comp = NULL; in send_tasklet()
369 atomic_set(&fmdev->tx_cnt, 1); in send_tasklet()
371 fmdev->last_tx_jiffies = jiffies; in send_tasklet()
379 static int fm_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload, in fm_send_cmd() argument
390 if (test_bit(FM_FW_DW_INPROGRESS, &fmdev->flag) && payload == NULL) { in fm_send_cmd()
394 if (!test_bit(FM_FW_DW_INPROGRESS, &fmdev->flag)) in fm_send_cmd()
409 if (!test_bit(FM_FW_DW_INPROGRESS, &fmdev->flag) || in fm_send_cmd()
410 test_bit(FM_INTTASK_RUNNING, &fmdev->flag)) { in fm_send_cmd()
441 skb_queue_tail(&fmdev->tx_q, skb); in fm_send_cmd()
442 tasklet_schedule(&fmdev->tx_task); in fm_send_cmd()
448 int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload, in fmc_send_cmd() argument
456 init_completion(&fmdev->maintask_comp); in fmc_send_cmd()
457 ret = fm_send_cmd(fmdev, fm_op, type, payload, payload_len, in fmc_send_cmd()
458 &fmdev->maintask_comp); in fmc_send_cmd()
462 if (!wait_for_completion_timeout(&fmdev->maintask_comp, in fmc_send_cmd()
468 if (!fmdev->resp_skb) { in fmc_send_cmd()
472 spin_lock_irqsave(&fmdev->resp_skb_lock, flags); in fmc_send_cmd()
473 skb = fmdev->resp_skb; in fmc_send_cmd()
474 fmdev->resp_skb = NULL; in fmc_send_cmd()
475 spin_unlock_irqrestore(&fmdev->resp_skb_lock, flags); in fmc_send_cmd()
500 static inline int check_cmdresp_status(struct fmdev *fmdev, in check_cmdresp_status() argument
506 del_timer(&fmdev->irq_info.timer); in check_cmdresp_status()
508 spin_lock_irqsave(&fmdev->resp_skb_lock, flags); in check_cmdresp_status()
509 *skb = fmdev->resp_skb; in check_cmdresp_status()
510 fmdev->resp_skb = NULL; in check_cmdresp_status()
511 spin_unlock_irqrestore(&fmdev->resp_skb_lock, flags); in check_cmdresp_status()
518 mod_timer(&fmdev->irq_info.timer, jiffies + FM_DRV_TX_TIMEOUT); in check_cmdresp_status()
525 static inline void fm_irq_common_cmd_resp_helper(struct fmdev *fmdev, u8 stage) in fm_irq_common_cmd_resp_helper() argument
529 if (!check_cmdresp_status(fmdev, &skb)) in fm_irq_common_cmd_resp_helper()
530 fm_irq_call_stage(fmdev, stage); in fm_irq_common_cmd_resp_helper()
542 struct fmdev *fmdev; in int_timeout_handler() local
546 fmdev = from_timer(fmdev, t, irq_info.timer); in int_timeout_handler()
547 fmirq = &fmdev->irq_info; in int_timeout_handler()
558 fm_irq_call_stage(fmdev, FM_SEND_INTMSK_CMD_IDX); in int_timeout_handler()
562 static void fm_irq_send_flag_getcmd(struct fmdev *fmdev) in fm_irq_send_flag_getcmd() argument
567 if (!fm_send_cmd(fmdev, FLAG_GET, REG_RD, NULL, sizeof(flag), NULL)) in fm_irq_send_flag_getcmd()
568 fm_irq_timeout_stage(fmdev, FM_HANDLE_FLAG_GETCMD_RESP_IDX); in fm_irq_send_flag_getcmd()
571 static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev) in fm_irq_handle_flag_getcmd_resp() argument
576 if (check_cmdresp_status(fmdev, &skb)) in fm_irq_handle_flag_getcmd_resp()
580 if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag)) in fm_irq_handle_flag_getcmd_resp()
585 memcpy(&fmdev->irq_info.flag, skb->data, fm_evt_hdr->dlen); in fm_irq_handle_flag_getcmd_resp()
587 fmdev->irq_info.flag = be16_to_cpu((__force __be16)fmdev->irq_info.flag); in fm_irq_handle_flag_getcmd_resp()
588 fmdbg("irq: flag register(0x%x)\n", fmdev->irq_info.flag); in fm_irq_handle_flag_getcmd_resp()
591 fm_irq_call_stage(fmdev, FM_HW_MAL_FUNC_IDX); in fm_irq_handle_flag_getcmd_resp()
594 static void fm_irq_handle_hw_malfunction(struct fmdev *fmdev) in fm_irq_handle_hw_malfunction() argument
596 if (fmdev->irq_info.flag & FM_MAL_EVENT & fmdev->irq_info.mask) in fm_irq_handle_hw_malfunction()
600 fm_irq_call_stage(fmdev, FM_RDS_START_IDX); in fm_irq_handle_hw_malfunction()
603 static void fm_irq_handle_rds_start(struct fmdev *fmdev) in fm_irq_handle_rds_start() argument
605 if (fmdev->irq_info.flag & FM_RDS_EVENT & fmdev->irq_info.mask) { in fm_irq_handle_rds_start()
607 fmdev->irq_info.stage = FM_RDS_SEND_RDS_GETCMD_IDX; in fm_irq_handle_rds_start()
610 fmdev->irq_info.stage = FM_HW_TUNE_OP_ENDED_IDX; in fm_irq_handle_rds_start()
613 fm_irq_call(fmdev); in fm_irq_handle_rds_start()
616 static void fm_irq_send_rdsdata_getcmd(struct fmdev *fmdev) in fm_irq_send_rdsdata_getcmd() argument
619 if (!fm_send_cmd(fmdev, RDS_DATA_GET, REG_RD, NULL, in fm_irq_send_rdsdata_getcmd()
621 fm_irq_timeout_stage(fmdev, FM_RDS_HANDLE_RDS_GETCMD_RESP_IDX); in fm_irq_send_rdsdata_getcmd()
625 static void fm_rx_update_af_cache(struct fmdev *fmdev, u8 af) in fm_rx_update_af_cache() argument
627 struct tuned_station_info *stat_info = &fmdev->rx.stat_info; in fm_rx_update_af_cache()
628 u8 reg_idx = fmdev->rx.region.fm_band; in fm_rx_update_af_cache()
634 fmdev->rx.stat_info.af_list_max = (af - FM_RDS_1_AF_FOLLOWS + 1); in fm_rx_update_af_cache()
635 fmdev->rx.stat_info.afcache_size = 0; in fm_rx_update_af_cache()
636 fmdbg("No of expected AF : %d\n", fmdev->rx.stat_info.af_list_max); in fm_rx_update_af_cache()
647 freq = fmdev->rx.region.bot_freq + (af * 100); in fm_rx_update_af_cache()
648 if (freq == fmdev->rx.freq) { in fm_rx_update_af_cache()
650 fmdev->rx.freq, freq); in fm_rx_update_af_cache()
678 static void fm_rdsparse_swapbytes(struct fmdev *fmdev, in fm_rdsparse_swapbytes() argument
689 if (fmdev->asci_id != 0x6350) { in fm_rdsparse_swapbytes()
698 static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *fmdev) in fm_irq_handle_rdsdata_getcmd_resp() argument
702 struct fm_rds *rds = &fmdev->rx.rds; in fm_irq_handle_rdsdata_getcmd_resp()
709 if (check_cmdresp_status(fmdev, &skb)) in fm_irq_handle_rdsdata_getcmd_resp()
749 fm_rdsparse_swapbytes(fmdev, &rds_fmt); in fm_irq_handle_rdsdata_getcmd_resp()
756 if (fmdev->rx.stat_info.picode != cur_picode) in fm_irq_handle_rdsdata_getcmd_resp()
757 fmdev->rx.stat_info.picode = cur_picode; in fm_irq_handle_rdsdata_getcmd_resp()
767 fm_rx_update_af_cache(fmdev, rds_fmt.data.group0A.af[0]); in fm_irq_handle_rdsdata_getcmd_resp()
768 fm_rx_update_af_cache(fmdev, rds_fmt.data.group0A.af[1]); in fm_irq_handle_rdsdata_getcmd_resp()
779 spin_lock_irqsave(&fmdev->rds_buff_lock, flags); in fm_irq_handle_rdsdata_getcmd_resp()
807 spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); in fm_irq_handle_rdsdata_getcmd_resp()
813 fm_irq_call_stage(fmdev, FM_RDS_FINISH_IDX); in fm_irq_handle_rdsdata_getcmd_resp()
816 static void fm_irq_handle_rds_finish(struct fmdev *fmdev) in fm_irq_handle_rds_finish() argument
818 fm_irq_call_stage(fmdev, FM_HW_TUNE_OP_ENDED_IDX); in fm_irq_handle_rds_finish()
821 static void fm_irq_handle_tune_op_ended(struct fmdev *fmdev) in fm_irq_handle_tune_op_ended() argument
823 if (fmdev->irq_info.flag & (FM_FR_EVENT | FM_BL_EVENT) & fmdev-> in fm_irq_handle_tune_op_ended()
826 if (test_and_clear_bit(FM_AF_SWITCH_INPROGRESS, &fmdev->flag)) { in fm_irq_handle_tune_op_ended()
827 fmdev->irq_info.stage = FM_AF_JUMP_RD_FREQ_IDX; in fm_irq_handle_tune_op_ended()
829 complete(&fmdev->maintask_comp); in fm_irq_handle_tune_op_ended()
830 fmdev->irq_info.stage = FM_HW_POWER_ENB_IDX; in fm_irq_handle_tune_op_ended()
833 fmdev->irq_info.stage = FM_HW_POWER_ENB_IDX; in fm_irq_handle_tune_op_ended()
835 fm_irq_call(fmdev); in fm_irq_handle_tune_op_ended()
838 static void fm_irq_handle_power_enb(struct fmdev *fmdev) in fm_irq_handle_power_enb() argument
840 if (fmdev->irq_info.flag & FM_POW_ENB_EVENT) { in fm_irq_handle_power_enb()
842 complete(&fmdev->maintask_comp); in fm_irq_handle_power_enb()
845 fm_irq_call_stage(fmdev, FM_LOW_RSSI_START_IDX); in fm_irq_handle_power_enb()
848 static void fm_irq_handle_low_rssi_start(struct fmdev *fmdev) in fm_irq_handle_low_rssi_start() argument
850 if ((fmdev->rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON) && in fm_irq_handle_low_rssi_start()
851 (fmdev->irq_info.flag & FM_LEV_EVENT & fmdev->irq_info.mask) && in fm_irq_handle_low_rssi_start()
852 (fmdev->rx.freq != FM_UNDEFINED_FREQ) && in fm_irq_handle_low_rssi_start()
853 (fmdev->rx.stat_info.afcache_size != 0)) { in fm_irq_handle_low_rssi_start()
857 fmdev->irq_info.mask &= ~FM_LEV_EVENT; in fm_irq_handle_low_rssi_start()
859 fmdev->rx.afjump_idx = 0; in fm_irq_handle_low_rssi_start()
860 fmdev->rx.freq_before_jump = fmdev->rx.freq; in fm_irq_handle_low_rssi_start()
861 fmdev->irq_info.stage = FM_AF_JUMP_SETPI_IDX; in fm_irq_handle_low_rssi_start()
864 fmdev->irq_info.stage = FM_SEND_INTMSK_CMD_IDX; in fm_irq_handle_low_rssi_start()
867 fm_irq_call(fmdev); in fm_irq_handle_low_rssi_start()
870 static void fm_irq_afjump_set_pi(struct fmdev *fmdev) in fm_irq_afjump_set_pi() argument
875 payload = fmdev->rx.stat_info.picode; in fm_irq_afjump_set_pi()
876 if (!fm_send_cmd(fmdev, RDS_PI_SET, REG_WR, &payload, sizeof(payload), NULL)) in fm_irq_afjump_set_pi()
877 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_HANDLE_SETPI_RESP_IDX); in fm_irq_afjump_set_pi()
880 static void fm_irq_handle_set_pi_resp(struct fmdev *fmdev) in fm_irq_handle_set_pi_resp() argument
882 fm_irq_common_cmd_resp_helper(fmdev, FM_AF_JUMP_SETPI_MASK_IDX); in fm_irq_handle_set_pi_resp()
890 static void fm_irq_afjump_set_pimask(struct fmdev *fmdev) in fm_irq_afjump_set_pimask() argument
895 if (!fm_send_cmd(fmdev, RDS_PI_MASK_SET, REG_WR, &payload, sizeof(payload), NULL)) in fm_irq_afjump_set_pimask()
896 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_HANDLE_SETPI_MASK_RESP_IDX); in fm_irq_afjump_set_pimask()
899 static void fm_irq_handle_set_pimask_resp(struct fmdev *fmdev) in fm_irq_handle_set_pimask_resp() argument
901 fm_irq_common_cmd_resp_helper(fmdev, FM_AF_JUMP_SET_AF_FREQ_IDX); in fm_irq_handle_set_pimask_resp()
904 static void fm_irq_afjump_setfreq(struct fmdev *fmdev) in fm_irq_afjump_setfreq() argument
909 fmdbg("Switch to %d KHz\n", fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx]); in fm_irq_afjump_setfreq()
910 frq_index = (fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx] - in fm_irq_afjump_setfreq()
911 fmdev->rx.region.bot_freq) / FM_FREQ_MUL; in fm_irq_afjump_setfreq()
914 if (!fm_send_cmd(fmdev, AF_FREQ_SET, REG_WR, &payload, sizeof(payload), NULL)) in fm_irq_afjump_setfreq()
915 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_HANDLE_SET_AFFREQ_RESP_IDX); in fm_irq_afjump_setfreq()
918 static void fm_irq_handle_setfreq_resp(struct fmdev *fmdev) in fm_irq_handle_setfreq_resp() argument
920 fm_irq_common_cmd_resp_helper(fmdev, FM_AF_JUMP_ENABLE_INT_IDX); in fm_irq_handle_setfreq_resp()
923 static void fm_irq_afjump_enableint(struct fmdev *fmdev) in fm_irq_afjump_enableint() argument
929 if (!fm_send_cmd(fmdev, INT_MASK_SET, REG_WR, &payload, sizeof(payload), NULL)) in fm_irq_afjump_enableint()
930 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_ENABLE_INT_RESP_IDX); in fm_irq_afjump_enableint()
933 static void fm_irq_afjump_enableint_resp(struct fmdev *fmdev) in fm_irq_afjump_enableint_resp() argument
935 fm_irq_common_cmd_resp_helper(fmdev, FM_AF_JUMP_START_AFJUMP_IDX); in fm_irq_afjump_enableint_resp()
938 static void fm_irq_start_afjump(struct fmdev *fmdev) in fm_irq_start_afjump() argument
943 if (!fm_send_cmd(fmdev, TUNER_MODE_SET, REG_WR, &payload, in fm_irq_start_afjump()
945 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_HANDLE_START_AFJUMP_RESP_IDX); in fm_irq_start_afjump()
948 static void fm_irq_handle_start_afjump_resp(struct fmdev *fmdev) in fm_irq_handle_start_afjump_resp() argument
952 if (check_cmdresp_status(fmdev, &skb)) in fm_irq_handle_start_afjump_resp()
955 fmdev->irq_info.stage = FM_SEND_FLAG_GETCMD_IDX; in fm_irq_handle_start_afjump_resp()
956 set_bit(FM_AF_SWITCH_INPROGRESS, &fmdev->flag); in fm_irq_handle_start_afjump_resp()
957 clear_bit(FM_INTTASK_RUNNING, &fmdev->flag); in fm_irq_handle_start_afjump_resp()
960 static void fm_irq_afjump_rd_freq(struct fmdev *fmdev) in fm_irq_afjump_rd_freq() argument
964 if (!fm_send_cmd(fmdev, FREQ_SET, REG_RD, NULL, sizeof(payload), NULL)) in fm_irq_afjump_rd_freq()
965 fm_irq_timeout_stage(fmdev, FM_AF_JUMP_RD_FREQ_RESP_IDX); in fm_irq_afjump_rd_freq()
968 static void fm_irq_afjump_rd_freq_resp(struct fmdev *fmdev) in fm_irq_afjump_rd_freq_resp() argument
974 if (check_cmdresp_status(fmdev, &skb)) in fm_irq_afjump_rd_freq_resp()
981 curr_freq = fmdev->rx.region.bot_freq + ((u32)read_freq * FM_FREQ_MUL); in fm_irq_afjump_rd_freq_resp()
983 jumped_freq = fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx]; in fm_irq_afjump_rd_freq_resp()
986 if ((curr_freq != fmdev->rx.freq_before_jump) && (curr_freq == jumped_freq)) { in fm_irq_afjump_rd_freq_resp()
988 fmdev->rx.freq = curr_freq; in fm_irq_afjump_rd_freq_resp()
989 fm_rx_reset_rds_cache(fmdev); in fm_irq_afjump_rd_freq_resp()
992 if (fmdev->rx.af_mode == FM_RX_RDS_AF_SWITCH_MODE_ON) in fm_irq_afjump_rd_freq_resp()
993 fmdev->irq_info.mask |= FM_LEV_EVENT; in fm_irq_afjump_rd_freq_resp()
995 fmdev->irq_info.stage = FM_LOW_RSSI_FINISH_IDX; in fm_irq_afjump_rd_freq_resp()
997 fmdev->rx.afjump_idx++; in fm_irq_afjump_rd_freq_resp()
1000 if (fmdev->rx.afjump_idx >= fmdev->rx.stat_info.afcache_size) { in fm_irq_afjump_rd_freq_resp()
1002 fmdev->irq_info.stage = FM_LOW_RSSI_FINISH_IDX; in fm_irq_afjump_rd_freq_resp()
1006 fmdev->irq_info.stage = FM_AF_JUMP_SETPI_IDX; in fm_irq_afjump_rd_freq_resp()
1009 fm_irq_call(fmdev); in fm_irq_afjump_rd_freq_resp()
1012 static void fm_irq_handle_low_rssi_finish(struct fmdev *fmdev) in fm_irq_handle_low_rssi_finish() argument
1014 fm_irq_call_stage(fmdev, FM_SEND_INTMSK_CMD_IDX); in fm_irq_handle_low_rssi_finish()
1017 static void fm_irq_send_intmsk_cmd(struct fmdev *fmdev) in fm_irq_send_intmsk_cmd() argument
1022 payload = fmdev->irq_info.mask; in fm_irq_send_intmsk_cmd()
1024 if (!fm_send_cmd(fmdev, INT_MASK_SET, REG_WR, &payload, in fm_irq_send_intmsk_cmd()
1026 fm_irq_timeout_stage(fmdev, FM_HANDLE_INTMSK_CMD_RESP_IDX); in fm_irq_send_intmsk_cmd()
1029 static void fm_irq_handle_intmsk_cmd_resp(struct fmdev *fmdev) in fm_irq_handle_intmsk_cmd_resp() argument
1033 if (check_cmdresp_status(fmdev, &skb)) in fm_irq_handle_intmsk_cmd_resp()
1039 fmdev->irq_info.stage = FM_SEND_FLAG_GETCMD_IDX; in fm_irq_handle_intmsk_cmd_resp()
1042 if (test_and_clear_bit(FM_INTTASK_SCHEDULE_PENDING, &fmdev->flag)) in fm_irq_handle_intmsk_cmd_resp()
1043 fmdev->irq_info.handlers[fmdev->irq_info.stage](fmdev); in fm_irq_handle_intmsk_cmd_resp()
1045 clear_bit(FM_INTTASK_RUNNING, &fmdev->flag); in fm_irq_handle_intmsk_cmd_resp()
1049 int fmc_is_rds_data_available(struct fmdev *fmdev, struct file *file, in fmc_is_rds_data_available() argument
1052 poll_wait(file, &fmdev->rx.rds.read_queue, pts); in fmc_is_rds_data_available()
1053 if (fmdev->rx.rds.rd_idx != fmdev->rx.rds.wr_idx) in fmc_is_rds_data_available()
1060 int fmc_transfer_rds_from_internal_buff(struct fmdev *fmdev, struct file *file, in fmc_transfer_rds_from_internal_buff() argument
1068 if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) { in fmc_transfer_rds_from_internal_buff()
1072 ret = wait_event_interruptible(fmdev->rx.rds.read_queue, in fmc_transfer_rds_from_internal_buff()
1073 (fmdev->rx.rds.wr_idx != fmdev->rx.rds.rd_idx)); in fmc_transfer_rds_from_internal_buff()
1084 spin_lock_irqsave(&fmdev->rds_buff_lock, flags); in fmc_transfer_rds_from_internal_buff()
1086 if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) { in fmc_transfer_rds_from_internal_buff()
1087 spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); in fmc_transfer_rds_from_internal_buff()
1090 memcpy(tmpbuf, &fmdev->rx.rds.buff[fmdev->rx.rds.rd_idx], in fmc_transfer_rds_from_internal_buff()
1092 fmdev->rx.rds.rd_idx += FM_RDS_BLK_SIZE; in fmc_transfer_rds_from_internal_buff()
1093 if (fmdev->rx.rds.rd_idx >= fmdev->rx.rds.buf_size) in fmc_transfer_rds_from_internal_buff()
1094 fmdev->rx.rds.rd_idx = 0; in fmc_transfer_rds_from_internal_buff()
1096 spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); in fmc_transfer_rds_from_internal_buff()
1108 int fmc_set_freq(struct fmdev *fmdev, u32 freq_to_set) in fmc_set_freq() argument
1110 switch (fmdev->curr_fmmode) { in fmc_set_freq()
1112 return fm_rx_set_freq(fmdev, freq_to_set); in fmc_set_freq()
1115 return fm_tx_set_freq(fmdev, freq_to_set); in fmc_set_freq()
1122 int fmc_get_freq(struct fmdev *fmdev, u32 *cur_tuned_frq) in fmc_get_freq() argument
1124 if (fmdev->rx.freq == FM_UNDEFINED_FREQ) { in fmc_get_freq()
1133 switch (fmdev->curr_fmmode) { in fmc_get_freq()
1135 *cur_tuned_frq = fmdev->rx.freq; in fmc_get_freq()
1148 int fmc_set_region(struct fmdev *fmdev, u8 region_to_set) in fmc_set_region() argument
1150 switch (fmdev->curr_fmmode) { in fmc_set_region()
1152 return fm_rx_set_region(fmdev, region_to_set); in fmc_set_region()
1155 return fm_tx_set_region(fmdev, region_to_set); in fmc_set_region()
1162 int fmc_set_mute_mode(struct fmdev *fmdev, u8 mute_mode_toset) in fmc_set_mute_mode() argument
1164 switch (fmdev->curr_fmmode) { in fmc_set_mute_mode()
1166 return fm_rx_set_mute_mode(fmdev, mute_mode_toset); in fmc_set_mute_mode()
1169 return fm_tx_set_mute_mode(fmdev, mute_mode_toset); in fmc_set_mute_mode()
1176 int fmc_set_stereo_mono(struct fmdev *fmdev, u16 mode) in fmc_set_stereo_mono() argument
1178 switch (fmdev->curr_fmmode) { in fmc_set_stereo_mono()
1180 return fm_rx_set_stereo_mono(fmdev, mode); in fmc_set_stereo_mono()
1183 return fm_tx_set_stereo_mono(fmdev, mode); in fmc_set_stereo_mono()
1190 int fmc_set_rds_mode(struct fmdev *fmdev, u8 rds_en_dis) in fmc_set_rds_mode() argument
1192 switch (fmdev->curr_fmmode) { in fmc_set_rds_mode()
1194 return fm_rx_set_rds_mode(fmdev, rds_en_dis); in fmc_set_rds_mode()
1197 return fm_tx_set_rds_mode(fmdev, rds_en_dis); in fmc_set_rds_mode()
1205 static int fm_power_down(struct fmdev *fmdev) in fm_power_down() argument
1210 if (!test_bit(FM_CORE_READY, &fmdev->flag)) { in fm_power_down()
1214 if (fmdev->curr_fmmode == FM_MODE_OFF) { in fm_power_down()
1220 ret = fmc_send_cmd(fmdev, FM_POWER_MODE, REG_WR, &payload, in fm_power_down()
1225 return fmc_release(fmdev); in fm_power_down()
1229 static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name) in fm_download_firmware() argument
1239 set_bit(FM_FW_DW_INPROGRESS, &fmdev->flag); in fm_download_firmware()
1242 &fmdev->radio_dev->dev); in fm_download_firmware()
1269 ret = fmc_send_cmd(fmdev, 0, 0, action->data, in fm_download_firmware()
1289 clear_bit(FM_FW_DW_INPROGRESS, &fmdev->flag); in fm_download_firmware()
1295 static int load_default_rx_configuration(struct fmdev *fmdev) in load_default_rx_configuration() argument
1299 ret = fm_rx_set_volume(fmdev, FM_DEFAULT_RX_VOLUME); in load_default_rx_configuration()
1303 return fm_rx_set_rssi_threshold(fmdev, FM_DEFAULT_RSSI_THRESHOLD); in load_default_rx_configuration()
1307 static int fm_power_up(struct fmdev *fmdev, u8 mode) in fm_power_up() argument
1323 ret = fmc_prepare(fmdev); in fm_power_up()
1330 if (fmc_send_cmd(fmdev, FM_POWER_MODE, REG_WR, &payload, in fm_power_up()
1337 if (fmc_send_cmd(fmdev, ASIC_ID_GET, REG_RD, NULL, in fm_power_up()
1341 if (fmc_send_cmd(fmdev, ASIC_VER_GET, REG_RD, NULL, in fm_power_up()
1351 ret = fm_download_firmware(fmdev, fw_name); in fm_power_up()
1360 ret = fm_download_firmware(fmdev, fw_name); in fm_power_up()
1367 return fmc_release(fmdev); in fm_power_up()
1371 int fmc_set_mode(struct fmdev *fmdev, u8 fm_mode) in fmc_set_mode() argument
1379 if (fmdev->curr_fmmode == fm_mode) { in fmc_set_mode()
1386 ret = fm_power_down(fmdev); in fmc_set_mode()
1396 if (fmdev->curr_fmmode != FM_MODE_OFF) { in fmc_set_mode()
1397 ret = fm_power_down(fmdev); in fmc_set_mode()
1404 ret = fm_power_up(fmdev, fm_mode); in fmc_set_mode()
1410 fmdev->curr_fmmode = fm_mode; in fmc_set_mode()
1413 if (fmdev->curr_fmmode == FM_MODE_RX) { in fmc_set_mode()
1415 ret = load_default_rx_configuration(fmdev); in fmc_set_mode()
1424 int fmc_get_mode(struct fmdev *fmdev, u8 *fmmode) in fmc_get_mode() argument
1426 if (!test_bit(FM_CORE_READY, &fmdev->flag)) { in fmc_get_mode()
1435 *fmmode = fmdev->curr_fmmode; in fmc_get_mode()
1442 struct fmdev *fmdev; in fm_st_receive() local
1444 fmdev = (struct fmdev *)arg; in fm_st_receive()
1457 skb_queue_tail(&fmdev->rx_q, skb); in fm_st_receive()
1458 tasklet_schedule(&fmdev->rx_task); in fm_st_receive()
1469 struct fmdev *fmdev; in fm_st_reg_comp_cb() local
1471 fmdev = (struct fmdev *)arg; in fm_st_reg_comp_cb()
1472 fmdev->streg_cbdata = data; in fm_st_reg_comp_cb()
1480 int fmc_prepare(struct fmdev *fmdev) in fmc_prepare() argument
1485 if (test_bit(FM_CORE_READY, &fmdev->flag)) { in fmc_prepare()
1495 fm_st_proto.priv_data = fmdev; in fmc_prepare()
1506 fmdev->streg_cbdata = -EINPROGRESS; in fmc_prepare()
1515 if (fmdev->streg_cbdata != 0) { in fmc_prepare()
1517 fmdev->streg_cbdata); in fmc_prepare()
1537 spin_lock_init(&fmdev->rds_buff_lock); in fmc_prepare()
1538 spin_lock_init(&fmdev->resp_skb_lock); in fmc_prepare()
1541 skb_queue_head_init(&fmdev->tx_q); in fmc_prepare()
1542 tasklet_setup(&fmdev->tx_task, send_tasklet); in fmc_prepare()
1545 skb_queue_head_init(&fmdev->rx_q); in fmc_prepare()
1546 tasklet_setup(&fmdev->rx_task, recv_tasklet); in fmc_prepare()
1548 fmdev->irq_info.stage = 0; in fmc_prepare()
1549 atomic_set(&fmdev->tx_cnt, 1); in fmc_prepare()
1550 fmdev->resp_comp = NULL; in fmc_prepare()
1552 timer_setup(&fmdev->irq_info.timer, int_timeout_handler, 0); in fmc_prepare()
1554 fmdev->irq_info.mask = FM_MAL_EVENT; in fmc_prepare()
1557 fmdev->rx.region = region_configs[default_radio_region]; in fmc_prepare()
1559 fmdev->rx.mute_mode = FM_MUTE_OFF; in fmc_prepare()
1560 fmdev->rx.rf_depend_mute = FM_RX_RF_DEPENDENT_MUTE_OFF; in fmc_prepare()
1561 fmdev->rx.rds.flag = FM_RDS_DISABLE; in fmc_prepare()
1562 fmdev->rx.freq = FM_UNDEFINED_FREQ; in fmc_prepare()
1563 fmdev->rx.rds_mode = FM_RDS_SYSTEM_RDS; in fmc_prepare()
1564 fmdev->rx.af_mode = FM_RX_RDS_AF_SWITCH_MODE_OFF; in fmc_prepare()
1565 fmdev->irq_info.retry = 0; in fmc_prepare()
1567 fm_rx_reset_rds_cache(fmdev); in fmc_prepare()
1568 init_waitqueue_head(&fmdev->rx.rds.read_queue); in fmc_prepare()
1570 fm_rx_reset_station_info(fmdev); in fmc_prepare()
1571 set_bit(FM_CORE_READY, &fmdev->flag); in fmc_prepare()
1580 int fmc_release(struct fmdev *fmdev) in fmc_release() argument
1585 if (!test_bit(FM_CORE_READY, &fmdev->flag)) { in fmc_release()
1590 wake_up_interruptible(&fmdev->rx.rds.read_queue); in fmc_release()
1592 tasklet_kill(&fmdev->tx_task); in fmc_release()
1593 tasklet_kill(&fmdev->rx_task); in fmc_release()
1595 skb_queue_purge(&fmdev->tx_q); in fmc_release()
1596 skb_queue_purge(&fmdev->rx_q); in fmc_release()
1598 fmdev->resp_comp = NULL; in fmc_release()
1599 fmdev->rx.freq = 0; in fmc_release()
1611 clear_bit(FM_CORE_READY, &fmdev->flag); in fmc_release()
1621 struct fmdev *fmdev = NULL; in fm_drv_init() local
1626 fmdev = kzalloc(sizeof(struct fmdev), GFP_KERNEL); in fm_drv_init()
1627 if (NULL == fmdev) { in fm_drv_init()
1631 fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE; in fm_drv_init()
1632 fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL); in fm_drv_init()
1633 if (NULL == fmdev->rx.rds.buff) { in fm_drv_init()
1638 ret = fm_v4l2_init_video_device(fmdev, radio_nr); in fm_drv_init()
1642 fmdev->irq_info.handlers = int_handler_table; in fm_drv_init()
1643 fmdev->curr_fmmode = FM_MODE_OFF; in fm_drv_init()
1644 fmdev->tx_data.pwr_lvl = FM_PWR_LVL_DEF; in fm_drv_init()
1645 fmdev->tx_data.preemph = FM_TX_PREEMPH_50US; in fm_drv_init()
1649 kfree(fmdev->rx.rds.buff); in fm_drv_init()
1651 kfree(fmdev); in fm_drv_init()
1659 struct fmdev *fmdev = NULL; in fm_drv_exit() local
1661 fmdev = fm_v4l2_deinit_video_device(); in fm_drv_exit()
1662 if (fmdev != NULL) { in fm_drv_exit()
1663 kfree(fmdev->rx.rds.buff); in fm_drv_exit()
1664 kfree(fmdev); in fm_drv_exit()