Advertisement
Guest User

technisat skystar 2 pci linux kernel patch

a guest
Apr 10th, 2015
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 57.02 KB | None | 0 0
  1. diff -NurEbBw --strip-trailing-cr drivers/media/common/b2c2/flexcop-common.h drivers/media/common/b2c2/flexcop-common.h
  2. --- linux/drivers/media/common/b2c2/flexcop-common.h    2012-04-03 15:23:44.824143495 +0400
  3. +++ linux/drivers/media/common/b2c2/flexcop-common.h    2012-04-03 15:26:40.756140116 +0400
  4. @@ -91,6 +91,8 @@
  5.     int feedcount;
  6.     int pid_filtering;
  7.     int fullts_streaming_state;
  8. +   /* the stream will be activated by an externally (by the fe for example) */
  9. +   int need_external_stream_control;
  10.  
  11.     /* bus specific callbacks */
  12.     flexcop_ibi_value(*read_ibi_reg) (struct flexcop_device *,
  13. @@ -177,6 +179,8 @@
  14.         struct dvb_demux_feed *dvbdmxfeed, int onoff);
  15.  void flexcop_hw_filter_init(struct flexcop_device *fc);
  16.  
  17. +extern void flexcop_external_stream_control(struct dvb_frontend *fe, u8 onoff);
  18. +
  19.  void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
  20.  
  21.  void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6]);
  22. diff -NurEbBw --strip-trailing-cr drivers/media/common/b2c2/flexcop-fe-tuner.c drivers/media/common/b2c2/flexcop-fe-tuner.c
  23. --- linux/drivers/media/common/b2c2/flexcop-fe-tuner.c  2012-04-03 15:23:44.828143388 +0400
  24. +++ linux/drivers/media/common/b2c2/flexcop-fe-tuner.c  2012-04-03 15:26:40.760141513 +0400
  25. @@ -12,6 +12,7 @@
  26.  #include "cx24113.h"
  27.  #include "cx24123.h"
  28.  #include "isl6421.h"
  29. +#include "cx24120.h"
  30.  #include "mt352.h"
  31.  #include "bcm3510.h"
  32.  #include "nxt200x.h"
  33. @@ -26,6 +27,15 @@
  34.  #define FE_SUPPORTED(fe) (defined(CONFIG_DVB_##fe) || \
  35.     (defined(CONFIG_DVB_##fe##_MODULE) && defined(MODULE)))
  36.  
  37. +#if FE_SUPPORTED(BCM3510) || FE_SUPPORTED(CX24120)
  38. +static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
  39. +   const struct firmware **fw, char* name)
  40. +{
  41. +   struct flexcop_device *fc = fe->dvb->priv;
  42. +   return request_firmware(fw, name, fc->dev);
  43. +}
  44. +#endif
  45. +
  46.  /* lnb control */
  47.  #if FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)
  48.  static int flexcop_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  49. @@ -445,13 +455,6 @@
  50.  
  51.  /* AirStar ATSC 1st generation */
  52.  #if FE_SUPPORTED(BCM3510)
  53. -static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
  54. -   const struct firmware **fw, char* name)
  55. -{
  56. -   struct flexcop_device *fc = fe->dvb->priv;
  57. -   return request_firmware(fw, name, fc->dev);
  58. -}
  59. -
  60.  static struct bcm3510_config air2pc_atsc_first_gen_config = {
  61.     .demod_address    = 0x0f,
  62.     .request_firmware = flexcop_fe_request_firmware,
  63. @@ -619,10 +622,40 @@
  64.  #define cablestar2_attach NULL
  65.  #endif
  66.  
  67. +/* SkyStar S2 PCI DVB-S/S2 card based on Conexant cx24120/cx24118 */
  68. +#if FE_SUPPORTED(CX24120) && FE_SUPPORTED(ISL6421)
  69. +static const struct cx24120_config skystar2_rev3_3_cx24120_config = {
  70. +   .i2c_addr = 0x55,
  71. +   .request_firmware = flexcop_fe_request_firmware,
  72. +};
  73. +
  74. +static int skystarS2_rev33_attach(struct flexcop_device *fc, struct i2c_adapter *i2c)
  75. +{
  76. +// struct dvb_frontend_ops *ops;
  77. +  
  78. +   fc->fe = dvb_attach(cx24120_attach,
  79. +       &skystar2_rev3_3_cx24120_config, i2c);
  80. +   if (fc->fe == NULL) return 0;
  81. +   fc->dev_type = FC_SKYS2_REV33;
  82. +   fc->fc_i2c_adap[2].no_base_addr = 1;
  83. +   if ( (dvb_attach(isl6421_attach, fc->fe,
  84. +       &fc->fc_i2c_adap[2].i2c_adap, 0x08, 0, 0, false) == NULL) ) {
  85. +       err("ISL6421 could NOT be attached!");
  86. +       return 0;
  87. +   }
  88. +   info("ISL6421 successfully attached.");
  89. +// ops = &fc->fe->ops;
  90. +   return 1;
  91. +}
  92. +#else
  93. +#define skystarS2_rev33_attach NULL
  94. +#endif
  95. +
  96.  static struct {
  97.     flexcop_device_type_t type;
  98.     int (*attach)(struct flexcop_device *, struct i2c_adapter *);
  99.  } flexcop_frontends[] = {
  100. +   { FC_SKYS2_REV33, skystarS2_rev33_attach },
  101.     { FC_SKY_REV27, skystar2_rev27_attach },
  102.     { FC_SKY_REV28, skystar2_rev28_attach },
  103.     { FC_SKY_REV26, skystar2_rev26_attach },
  104. diff -NurEbBw --strip-trailing-cr drivers/media/common/b2c2/flexcop-hw-filter.c drivers/media/common/b2c2/flexcop-hw-filter.c
  105. --- linux/drivers/media/common/b2c2/flexcop-hw-filter.c 2012-04-03 15:23:44.828143388 +0400
  106. +++ linux/drivers/media/common/b2c2/flexcop-hw-filter.c 2012-04-03 15:26:40.760141513 +0400
  107. @@ -11,6 +11,12 @@
  108.     deb_ts("rcv_data is now: '%s'\n", onoff ? "on" : "off");
  109.  }
  110.  
  111. +void flexcop_external_stream_control(struct dvb_frontend *fe, u8 onoff)
  112. +{
  113. +   struct flexcop_device *fc = fe->dvb->priv;
  114. +   flexcop_rcv_data_ctrl(fc, onoff);
  115. +}
  116. +
  117.  void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
  118.  {
  119.     flexcop_set_ibi_value(ctrl_208, SMC_Enable_sig, onoff);
  120. @@ -199,6 +205,7 @@
  121.  
  122.     /* if it was the first or last feed request change the stream-status */
  123.     if (fc->feedcount == onoff) {
  124. +       if (!fc->need_external_stream_control)
  125.         flexcop_rcv_data_ctrl(fc, onoff);
  126.         if (fc->stream_control) /* device specific stream control */
  127.             fc->stream_control(fc, onoff);
  128. diff -NurEbBw drivers/media/common/b2c2/flexcop-misc.c drivers/media/common/b2c2/flexcop-misc.c
  129. --- linux/drivers/media/common/b2c2/flexcop-misc.c  2012-04-03 15:23:44.832143280 +0400
  130. +++ linux/drivers/media/common/b2c2/flexcop-misc.c  2012-04-03 15:26:40.760141513 +0400
  131. @@ -56,6 +56,7 @@
  132.     [FC_SKY_REV26]  = "Sky2PC/SkyStar 2 DVB-S rev 2.6",
  133.     [FC_SKY_REV27]  = "Sky2PC/SkyStar 2 DVB-S rev 2.7a/u",
  134.     [FC_SKY_REV28]  = "Sky2PC/SkyStar 2 DVB-S rev 2.8",
  135. +   [FC_SKYS2_REV33]= "Sky2PC/SkyStar S2 DVB-S/S2 rev 3.3",
  136.  };
  137.  
  138.  static const char *flexcop_bus_names[] = {
  139. diff -NurEbBw --strip-trailing-cr drivers/media/common/b2c2/flexcop-reg.h drivers/media/common/b2c2/flexcop-reg.h
  140. --- linux/drivers/media/common/b2c2/flexcop-reg.h   2012-04-03 15:23:44.832143280 +0400
  141. +++ linux/drivers/media/common/b2c2/flexcop-reg.h   2012-04-03 15:26:40.760141513 +0400
  142. @@ -24,6 +24,7 @@
  143.     FC_SKY_REV26,
  144.     FC_SKY_REV27,
  145.     FC_SKY_REV28,
  146. +   FC_SKYS2_REV33,
  147.  } flexcop_device_type_t;
  148.  
  149.  typedef enum {
  150. diff -NurEbBw --strip-trailing-cr drivers/media/common/b2c2/Kconfig drivers/media/common/b2c2/Kconfig
  151. --- linux/drivers/media/common/b2c2/Kconfig 2012-04-03 15:23:44.824143495 +0400
  152. +++ linux/drivers/media/common/b2c2/Kconfig 2012-04-03 15:26:40.760141513 +0400
  153. @@ -3,6 +3,7 @@
  154.     depends on DVB_CORE && I2C
  155.     depends on DVB_B2C2_FLEXCOP_PCI || DVB_B2C2_FLEXCOP_USB
  156.     default y
  157. +   select DVB_CX24120 if !DVB_FE_CUSTOMISE
  158.     select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT
  159.     select DVB_STV0299 if MEDIA_SUBDRV_AUTOSELECT
  160.     select DVB_MT352 if MEDIA_SUBDRV_AUTOSELECT
  161. diff -NurEbBw --strip-trailing-cr drivers/media/dvb-frontends/cx24120.c drivers/media/dvb-frontends/cx24120.c
  162. --- linux/drivers/media/dvb-frontends/cx24120.c 1970-01-01 03:00:00.000000000 +0300
  163. +++ linux/drivers/media/dvb-frontends/cx24120.c 2012-04-03 16:10:59.000000000 +0400
  164. @@ -0,0 +1,1053 @@
  165. +/*
  166. +    Conexant cx24120/cx24118 - DVBS/S2 Satellite demod/tuner driver
  167. +   Version 0.0.4a  03.04.2012
  168. +  
  169. +   Copyright (C) 2009 Sergey Tyurin <forum.free-x.de>
  170. +   Updated 2012 by Jannis Achstetter <jannis_achstetter@web.de>
  171. +
  172. +    This program is free software; you can redistribute it and/or modify
  173. +    it under the terms of the GNU General Public License as published by
  174. +    the Free Software Foundation; either version 2 of the License, or
  175. +    (at your option) any later version.
  176. +
  177. +    This program is distributed in the hope that it will be useful,
  178. +    but WITHOUT ANY WARRANTY; without even the implied warranty of
  179. +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  180. +    GNU General Public License for more details.
  181. +
  182. +    You should have received a copy of the GNU General Public License
  183. +    along with this program; if not, write to the Free Software
  184. +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  185. +*/
  186. +
  187. +#include <linux/slab.h>
  188. +#include <linux/kernel.h>
  189. +#include <linux/module.h>
  190. +#include <linux/moduleparam.h>
  191. +#include <linux/init.h>
  192. +#include <linux/firmware.h>
  193. +#include "dvb_frontend.h"
  194. +#include "cx24120.h"
  195. +#include "cx24120_const.h"
  196. +
  197. +//==========================
  198. +#define dbginfo(args...) do { if(cx24120_debug) { printk(KERN_DEBUG "CX24120: %s: >>> ", __func__); \
  199. +           printk(args); }  } while (0)
  200. +#define info(args...) do { printk(KERN_INFO "CX24120: %s: -> ", __func__); \
  201. +           printk(args); } while (0)
  202. +#define err(args...) do {  printk(KERN_ERR "CX24120: %s: ### ERROR: ", __func__); \
  203. +           printk(args); } while (0)
  204. +//==========================
  205. +
  206. +static int cx24120_debug=0;
  207. +static int reg_debug=0;
  208. +MODULE_DESCRIPTION("DVB Frontend module for Conexant CX24120/CX24118 hardware");
  209. +module_param(cx24120_debug, int, 0644);
  210. +MODULE_PARM_DESC(cx24120_debug, "Activates frontend debugging (default:0)");
  211. +
  212. +// ##############################
  213. +struct cx24120_state {
  214. +   struct i2c_adapter *i2c;
  215. +   const struct cx24120_config *config;
  216. +   struct dvb_frontend frontend;
  217. +   u8 need_set_mpeg_out;
  218. +   u8 attached;
  219. +   u8 dvb_s2_mode;
  220. +   u8 cold_init;  
  221. +};
  222. +// #####################################
  223. +// #### Command message to firmware ####
  224. +struct cx24120_cmd {           // total size = 36
  225. +   u8 id;                      // [00] - message id
  226. +   u8 arg[30];                 // [04] - message first byte
  227. +   u8 len;                     // [34] - message lengh or first registers to read
  228. +   u8 reg;                     // [35] - number of registers to read
  229. +};
  230. +
  231. +//===================================================================
  232. +static int cx24120_readreg(struct cx24120_state *state, u8 reg)
  233. +{
  234. +   int ret;
  235. +   u8 buf = 0;
  236. +   struct i2c_msg msg[] = {
  237. +       {   .addr = state->config->i2c_addr,
  238. +           .flags = 0,
  239. +           .len = 1,
  240. +           .buf = &reg },
  241. +          
  242. +       {   .addr = state->config->i2c_addr,
  243. +           .flags = I2C_M_RD,
  244. +           .len = 1,
  245. +           .buf = &buf }
  246. +   };
  247. +   ret = i2c_transfer(state->i2c, msg, 2);
  248. +   if (ret != 2) {
  249. +       err("Read error: reg=0x%02x,  ret=0x%02x)\n", reg, ret);
  250. +       return ret;
  251. +   }
  252. +   if (reg_debug) dbginfo("reg=0x%02x; data=0x%02x\n", reg, buf);
  253. +   return buf;
  254. +} // end cx24120_readreg
  255. +//===================================================================
  256. +static int cx24120_writereg(struct cx24120_state *state, u8 reg, u8 data)
  257. +{
  258. +   u8 buf[] = { reg, data };
  259. +   struct i2c_msg msg = {
  260. +       .addr = state->config->i2c_addr,
  261. +       .flags = 0,
  262. +       .buf = buf,
  263. +       .len = 2 };
  264. +   int ret;
  265. +   ret = i2c_transfer(state->i2c, &msg, 1);
  266. +   if (ret != 1) {
  267. +       err("Write error: i2c_write error(err == %i, 0x%02x: 0x%02x)\n", ret, reg, data);
  268. +       return ret;
  269. +   }
  270. +   if (reg_debug) dbginfo("reg=0x%02x; data=0x%02x\n", reg, data);
  271. +   return 0;
  272. +} // end cx24120_writereg
  273. +//===================================================================
  274. +static int cx24120_writeregN(struct cx24120_state *state, u8 reg, const u8 *values, u16 len, u8 incr)
  275. +{
  276. +   u8 buf[5]; /* maximum 4 data bytes at once - flexcop limitation (very limited i2c-interface this one) */
  277. +   struct i2c_msg msg = {
  278. +       .addr = state->config->i2c_addr,
  279. +       .flags = 0,
  280. +       .buf = buf,
  281. +       .len = len };
  282. +   int ret;
  283. +
  284. +   do {
  285. +       buf[0] = reg;
  286. +       msg.len = len > 4 ? 4 : len;
  287. +       memcpy(&buf[1], values, msg.len);
  288. +       len  -= msg.len;                    // data length revers counter
  289. +       values += msg.len;                  // incr data pointer
  290. +       if (incr) reg += msg.len;          
  291. +       msg.len++;                          /* don't forget the addr byte */
  292. +       ret = i2c_transfer(state->i2c, &msg, 1);
  293. +       if (ret != 1) {
  294. +           err("i2c_write error(err == %i, 0x%02x)\n", ret, reg);
  295. +           return ret;
  296. +       }
  297. +       if (reg_debug) {
  298. +           if( !(reg == 0xFA) && !(reg == 0x20) && !(reg == 0x21)) {       // Exclude firmware upload & diseqc messages
  299. +               dbginfo("reg=0x%02x; data=0x%02x,0x%02x,0x%02x,0x%02x\n",   // from debug
  300. +                       reg,    buf[1], buf[2], buf[3], buf[4]);
  301. +           }
  302. +       }
  303. +   } while (len);
  304. +   return 0;
  305. +} // end cx24120_writeregN
  306. +//===================================================================
  307. +static struct dvb_frontend_ops cx24120_ops;
  308. +//===================================================================
  309. +struct dvb_frontend *cx24120_attach(const struct cx24120_config *config, struct i2c_adapter *i2c)
  310. +{
  311. +   struct cx24120_state *state = NULL;
  312. +   int demod_rev;
  313. +
  314. +   info("Conexant cx24120/cx24118 - DVBS/S2 Satellite demod/tuner\n");
  315. +   info("Driver version: 'SVT - 0.0.4a 03.04.2012'\n");
  316. +   state = kzalloc(sizeof(struct cx24120_state),
  317. +                       GFP_KERNEL);
  318. +   if (state == NULL) {
  319. +       err("### Unable to allocate memory for cx24120_state structure. :(\n");
  320. +       goto error;
  321. +   }
  322. +   /* setup the state */
  323. +   state->config = config;
  324. +   state->i2c = i2c;
  325. +   /* check if the demod is present and has proper type */
  326. +   demod_rev = cx24120_readreg(state, CX24120_REG_REVISION);
  327. +   switch (demod_rev) {
  328. +   case 0x07:
  329. +       info("Demod CX24120 rev. 0x07 detected.\n");
  330. +       break;
  331. +   case 0x05:
  332. +       info("Demod CX24120 rev. 0x05 detected.\n");
  333. +       break;
  334. +   default:
  335. +       err("### Unsupported demod revision: 0x%x detected. Exit.\n", demod_rev);
  336. +       goto error;
  337. +   }
  338. +   /* create dvb_frontend */
  339. +   state->attached = 0x10;         // set attached flag
  340. +   state->cold_init=0;
  341. +   memcpy(&state->frontend.ops, &cx24120_ops, sizeof(struct dvb_frontend_ops));
  342. +   state->frontend.demodulator_priv = state;
  343. +   info("Conexant cx24120/cx24118 - DVBS/S2 Satellite demod/tuner ATTACHED.\n");
  344. +   return &state->frontend;
  345. +
  346. +error:
  347. +   kfree(state);
  348. +   return NULL;
  349. +}
  350. +EXPORT_SYMBOL(cx24120_attach); // end cx24120_attach
  351. +//===================================================================
  352. +static int cx24120_test_rom(struct cx24120_state *state)
  353. +{
  354. +   int err, ret;
  355. +   err = cx24120_readreg(state, 0xFD);
  356. +   if (err & 4 )
  357. +       {
  358. +           ret = cx24120_readreg(state, 0xDF) & 0xFE;
  359. +           err = cx24120_writereg(state, 0xDF, ret);
  360. +       }
  361. +   return err;
  362. +} // end  cx24120_test_rom
  363. +//===================================================================
  364. +static int cx24120_read_snr(struct dvb_frontend *fe, u16 *snr)
  365. +{
  366. +   struct cx24120_state *state = fe->demodulator_priv;
  367. +  
  368. +   *snr = (cx24120_readreg(state, CX24120_REG_QUALITY_H)<<8) |
  369. +                (cx24120_readreg(state, CX24120_REG_QUALITY_L));
  370. +   dbginfo("read SNR index = %d\n", *snr);
  371. +  
  372. +   return 0;
  373. +}
  374. +EXPORT_SYMBOL(cx24120_read_snr); // end cx24120_read_snr
  375. +//===================================================================
  376. +static int cx24120_read_ber(struct dvb_frontend *fe, u32 *ber)
  377. +{
  378. +   struct cx24120_state *state = fe->demodulator_priv;
  379. +
  380. +   *ber =  (cx24120_readreg(state, CX24120_REG_BER_HH) << 24)  |   // BER high byte of high word
  381. +       (cx24120_readreg(state, CX24120_REG_BER_HL) << 16)      |   // BER low byte of high word
  382. +       (cx24120_readreg(state, CX24120_REG_BER_LH)  << 8)      |   // BER high byte of low word
  383. +        cx24120_readreg(state, CX24120_REG_BER_LL);                // BER low byte of low word
  384. +       dbginfo("read BER index = %d\n", *ber);
  385. +
  386. +   return 0;
  387. +}
  388. +EXPORT_SYMBOL(cx24120_read_ber); // end cx24120_read_ber
  389. +//===================================================================
  390. +static int cx24120_message_send(struct cx24120_state *state, struct cx24120_cmd *cmd);
  391. +//===================================================================
  392. +static int cx24120_msg_mpeg_output_global_config(struct cx24120_state *state, u8 flag)
  393. +{
  394. +   u8 tristate;
  395. +   struct cx24120_cmd cmd;
  396. +
  397. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  398. +  
  399. +   cmd.id = 0x13;                      // (19) message Enable/Disable mpeg output ???
  400. +   cmd.arg[0] = 1;
  401. +   cmd.arg[1] = 0;
  402. +   tristate = flag ? 0 : (u8)(-1);
  403. +   cmd.arg[2] = tristate;
  404. +   cmd.arg[3] = 1;                    
  405. +   cmd.len = 4;
  406. +
  407. +   if(flag) dbginfo("MPEG output DISABLED\n");
  408. +   else dbginfo("MPEG output ENABLED\n");
  409. +  
  410. +   return cx24120_message_send(state, &cmd);
  411. +}      // end  cx24120_msg_mpeg_output_global_config
  412. +//===================================================================
  413. +static int cx24120_message_send(struct cx24120_state *state, struct cx24120_cmd *cmd)
  414. +{
  415. +   u8 xxzz;
  416. +   u32 msg_cmd_mask;
  417. +   int ret, ficus;
  418. +
  419. +   if(state->dvb_s2_mode & 0x02) {     // is MPEG enabled?
  420. +                                       // if yes:
  421. +       xxzz = cmd->id - 0x11;          // look for specific message id
  422. +       if ( xxzz <= 0x13 ) {
  423. +           msg_cmd_mask = 1 << xxzz;
  424. +           //0x0F8021 // if cmd_id 17 or 22 or 33-36, 42, 47, 57-61 etc. disable mpeg output
  425. +           if ( msg_cmd_mask & 0x0F8021 ) {        // 000011111000000000100001b
  426. +               cx24120_msg_mpeg_output_global_config(state, 0);
  427. +               msleep(100);
  428. +               state->dvb_s2_mode &=  0xFD;        // reset mpeg out enable flag
  429. +           }
  430. +       }
  431. +   }
  432. +   ret = cx24120_writereg(state, 0x00 /* reg id*/, cmd->id /* value */);           // message start & target
  433. +   ret = cx24120_writeregN(state, 0x01 /* reg msg*/, &cmd->arg[0], cmd->len /* len*/, 1 /* incr */);       // message data
  434. +   ret = cx24120_writereg(state, 0x1F /* reg msg_end */, 0x01 /* value */);        // message end
  435. +
  436. +   ficus = 1000;
  437. +   while ( cx24120_readreg(state, 0x1F)) {     // is command done???
  438. +       msleep(1);
  439. +       if( !(--ficus)) {
  440. +           err("Too long waiting 'done' state from reg(0x1F). :(\n");
  441. +           return -EREMOTEIO;
  442. +       }
  443. +   }
  444. +   dbginfo("Successfully send message 0x%02x\n", cmd->id);
  445. +
  446. +   if ( cmd->reg > 30 ) {
  447. +       err("Too much registers to read. cmd->reg = %d", cmd->reg);
  448. +       return -EREMOTEIO;
  449. +   }
  450. +   ficus = 0;
  451. +   if ( cmd->reg ) {                   // cmd->reg - qty consecutive regs to read
  452. +       while ( ficus < cmd->reg ){     // starts from reg No cmd->len
  453. +                                       // number of registers to read is cmd->reg
  454. +                                       // and write results starts from cmd->arg[0].
  455. +           cmd->arg[ficus] = cx24120_readreg(state, (cmd->len+ficus+1));      
  456. +           ++ficus;
  457. +       }
  458. +   }      
  459. +   return 0;
  460. +} // end cx24120_message_send
  461. +//===================================================================
  462. +static int cx24120_set_frontend(struct dvb_frontend *fe)
  463. +{
  464. +        struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  465. +   struct cx24120_state *state = fe->demodulator_priv;
  466. +   struct cx24120_cmd cmd;
  467. +   u32 srate, freq;
  468. +   fe_code_rate_t fec;
  469. +   fe_spectral_inversion_t inversion;
  470. +   u8 smbr1, smbr2;
  471. +   int ret;
  472. +  
  473. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  474. +  
  475. +   cmd.id = CMD_TUNEREQUEST;       // 0x11 set tuner parametrs
  476. +   cmd.len = 15;      
  477. +  
  478. +   freq = p->frequency;
  479. +   srate = p->symbol_rate;
  480. +   fec = p->fec_inner;
  481. +   inversion = p->inversion;
  482. +  
  483. +   // check symbol rate
  484. +   if ( srate  > 31000000 ) {          // if symbol rate > 31 000
  485. +       smbr1 = (-(srate < 31000001) & 3) + 2;      // ebp
  486. +       smbr2 = (-(srate < 31000001) & 6) + 4;      // edi
  487. +   } else {
  488. +       smbr1 = 3;
  489. +       smbr2 = 6;
  490. +   }
  491. +
  492. +   ret = cx24120_writereg(state, 0xE6, smbr1);
  493. +   ret = cx24120_readreg(state, 0xF0);
  494. +   ret &= 0xFFFFFFF0;
  495. +   ret |= smbr2;
  496. +   ret = cx24120_writereg(state, 0xF0, ret);
  497. +  
  498. +   cmd.arg[0] = 0;     // CMD_TUNER_REQUEST
  499. +  
  500. +   // Frequency
  501. +   cmd.arg[1] = (freq & 0xFF0000) >> 16;       /* intermediate frequency in kHz */
  502. +   cmd.arg[2] = (freq & 0x00FF00) >> 8;
  503. +   cmd.arg[3] = (freq & 0x0000FF);
  504. +  
  505. +   // Symbol Rate
  506. +   cmd.arg[4] = ((srate/1000) & 0xFF00) >> 8;
  507. +   cmd.arg[5] = ((srate/1000) & 0x00FF);
  508. +  
  509. +   // Inversion
  510. +   if ( inversion ) {
  511. +       if ( inversion == 1 ) cmd.arg[6] = 4;
  512. +       else cmd.arg[6] = 0x0C;
  513. +   } else {
  514. +       cmd.arg[6] = 0;
  515. +   }
  516. +
  517. +   // FEC
  518. +   switch ( fec )          // fec = p->u.qpsk.fec_inner
  519. +   {
  520. +       case 1:                         // FEC_1_2
  521. +           cmd.arg[7] = 0x2E; break;   // [11] = 0 by memset  
  522. +       case 2:                         // FEC_2_3
  523. +           cmd.arg[7] = 0x2F; break;
  524. +       case 3:                         // FEC_3_4
  525. +           cmd.arg[7] = 0x30; break;
  526. +       case 5:                         // FEC_5_6
  527. +           cmd.arg[7] = 0x31; break;
  528. +       case 7:                         // FEC_7_8
  529. +           cmd.arg[7] = 0x32; break;
  530. +       default:                                // FEC_NONE, FEC_4_5, FEC_6_7, FEC_8_9,
  531. +                                               // FEC_AUTO, FEC_3_5, FEC_9_10
  532. +           if ( state->dvb_s2_mode & 1 ) { // if DVB-S2 mode  
  533. +               cmd.arg[7] = 0;            
  534. +               cmd.arg[11] = 0;
  535. +           } else {
  536. +               cmd.arg[7] = 0x2E;
  537. +               cmd.arg[11] = 0xAC;
  538. +           }
  539. +           break;
  540. +   }
  541. +   cmd.arg[8] = 0x13;
  542. +   cmd.arg[9] = 0x88;
  543. +   cmd.arg[10] = 0;
  544. +   cmd.arg[12] = smbr2;
  545. +   cmd.arg[13] = smbr1;
  546. +   cmd.arg[14] = 0;
  547. +
  548. +   state->need_set_mpeg_out |= 0x01;       // after tune we need restart mpeg out ?????
  549. +
  550. +   return cx24120_message_send(state, &cmd);
  551. +  
  552. +}
  553. +EXPORT_SYMBOL(cx24120_set_frontend);       // end cx24120_set_frontend
  554. +//===================================================================
  555. +void cx24120_message_fill(struct cx24120_cmd *cmd,
  556. +       u8 msg_id,
  557. +       u8 *msg_addr,
  558. +       u8 msg_len,
  559. +       u8 num_regs)
  560. +{
  561. +   cmd->id = msg_id;
  562. +   memcpy(&cmd->arg[0], msg_addr, msg_len);
  563. +   cmd->len = msg_len;
  564. +   cmd->reg = num_regs;
  565. +} // end cx24120_message_fill
  566. +//===================================================================
  567. +static int cx24120_read_signal_strength(struct dvb_frontend *fe, u16 *signal_strength)
  568. +{
  569. +   struct cx24120_state *state = fe->demodulator_priv;
  570. +   struct cx24120_cmd cmd;
  571. +   int result, sigstr_h, sigstr_l;
  572. +
  573. +   cx24120_message_fill(&cmd, 0x1A/*msg_id*/, &cx24120_msg_read_sigstr[0], 1/*msg_len*/, 0/*num_regs*/);
  574. +
  575. +   if( !(cx24120_message_send(state, &cmd)) ) {
  576. +       sigstr_h = (cx24120_readreg(state, CX24120_REG_SIGSTR_H) >> 6) << 8;
  577. +       sigstr_l = cx24120_readreg(state, CX24120_REG_SIGSTR_L );
  578. +       dbginfo("Signal strength from firmware= 0x%x\n", (sigstr_h | sigstr_l));
  579. +       *signal_strength = ((sigstr_h | sigstr_l)  << 5) & 0x0000FFFF;
  580. +       dbginfo("Signal strength= 0x%x\n", *signal_strength);
  581. +       result = 0;
  582. +   } else {
  583. +       err("error reading signal strength\n");
  584. +       result = -EREMOTEIO;
  585. +   }
  586. +   return result;
  587. +}
  588. +EXPORT_SYMBOL(cx24120_read_signal_strength);       // end cx24120_read_signal_strength
  589. +//===================================================================
  590. +static int cx24120_msg_mpeg_output_config(struct cx24120_state *state, u8 num,
  591. +           struct cx24120_skystar2_mpeg_config *config_msg)
  592. +{
  593. +   struct cx24120_cmd cmd;
  594. +  
  595. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  596. +  
  597. +   cmd.id = CMD_MPEG_INIT;          // cmd->id=20 - message id
  598. +   cmd.len = 7;            
  599. +   cmd.arg[0] = num;     // sequental number - can be 0,1,2
  600. +   cmd.arg[1] =    ((config_msg->x1 & 0x01) << 1) |
  601. +                   ((config_msg->x1 >> 1) & 0x01);
  602. +   cmd.arg[2] = 0x05;
  603. +   cmd.arg[3] = 0x02;
  604. +   cmd.arg[4] = ((config_msg->x2 >> 1) & 0x01);
  605. +   cmd.arg[5] = (config_msg->x2 & 0xF0) | (config_msg->x3 & 0x0F);
  606. +   cmd.arg[6] = state->attached;   /* 0x10 if succesfully attached */
  607. +  
  608. +  return cx24120_message_send(state, &cmd);
  609. +}  // end cx24120_msg_mpeg_output_config
  610. +//===================================================================
  611. +static int cx24120_diseqc_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)
  612. +{
  613. +   struct cx24120_state *state = fe->demodulator_priv;
  614. +   struct cx24120_cmd cmd;
  615. +  
  616. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  617. +  
  618. +   cmd.id = CMD_DISEQC_BURST;
  619. +   cmd.arg[0] = 0x00;
  620. +   if (burst)
  621. +       cmd.arg[1] = 0x01;
  622. +   dbginfo("burst sent.\n");
  623. +
  624. +  return cx24120_message_send(state, &cmd);
  625. +}
  626. +EXPORT_SYMBOL(cx24120_diseqc_send_burst);      // end cx24120_diseqc_send_burst
  627. +//===================================================================
  628. +static int cx24120_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
  629. +{
  630. +   struct cx24120_state *state = fe->demodulator_priv;
  631. +   struct cx24120_cmd cmd;
  632. +
  633. +   dbginfo("cmd(0x23,4) - tone = %d\n", tone);
  634. +   if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) {
  635. +       err("Invalid tone=%d\n", tone);
  636. +       return -EINVAL;
  637. +   }
  638. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  639. +   cmd.id = CMD_SETTONE;   // 0x23
  640. +   cmd.len = 4;
  641. +   if (!tone)
  642. +       cmd.arg[3] = 0x01;
  643. +  return cx24120_message_send(state, &cmd);
  644. +}
  645. +EXPORT_SYMBOL(cx24120_set_tone);       // end cx24120_set_tone
  646. +//===================================================================
  647. +static int cx24120_set_voltage(struct dvb_frontend *fe,    fe_sec_voltage_t voltage)
  648. +{
  649. +   struct cx24120_state *state = fe->demodulator_priv;
  650. +   struct cx24120_cmd cmd;
  651. +
  652. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  653. +   cmd.id = CMD_SETVOLTAGE;        //
  654. +   cmd.len = 2;
  655. +   if (!(voltage - 1))
  656. +       cmd.arg[1] = 0x01;
  657. +   return cx24120_message_send(state, &cmd);
  658. +}
  659. +EXPORT_SYMBOL(cx24120_set_voltage);        // end cx24120_set_voltage
  660. +//===================================================================
  661. +static int cx24120_send_diseqc_msg(struct dvb_frontend *fe,    struct dvb_diseqc_master_cmd *d)
  662. +{
  663. +   struct cx24120_state *state = fe->demodulator_priv;
  664. +   struct cx24120_cmd cmd;
  665. +   int back_count;
  666. +  
  667. +   dbginfo("Start sending diseqc sequence===============\n");
  668. +  
  669. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  670. +  
  671. +   cmd.id = CMD_DISEQC_MSG1;       // 0x20
  672. +   cmd.len = 11;
  673. +   cmd.arg[0] = 0x00;
  674. +   cmd.arg[1] = 0x00;
  675. +   cmd.arg[2] = 0x03;
  676. +   cmd.arg[3] = 0x16;
  677. +   cmd.arg[4] = 0x28;
  678. +   cmd.arg[5] = 0x01;
  679. +   cmd.arg[6] = 0x01;
  680. +   cmd.arg[7] = 0x14;
  681. +   cmd.arg[8] = 0x19;
  682. +   cmd.arg[9] = 0x14;
  683. +   cmd.arg[10] = 0x1E;
  684. +   if ( cx24120_message_send(state, &cmd) ) {
  685. +       err("send 1st message(0x%x) filed==========\n", cmd.id);
  686. +       return -EREMOTEIO;
  687. +   }
  688. +   cmd.id = CMD_DISEQC_MSG2;       // 0x21
  689. +   cmd.len = d->msg_len + 6;
  690. +   cmd.arg[0] = 0x00;
  691. +   cmd.arg[1] = 0x01;
  692. +   cmd.arg[2] = 0x02;
  693. +   cmd.arg[3] = 0x00;
  694. +   cmd.arg[4] = 0x00;
  695. +   cmd.arg[5] = d->msg_len;
  696. +  
  697. +   memcpy(&cmd.arg[6], &d->msg, d->msg_len);
  698. +  
  699. +   if ( cx24120_message_send(state, &cmd) ) {
  700. +       err("send 2d message(0x%x) filed========\n", cmd.id);
  701. +       return -EREMOTEIO;
  702. +   }
  703. +   back_count = 100;
  704. +   do {
  705. +       if ( !(cx24120_readreg(state, 0x93) & 0x01) ) {
  706. +           dbginfo("diseqc sequence sent success==========.\n");
  707. +           return 0;
  708. +       }
  709. +       msleep(5);
  710. +       --back_count;
  711. +   } while ( back_count );
  712. +   err("Too long waiting for diseqc.=============\n");
  713. +   return -ETIMEDOUT;
  714. +}
  715. +EXPORT_SYMBOL(cx24120_send_diseqc_msg);        // end cx24120_send_diseqc_msg
  716. +//===================================================================
  717. +static int cx24120_read_status(struct dvb_frontend *fe, fe_status_t *status)
  718. +{
  719. +   struct cx24120_state *state = fe->demodulator_priv;
  720. +   struct cx24120_cmd cmd;
  721. +   int ret, clock_seq_num, GettedFEC;
  722. +   u8 mode_code, mode_8PSK_flag, attached_flag, clock_id;
  723. +  
  724. +   ret = cx24120_readreg(state, CX24120_REG_STATUS);       //0x3A
  725. +   dbginfo("status = 0x%x\n", ret);
  726. +   *status = 0;
  727. +   if ( ret & CX24120_HAS_SIGNAL ) *status = FE_HAS_SIGNAL;
  728. +   if ( ret & CX24120_HAS_CARRIER) *status |= FE_HAS_CARRIER;
  729. +   if ( ret & CX24120_HAS_VITERBI) *status |= (FE_HAS_VITERBI + FE_HAS_SYNC);
  730. +  
  731. +   if ( ret & CX24120_HAS_LOCK ) {     // 0x08
  732. +       *status |= FE_HAS_LOCK;
  733. +       if ( state->need_set_mpeg_out & 1 ) {           // just tuned???
  734. +           memset(&cmd, 0, sizeof(struct cx24120_cmd));
  735. +           cmd.id = CMD_CLOCK_READ;
  736. +           cmd.arg[0] = 0x00;
  737. +           cmd.len = 1;            // cmd.reg != 0, so it is first register to read
  738. +           cmd.reg = 6;            // number of registers to read (0x01-0x06)
  739. +           if ( !cx24120_message_send(state, &cmd) ) {         // in cmd[0]-[5] - result
  740. +                                                               //      0x02-0x07
  741. +               ret = cx24120_readreg(state, CX24120_REG_FECMODE) & 0x3F;       // ntv - 0x8E(142) & 3F = 14
  742. +               GettedFEC = ret;                                                //       0x0d= 13
  743. +               dbginfo("Get FEC: %d\n", ret);
  744. +               if ( state->dvb_s2_mode & 0x01 ) {                          // is DVB-S2?
  745. +                   switch (ret-4) {
  746. +                       case 0:
  747. +                           mode_code = 0x01; goto mode_QPSK;   // FEC_1_2 - qpsk only
  748. +                       case 1:
  749. +                       case 8:
  750. +                           mode_code = 0x64; goto mode_8PSK;   // FEC_3_5 (10)- 8PSK only
  751. +                       case 2:
  752. +                       case 9:
  753. +                           mode_code = 0x02; goto mode_8PSK;   // FEC_2_3
  754. +                       case 3:
  755. +                       case 10:
  756. +                           mode_code = 0x03; goto mode_8PSK;   // FEC_3_4  // 14-4=10 - ntv+
  757. +                       case 4:
  758. +                           mode_code = 0x04; goto mode_QPSK;   // FEC_4_5 - qpsk only
  759. +                       case 5:
  760. +                       case 11:
  761. +                           mode_code = 0x05; goto mode_8PSK;   // FEC_5_6
  762. +                       case 6:
  763. +                       case 12:
  764. +                           mode_code = 0x08; goto mode_8PSK;   // FEC_8_9
  765. +                       case 7:
  766. +                       case 13:
  767. +                           mode_code = 0x65; goto mode_8PSK;   // FEC_9_10 (11)- 8PSK only
  768. +                       default:
  769. +                           info("Unknown DVB-S2 modefec (not QPSK or 8PSK): %d\n", ret-4);
  770. +                           mode_code = 0x01;                       // set like for mode 0
  771. +                   mode_8PSK:
  772. +                       if ( ret > 11 ) {       // 14
  773. +                           mode_8PSK_flag = 0x63;          // DVB-S2-8PSK flag
  774. +                           dbginfo("DVB-S2: 8PSK mode: %d, mode_code= 0x%x\n", ret-4, mode_code);
  775. +                       } else {
  776. +                   mode_QPSK:
  777. +                           mode_8PSK_flag = 0x00;
  778. +                               dbginfo("DVB-S2: QPSK mode: %d\n", ret-4);
  779. +                       }
  780. +                       break;
  781. +                   } // end switch
  782. +               } // end if dvb_s2_mode // dvb-s2
  783. +               else {                              // state->dvb_s2_mode & 1 = 0 -> #### DVB-S
  784. +                   switch ( ret - 2 ) {
  785. +                       case 0:
  786. +                           mode_code = 2; break;   // FEC_2_3
  787. +                       case 1:
  788. +                           mode_code = 3; break;   // FEC_3_4
  789. +                       case 2:
  790. +                           mode_code = 4; break;   // FEC_4_5
  791. +                       case 3:
  792. +                           mode_code = 5; break;   // FEC_5_6
  793. +                       case 4:
  794. +                           mode_code = 6; break;   // FEC_6_7
  795. +                       case 5:
  796. +                           mode_code = 7; break;   // FEC_7_8
  797. +                       default:
  798. +                           mode_code = 1;break;    // FEC_1_2
  799. +                   }
  800. +                   mode_8PSK_flag = 0;
  801. +               } // end of switch for dvb-s
  802. +              
  803. +               attached_flag = 0x10;
  804. +               if (state->attached == 0x10)  // must be 0x10 if successfully attached in flexcop_fe_tuner
  805. +                   attached_flag = 0;
  806. +               ret = 0;
  807. +               if ( state->dvb_s2_mode & 0x01 )        // if dvb-s2
  808. +                   ret = (cx24120_readreg(state, CX24120_REG_FECMODE) >> 7) & 0x01;  // QPSK or 8PSK ???
  809. +                        // bit 4          bit 5            bit 0                 bit 3
  810. +               clock_id = (ret << 3) | attached_flag | (state->dvb_s2_mode & 1) | 4;       // possible id: 4, 5, 13. 12-impossible,
  811. +               // ntv S2 = 0x8E -> 8 | 1 | 4 = 13                                          // because 7th bit of ret - is S2 flag
  812. +               // 1/2 S2 = 0x0d -> 0 | 1 | 4 = 5
  813. +               dbginfo("Check clock table for: clock_id=0x%x, 8PSK_mask=0x%x, mode_code=0x%x\n",
  814. +                   clock_id, mode_8PSK_flag, mode_code);
  815. +              
  816. +               clock_seq_num = 0;
  817. +               while ( (clock_ratios_table[clock_seq_num].ratio_id != clock_id) ||
  818. +                       (clock_ratios_table[clock_seq_num].mode_xPSK != mode_8PSK_flag) ||
  819. +                       (clock_ratios_table[clock_seq_num].fec_mode != mode_code) )
  820. +               {
  821. +               /*  dbginfo("Check table string(%d): clock_id=%d, 8PSK_flag=%d, mode_code=%d\n",    clock_seq_num,
  822. +                *      clock_ratios_table[clock_seq_num].ratio_id,
  823. +                *      clock_ratios_table[clock_seq_num].mode_xPSK,
  824. +                *      clock_ratios_table[clock_seq_num].fec_mode);
  825. +                */
  826. +                   ++clock_seq_num;
  827. +                   if ( clock_seq_num == ARRAY_SIZE(clock_ratios_table) ) {
  828. +                       info("Check in clock table filed: unsupported modulation tuned - data reception in danger. :(\n");
  829. +                       goto settings_end;
  830. +                   }
  831. +               }
  832. +   //###############################
  833. +               dbginfo("Check succesful: GetFEC: %d; post lock: m=%d, n=%d; clock_seq_idx: %d m=%d, n=%d, rate=%d\n",
  834. +                   GettedFEC,
  835. +                   cmd.arg[2] | (cmd.arg[1] << 8) | (cmd.arg[0] << 16),        // registers was readed early
  836. +                   cmd.arg[5] | (cmd.arg[4] << 8) | (cmd.arg[3] << 16),        // in message with id = 0x16
  837. +                   clock_seq_num,
  838. +                   clock_ratios_table[clock_seq_num].m_rat,
  839. +                   clock_ratios_table[clock_seq_num].n_rat,
  840. +                   clock_ratios_table[clock_seq_num].rate);
  841. +   //###############################
  842. +               cmd.id = CMD_CLOCK_SET;
  843. +               cmd.len = 10;
  844. +               cmd.reg = 0;
  845. +               cmd.arg[0] = 0;
  846. +               cmd.arg[1] = state->attached;       // must be 0x10 if successfully attached in flexcop_fe_tuner
  847. +              
  848. +               cmd.arg[2] = (clock_ratios_table[clock_seq_num].m_rat >> 16) & 0xFF;
  849. +               cmd.arg[3] = (clock_ratios_table[clock_seq_num].m_rat >>  8) & 0xFF;
  850. +               cmd.arg[4] = (clock_ratios_table[clock_seq_num].m_rat >>  0) & 0xFF;
  851. +
  852. +               cmd.arg[5] = (clock_ratios_table[clock_seq_num].n_rat >> 16) & 0xFF;
  853. +               cmd.arg[6] = (clock_ratios_table[clock_seq_num].n_rat >>  8) & 0xFF;
  854. +               cmd.arg[7] = (clock_ratios_table[clock_seq_num].n_rat >>  0) & 0xFF;
  855. +
  856. +               cmd.arg[8] = (clock_ratios_table[clock_seq_num].rate >> 8) & 0xFF;
  857. +               cmd.arg[9] = (clock_ratios_table[clock_seq_num].rate >> 0) & 0xFF;
  858. +              
  859. +               cx24120_message_send(state, &cmd);
  860. +              
  861. +           settings_end:
  862. +               msleep(200);
  863. +               cx24120_msg_mpeg_output_global_config(state, 1);   
  864. +               state->dvb_s2_mode |= 0x02;                         // set mpeg flag
  865. +               state->need_set_mpeg_out &= 0xFE;                   // clocks set done -> clear flag
  866. +           }
  867. +       }
  868. +   }
  869. +   return 0;
  870. +}
  871. +EXPORT_SYMBOL(cx24120_read_status);        // end cx24120_read_status
  872. +//===================================================================
  873. +int cx24120_init(struct dvb_frontend *fe)
  874. +{
  875. +   const struct firmware *fw;
  876. +   struct cx24120_state *state = fe->demodulator_priv;
  877. +   struct cx24120_cmd cmd;
  878. +   u8 ret, ret_EA, reg1, fL, fH;
  879. +   u32 vco, xtal_khz;
  880. +   u64 inv_vco, res, xxyyzz;
  881. +   int reset_result;
  882. +
  883. +   if( state->cold_init ) return 0;
  884. +
  885. +   ret = cx24120_writereg(state, 0xEA, 0x00);
  886. +   ret = cx24120_test_rom(state);
  887. +   ret = cx24120_readreg(state, 0xFB) & 0xFE;
  888. +   ret = cx24120_writereg(state, 0xFB, ret);
  889. +   ret = cx24120_readreg(state, 0xFC) & 0xFE;
  890. +   ret = cx24120_writereg(state, 0xFC, ret);
  891. +   ret = cx24120_writereg(state, 0xC3, 0x04);
  892. +   ret = cx24120_writereg(state, 0xC4, 0x04);
  893. +   ret = cx24120_writereg(state, 0xCE, 0x00);
  894. +   ret = cx24120_writereg(state, 0xCF, 0x00);
  895. +   ret_EA = cx24120_readreg(state, 0xEA) & 0xFE;
  896. +   ret = cx24120_writereg(state, 0xEA, ret_EA);
  897. +   ret = cx24120_writereg(state, 0xEB, 0x0C);
  898. +   ret = cx24120_writereg(state, 0xEC, 0x06);
  899. +   ret = cx24120_writereg(state, 0xED, 0x05);
  900. +   ret = cx24120_writereg(state, 0xEE, 0x03);
  901. +   ret = cx24120_writereg(state, 0xEF, 0x05);
  902. +   ret = cx24120_writereg(state, 0xF3, 0x03);
  903. +   ret = cx24120_writereg(state, 0xF4, 0x44);
  904. +  
  905. +   reg1 = 0xF0;
  906. +   do {
  907. +       cx24120_writereg(state, reg1, 0x04);
  908. +       cx24120_writereg(state, reg1 - 10, 0x02);
  909. +       ++reg1;
  910. +   } while ( reg1 != 0xF3 );
  911. +
  912. +   ret = cx24120_writereg(state, 0xEA, (ret_EA | 0x01));
  913. +       reg1 = 0xC5;
  914. +   do {
  915. +       ret = cx24120_writereg(state, reg1, 0x00);
  916. +       ret = cx24120_writereg(state, reg1 + 1, 0x00);
  917. +       reg1 += 2;
  918. +    } while ( reg1 != 0xCB );
  919. +    
  920. +    ret = cx24120_writereg(state, 0xE4, 0x03);
  921. +    ret = cx24120_writereg(state, 0xEB, 0x0A);
  922. +    
  923. +    dbginfo("Requesting firmware (%s) to download...\n", CX24120_FIRMWARE);
  924. +    ret = state->config->request_firmware(fe, &fw, CX24120_FIRMWARE);
  925. +   if (ret) {
  926. +       err("Could not load firmware (%s): %d\n", CX24120_FIRMWARE, ret);
  927. +       return ret;
  928. +   }
  929. +   dbginfo("Firmware found and it size is %d bytes (%02x %02x .. %02x %02x)\n",
  930. +        (int)fw->size,             // firmware_size in bytes u32*
  931. +        fw->data[0],           // fw 1st byte
  932. +        fw->data[1],           // fw 2d byte
  933. +        fw->data[fw->size - 2],    // fw before last byte
  934. +        fw->data[fw->size - 1]);   // fw last byte
  935. +        
  936. +    ret = cx24120_test_rom(state);
  937. +   ret = cx24120_readreg(state, 0xFB) & 0xFE;
  938. +   ret = cx24120_writereg(state, 0xFB, ret);
  939. +   ret = cx24120_writereg(state, 0xE0, 0x76);
  940. +   ret = cx24120_writereg(state, 0xF7, 0x81);
  941. +   ret = cx24120_writereg(state, 0xF8, 0x00);
  942. +   ret = cx24120_writereg(state, 0xF9, 0x00);
  943. +   ret = cx24120_writeregN(state, 0xFA, fw->data, (fw->size - 1), 0x00);
  944. +   ret = cx24120_writereg(state, 0xF7, 0xC0);
  945. +   ret = cx24120_writereg(state, 0xE0, 0x00);
  946. +   ret = (fw->size - 2) & 0x00FF;
  947. +   ret = cx24120_writereg(state, 0xF8, ret);   // ret now is 0x7a
  948. +   ret = ((fw->size - 2) >> 8) & 0x00FF;
  949. +   ret = cx24120_writereg(state, 0xF9, ret);   // ret now is 0xaf
  950. +   ret = cx24120_writereg(state, 0xF7, 0x00);
  951. +   ret = cx24120_writereg(state, 0xDC, 0x00);
  952. +   ret = cx24120_writereg(state, 0xDC, 0x07);
  953. +   msleep(500);
  954. +  
  955. +   ret = cx24120_readreg(state, 0xE1);     // now is 0xd5 - last byte of the firmware
  956. +    if ( ret == fw->data[fw->size - 1] ) {
  957. +       dbginfo("Firmware uploaded successfully\n");
  958. +       reset_result = 0;
  959. +   } else {
  960. +       err("Firmware upload failed. Last byte returned=0x%x\n", ret );
  961. +       reset_result = -EREMOTEIO;
  962. +   }
  963. +   ret = cx24120_writereg(state, 0xDC, 0x00);     
  964. +   release_firmware(fw);
  965. +   if (reset_result)
  966. +       return reset_result;
  967. +      
  968. +   //================== Start tuner
  969. +   cx24120_message_fill(&cmd, CMD_START_TUNER, &cx24120_msg_tuner_init[0], 3, 0);  // 0x1B
  970. +   if(cx24120_message_send(state, &cmd)) {
  971. +       err("Error tuner start! :(\n");
  972. +       return -EREMOTEIO;
  973. +   }
  974. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  975. +  
  976. +   cmd.id = CMD_VCO_SET;       // 0x10
  977. +   cmd.len = 12;
  978. +  
  979. +   // ######################
  980. +   // Calc VCO
  981. +   xtal_khz = 10111;
  982. +   xxyyzz = 0x400000000ULL;    // 17179869184
  983. +   vco = xtal_khz * 10 * 4;    // 404440
  984. +   inv_vco = xxyyzz / vco;     // 42478 = 0x00A5EE
  985. +   res = xxyyzz % vco;         // 66864 = 0x010530
  986. +  
  987. +   if( inv_vco > xtal_khz * 10 * 2) ++inv_vco;
  988. +      
  989. +   fH = (inv_vco >> 8) & 0xFF;
  990. +   fL = (inv_vco) & 0xFF;
  991. +    dbginfo("vco= %d, inv_vco= %lld, res= %lld, fL= 0x%x, fH= 0x%x\n", vco, inv_vco, res, fL, fH);
  992. +    // ######################
  993. +    
  994. +   cmd.arg[0] = 0x06;
  995. +   cmd.arg[1] = 0x2B;
  996. +   cmd.arg[2] = 0xD8;
  997. +   cmd.arg[3] = fH;        // 0xA5
  998. +   cmd.arg[4] = fL;        // 0xEE
  999. +   cmd.arg[5] = 0x03;
  1000. +   cmd.arg[6] = 0x9D;
  1001. +   cmd.arg[7] = 0xFC;
  1002. +   cmd.arg[8] = 0x06;
  1003. +   cmd.arg[9] = 0x03;
  1004. +   cmd.arg[10] = 0x27;
  1005. +   cmd.arg[11] = 0x7F;
  1006. +  
  1007. +   if(cx24120_message_send(state, &cmd)) {
  1008. +       err("Error set VCO! :(\n");
  1009. +       return -EREMOTEIO;
  1010. +   }
  1011. +   memset(&cmd, 0, sizeof(struct cx24120_cmd));
  1012. +   // set bandwidth
  1013. +   cmd.id = CMD_BANDWIDTH;     // 0x15
  1014. +   cmd.len = 12;
  1015. +   cmd.arg[0] = 0x00;
  1016. +   cmd.arg[1] = 0x00;
  1017. +   cmd.arg[2] = 0x00;
  1018. +   cmd.arg[3] = 0x00;
  1019. +   cmd.arg[4] = 0x05;
  1020. +   cmd.arg[5] = 0x02;
  1021. +   cmd.arg[6] = 0x02;
  1022. +   cmd.arg[7] = 0x00;
  1023. +   cmd.arg[8] = 0x05;
  1024. +   cmd.arg[9] = 0x02;
  1025. +   cmd.arg[10] = 0x02;
  1026. +   cmd.arg[11] = 0x00;
  1027. +  
  1028. +   if ( cx24120_message_send(state, &cmd) ) {
  1029. +       err("Error set bandwidth! :(\n");
  1030. +       return -EREMOTEIO;
  1031. +   }
  1032. +   ret = cx24120_readreg(state, 0xBA);
  1033. +   if ( ret > 3) {
  1034. +       dbginfo("Reset-readreg 0xBA: %x\n", ret);
  1035. +       err("Error intitilizing tuner! :(\n");
  1036. +       return -EREMOTEIO;
  1037. +   }
  1038. +   dbginfo("Tuner initialized correctly.\n");
  1039. +
  1040. +   ret = cx24120_writereg(state, 0xEB, 0x0A);
  1041. +   if (cx24120_msg_mpeg_output_global_config(state, 0) ||
  1042. +       cx24120_msg_mpeg_output_config(state, 0, &initial_mpeg_config) ||
  1043. +       cx24120_msg_mpeg_output_config(state, 1, &initial_mpeg_config) ||
  1044. +       cx24120_msg_mpeg_output_config(state, 2, &initial_mpeg_config) )
  1045. +   {
  1046. +       err("Error initilizing mpeg output. :(\n");
  1047. +        return -EREMOTEIO;
  1048. +   } else {
  1049. +       cmd.id = 0x3C;  // 60
  1050. +       cmd.len = 0x03;
  1051. +       cmd.arg[0] = 0x00;
  1052. +       cmd.arg[1] = 0x10;
  1053. +       cmd.arg[2] = 0x10;
  1054. +       if(cx24120_message_send(state, &cmd)) {
  1055. +           err("Error sending final init message. :(\n");
  1056. +           return -EREMOTEIO;
  1057. +       }  
  1058. +    }
  1059. +   state->cold_init=1;
  1060. +   return 0;
  1061. +}
  1062. +EXPORT_SYMBOL(cx24120_init);       // end cx24120_reset
  1063. +//===================================================================
  1064. +static int cx24120_tune(struct dvb_frontend *fe, bool re_tune,
  1065. +        unsigned int mode_flags, unsigned int *delay, fe_status_t *p_status)
  1066. +{
  1067. +        struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  1068. +   struct cx24120_state *state = fe->demodulator_priv;
  1069. +   int delay_cnt, sd_idx = 0;
  1070. +   fe_status_t status;
  1071. +  
  1072. +   if (re_tune) {
  1073. +      
  1074. +//     dbginfo("Compare symrate with table: symrate= %d, in table= %d\n",
  1075. +//             p->u.qpsk.symbol_rate, symrates_pairs[sd_idx].symrate);
  1076. +
  1077. +       while ( p->symbol_rate > symrates_pairs[sd_idx].symrate ) {
  1078. +           ++sd_idx;
  1079. +       }
  1080. +       dbginfo("Found symrate delay = %d\n", symrates_pairs[sd_idx].delay);
  1081. +       state->dvb_s2_mode &= 0xFE;         // clear bit -> try not DVB-S2
  1082. +       dbginfo("trying DVB-S =================\n");
  1083. +       cx24120_set_frontend(fe);
  1084. +      
  1085. +       delay_cnt = symrates_pairs[sd_idx].delay;
  1086. +       dbginfo("Wait for LOCK for DVB-S =================\n");
  1087. +       while (delay_cnt >= 0) {
  1088. +           cx24120_read_status(fe, &status);
  1089. +           if (status & FE_HAS_LOCK) {
  1090. +               dbginfo("DVB-S LOCKED================\n");
  1091. +               break;
  1092. +           }
  1093. +           msleep(100);
  1094. +           delay_cnt -=100;
  1095. +       }
  1096. +       dbginfo("Waiting finished - NO lock for DVB-S =================\n");
  1097. +      
  1098. +       cx24120_read_status(fe, &status);
  1099. +       if ( !(status & FE_HAS_LOCK) ) {        // if no lock on S
  1100. +           dbginfo("trying DVB-S2 ++++++++++++++++++++++++++\n");
  1101. +           state->dvb_s2_mode |= 0x01;         // may be it locked on S2 ?
  1102. +           p->fec_inner = FEC_AUTO;
  1103. +           cx24120_set_frontend(fe);
  1104. +           delay_cnt = symrates_pairs[sd_idx].delay;
  1105. +           dbginfo("Wait for LOCK for DVB-S2 ++++++++++++++++\n");
  1106. +           while (delay_cnt >= 0) {
  1107. +               cx24120_read_status(fe, &status);
  1108. +               if (status & FE_HAS_LOCK) {
  1109. +                   dbginfo("DVB-S2 LOCKED++++++++++++++++\n");
  1110. +                   break;
  1111. +               }
  1112. +               msleep(100);
  1113. +               delay_cnt -=100;
  1114. +           }
  1115. +           dbginfo("Waiting finished - NO lock for DVB-S2 ++++++++++++++++\n");
  1116. +       }
  1117. +   }
  1118. +   return 0;
  1119. +}
  1120. +EXPORT_SYMBOL(cx24120_tune);   // end of cx24120_tune
  1121. +//===================================================================
  1122. +static int cx24120_get_algo(struct dvb_frontend *fe)
  1123. +{
  1124. +   return DVBFE_ALGO_HW;
  1125. +}
  1126. +EXPORT_SYMBOL(cx24120_get_algo);
  1127. +//===================================================================
  1128. +static int cx24120_sleep(struct dvb_frontend *fe)
  1129. +{
  1130. +  return 0;
  1131. +}
  1132. +EXPORT_SYMBOL(cx24120_sleep);
  1133. +//===================================================================
  1134. +/*static int cx24120_wakeup(struct dvb_frontend *fe)
  1135. + * {
  1136. + *   return 0;
  1137. + * }
  1138. + * EXPORT_SYMBOL(cx24120_wakeup);
  1139. + */
  1140. +//===================================================================
  1141. +static int cx24120_get_frontend(struct dvb_frontend *fe)
  1142. +{
  1143. +   return 0;
  1144. +}
  1145. +EXPORT_SYMBOL(cx24120_get_frontend);
  1146. +//===================================================================
  1147. +static void cx24120_release(struct dvb_frontend *fe)
  1148. +{
  1149. +   struct cx24120_state *state = fe->demodulator_priv;
  1150. +   dbginfo("Clear state structure\n");
  1151. +   kfree(state);
  1152. +}
  1153. +EXPORT_SYMBOL(cx24120_release);
  1154. +//===================================================================
  1155. +static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)   // UNCORRECTED_BLOCKS
  1156. +{
  1157. +   struct cx24120_state *state = fe->demodulator_priv;
  1158. +
  1159. +   *ucblocks = (cx24120_readreg(state, CX24120_REG_UCB_H) << 8) |
  1160. +       cx24120_readreg(state, CX24120_REG_UCB_L);
  1161. +   dbginfo("Blocks = %d\n", *ucblocks);
  1162. +   return 0;
  1163. +}
  1164. +EXPORT_SYMBOL(cx24120_read_ucblocks);
  1165. +// ########################################################################################
  1166. +static struct dvb_frontend_ops cx24120_ops = {
  1167. +
  1168. +   .delsys = { SYS_DVBS, SYS_DVBS2 },
  1169. +   .info = {
  1170. +       .name = "Conexant CX24120/CX24118",
  1171. +       .frequency_min = 950000,
  1172. +       .frequency_max = 2150000,
  1173. +       .frequency_stepsize = 1011, /* kHz for QPSK frontends */
  1174. +       .frequency_tolerance = 5000,
  1175. +       .symbol_rate_min = 1000000,
  1176. +       .symbol_rate_max = 45000000,
  1177. +       .caps =                         // 0x500006ff
  1178. +           FE_CAN_INVERSION_AUTO |     //0x00 000 001
  1179. +           FE_CAN_FEC_1_2 |            //0x00 000 002
  1180. +           FE_CAN_FEC_2_3 |            //0x00 000 004
  1181. +           FE_CAN_FEC_3_4 |            //0x00 000 008
  1182. +           FE_CAN_FEC_4_5 |            //0x00 000 010
  1183. +           FE_CAN_FEC_5_6 |            //0x00 000 020
  1184. +           FE_CAN_FEC_6_7 |            //0x00 000 040
  1185. +           FE_CAN_FEC_7_8 |            //0x00 000 080
  1186. +           FE_CAN_FEC_AUTO |           //0x00 000 200
  1187. +           FE_CAN_QPSK |               //0x00 000 400
  1188. +//???      FE_HAS_EXTENDED_CAPS |      //0x00 800 000      /* We need more bitspace for newer APIs, indicate this. */
  1189. +           FE_CAN_2G_MODULATION |      //0x10 000 000      /* frontend supports "2nd generation modulation" (DVB-S2) */
  1190. +           FE_CAN_RECOVER              //0x40 000 000      /* frontend can recover from a cable unplug automatically */
  1191. +   },                                  //sum=50 000 6FF
  1192. +   .release =                  cx24120_release,
  1193. +  
  1194. +   .init =                     cx24120_init,
  1195. +   .sleep =                    cx24120_sleep,
  1196. +  
  1197. +   .tune =                     cx24120_tune,
  1198. +   .get_frontend_algo =        cx24120_get_algo,
  1199. +   .set_frontend =             cx24120_set_frontend,
  1200. +
  1201. +   .get_frontend =             cx24120_get_frontend,
  1202. +   .read_status =              cx24120_read_status,
  1203. +   .read_ber =                 cx24120_read_ber,
  1204. +   .read_signal_strength =     cx24120_read_signal_strength,
  1205. +   .read_snr =                 cx24120_read_snr,
  1206. +   .read_ucblocks =            cx24120_read_ucblocks,
  1207. +  
  1208. +   .diseqc_send_master_cmd =   cx24120_send_diseqc_msg,
  1209. +  
  1210. +   .diseqc_send_burst =        cx24120_diseqc_send_burst,
  1211. +   .set_tone =                 cx24120_set_tone,
  1212. +   .set_voltage =              cx24120_set_voltage,
  1213. +};
  1214. +//===================================================================
  1215. +MODULE_PARM_DESC(cx24120_debug, "prints some verbose debugging information (default:0)");
  1216. +MODULE_AUTHOR("Sergey Tyurin");
  1217. +MODULE_LICENSE("GPL");
  1218. diff -NurEbBw --strip-trailing-cr drivers/media/dvb-frontends/cx24120_const.h drivers/media/dvb-frontends/cx24120_const.h
  1219. --- linux/drivers/media/dvb-frontends/cx24120_const.h   1970-01-01 03:00:00.000000000 +0300
  1220. +++ linux/drivers/media/dvb-frontends/cx24120_const.h   2012-04-03 16:37:20.684139905 +0400
  1221. @@ -0,0 +1,259 @@
  1222. +/*
  1223. + * Conexant CX24120/CX24118 - DVB-S/S2 demod/tuner driver
  1224. + * DVBS/S2 Satellite demod/tuner driver static definitins
  1225. + *
  1226. + * Copyright (C) 2009 Sergey Tyurin <forum.free-x.de>
  1227. + * Updated 2012 by Jannis Achstetter <jannis_achstetter@web.de>
  1228. + *
  1229. + * This program is free software; you can redistribute it and/or modify
  1230. + * it under the terms of the GNU General Public License as published by
  1231. + * the Free Software Foundation; either version 2 of the License, or
  1232. + * (at your option) any later version.
  1233. + *
  1234. + * This program is distributed in the hope that it will be useful,
  1235. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1236. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1237. + * GNU General Public License for more details.
  1238. + *
  1239. + * You should have received a copy of the GNU General Public License
  1240. + * along with this program; if not, write to the Free Software
  1241. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1242. + */
  1243. +
  1244. +#define CX24120_FIRMWARE "dvb-fe-cx24120-1.20.58.2.fw"
  1245. +
  1246. +// ##############################
  1247. +// ### cx24120 i2c registers ###
  1248. +#define CX24120_REG_CMD_START (0x00)   // write cmd_id, and then start write args to next register:
  1249. +#define CX24120_REG_CMD_ARGS (0x01)        // write command arguments, max 4 at once, then next 4, etc.
  1250. +#define CX24120_REG_CMD_END (0x1F)     // write 0x01 for end, and read it for command result
  1251. +
  1252. +#define CX24120_REG_FECMODE (0x39)     // FEC status
  1253. +#define CX24120_REG_STATUS (0x3A)      // Tuner status - signal, carrier, sync, lock ...
  1254. +#define CX24120_REG_QUALITY_H (0x40)   // SNR high byte
  1255. +#define CX24120_REG_QUALITY_L (0x41)   // SNR low byte
  1256. +
  1257. +#define CX24120_REG_BER_HH (0x47)      // BER high byte of high word
  1258. +#define CX24120_REG_BER_HL (0x48)      // BER low byte of high word
  1259. +#define CX24120_REG_BER_LH (0x49)      // BER high byte of low word
  1260. +#define CX24120_REG_BER_LL (0x4A)      // BER low byte of low word
  1261. +
  1262. +#define CX24120_REG_SIGSTR_H (0x3A)        // Signal strength high byte & ??? status register ???
  1263. +#define CX24120_REG_SIGSTR_L (0x3B)        // Signal strength low byte
  1264. +
  1265. +#define CX24120_REG_UCB_H (0x50)       // UCB high byte
  1266. +#define CX24120_REG_UCB_L (0x51)       // UCB low byte
  1267. +
  1268. +#define CX24120_REG_REVISION (0xFF)        // Chip revision (ro). Must be 0x7 or 0x5
  1269. +
  1270. +// ##############################
  1271. +/* Command messages */
  1272. +enum command_message_id {
  1273. +   CMD_VCO_SET         = 0x10,     // cmdlen = 12;
  1274. +   CMD_TUNEREQUEST     = 0x11,     // cmd.len = 15;
  1275. +  
  1276. +   CMD_MPEG_ONOFF      = 0x13,     // cmd.len = 4;
  1277. +   CMD_MPEG_INIT       = 0x14,     // cmd.len = 7;
  1278. +   CMD_BANDWIDTH       = 0x15,     // cmd.len = 12;
  1279. +   CMD_CLOCK_READ      = 0x16,     // read clock from registers 0x01-0x06
  1280. +   CMD_CLOCK_SET       = 0x17,     // cmd.len = 10;
  1281. +  
  1282. +   CMD_DISEQC_MSG1     = 0x20,     // cmd.len = 11;
  1283. +   CMD_DISEQC_MSG2     = 0x21,     // cmd.len = d->msg_len + 6;
  1284. +   CMD_SETVOLTAGE      = 0x22,     // cmd.len = 2;
  1285. +   CMD_SETTONE         = 0x23,     // cmd.len = 4;
  1286. +   CMD_DISEQC_BURST    = 0x24,     // cmd.len not used !!!
  1287. +  
  1288. +   CMD_READ_SNR        = 0x1A,     // Read signal strength
  1289. +   CMD_START_TUNER     = 0x1B,     // ???
  1290. +  
  1291. +   CMD_TUNER_INIT      = 0x3C,     // cmd.len = 0x03;
  1292. +};
  1293. +// ##############################
  1294. +/* signal status */
  1295. +#define CX24120_HAS_SIGNAL  (0x01)
  1296. +#define CX24120_HAS_CARRIER (0x02)
  1297. +#define CX24120_HAS_VITERBI    (0x04)
  1298. +#define CX24120_HAS_LOCK   (0x08)
  1299. +#define CX24120_HAS_UNK1   (0x10)
  1300. +#define CX24120_HAS_UNK2   (0x20)
  1301. +#define CX24120_STATUS_MASK (0x0f)
  1302. +#define CX24120_SIGNAL_MASK (0xc0)
  1303. +
  1304. +static u8 cx24120_msg_tuner_init[] = { 0,0,0,0,0,0 };
  1305. +static u8 cx24120_msg_read_sigstr[] = {0,0};
  1306. +
  1307. +static struct cx24120_skystar2_mpeg_config {
  1308. +   u8 x1;
  1309. +   u8 x2;
  1310. +   u8 x3;
  1311. +} initial_mpeg_config = { 
  1312. +   0xA1,   // 10100001
  1313. +   0x76,   // 01110110
  1314. +   0x07,   // 00000111
  1315. +};
  1316. +
  1317. +static struct cx24120_symrate_delay {
  1318. +   u32 symrate;
  1319. +   u32 delay;
  1320. +} symrates_pairs[] = {
  1321. +   {    3000000, 15000 },
  1322. +   {    6000000, 10000 },
  1323. +   {    8000000,  5000 },
  1324. +   {   10000000,  2000 },
  1325. +   {0x0FFFFFFFF,   400 },
  1326. +};
  1327. +
  1328. +static struct cx24120_clock_ratios_table {
  1329. +   u32 ratio_id;
  1330. +   u32 mode_xPSK;
  1331. +   u32 fec_mode;
  1332. +   u32 m_rat;
  1333. +   u32 n_rat;
  1334. +   u32 rate;
  1335. +} clock_ratios_table[] = {
  1336. +{  21  ,   0   ,   1   ,   770068  ,   763515  ,   258 },
  1337. +{  21  ,   0   ,   100 ,   97409   ,   80370   ,   310 },
  1338. +{  21  ,   0   ,   2   ,   137293  ,   101802  ,   345 },
  1339. +{  21  ,   0   ,   3   ,   4633447 ,   3054060 ,   388 },
  1340. +{  21  ,   0   ,   4   ,   2472041 ,   1527030 ,   414 },
  1341. +{  21  ,   0   ,   5   ,   85904   ,   50901   ,   432 },
  1342. +{  21  ,   0   ,   8   ,   2751229 ,   1527030 ,   461 },
  1343. +{  21  ,   0   ,   101 ,   1392872 ,   763515  ,   467 },
  1344. +{  21  ,   99  ,   100 ,   1850771 ,   1019430 ,   464 },
  1345. +{  21  ,   99  ,   2   ,   137293  ,   67962   ,   517 },
  1346. +{  21  ,   99  ,   3   ,   4633447 ,   2038860 ,   581 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1347. +{  21  ,   99  ,   5   ,   85904   ,   33981   ,   647 },
  1348. +{  21  ,   99  ,   8   ,   2751229 ,   1019430 ,   690 },
  1349. +{  21  ,   99  ,   101 ,   1392872 ,   509715  ,   699 },
  1350. +{  29  ,   0   ,   1   ,   770068  ,   782127  ,   252 },
  1351. +{  29  ,   0   ,   100 ,   1850771 ,   1564254 ,   302 },
  1352. +{  29  ,   0   ,   2   ,   686465  ,   521418  ,   337 },
  1353. +{  29  ,   0   ,   3   ,   4633447 ,   3128508 ,   379 },
  1354. +{  29  ,   0   ,   4   ,   2472041 ,   1564254 ,   404 },
  1355. +{  29  ,   0   ,   5   ,   429520  ,   260709  ,   421 },
  1356. +{  29  ,   0   ,   8   ,   2751229 ,   1564254 ,   450 },
  1357. +{  29  ,   0   ,   101 ,   1392872 ,   782127  ,   455 },
  1358. +{  29  ,   99  ,   100 ,   1850771 ,   1043118 ,   454 },
  1359. +{  29  ,   99  ,   2   ,   686465  ,   347706  ,   505 },
  1360. +{  29  ,   99  ,   3   ,   4633447 ,   2086236 ,   568 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1361. +{  29  ,   99  ,   5   ,   429520  ,   173853  ,   632 },
  1362. +{  29  ,   99  ,   8   ,   2751229 ,   1043118 ,   675 },
  1363. +{  29  ,   99  ,   101 ,   1392872 ,   521559  ,   683 },
  1364. +{  17  ,   0   ,   1   ,   766052  ,   763515  ,   256 },
  1365. +{  17  ,   0   ,   100 ,   96901   ,   80370   ,   308 },
  1366. +{  17  ,   0   ,   2   ,   136577  ,   101802  ,   343 },
  1367. +{  17  ,   0   ,   3   ,   4609283 ,   3054060 ,   386 },
  1368. +{  17  ,   0   ,   4   ,   2459149 ,   1527030 ,   412 },
  1369. +{  17  ,   0   ,   5   ,   85456   ,   50901   ,   429 },
  1370. +{  17  ,   0   ,   8   ,   2736881 ,   1527030 ,   458 },
  1371. +{  17  ,   0   ,   101 ,   1385608 ,   763515  ,   464 },
  1372. +{  17  ,   99  ,   100 ,   1841119 ,   1019430 ,   462 },
  1373. +{  17  ,   99  ,   2   ,   136577  ,   67962   ,   514 },
  1374. +{  17  ,   99  ,   3   ,   4609283 ,   2038860 ,   578 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1375. +{  17  ,   99  ,   5   ,   85456   ,   33981   ,   643 },
  1376. +{  17  ,   99  ,   8   ,   2736881 ,   1019430 ,   687 },
  1377. +{  17  ,   99  ,   101 ,   1385608 ,   509715  ,   695 },
  1378. +{  25  ,   0   ,   1   ,   766052  ,   782127  ,   250 },
  1379. +{  25  ,   0   ,   100 ,   1841119 ,   1564254 ,   301 },
  1380. +{  25  ,   0   ,   2   ,   682885  ,   521418  ,   335 },
  1381. +{  25  ,   0   ,   3   ,   4609283 ,   3128508 ,   377 },
  1382. +{  25  ,   0   ,   4   ,   2459149 ,   1564254 ,   402 },
  1383. +{  25  ,   0   ,   5   ,   427280  ,   260709  ,   419 },
  1384. +{  25  ,   0   ,   8   ,   2736881 ,   1564254 ,   447 },
  1385. +{  25  ,   0   ,   101 ,   1385608 ,   782127  ,   453 },
  1386. +{  25  ,   99  ,   100 ,   1841119 ,   1043118 ,   451 },
  1387. +{  25  ,   99  ,   2   ,   682885  ,   347706  ,   502 },
  1388. +{  25  ,   99  ,   3   ,   4609283 ,   2086236 ,   565 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1389. +{  25  ,   99  ,   5   ,   427280  ,   173853  ,   629 },
  1390. +{  25  ,   99  ,   8   ,   2736881 ,   1043118 ,   671 },
  1391. +{  25  ,   99  ,   101 ,   1385608 ,   521559  ,   680 },
  1392. +{  5   ,   0   ,   1   ,   273088  ,   254505  ,   274 },
  1393. +{  5   ,   0   ,   100 ,   17272   ,   13395   ,   330 },
  1394. +{  5   ,   0   ,   2   ,   24344   ,   16967   ,   367 },
  1395. +{  5   ,   0   ,   3   ,   410788  ,   254505  ,   413 },
  1396. +{  5   ,   0   ,   4   ,   438328  ,   254505  ,   440 },
  1397. +{  5   ,   0   ,   5   ,   30464   ,   16967   ,   459 },
  1398. +{  5   ,   0   ,   8   ,   487832  ,   254505  ,   490 },
  1399. +{  5   ,   0   ,   101 ,   493952  ,   254505  ,   496 },
  1400. +{  5   ,   99  ,   100 ,   328168  ,   169905  ,   494 },
  1401. +{  5   ,   99  ,   2   ,   24344   ,   11327   ,   550 }// work for 0x0d - 11278V - DVB-S2 - 8PSK MPEG-4/HD
  1402. +{  5   ,   99  ,   3   ,   410788  ,   169905  ,   618 }// 0x0e S2 8psk        // was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1403. +{  5   ,   99  ,   5   ,   30464   ,   11327   ,   688 },
  1404. +{  5   ,   99  ,   8   ,   487832  ,   169905  ,   735 },
  1405. +{  5   ,   99  ,   101 ,   493952  ,   169905  ,   744 },
  1406. +{  13  ,   0   ,   1   ,   273088  ,   260709  ,   268 },
  1407. +{  13  ,   0   ,   100 ,   328168  ,   260709  ,   322 },
  1408. +{  13  ,   0   ,   2   ,   121720  ,   86903   ,   358 },
  1409. +{  13  ,   0   ,   3   ,   410788  ,   260709  ,   403 },
  1410. +{  13  ,   0   ,   4   ,   438328  ,   260709  ,   430 },
  1411. +{  13  ,   0   ,   5   ,   152320  ,   86903   ,   448 },
  1412. +{  13  ,   0   ,   8   ,   487832  ,   260709  ,   479 },
  1413. +{  13  ,   0   ,   101 ,   493952  ,   260709  ,   485 },
  1414. +{  13  ,   99  ,   100 ,   328168  ,   173853  ,   483 },
  1415. +{  13  ,   99  ,   2   ,   121720  ,   57951   ,   537 }, // work for 0x8d - dvb-s2 8psk
  1416. +{  13  ,   99  ,   3   ,   410788  ,   173853  ,   604 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1417. +{  13  ,   99  ,   5   ,   152320  ,   57951   ,   672 },
  1418. +{  13  ,   99  ,   8   ,   487832  ,   173853  ,   718 },
  1419. +{  13  ,   99  ,   101 ,   493952  ,   173853  ,   727 },
  1420. +{  1   ,   0   ,   1   ,   815248  ,   763515  ,   273 },
  1421. +{  1   ,   0   ,   100 ,   51562   ,   40185   ,   328 },
  1422. +{  1   ,   0   ,   2   ,   72674   ,   50901   ,   365 },
  1423. +{  1   ,   0   ,   3   ,   1226323 ,   763515  ,   411 },
  1424. +{  1   ,   0   ,   4   ,   1308538 ,   763515  ,   438 },
  1425. +{  1   ,   0   ,   5   ,   90944   ,   50901   ,   457 },
  1426. +{  1   ,   0   ,   8   ,   1456322 ,   763515  ,   488 },
  1427. +{  1   ,   0   ,   101 ,   1474592 ,   763515  ,   494 },
  1428. +{  1   ,   99  ,   100 ,   979678  ,   509715  ,   492 },
  1429. +{  1   ,   99  ,   2   ,   72674   ,   33981   ,   547 },
  1430. +{  1   ,   99  ,   3   ,   1226323 ,   509715  ,   615 }// was 4 - ERRORR!? FEC_4_5 not in DVB-S2
  1431. +{  1   ,   99  ,   5   ,   90944   ,   33981   ,   685 },
  1432. +{  1   ,   99  ,   8   ,   1456322 ,   509715  ,   731 },
  1433. +{  1   ,   99  ,   101 ,   1474592 ,   509715  ,   740 },
  1434. +{  9   ,   0   ,   1   ,   815248  ,   782127  ,   266 },
  1435. +{  9   ,   0   ,   100 ,   979678  ,   782127  ,   320 },
  1436. +{  9   ,   0   ,   2   ,   363370  ,   260709  ,   356 },
  1437. +{  9   ,   0   ,   3   ,   1226323 ,   782127  ,   401 },
  1438. +{  9   ,   0   ,   4   ,   1308538 ,   782127  ,   428 },
  1439. +{  9   ,   0   ,   5   ,   454720  ,   260709  ,   446 },
  1440. +{  9   ,   0   ,   8   ,   1456322 ,   782127  ,   476 },
  1441. +{  9   ,   0   ,   101 ,   1474592 ,   782127  ,   482 },
  1442. +{  9   ,   99  ,   100 ,   979678  ,   521559  ,   480 },
  1443. +{  9   ,   99  ,   2   ,   363370  ,   173853  ,   535 },
  1444. +{  9   ,   99  ,   3   ,   1226323 ,   521559  ,   601 }// was 4 - ERRORR! FEC_4_5 not in DVB-S2
  1445. +{  9   ,   99  ,   5   ,   454720  ,   173853  ,   669 },
  1446. +{  9   ,   99  ,   8   ,   1456322 ,   521559  ,   714 },
  1447. +{  9   ,   99  ,   101 ,   1474592 ,   521559  ,   723 },
  1448. +{  18  ,   0   ,   1   ,   535 ,   588 ,   233 },
  1449. +{  18  ,   0   ,   2   ,   1070    ,   882 ,   311 },
  1450. +{  18  ,   0   ,   6   ,   3210    ,   2058    ,   399 },
  1451. +{  16  ,   0   ,   1   ,   763 ,   816 ,   239 },
  1452. +{  16  ,   0   ,   2   ,   1526    ,   1224    ,   319 },
  1453. +{  16  ,   0   ,   3   ,   2289    ,   1632    ,   359 },
  1454. +{  16  ,   0   ,   5   ,   3815    ,   2448    ,   399 },
  1455. +{  16  ,   0   ,   7   ,   5341    ,   3264    ,   419 },
  1456. +{  22  ,   0   ,   1   ,   535 ,   588 ,   233 },
  1457. +{  22  ,   0   ,   2   ,   1070    ,   882 ,   311 },
  1458. +{  22  ,   0   ,   6   ,   3210    ,   2058    ,   399 },
  1459. +{  20  ,   0   ,   1   ,   143429  ,   152592  ,   241 },
  1460. +{  20  ,   0   ,   2   ,   286858  ,   228888  ,   321 },
  1461. +{  20  ,   0   ,   3   ,   430287  ,   305184  ,   361 },
  1462. +{  20  ,   0   ,   5   ,   717145  ,   457776  ,   401 },
  1463. +{  20  ,   0   ,   7   ,   1004003 ,   610368  ,   421 },
  1464. +{  2   ,   0   ,   1   ,   584 ,   588 ,   254 },
  1465. +{  2   ,   0   ,   2   ,   1169    ,   882 ,   339 },
  1466. +{  2   ,   0   ,   6   ,   3507    ,   2058    ,   436 },
  1467. +{  0   ,   0   ,   1   ,   812 ,   816 ,   255 },
  1468. +{  0   ,   0   ,   2   ,   1624    ,   1224    ,   340 },
  1469. +{  0   ,   0   ,   3   ,   2436    ,   1632    ,   382 },
  1470. +{  0   ,   0   ,   5   ,   4060    ,   2448    ,   425 },
  1471. +{  0   ,   0   ,   7   ,   5684    ,   3264    ,   446 },
  1472. +{  6   ,   0   ,   1   ,   584 ,   588 ,   254 },
  1473. +{  6   ,   0   ,   2   ,   1168    ,   882 ,   339 },
  1474. +{  6   ,   0   ,   6   ,   3504    ,   2058    ,   436 },
  1475. +{  4   ,   0   ,   1   ,   152592  ,   152592  ,   256 },
  1476. +{  4   ,   0   ,   2   ,   305184  ,   228888  ,   341 },
  1477. +{  4   ,   0   ,   3   ,   457776  ,   305184  ,   384 },
  1478. +{  4   ,   0   ,   5   ,   762960  ,   457776  ,   427 },
  1479. +{  4   ,   0   ,   7   ,   1068144 ,   610368  ,   448 },
  1480. +};
  1481. diff -NurEbBw --strip-trailing-cr drivers/media/dvb-frontends/cx24120.h drivers/media/dvb-frontends/cx24120.h
  1482. --- linux/drivers/media/dvb-frontends/cx24120.h 1970-01-01 03:00:00.000000000 +0300
  1483. +++ linux/drivers/media/dvb-frontends/cx24120.h 2012-04-03 10:27:59.000000000 +0400
  1484. @@ -0,0 +1,59 @@
  1485. +/*
  1486. + * Conexant CX24120/CX24118 - DVB-S/S2 demod/tuner driver
  1487. + *
  1488. + * Copyright (C) 2008 Patrick Boettcher <pb@linuxtv.org>
  1489. + * Copyright (C) 2009 Sergey Tyurin <forum.free-x.de>
  1490. + * Updated 2012 by Jannis Achstetter <jannis_achstetter@web.de>
  1491. + *
  1492. + * This program is free software; you can redistribute it and/or modify
  1493. + * it under the terms of the GNU General Public License as published by
  1494. + * the Free Software Foundation; either version 2 of the License, or
  1495. + * (at your option) any later version.
  1496. + *
  1497. + * This program is distributed in the hope that it will be useful,
  1498. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1499. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1500. + * GNU General Public License for more details.
  1501. + *
  1502. + * You should have received a copy of the GNU General Public License
  1503. + * along with this program; if not, write to the Free Software
  1504. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1505. + */
  1506. +
  1507. +#ifndef CX24120_H
  1508. +#define CX24120_H
  1509. +
  1510. +#include <linux/dvb/frontend.h>
  1511. +
  1512. +struct firmware;
  1513. +struct dvb_frontend;
  1514. +struct i2c_adapter;
  1515. +
  1516. +struct cx24120_config
  1517. +{
  1518. +   u8 i2c_addr;
  1519. +   int (*request_firmware)(struct dvb_frontend *fe, const struct firmware **fw, char *name);
  1520. +   void (*stream_control)(struct dvb_frontend *fe, u8 onoff);
  1521. +};
  1522. +
  1523. +#if defined(CONFIG_DVB_CX24120) || \
  1524. +   (defined(CONFIG_DVB_CX24120_MODULE) && defined(MODULE))
  1525. +extern struct dvb_frontend *cx24120_attach(const struct cx24120_config *config,
  1526. +       struct i2c_adapter *i2c);
  1527. +extern int cx24120_reset(struct dvb_frontend *fe);
  1528. +#else
  1529. +static inline
  1530. +struct dvb_frontend *cx24120_attach(const struct cx24120_config *config,
  1531. +       struct i2c_adapter *i2c)
  1532. +{
  1533. +   printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
  1534. +   return NULL;
  1535. +}
  1536. +static inline int cx24120_reset(struct dvb_frontend *fe)
  1537. +{
  1538. +   printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
  1539. +   return -ENODEV;
  1540. +}
  1541. +#endif
  1542. +
  1543. +#endif
  1544. diff -NurEbBw --strip-trailing-cr drivers/media/dvb-frontends/Kconfig drivers/media/dvb-frontends/Kconfig
  1545. --- linux/drivers/media/dvb-frontends/Kconfig   2012-04-03 15:23:44.976143444 +0400
  1546. +++ linux/drivers/media/dvb-frontends/Kconfig   2012-04-03 15:26:40.760141513 +0400
  1547. @@ -4,6 +4,13 @@
  1548.  comment "Multistandard (satellite) frontends"
  1549.     depends on DVB_CORE
  1550.  
  1551. +config DVB_CX24120
  1552. +   tristate "Conexant CX24120 based"
  1553. +   depends on DVB_CORE && I2C
  1554. +   default m if DVB_FE_CUSTOMISE
  1555. +   help
  1556. +     A DVB-S/DVB-S2 tuner module. Say Y when you want to support this frontend.
  1557. +
  1558.  config DVB_STB0899
  1559.     tristate "STB0899 based"
  1560.     depends on DVB_CORE && I2C
  1561. diff -NurEbBw --strip-trailing-cr drivers/media/dvb-frontends/Makefile drivers/media/dvb-frontends/Makefile
  1562. --- linux/drivers/media/dvb-frontends/Makefile  2012-04-03 15:23:44.976143444 +0400
  1563. +++ linux/drivers/media/dvb-frontends/Makefile  2012-04-03 15:26:40.760141513 +0400
  1564. @@ -19,6 +19,10 @@
  1565.  obj-$(CONFIG_DVB_CX22700) += cx22700.o
  1566.  obj-$(CONFIG_DVB_S5H1432) += s5h1432.o
  1567.  obj-$(CONFIG_DVB_CX24110) += cx24110.o
  1568. +
  1569. +# inserted by Custler
  1570. +obj-$(CONFIG_DVB_CX24120) += cx24120.o
  1571. +
  1572.  obj-$(CONFIG_DVB_TDA8083) += tda8083.o
  1573.  obj-$(CONFIG_DVB_L64781) += l64781.o
  1574.  obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement