xc4000.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775
  1. /*
  2. * Driver for Xceive XC4000 "QAM/8VSB single chip tuner"
  3. *
  4. * Copyright (c) 2007 Xceive Corporation
  5. * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org>
  6. * Copyright (c) 2009 Devin Heitmueller <dheitmueller@kernellabs.com>
  7. * Copyright (c) 2009 Davide Ferri <d.ferri@zero11.it>
  8. * Copyright (c) 2010 Istvan Varga <istvan_v@mailbox.hu>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. */
  24. #include <linux/module.h>
  25. #include <linux/moduleparam.h>
  26. #include <linux/videodev2.h>
  27. #include <linux/delay.h>
  28. #include <linux/dvb/frontend.h>
  29. #include <linux/i2c.h>
  30. #include <linux/mutex.h>
  31. #include <asm/unaligned.h>
  32. #include "dvb_frontend.h"
  33. #include "xc4000.h"
  34. #include "tuner-i2c.h"
  35. #include "tuner-xc2028-types.h"
  36. static int debug;
  37. module_param(debug, int, 0644);
  38. MODULE_PARM_DESC(debug, "Debugging level (0 to 2, default: 0 (off)).");
  39. static int no_poweroff;
  40. module_param(no_poweroff, int, 0644);
  41. MODULE_PARM_DESC(no_poweroff, "Power management (1: disabled, 2: enabled, "
  42. "0 (default): use device-specific default mode).");
  43. static int audio_std;
  44. module_param(audio_std, int, 0644);
  45. MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly "
  46. "needs to know what audio standard is needed for some video standards "
  47. "with audio A2 or NICAM. The valid settings are a sum of:\n"
  48. " 1: use NICAM/B or A2/B instead of NICAM/A or A2/A\n"
  49. " 2: use A2 instead of NICAM or BTSC\n"
  50. " 4: use SECAM/K3 instead of K1\n"
  51. " 8: use PAL-D/K audio for SECAM-D/K\n"
  52. "16: use FM radio input 1 instead of input 2\n"
  53. "32: use mono audio (the lower three bits are ignored)");
  54. static char firmware_name[30];
  55. module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
  56. MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the "
  57. "default firmware name.");
  58. static DEFINE_MUTEX(xc4000_list_mutex);
  59. static LIST_HEAD(hybrid_tuner_instance_list);
  60. #define dprintk(level, fmt, arg...) if (debug >= level) \
  61. printk(KERN_INFO "%s: " fmt, "xc4000", ## arg)
  62. /* struct for storing firmware table */
  63. struct firmware_description {
  64. unsigned int type;
  65. v4l2_std_id id;
  66. __u16 int_freq;
  67. unsigned char *ptr;
  68. unsigned int size;
  69. };
  70. struct firmware_properties {
  71. unsigned int type;
  72. v4l2_std_id id;
  73. v4l2_std_id std_req;
  74. __u16 int_freq;
  75. unsigned int scode_table;
  76. int scode_nr;
  77. };
  78. struct xc4000_priv {
  79. struct tuner_i2c_props i2c_props;
  80. struct list_head hybrid_tuner_instance_list;
  81. struct firmware_description *firm;
  82. int firm_size;
  83. u32 if_khz;
  84. u32 freq_hz, freq_offset;
  85. u32 bandwidth;
  86. u8 video_standard;
  87. u8 rf_mode;
  88. u8 default_pm;
  89. u8 dvb_amplitude;
  90. u8 set_smoothedcvbs;
  91. u8 ignore_i2c_write_errors;
  92. __u16 firm_version;
  93. struct firmware_properties cur_fw;
  94. __u16 hwmodel;
  95. __u16 hwvers;
  96. struct mutex lock;
  97. };
  98. #define XC4000_AUDIO_STD_B 1
  99. #define XC4000_AUDIO_STD_A2 2
  100. #define XC4000_AUDIO_STD_K3 4
  101. #define XC4000_AUDIO_STD_L 8
  102. #define XC4000_AUDIO_STD_INPUT1 16
  103. #define XC4000_AUDIO_STD_MONO 32
  104. #define XC4000_DEFAULT_FIRMWARE "dvb-fe-xc4000-1.4.fw"
  105. #define XC4000_DEFAULT_FIRMWARE_NEW "dvb-fe-xc4000-1.4.1.fw"
  106. /* Misc Defines */
  107. #define MAX_TV_STANDARD 24
  108. #define XC_MAX_I2C_WRITE_LENGTH 64
  109. #define XC_POWERED_DOWN 0x80000000U
  110. /* Signal Types */
  111. #define XC_RF_MODE_AIR 0
  112. #define XC_RF_MODE_CABLE 1
  113. /* Product id */
  114. #define XC_PRODUCT_ID_FW_NOT_LOADED 0x2000
  115. #define XC_PRODUCT_ID_XC4000 0x0FA0
  116. #define XC_PRODUCT_ID_XC4100 0x1004
  117. /* Registers (Write-only) */
  118. #define XREG_INIT 0x00
  119. #define XREG_VIDEO_MODE 0x01
  120. #define XREG_AUDIO_MODE 0x02
  121. #define XREG_RF_FREQ 0x03
  122. #define XREG_D_CODE 0x04
  123. #define XREG_DIRECTSITTING_MODE 0x05
  124. #define XREG_SEEK_MODE 0x06
  125. #define XREG_POWER_DOWN 0x08
  126. #define XREG_SIGNALSOURCE 0x0A
  127. #define XREG_SMOOTHEDCVBS 0x0E
  128. #define XREG_AMPLITUDE 0x10
  129. /* Registers (Read-only) */
  130. #define XREG_ADC_ENV 0x00
  131. #define XREG_QUALITY 0x01
  132. #define XREG_FRAME_LINES 0x02
  133. #define XREG_HSYNC_FREQ 0x03
  134. #define XREG_LOCK 0x04
  135. #define XREG_FREQ_ERROR 0x05
  136. #define XREG_SNR 0x06
  137. #define XREG_VERSION 0x07
  138. #define XREG_PRODUCT_ID 0x08
  139. #define XREG_SIGNAL_LEVEL 0x0A
  140. #define XREG_NOISE_LEVEL 0x0B
  141. /*
  142. Basic firmware description. This will remain with
  143. the driver for documentation purposes.
  144. This represents an I2C firmware file encoded as a
  145. string of unsigned char. Format is as follows:
  146. char[0 ]=len0_MSB -> len = len_MSB * 256 + len_LSB
  147. char[1 ]=len0_LSB -> length of first write transaction
  148. char[2 ]=data0 -> first byte to be sent
  149. char[3 ]=data1
  150. char[4 ]=data2
  151. char[ ]=...
  152. char[M ]=dataN -> last byte to be sent
  153. char[M+1]=len1_MSB -> len = len_MSB * 256 + len_LSB
  154. char[M+2]=len1_LSB -> length of second write transaction
  155. char[M+3]=data0
  156. char[M+4]=data1
  157. ...
  158. etc.
  159. The [len] value should be interpreted as follows:
  160. len= len_MSB _ len_LSB
  161. len=1111_1111_1111_1111 : End of I2C_SEQUENCE
  162. len=0000_0000_0000_0000 : Reset command: Do hardware reset
  163. len=0NNN_NNNN_NNNN_NNNN : Normal transaction: number of bytes = {1:32767)
  164. len=1WWW_WWWW_WWWW_WWWW : Wait command: wait for {1:32767} ms
  165. For the RESET and WAIT commands, the two following bytes will contain
  166. immediately the length of the following transaction.
  167. */
  168. struct XC_TV_STANDARD {
  169. const char *Name;
  170. u16 audio_mode;
  171. u16 video_mode;
  172. u16 int_freq;
  173. };
  174. /* Tuner standards */
  175. #define XC4000_MN_NTSC_PAL_BTSC 0
  176. #define XC4000_MN_NTSC_PAL_A2 1
  177. #define XC4000_MN_NTSC_PAL_EIAJ 2
  178. #define XC4000_MN_NTSC_PAL_Mono 3
  179. #define XC4000_BG_PAL_A2 4
  180. #define XC4000_BG_PAL_NICAM 5
  181. #define XC4000_BG_PAL_MONO 6
  182. #define XC4000_I_PAL_NICAM 7
  183. #define XC4000_I_PAL_NICAM_MONO 8
  184. #define XC4000_DK_PAL_A2 9
  185. #define XC4000_DK_PAL_NICAM 10
  186. #define XC4000_DK_PAL_MONO 11
  187. #define XC4000_DK_SECAM_A2DK1 12
  188. #define XC4000_DK_SECAM_A2LDK3 13
  189. #define XC4000_DK_SECAM_A2MONO 14
  190. #define XC4000_DK_SECAM_NICAM 15
  191. #define XC4000_L_SECAM_NICAM 16
  192. #define XC4000_LC_SECAM_NICAM 17
  193. #define XC4000_DTV6 18
  194. #define XC4000_DTV8 19
  195. #define XC4000_DTV7_8 20
  196. #define XC4000_DTV7 21
  197. #define XC4000_FM_Radio_INPUT2 22
  198. #define XC4000_FM_Radio_INPUT1 23
  199. static struct XC_TV_STANDARD xc4000_standard[MAX_TV_STANDARD] = {
  200. {"M/N-NTSC/PAL-BTSC", 0x0000, 0x80A0, 4500},
  201. {"M/N-NTSC/PAL-A2", 0x0000, 0x80A0, 4600},
  202. {"M/N-NTSC/PAL-EIAJ", 0x0040, 0x80A0, 4500},
  203. {"M/N-NTSC/PAL-Mono", 0x0078, 0x80A0, 4500},
  204. {"B/G-PAL-A2", 0x0000, 0x8159, 5640},
  205. {"B/G-PAL-NICAM", 0x0004, 0x8159, 5740},
  206. {"B/G-PAL-MONO", 0x0078, 0x8159, 5500},
  207. {"I-PAL-NICAM", 0x0080, 0x8049, 6240},
  208. {"I-PAL-NICAM-MONO", 0x0078, 0x8049, 6000},
  209. {"D/K-PAL-A2", 0x0000, 0x8049, 6380},
  210. {"D/K-PAL-NICAM", 0x0080, 0x8049, 6200},
  211. {"D/K-PAL-MONO", 0x0078, 0x8049, 6500},
  212. {"D/K-SECAM-A2 DK1", 0x0000, 0x8049, 6340},
  213. {"D/K-SECAM-A2 L/DK3", 0x0000, 0x8049, 6000},
  214. {"D/K-SECAM-A2 MONO", 0x0078, 0x8049, 6500},
  215. {"D/K-SECAM-NICAM", 0x0080, 0x8049, 6200},
  216. {"L-SECAM-NICAM", 0x8080, 0x0009, 6200},
  217. {"L'-SECAM-NICAM", 0x8080, 0x4009, 6200},
  218. {"DTV6", 0x00C0, 0x8002, 0},
  219. {"DTV8", 0x00C0, 0x800B, 0},
  220. {"DTV7/8", 0x00C0, 0x801B, 0},
  221. {"DTV7", 0x00C0, 0x8007, 0},
  222. {"FM Radio-INPUT2", 0x0008, 0x9800, 10700},
  223. {"FM Radio-INPUT1", 0x0008, 0x9000, 10700}
  224. };
  225. static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val);
  226. static int xc4000_tuner_reset(struct dvb_frontend *fe);
  227. static void xc_debug_dump(struct xc4000_priv *priv);
  228. static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len)
  229. {
  230. struct i2c_msg msg = { .addr = priv->i2c_props.addr,
  231. .flags = 0, .buf = buf, .len = len };
  232. if (i2c_transfer(priv->i2c_props.adap, &msg, 1) != 1) {
  233. if (priv->ignore_i2c_write_errors == 0) {
  234. printk(KERN_ERR "xc4000: I2C write failed (len=%i)\n",
  235. len);
  236. if (len == 4) {
  237. printk(KERN_ERR "bytes %*ph\n", 4, buf);
  238. }
  239. return -EREMOTEIO;
  240. }
  241. }
  242. return 0;
  243. }
  244. static int xc4000_tuner_reset(struct dvb_frontend *fe)
  245. {
  246. struct xc4000_priv *priv = fe->tuner_priv;
  247. int ret;
  248. dprintk(1, "%s()\n", __func__);
  249. if (fe->callback) {
  250. ret = fe->callback(((fe->dvb) && (fe->dvb->priv)) ?
  251. fe->dvb->priv :
  252. priv->i2c_props.adap->algo_data,
  253. DVB_FRONTEND_COMPONENT_TUNER,
  254. XC4000_TUNER_RESET, 0);
  255. if (ret) {
  256. printk(KERN_ERR "xc4000: reset failed\n");
  257. return -EREMOTEIO;
  258. }
  259. } else {
  260. printk(KERN_ERR "xc4000: no tuner reset callback function, "
  261. "fatal\n");
  262. return -EINVAL;
  263. }
  264. return 0;
  265. }
  266. static int xc_write_reg(struct xc4000_priv *priv, u16 regAddr, u16 i2cData)
  267. {
  268. u8 buf[4];
  269. int result;
  270. buf[0] = (regAddr >> 8) & 0xFF;
  271. buf[1] = regAddr & 0xFF;
  272. buf[2] = (i2cData >> 8) & 0xFF;
  273. buf[3] = i2cData & 0xFF;
  274. result = xc_send_i2c_data(priv, buf, 4);
  275. return result;
  276. }
  277. static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence)
  278. {
  279. struct xc4000_priv *priv = fe->tuner_priv;
  280. int i, nbytes_to_send, result;
  281. unsigned int len, pos, index;
  282. u8 buf[XC_MAX_I2C_WRITE_LENGTH];
  283. index = 0;
  284. while ((i2c_sequence[index] != 0xFF) ||
  285. (i2c_sequence[index + 1] != 0xFF)) {
  286. len = i2c_sequence[index] * 256 + i2c_sequence[index+1];
  287. if (len == 0x0000) {
  288. /* RESET command */
  289. /* NOTE: this is ignored, as the reset callback was */
  290. /* already called by check_firmware() */
  291. index += 2;
  292. } else if (len & 0x8000) {
  293. /* WAIT command */
  294. msleep(len & 0x7FFF);
  295. index += 2;
  296. } else {
  297. /* Send i2c data whilst ensuring individual transactions
  298. * do not exceed XC_MAX_I2C_WRITE_LENGTH bytes.
  299. */
  300. index += 2;
  301. buf[0] = i2c_sequence[index];
  302. buf[1] = i2c_sequence[index + 1];
  303. pos = 2;
  304. while (pos < len) {
  305. if ((len - pos) > XC_MAX_I2C_WRITE_LENGTH - 2)
  306. nbytes_to_send =
  307. XC_MAX_I2C_WRITE_LENGTH;
  308. else
  309. nbytes_to_send = (len - pos + 2);
  310. for (i = 2; i < nbytes_to_send; i++) {
  311. buf[i] = i2c_sequence[index + pos +
  312. i - 2];
  313. }
  314. result = xc_send_i2c_data(priv, buf,
  315. nbytes_to_send);
  316. if (result != 0)
  317. return result;
  318. pos += nbytes_to_send - 2;
  319. }
  320. index += len;
  321. }
  322. }
  323. return 0;
  324. }
  325. static int xc_set_tv_standard(struct xc4000_priv *priv,
  326. u16 video_mode, u16 audio_mode)
  327. {
  328. int ret;
  329. dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, video_mode, audio_mode);
  330. dprintk(1, "%s() Standard = %s\n",
  331. __func__,
  332. xc4000_standard[priv->video_standard].Name);
  333. /* Don't complain when the request fails because of i2c stretching */
  334. priv->ignore_i2c_write_errors = 1;
  335. ret = xc_write_reg(priv, XREG_VIDEO_MODE, video_mode);
  336. if (ret == 0)
  337. ret = xc_write_reg(priv, XREG_AUDIO_MODE, audio_mode);
  338. priv->ignore_i2c_write_errors = 0;
  339. return ret;
  340. }
  341. static int xc_set_signal_source(struct xc4000_priv *priv, u16 rf_mode)
  342. {
  343. dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode,
  344. rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE");
  345. if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) {
  346. rf_mode = XC_RF_MODE_CABLE;
  347. printk(KERN_ERR
  348. "%s(), Invalid mode, defaulting to CABLE",
  349. __func__);
  350. }
  351. return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode);
  352. }
  353. static const struct dvb_tuner_ops xc4000_tuner_ops;
  354. static int xc_set_rf_frequency(struct xc4000_priv *priv, u32 freq_hz)
  355. {
  356. u16 freq_code;
  357. dprintk(1, "%s(%u)\n", __func__, freq_hz);
  358. if ((freq_hz > xc4000_tuner_ops.info.frequency_max) ||
  359. (freq_hz < xc4000_tuner_ops.info.frequency_min))
  360. return -EINVAL;
  361. freq_code = (u16)(freq_hz / 15625);
  362. /* WAS: Starting in firmware version 1.1.44, Xceive recommends using the
  363. FINERFREQ for all normal tuning (the doc indicates reg 0x03 should
  364. only be used for fast scanning for channel lock) */
  365. /* WAS: XREG_FINERFREQ */
  366. return xc_write_reg(priv, XREG_RF_FREQ, freq_code);
  367. }
  368. static int xc_get_adc_envelope(struct xc4000_priv *priv, u16 *adc_envelope)
  369. {
  370. return xc4000_readreg(priv, XREG_ADC_ENV, adc_envelope);
  371. }
  372. static int xc_get_frequency_error(struct xc4000_priv *priv, u32 *freq_error_hz)
  373. {
  374. int result;
  375. u16 regData;
  376. u32 tmp;
  377. result = xc4000_readreg(priv, XREG_FREQ_ERROR, &regData);
  378. if (result != 0)
  379. return result;
  380. tmp = (u32)regData & 0xFFFFU;
  381. tmp = (tmp < 0x8000U ? tmp : 0x10000U - tmp);
  382. (*freq_error_hz) = tmp * 15625;
  383. return result;
  384. }
  385. static int xc_get_lock_status(struct xc4000_priv *priv, u16 *lock_status)
  386. {
  387. return xc4000_readreg(priv, XREG_LOCK, lock_status);
  388. }
  389. static int xc_get_version(struct xc4000_priv *priv,
  390. u8 *hw_majorversion, u8 *hw_minorversion,
  391. u8 *fw_majorversion, u8 *fw_minorversion)
  392. {
  393. u16 data;
  394. int result;
  395. result = xc4000_readreg(priv, XREG_VERSION, &data);
  396. if (result != 0)
  397. return result;
  398. (*hw_majorversion) = (data >> 12) & 0x0F;
  399. (*hw_minorversion) = (data >> 8) & 0x0F;
  400. (*fw_majorversion) = (data >> 4) & 0x0F;
  401. (*fw_minorversion) = data & 0x0F;
  402. return 0;
  403. }
  404. static int xc_get_hsync_freq(struct xc4000_priv *priv, u32 *hsync_freq_hz)
  405. {
  406. u16 regData;
  407. int result;
  408. result = xc4000_readreg(priv, XREG_HSYNC_FREQ, &regData);
  409. if (result != 0)
  410. return result;
  411. (*hsync_freq_hz) = ((regData & 0x0fff) * 763)/100;
  412. return result;
  413. }
  414. static int xc_get_frame_lines(struct xc4000_priv *priv, u16 *frame_lines)
  415. {
  416. return xc4000_readreg(priv, XREG_FRAME_LINES, frame_lines);
  417. }
  418. static int xc_get_quality(struct xc4000_priv *priv, u16 *quality)
  419. {
  420. return xc4000_readreg(priv, XREG_QUALITY, quality);
  421. }
  422. static int xc_get_signal_level(struct xc4000_priv *priv, u16 *signal)
  423. {
  424. return xc4000_readreg(priv, XREG_SIGNAL_LEVEL, signal);
  425. }
  426. static int xc_get_noise_level(struct xc4000_priv *priv, u16 *noise)
  427. {
  428. return xc4000_readreg(priv, XREG_NOISE_LEVEL, noise);
  429. }
  430. static u16 xc_wait_for_lock(struct xc4000_priv *priv)
  431. {
  432. u16 lock_state = 0;
  433. int watchdog_count = 40;
  434. while ((lock_state == 0) && (watchdog_count > 0)) {
  435. xc_get_lock_status(priv, &lock_state);
  436. if (lock_state != 1) {
  437. msleep(5);
  438. watchdog_count--;
  439. }
  440. }
  441. return lock_state;
  442. }
  443. static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz)
  444. {
  445. int found = 1;
  446. int result;
  447. dprintk(1, "%s(%u)\n", __func__, freq_hz);
  448. /* Don't complain when the request fails because of i2c stretching */
  449. priv->ignore_i2c_write_errors = 1;
  450. result = xc_set_rf_frequency(priv, freq_hz);
  451. priv->ignore_i2c_write_errors = 0;
  452. if (result != 0)
  453. return 0;
  454. /* wait for lock only in analog TV mode */
  455. if ((priv->cur_fw.type & (FM | DTV6 | DTV7 | DTV78 | DTV8)) == 0) {
  456. if (xc_wait_for_lock(priv) != 1)
  457. found = 0;
  458. }
  459. /* Wait for stats to stabilize.
  460. * Frame Lines needs two frame times after initial lock
  461. * before it is valid.
  462. */
  463. msleep(debug ? 100 : 10);
  464. if (debug)
  465. xc_debug_dump(priv);
  466. return found;
  467. }
  468. static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val)
  469. {
  470. u8 buf[2] = { reg >> 8, reg & 0xff };
  471. u8 bval[2] = { 0, 0 };
  472. struct i2c_msg msg[2] = {
  473. { .addr = priv->i2c_props.addr,
  474. .flags = 0, .buf = &buf[0], .len = 2 },
  475. { .addr = priv->i2c_props.addr,
  476. .flags = I2C_M_RD, .buf = &bval[0], .len = 2 },
  477. };
  478. if (i2c_transfer(priv->i2c_props.adap, msg, 2) != 2) {
  479. printk(KERN_ERR "xc4000: I2C read failed\n");
  480. return -EREMOTEIO;
  481. }
  482. *val = (bval[0] << 8) | bval[1];
  483. return 0;
  484. }
  485. #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0)
  486. static void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq)
  487. {
  488. if (type & BASE)
  489. printk(KERN_CONT "BASE ");
  490. if (type & INIT1)
  491. printk(KERN_CONT "INIT1 ");
  492. if (type & F8MHZ)
  493. printk(KERN_CONT "F8MHZ ");
  494. if (type & MTS)
  495. printk(KERN_CONT "MTS ");
  496. if (type & D2620)
  497. printk(KERN_CONT "D2620 ");
  498. if (type & D2633)
  499. printk(KERN_CONT "D2633 ");
  500. if (type & DTV6)
  501. printk(KERN_CONT "DTV6 ");
  502. if (type & QAM)
  503. printk(KERN_CONT "QAM ");
  504. if (type & DTV7)
  505. printk(KERN_CONT "DTV7 ");
  506. if (type & DTV78)
  507. printk(KERN_CONT "DTV78 ");
  508. if (type & DTV8)
  509. printk(KERN_CONT "DTV8 ");
  510. if (type & FM)
  511. printk(KERN_CONT "FM ");
  512. if (type & INPUT1)
  513. printk(KERN_CONT "INPUT1 ");
  514. if (type & LCD)
  515. printk(KERN_CONT "LCD ");
  516. if (type & NOGD)
  517. printk(KERN_CONT "NOGD ");
  518. if (type & MONO)
  519. printk(KERN_CONT "MONO ");
  520. if (type & ATSC)
  521. printk(KERN_CONT "ATSC ");
  522. if (type & IF)
  523. printk(KERN_CONT "IF ");
  524. if (type & LG60)
  525. printk(KERN_CONT "LG60 ");
  526. if (type & ATI638)
  527. printk(KERN_CONT "ATI638 ");
  528. if (type & OREN538)
  529. printk(KERN_CONT "OREN538 ");
  530. if (type & OREN36)
  531. printk(KERN_CONT "OREN36 ");
  532. if (type & TOYOTA388)
  533. printk(KERN_CONT "TOYOTA388 ");
  534. if (type & TOYOTA794)
  535. printk(KERN_CONT "TOYOTA794 ");
  536. if (type & DIBCOM52)
  537. printk(KERN_CONT "DIBCOM52 ");
  538. if (type & ZARLINK456)
  539. printk(KERN_CONT "ZARLINK456 ");
  540. if (type & CHINA)
  541. printk(KERN_CONT "CHINA ");
  542. if (type & F6MHZ)
  543. printk(KERN_CONT "F6MHZ ");
  544. if (type & INPUT2)
  545. printk(KERN_CONT "INPUT2 ");
  546. if (type & SCODE)
  547. printk(KERN_CONT "SCODE ");
  548. if (type & HAS_IF)
  549. printk(KERN_CONT "HAS_IF_%d ", int_freq);
  550. }
  551. static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
  552. v4l2_std_id *id)
  553. {
  554. struct xc4000_priv *priv = fe->tuner_priv;
  555. int i, best_i = -1;
  556. unsigned int best_nr_diffs = 255U;
  557. if (!priv->firm) {
  558. printk(KERN_ERR "Error! firmware not loaded\n");
  559. return -EINVAL;
  560. }
  561. if (((type & ~SCODE) == 0) && (*id == 0))
  562. *id = V4L2_STD_PAL;
  563. /* Seek for generic video standard match */
  564. for (i = 0; i < priv->firm_size; i++) {
  565. v4l2_std_id id_diff_mask =
  566. (priv->firm[i].id ^ (*id)) & (*id);
  567. unsigned int type_diff_mask =
  568. (priv->firm[i].type ^ type)
  569. & (BASE_TYPES | DTV_TYPES | LCD | NOGD | MONO | SCODE);
  570. unsigned int nr_diffs;
  571. if (type_diff_mask
  572. & (BASE | INIT1 | FM | DTV6 | DTV7 | DTV78 | DTV8 | SCODE))
  573. continue;
  574. nr_diffs = hweight64(id_diff_mask) + hweight32(type_diff_mask);
  575. if (!nr_diffs) /* Supports all the requested standards */
  576. goto found;
  577. if (nr_diffs < best_nr_diffs) {
  578. best_nr_diffs = nr_diffs;
  579. best_i = i;
  580. }
  581. }
  582. /* FIXME: Would make sense to seek for type "hint" match ? */
  583. if (best_i < 0) {
  584. i = -ENOENT;
  585. goto ret;
  586. }
  587. if (best_nr_diffs > 0U) {
  588. printk(KERN_WARNING
  589. "Selecting best matching firmware (%u bits differ) for "
  590. "type=(%x), id %016llx:\n",
  591. best_nr_diffs, type, (unsigned long long)*id);
  592. i = best_i;
  593. }
  594. found:
  595. *id = priv->firm[i].id;
  596. ret:
  597. if (debug) {
  598. printk(KERN_DEBUG "%s firmware for type=",
  599. (i < 0) ? "Can't find" : "Found");
  600. dump_firm_type(type);
  601. printk(KERN_DEBUG "(%x), id %016llx.\n", type, (unsigned long long)*id);
  602. }
  603. return i;
  604. }
  605. static int load_firmware(struct dvb_frontend *fe, unsigned int type,
  606. v4l2_std_id *id)
  607. {
  608. struct xc4000_priv *priv = fe->tuner_priv;
  609. int pos, rc;
  610. unsigned char *p;
  611. pos = seek_firmware(fe, type, id);
  612. if (pos < 0)
  613. return pos;
  614. p = priv->firm[pos].ptr;
  615. /* Don't complain when the request fails because of i2c stretching */
  616. priv->ignore_i2c_write_errors = 1;
  617. rc = xc_load_i2c_sequence(fe, p);
  618. priv->ignore_i2c_write_errors = 0;
  619. return rc;
  620. }
  621. static int xc4000_fwupload(struct dvb_frontend *fe)
  622. {
  623. struct xc4000_priv *priv = fe->tuner_priv;
  624. const struct firmware *fw = NULL;
  625. const unsigned char *p, *endp;
  626. int rc = 0;
  627. int n, n_array;
  628. char name[33];
  629. const char *fname;
  630. if (firmware_name[0] != '\0') {
  631. fname = firmware_name;
  632. dprintk(1, "Reading custom firmware %s\n", fname);
  633. rc = request_firmware(&fw, fname,
  634. priv->i2c_props.adap->dev.parent);
  635. } else {
  636. fname = XC4000_DEFAULT_FIRMWARE_NEW;
  637. dprintk(1, "Trying to read firmware %s\n", fname);
  638. rc = request_firmware(&fw, fname,
  639. priv->i2c_props.adap->dev.parent);
  640. if (rc == -ENOENT) {
  641. fname = XC4000_DEFAULT_FIRMWARE;
  642. dprintk(1, "Trying to read firmware %s\n", fname);
  643. rc = request_firmware(&fw, fname,
  644. priv->i2c_props.adap->dev.parent);
  645. }
  646. }
  647. if (rc < 0) {
  648. if (rc == -ENOENT)
  649. printk(KERN_ERR "Error: firmware %s not found.\n", fname);
  650. else
  651. printk(KERN_ERR "Error %d while requesting firmware %s\n",
  652. rc, fname);
  653. return rc;
  654. }
  655. dprintk(1, "Loading Firmware: %s\n", fname);
  656. p = fw->data;
  657. endp = p + fw->size;
  658. if (fw->size < sizeof(name) - 1 + 2 + 2) {
  659. printk(KERN_ERR "Error: firmware file %s has invalid size!\n",
  660. fname);
  661. goto corrupt;
  662. }
  663. memcpy(name, p, sizeof(name) - 1);
  664. name[sizeof(name) - 1] = '\0';
  665. p += sizeof(name) - 1;
  666. priv->firm_version = get_unaligned_le16(p);
  667. p += 2;
  668. n_array = get_unaligned_le16(p);
  669. p += 2;
  670. dprintk(1, "Loading %d firmware images from %s, type: %s, ver %d.%d\n",
  671. n_array, fname, name,
  672. priv->firm_version >> 8, priv->firm_version & 0xff);
  673. priv->firm = kcalloc(n_array, sizeof(*priv->firm), GFP_KERNEL);
  674. if (priv->firm == NULL) {
  675. printk(KERN_ERR "Not enough memory to load firmware file.\n");
  676. rc = -ENOMEM;
  677. goto done;
  678. }
  679. priv->firm_size = n_array;
  680. n = -1;
  681. while (p < endp) {
  682. __u32 type, size;
  683. v4l2_std_id id;
  684. __u16 int_freq = 0;
  685. n++;
  686. if (n >= n_array) {
  687. printk(KERN_ERR "More firmware images in file than "
  688. "were expected!\n");
  689. goto corrupt;
  690. }
  691. /* Checks if there's enough bytes to read */
  692. if (endp - p < sizeof(type) + sizeof(id) + sizeof(size))
  693. goto header;
  694. type = get_unaligned_le32(p);
  695. p += sizeof(type);
  696. id = get_unaligned_le64(p);
  697. p += sizeof(id);
  698. if (type & HAS_IF) {
  699. int_freq = get_unaligned_le16(p);
  700. p += sizeof(int_freq);
  701. if (endp - p < sizeof(size))
  702. goto header;
  703. }
  704. size = get_unaligned_le32(p);
  705. p += sizeof(size);
  706. if (!size || size > endp - p) {
  707. printk(KERN_ERR "Firmware type (%x), id %llx is corrupted (size=%d, expected %d)\n",
  708. type, (unsigned long long)id,
  709. (unsigned)(endp - p), size);
  710. goto corrupt;
  711. }
  712. priv->firm[n].ptr = kzalloc(size, GFP_KERNEL);
  713. if (priv->firm[n].ptr == NULL) {
  714. printk(KERN_ERR "Not enough memory to load firmware file.\n");
  715. rc = -ENOMEM;
  716. goto done;
  717. }
  718. if (debug) {
  719. printk(KERN_DEBUG "Reading firmware type ");
  720. dump_firm_type_and_int_freq(type, int_freq);
  721. printk(KERN_DEBUG "(%x), id %llx, size=%d.\n",
  722. type, (unsigned long long)id, size);
  723. }
  724. memcpy(priv->firm[n].ptr, p, size);
  725. priv->firm[n].type = type;
  726. priv->firm[n].id = id;
  727. priv->firm[n].size = size;
  728. priv->firm[n].int_freq = int_freq;
  729. p += size;
  730. }
  731. if (n + 1 != priv->firm_size) {
  732. printk(KERN_ERR "Firmware file is incomplete!\n");
  733. goto corrupt;
  734. }
  735. goto done;
  736. header:
  737. printk(KERN_ERR "Firmware header is incomplete!\n");
  738. corrupt:
  739. rc = -EINVAL;
  740. printk(KERN_ERR "Error: firmware file is corrupted!\n");
  741. done:
  742. release_firmware(fw);
  743. if (rc == 0)
  744. dprintk(1, "Firmware files loaded.\n");
  745. return rc;
  746. }
  747. static int load_scode(struct dvb_frontend *fe, unsigned int type,
  748. v4l2_std_id *id, __u16 int_freq, int scode)
  749. {
  750. struct xc4000_priv *priv = fe->tuner_priv;
  751. int pos, rc;
  752. unsigned char *p;
  753. u8 scode_buf[13];
  754. u8 indirect_mode[5];
  755. dprintk(1, "%s called int_freq=%d\n", __func__, int_freq);
  756. if (!int_freq) {
  757. pos = seek_firmware(fe, type, id);
  758. if (pos < 0)
  759. return pos;
  760. } else {
  761. for (pos = 0; pos < priv->firm_size; pos++) {
  762. if ((priv->firm[pos].int_freq == int_freq) &&
  763. (priv->firm[pos].type & HAS_IF))
  764. break;
  765. }
  766. if (pos == priv->firm_size)
  767. return -ENOENT;
  768. }
  769. p = priv->firm[pos].ptr;
  770. if (priv->firm[pos].size != 12 * 16 || scode >= 16)
  771. return -EINVAL;
  772. p += 12 * scode;
  773. if (debug) {
  774. tuner_info("Loading SCODE for type=");
  775. dump_firm_type_and_int_freq(priv->firm[pos].type,
  776. priv->firm[pos].int_freq);
  777. printk(KERN_CONT "(%x), id %016llx.\n", priv->firm[pos].type,
  778. (unsigned long long)*id);
  779. }
  780. scode_buf[0] = 0x00;
  781. memcpy(&scode_buf[1], p, 12);
  782. /* Enter direct-mode */
  783. rc = xc_write_reg(priv, XREG_DIRECTSITTING_MODE, 0);
  784. if (rc < 0) {
  785. printk(KERN_ERR "failed to put device into direct mode!\n");
  786. return -EIO;
  787. }
  788. rc = xc_send_i2c_data(priv, scode_buf, 13);
  789. if (rc != 0) {
  790. /* Even if the send failed, make sure we set back to indirect
  791. mode */
  792. printk(KERN_ERR "Failed to set scode %d\n", rc);
  793. }
  794. /* Switch back to indirect-mode */
  795. memset(indirect_mode, 0, sizeof(indirect_mode));
  796. indirect_mode[4] = 0x88;
  797. xc_send_i2c_data(priv, indirect_mode, sizeof(indirect_mode));
  798. msleep(10);
  799. return 0;
  800. }
  801. static int check_firmware(struct dvb_frontend *fe, unsigned int type,
  802. v4l2_std_id std, __u16 int_freq)
  803. {
  804. struct xc4000_priv *priv = fe->tuner_priv;
  805. struct firmware_properties new_fw;
  806. int rc = 0, is_retry = 0;
  807. u16 hwmodel;
  808. v4l2_std_id std0;
  809. u8 hw_major = 0, hw_minor = 0, fw_major = 0, fw_minor = 0;
  810. dprintk(1, "%s called\n", __func__);
  811. if (!priv->firm) {
  812. rc = xc4000_fwupload(fe);
  813. if (rc < 0)
  814. return rc;
  815. }
  816. retry:
  817. new_fw.type = type;
  818. new_fw.id = std;
  819. new_fw.std_req = std;
  820. new_fw.scode_table = SCODE;
  821. new_fw.scode_nr = 0;
  822. new_fw.int_freq = int_freq;
  823. dprintk(1, "checking firmware, user requested type=");
  824. if (debug) {
  825. dump_firm_type(new_fw.type);
  826. printk(KERN_CONT "(%x), id %016llx, ", new_fw.type,
  827. (unsigned long long)new_fw.std_req);
  828. if (!int_freq)
  829. printk(KERN_CONT "scode_tbl ");
  830. else
  831. printk(KERN_CONT "int_freq %d, ", new_fw.int_freq);
  832. printk(KERN_CONT "scode_nr %d\n", new_fw.scode_nr);
  833. }
  834. /* No need to reload base firmware if it matches */
  835. if (priv->cur_fw.type & BASE) {
  836. dprintk(1, "BASE firmware not changed.\n");
  837. goto skip_base;
  838. }
  839. /* Updating BASE - forget about all currently loaded firmware */
  840. memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
  841. /* Reset is needed before loading firmware */
  842. rc = xc4000_tuner_reset(fe);
  843. if (rc < 0)
  844. goto fail;
  845. /* BASE firmwares are all std0 */
  846. std0 = 0;
  847. rc = load_firmware(fe, BASE, &std0);
  848. if (rc < 0) {
  849. printk(KERN_ERR "Error %d while loading base firmware\n", rc);
  850. goto fail;
  851. }
  852. /* Load INIT1, if needed */
  853. dprintk(1, "Load init1 firmware, if exists\n");
  854. rc = load_firmware(fe, BASE | INIT1, &std0);
  855. if (rc == -ENOENT)
  856. rc = load_firmware(fe, BASE | INIT1, &std0);
  857. if (rc < 0 && rc != -ENOENT) {
  858. tuner_err("Error %d while loading init1 firmware\n",
  859. rc);
  860. goto fail;
  861. }
  862. skip_base:
  863. /*
  864. * No need to reload standard specific firmware if base firmware
  865. * was not reloaded and requested video standards have not changed.
  866. */
  867. if (priv->cur_fw.type == (BASE | new_fw.type) &&
  868. priv->cur_fw.std_req == std) {
  869. dprintk(1, "Std-specific firmware already loaded.\n");
  870. goto skip_std_specific;
  871. }
  872. /* Reloading std-specific firmware forces a SCODE update */
  873. priv->cur_fw.scode_table = 0;
  874. /* Load the standard firmware */
  875. rc = load_firmware(fe, new_fw.type, &new_fw.id);
  876. if (rc < 0)
  877. goto fail;
  878. skip_std_specific:
  879. if (priv->cur_fw.scode_table == new_fw.scode_table &&
  880. priv->cur_fw.scode_nr == new_fw.scode_nr) {
  881. dprintk(1, "SCODE firmware already loaded.\n");
  882. goto check_device;
  883. }
  884. /* Load SCODE firmware, if exists */
  885. rc = load_scode(fe, new_fw.type | new_fw.scode_table, &new_fw.id,
  886. new_fw.int_freq, new_fw.scode_nr);
  887. if (rc != 0)
  888. dprintk(1, "load scode failed %d\n", rc);
  889. check_device:
  890. rc = xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel);
  891. if (xc_get_version(priv, &hw_major, &hw_minor, &fw_major,
  892. &fw_minor) != 0) {
  893. printk(KERN_ERR "Unable to read tuner registers.\n");
  894. goto fail;
  895. }
  896. dprintk(1, "Device is Xceive %d version %d.%d, "
  897. "firmware version %d.%d\n",
  898. hwmodel, hw_major, hw_minor, fw_major, fw_minor);
  899. /* Check firmware version against what we downloaded. */
  900. if (priv->firm_version != ((fw_major << 8) | fw_minor)) {
  901. printk(KERN_WARNING
  902. "Incorrect readback of firmware version %d.%d.\n",
  903. fw_major, fw_minor);
  904. goto fail;
  905. }
  906. /* Check that the tuner hardware model remains consistent over time. */
  907. if (priv->hwmodel == 0 &&
  908. (hwmodel == XC_PRODUCT_ID_XC4000 ||
  909. hwmodel == XC_PRODUCT_ID_XC4100)) {
  910. priv->hwmodel = hwmodel;
  911. priv->hwvers = (hw_major << 8) | hw_minor;
  912. } else if (priv->hwmodel == 0 || priv->hwmodel != hwmodel ||
  913. priv->hwvers != ((hw_major << 8) | hw_minor)) {
  914. printk(KERN_WARNING
  915. "Read invalid device hardware information - tuner "
  916. "hung?\n");
  917. goto fail;
  918. }
  919. priv->cur_fw = new_fw;
  920. /*
  921. * By setting BASE in cur_fw.type only after successfully loading all
  922. * firmwares, we can:
  923. * 1. Identify that BASE firmware with type=0 has been loaded;
  924. * 2. Tell whether BASE firmware was just changed the next time through.
  925. */
  926. priv->cur_fw.type |= BASE;
  927. return 0;
  928. fail:
  929. memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
  930. if (!is_retry) {
  931. msleep(50);
  932. is_retry = 1;
  933. dprintk(1, "Retrying firmware load\n");
  934. goto retry;
  935. }
  936. if (rc == -ENOENT)
  937. rc = -EINVAL;
  938. return rc;
  939. }
  940. static void xc_debug_dump(struct xc4000_priv *priv)
  941. {
  942. u16 adc_envelope;
  943. u32 freq_error_hz = 0;
  944. u16 lock_status;
  945. u32 hsync_freq_hz = 0;
  946. u16 frame_lines;
  947. u16 quality;
  948. u16 signal = 0;
  949. u16 noise = 0;
  950. u8 hw_majorversion = 0, hw_minorversion = 0;
  951. u8 fw_majorversion = 0, fw_minorversion = 0;
  952. xc_get_adc_envelope(priv, &adc_envelope);
  953. dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope);
  954. xc_get_frequency_error(priv, &freq_error_hz);
  955. dprintk(1, "*** Frequency error = %d Hz\n", freq_error_hz);
  956. xc_get_lock_status(priv, &lock_status);
  957. dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n",
  958. lock_status);
  959. xc_get_version(priv, &hw_majorversion, &hw_minorversion,
  960. &fw_majorversion, &fw_minorversion);
  961. dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n",
  962. hw_majorversion, hw_minorversion,
  963. fw_majorversion, fw_minorversion);
  964. if (priv->video_standard < XC4000_DTV6) {
  965. xc_get_hsync_freq(priv, &hsync_freq_hz);
  966. dprintk(1, "*** Horizontal sync frequency = %d Hz\n",
  967. hsync_freq_hz);
  968. xc_get_frame_lines(priv, &frame_lines);
  969. dprintk(1, "*** Frame lines = %d\n", frame_lines);
  970. }
  971. xc_get_quality(priv, &quality);
  972. dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality);
  973. xc_get_signal_level(priv, &signal);
  974. dprintk(1, "*** Signal level = -%ddB (%d)\n", signal >> 8, signal);
  975. xc_get_noise_level(priv, &noise);
  976. dprintk(1, "*** Noise level = %ddB (%d)\n", noise >> 8, noise);
  977. }
  978. static int xc4000_set_params(struct dvb_frontend *fe)
  979. {
  980. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  981. u32 delsys = c->delivery_system;
  982. u32 bw = c->bandwidth_hz;
  983. struct xc4000_priv *priv = fe->tuner_priv;
  984. unsigned int type;
  985. int ret = -EREMOTEIO;
  986. dprintk(1, "%s() frequency=%d (Hz)\n", __func__, c->frequency);
  987. mutex_lock(&priv->lock);
  988. switch (delsys) {
  989. case SYS_ATSC:
  990. dprintk(1, "%s() VSB modulation\n", __func__);
  991. priv->rf_mode = XC_RF_MODE_AIR;
  992. priv->freq_offset = 1750000;
  993. priv->video_standard = XC4000_DTV6;
  994. type = DTV6;
  995. break;
  996. case SYS_DVBC_ANNEX_B:
  997. dprintk(1, "%s() QAM modulation\n", __func__);
  998. priv->rf_mode = XC_RF_MODE_CABLE;
  999. priv->freq_offset = 1750000;
  1000. priv->video_standard = XC4000_DTV6;
  1001. type = DTV6;
  1002. break;
  1003. case SYS_DVBT:
  1004. case SYS_DVBT2:
  1005. dprintk(1, "%s() OFDM\n", __func__);
  1006. if (bw == 0) {
  1007. if (c->frequency < 400000000) {
  1008. priv->freq_offset = 2250000;
  1009. } else {
  1010. priv->freq_offset = 2750000;
  1011. }
  1012. priv->video_standard = XC4000_DTV7_8;
  1013. type = DTV78;
  1014. } else if (bw <= 6000000) {
  1015. priv->video_standard = XC4000_DTV6;
  1016. priv->freq_offset = 1750000;
  1017. type = DTV6;
  1018. } else if (bw <= 7000000) {
  1019. priv->video_standard = XC4000_DTV7;
  1020. priv->freq_offset = 2250000;
  1021. type = DTV7;
  1022. } else {
  1023. priv->video_standard = XC4000_DTV8;
  1024. priv->freq_offset = 2750000;
  1025. type = DTV8;
  1026. }
  1027. priv->rf_mode = XC_RF_MODE_AIR;
  1028. break;
  1029. default:
  1030. printk(KERN_ERR "xc4000 delivery system not supported!\n");
  1031. ret = -EINVAL;
  1032. goto fail;
  1033. }
  1034. priv->freq_hz = c->frequency - priv->freq_offset;
  1035. dprintk(1, "%s() frequency=%d (compensated)\n",
  1036. __func__, priv->freq_hz);
  1037. /* Make sure the correct firmware type is loaded */
  1038. if (check_firmware(fe, type, 0, priv->if_khz) != 0)
  1039. goto fail;
  1040. priv->bandwidth = c->bandwidth_hz;
  1041. ret = xc_set_signal_source(priv, priv->rf_mode);
  1042. if (ret != 0) {
  1043. printk(KERN_ERR "xc4000: xc_set_signal_source(%d) failed\n",
  1044. priv->rf_mode);
  1045. goto fail;
  1046. } else {
  1047. u16 video_mode, audio_mode;
  1048. video_mode = xc4000_standard[priv->video_standard].video_mode;
  1049. audio_mode = xc4000_standard[priv->video_standard].audio_mode;
  1050. if (type == DTV6 && priv->firm_version != 0x0102)
  1051. video_mode |= 0x0001;
  1052. ret = xc_set_tv_standard(priv, video_mode, audio_mode);
  1053. if (ret != 0) {
  1054. printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n");
  1055. /* DJH - do not return when it fails... */
  1056. /* goto fail; */
  1057. }
  1058. }
  1059. if (xc_write_reg(priv, XREG_D_CODE, 0) == 0)
  1060. ret = 0;
  1061. if (priv->dvb_amplitude != 0) {
  1062. if (xc_write_reg(priv, XREG_AMPLITUDE,
  1063. (priv->firm_version != 0x0102 ||
  1064. priv->dvb_amplitude != 134 ?
  1065. priv->dvb_amplitude : 132)) != 0)
  1066. ret = -EREMOTEIO;
  1067. }
  1068. if (priv->set_smoothedcvbs != 0) {
  1069. if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0)
  1070. ret = -EREMOTEIO;
  1071. }
  1072. if (ret != 0) {
  1073. printk(KERN_ERR "xc4000: setting registers failed\n");
  1074. /* goto fail; */
  1075. }
  1076. xc_tune_channel(priv, priv->freq_hz);
  1077. ret = 0;
  1078. fail:
  1079. mutex_unlock(&priv->lock);
  1080. return ret;
  1081. }
  1082. static int xc4000_set_analog_params(struct dvb_frontend *fe,
  1083. struct analog_parameters *params)
  1084. {
  1085. struct xc4000_priv *priv = fe->tuner_priv;
  1086. unsigned int type = 0;
  1087. int ret = -EREMOTEIO;
  1088. if (params->mode == V4L2_TUNER_RADIO) {
  1089. dprintk(1, "%s() frequency=%d (in units of 62.5Hz)\n",
  1090. __func__, params->frequency);
  1091. mutex_lock(&priv->lock);
  1092. params->std = 0;
  1093. priv->freq_hz = params->frequency * 125L / 2;
  1094. if (audio_std & XC4000_AUDIO_STD_INPUT1) {
  1095. priv->video_standard = XC4000_FM_Radio_INPUT1;
  1096. type = FM | INPUT1;
  1097. } else {
  1098. priv->video_standard = XC4000_FM_Radio_INPUT2;
  1099. type = FM | INPUT2;
  1100. }
  1101. goto tune_channel;
  1102. }
  1103. dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n",
  1104. __func__, params->frequency);
  1105. mutex_lock(&priv->lock);
  1106. /* params->frequency is in units of 62.5khz */
  1107. priv->freq_hz = params->frequency * 62500;
  1108. params->std &= V4L2_STD_ALL;
  1109. /* if std is not defined, choose one */
  1110. if (!params->std)
  1111. params->std = V4L2_STD_PAL_BG;
  1112. if (audio_std & XC4000_AUDIO_STD_MONO)
  1113. type = MONO;
  1114. if (params->std & V4L2_STD_MN) {
  1115. params->std = V4L2_STD_MN;
  1116. if (audio_std & XC4000_AUDIO_STD_MONO) {
  1117. priv->video_standard = XC4000_MN_NTSC_PAL_Mono;
  1118. } else if (audio_std & XC4000_AUDIO_STD_A2) {
  1119. params->std |= V4L2_STD_A2;
  1120. priv->video_standard = XC4000_MN_NTSC_PAL_A2;
  1121. } else {
  1122. params->std |= V4L2_STD_BTSC;
  1123. priv->video_standard = XC4000_MN_NTSC_PAL_BTSC;
  1124. }
  1125. goto tune_channel;
  1126. }
  1127. if (params->std & V4L2_STD_PAL_BG) {
  1128. params->std = V4L2_STD_PAL_BG;
  1129. if (audio_std & XC4000_AUDIO_STD_MONO) {
  1130. priv->video_standard = XC4000_BG_PAL_MONO;
  1131. } else if (!(audio_std & XC4000_AUDIO_STD_A2)) {
  1132. if (!(audio_std & XC4000_AUDIO_STD_B)) {
  1133. params->std |= V4L2_STD_NICAM_A;
  1134. priv->video_standard = XC4000_BG_PAL_NICAM;
  1135. } else {
  1136. params->std |= V4L2_STD_NICAM_B;
  1137. priv->video_standard = XC4000_BG_PAL_NICAM;
  1138. }
  1139. } else {
  1140. if (!(audio_std & XC4000_AUDIO_STD_B)) {
  1141. params->std |= V4L2_STD_A2_A;
  1142. priv->video_standard = XC4000_BG_PAL_A2;
  1143. } else {
  1144. params->std |= V4L2_STD_A2_B;
  1145. priv->video_standard = XC4000_BG_PAL_A2;
  1146. }
  1147. }
  1148. goto tune_channel;
  1149. }
  1150. if (params->std & V4L2_STD_PAL_I) {
  1151. /* default to NICAM audio standard */
  1152. params->std = V4L2_STD_PAL_I | V4L2_STD_NICAM;
  1153. if (audio_std & XC4000_AUDIO_STD_MONO)
  1154. priv->video_standard = XC4000_I_PAL_NICAM_MONO;
  1155. else
  1156. priv->video_standard = XC4000_I_PAL_NICAM;
  1157. goto tune_channel;
  1158. }
  1159. if (params->std & V4L2_STD_PAL_DK) {
  1160. params->std = V4L2_STD_PAL_DK;
  1161. if (audio_std & XC4000_AUDIO_STD_MONO) {
  1162. priv->video_standard = XC4000_DK_PAL_MONO;
  1163. } else if (audio_std & XC4000_AUDIO_STD_A2) {
  1164. params->std |= V4L2_STD_A2;
  1165. priv->video_standard = XC4000_DK_PAL_A2;
  1166. } else {
  1167. params->std |= V4L2_STD_NICAM;
  1168. priv->video_standard = XC4000_DK_PAL_NICAM;
  1169. }
  1170. goto tune_channel;
  1171. }
  1172. if (params->std & V4L2_STD_SECAM_DK) {
  1173. /* default to A2 audio standard */
  1174. params->std = V4L2_STD_SECAM_DK | V4L2_STD_A2;
  1175. if (audio_std & XC4000_AUDIO_STD_L) {
  1176. type = 0;
  1177. priv->video_standard = XC4000_DK_SECAM_NICAM;
  1178. } else if (audio_std & XC4000_AUDIO_STD_MONO) {
  1179. priv->video_standard = XC4000_DK_SECAM_A2MONO;
  1180. } else if (audio_std & XC4000_AUDIO_STD_K3) {
  1181. params->std |= V4L2_STD_SECAM_K3;
  1182. priv->video_standard = XC4000_DK_SECAM_A2LDK3;
  1183. } else {
  1184. priv->video_standard = XC4000_DK_SECAM_A2DK1;
  1185. }
  1186. goto tune_channel;
  1187. }
  1188. if (params->std & V4L2_STD_SECAM_L) {
  1189. /* default to NICAM audio standard */
  1190. type = 0;
  1191. params->std = V4L2_STD_SECAM_L | V4L2_STD_NICAM;
  1192. priv->video_standard = XC4000_L_SECAM_NICAM;
  1193. goto tune_channel;
  1194. }
  1195. if (params->std & V4L2_STD_SECAM_LC) {
  1196. /* default to NICAM audio standard */
  1197. type = 0;
  1198. params->std = V4L2_STD_SECAM_LC | V4L2_STD_NICAM;
  1199. priv->video_standard = XC4000_LC_SECAM_NICAM;
  1200. goto tune_channel;
  1201. }
  1202. tune_channel:
  1203. /* FIXME: it could be air. */
  1204. priv->rf_mode = XC_RF_MODE_CABLE;
  1205. if (check_firmware(fe, type, params->std,
  1206. xc4000_standard[priv->video_standard].int_freq) != 0)
  1207. goto fail;
  1208. ret = xc_set_signal_source(priv, priv->rf_mode);
  1209. if (ret != 0) {
  1210. printk(KERN_ERR
  1211. "xc4000: xc_set_signal_source(%d) failed\n",
  1212. priv->rf_mode);
  1213. goto fail;
  1214. } else {
  1215. u16 video_mode, audio_mode;
  1216. video_mode = xc4000_standard[priv->video_standard].video_mode;
  1217. audio_mode = xc4000_standard[priv->video_standard].audio_mode;
  1218. if (priv->video_standard < XC4000_BG_PAL_A2) {
  1219. if (type & NOGD)
  1220. video_mode &= 0xFF7F;
  1221. } else if (priv->video_standard < XC4000_I_PAL_NICAM) {
  1222. if (priv->firm_version == 0x0102)
  1223. video_mode &= 0xFEFF;
  1224. if (audio_std & XC4000_AUDIO_STD_B)
  1225. video_mode |= 0x0080;
  1226. }
  1227. ret = xc_set_tv_standard(priv, video_mode, audio_mode);
  1228. if (ret != 0) {
  1229. printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n");
  1230. goto fail;
  1231. }
  1232. }
  1233. if (xc_write_reg(priv, XREG_D_CODE, 0) == 0)
  1234. ret = 0;
  1235. if (xc_write_reg(priv, XREG_AMPLITUDE, 1) != 0)
  1236. ret = -EREMOTEIO;
  1237. if (priv->set_smoothedcvbs != 0) {
  1238. if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0)
  1239. ret = -EREMOTEIO;
  1240. }
  1241. if (ret != 0) {
  1242. printk(KERN_ERR "xc4000: setting registers failed\n");
  1243. goto fail;
  1244. }
  1245. xc_tune_channel(priv, priv->freq_hz);
  1246. ret = 0;
  1247. fail:
  1248. mutex_unlock(&priv->lock);
  1249. return ret;
  1250. }
  1251. static int xc4000_get_signal(struct dvb_frontend *fe, u16 *strength)
  1252. {
  1253. struct xc4000_priv *priv = fe->tuner_priv;
  1254. u16 value = 0;
  1255. int rc;
  1256. mutex_lock(&priv->lock);
  1257. rc = xc4000_readreg(priv, XREG_SIGNAL_LEVEL, &value);
  1258. mutex_unlock(&priv->lock);
  1259. if (rc < 0)
  1260. goto ret;
  1261. /* Informations from real testing of DVB-T and radio part,
  1262. coeficient for one dB is 0xff.
  1263. */
  1264. tuner_dbg("Signal strength: -%ddB (%05d)\n", value >> 8, value);
  1265. /* all known digital modes */
  1266. if ((priv->video_standard == XC4000_DTV6) ||
  1267. (priv->video_standard == XC4000_DTV7) ||
  1268. (priv->video_standard == XC4000_DTV7_8) ||
  1269. (priv->video_standard == XC4000_DTV8))
  1270. goto digital;
  1271. /* Analog mode has NOISE LEVEL important, signal
  1272. depends only on gain of antenna and amplifiers,
  1273. but it doesn't tell anything about real quality
  1274. of reception.
  1275. */
  1276. mutex_lock(&priv->lock);
  1277. rc = xc4000_readreg(priv, XREG_NOISE_LEVEL, &value);
  1278. mutex_unlock(&priv->lock);
  1279. tuner_dbg("Noise level: %ddB (%05d)\n", value >> 8, value);
  1280. /* highest noise level: 32dB */
  1281. if (value >= 0x2000) {
  1282. value = 0;
  1283. } else {
  1284. value = ~value << 3;
  1285. }
  1286. goto ret;
  1287. /* Digital mode has SIGNAL LEVEL important and real
  1288. noise level is stored in demodulator registers.
  1289. */
  1290. digital:
  1291. /* best signal: -50dB */
  1292. if (value <= 0x3200) {
  1293. value = 0xffff;
  1294. /* minimum: -114dB - should be 0x7200 but real zero is 0x713A */
  1295. } else if (value >= 0x713A) {
  1296. value = 0;
  1297. } else {
  1298. value = ~(value - 0x3200) << 2;
  1299. }
  1300. ret:
  1301. *strength = value;
  1302. return rc;
  1303. }
  1304. static int xc4000_get_frequency(struct dvb_frontend *fe, u32 *freq)
  1305. {
  1306. struct xc4000_priv *priv = fe->tuner_priv;
  1307. *freq = priv->freq_hz + priv->freq_offset;
  1308. if (debug) {
  1309. mutex_lock(&priv->lock);
  1310. if ((priv->cur_fw.type
  1311. & (BASE | FM | DTV6 | DTV7 | DTV78 | DTV8)) == BASE) {
  1312. u16 snr = 0;
  1313. if (xc4000_readreg(priv, XREG_SNR, &snr) == 0) {
  1314. mutex_unlock(&priv->lock);
  1315. dprintk(1, "%s() freq = %u, SNR = %d\n",
  1316. __func__, *freq, snr);
  1317. return 0;
  1318. }
  1319. }
  1320. mutex_unlock(&priv->lock);
  1321. }
  1322. dprintk(1, "%s()\n", __func__);
  1323. return 0;
  1324. }
  1325. static int xc4000_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
  1326. {
  1327. struct xc4000_priv *priv = fe->tuner_priv;
  1328. dprintk(1, "%s()\n", __func__);
  1329. *bw = priv->bandwidth;
  1330. return 0;
  1331. }
  1332. static int xc4000_get_status(struct dvb_frontend *fe, u32 *status)
  1333. {
  1334. struct xc4000_priv *priv = fe->tuner_priv;
  1335. u16 lock_status = 0;
  1336. mutex_lock(&priv->lock);
  1337. if (priv->cur_fw.type & BASE)
  1338. xc_get_lock_status(priv, &lock_status);
  1339. *status = (lock_status == 1 ?
  1340. TUNER_STATUS_LOCKED | TUNER_STATUS_STEREO : 0);
  1341. if (priv->cur_fw.type & (DTV6 | DTV7 | DTV78 | DTV8))
  1342. *status &= (~TUNER_STATUS_STEREO);
  1343. mutex_unlock(&priv->lock);
  1344. dprintk(2, "%s() lock_status = %d\n", __func__, lock_status);
  1345. return 0;
  1346. }
  1347. static int xc4000_sleep(struct dvb_frontend *fe)
  1348. {
  1349. struct xc4000_priv *priv = fe->tuner_priv;
  1350. int ret = 0;
  1351. dprintk(1, "%s()\n", __func__);
  1352. mutex_lock(&priv->lock);
  1353. /* Avoid firmware reload on slow devices */
  1354. if ((no_poweroff == 2 ||
  1355. (no_poweroff == 0 && priv->default_pm != 0)) &&
  1356. (priv->cur_fw.type & BASE) != 0) {
  1357. /* force reset and firmware reload */
  1358. priv->cur_fw.type = XC_POWERED_DOWN;
  1359. if (xc_write_reg(priv, XREG_POWER_DOWN, 0) != 0) {
  1360. printk(KERN_ERR
  1361. "xc4000: %s() unable to shutdown tuner\n",
  1362. __func__);
  1363. ret = -EREMOTEIO;
  1364. }
  1365. msleep(20);
  1366. }
  1367. mutex_unlock(&priv->lock);
  1368. return ret;
  1369. }
  1370. static int xc4000_init(struct dvb_frontend *fe)
  1371. {
  1372. dprintk(1, "%s()\n", __func__);
  1373. return 0;
  1374. }
  1375. static int xc4000_release(struct dvb_frontend *fe)
  1376. {
  1377. struct xc4000_priv *priv = fe->tuner_priv;
  1378. dprintk(1, "%s()\n", __func__);
  1379. mutex_lock(&xc4000_list_mutex);
  1380. if (priv)
  1381. hybrid_tuner_release_state(priv);
  1382. mutex_unlock(&xc4000_list_mutex);
  1383. fe->tuner_priv = NULL;
  1384. return 0;
  1385. }
  1386. static const struct dvb_tuner_ops xc4000_tuner_ops = {
  1387. .info = {
  1388. .name = "Xceive XC4000",
  1389. .frequency_min = 1000000,
  1390. .frequency_max = 1023000000,
  1391. .frequency_step = 50000,
  1392. },
  1393. .release = xc4000_release,
  1394. .init = xc4000_init,
  1395. .sleep = xc4000_sleep,
  1396. .set_params = xc4000_set_params,
  1397. .set_analog_params = xc4000_set_analog_params,
  1398. .get_frequency = xc4000_get_frequency,
  1399. .get_rf_strength = xc4000_get_signal,
  1400. .get_bandwidth = xc4000_get_bandwidth,
  1401. .get_status = xc4000_get_status
  1402. };
  1403. struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
  1404. struct i2c_adapter *i2c,
  1405. struct xc4000_config *cfg)
  1406. {
  1407. struct xc4000_priv *priv = NULL;
  1408. int instance;
  1409. u16 id = 0;
  1410. dprintk(1, "%s(%d-%04x)\n", __func__,
  1411. i2c ? i2c_adapter_id(i2c) : -1,
  1412. cfg ? cfg->i2c_address : -1);
  1413. mutex_lock(&xc4000_list_mutex);
  1414. instance = hybrid_tuner_request_state(struct xc4000_priv, priv,
  1415. hybrid_tuner_instance_list,
  1416. i2c, cfg->i2c_address, "xc4000");
  1417. switch (instance) {
  1418. case 0:
  1419. goto fail;
  1420. case 1:
  1421. /* new tuner instance */
  1422. priv->bandwidth = 6000000;
  1423. /* set default configuration */
  1424. priv->if_khz = 4560;
  1425. priv->default_pm = 0;
  1426. priv->dvb_amplitude = 134;
  1427. priv->set_smoothedcvbs = 1;
  1428. mutex_init(&priv->lock);
  1429. fe->tuner_priv = priv;
  1430. break;
  1431. default:
  1432. /* existing tuner instance */
  1433. fe->tuner_priv = priv;
  1434. break;
  1435. }
  1436. if (cfg->if_khz != 0) {
  1437. /* copy configuration if provided by the caller */
  1438. priv->if_khz = cfg->if_khz;
  1439. priv->default_pm = cfg->default_pm;
  1440. priv->dvb_amplitude = cfg->dvb_amplitude;
  1441. priv->set_smoothedcvbs = cfg->set_smoothedcvbs;
  1442. }
  1443. /* Check if firmware has been loaded. It is possible that another
  1444. instance of the driver has loaded the firmware.
  1445. */
  1446. if (instance == 1) {
  1447. if (xc4000_readreg(priv, XREG_PRODUCT_ID, &id) != 0)
  1448. goto fail;
  1449. } else {
  1450. id = ((priv->cur_fw.type & BASE) != 0 ?
  1451. priv->hwmodel : XC_PRODUCT_ID_FW_NOT_LOADED);
  1452. }
  1453. switch (id) {
  1454. case XC_PRODUCT_ID_XC4000:
  1455. case XC_PRODUCT_ID_XC4100:
  1456. printk(KERN_INFO
  1457. "xc4000: Successfully identified at address 0x%02x\n",
  1458. cfg->i2c_address);
  1459. printk(KERN_INFO
  1460. "xc4000: Firmware has been loaded previously\n");
  1461. break;
  1462. case XC_PRODUCT_ID_FW_NOT_LOADED:
  1463. printk(KERN_INFO
  1464. "xc4000: Successfully identified at address 0x%02x\n",
  1465. cfg->i2c_address);
  1466. printk(KERN_INFO
  1467. "xc4000: Firmware has not been loaded previously\n");
  1468. break;
  1469. default:
  1470. printk(KERN_ERR
  1471. "xc4000: Device not found at addr 0x%02x (0x%x)\n",
  1472. cfg->i2c_address, id);
  1473. goto fail;
  1474. }
  1475. mutex_unlock(&xc4000_list_mutex);
  1476. memcpy(&fe->ops.tuner_ops, &xc4000_tuner_ops,
  1477. sizeof(struct dvb_tuner_ops));
  1478. if (instance == 1) {
  1479. int ret;
  1480. mutex_lock(&priv->lock);
  1481. ret = xc4000_fwupload(fe);
  1482. mutex_unlock(&priv->lock);
  1483. if (ret != 0)
  1484. goto fail2;
  1485. }
  1486. return fe;
  1487. fail:
  1488. mutex_unlock(&xc4000_list_mutex);
  1489. fail2:
  1490. xc4000_release(fe);
  1491. return NULL;
  1492. }
  1493. EXPORT_SYMBOL(xc4000_attach);
  1494. MODULE_AUTHOR("Steven Toth, Davide Ferri");
  1495. MODULE_DESCRIPTION("Xceive xc4000 silicon tuner driver");
  1496. MODULE_LICENSE("GPL");
  1497. MODULE_FIRMWARE(XC4000_DEFAULT_FIRMWARE_NEW);
  1498. MODULE_FIRMWARE(XC4000_DEFAULT_FIRMWARE);