Venkateshwarlu Domakonda | acdd9a4 | 2015-03-24 10:28:37 +0530 | [diff] [blame] | 1 | /* |
| 2 | Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are |
| 6 | met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above |
| 10 | copyright notice, this list of conditions and the following |
| 11 | disclaimer in the documentation and/or other materials provided |
| 12 | with the distribution. |
| 13 | * Neither the name of The Linux Foundation nor the names of its |
| 14 | contributors may be used to endorse or promote products derived |
| 15 | from this software without specific prior written permission. |
| 16 | |
| 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef __FM_RADIO_CTRL_H__ |
| 31 | #define __FM_RADIO_CTRL_H___ |
| 32 | |
| 33 | #include <pthread.h> |
| 34 | #include <ctime> |
| 35 | |
| 36 | class FmRadioController |
| 37 | { |
| 38 | private: |
| 39 | int cur_fm_state; |
| 40 | char af_enabled; |
| 41 | bool seek_scan_canceled; |
| 42 | bool is_rds_support; |
| 43 | bool is_ps_event_received = false; |
| 44 | bool is_rt_event_received = false; |
| 45 | bool is_af_jump_received = false; |
| 46 | bool event_listener_canceled; |
| 47 | pthread_mutex_t mutex_fm_state; |
| 48 | pthread_mutex_t mutex_turn_on_cond; |
| 49 | pthread_mutex_t mutex_seek_compl_cond; |
| 50 | pthread_mutex_t mutex_scan_compl_cond; |
| 51 | pthread_mutex_t mutex_tune_compl_cond; |
| 52 | pthread_cond_t turn_on_cond; |
| 53 | pthread_cond_t seek_compl_cond; |
| 54 | pthread_cond_t scan_compl_cond; |
| 55 | pthread_cond_t tune_compl_cond; |
| 56 | char rds_enabled; |
| 57 | long int prev_freq; |
| 58 | int fd_driver; |
| 59 | pthread_t event_listener_thread; |
| 60 | int SetRdsGrpMask(int mask); |
| 61 | int SetRdsGrpProcessing(int grps); |
| 62 | void handle_enabled_event(void); |
| 63 | void handle_tuned_event(void); |
| 64 | void handle_seek_next_event(void); |
| 65 | void handle_seek_complete_event(void); |
| 66 | void handle_raw_rds_event(void); |
| 67 | void handle_rt_event(void); |
| 68 | void handle_ps_event(void); |
| 69 | void handle_error_event(void); |
| 70 | void handle_below_th_event(void); |
| 71 | void handle_above_th_event(void); |
| 72 | void handle_stereo_event(void); |
| 73 | void handle_mono_event(void); |
| 74 | void handle_rds_aval_event(void); |
| 75 | void handle_rds_not_aval_event(void); |
| 76 | void handle_srch_list_event(void); |
| 77 | void handle_af_list_event(void); |
| 78 | void handle_disabled_event(void); |
| 79 | void handle_rds_grp_mask_req_event(void); |
| 80 | void handle_rt_plus_event(void); |
| 81 | void handle_ert_event(void); |
| 82 | void handle_af_jmp_event(void); |
| 83 | void set_fm_state(int state); |
| 84 | struct timespec set_time_out(int secs); |
| 85 | int GetStationList(uint16_t *scan_tbl, int *max_cnt); |
| 86 | int EnableRDS(void); |
| 87 | int DisableRDS(void); |
| 88 | int EnableAF(void); |
| 89 | int DisableAF(void); |
| 90 | int SetStereo(void); |
| 91 | int SetMono(void); |
| 92 | int MuteOn(void); |
| 93 | int MuteOff(void); |
| 94 | int get_fm_state(void); |
| 95 | long GetCurrentRSSI(void); |
| 96 | bool GetSoftMute(void); |
| 97 | public: |
| 98 | FmRadioController(); |
| 99 | ~FmRadioController(); |
| 100 | int open_dev(void); |
| 101 | int close_dev(); |
| 102 | int Pwr_Up(int freq); |
| 103 | int Pwr_Down(void); |
| 104 | long GetChannel(void); |
| 105 | int TuneChannel(long); |
| 106 | bool IsRds_support(); |
| 107 | int ScanList(uint16_t *scan_tbl, int *max_cnt); |
| 108 | int Seek(int dir); |
| 109 | int ReadRDS(void); |
| 110 | int Get_ps(char *ps, int *ps_len); |
| 111 | int Get_rt(char *rt, int *rt_len); |
| 112 | int Get_AF_freq(uint16_t *ret_freq); |
| 113 | int SetDeConstant(long ); |
| 114 | int SetSoftMute(bool mode); |
| 115 | int Set_mute(bool mute); |
| 116 | int SetBand(long); |
| 117 | int SetChannelSpacing(long); |
| 118 | int Stop_Scan_Seek(void); |
| 119 | int Turn_On_Off_Rds(bool onoff); |
| 120 | int Antenna_Switch(int antenna); |
| 121 | static void* handle_events(void *arg); |
| 122 | bool process_radio_events(int event); |
| 123 | }; |
| 124 | |
| 125 | #endif |