fc8300_tun.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*****************************************************************************
  2. Copyright(c) 2013 FCI Inc. All Rights Reserved
  3. File name : fc8300_tun.c
  4. Description : source of FC8300 tuner driver
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. History :
  17. ----------------------------------------------------------------------
  18. 0p1 initial driver
  19. 0p2 VCO Currunt Setting Add
  20. 0p4
  21. 0p5 20130625
  22. 0p6 20130628
  23. 0p7 20130629
  24. 0p8 20130704
  25. 1p0 20130711
  26. 1p0 20130723
  27. 2p1 20130717
  28. 2p7 20130723
  29. 2p10 20130730
  30. 2p11 20130812
  31. 2p15 20130826
  32. 2p16 20130827
  33. 2p17 20130830
  34. ----------------------------------------------------------------------
  35. *******************************************************************************/
  36. #include "fci_types.h"
  37. #include "fci_oal.h"
  38. #include "fci_tun.h"
  39. #include "fci_hal.h"
  40. #include "fc8300_regs.h"
  41. #include "fc8300_es1_tun.h"
  42. #include "fc8300_es2_tun.h"
  43. #include "fc8300_cs_tun.h"
  44. #define FC8300_TUN_ES1 0xa0
  45. #define FC8300_TUN_ES2 0xb0
  46. #define FC8300_TUN_CS 0xc0
  47. #if 0
  48. static s32 fc8300_write(HANDLE handle, DEVICEID devid, u8 addr, u8 data)
  49. {
  50. s32 res;
  51. res = tuner_i2c_write(handle, devid, addr, 1, &data, 1);
  52. return res;
  53. }
  54. #endif
  55. static s32 fc8300_read(HANDLE handle, DEVICEID devid, u8 addr, u8 *data)
  56. {
  57. s32 res;
  58. res = tuner_i2c_read(handle, devid, addr, 1, data, 1);
  59. return res;
  60. }
  61. #if 0
  62. static s32 fc8300_bb_write(HANDLE handle, DEVICEID devid, u16 addr, u8 data)
  63. {
  64. s32 res;
  65. res = bbm_write(handle, devid, addr, data);
  66. return res;
  67. }
  68. static s32 fc8300_bb_read(HANDLE handle, DEVICEID devid, u16 addr, u8 *data)
  69. {
  70. s32 res;
  71. res = bbm_read(handle, devid, addr, data);
  72. return res;
  73. }
  74. #endif
  75. static u8 fc8300_tun_ver;
  76. s32 fc8300_tuner_init(HANDLE handle, DEVICEID devid,
  77. enum BROADCAST_TYPE broadcast)
  78. {
  79. fc8300_read(handle, devid, 0xff, &fc8300_tun_ver);
  80. if (fc8300_tun_ver == 0xa0)
  81. fc8300_tun_ver = FC8300_TUN_ES1;
  82. else if (fc8300_tun_ver == 0xb0)
  83. fc8300_tun_ver = FC8300_TUN_ES2;
  84. else if (fc8300_tun_ver == 0xc0)
  85. fc8300_tun_ver = FC8300_TUN_CS;
  86. if (fc8300_tun_ver == FC8300_TUN_ES1)
  87. return fc8300_es1_tuner_init(handle, devid, broadcast);
  88. else if (fc8300_tun_ver == FC8300_TUN_ES2)
  89. return fc8300_es2_tuner_init(handle, devid, broadcast);
  90. else if (fc8300_tun_ver == FC8300_TUN_CS)
  91. return fc8300_cs_tuner_init(handle, devid, broadcast);
  92. return BBM_OK;
  93. }
  94. s32 fc8300_set_freq(HANDLE handle, DEVICEID devid, u32 freq)
  95. {
  96. if (fc8300_tun_ver == FC8300_TUN_ES1)
  97. return fc8300_es1_set_freq(handle, devid, freq);
  98. else if (fc8300_tun_ver == FC8300_TUN_ES2)
  99. return fc8300_es2_set_freq(handle, devid, freq);
  100. else if (fc8300_tun_ver == FC8300_TUN_CS)
  101. return fc8300_cs_set_freq(handle, devid, freq);
  102. return BBM_OK;
  103. }
  104. s32 fc8300_get_rssi(HANDLE handle, DEVICEID devid, s32 *rssi)
  105. {
  106. if (fc8300_tun_ver == FC8300_TUN_ES1)
  107. return fc8300_es1_get_rssi(handle, devid, rssi);
  108. else if (fc8300_tun_ver == FC8300_TUN_ES2)
  109. return fc8300_es2_get_rssi(handle, devid, rssi);
  110. else if (fc8300_tun_ver == FC8300_TUN_CS)
  111. return fc8300_cs_get_rssi(handle, devid, rssi);
  112. return BBM_OK;
  113. }
  114. s32 fc8300_tuner_deinit(HANDLE handle, DEVICEID devid)
  115. {
  116. if (fc8300_tun_ver == FC8300_TUN_ES1)
  117. return fc8300_es1_tuner_deinit(handle, devid);
  118. else if (fc8300_tun_ver == FC8300_TUN_ES2)
  119. return fc8300_es2_tuner_deinit(handle, devid);
  120. else if (fc8300_tun_ver == FC8300_TUN_CS)
  121. return fc8300_cs_tuner_deinit(handle, devid);
  122. return BBM_OK;
  123. }