| 1 | |
|---|
| 2 | /******************************************************************** |
|---|
| 3 | DHL_FE_Platform.c |
|---|
| 4 | |
|---|
| 5 | write by yhkim |
|---|
| 6 | |
|---|
| 7 | ¿©·¯ FE Ç÷§Æû¿¡ µû¸¥ µå¶óÀ̹ö¸¦ Áö¿øÇϱâ À§ÇÑ È®Àå¿ë API |
|---|
| 8 | |
|---|
| 9 | ********************************************************************/ |
|---|
| 10 | |
|---|
| 11 | #include "DHL_OSAL.h" |
|---|
| 12 | #include "DHL_DBG.h" |
|---|
| 13 | |
|---|
| 14 | #include "DHL_FE_Priv.h" |
|---|
| 15 | #include "bsettop_tuner.h" |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #if COMMENT |
|---|
| 21 | ____DBG____(){} |
|---|
| 22 | #endif |
|---|
| 23 | |
|---|
| 24 | //DHL_MODULE("*fe", 0); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | #if COMMENT |
|---|
| 29 | ____Global____(){} |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | static btuner_t regTuner; |
|---|
| 34 | static btuner_params tuner_params; |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | #if COMMENT |
|---|
| 39 | ________(){} |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | // id : B/D ¿¡¼ Áö¿øÇÏ´Â FE ÀÇ Ch. No |
|---|
| 44 | #define CHECK_TUNER_id(id) { \ |
|---|
| 45 | if((id)>=DHL_CFG_NUM_TUNER) { \ |
|---|
| 46 | dprint(0, "!! %s : bad tuner id\n", __func__); \ |
|---|
| 47 | return DHL_FAIL_INVALID_PARAM; } \ |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | #if COMMENT |
|---|
| 53 | ____API____(){} |
|---|
| 54 | #endif |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | /* FE Device ÃʱâÈ |
|---|
| 60 | |
|---|
| 61 | FE ä³ÎÁß Çϳª¶óµµ ÃʱâÈ ¿¡·¯½Ã °è¼Ó ÁøÇàÇÏÁö ¾Ê°í ¿¡·¯ ¹Ýȯ.. |
|---|
| 62 | |
|---|
| 63 | */ |
|---|
| 64 | DHL_RESULT dhl_fe_init() |
|---|
| 65 | { |
|---|
| 66 | |
|---|
| 67 | regTuner=btuner_open(0); |
|---|
| 68 | |
|---|
| 69 | if(regTuner==NULL) return DHL_FAIL; |
|---|
| 70 | |
|---|
| 71 | return DHL_OK; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | /* FE Open |
|---|
| 76 | |
|---|
| 77 | --TODO-- |
|---|
| 78 | |
|---|
| 79 | */ |
|---|
| 80 | DHL_RESULT dhl_fe_open(tDHL_TunerID id) |
|---|
| 81 | { |
|---|
| 82 | |
|---|
| 83 | regTuner=btuner_open(0); |
|---|
| 84 | |
|---|
| 85 | if(regTuner==NULL) return DHL_FAIL; |
|---|
| 86 | |
|---|
| 87 | return DHL_OK; |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | /* FE Close |
|---|
| 93 | |
|---|
| 94 | --TODO-- |
|---|
| 95 | |
|---|
| 96 | */ |
|---|
| 97 | DHL_RESULT dhl_fe_close(tDHL_TunerID id) |
|---|
| 98 | { |
|---|
| 99 | |
|---|
| 100 | // if(regTuner) |
|---|
| 101 | // btuner_close(regTuner); |
|---|
| 102 | return DHL_OK; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | void dhl_fe_cancel_callback(void *context) |
|---|
| 108 | { |
|---|
| 109 | //TODO: cancel callback up app |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | oob Æ©´×À» À§ÇØ È®ÀåµÈ fe control API. |
|---|
| 115 | backward compatibility¸¦ À§ÇÏ¿© @settings´Â ÇÊ¿ä ¾ø´Ù¸é »ý·« °¡´ÉÇÔ. |
|---|
| 116 | |
|---|
| 117 | Tune start ÇÔ¼ö.. setting ÆÄ¶ó¹ÌÅÍ´Â OOB Æ©´×À» À§ÇÑ ¼ÂÆÃ°ª.. |
|---|
| 118 | |
|---|
| 119 | Tuning µ¿ÀÛÀ» ¼öÇàÇÒ¶§´Â Demod ¸¦ ¸ÕÀú tune start ÈÄ Tuner tune start...!! |
|---|
| 120 | |
|---|
| 121 | BKNOTE: newcon3 only support 8VBS... |
|---|
| 122 | |
|---|
| 123 | */ |
|---|
| 124 | DHL_RESULT dhl_fe_start(tDHL_TunerID id, UINT32 freqKHz, tDHL_Demod demod, |
|---|
| 125 | tDHL_DemodExtSettings *settings) |
|---|
| 126 | { |
|---|
| 127 | DHL_RESULT dhr = DHL_OK; |
|---|
| 128 | unsigned freq_hz = freqKHz * 1000; |
|---|
| 129 | bband_t band; |
|---|
| 130 | |
|---|
| 131 | btuner_params_init(&tuner_params, regTuner); |
|---|
| 132 | #if 1//unused |
|---|
| 133 | tuner_params.cancel_callback = dhl_fe_cancel_callback; |
|---|
| 134 | tuner_params.cancel_callback_context = NULL; |
|---|
| 135 | #endif |
|---|
| 136 | |
|---|
| 137 | if(demod == eDHL_DEMOD_64QAM) |
|---|
| 138 | { |
|---|
| 139 | tuner_params.qamMode = eQAM_64; |
|---|
| 140 | tuner_params.fecMode = eFEC_ANNEX_B; |
|---|
| 141 | } |
|---|
| 142 | else if(demod == eDHL_DEMOD_256QAM) |
|---|
| 143 | { |
|---|
| 144 | tuner_params.qamMode = eQAM_256; |
|---|
| 145 | tuner_params.fecMode = eFEC_ANNEX_B; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | tuner_params.wait_for_lock = false; |
|---|
| 149 | |
|---|
| 150 | band = btuner_tune(regTuner, freq_hz, &tuner_params); |
|---|
| 151 | if (band < 0) |
|---|
| 152 | { |
|---|
| 153 | printf("Tune failed (freq = %d)\n", freq_hz); |
|---|
| 154 | dhr = DHL_FAIL; |
|---|
| 155 | } |
|---|
| 156 | #if 1 |
|---|
| 157 | else |
|---|
| 158 | { |
|---|
| 159 | #ifndef TUNER_BAND |
|---|
| 160 | #define TUNER_BAND 0 |
|---|
| 161 | #endif |
|---|
| 162 | //dhl_set_tuner_band(TUNER_BAND);//(band); |
|---|
| 163 | dhl_set_tuner_band(band); |
|---|
| 164 | } |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| 167 | return dhr; |
|---|
| 168 | |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | /* FE Stop |
|---|
| 172 | |
|---|
| 173 | ----TODO---- |
|---|
| 174 | |
|---|
| 175 | */ |
|---|
| 176 | DHL_RESULT dhl_fe_stop(tDHL_TunerID id) |
|---|
| 177 | { |
|---|
| 178 | |
|---|
| 179 | DHL_RESULT dhr = DHL_OK; |
|---|
| 180 | //btuner_close(regTuner); |
|---|
| 181 | |
|---|
| 182 | return dhr; |
|---|
| 183 | |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | /* FE(ÁÖ·Î Domod) ÀÇ °¢ Lock »óŸ¦ °¡Á®¿À´Â ÇÔ¼ö.. |
|---|
| 188 | |
|---|
| 189 | Decoder ÀÇ Lock »óÅ ÆÇ´Üµî¿¡ ¾²ÀδÙ. |
|---|
| 190 | |
|---|
| 191 | ÇöÀç ±¸Á¶»ó ÇѰ¡Áö »óÅ¿¡ ´ëÇØ ÇѰ¡Áö ÆÄ¶ó¹ÌÅ͸¸ ¹Ýȯ °¡´ÉÇϹǷΠ|
|---|
| 192 | °°Àº »óÅ¿¡ ´ëÇØ Tuner ¿Í Demod °¡ µ¿½Ã¿¡ °ªÀ» ¹Ýȯ ÇØ¼´Â ¾ÈµÈ´Ù.. |
|---|
| 193 | üũÇÒ »óÅ Ç׸ñÀÌ ¾øÀ» °æ¿ì¿¡¸¸ ´ÙÀ½ Device ¸¦ »óÅ üũÇÔ.. |
|---|
| 194 | ¿¡·¯ ¹× »óÅ üũ ¿Ï·á ½Ã¿¡´Â ¹Ù·Î Return.. |
|---|
| 195 | |
|---|
| 196 | */ |
|---|
| 197 | DHL_RESULT dhl_fe_get_sig_info(tDHL_TunerID id, tDHL_SignalStatus selector, UINT32 *pValue) |
|---|
| 198 | { |
|---|
| 199 | DHL_RESULT dhr=DHL_OK; |
|---|
| 200 | btuner_status tuner_status; |
|---|
| 201 | if(pValue==NULL) |
|---|
| 202 | return DHL_FAIL_INVALID_PARAM; |
|---|
| 203 | |
|---|
| 204 | if (btuner_get_status(regTuner,&tuner_status) == b_ok) |
|---|
| 205 | { |
|---|
| 206 | switch(selector) |
|---|
| 207 | { |
|---|
| 208 | case eDHL_SIGNAL_STRENGTH: |
|---|
| 209 | // if(tuner_status.lock) |
|---|
| 210 | *pValue = tuner_status.power; |
|---|
| 211 | // else |
|---|
| 212 | // *pValue = 0;//BKTODO: lockÀÌ ¾ÈµÇ¾îµµ power°ªÀº ÀÖÀ» ¼ö ÀÖÀ½ |
|---|
| 213 | break; |
|---|
| 214 | case eDHL_SIGNAL_LOCK: |
|---|
| 215 | *pValue = tuner_status.lock; |
|---|
| 216 | break; |
|---|
| 217 | |
|---|
| 218 | case eDHL_SIGNAL_SNR: |
|---|
| 219 | case eDHL_SIGNAL_SER_1SEC: |
|---|
| 220 | case eDHL_SIGNAL_SER_10SEC: |
|---|
| 221 | *pValue = tuner_status.snr * 100; //BKTODO: x100ÀÌ ¸Â´ÂÁö È®ÀÎ ¿äÇÔ. |
|---|
| 222 | break; |
|---|
| 223 | |
|---|
| 224 | default: |
|---|
| 225 | printf("ERR: dhl_fe_get_sig_info unsupported type %d\n",selector); |
|---|
| 226 | break; |
|---|
| 227 | //BKTODO: p_chm->signal_evt.signal_quality = tuner_status.PreRS; (quality´Â ÇÊ¿ä ¾ø³ª?) |
|---|
| 228 | |
|---|
| 229 | } |
|---|
| 230 | } |
|---|
| 231 | return dhr; |
|---|
| 232 | |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | DHL_RESULT dhl_fe_get_sig_info_detail(int *lock, int *snr, int* power) |
|---|
| 236 | { |
|---|
| 237 | btuner_status tuner_status; |
|---|
| 238 | btuner_get_status(regTuner, &tuner_status); |
|---|
| 239 | *lock = tuner_status.lock; |
|---|
| 240 | *snr = tuner_status.snr; |
|---|
| 241 | *power = tuner_status.power; |
|---|
| 242 | return DHL_OK; |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | /* FE Control |
|---|
| 246 | |
|---|
| 247 | ----TODO----- |
|---|
| 248 | |
|---|
| 249 | */ |
|---|
| 250 | DHL_RESULT dhl_fe_control(tDHL_TunerID id, tDHL_FeControlType selector, UINT32 arg) |
|---|
| 251 | { |
|---|
| 252 | DHL_RESULT dhr=DHL_OK; |
|---|
| 253 | |
|---|
| 254 | return dhr; |
|---|
| 255 | |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | /* demod ÀÇ modulation type ¼³Á¤°ªÀ» °¡Á®¿È.. |
|---|
| 260 | |
|---|
| 261 | Lock üũ¸¦ ÇÏ¿© Lock ÀÌ µÈ °æ¿ì¿¡¸¸ Àоî¿È.... |
|---|
| 262 | Lock üũ ¾È¿¡ demod reg ¿Í app ¼³Á¤°ª üũ¸¦ Æ÷ÇÔ Çϵµ·Ï ±¸Çö.. |
|---|
| 263 | Lock ÀÌ µÇ¾úÀ¸¸é Device ¿¡¼ Àоî¿Â °ªÀÌ ¾Æ´Ñ App ÀÇ ¼ÂÆÃ°ªÀ» ±×´ë·Î ¹Ýȯ..(Lock ÀÎ °æ¿ì °°À¸¹Ç·Î..) |
|---|
| 264 | |
|---|
| 265 | */ |
|---|
| 266 | DHL_RESULT dhl_fe_get_demod_type(tDHL_TunerID id, tDHL_Demod *pDemod) |
|---|
| 267 | { |
|---|
| 268 | |
|---|
| 269 | DHL_RESULT dhr=DHL_OK; |
|---|
| 270 | if(pDemod != NULL) |
|---|
| 271 | *pDemod=eDHL_DEMOD_8VSB; //only 8 VSB |
|---|
| 272 | |
|---|
| 273 | return dhr; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | /* FE Device ÀÇ Á¤º¸¸¦ °¡Á®¿È.. |
|---|
| 277 | |
|---|
| 278 | 1. Vendor : Tuner ¸¸ Áö¿ø ?? |
|---|
| 279 | 2. Partname : Tuner ¸¸ Áö¿ø ?? |
|---|
| 280 | 3. Áö¿ø ±â´É.. : Demod ÀÇ Modulation ¸¸ Áö¿ø..?? |
|---|
| 281 | |
|---|
| 282 | ±âÁ¸ Tuner ¿Í Demod °¡ ÅëÇÕµÈ Ä¨À» »ç¿ë ÇÏ¿´±â¿¡ Çϳª¸¸ Áö¿ø.. |
|---|
| 283 | ³ªÁß Tuner ¿Í Demod ºÐ¸® »ç¿ë½Ã ¾î¶»°Ô ó¸®ÇÒ °ÍÀÎÁö..³íÀÇ ÇÊ¿ä!! |
|---|
| 284 | |
|---|
| 285 | */ |
|---|
| 286 | DHL_RESULT dhl_fe_get_device_info(tDHL_TunerID id, tDHL_TunerDeviceInfo selector, void *pValue) |
|---|
| 287 | { |
|---|
| 288 | DHL_RESULT dhr=DHL_OK; |
|---|
| 289 | UINT32 value = 0; |
|---|
| 290 | |
|---|
| 291 | switch (selector) |
|---|
| 292 | { |
|---|
| 293 | case eDHL_FE_DEV_VENDOR_NAME: |
|---|
| 294 | strcpy((char *)pValue, "NXP"); |
|---|
| 295 | break; |
|---|
| 296 | case eDHL_FE_DEV_CAPABILITY_1: |
|---|
| 297 | value |= eDHL_TUCAP_VSB; |
|---|
| 298 | // value |= eDHL_TUCAP_QAM; //only vsb |
|---|
| 299 | *(UINT32 *)pValue = value; |
|---|
| 300 | break; |
|---|
| 301 | default: |
|---|
| 302 | dhr = DHL_FAIL_NOT_IMPLEMENTED; |
|---|
| 303 | break; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | return dhr; |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | #if COMMENT |
|---|
| 317 | ____Test_Code____(){} |
|---|
| 318 | #endif |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | |
|---|