├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── cxd2857.h ├── cxd2857_priv.h ├── cxd2857er.c ├── default-channels.conf ├── tbsecp3-asi.c ├── tbsecp3-ca.c ├── tbsecp3-cards.c ├── tbsecp3-core.c ├── tbsecp3-dma.c ├── tbsecp3-dvb.c ├── tbsecp3-i2c.c ├── tbsecp3-regs.h └── tbsecp3.h /.gitignore: -------------------------------------------------------------------------------- 1 | Module.symvers 2 | modules.order 3 | *.o 4 | *.rc 5 | *.ko 6 | *.o.cmd 7 | *.o.d 8 | *.ko.cmd 9 | *.symvers.cmd 10 | *.mod.cmd 11 | *.mod 12 | *.mod.c 13 | *.mod.o 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | tbs6812-objs := tbsecp3-core.o tbsecp3-cards.o tbsecp3-i2c.o tbsecp3-dma.o tbsecp3-dvb.o tbsecp3-asi.o 2 | cxd2857-objs := cxd2857er.o 3 | # tbsecp3-ca.o 4 | obj-m := tbs6812.o cxd2857.o 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## tbs6812_drv 2 | 3 | ISDB-T/ISDB-S/ISDB-S3対応Linux向けTBS6812 a.k.a. PT4Kドライバ 4 | 5 | カーネルモジュールのビルド環境を構築後、次のようにしてビルド (例): 6 | 7 | ```sh 8 | make -C "/lib/modules/$(uname -r)/build" "M=$(pwd)" tbs6812.ko cxd2857.ko 9 | ``` 10 | 11 | ロード: 12 | 13 | ```sh 14 | modprobe dvb-core 15 | insmod ./cxd2857.ko 16 | insmod ./tbs6812.ko 17 | ``` 18 | 19 | DVBデバイスとして見えるのでdvb-toolsなどを導入するとストリームを得ることができます。 20 | 21 | ```sh 22 | dvbv5-zap -a 0 -c default-channels.conf defaultTLV -r -P -o defaultTLV.mmts 23 | dvbv5-zap -a 0 -c default-channels.conf defaultTS -r -P -o defaultTS.ts 24 | ``` 25 | 26 | ### 仕様 27 | 28 | `DELIVERY_SYSTEM = ISDBS`かつ`STREAM_ID`が8未満のときISDB-Sの相対TS番号で選局されます。 29 | 30 | `DELIVERY_SYSTEM = ISDBS`かつ`STREAM_ID`の上位4ビットが0xbまたは0xcのときISDB-S3のストリームIDで選局、それ以外のときISDB-SのTSIDで選局されます。 31 | -------------------------------------------------------------------------------- /cxd2857.h: -------------------------------------------------------------------------------- 1 | #ifndef _CXD2878_H_ 2 | #define _CXD2878_H_ 3 | 4 | enum sony_demod_xtal_t { 5 | SONY_DEMOD_XTAL_16000KHz = 0, /**< 16 MHz */ 6 | SONY_DEMOD_XTAL_24000KHz = 1, /**< 24 MHz */ 7 | SONY_DEMOD_XTAL_32000KHz = 2 /**< 32 MHz */ 8 | }; 9 | enum sony_ascot3_xtal_t { 10 | SONY_ASCOT3_XTAL_16000KHz, /**< 16 MHz */ 11 | SONY_ASCOT3_XTAL_20500KHz, /**< 20.5 MHz */ 12 | SONY_ASCOT3_XTAL_24000KHz, /**< 24 MHz */ 13 | SONY_ASCOT3_XTAL_41000KHz /**< 41 MHz */ 14 | }; 15 | 16 | #define SONY_DEMOD_MAKE_IFFREQ_CONFIG(iffreq) \ 17 | ((u32)(((iffreq) / 48.0) * 16777216.0 + 0.5)) 18 | #define SONY_DEMOD_ATSC_MAKE_IFFREQ_CONFIG(iffreq) \ 19 | ((u32)(((iffreq) / 24.0) * 4294967296.0 + 0.5)) 20 | 21 | #define MASKUPPER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU << (32 - (n)))) 22 | #define MASKLOWER(n) (((n) == 0) ? 0 : (0xFFFFFFFFU >> (32 - (n)))) 23 | 24 | struct cxd2857_config { 25 | u8 addr_slvt; 26 | enum sony_demod_xtal_t xtal; 27 | u8 tuner_addr; 28 | enum sony_ascot3_xtal_t tuner_xtal; 29 | u8 tuner_index; 30 | bool tlv_mode; 31 | //for ecp3 update 32 | void (*write_properties)(struct i2c_adapter *i2c, u8 reg, u32 buf); 33 | void (*read_properties)(struct i2c_adapter *i2c, u8 reg, u32 *buf); 34 | // EEPROM access 35 | void (*write_eeprom)(struct i2c_adapter *i2c, u8 reg, u8 buf); 36 | void (*read_eeprom)(struct i2c_adapter *i2c, u8 reg, u8 *buf); 37 | 38 | //for 6590SE mode change(T or s); 39 | void (*RF_switch)(struct i2c_adapter *i2c, u8 rf_in, u8 flag); 40 | u8 rf_port; //for change command 41 | void (*TS_switch)(struct i2c_adapter *i2c, u8 flag); //5590 42 | void (*LED_switch)(struct i2c_adapter *i2c, u8 flag); //5590 43 | }; 44 | 45 | #define CONFIG_DVB_CXD2878_MODULE 46 | #define CONFIG_DVB_CXD2878 47 | #if 1 48 | extern struct dvb_frontend *cxd2857_attach(const struct cxd2857_config *config, 49 | struct i2c_adapter *i2c); 50 | #else 51 | static inline struct dvb_frontend * 52 | cxd2857_attach(const struct cxd2857_config *config, struct i2c_adapter *i2c) 53 | { 54 | dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__); 55 | return NULL; 56 | } 57 | 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /cxd2857_priv.h: -------------------------------------------------------------------------------- 1 | #ifndef _CXD2878_PRIV_H_ 2 | #define _CXD2878_PRIV_H_ 3 | 4 | #define AUTO \ 5 | (0xFF) /* For IF_OUT_SEL and AGC_SEL, it means that the value is desided by config flags. */ 6 | /* For RF_GAIN, it means that RF_GAIN_SEL(SubAddr:0x4E) = 1 */ 7 | #define OFFSET(ofs) ((u8)(ofs)&0x1F) 8 | #define BW_6 (0x00) 9 | #define BW_7 (0x01) 10 | #define BW_8 (0x02) 11 | #define BW_1_7 (0x03) 12 | 13 | #define MAX_BIT_PRECISION 5 14 | #define FRAC_BITMASK 0x1F 15 | #define LOG2_10_100X 332 /**< log2 (10) */ 16 | #define LOG2_E_100X 144 /**< log2 (e) */ 17 | 18 | ////////////////////////////// 19 | enum sony_ascot3_tv_system_t { 20 | SONY_ASCOT3_TV_SYSTEM_UNKNOWN, 21 | /* Analog */ 22 | SONY_ASCOT3_ATV_MN_EIAJ, /**< System-M (Japan) (IF: Fp=5.75MHz in default) */ 23 | SONY_ASCOT3_ATV_MN_SAP, /**< System-M (US) (IF: Fp=5.75MHz in default) */ 24 | SONY_ASCOT3_ATV_MN_A2, /**< System-M (Korea) (IF: Fp=5.9MHz in default) */ 25 | SONY_ASCOT3_ATV_BG, /**< System-B/G (IF: Fp=7.3MHz in default) */ 26 | SONY_ASCOT3_ATV_I, /**< System-I (IF: Fp=7.85MHz in default) */ 27 | SONY_ASCOT3_ATV_DK, /**< System-D/K (IF: Fp=7.85MHz in default) */ 28 | SONY_ASCOT3_ATV_L, /**< System-L (IF: Fp=7.85MHz in default) */ 29 | SONY_ASCOT3_ATV_L_DASH, /**< System-L DASH (IF: Fp=2.2MHz in default) */ 30 | /* Digital */ 31 | SONY_ASCOT3_DTV_8VSB, /**< ATSC 8VSB (IF: Fc=3.7MHz in default) */ 32 | SONY_ASCOT3_DTV_QAM, /**< US QAM (IF: Fc=3.7MHz in default) */ 33 | SONY_ASCOT3_DTV_ISDBT_6, /**< ISDB-T 6MHzBW (IF: Fc=3.55MHz in default) */ 34 | SONY_ASCOT3_DTV_ISDBT_7, /**< ISDB-T 7MHzBW (IF: Fc=4.15MHz in default) */ 35 | SONY_ASCOT3_DTV_ISDBT_8, /**< ISDB-T 8MHzBW (IF: Fc=4.75MHz in default) */ 36 | SONY_ASCOT3_DTV_DVBT_5, /**< DVB-T 5MHzBW (IF: Fc=3.6MHz in default) */ 37 | SONY_ASCOT3_DTV_DVBT_6, /**< DVB-T 6MHzBW (IF: Fc=3.6MHz in default) */ 38 | SONY_ASCOT3_DTV_DVBT_7, /**< DVB-T 7MHzBW (IF: Fc=4.2MHz in default) */ 39 | SONY_ASCOT3_DTV_DVBT_8, /**< DVB-T 8MHzBW (IF: Fc=4.8MHz in default) */ 40 | SONY_ASCOT3_DTV_DVBT2_1_7, /**< DVB-T2 1.7MHzBW (IF: Fc=3.5MHz in default) */ 41 | SONY_ASCOT3_DTV_DVBT2_5, /**< DVB-T2 5MHzBW (IF: Fc=3.6MHz in default) */ 42 | SONY_ASCOT3_DTV_DVBT2_6, /**< DVB-T2 6MHzBW (IF: Fc=3.6MHz in default) */ 43 | SONY_ASCOT3_DTV_DVBT2_7, /**< DVB-T2 7MHzBW (IF: Fc=4.2MHz in default) */ 44 | SONY_ASCOT3_DTV_DVBT2_8, /**< DVB-T2 8MHzBW (IF: Fc=4.8MHz in default) */ 45 | SONY_ASCOT3_DTV_DVBC_6, /**< DVB-C 6MHzBW (IF: Fc=3.7MHz in default) */ 46 | SONY_ASCOT3_DTV_DVBC_8, /**< DVB-C 8MHzBW (IF: Fc=4.9MHz in default) */ 47 | SONY_ASCOT3_DTV_DVBC2_6, /**< DVB-C2 6MHzBW (IF: Fc=3.7MHz in default) */ 48 | SONY_ASCOT3_DTV_DVBC2_8, /**< DVB-C2 8MHzBW (IF: Fc=4.9MHz in default) */ 49 | SONY_ASCOT3_DTV_ATSC3_6, /**< ATSC 3.0 6MHzBW (IF: Fc=3.6MHz in default) */ 50 | SONY_ASCOT3_DTV_ATSC3_7, /**< ATSC 3.0 7MHzBW (IF: Fc=4.2MHz in default) */ 51 | SONY_ASCOT3_DTV_ATSC3_8, /**< ATSC 3.0 8MHzBW (IF: Fc=4.8MHz in default) */ 52 | SONY_ASCOT3_DTV_J83B_5_6, /**< J.83B 5.6Msps (IF: Fc=3.75MHz in default) */ 53 | SONY_ASCOT3_DTV_DTMB, /**< DTMB (IF: Fc=5.1MHz in default) */ 54 | 55 | SONY_ASCOT3_ATV_MIN = 56 | SONY_ASCOT3_ATV_MN_EIAJ, /**< Minimum analog terrestrial system */ 57 | SONY_ASCOT3_ATV_MAX = 58 | SONY_ASCOT3_ATV_L_DASH, /**< Maximum analog terrestrial system */ 59 | SONY_ASCOT3_DTV_MIN = 60 | SONY_ASCOT3_DTV_8VSB, /**< Minimum digital terrestrial system */ 61 | SONY_ASCOT3_DTV_MAX = 62 | SONY_ASCOT3_DTV_DTMB, /**< Maximum digital terrestrial system */ 63 | SONY_ASCOT3_TV_SYSTEM_NUM /**< Number of supported broadcasting system */ 64 | }; 65 | 66 | struct sony_ascot3_adjust_param_t { 67 | u8 OUTLMT; /**< Addr:0x68 Bit[1:0] : Maximum IF output. (0: 1.5Vp-p, 1: 1.2Vp-p) */ 68 | u8 RF_GAIN; /**< Addr:0x69 Bit[6:4] : RFVGA gain. 0xFF means Auto. (RF_GAIN_SEL = 1) */ 69 | u8 IF_BPF_GC; /**< Addr:0x69 Bit[3:0] : IF_BPF gain. */ 70 | u8 RFOVLD_DET_LV1_VL; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (FRF <= 172MHz) */ 71 | u8 RFOVLD_DET_LV1_VH; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (172MHz < FRF <= 464MHz) */ 72 | u8 RFOVLD_DET_LV1_U; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (FRF > 464MHz) */ 73 | u8 IFOVLD_DET_LV_VL; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (FRF <= 172MHz) */ 74 | u8 IFOVLD_DET_LV_VH; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (172MHz < FRF <= 464MHz) */ 75 | u8 IFOVLD_DET_LV_U; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (FRF > 464MHz) */ 76 | u8 IF_BPF_F0; /**< Addr:0x6D Bit[5:4] : IF filter center offset. */ 77 | u8 BW; /**< Addr:0x6D Bit[1:0] : 6MHzBW(0x00) or 7MHzBW(0x01) or 8MHzBW(0x02) or 1.7MHzBW(0x03) */ 78 | u8 FIF_OFFSET; /**< Addr:0x6E Bit[4:0] : 5bit signed. IF offset (kHz) = FIF_OFFSET x 50 */ 79 | u8 BW_OFFSET; /**< Addr:0x6F Bit[4:0] : 5bit signed. BW offset (kHz) = BW_OFFSET x 50 (BW_OFFSET x 10 in 1.7MHzBW) */ 80 | u8 AGC_SEL; /**< Addr:0x74 Bit[5:4] : AGC pin select. (0: AGC1, 1: AGC2) 0xFF means Auto (by config flags) */ 81 | u8 IF_OUT_SEL; /**< Addr:0x74 Bit[1:0] : IFOUT pin select. (0: IFOUT1, 1: IFOUT2) 0xFF means Auto. (by config flags) */ 82 | u8 IS_LOWERLOCAL; /**< Addr:0x9C Bit[0] : Local polarity. (0: Upper Local, 1: Lower Local) */ 83 | }; 84 | //////////////////////////////// 85 | 86 | enum sony_freia_tv_system_t { 87 | SONY_FREIA_TV_SYSTEM_UNKNOWN, 88 | /* Terrestrial Analog */ 89 | SONY_FREIA_ATV_MN_EIAJ, /**< System-M (Japan) (IF: Fp=5.75MHz in default) */ 90 | SONY_FREIA_ATV_MN_SAP, /**< System-M (US) (IF: Fp=5.75MHz in default) */ 91 | SONY_FREIA_ATV_MN_A2, /**< System-M (Korea) (IF: Fp=5.9MHz in default) */ 92 | SONY_FREIA_ATV_BG, /**< System-B/G (IF: Fp=7.3MHz in default) */ 93 | SONY_FREIA_ATV_I, /**< System-I (IF: Fp=7.85MHz in default) */ 94 | SONY_FREIA_ATV_DK, /**< System-D/K (IF: Fp=7.85MHz in default) */ 95 | SONY_FREIA_ATV_L, /**< System-L (IF: Fp=7.85MHz in default) */ 96 | SONY_FREIA_ATV_L_DASH, /**< System-L DASH (IF: Fp=2.2MHz in default) */ 97 | /* Terrestrial/Cable Digital */ 98 | SONY_FREIA_DTV_8VSB, /**< ATSC 8VSB (IF: Fc=3.7MHz in default) */ 99 | SONY_FREIA_DTV_ISDBT_6, /**< ISDB-T 6MHzBW (IF: Fc=3.55MHz in default) */ 100 | SONY_FREIA_DTV_ISDBT_7, /**< ISDB-T 7MHzBW (IF: Fc=4.15MHz in default) */ 101 | SONY_FREIA_DTV_ISDBT_8, /**< ISDB-T 8MHzBW (IF: Fc=4.75MHz in default) */ 102 | SONY_FREIA_DTV_DVBT_5, /**< DVB-T 5MHzBW (IF: Fc=3.6MHz in default) */ 103 | SONY_FREIA_DTV_DVBT_6, /**< DVB-T 6MHzBW (IF: Fc=3.6MHz in default) */ 104 | SONY_FREIA_DTV_DVBT_7, /**< DVB-T 7MHzBW (IF: Fc=4.2MHz in default) */ 105 | SONY_FREIA_DTV_DVBT_8, /**< DVB-T 8MHzBW (IF: Fc=4.8MHz in default) */ 106 | SONY_FREIA_DTV_DVBT2_1_7, /**< DVB-T2 1.7MHzBW (IF: Fc=3.5MHz in default) */ 107 | SONY_FREIA_DTV_DVBT2_5, /**< DVB-T2 5MHzBW (IF: Fc=3.6MHz in default) */ 108 | SONY_FREIA_DTV_DVBT2_6, /**< DVB-T2 6MHzBW (IF: Fc=3.6MHz in default) */ 109 | SONY_FREIA_DTV_DVBT2_7, /**< DVB-T2 7MHzBW (IF: Fc=4.2MHz in default) */ 110 | SONY_FREIA_DTV_DVBT2_8, /**< DVB-T2 8MHzBW (IF: Fc=4.8MHz in default) */ 111 | SONY_FREIA_DTV_CABLE_6, /**< DVB-C 6MHzBW/ISDB-C/J.83B (IF: Fc=3.7MHz in default) */ 112 | SONY_FREIA_DTV_CABLE_8, /**< DVB-C 8MHzBW/7MHzBW (IF: Fc=4.9MHz in default) */ 113 | SONY_FREIA_DTV_DVBC2_6, /**< DVB-C2 6MHzBW (IF: Fc=3.7MHz in default) */ 114 | SONY_FREIA_DTV_DVBC2_8, /**< DVB-C2 8MHzBW (IF: Fc=4.9MHz in default) */ 115 | SONY_FREIA_DTV_ATSC3_6, /**< ATSC 3.0 6MHzBW (IF: Fc=3.6MHz in default) */ 116 | SONY_FREIA_DTV_ATSC3_7, /**< ATSC 3.0 7MHzBW (IF: Fc=4.2MHz in default) */ 117 | SONY_FREIA_DTV_ATSC3_8, /**< ATSC 3.0 8MHzBW (IF: Fc=4.8MHz in default) */ 118 | SONY_FREIA_DTV_SKP_OPT, /**< J.83B 5.6Msps (IF: Fc=3.75MHz in default) */ 119 | SONY_FREIA_DTV_DTMB, /**< DTMB (IF: Fc=5.1MHz in default) */ 120 | /* Satellite */ 121 | SONY_FREIA_STV_ISDBS, /**< ISDB-S */ 122 | SONY_FREIA_STV_ISDBS3, /**< ISDB-S3 */ 123 | SONY_FREIA_STV_DVBS, /**< DVB-S */ 124 | SONY_FREIA_STV_DVBS2, /**< DVB-S2 */ 125 | 126 | SONY_FREIA_ATV_MIN = 127 | SONY_FREIA_ATV_MN_EIAJ, /**< Minimum analog terrestrial system */ 128 | SONY_FREIA_ATV_MAX = 129 | SONY_FREIA_ATV_L_DASH, /**< Maximum analog terrestrial system */ 130 | SONY_FREIA_DTV_MIN = 131 | SONY_FREIA_DTV_8VSB, /**< Minimum digital terrestrial system */ 132 | SONY_FREIA_DTV_MAX = 133 | SONY_FREIA_DTV_DTMB, /**< Maximum digital terrestrial system */ 134 | SONY_FREIA_TERR_TV_SYSTEM_NUM, /**< Number of supported terrestrial broadcasting system */ 135 | SONY_FREIA_STV_MIN = 136 | SONY_FREIA_STV_ISDBS, /**< Minimum satellite system */ 137 | SONY_FREIA_STV_MAX = 138 | SONY_FREIA_STV_DVBS2 /**< Maximum satellite system */ 139 | }; 140 | 141 | #define SONY_FREIA_IS_DVB_T_T2(tvSystem) \ 142 | ((((tvSystem) >= SONY_FREIA_DTV_DVBT_5) && \ 143 | ((tvSystem) <= SONY_FREIA_DTV_DVBT2_8)) || \ 144 | (((tvSystem) >= SONY_FREIA_DTV_ATSC3_6) && \ 145 | ((tvSystem) <= SONY_FREIA_DTV_ATSC3_8))) 146 | 147 | struct sony_freia_terr_adjust_param_t { 148 | u8 RF_GAIN; /**< Addr:0x69 Bit[6:4] : RFVGA gain. 0xFF means Auto. (RF_GAIN_SEL = 1) */ 149 | u8 IF_BPF_GC; /**< Addr:0x69 Bit[3:0] : IF_BPF gain. */ 150 | u8 RFOVLD_DET_LV1_VL; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (FRF <= 172MHz) */ 151 | u8 RFOVLD_DET_LV1_VH; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (172MHz < FRF <= 464MHz) */ 152 | u8 RFOVLD_DET_LV1_U; /**< Addr:0x6B Bit[3:0] : RF overload RF input detect level. (FRF > 464MHz) */ 153 | u8 IFOVLD_DET_LV_VL; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (FRF <= 172MHz) */ 154 | u8 IFOVLD_DET_LV_VH; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (172MHz < FRF <= 464MHz) */ 155 | u8 IFOVLD_DET_LV_U; /**< Addr:0x6C Bit[2:0] : Internal RFAGC detect level. (FRF > 464MHz) */ 156 | u8 IF_BPF_F0; /**< Addr:0x6D Bit[5:4] : IF filter center offset. */ 157 | u8 BW; /**< Addr:0x6D Bit[1:0] : 6MHzBW(0x00) or 7MHzBW(0x01) or 8MHzBW(0x02) or 1.7MHzBW(0x03) */ 158 | u8 FIF_OFFSET; /**< Addr:0x6E Bit[4:0] : 5bit signed. IF offset (kHz) = FIF_OFFSET x 50 */ 159 | u8 BW_OFFSET; /**< Addr:0x6F Bit[4:0] : 5bit signed. BW offset (kHz) = BW_OFFSET x 50 (BW_OFFSET x 10 in 1.7MHzBW) */ 160 | u8 AGC_SEL; /**< Addr:0x74 Bit[5:4] : AGC pin select. (0: AGC1, 1: AGC2) 0xFF means Auto (by config flags) */ 161 | u8 IF_OUT_SEL; /**< Addr:0x74 Bit[0:1] : IFOUT pin select. (0: IFOUT1, 1: IFOUT2) 0xFF means Auto. (by config flags) */ 162 | }; 163 | 164 | //////////////////////// 165 | enum sony_demod_chip_id_t { 166 | SONY_DEMOD_CHIP_ID_UNKNOWN = 0, /**< Unknown */ 167 | SONY_DEMOD_CHIP_ID_CXD2856 = 0x090, /**< CXD2856 / CXD6800(SiP) */ 168 | SONY_DEMOD_CHIP_ID_CXD2857 = 0x091, /**< CXD2857 */ 169 | SONY_DEMOD_CHIP_ID_CXD2878 = 0x396, /**< CXD2878 / CXD6801(SiP) */ 170 | SONY_DEMOD_CHIP_ID_CXD2879 = 0x297, /**< CXD2879 */ 171 | SONY_DEMOD_CHIP_ID_CXD6802 = 0x197, /**< CXD6802(SiP) */ 172 | SONY_DEMOD_CHIP_ID_CXD6822 = 0X19C, /**/ 173 | SONY_DEMOD_CHIP_ID_CXD2878A = 0x39A /**/ 174 | }; 175 | enum sony_ascot3_chip_id_t { 176 | SONY_ASCOT3_CHIP_ID_UNKNOWN, /**< Unknown */ 177 | SONY_ASCOT3_CHIP_ID_2871, /**< CXD2871 (for TV) */ 178 | SONY_ASCOT3_CHIP_ID_2872, /**< CXD2872 (for STB) */ 179 | SONY_ASCOT3_CHIP_ID_2871A, /**< CXD2871A (ASCOT3I) (for TV) */ 180 | SONY_ASCOT3_CHIP_ID_2875 /**< CXD2875 */ 181 | }; 182 | enum sony_dtv_system_t { 183 | SONY_DTV_SYSTEM_UNKNOWN, /**< Unknown. */ 184 | SONY_DTV_SYSTEM_DVBT, /**< DVB-T */ 185 | SONY_DTV_SYSTEM_DVBT2, /**< DVB-T2 */ 186 | SONY_DTV_SYSTEM_DVBC, /**< DVB-C(J.83A) */ 187 | SONY_DTV_SYSTEM_DVBC2, /**< DVB-C2(J.382) */ 188 | SONY_DTV_SYSTEM_ATSC, /**< ATSC */ 189 | SONY_DTV_SYSTEM_ATSC3, /**< ATSC3.0 */ 190 | SONY_DTV_SYSTEM_ISDBT, /**< ISDB-T */ 191 | SONY_DTV_SYSTEM_ISDBC, /**< ISDB-C(J.83C) */ 192 | SONY_DTV_SYSTEM_J83B, /**< J.83B */ 193 | SONY_DTV_SYSTEM_DVBS, /**< DVB-S */ 194 | SONY_DTV_SYSTEM_DVBS2, /**< DVB-S2 */ 195 | SONY_DTV_SYSTEM_ISDBS, /**< ISDB-S */ 196 | SONY_DTV_SYSTEM_ISDBS3, /**< ISDB-S3 */ 197 | SONY_DTV_SYSTEM_ANY /**< Used for multiple system scanning / blind tuning */ 198 | }; 199 | 200 | enum sony_dtv_bandwidth_t { 201 | SONY_DTV_BW_UNKNOWN = 0, /**< Unknown bandwidth. */ 202 | SONY_DTV_BW_1_7_MHZ = 1, /**< 1.7MHz bandwidth. */ 203 | SONY_DTV_BW_5_MHZ = 5, /**< 5MHz bandwidth. */ 204 | SONY_DTV_BW_6_MHZ = 6, /**< 6MHz bandwidth. */ 205 | SONY_DTV_BW_7_MHZ = 7, /**< 7MHz bandwidth. */ 206 | SONY_DTV_BW_8_MHZ = 8, /**< 8MHz bandwidth. */ 207 | 208 | SONY_DTV_BW_J83B_5_06_5_36_MSPS = 209 | 50, /**< For J.83B. 5.06/5.36Msps auto selection commonly used in US. */ 210 | SONY_DTV_BW_J83B_5_60_MSPS = 211 | 51 /**< For J.83B. 5.6Msps used by SKY PerfecTV! Hikari in Japan. */ 212 | }; 213 | 214 | enum sony_demod_state_t { 215 | SONY_DEMOD_STATE_UNKNOWN, /**< Unknown. */ 216 | SONY_DEMOD_STATE_SHUTDOWN, /**< Chip is in Shutdown state. */ 217 | SONY_DEMOD_STATE_SLEEP, /**< Chip is in Sleep state. */ 218 | SONY_DEMOD_STATE_ACTIVE, /**< Chip is in Active state. */ 219 | SONY_DEMOD_STATE_INVALID /**< Invalid, result of an error during a state change. */ 220 | }; 221 | struct sony_demod_ts_clk_configuration_t { 222 | u8 serialClkMode; /**< Serial clock mode (gated or continuous) */ 223 | u8 serialDutyMode; /**< Serial clock duty mode (full rate or half rate) */ 224 | u8 tsClkPeriod; /**< TS clock period */ 225 | u8 clkSelTSIf; /**< TS clock frequency (low, mid or high) */ 226 | }; 227 | struct sony_demod_iffreq_config_t { 228 | u32 configDVBT_5; /**< DVB-T 5MHz */ 229 | u32 configDVBT_6; /**< DVB-T 6MHz */ 230 | u32 configDVBT_7; /**< DVB-T 7MHz */ 231 | u32 configDVBT_8; /**< DVB-T 8MHz */ 232 | u32 configDVBT2_1_7; /**< DVB-T2 1.7MHz */ 233 | u32 configDVBT2_5; /**< DVB-T2 5MHz */ 234 | u32 configDVBT2_6; /**< DVB-T2 6MHz */ 235 | u32 configDVBT2_7; /**< DVB-T2 7MHz */ 236 | u32 configDVBT2_8; /**< DVB-T2 8MHz */ 237 | u32 configDVBC_6; /**< DVB-C 6MHz */ 238 | u32 configDVBC_7; /**< DVB-C 7MHz */ 239 | u32 configDVBC_8; /**< DVB-C 8MHz */ 240 | u32 configATSC; /**< ATSC 1.0 */ 241 | u32 configISDBT_6; /**< ISDB-T 6MHz */ 242 | u32 configISDBT_7; /**< ISDB-T 7MHz */ 243 | u32 configISDBT_8; /**< ISDB-T 8MHz */ 244 | u32 configJ83B_5_06_5_36; /**< J.83B 5.06/5.36Msps auto selection */ 245 | u32 configJ83B_5_60; /**< J.83B. 5.6Msps */ 246 | }; 247 | 248 | #endif 249 | -------------------------------------------------------------------------------- /default-channels.conf: -------------------------------------------------------------------------------- 1 | [defaultTS] 2 | DELIVERY_SYSTEM = ISDBS 3 | FREQUENCY = 1318000 4 | STREAM_ID = 16625 5 | 6 | [defaultTLV] 7 | DELIVERY_SYSTEM = ISDBS 8 | FREQUENCY = 1356360 9 | STREAM_ID = 45328 10 | -------------------------------------------------------------------------------- /tbsecp3-asi.c: -------------------------------------------------------------------------------- 1 | 2 | #include "tbsecp3.h" 3 | 4 | u8 asi_CheckFree(struct tbsecp3_dev *dev,int asi_base_addr, unsigned char OpbyteNum) 5 | { 6 | unsigned char tmpbuf[4]; 7 | int i; 8 | int j=500; 9 | if(OpbyteNum==2) 10 | j=400; 11 | else if(OpbyteNum==1) 12 | j=200; 13 | //pauseThread(OpbyteNum+1); 14 | 15 | tmpbuf[0] = 0; 16 | for(i=0;(i>8)&0xff; //read_address, msb first; 53 | tmpbuf[1] = (unsigned char)(reg_addr&0xff); 54 | tmpbuf[0] += 0x80; //read data; 55 | 56 | 57 | tbs_write( asi_base_addr, ASI_SPI_CMD, *(u32 *)&tmpbuf[0]); 58 | 59 | tmpbuf[0] = 0xf0; //cs low,cs high, write, read; 60 | tmpbuf[1] = 0x20; // 2 bytes command for writing; 61 | tmpbuf[1] += 0x02; //read 2 bytes data; 62 | tbs_write( asi_base_addr, ASI_SPI_CONFIG, *(u32 *)&tmpbuf[0]); 63 | 64 | if(asi_CheckFree(dev,asi_base_addr,2)== false) 65 | { 66 | printk(" spi_read16bit error!\n"); 67 | return false; 68 | } 69 | 70 | *(u32 *)tmpbuf = tbs_read(asi_base_addr, ASI_SPI_RD_32 ); 71 | 72 | regData = ((tmpbuf[0]<<8) | tmpbuf[1]); 73 | 74 | return regData; 75 | } 76 | 77 | bool asi_write16bit(struct tbsecp3_dev *dev,int asi_base_addr, int reg_addr, int data16bit) 78 | { 79 | unsigned char tmpbuf[4]; 80 | int regData; 81 | 82 | tmpbuf[0] = (unsigned char) (reg_addr>>8)&0xff; //read_address, msb first; 83 | tmpbuf[1] = (unsigned char)(reg_addr&0xff); 84 | 85 | tmpbuf[2] = (unsigned char) (data16bit>>8)&0xff; //read_address, msb first; 86 | tmpbuf[3] = (unsigned char)(data16bit&0xff); 87 | 88 | tbs_write( asi_base_addr, ASI_SPI_CMD, *(u32 *)&tmpbuf[0]); 89 | 90 | tmpbuf[0] = 0xe0; //cs low,cs high, write, no read; 91 | tmpbuf[1] = 0x40; // 4 bytes command for writing; 92 | tbs_write( asi_base_addr, ASI_SPI_CONFIG, *(u32 *)&tmpbuf[0]); 93 | 94 | if(asi_CheckFree(dev,asi_base_addr,2)== false) 95 | { 96 | printk(" spi_write16bit error!\n"); 97 | return false; 98 | } 99 | return true ; 100 | } 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /tbsecp3-ca.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | static int tbsecp3_ca_rd_attr_mem(struct dvb_ca_en50221 *ca, 21 | int slot, int address) 22 | { 23 | struct tbsecp3_ca *tbsca = ca->data; 24 | struct tbsecp3_adapter *adapter = tbsca->adapter; 25 | struct tbsecp3_dev *dev = adapter->dev; 26 | u32 data = 0; 27 | 28 | if (slot != 0) 29 | return -EINVAL; 30 | 31 | mutex_lock(&tbsca->lock); 32 | 33 | data |= (address >> 8) & 0x7f; 34 | data |= (address & 0xff) << 8; 35 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x00, data); 36 | udelay(150); 37 | 38 | data = tbs_read(TBSECP3_CA_BASE(tbsca->nr), 0x04); 39 | 40 | mutex_unlock(&tbsca->lock); 41 | 42 | return (data & 0xff); 43 | } 44 | 45 | static int tbsecp3_ca_wr_attr_mem(struct dvb_ca_en50221 *ca, 46 | int slot, int address, u8 value) 47 | { 48 | struct tbsecp3_ca *tbsca = ca->data; 49 | struct tbsecp3_adapter *adapter = 50 | (struct tbsecp3_adapter *) tbsca->adapter; 51 | struct tbsecp3_dev *dev = adapter->dev; 52 | u32 data = 0; 53 | 54 | if (slot != 0) 55 | return -EINVAL; 56 | 57 | mutex_lock(&tbsca->lock); 58 | 59 | data |= (address >> 8) & 0x7f; 60 | data |= (address & 0xff) << 8; 61 | data |= 0x01 << 16; 62 | data |= value << 24; 63 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x00, data); 64 | udelay(150); 65 | 66 | mutex_unlock(&tbsca->lock); 67 | 68 | return 0; 69 | } 70 | 71 | static int tbsecp3_ca_rd_cam_ctrl(struct dvb_ca_en50221 *ca, 72 | int slot, u8 address) 73 | { 74 | struct tbsecp3_ca *tbsca = ca->data; 75 | struct tbsecp3_adapter *adapter = 76 | (struct tbsecp3_adapter *) tbsca->adapter; 77 | struct tbsecp3_dev *dev = adapter->dev; 78 | u32 data = 0; 79 | 80 | if (slot != 0) 81 | return -EINVAL; 82 | 83 | mutex_lock(&tbsca->lock); 84 | 85 | data |= (address & 3) << 8; 86 | data |= 0x02 << 16; 87 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x00, data); 88 | udelay(150); 89 | 90 | data = tbs_read(TBSECP3_CA_BASE(tbsca->nr), 0x08); 91 | 92 | mutex_unlock(&tbsca->lock); 93 | 94 | return (data & 0xff); 95 | } 96 | 97 | static int tbsecp3_ca_wr_cam_ctrl(struct dvb_ca_en50221 *ca, int slot, 98 | u8 address, u8 value) 99 | { 100 | struct tbsecp3_ca *tbsca = ca->data; 101 | struct tbsecp3_adapter *adapter = 102 | (struct tbsecp3_adapter *) tbsca->adapter; 103 | struct tbsecp3_dev *dev = adapter->dev; 104 | u32 data = 0; 105 | 106 | if (slot != 0) 107 | return -EINVAL; 108 | 109 | mutex_lock(&tbsca->lock); 110 | 111 | data |= (address & 3) << 8; 112 | data |= 0x03 << 16; 113 | data |= value << 24; 114 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x00, data); 115 | udelay(150); 116 | 117 | mutex_unlock(&tbsca->lock); 118 | 119 | return 0; 120 | } 121 | 122 | static int tbsecp3_ca_slot_reset(struct dvb_ca_en50221 *ca, int slot) 123 | { 124 | struct tbsecp3_ca *tbsca = ca->data; 125 | struct tbsecp3_adapter *adapter = 126 | (struct tbsecp3_adapter *) tbsca->adapter; 127 | struct tbsecp3_dev *dev = adapter->dev; 128 | 129 | if (slot != 0) 130 | return -EINVAL; 131 | 132 | mutex_lock(&tbsca->lock); 133 | 134 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x04, 1); 135 | msleep (10); 136 | 137 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x04, 0); 138 | msleep (2800); 139 | 140 | mutex_unlock (&tbsca->lock); 141 | return 0; 142 | } 143 | 144 | static int tbsecp3_ca_slot_ctrl(struct dvb_ca_en50221 *ca, 145 | int slot, int enable) 146 | { 147 | struct tbsecp3_ca *tbsca = ca->data; 148 | struct tbsecp3_adapter *adapter = 149 | (struct tbsecp3_adapter *) tbsca->adapter; 150 | struct tbsecp3_dev *dev = adapter->dev; 151 | u32 data; 152 | 153 | if (slot != 0) 154 | return -EINVAL; 155 | 156 | mutex_lock(&tbsca->lock); 157 | 158 | data = enable & 1; 159 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x0c, data); 160 | 161 | mutex_unlock(&tbsca->lock); 162 | 163 | dev_info(&dev->pci_dev->dev, "CA slot %sabled for adapter%d\n", 164 | enable ? "en" : "dis", 165 | adapter->fe->dvb->num); 166 | 167 | return 0; 168 | } 169 | 170 | static int tbsecp3_ca_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) 171 | { 172 | return tbsecp3_ca_slot_ctrl(ca, slot, 0); 173 | } 174 | 175 | static int tbsecp3_ca_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) 176 | { 177 | return tbsecp3_ca_slot_ctrl(ca, slot, 1); 178 | } 179 | 180 | static int tbsecp3_ca_poll_slot_status(struct dvb_ca_en50221 *ca, 181 | int slot, int open) 182 | { 183 | struct tbsecp3_ca *tbsca = ca->data; 184 | struct tbsecp3_adapter *adapter = 185 | (struct tbsecp3_adapter *) tbsca->adapter; 186 | struct tbsecp3_dev *dev = adapter->dev; 187 | u32 data; 188 | int ret; 189 | 190 | if (slot != 0) 191 | return -EINVAL; 192 | 193 | mutex_lock(&tbsca->lock); 194 | data = tbs_read(TBSECP3_CA_BASE(tbsca->nr), 0x0c) & 1; 195 | if (tbsca->status != data){ 196 | tbs_write(TBSECP3_CA_BASE(tbsca->nr), 0x08, !data); 197 | msleep(300); 198 | tbsca->status = data; 199 | } 200 | mutex_unlock(&tbsca->lock); 201 | 202 | if (data & 1) 203 | ret = DVB_CA_EN50221_POLL_CAM_PRESENT | 204 | DVB_CA_EN50221_POLL_CAM_READY; 205 | else 206 | ret = 0; 207 | 208 | return ret; 209 | } 210 | 211 | 212 | struct dvb_ca_en50221 ca_config = { 213 | .read_attribute_mem = tbsecp3_ca_rd_attr_mem, 214 | .write_attribute_mem = tbsecp3_ca_wr_attr_mem, 215 | .read_cam_control = tbsecp3_ca_rd_cam_ctrl, 216 | .write_cam_control = tbsecp3_ca_wr_cam_ctrl, 217 | .slot_reset = tbsecp3_ca_slot_reset, 218 | .slot_shutdown = tbsecp3_ca_slot_shutdown, 219 | .slot_ts_enable = tbsecp3_ca_slot_ts_enable, 220 | .poll_slot_status = tbsecp3_ca_poll_slot_status, 221 | }; 222 | 223 | 224 | int tbsecp3_ca_init(struct tbsecp3_adapter *adap, int nr) 225 | { 226 | struct tbsecp3_dev *dev = adap->dev; 227 | struct tbsecp3_ca *tbsca; 228 | int ret; 229 | 230 | tbsca = kzalloc(sizeof(struct tbsecp3_ca), GFP_KERNEL); 231 | if (tbsca == NULL) { 232 | ret = -ENOMEM; 233 | goto error1; 234 | } 235 | 236 | adap->tbsca = tbsca; 237 | 238 | tbsca->nr = nr; 239 | tbsca->status = 0; 240 | tbsca->adapter = adap; 241 | mutex_init(&tbsca->lock); 242 | 243 | memcpy(&tbsca->ca, &ca_config, sizeof(struct dvb_ca_en50221)); 244 | tbsca->ca.owner = THIS_MODULE; 245 | tbsca->ca.data = tbsca; 246 | 247 | dev_info(&dev->pci_dev->dev, 248 | "initializing CA slot %d on adapter %d\n", 249 | nr, adap->dvb_adapter.num); 250 | 251 | ret = dvb_ca_en50221_init(&adap->dvb_adapter, &tbsca->ca, 0, 1); 252 | if (ret) 253 | goto error2; 254 | 255 | return 0; 256 | 257 | error2: 258 | kfree(tbsca); 259 | error1: 260 | dev_err(&dev->pci_dev->dev, 261 | "adapter %d CA slot initialization failed\n", 262 | adap->dvb_adapter.num); 263 | return ret; 264 | } 265 | 266 | void tbsecp3_ca_release(struct tbsecp3_adapter *adap) 267 | { 268 | struct tbsecp3_ca *tbsca = adap->tbsca; 269 | if (!adap) 270 | return; 271 | if (!tbsca) 272 | return; 273 | if (!tbsca->ca.data) 274 | return; 275 | dvb_ca_en50221_release(&tbsca->ca); 276 | kfree(tbsca); 277 | } 278 | 279 | -------------------------------------------------------------------------------- /tbsecp3-cards.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | struct tbsecp3_board tbsecp3_boards[] = { 21 | #ifdef TBS_DVB_EXTENSION 22 | [TBSECP3_BOARD_TBS6916] = { 23 | .board_id = TBSECP3_BOARD_TBS6916, 24 | .name = "TurboSight TBS 6916 (Octa DVB-S/S2/S2X)", 25 | .adapters = 16, 26 | .i2c_speed = 39, 27 | .eeprom_i2c = 1, 28 | .eeprom_addr = 0x02, 29 | .adap_config = { 30 | { 31 | .ts_in = 0, 32 | .i2c_bus_nr = 0, 33 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 34 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 35 | }, 36 | { 37 | .ts_in = 1, 38 | .i2c_bus_nr = 0, 39 | }, 40 | { 41 | .ts_in = 2, 42 | .i2c_bus_nr = 0, 43 | }, 44 | { 45 | .ts_in = 3, 46 | .i2c_bus_nr = 0, 47 | }, 48 | { 49 | .ts_in = 4, 50 | .i2c_bus_nr = 0, 51 | }, 52 | { 53 | .ts_in = 5, 54 | .i2c_bus_nr = 0, 55 | }, 56 | { 57 | .ts_in = 6, 58 | .i2c_bus_nr = 0, 59 | }, 60 | { 61 | .ts_in = 7, 62 | .i2c_bus_nr = 0, 63 | }, 64 | { 65 | .ts_in = 8, 66 | .i2c_bus_nr = 1, 67 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 68 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 69 | }, 70 | { 71 | .ts_in = 9, 72 | .i2c_bus_nr = 1, 73 | }, 74 | { 75 | .ts_in = 10, 76 | .i2c_bus_nr = 1, 77 | }, 78 | { 79 | .ts_in = 11, 80 | .i2c_bus_nr = 1, 81 | }, 82 | { 83 | .ts_in = 12, 84 | .i2c_bus_nr = 1, 85 | }, 86 | { 87 | .ts_in = 13, 88 | .i2c_bus_nr = 1, 89 | }, 90 | { 91 | .ts_in = 14, 92 | .i2c_bus_nr = 1, 93 | }, 94 | { 95 | .ts_in = 15, 96 | .i2c_bus_nr = 1, 97 | } 98 | 99 | } 100 | }, 101 | [TBSECP3_BOARD_TBS6590SE] = { 102 | .board_id = TBSECP3_BOARD_TBS6590SE, 103 | .name = "TurboSight TBS 6590SE DVB-S/S2/S2X/T/T2/C/C2 + 2xCI ", 104 | .adapters = 2, 105 | .i2c_speed = 39, 106 | .eeprom_i2c = 0, 107 | .eeprom_addr = 0x10, 108 | .adap_config = { 109 | { 110 | .ts_in = 0, 111 | .i2c_bus_nr = 0, 112 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 113 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 114 | 115 | }, 116 | { 117 | .ts_in = 1, 118 | .i2c_bus_nr = 1, 119 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 120 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 121 | 122 | }, 123 | } 124 | }, 125 | [TBSECP3_BOARD_TBS6504H] = { 126 | .board_id = TBSECP3_BOARD_TBS6504H, 127 | .name = "TurboSight TBS 6504H Quad DVBS/S2x + Quad DVB-T/T2/C ISDB-T/C ATSC1.0", 128 | .i2c_speed = 39, 129 | .eeprom_i2c = 3, 130 | .eeprom_addr = 0x10, 131 | .adapters = 8, 132 | .adap_config = { 133 | { 134 | .ts_in = 0, 135 | .i2c_bus_nr = 0, 136 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 137 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 138 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 139 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 140 | }, 141 | { 142 | .ts_in = 1, 143 | .i2c_bus_nr = 0, 144 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 145 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 146 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 147 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 148 | }, 149 | { 150 | .ts_in = 2, 151 | .i2c_bus_nr = 1, 152 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 153 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 154 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 155 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 156 | }, 157 | { 158 | .ts_in = 3, 159 | .i2c_bus_nr = 1, 160 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 161 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 162 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 163 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 164 | }, 165 | { 166 | .ts_in = 4, 167 | .i2c_bus_nr = 2, 168 | 169 | }, 170 | { 171 | .ts_in = 5, 172 | .i2c_bus_nr = 2, 173 | }, 174 | { 175 | .ts_in = 6, 176 | .i2c_bus_nr = 3, 177 | }, 178 | { 179 | .ts_in = 7, 180 | .i2c_bus_nr = 3, 181 | }, 182 | } 183 | }, 184 | [TBSECP3_BOARD_TBS6522H] = { 185 | .board_id = TBSECP3_BOARD_TBS6522H, 186 | .name = "TurboSight TBS 6522H Dual DVBS/S2x + Dual DVB-T/T2/C ISDB-T/C ATSC1.0", 187 | .i2c_speed = 39, 188 | .eeprom_i2c = 3, 189 | .eeprom_addr = 0x10, 190 | .adapters = 4, 191 | .adap_config = { 192 | { 193 | .ts_in = 0, 194 | .i2c_bus_nr = 0, 195 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 196 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 197 | }, 198 | { 199 | .ts_in = 1, 200 | .i2c_bus_nr = 1, 201 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 202 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 203 | }, 204 | { 205 | .ts_in = 2, 206 | .i2c_bus_nr = 2, 207 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 208 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 209 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 210 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 211 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 212 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 213 | }, 214 | { 215 | .ts_in = 3, 216 | .i2c_bus_nr = 3, 217 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 218 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 219 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 220 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 221 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 222 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 223 | } 224 | } 225 | }, 226 | [TBSECP3_BOARD_TBS6909SE] = { 227 | .board_id = TBSECP3_BOARD_TBS6909SE, 228 | .name = "Turbosight TBS 6909SE(Octa DVB-S/S2/S2x)", 229 | .i2c_speed = 39, 230 | .eeprom_i2c = 3, 231 | .eeprom_addr = 0x10, 232 | .adapters = 8, 233 | .adap_config ={ 234 | { 235 | .ts_in = 0, 236 | .i2c_bus_nr = 0, 237 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 238 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 239 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 240 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 241 | }, 242 | { 243 | .ts_in = 1, 244 | .i2c_bus_nr = 0, 245 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 246 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 247 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 248 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 249 | }, 250 | { 251 | .ts_in = 2, 252 | .i2c_bus_nr = 1, 253 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 254 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 255 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 256 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 257 | }, 258 | { 259 | .ts_in = 3, 260 | .i2c_bus_nr = 1, 261 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 262 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 263 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 264 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 265 | }, 266 | { 267 | .ts_in = 4, 268 | .i2c_bus_nr = 2, 269 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 270 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 271 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 272 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 273 | }, 274 | { 275 | .ts_in = 5, 276 | .i2c_bus_nr = 2, 277 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 278 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 279 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 280 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 281 | }, 282 | { 283 | .ts_in = 6, 284 | .i2c_bus_nr = 3, 285 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 286 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 287 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 288 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 289 | 290 | }, 291 | { 292 | .ts_in = 7, 293 | .i2c_bus_nr = 3, 294 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_HIGH, 295 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 296 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 297 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 298 | } 299 | 300 | } 301 | }, 302 | [TBSECP3_BOARD_TBS6281TD] = { 303 | .board_id = TBSECP3_BOARD_TBS6281TD, 304 | .name = "TurboSight TBS 6281TD DVB-T/T2/C ISDB-T/C ATSC1.0", 305 | .i2c_speed = 39, 306 | .eeprom_i2c = 0, 307 | .eeprom_addr = 0x10, 308 | .adapters = 2, 309 | .adap_config = { 310 | { 311 | .ts_in = 0, 312 | .i2c_bus_nr = 0, 313 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 314 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 315 | }, 316 | { 317 | .ts_in = 1, 318 | .i2c_bus_nr = 1, 319 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 320 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 321 | }, 322 | } 323 | }, 324 | [TBSECP3_BOARD_TBS6205SE] = { 325 | .board_id = TBSECP3_BOARD_TBS6205SE, 326 | .name = "TurboSight TBS 6205SE DVB-T/T2/C ISDB-T/C ATSC1.0", 327 | .i2c_speed = 39, 328 | .eeprom_i2c = 2, 329 | .eeprom_addr = 0x10, 330 | .adapters = 4, 331 | .adap_config = { 332 | { 333 | .ts_in = 0, 334 | .i2c_bus_nr = 0, 335 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 336 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 337 | }, 338 | { 339 | .ts_in = 1, 340 | .i2c_bus_nr = 1, 341 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 342 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 343 | }, 344 | { 345 | .ts_in = 2, 346 | .i2c_bus_nr = 2, 347 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 348 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 349 | }, 350 | { 351 | .ts_in = 3, 352 | .i2c_bus_nr = 3, 353 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 354 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 355 | } 356 | } 357 | }, 358 | [TBSECP3_BOARD_TBS6290TD] = { 359 | .board_id = TBSECP3_BOARD_TBS6290TD, 360 | .name = "TurboSight TBS 6290SE DVB-T/T2/C + 2xCI ", 361 | .i2c_speed = 39, 362 | .eeprom_i2c = 1, 363 | .adapters = 2, 364 | .adap_config = { 365 | { 366 | .ts_in = 0, 367 | .i2c_bus_nr = 0, 368 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 369 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 370 | 371 | }, 372 | { 373 | .ts_in = 1, 374 | .i2c_bus_nr = 1, 375 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 376 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 377 | 378 | }, 379 | } 380 | }, 381 | [TBSECP3_BOARD_TBS7230] = { 382 | .board_id = TBSECP3_BOARD_TBS7230, 383 | .name = "Turbosight TBS 7230(Octa DVB-T/T2/C/C2/ISDB-T/C/ATSC)", 384 | .i2c_speed = 39, 385 | .eeprom_i2c = 0, 386 | .eeprom_addr = 0x10, 387 | .adapters = 1, 388 | .adap_config ={ 389 | { 390 | .ts_in = 0, 391 | .i2c_bus_nr = 0, 392 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 393 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 394 | }, 395 | 396 | } 397 | }, 398 | [TBSECP3_BOARD_TBS6209SE] = { 399 | .board_id = TBSECP3_BOARD_TBS6209SE, 400 | .name = "Turbosight TBS 6209SE(Octa DVB-T/T2/C/C2/ISDB-T/C/ATSC)", 401 | .i2c_speed = 39, 402 | .eeprom_i2c = 3, 403 | .eeprom_addr = 0x10, 404 | .adapters = 8, 405 | .adap_config ={ 406 | { 407 | .ts_in = 0, 408 | .i2c_bus_nr = 0, 409 | }, 410 | { 411 | .ts_in = 1, 412 | .i2c_bus_nr = 0, 413 | }, 414 | { 415 | .ts_in = 2, 416 | .i2c_bus_nr = 1, 417 | }, 418 | { 419 | .ts_in = 3, 420 | .i2c_bus_nr = 1, 421 | }, 422 | { 423 | .ts_in = 4, 424 | .i2c_bus_nr = 2, 425 | 426 | }, 427 | { 428 | .ts_in = 5, 429 | .i2c_bus_nr = 2, 430 | }, 431 | { 432 | .ts_in = 6, 433 | .i2c_bus_nr = 3, 434 | 435 | }, 436 | { 437 | .ts_in = 7, 438 | .i2c_bus_nr = 3, 439 | } 440 | 441 | } 442 | }, 443 | [TBSECP3_BOARD_TBS7901] = { 444 | .board_id = TBSECP3_BOARD_TBS7901, 445 | .name = "TurboSight TBS 7901 DVB-S/S2/S2x ", 446 | .adapters = 1, 447 | .i2c_speed = 39, 448 | .eeprom_i2c = 0, 449 | .eeprom_addr = 0x10, 450 | .adap_config = { 451 | { 452 | .ts_in = 0, 453 | .i2c_bus_nr = 0, 454 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 455 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 456 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 457 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 458 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 459 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0,1), 460 | } 461 | 462 | } 463 | }, 464 | 465 | [TBSECP3_BOARD_TBS6910SE] = { 466 | .board_id = TBSECP3_BOARD_TBS6910SE, 467 | .name = "TurboSight TBS 6910SE DVB-S/S2/S2x + 2xCI ", 468 | .adapters = 2, 469 | .i2c_speed = 39, 470 | .eeprom_i2c = 1, 471 | .eeprom_addr = 0x10, 472 | .adap_config = { 473 | { 474 | .ts_in = 0, 475 | .i2c_bus_nr = 0, 476 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 477 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 478 | }, 479 | { 480 | .ts_in = 1, 481 | .i2c_bus_nr = 1, 482 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 483 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 484 | }, 485 | } 486 | }, 487 | [TBSECP3_BOARD_TBS6902SE] = { 488 | .board_id = TBSECP3_BOARD_TBS6902SE, 489 | .name = "TurboSight TBS 6902SE DVB-S/S2/S2x ", 490 | .adapters = 2, 491 | .i2c_speed = 39, 492 | .eeprom_i2c = 1, 493 | .eeprom_addr = 0x10, 494 | .adap_config = { 495 | { 496 | .ts_in = 0, 497 | .i2c_bus_nr = 0, 498 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 499 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 500 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 501 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 502 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 503 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 504 | }, 505 | { 506 | .ts_in = 1, 507 | .i2c_bus_nr = 1, 508 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 509 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 510 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 511 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 512 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 513 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 514 | } 515 | 516 | } 517 | }, 518 | 519 | [TBSECP3_BOARD_TBS6904SE] = { 520 | .board_id = TBSECP3_BOARD_TBS6904SE, 521 | .name = "TurboSight TBS 6904se DVB-S/S2/S2x ", 522 | .adapters = 4, 523 | .i2c_speed = 39, 524 | .eeprom_i2c = 3, 525 | .adap_config = { 526 | { 527 | .ts_in = 0, 528 | .i2c_bus_nr = 0, 529 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 530 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 531 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 532 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 533 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 534 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 535 | }, 536 | { 537 | .ts_in = 1, 538 | .i2c_bus_nr = 1, 539 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 540 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 541 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 542 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 543 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 544 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 545 | }, 546 | { 547 | .ts_in = 2, 548 | .i2c_bus_nr = 2, 549 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 550 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 551 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 552 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 553 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 554 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 555 | }, 556 | { 557 | .ts_in = 3, 558 | .i2c_bus_nr = 3, 559 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 560 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 561 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 562 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 563 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 564 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 565 | }, 566 | } 567 | }, 568 | [TBSECP3_BOARD_TBS6508] = { 569 | .board_id = TBSECP3_BOARD_TBS6508, 570 | .name = "TurboSight TBS 6508 DVB-S/S2/S2X/T/T2/C(QAM-A/B/C)/C2/ISDB-T ", 571 | .adapters = 8, 572 | .i2c_speed = 39, 573 | .eeprom_i2c = 3, 574 | .eeprom_addr = 0x10, 575 | .adap_config = { 576 | { 577 | .ts_in = 4, 578 | .i2c_bus_nr = 2, 579 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 580 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 581 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 582 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 583 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 584 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 585 | }, 586 | { 587 | .ts_in = 5, 588 | .i2c_bus_nr = 2, 589 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 590 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 591 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 592 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 593 | }, 594 | { 595 | .ts_in = 0, 596 | .i2c_bus_nr = 0, 597 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 598 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 599 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 600 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 601 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 602 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 603 | }, 604 | { 605 | .ts_in = 1, 606 | .i2c_bus_nr = 0, 607 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 608 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 609 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 610 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 611 | }, 612 | { 613 | .ts_in = 2, 614 | .i2c_bus_nr = 1, 615 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 616 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 617 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 618 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 619 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 620 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 621 | }, 622 | { 623 | .ts_in = 3, 624 | .i2c_bus_nr = 1, 625 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 626 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 627 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 628 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 629 | }, 630 | { 631 | .ts_in = 6, 632 | .i2c_bus_nr = 3, 633 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 634 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 635 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 636 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 637 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 638 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 639 | }, 640 | { 641 | .ts_in = 7, 642 | .i2c_bus_nr = 3, 643 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 644 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 645 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 646 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 647 | }, 648 | } 649 | }, 650 | 651 | [TBSECP3_BOARD_TBS6504] = { 652 | .board_id = TBSECP3_BOARD_TBS6504, 653 | .name = "TurboSight TBS 6504 DVB-S/S2/S2X/T/T2/C/C2/ISDB-T ", 654 | .adapters = 4, 655 | .i2c_speed = 39, 656 | .eeprom_i2c = 0, 657 | .adap_config = { 658 | { 659 | .ts_in = 3, 660 | .i2c_bus_nr = 1, 661 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 662 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 663 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 664 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 665 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 666 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 667 | }, 668 | { 669 | .ts_in = 2, 670 | .i2c_bus_nr = 1, 671 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 672 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 673 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 674 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 675 | }, 676 | { 677 | .ts_in = 1, 678 | .i2c_bus_nr = 0, 679 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 680 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 681 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 682 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 683 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 684 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 685 | }, 686 | { 687 | .ts_in = 0, 688 | .i2c_bus_nr = 0, 689 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 690 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 691 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 692 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 693 | }, 694 | } 695 | }, 696 | 697 | [TBSECP3_BOARD_TBS6904X] = { 698 | .board_id = TBSECP3_BOARD_TBS6904X, 699 | .name = "TurboSight TBS 6904x DVB-S/S2/S2X ", 700 | .adapters = 4, 701 | .i2c_speed = 39, 702 | .eeprom_i2c = 0, 703 | .eeprom_addr = 0x10, 704 | .adap_config = { 705 | { 706 | .ts_in = 3, 707 | .i2c_bus_nr = 1, 708 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 709 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 710 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 711 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 712 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 713 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 714 | }, 715 | { 716 | .ts_in = 2, 717 | .i2c_bus_nr = 1, 718 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 719 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 720 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 721 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 722 | }, 723 | { 724 | .ts_in = 1, 725 | .i2c_bus_nr = 0, 726 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 727 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 728 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 729 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 730 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 731 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 732 | }, 733 | { 734 | .ts_in = 0, 735 | .i2c_bus_nr = 0, 736 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 737 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 738 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 739 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 740 | }, 741 | 742 | } 743 | }, 744 | // added by lucy on 06012020 745 | [TBSECP3_BOARD_TBS6302SE] = { 746 | .board_id = TBSECP3_BOARD_TBS6302SE, 747 | .name = "TurboSight TBS 6302se HDMI Capture ", 748 | .adapters = 2, 749 | .i2c_speed = 39, 750 | .eeprom_i2c = 0, 751 | .adap_config = { 752 | { 753 | .ts_in = 1, 754 | .i2c_bus_nr = 2, 755 | }, 756 | { 757 | .ts_in = 3, 758 | .i2c_bus_nr = 0, 759 | }, 760 | 761 | } 762 | }, 763 | [TBSECP3_BOARD_TBS6308] = { 764 | .board_id = TBSECP3_BOARD_TBS6308, 765 | .name = "TurboSight TBS 6304 HDMI Capture", 766 | .adapters = 4, 767 | .i2c_speed = 39, 768 | .eeprom_i2c = 0, 769 | .adap_config = { 770 | { 771 | .ts_in = 0, 772 | .i2c_bus_nr = 0, 773 | }, 774 | { 775 | .ts_in = 1, 776 | .i2c_bus_nr = 0, 777 | }, 778 | { 779 | .ts_in = 2, 780 | .i2c_bus_nr = 0, 781 | }, 782 | { 783 | .ts_in = 3, 784 | .i2c_bus_nr = 0, 785 | }, 786 | { 787 | .ts_in = 4, 788 | .i2c_bus_nr = 0, 789 | }, 790 | { 791 | .ts_in = 5, 792 | .i2c_bus_nr = 0, 793 | }, 794 | { 795 | .ts_in = 6, 796 | .i2c_bus_nr = 0, 797 | }, 798 | { 799 | .ts_in = 7, 800 | .i2c_bus_nr = 0, 801 | 802 | } 803 | } 804 | }, 805 | [TBSECP3_BOARD_TBS6308X] = { 806 | .board_id = TBSECP3_BOARD_TBS6308X, 807 | .name = "TurboSight TBS 6308X 4K@30FPS HDMI PCIe Encoder", 808 | .adapters = 8, 809 | .i2c_speed = 39, 810 | .eeprom_i2c = 1, 811 | .eeprom_addr = 0x10, 812 | .adap_config = { 813 | { 814 | .ts_in = 0, 815 | .i2c_bus_nr = 0, 816 | }, 817 | { 818 | .ts_in = 1, 819 | .i2c_bus_nr = 0, 820 | }, 821 | { 822 | .ts_in = 2, 823 | .i2c_bus_nr = 0, 824 | }, 825 | { 826 | .ts_in = 3, 827 | .i2c_bus_nr = 0, 828 | }, 829 | { 830 | .ts_in = 4, 831 | .i2c_bus_nr = 0, 832 | }, 833 | { 834 | .ts_in = 5, 835 | .i2c_bus_nr = 0, 836 | }, 837 | { 838 | .ts_in = 6, 839 | .i2c_bus_nr = 0, 840 | }, 841 | { 842 | .ts_in = 7, 843 | .i2c_bus_nr = 0, 844 | 845 | } 846 | } 847 | }, 848 | [TBSECP3_BOARD_TBS6312X] = { 849 | .board_id = TBSECP3_BOARD_TBS6312X, 850 | .name = "TurboSight TBS 6312X 4K@30FPS HDMI PCIe Encoder", 851 | .adapters = 12, 852 | .i2c_speed = 39, 853 | .eeprom_i2c = 1, 854 | .eeprom_addr = 0x10, 855 | .adap_config = { 856 | { 857 | .ts_in = 0, 858 | .i2c_bus_nr = 0, 859 | }, 860 | { 861 | .ts_in = 1, 862 | .i2c_bus_nr = 0, 863 | }, 864 | { 865 | .ts_in = 2, 866 | .i2c_bus_nr = 0, 867 | }, 868 | { 869 | .ts_in = 3, 870 | .i2c_bus_nr = 0, 871 | }, 872 | { 873 | .ts_in = 4, 874 | .i2c_bus_nr = 0, 875 | }, 876 | { 877 | .ts_in = 5, 878 | .i2c_bus_nr = 0, 879 | }, 880 | { 881 | .ts_in = 6, 882 | .i2c_bus_nr = 0, 883 | }, 884 | { 885 | .ts_in = 7, 886 | .i2c_bus_nr = 0, 887 | 888 | }, 889 | { 890 | .ts_in = 8, 891 | .i2c_bus_nr = 0, 892 | 893 | }, 894 | { 895 | .ts_in = 9, 896 | .i2c_bus_nr = 0, 897 | 898 | }, 899 | { 900 | .ts_in = 10, 901 | .i2c_bus_nr = 0, 902 | 903 | }, 904 | { 905 | .ts_in = 11, 906 | .i2c_bus_nr = 0, 907 | 908 | } 909 | } 910 | }, 911 | // added by pzw in 2017,12,12 912 | [TBSECP3_BOARD_TBS6304] = { 913 | .board_id = TBSECP3_BOARD_TBS6304, 914 | .name = "TurboSight TBS 6304 HDMI Capture ", 915 | .adapters = 4, 916 | .i2c_speed = 39, 917 | .eeprom_i2c = 0, 918 | .adap_config = { 919 | { 920 | .ts_in = 0, 921 | .i2c_bus_nr = 3, 922 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 923 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 924 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 925 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 926 | }, 927 | { 928 | .ts_in = 1, 929 | .i2c_bus_nr = 2, 930 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 931 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 932 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 933 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 934 | }, 935 | { 936 | .ts_in = 2, 937 | .i2c_bus_nr = 1, 938 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 939 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 940 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 941 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 942 | }, 943 | { 944 | .ts_in = 3, 945 | .i2c_bus_nr = 0, 946 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 947 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 948 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 949 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 950 | }, 951 | 952 | } 953 | }, 954 | [TBSECP3_BOARD_TBS6301] = { 955 | .board_id = TBSECP3_BOARD_TBS6301, 956 | .name = "TurboSight TBS 6301 HDMI Capture ", 957 | .adapters = 1, 958 | .i2c_speed = 39, 959 | .eeprom_i2c = 0, 960 | .adap_config = { 961 | { 962 | .ts_in = 0, 963 | .i2c_bus_nr = 3, 964 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 965 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 966 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 967 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 968 | }, 969 | 970 | } 971 | }, 972 | [TBSECP3_BOARD_TBS6301SE] = { 973 | .board_id = TBSECP3_BOARD_TBS6301SE, 974 | .name = "TurboSight TBS 6301T HDMI Capture ", 975 | .adapters = 1, 976 | .i2c_speed = 39, 977 | .eeprom_i2c = 1, 978 | .adap_config = { 979 | { 980 | .ts_in = 0, 981 | .i2c_bus_nr = 3, 982 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 983 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 984 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 985 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 986 | }, 987 | 988 | } 989 | }, 990 | [TBSECP3_BOARD_TBS6302X] = { 991 | .board_id = TBSECP3_BOARD_TBS6302X, 992 | .name = "TurboSight TBS 6302X 4K@30FPS HDMI PCIe Encoder ", 993 | .adapters = 2, 994 | .i2c_speed = 39, 995 | .eeprom_i2c = 1, 996 | .adap_config = { 997 | { 998 | .ts_in = 0, 999 | .i2c_bus_nr = 3, 1000 | }, 1001 | { 1002 | .ts_in = 1, 1003 | .i2c_bus_nr = 2, 1004 | }, 1005 | } 1006 | }, 1007 | [TBSECP3_BOARD_TBS6302T] = { 1008 | .board_id = TBSECP3_BOARD_TBS6302T, 1009 | .name = "TurboSight TBS 6302T HDMI Capture ", 1010 | .adapters = 2, 1011 | .i2c_speed = 39, 1012 | .eeprom_i2c = 1, 1013 | .adap_config = { 1014 | { 1015 | .ts_in = 0, 1016 | .i2c_bus_nr = 3, 1017 | }, 1018 | { 1019 | .ts_in = 1, 1020 | .i2c_bus_nr = 2, 1021 | }, 1022 | } 1023 | }, 1024 | [TBSECP3_BOARD_TBS6304X] = { 1025 | .board_id = TBSECP3_BOARD_TBS6304X, 1026 | .name = "TurboSight TBS 6304X 4K@30FPS HDMI PCIe Encoder ", 1027 | .adapters = 4, 1028 | .i2c_speed = 39, 1029 | .eeprom_i2c = 1, 1030 | .adap_config = { 1031 | { 1032 | .ts_in = 0, 1033 | .i2c_bus_nr = 3, 1034 | }, 1035 | { 1036 | .ts_in = 1, 1037 | .i2c_bus_nr = 2, 1038 | }, 1039 | { 1040 | .ts_in = 2, 1041 | .i2c_bus_nr = 1, 1042 | }, 1043 | { 1044 | .ts_in = 3, 1045 | .i2c_bus_nr = 0, 1046 | }, 1047 | } 1048 | }, 1049 | [TBSECP3_BOARD_TBS6304T] = { 1050 | .board_id = TBSECP3_BOARD_TBS6304T, 1051 | .name = "TurboSight TBS 6304T HDMI Capture ", 1052 | .adapters = 4, 1053 | .i2c_speed = 39, 1054 | .eeprom_i2c = 1, 1055 | .adap_config = { 1056 | { 1057 | .ts_in = 0, 1058 | .i2c_bus_nr = 3, 1059 | }, 1060 | { 1061 | .ts_in = 1, 1062 | .i2c_bus_nr = 2, 1063 | }, 1064 | { 1065 | .ts_in = 2, 1066 | .i2c_bus_nr = 1, 1067 | }, 1068 | { 1069 | .ts_in = 3, 1070 | .i2c_bus_nr = 0, 1071 | }, 1072 | } 1073 | }, 1074 | [TBSECP3_BOARD_TBS6324] = { 1075 | .board_id = TBSECP3_BOARD_TBS6324, 1076 | .name = "TurboSight TBS 6324 3G-SDI PCIe Encoder ", 1077 | .adapters = 4, 1078 | .i2c_speed = 39, 1079 | .eeprom_i2c = 1, 1080 | .adap_config = { 1081 | { 1082 | .ts_in = 0, 1083 | .i2c_bus_nr = 3, 1084 | }, 1085 | { 1086 | .ts_in = 1, 1087 | .i2c_bus_nr = 2, 1088 | }, 1089 | { 1090 | .ts_in = 2, 1091 | .i2c_bus_nr = 1, 1092 | }, 1093 | { 1094 | .ts_in = 3, 1095 | .i2c_bus_nr = 0, 1096 | }, 1097 | } 1098 | }, 1099 | [TBSECP3_BOARD_TBS6322] = { 1100 | .board_id = TBSECP3_BOARD_TBS6322, 1101 | .name = "TurboSight TBS 6322 3G-SDI PCIe Encoder ", 1102 | .adapters = 2, 1103 | .i2c_speed = 39, 1104 | .eeprom_i2c = 1, 1105 | .adap_config = { 1106 | { 1107 | .ts_in = 0, 1108 | .i2c_bus_nr = 3, 1109 | }, 1110 | { 1111 | .ts_in = 1, 1112 | .i2c_bus_nr = 2, 1113 | }, 1114 | } 1115 | }, 1116 | [TBSECP3_BOARD_TBS690a] = { 1117 | .board_id = TBSECP3_BOARD_TBS690a, 1118 | .name = "TurboSight TBS 690a ASI Capture ", 1119 | .adapters = 4, 1120 | .i2c_speed = 39, 1121 | .eeprom_i2c = 1, 1122 | .adap_config = { 1123 | { 1124 | .ts_in = 0, 1125 | .i2c_bus_nr = 3, 1126 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1127 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1128 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1129 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 1130 | }, 1131 | { 1132 | .ts_in = 1, 1133 | .i2c_bus_nr = 2, 1134 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1135 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1136 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1137 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 1138 | }, 1139 | { 1140 | .ts_in = 2, 1141 | .i2c_bus_nr = 1, 1142 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1143 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1144 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1145 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1146 | }, 1147 | { 1148 | .ts_in = 3, 1149 | .i2c_bus_nr = 0, 1150 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1151 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1152 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1153 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1154 | }, 1155 | } 1156 | }, 1157 | [TBSECP3_BOARD_TBS6514] = { 1158 | .board_id = TBSECP3_BOARD_TBS6514, 1159 | .name = "Turbosight TBS 6514 (Quad DTMB)", 1160 | .i2c_speed = 39, 1161 | .eeprom_i2c = 1, 1162 | .adapters = 4, 1163 | .adap_config ={ 1164 | 1165 | { 1166 | .ts_in = 0, 1167 | .i2c_bus_nr = 0, 1168 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1169 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1170 | }, 1171 | { 1172 | .ts_in = 1, 1173 | .i2c_bus_nr = 1, 1174 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1175 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1176 | }, 1177 | { 1178 | .ts_in = 2, 1179 | .i2c_bus_nr = 2, 1180 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1181 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1182 | }, 1183 | { 1184 | .ts_in = 3, 1185 | .i2c_bus_nr = 3, 1186 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1187 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1188 | } 1189 | }, 1190 | }, 1191 | 1192 | [TBSECP3_BOARD_TBS6814] = { 1193 | .board_id = TBSECP3_BOARD_TBS6814, 1194 | .name = "Turbosight TBS 6814 (Quad ISDB-T)", 1195 | .i2c_speed = 39, 1196 | .eeprom_i2c = 1, 1197 | .adapters = 4, 1198 | .adap_config ={ 1199 | 1200 | { 1201 | .ts_in = 0, 1202 | .i2c_bus_nr = 0, 1203 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1204 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1205 | }, 1206 | { 1207 | .ts_in = 1, 1208 | .i2c_bus_nr = 1, 1209 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1210 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1211 | }, 1212 | { 1213 | .ts_in = 2, 1214 | .i2c_bus_nr = 2, 1215 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1216 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1217 | }, 1218 | { 1219 | .ts_in = 3, 1220 | .i2c_bus_nr = 3, 1221 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1222 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1223 | } 1224 | }, 1225 | }, 1226 | [TBSECP3_BOARD_TBS6209] = { 1227 | .board_id = TBSECP3_BOARD_TBS6209, 1228 | .name = "Turbosight TBS 6209 (Octa DVB-T/T2/C/C2/ISDB-T)", 1229 | .i2c_speed = 39, 1230 | .eeprom_i2c = 0, 1231 | .eeprom_addr = 0x10, 1232 | .adapters = 8, 1233 | .adap_config ={ 1234 | { 1235 | .ts_in = 0, 1236 | .i2c_bus_nr = 0, 1237 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1238 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1239 | }, 1240 | { 1241 | .ts_in = 1, 1242 | .i2c_bus_nr = 0, 1243 | }, 1244 | { 1245 | .ts_in = 2, 1246 | .i2c_bus_nr = 1, 1247 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1248 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1249 | }, 1250 | { 1251 | .ts_in = 3, 1252 | .i2c_bus_nr = 1, 1253 | }, 1254 | { 1255 | .ts_in = 4, 1256 | .i2c_bus_nr = 2, 1257 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1258 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1259 | 1260 | }, 1261 | { 1262 | .ts_in = 5, 1263 | .i2c_bus_nr = 2, 1264 | }, 1265 | { 1266 | .ts_in = 6, 1267 | .i2c_bus_nr = 3, 1268 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1269 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1270 | 1271 | }, 1272 | { 1273 | .ts_in = 7, 1274 | .i2c_bus_nr = 3, 1275 | } 1276 | 1277 | } 1278 | }, 1279 | [TBSECP3_BOARD_TBS6704] = { 1280 | .board_id = TBSECP3_BOARD_TBS6704, 1281 | .name = "TurboSight TBS 6704(Quad ATSC/QAMB)", 1282 | .i2c_speed = 39, 1283 | .eeprom_i2c = 1, 1284 | .adapters = 4, 1285 | .adap_config = { 1286 | { 1287 | .ts_in = 0, 1288 | .i2c_bus_nr = 0, 1289 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1290 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1291 | }, 1292 | { 1293 | .ts_in = 1, 1294 | .i2c_bus_nr = 1, 1295 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1296 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1297 | }, 1298 | { 1299 | .ts_in = 2, 1300 | .i2c_bus_nr = 2, 1301 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1302 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1303 | }, 1304 | { 1305 | .ts_in = 3, 1306 | .i2c_bus_nr = 3, 1307 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1308 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1309 | } 1310 | } 1311 | }, 1312 | 1313 | [TBSECP3_BOARD_TBS6205] = { 1314 | .board_id = TBSECP3_BOARD_TBS6205, 1315 | .name = "TurboSight TBS 6205 DVB-T/T2/C ", 1316 | .i2c_speed = 39, 1317 | .eeprom_i2c = 1, 1318 | .eeprom_addr = 0xa0, 1319 | .adapters = 4, 1320 | .adap_config = { 1321 | { 1322 | .ts_in = 0, 1323 | .i2c_bus_nr = 0, 1324 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1325 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1326 | }, 1327 | { 1328 | .ts_in = 1, 1329 | .i2c_bus_nr = 1, 1330 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1331 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1332 | }, 1333 | { 1334 | .ts_in = 2, 1335 | .i2c_bus_nr = 2, 1336 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1337 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1338 | }, 1339 | { 1340 | .ts_in = 3, 1341 | .i2c_bus_nr = 3, 1342 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1343 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1344 | } 1345 | } 1346 | }, 1347 | [TBSECP3_BOARD_TBS6522] = { 1348 | .board_id = TBSECP3_BOARD_TBS6522, 1349 | .name = "TurboSight TBS 6522 DVB-S/S2/S2X/T/T2/C/C2/ISDB-T ", 1350 | .adapters = 2, 1351 | .i2c_speed = 39, 1352 | .eeprom_i2c = 0, 1353 | .eeprom_addr = 0xa0, 1354 | .adap_config = { 1355 | { 1356 | .ts_in = 1, 1357 | .i2c_bus_nr = 0, 1358 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1359 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1360 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1361 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1362 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1363 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1364 | }, 1365 | { 1366 | .ts_in = 0, 1367 | .i2c_bus_nr = 0, 1368 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1369 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1370 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1371 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1372 | }, 1373 | } 1374 | }, 1375 | [TBSECP3_BOARD_TBS6902] = { 1376 | .board_id = TBSECP3_BOARD_TBS6902, 1377 | .name = "TurboSight TBS 6902 DVB-S/S2 ", 1378 | .adapters = 2, 1379 | .i2c_speed = 39, 1380 | .eeprom_i2c = 0, 1381 | .adap_config = { 1382 | { 1383 | .ts_in = 1, 1384 | .i2c_bus_nr = 1, 1385 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1386 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1387 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1388 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1389 | }, 1390 | { 1391 | .ts_in = 0, 1392 | .i2c_bus_nr = 0, 1393 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1394 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1395 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1396 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1397 | } 1398 | 1399 | } 1400 | }, 1401 | [TBSECP3_BOARD_TBS6903] = { 1402 | .board_id = TBSECP3_BOARD_TBS6903, 1403 | .name = "TurboSight TBS 6903 DVB-S/S2 ", 1404 | .adapters = 2, 1405 | .i2c_speed = 39, 1406 | .eeprom_i2c = 1, 1407 | .adap_config = { 1408 | { 1409 | .ts_in = 0, 1410 | .i2c_bus_nr = 0, 1411 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1412 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1413 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1414 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1415 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1416 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1417 | }, 1418 | { 1419 | .ts_in = 1, 1420 | .i2c_bus_nr = 0, 1421 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1422 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1423 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1424 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1425 | }, 1426 | } 1427 | }, 1428 | [TBSECP3_BOARD_TBS6904] = { 1429 | .board_id = TBSECP3_BOARD_TBS6904, 1430 | .name = "TurboSight TBS 6904 DVB-S/S2 ", 1431 | .adapters = 4, 1432 | .i2c_speed = 39, 1433 | .eeprom_i2c = 1, 1434 | .adap_config = { 1435 | { 1436 | .ts_in = 3, 1437 | .i2c_bus_nr = 3, 1438 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1439 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(3, 0), 1440 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1441 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 1442 | }, 1443 | { 1444 | .ts_in = 2, 1445 | .i2c_bus_nr = 2, 1446 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1447 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1448 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1449 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 1450 | }, 1451 | { 1452 | .ts_in = 1, 1453 | .i2c_bus_nr = 1, 1454 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1455 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1456 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1457 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1458 | }, 1459 | { 1460 | .ts_in = 0, 1461 | .i2c_bus_nr = 0, 1462 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1463 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1464 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1465 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1466 | }, 1467 | } 1468 | }, 1469 | [TBSECP3_BOARD_TBS6905] = { 1470 | .board_id = TBSECP3_BOARD_TBS6905, 1471 | .name = "TurboSight TBS 6905 DVB-S/S2 ", 1472 | .adapters = 4, 1473 | .i2c_speed = 39, 1474 | .eeprom_i2c = 2, 1475 | .adap_config = { 1476 | { 1477 | .ts_in = 2, 1478 | .i2c_bus_nr = 2, 1479 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1480 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1481 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1482 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 1483 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1484 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 1485 | }, 1486 | { 1487 | .ts_in = 3, 1488 | .i2c_bus_nr = 2, 1489 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1490 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 1491 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1492 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 1493 | }, 1494 | { 1495 | .ts_in = 0, 1496 | .i2c_bus_nr = 0, 1497 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1498 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1499 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1500 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1501 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1502 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1503 | }, 1504 | { 1505 | .ts_in = 1, 1506 | .i2c_bus_nr = 0, 1507 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1508 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1509 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1510 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1511 | }, 1512 | } 1513 | }, 1514 | [TBSECP3_BOARD_TBS6908] = { 1515 | .board_id = TBSECP3_BOARD_TBS6908, 1516 | .name = "TurboSight TBS 6908 DVB-S/S2 ", 1517 | .adapters = 4, 1518 | .i2c_speed = 39, 1519 | .eeprom_i2c = 2, 1520 | .adap_config = { 1521 | { 1522 | .ts_in = 2, 1523 | .i2c_bus_nr = 2, 1524 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1525 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1526 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1527 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(2, 2), 1528 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1529 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(2, 1), 1530 | }, 1531 | 1532 | { 1533 | .ts_in = 3, 1534 | .i2c_bus_nr = 2, 1535 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1536 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(3, 2), 1537 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1538 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(3, 1), 1539 | }, 1540 | { 1541 | .ts_in = 0, 1542 | .i2c_bus_nr = 0, 1543 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1544 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1545 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1546 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1547 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1548 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1549 | }, 1550 | { 1551 | .ts_in = 1, 1552 | .i2c_bus_nr = 0, 1553 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1554 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1555 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1556 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1557 | }, 1558 | } 1559 | }, 1560 | [TBSECP3_BOARD_TBS6909] = { 1561 | .board_id = TBSECP3_BOARD_TBS6909, 1562 | .name = "TurboSight TBS 6909 DVB-S/S2 ", 1563 | .adapters = 8, 1564 | .i2c_speed = 39, 1565 | .eeprom_i2c = 0, 1566 | .eeprom_addr = 0x10, 1567 | .adap_config = { 1568 | { 1569 | .ts_in = 0, 1570 | .i2c_bus_nr = 0, 1571 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1572 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1573 | }, 1574 | { 1575 | .ts_in = 1, 1576 | .i2c_bus_nr = 0, 1577 | }, 1578 | { 1579 | .ts_in = 2, 1580 | .i2c_bus_nr = 0, 1581 | }, 1582 | { 1583 | .ts_in = 3, 1584 | .i2c_bus_nr = 0, 1585 | }, 1586 | { 1587 | .ts_in = 4, 1588 | .i2c_bus_nr = 0, 1589 | }, 1590 | { 1591 | .ts_in = 5, 1592 | .i2c_bus_nr = 0, 1593 | }, 1594 | { 1595 | .ts_in = 6, 1596 | .i2c_bus_nr = 0, 1597 | }, 1598 | { 1599 | .ts_in = 7, 1600 | .i2c_bus_nr = 0, 1601 | } 1602 | } 1603 | }, 1604 | [TBSECP3_BOARD_TBS6910] = { 1605 | .board_id = TBSECP3_BOARD_TBS6910, 1606 | .name = "TurboSight TBS 6910 DVB-S/S2 + 2xCI ", 1607 | .adapters = 2, 1608 | .i2c_speed = 39, 1609 | .eeprom_i2c = 1, 1610 | .adap_config = { 1611 | { 1612 | .ts_in = 0, 1613 | .i2c_bus_nr = 0, 1614 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1615 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1616 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1617 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1618 | }, 1619 | { 1620 | .ts_in = 1, 1621 | .i2c_bus_nr = 1, 1622 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1623 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1624 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1625 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1626 | }, 1627 | } 1628 | }, 1629 | [TBSECP3_BOARD_TBS6528] = { 1630 | .board_id = TBSECP3_BOARD_TBS6528, 1631 | .name = "TurboSight TBS 6528 DVB-S/S2/S2X/T/T2/C/C2/ISDB-T + CI ", 1632 | .adapters = 1, 1633 | .i2c_speed = 39, 1634 | .eeprom_i2c = 0, 1635 | .eeprom_addr = 0xa0, 1636 | .adap_config = { 1637 | { 1638 | .ts_in = 0, 1639 | .i2c_bus_nr = 0, 1640 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1641 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1642 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1643 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1644 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1645 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1646 | }, 1647 | } 1648 | }, 1649 | [TBSECP3_BOARD_TBS6590] = { 1650 | .board_id = TBSECP3_BOARD_TBS6590, 1651 | .name = "TurboSight TBS 6590 DVB-S/S2/S2X/T/T2/C/C2/ISDB-T + 2xCI ", 1652 | .adapters = 2, 1653 | .i2c_speed = 39, 1654 | .eeprom_i2c = 0, 1655 | .eeprom_addr = 0xa0, 1656 | .adap_config = { 1657 | { 1658 | .ts_in = 0, 1659 | .i2c_bus_nr = 0, 1660 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1661 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1662 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1663 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1664 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1665 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1666 | }, 1667 | { 1668 | .ts_in = 1, 1669 | .i2c_bus_nr = 0, 1670 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1671 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1672 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1673 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1674 | }, 1675 | } 1676 | }, 1677 | [TBSECP3_BOARD_TBS6290SE] = { 1678 | .board_id = TBSECP3_BOARD_TBS6290SE, 1679 | .name = "TurboSight TBS 6290SE DVB-T/T2/C + 2xCI ", 1680 | .i2c_speed = 39, 1681 | .eeprom_i2c = 1, 1682 | .adapters = 2, 1683 | .adap_config = { 1684 | { 1685 | .ts_in = 0, 1686 | .i2c_bus_nr = 0, 1687 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_NONE, 1688 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1689 | 1690 | }, 1691 | { 1692 | .ts_in = 1, 1693 | .i2c_bus_nr = 1, 1694 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_NONE, 1695 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1696 | 1697 | }, 1698 | } 1699 | }, 1700 | [TBSECP3_BOARD_TBS6281SE] = { 1701 | .board_id = TBSECP3_BOARD_TBS6281SE, 1702 | .name = "TurboSight TBS 6281SE DVB-T/T2/C ", 1703 | .i2c_speed = 39, 1704 | .eeprom_i2c = 1, 1705 | .adapters = 2, 1706 | .adap_config = { 1707 | { 1708 | .ts_in = 1, 1709 | .i2c_bus_nr = 1, 1710 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1711 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(1, 0), 1712 | }, 1713 | { 1714 | .ts_in = 2, 1715 | .i2c_bus_nr = 2, 1716 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1717 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(2, 0), 1718 | }, 1719 | } 1720 | }, 1721 | [TBSECP3_BOARD_TBS6909X] = { 1722 | .board_id = TBSECP3_BOARD_TBS6909X, 1723 | .name = "TurboSight TBS 6909x (Octa DVB-S/S2/S2X)", 1724 | .adapters = 8, 1725 | .eeprom_i2c = 0, 1726 | .eeprom_addr = 0x10, 1727 | .adap_config = { 1728 | { 1729 | .ts_in = 0, 1730 | .i2c_bus_nr = 0, 1731 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1732 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1733 | }, 1734 | { 1735 | .ts_in = 1, 1736 | .i2c_bus_nr = 0, 1737 | }, 1738 | { 1739 | .ts_in = 2, 1740 | .i2c_bus_nr = 0, 1741 | }, 1742 | { 1743 | .ts_in = 3, 1744 | .i2c_bus_nr = 0, 1745 | }, 1746 | { 1747 | .ts_in = 4, 1748 | .i2c_bus_nr = 0, 1749 | }, 1750 | { 1751 | .ts_in = 5, 1752 | .i2c_bus_nr = 0, 1753 | }, 1754 | { 1755 | .ts_in = 6, 1756 | .i2c_bus_nr = 0, 1757 | }, 1758 | { 1759 | .ts_in = 7, 1760 | .i2c_bus_nr = 0, 1761 | } 1762 | } 1763 | }, 1764 | [TBSECP3_BOARD_TBS6903X] = { 1765 | .board_id = TBSECP3_BOARD_TBS6903X, 1766 | .name = "TurboSight TBS 6903x (Dual DVB-S/S2/S2X)", 1767 | .adapters = 2, 1768 | .eeprom_i2c = 0, 1769 | .eeprom_addr = 0x10, 1770 | .adap_config = { 1771 | { 1772 | .ts_in = 0, 1773 | .i2c_bus_nr = 0, 1774 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1775 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1776 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1777 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1778 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1779 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1780 | }, 1781 | { 1782 | .ts_in = 1, 1783 | .i2c_bus_nr = 0, 1784 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1785 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1786 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1787 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1788 | }, 1789 | } 1790 | }, 1791 | 1792 | [TBSECP3_BOARD_TBS6912] = { 1793 | .board_id = TBSECP3_BOARD_TBS6912, 1794 | .name = "TurboSight TBS 6912 (Dual DVB-S/S2/S2X CI card)", 1795 | .adapters = 2, 1796 | .eeprom_i2c = 0, 1797 | .eeprom_addr = 0x10, 1798 | .adap_config = { 1799 | { 1800 | .ts_in = 0, 1801 | .i2c_bus_nr = 0, 1802 | .gpio.demod_reset.lvl = TBSECP3_GPIODEF_LOW, 1803 | .gpio.demod_reset.nr = TBSECP3_GPIO_PIN(0, 0), 1804 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1805 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1806 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1807 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1808 | }, 1809 | { 1810 | .ts_in = 1, 1811 | .i2c_bus_nr = 0, 1812 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1813 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(1, 2), 1814 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1815 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(1, 1), 1816 | }, 1817 | 1818 | } 1819 | }, 1820 | #endif 1821 | [TBSECP3_BOARD_TBS6812] = { 1822 | .board_id = TBSECP3_BOARD_TBS6812, 1823 | .name = "Turbosight TBS 6812 (Dual ISDB-T/S/S3)", 1824 | .i2c_speed = 10, 1825 | .adapters = 2, 1826 | .eeprom_i2c = 0, 1827 | .eeprom_addr = 0xa0, 1828 | .adap_config ={ 1829 | 1830 | { 1831 | .ts_in = 0, 1832 | .i2c_bus_nr = 0, 1833 | .tlv_dma = true, 1834 | .gpio.lnb_power.lvl = TBSECP3_GPIODEF_LOW, 1835 | .gpio.lnb_power.nr = TBSECP3_GPIO_PIN(0, 2), 1836 | .gpio.lnb_voltage.lvl = TBSECP3_GPIODEF_HIGH, 1837 | .gpio.lnb_voltage.nr = TBSECP3_GPIO_PIN(0, 1), 1838 | }, 1839 | { 1840 | .ts_in = 1, 1841 | .i2c_bus_nr = 1, 1842 | .tlv_dma = true, 1843 | }, 1844 | }, 1845 | }, 1846 | }; 1847 | -------------------------------------------------------------------------------- /tbsecp3-core.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | static bool enable_msi = true; 21 | module_param(enable_msi, bool, 0444); 22 | MODULE_PARM_DESC(enable_msi, "use an msi interrupt if available"); 23 | 24 | 25 | void tbsecp3_gpio_set_pin(struct tbsecp3_dev *dev, 26 | struct tbsecp3_gpio_pin *pin, int state) 27 | { 28 | u32 tmp, bank, bit; 29 | 30 | if (pin->lvl == TBSECP3_GPIODEF_NONE) 31 | return; 32 | 33 | if (pin->lvl == TBSECP3_GPIODEF_LOW) 34 | state = !state; 35 | 36 | bank = (pin->nr >> 3) & ~3; 37 | bit = pin->nr % 32; 38 | 39 | tmp = tbs_read(TBSECP3_GPIO_BASE, bank); 40 | if (state) 41 | tmp |= 1 << bit; 42 | else 43 | tmp &= ~(1 << bit); 44 | tbs_write(TBSECP3_GPIO_BASE, bank, tmp); 45 | } 46 | 47 | static irqreturn_t tbsecp3_irq_handler(int irq, void *dev_id) 48 | { 49 | struct tbsecp3_dev *dev = (struct tbsecp3_dev *) dev_id; 50 | struct tbsecp3_i2c *i2c; 51 | int i, in; 52 | u32 stat = tbs_read(TBSECP3_INT_BASE, TBSECP3_INT_STAT); 53 | 54 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_STAT, stat); 55 | 56 | if (stat & 0x000ffff0) { 57 | /* dma0~15 */ 58 | for (i = 0; i < dev->info->adapters; i++) { 59 | in = dev->adapter[i].cfg->ts_in; 60 | if (stat & TBSECP3_DMA_IF(in)){ 61 | tasklet_schedule(&dev->adapter[i].tasklet); 62 | } 63 | } 64 | } 65 | 66 | if (stat & 0x0000000f) { 67 | /* i2c */ 68 | for (i = 0; i < 4; i++) { 69 | i2c = &dev->i2c_bus[i]; 70 | if (stat & TBSECP3_I2C_IF(i)) { 71 | i2c->done = 1; 72 | wake_up(&i2c->wq); 73 | } 74 | } 75 | } 76 | 77 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 1); 78 | return IRQ_HANDLED; 79 | } 80 | 81 | static int tbsecp3_adapters_attach(struct tbsecp3_dev *dev) 82 | { 83 | int i, ret = 0; 84 | for (i = 0; i < dev->info->adapters; i++) { 85 | ret = tbsecp3_dvb_init(&dev->adapter[i]); 86 | if (ret) { 87 | dev_err(&dev->pci_dev->dev, 88 | "adapter%d attach failed\n", 89 | dev->adapter[i].nr); 90 | dev->adapter[i].nr = -1; 91 | } 92 | } 93 | return 0; 94 | } 95 | 96 | static void tbsecp3_adapters_detach(struct tbsecp3_dev *dev) 97 | { 98 | struct tbsecp3_adapter *adapter; 99 | int i; 100 | 101 | for (i = 0; i < dev->info->adapters; i++) { 102 | adapter = &dev->adapter[i]; 103 | 104 | /* attach has failed, nothing to do */ 105 | if (adapter->nr == -1) 106 | continue; 107 | 108 | tbsecp3_i2c_remove_clients(adapter); 109 | tbsecp3_dvb_exit(adapter); 110 | } 111 | } 112 | 113 | static void tbsecp3_adapters_init(struct tbsecp3_dev *dev) 114 | { 115 | struct tbsecp3_adapter *adapter = dev->adapter; 116 | int i; 117 | 118 | for (i = 0; i < dev->info->adapters; i++) { 119 | adapter = &dev->adapter[i]; 120 | adapter->nr = i; 121 | adapter->cfg = &dev->info->adap_config[i]; 122 | adapter->dev = dev; 123 | adapter->i2c = &dev->i2c_bus[adapter->cfg->i2c_bus_nr]; 124 | } 125 | } 126 | 127 | static void tbsecp3_adapters_release(struct tbsecp3_dev *dev) 128 | { 129 | struct tbsecp3_adapter *adapter; 130 | int i; 131 | 132 | for (i = 0; i < dev->info->adapters; i++) { 133 | adapter = &dev->adapter[i]; 134 | tasklet_kill(&adapter->tasklet); 135 | } 136 | } 137 | 138 | 139 | static bool tbsecp3_enable_msi(struct pci_dev *pci_dev, struct tbsecp3_dev *dev) 140 | { 141 | int err; 142 | 143 | if (!enable_msi) { 144 | dev_warn(&dev->pci_dev->dev, 145 | "MSI disabled by module parameter 'enable_msi'\n"); 146 | return false; 147 | } 148 | 149 | err = pci_enable_msi(pci_dev); 150 | if (err) { 151 | dev_err(&dev->pci_dev->dev, 152 | "Failed to enable MSI interrupt." 153 | " Falling back to a shared IRQ\n"); 154 | return false; 155 | } 156 | 157 | /* no error - so request an msi interrupt */ 158 | err = request_irq(pci_dev->irq, tbsecp3_irq_handler, 0, 159 | "tbsecp3", dev); 160 | if (err) { 161 | /* fall back to legacy interrupt */ 162 | dev_err(&dev->pci_dev->dev, 163 | "Failed to get an MSI interrupt." 164 | " Falling back to a shared IRQ\n"); 165 | pci_disable_msi(pci_dev); 166 | return false; 167 | } 168 | return true; 169 | } 170 | 171 | 172 | static int tbsecp3_probe(struct pci_dev *pdev, const struct pci_device_id *id) 173 | { 174 | struct tbsecp3_dev *dev; 175 | int ret = -ENODEV; 176 | 177 | if (pci_enable_device(pdev) < 0) 178 | return -ENODEV; 179 | 180 | if(dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) 181 | if(dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) 182 | { 183 | dev_err(&pdev->dev, "64/32-bit PCI DMA not supported\n"); 184 | goto err0; 185 | } 186 | 187 | pci_set_master(pdev); 188 | 189 | dev = kzalloc(sizeof(struct tbsecp3_dev), GFP_KERNEL); 190 | if (!dev) { 191 | ret = -ENOMEM; 192 | goto err0; 193 | } 194 | 195 | dev->pci_dev = pdev; 196 | pci_set_drvdata(pdev, dev); 197 | 198 | dev->info = (struct tbsecp3_board *) id->driver_data; 199 | dev_info(&pdev->dev, "%s\n", dev->info->name); 200 | 201 | dev->lmmio = ioremap(pci_resource_start(pdev, 0), 202 | pci_resource_len(pdev, 0)); 203 | if (!dev->lmmio) { 204 | ret = -ENOMEM; 205 | goto err1; 206 | } 207 | 208 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 0); 209 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_STAT, 0xff); 210 | 211 | tbsecp3_adapters_init(dev); 212 | 213 | /* dma */ 214 | ret = tbsecp3_dma_init(dev); 215 | if (ret < 0) 216 | goto err2; 217 | 218 | /* i2c */ 219 | ret = tbsecp3_i2c_init(dev); 220 | if (ret < 0) 221 | goto err3; 222 | 223 | /* interrupts */ 224 | if (tbsecp3_enable_msi(pdev, dev)) { 225 | dev->msi = true; 226 | } else { 227 | ret = request_irq(pdev->irq, tbsecp3_irq_handler, 228 | IRQF_SHARED, "tbsecp3", dev); 229 | if (ret < 0) { 230 | dev_err(&pdev->dev, "%s: can't get IRQ %d\n", 231 | dev->info->name, pdev->irq); 232 | goto err4; 233 | } 234 | dev->msi = false; 235 | } 236 | /* global interrupt enable */ 237 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 1); 238 | 239 | ret = tbsecp3_adapters_attach(dev); 240 | if (ret < 0) 241 | goto err5; 242 | 243 | dev_info(&pdev->dev, "%s: PCI %s, IRQ %d, MMIO 0x%lx\n", 244 | dev->info->name, pci_name(pdev), pdev->irq, 245 | (unsigned long) pci_resource_start(pdev, 0)); 246 | 247 | //dev_info(&dev->pci_dev->dev, "%s ready\n", dev->info->name); 248 | return 0; 249 | 250 | err5: 251 | tbsecp3_adapters_detach(dev); 252 | 253 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 0); 254 | free_irq(dev->pci_dev->irq, dev); 255 | if (dev->msi) { 256 | pci_disable_msi(pdev); 257 | dev->msi = false; 258 | } 259 | err4: 260 | tbsecp3_i2c_exit(dev); 261 | err3: 262 | tbsecp3_dma_free(dev); 263 | err2: 264 | tbsecp3_adapters_release(dev); 265 | iounmap(dev->lmmio); 266 | err1: 267 | pci_set_drvdata(pdev, NULL); 268 | kfree(dev); 269 | err0: 270 | pci_disable_device(pdev); 271 | dev_err(&pdev->dev, "probe error\n"); 272 | return ret; 273 | } 274 | 275 | static void tbsecp3_remove(struct pci_dev *pdev) 276 | { 277 | struct tbsecp3_dev *dev = pci_get_drvdata(pdev); 278 | 279 | /* disable interrupts */ 280 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 0); 281 | free_irq(pdev->irq, dev); 282 | if (dev->msi) { 283 | pci_disable_msi(pdev); 284 | dev->msi = false; 285 | } 286 | tbsecp3_adapters_detach(dev); 287 | tbsecp3_adapters_release(dev); 288 | tbsecp3_dma_free(dev); 289 | tbsecp3_i2c_exit(dev); 290 | iounmap(dev->lmmio); 291 | pci_set_drvdata(pdev, NULL); 292 | pci_disable_device(pdev); 293 | kfree(dev); 294 | } 295 | 296 | static int tbsecp3_resume(struct pci_dev *pdev) 297 | { 298 | struct tbsecp3_dev *dev = pci_get_drvdata(pdev); 299 | /* re-init registers */ 300 | tbsecp3_i2c_reg_init(dev); 301 | tbsecp3_dma_reg_init(dev); 302 | tbs_write(TBSECP3_INT_BASE, TBSECP3_INT_EN, 1); 303 | return 0; 304 | } 305 | 306 | /* PCI IDs */ 307 | #define TBSECP3_ID(_board_id,_subvend,_subdev) { \ 308 | .vendor = TBSECP3_VID, .device = TBSECP3_PID, \ 309 | .subvendor = _subvend, .subdevice = _subdev, \ 310 | .driver_data = (unsigned long)&tbsecp3_boards[_board_id] } 311 | 312 | static const struct pci_device_id tbsecp3_id_table[] = { 313 | #ifdef TBS_DVB_EXTENSION 314 | TBSECP3_ID(TBSECP3_BOARD_TBS6205,0x6205,0x0001), 315 | TBSECP3_ID(TBSECP3_BOARD_TBS6281SE,0x6281,0x0002), 316 | TBSECP3_ID(TBSECP3_BOARD_TBS6290SE,0x6290,0x0002), 317 | TBSECP3_ID(TBSECP3_BOARD_TBS6290TD,0x6290,0x0008), 318 | TBSECP3_ID(TBSECP3_BOARD_TBS6209,0x6209,0x0001), 319 | TBSECP3_ID(TBSECP3_BOARD_TBS6522,0x6522,0x0002), 320 | TBSECP3_ID(TBSECP3_BOARD_TBS6528,0x6528,PCI_ANY_ID), 321 | TBSECP3_ID(TBSECP3_BOARD_TBS6590,0x6590,0x0001), 322 | TBSECP3_ID(TBSECP3_BOARD_TBS6902,0x6902,0x1132), 323 | TBSECP3_ID(TBSECP3_BOARD_TBS6902,0x6902,0x0001), 324 | TBSECP3_ID(TBSECP3_BOARD_TBS6902,0x6902,0x0002), 325 | TBSECP3_ID(TBSECP3_BOARD_TBS6902,0x6902,0x0003), 326 | TBSECP3_ID(TBSECP3_BOARD_TBS6903,0x6903,0x0001), 327 | TBSECP3_ID(TBSECP3_BOARD_TBS6904,0x6904,0x0001), 328 | TBSECP3_ID(TBSECP3_BOARD_TBS6904,0x6904,0x1131), 329 | TBSECP3_ID(TBSECP3_BOARD_TBS6905,0x6905,PCI_ANY_ID), 330 | TBSECP3_ID(TBSECP3_BOARD_TBS6908,0x6908,PCI_ANY_ID), 331 | TBSECP3_ID(TBSECP3_BOARD_TBS6909,0x6909,0x0001), 332 | TBSECP3_ID(TBSECP3_BOARD_TBS6910,0x6910,0x0001), 333 | TBSECP3_ID(TBSECP3_BOARD_TBS6704,0x6704,PCI_ANY_ID), 334 | TBSECP3_ID(TBSECP3_BOARD_TBS6814,0x6814,PCI_ANY_ID), 335 | TBSECP3_ID(TBSECP3_BOARD_TBS6514,0x6514,PCI_ANY_ID), 336 | TBSECP3_ID(TBSECP3_BOARD_TBS690a,0x690a,PCI_ANY_ID), 337 | TBSECP3_ID(TBSECP3_BOARD_TBS6301,0x6301,0x0001), 338 | TBSECP3_ID(TBSECP3_BOARD_TBS6304,0x6304,0x0001), 339 | TBSECP3_ID(TBSECP3_BOARD_TBS6308,0x6308,0x0001), 340 | TBSECP3_ID(TBSECP3_BOARD_TBS6308X,0x6308,0x0010), 341 | TBSECP3_ID(TBSECP3_BOARD_TBS6312X,0x6312,0x0010), 342 | TBSECP3_ID(TBSECP3_BOARD_TBS6909X,0x6909,0x0010), 343 | TBSECP3_ID(TBSECP3_BOARD_TBS6909X,0x6909,0x0009), 344 | TBSECP3_ID(TBSECP3_BOARD_TBS6909X,0x6909,0x0019), 345 | TBSECP3_ID(TBSECP3_BOARD_TBS6903X,0x6903,0x0020), 346 | TBSECP3_ID(TBSECP3_BOARD_TBS6903X,0x6903,0x0021), 347 | TBSECP3_ID(TBSECP3_BOARD_TBS6903X,0x6903,0x8888), 348 | TBSECP3_ID(TBSECP3_BOARD_TBS6904X,0x6904,0x2000), 349 | TBSECP3_ID(TBSECP3_BOARD_TBS6912,0x6912,0x0020), 350 | TBSECP3_ID(TBSECP3_BOARD_TBS6504,0x6504,0x0001), 351 | TBSECP3_ID(TBSECP3_BOARD_TBS6508,0x6508,0x0001), 352 | TBSECP3_ID(TBSECP3_BOARD_TBS6302SE,0x6302,0x0001), 353 | TBSECP3_ID(TBSECP3_BOARD_TBS6304,0x2605,PCI_ANY_ID), 354 | TBSECP3_ID(TBSECP3_BOARD_TBS6902SE,0x6902,0x0007), 355 | TBSECP3_ID(TBSECP3_BOARD_TBS6904SE,0x6904,0x0020), 356 | TBSECP3_ID(TBSECP3_BOARD_TBS6301SE,0x6301,0x0005), 357 | TBSECP3_ID(TBSECP3_BOARD_TBS6301SE,0x6302,0x0005), 358 | TBSECP3_ID(TBSECP3_BOARD_TBS6301SE,0x6301,0x0004), 359 | TBSECP3_ID(TBSECP3_BOARD_TBS6910SE,0x6910,0x0006), 360 | TBSECP3_ID(TBSECP3_BOARD_TBS7901,0x7901,0x0001), 361 | TBSECP3_ID(TBSECP3_BOARD_TBS6209SE,0x6209,0x0006), 362 | TBSECP3_ID(TBSECP3_BOARD_TBS7901,0x7901,0x0001), 363 | TBSECP3_ID(TBSECP3_BOARD_TBS7230,0x7230,0x0006), 364 | TBSECP3_ID(TBSECP3_BOARD_TBS6302X,0x6302,0x0010), 365 | TBSECP3_ID(TBSECP3_BOARD_TBS6302T,0x6302,0x0009), 366 | TBSECP3_ID(TBSECP3_BOARD_TBS6304X,0x6304,0x0010), 367 | TBSECP3_ID(TBSECP3_BOARD_TBS6205SE,0x6205,0x0003), 368 | TBSECP3_ID(TBSECP3_BOARD_TBS6281TD,0x6281,0x0003), 369 | TBSECP3_ID(TBSECP3_BOARD_TBS6909SE,0x6909,0x0066), 370 | TBSECP3_ID(TBSECP3_BOARD_TBS6304T,0x6304,0x0009), 371 | TBSECP3_ID(TBSECP3_BOARD_TBS6522H,0x6522,0x0004), 372 | TBSECP3_ID(TBSECP3_BOARD_TBS6504H,0x6504,0x0008), 373 | TBSECP3_ID(TBSECP3_BOARD_TBS6590SE,0x6590,0x0002), 374 | TBSECP3_ID(TBSECP3_BOARD_TBS6916,0x6916,0x0001), 375 | TBSECP3_ID(TBSECP3_BOARD_TBS6324,0x6324,0x0010), 376 | TBSECP3_ID(TBSECP3_BOARD_TBS6322,0x6322,0x0010), 377 | #endif 378 | TBSECP3_ID(TBSECP3_BOARD_TBS6812,0x6812,0x0001), 379 | {0} 380 | }; 381 | MODULE_DEVICE_TABLE(pci, tbsecp3_id_table); 382 | 383 | static struct pci_driver tbsecp3_driver = { 384 | #ifdef TBS_DVB_EXTENSION 385 | .name = "TBSECP3 driver", 386 | #else 387 | .name = "TBS6812 driver", 388 | #endif 389 | .id_table = tbsecp3_id_table, 390 | .probe = tbsecp3_probe, 391 | .remove = tbsecp3_remove, 392 | .resume = tbsecp3_resume, 393 | .suspend = NULL, 394 | }; 395 | 396 | module_pci_driver(tbsecp3_driver); 397 | 398 | MODULE_AUTHOR("Luis Alves "); 399 | #ifdef TBS_DVB_EXTENSION 400 | MODULE_DESCRIPTION("TBS ECP3 driver"); 401 | #else 402 | MODULE_DESCRIPTION("TBS6812 driver"); 403 | #endif 404 | MODULE_LICENSE("GPL"); 405 | -------------------------------------------------------------------------------- /tbsecp3-dma.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | static unsigned int dma_pkts[16] = {128, 128, 128, 128, 128, 128, 128, 128,128, 128, 128, 128, 128, 128, 128, 128}; 21 | module_param_array(dma_pkts, int, NULL, 0444); /* No /sys/module write access */ 22 | MODULE_PARM_DESC(dma_pkts, "DMA buffer size in TS packets (16-256), default 128"); 23 | 24 | #define TS_PACKET_SIZE 188 25 | 26 | static void tbsecp3_dma_tasklet(unsigned long adap) 27 | { 28 | struct tbsecp3_adapter *adapter = (struct tbsecp3_adapter *) adap; 29 | struct tbsecp3_dev *dev = adapter->dev; 30 | u32 read_buffer, next_buffer; 31 | u8* data; 32 | int i; 33 | 34 | spin_lock(&adapter->adap_lock); 35 | 36 | if (adapter->dma.cnt < TBSECP3_DMA_PRE_BUFFERS) 37 | { 38 | next_buffer = (tbs_read(adapter->dma.base, TBSECP3_DMA_STAT) - TBSECP3_DMA_PRE_BUFFERS + 1) & (TBSECP3_DMA_BUFFERS - 1); 39 | adapter->dma.cnt++; 40 | } 41 | else 42 | { 43 | next_buffer = (tbs_read(adapter->dma.base, TBSECP3_DMA_STAT) - TBSECP3_DMA_PRE_BUFFERS + 1) & (TBSECP3_DMA_BUFFERS - 1); 44 | read_buffer = (u32)adapter->dma.next_buffer; 45 | 46 | while (read_buffer != next_buffer) 47 | { 48 | data = adapter->dma.buf[read_buffer]; 49 | 50 | if (!adapter->cfg->tlv_dma && data[adapter->dma.offset] != 0x47) { 51 | /* Find sync byte offset with crude force (this might fail!) */ 52 | for (i = 0; i < TS_PACKET_SIZE; i++) 53 | if ((data[i] == 0x47) && 54 | (data[i + TS_PACKET_SIZE] == 0x47) && 55 | (data[i + 2 * TS_PACKET_SIZE] == 0x47) && 56 | (data[i + 4 * TS_PACKET_SIZE] == 0x47)) { 57 | adapter->dma.offset = i; 58 | break; 59 | } 60 | } 61 | 62 | if (adapter->dma.offset != 0) { 63 | data += adapter->dma.offset; 64 | /* Copy remains of last packet from buffer 0 behind last one */ 65 | if (read_buffer == (TBSECP3_DMA_BUFFERS - 1)) { 66 | memcpy( adapter->dma.buf[TBSECP3_DMA_BUFFERS], 67 | adapter->dma.buf[0], adapter->dma.offset); 68 | } 69 | } 70 | if (adapter->cfg->tlv_dma) 71 | dvb_dmx_swfilter_raw(&adapter->demux, data, adapter->dma.buffer_size); 72 | else 73 | dvb_dmx_swfilter_packets(&adapter->demux, data, adapter->dma.buffer_pkts); 74 | read_buffer = (read_buffer + 1) & (TBSECP3_DMA_BUFFERS - 1); 75 | } 76 | } 77 | 78 | adapter->dma.next_buffer = (u8)next_buffer; 79 | 80 | spin_unlock(&adapter->adap_lock); 81 | 82 | } 83 | 84 | void tbsecp3_dma_enable(struct tbsecp3_adapter *adap) 85 | { 86 | struct tbsecp3_dev *dev = adap->dev; 87 | 88 | spin_lock_irq(&adap->adap_lock); 89 | adap->dma.offset = 0; 90 | adap->dma.cnt = 0; 91 | adap->dma.next_buffer= 0; 92 | tbs_read(adap->dma.base, TBSECP3_DMA_STAT); 93 | tbs_write(TBSECP3_INT_BASE, TBSECP3_DMA_IE(adap->cfg->ts_in), 1); 94 | tbs_write(adap->dma.base, TBSECP3_DMA_EN, 1); 95 | spin_unlock_irq(&adap->adap_lock); 96 | } 97 | 98 | void tbsecp3_dma_disable(struct tbsecp3_adapter *adap) 99 | { 100 | struct tbsecp3_dev *dev = adap->dev; 101 | 102 | spin_lock_irq(&adap->adap_lock); 103 | tbs_read(adap->dma.base, TBSECP3_DMA_STAT); 104 | tbs_write(TBSECP3_INT_BASE, TBSECP3_DMA_IE(adap->cfg->ts_in), 0); 105 | tbs_write(adap->dma.base, TBSECP3_DMA_EN, 0); 106 | spin_unlock_irq(&adap->adap_lock); 107 | } 108 | 109 | void tbsecp3_dma_reg_init(struct tbsecp3_dev *dev) 110 | { 111 | int i; 112 | struct tbsecp3_adapter *adapter = dev->adapter; 113 | 114 | for (i = 0; i < dev->info->adapters; i++) { 115 | tbs_write(adapter->dma.base, TBSECP3_DMA_EN, 0); 116 | if (adapter->cfg->tlv_dma) 117 | tbs_write(adapter->dma.base, TBSECP3_DMA_TLV_UNK, 0); 118 | tbs_write(adapter->dma.base, TBSECP3_DMA_ADDRH, 0); 119 | tbs_write(adapter->dma.base, TBSECP3_DMA_ADDRL, (u32) adapter->dma.dma_addr); 120 | tbs_write(adapter->dma.base, TBSECP3_DMA_TSIZE, adapter->dma.page_size); 121 | tbs_write(adapter->dma.base, TBSECP3_DMA_BSIZE, adapter->dma.buffer_size); 122 | adapter++; 123 | } 124 | } 125 | 126 | void tbsecp3_dma_free(struct tbsecp3_dev *dev) 127 | { 128 | struct tbsecp3_adapter *adapter = dev->adapter; 129 | int i; 130 | for (i = 0; i < dev->info->adapters; i++) { 131 | if (adapter->dma.buf[0] == NULL) 132 | continue; 133 | 134 | dma_free_coherent(&dev->pci_dev->dev, 135 | adapter->dma.page_size + 0x100, 136 | adapter->dma.buf[0], adapter->dma.dma_addr); 137 | adapter->dma.buf[0] = NULL; 138 | adapter++; 139 | } 140 | } 141 | 142 | int tbsecp3_dma_init(struct tbsecp3_dev *dev) 143 | { 144 | struct tbsecp3_adapter *adapter = dev->adapter; 145 | int i, j; 146 | 147 | for (i = 0; i < dev->info->adapters; i++) { 148 | if (dma_pkts[i] < 16) 149 | dma_pkts[i] = 16; 150 | if (dma_pkts[i] > 256) 151 | dma_pkts[i] = 256; 152 | 153 | adapter->dma.buffer_pkts = dma_pkts[i]; 154 | adapter->dma.buffer_size = dma_pkts[i] * TS_PACKET_SIZE; 155 | adapter->dma.page_size = adapter->dma.buffer_size * TBSECP3_DMA_BUFFERS; 156 | 157 | adapter->dma.buf[0] = dma_alloc_coherent(&dev->pci_dev->dev, 158 | adapter->dma.page_size + 0x100, 159 | &adapter->dma.dma_addr, GFP_KERNEL); 160 | if (!adapter->dma.buf[0]) 161 | goto err; 162 | 163 | dev_dbg(&dev->pci_dev->dev, 164 | "TS in %d: DMA page %d bytes, %d bytes (%d TS packets) per %d buffers\n", adapter->cfg->ts_in, 165 | adapter->dma.page_size, adapter->dma.buffer_size, adapter->dma.buffer_pkts, TBSECP3_DMA_BUFFERS); 166 | 167 | adapter->dma.base = TBSECP3_DMA_BASE(adapter->cfg->ts_in); 168 | adapter->dma.cnt = 0; 169 | adapter->dma.next_buffer = 0; 170 | for (j = 1; j < TBSECP3_DMA_BUFFERS + 1; j++) 171 | adapter->dma.buf[j] = adapter->dma.buf[j-1] + adapter->dma.buffer_size; 172 | 173 | tasklet_init(&adapter->tasklet, tbsecp3_dma_tasklet, (unsigned long) adapter); 174 | spin_lock_init(&adapter->adap_lock); 175 | adapter++; 176 | } 177 | tbsecp3_dma_reg_init(dev); 178 | return 0; 179 | err: 180 | dev_err(&dev->pci_dev->dev, "dma: memory alloc failed\n"); 181 | tbsecp3_dma_free(dev); 182 | return -ENOMEM; 183 | } 184 | -------------------------------------------------------------------------------- /tbsecp3-dvb.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | #ifdef TBS_DVB_EXTENSION 21 | #include "tas2101.h" 22 | #include "av201x.h" 23 | 24 | #include "si2168.h" 25 | #include "si2157.h" 26 | 27 | #include "mxl58x.h" 28 | 29 | #include "si2183.h" 30 | 31 | #include "stv091x.h" 32 | #include "stv6120.h" 33 | 34 | #include "mn88436.h" 35 | #include "mxl603.h" 36 | 37 | #include "mtv23x.h" 38 | #include "gx1503.h" 39 | #include "tas2971.h" 40 | 41 | #include "stid135.h" 42 | #include "rda5816.h" 43 | #include "m88rs6060.h" 44 | #include "gx1133.h" 45 | #include "cxd2878.h" 46 | #endif 47 | #include "cxd2857.h" 48 | 49 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 50 | 51 | static bool swapfe = false; 52 | module_param(swapfe, bool, 0444); 53 | MODULE_PARM_DESC(swapfe, "swap combo frontends order"); 54 | 55 | static bool ciclock = false; 56 | module_param(ciclock, bool, 0444); 57 | MODULE_PARM_DESC(ciclock, "whether to manually set ci clock. false=set by fpga,true=set by si5351"); 58 | 59 | struct sec_priv { 60 | struct tbsecp3_adapter *adap; 61 | int (*set_voltage)(struct dvb_frontend *fe, 62 | enum fe_sec_voltage voltage); 63 | }; 64 | static void ecp3_spi_read(struct i2c_adapter *i2c,u8 reg, u32 *buf) 65 | { 66 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 67 | struct tbsecp3_dev *dev = i2c_adap->dev; 68 | *buf = tbs_read(TBSECP3_GPIO_BASE,reg ); 69 | 70 | //printk(" tbsecp3-dvb : ecp3_spi_read **********%x = %x*******\n",reg,*buf); 71 | 72 | return ; 73 | } 74 | static void ecp3_spi_write(struct i2c_adapter *i2c,u8 reg, u32 buf) 75 | { 76 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 77 | struct tbsecp3_dev *dev = i2c_adap->dev; 78 | //printk(" tbsecp3-dvb : ecp3_spi_write **********%x = %x*******\n",reg,buf); 79 | tbs_write(TBSECP3_GPIO_BASE, reg, buf); 80 | 81 | return ; 82 | } 83 | 84 | static void mcu_24cxx_read(struct i2c_adapter *i2c,u32 bassaddr, u8 reg, u32 *buf) 85 | { 86 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 87 | struct tbsecp3_dev *dev = i2c_adap->dev; 88 | *buf = tbs_read(bassaddr,reg ); 89 | 90 | //printk(" tbsecp3-dvb : mcu_24cxx_read *****bassaddr: %x, %x = %x*******\n",bassaddr,reg,*buf); 91 | 92 | return ; 93 | } 94 | static void mcu_24cxx_write(struct i2c_adapter *i2c,u32 bassaddr,u8 reg, u32 buf) 95 | { 96 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 97 | struct tbsecp3_dev *dev = i2c_adap->dev; 98 | //printk(" tbsecp3-dvb : mcu_24cxx_write ****bassaddr: %x,***%x = %x*******\n",bassaddr,reg,buf); 99 | tbs_write(bassaddr, reg, buf); 100 | 101 | return ; 102 | } 103 | 104 | static void ecp3_eeprom_read(struct i2c_adapter *i2c,u8 reg, u8 *buf) 105 | { 106 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 107 | struct tbsecp3_dev *dev = i2c_adap->dev; 108 | u8 eeprom_bus_nr = dev->info->eeprom_i2c; 109 | struct i2c_adapter *i2c_eep = &dev->i2c_bus[eeprom_bus_nr].i2c_adap; 110 | 111 | struct i2c_msg msg[] = { 112 | { .addr = 0x50, .flags = 0, 113 | .buf = ®, .len = 1 }, 114 | { .addr = 0x50, .flags = I2C_M_RD, 115 | .buf = buf, .len = 1 } 116 | }; 117 | 118 | i2c_transfer(i2c_eep, msg, 2); 119 | 120 | //printk(" tbsecp3-dvb : ecp3_eeprom_read **********%x = %x*******\n",reg,*buf); 121 | 122 | return; 123 | } 124 | static void ecp3_eeprom_write(struct i2c_adapter *i2c,u8 reg, u8 data) 125 | { 126 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 127 | struct tbsecp3_dev *dev = i2c_adap->dev; 128 | u8 eeprom_bus_nr = dev->info->eeprom_i2c; 129 | struct i2c_adapter *i2c_eep = &dev->i2c_bus[eeprom_bus_nr].i2c_adap; 130 | u8 tmp[2] = { reg, data }; 131 | 132 | struct i2c_msg msg[] = { 133 | { .addr = 0x50, .flags = 0, 134 | .buf = tmp, .len = 2 }, 135 | }; 136 | 137 | i2c_transfer(i2c_eep, msg, 1); 138 | //printk(" ecp3_eeprom_write : ecp3_spi_write **********%x = %x*******\n",reg,buf); 139 | 140 | return ; 141 | } 142 | 143 | static int tbs6302se_read_mac(struct tbsecp3_adapter *adap) 144 | { 145 | struct tbsecp3_dev *dev = adap->dev; 146 | int ret = 1; 147 | int i =0; 148 | u32 postaddr; 149 | unsigned char tmpbuf[4]={0}; 150 | unsigned char rdbuffer[8]={0}; 151 | 152 | if(adap->nr)//adapter1 is equal to adapter3 in tbs6304 153 | postaddr = 0x80 *(adap->nr+2) +0x08; 154 | else//adapter0 is equal to adapter1 in tbs6304 155 | postaddr = 0x80 *(adap->nr+1) +0x08; 156 | 157 | tmpbuf[0] = 0x31; //24cxx read; 158 | tmpbuf[1] = 6; //how many byte; 159 | tmpbuf[2] = (postaddr>>8); 160 | tmpbuf[3] = (postaddr &255); //24cxx sub_address,0x08 for mac 161 | 162 | 163 | tbs_write( BASE_ADDRESS_24CXX, CMD_24CXX, *(u32 *)&tmpbuf[0] ); 164 | //wait... until the data are received correctly; 165 | for(i=0;i<100;i++) 166 | { 167 | msleep(1); 168 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 169 | if((tmpbuf[0]&1) == 0) 170 | break; 171 | } 172 | if(i==100) 173 | { 174 | ret = 0; 175 | //printk(" the receiver always busy !\n"); 176 | //check mcu status 177 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 178 | if((tmpbuf[0]&0x4) == 1) // bit2==1 mcu busy 179 | { 180 | //printk("MCU status is busy!!!\n" ); 181 | // release cs; 182 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 183 | ret = 0; 184 | } 185 | 186 | } 187 | // release cs; 188 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 189 | //check the write finished; 190 | for(i=0;i<100;i++) 191 | { 192 | msleep(1); 193 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 194 | if((tmpbuf[0]&1) == 1) 195 | break; 196 | } 197 | if(i==100) 198 | { 199 | ret = 0; 200 | //printk(" wait wt_24cxx_done timeout! \n"); 201 | } 202 | //read back to host; 203 | *(u32 *)rdbuffer = tbs_read( BASE_ADDRESS_24CXX, DATA0_24CXX ); 204 | *(u32 *)&rdbuffer[4] = tbs_read( BASE_ADDRESS_24CXX, DATA1_24CXX ); 205 | if(ret!=0) 206 | { 207 | memcpy(adap->dvb_adapter.proposed_mac, rdbuffer,6); 208 | printk("adapter %d ,mac address: %x,%x,%x,%x,%x,%x \n",adap->dvb_adapter.num,rdbuffer[0],rdbuffer[1],rdbuffer[2],rdbuffer[3],rdbuffer[4],rdbuffer[5]); 209 | } 210 | 211 | return ret; 212 | }; 213 | 214 | static int tbs6304_read_mac(struct tbsecp3_adapter *adap) 215 | { 216 | struct tbsecp3_dev *dev = adap->dev; 217 | int ret = 1; 218 | int i =0; 219 | u32 postaddr; 220 | unsigned char tmpbuf[4]={0}; 221 | unsigned char rdbuffer[8]={0}; 222 | 223 | postaddr = 0x80 *(adap->nr) +0x08; 224 | 225 | tmpbuf[0] = 0x31; //24cxx read; 226 | tmpbuf[1] = 6; //how many byte; 227 | tmpbuf[2] = (postaddr>>8); 228 | tmpbuf[3] = (postaddr &255); //24cxx sub_address,0x08 for mac 229 | 230 | 231 | tbs_write( BASE_ADDRESS_24CXX, CMD_24CXX, *(u32 *)&tmpbuf[0] ); 232 | //wait... until the data are received correctly; 233 | for(i=0;i<100;i++) 234 | { 235 | msleep(1); 236 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 237 | if((tmpbuf[0]&1) == 0) 238 | break; 239 | } 240 | if(i==100) 241 | { 242 | ret = 0; 243 | //printk(" the receiver always busy !\n"); 244 | //check mcu status 245 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 246 | if((tmpbuf[0]&0x4) == 1) // bit2==1 mcu busy 247 | { 248 | //printk("MCU status is busy!!!\n" ); 249 | // release cs; 250 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 251 | ret = 0; 252 | } 253 | 254 | } 255 | // release cs; 256 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 257 | //check the write finished; 258 | for(i=0;i<100;i++) 259 | { 260 | msleep(1); 261 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 262 | if((tmpbuf[0]&1) == 1) 263 | break; 264 | } 265 | if(i==100) 266 | { 267 | ret = 0; 268 | //printk(" wait wt_24cxx_done timeout! \n"); 269 | } 270 | //read back to host; 271 | *(u32 *)rdbuffer = tbs_read( BASE_ADDRESS_24CXX, DATA0_24CXX ); 272 | *(u32 *)&rdbuffer[4] = tbs_read( BASE_ADDRESS_24CXX, DATA1_24CXX ); 273 | if(ret!=0) 274 | { 275 | memcpy(adap->dvb_adapter.proposed_mac, rdbuffer,6); 276 | printk("adapter %d ,mac address: %x,%x,%x,%x,%x,%x \n",adap->dvb_adapter.num,rdbuffer[0],rdbuffer[1],rdbuffer[2],rdbuffer[3],rdbuffer[4],rdbuffer[5]); 277 | } 278 | 279 | return ret; 280 | }; 281 | static void tbs_write_ext(struct tbsecp3_adapter *adap, u32 baseaddr, u8 address, u32 data) 282 | { 283 | struct tbsecp3_dev *dev = adap->dev; 284 | int i = 0; 285 | u32 uAddr = baseaddr + address; 286 | u32 tmp = ((uAddr & 0xff00) >> 8) | ((uAddr & 0x00ff) << 8); 287 | tbs_write(0x1000,4, data); 288 | tbs_write(0x1000,0, (((tmp << 16) & 0xffff0000) + 0x00000000)); 289 | 290 | while (0xff == tbs_read(0x1000,0)) { 291 | //msleep(1); 292 | if (10000 == i) { 293 | //printk("rdReg32_Extern:rdReg32(0x1000) time out\n"); 294 | return; 295 | } 296 | i++; 297 | } 298 | return; 299 | 300 | } 301 | 302 | static u32 tbs_read_ext(struct tbsecp3_adapter *adap, u32 baseaddr, u8 address) 303 | { 304 | struct tbsecp3_dev *dev = adap->dev; 305 | int i = 0; 306 | u32 uAddr = baseaddr + address; 307 | u32 tmp = ((uAddr & 0xff00) >> 8) | ((uAddr & 0x00ff) << 8); 308 | tbs_write(0x1000,0, (((tmp << 16) & 0xffff0000) + 0x00000080)); 309 | while (0xff == tbs_read(0x1000,0)) { 310 | //msleep(1); 311 | if (10000 == i) { 312 | //printk("rdReg32_Extern:rdReg32(0x1000) time out\n"); 313 | return 0; 314 | } 315 | i++; 316 | } 317 | return tbs_read(0x1000,4); 318 | } 319 | 320 | static int tbs6308_read_mac_ext(struct tbsecp3_adapter *adap) 321 | { 322 | struct tbsecp3_dev *dev = adap->dev; 323 | int ret = 1; 324 | int i =0; 325 | u32 postaddr; 326 | unsigned char tmpbuf[4]={0}; 327 | unsigned char rdbuffer[8]={0}; 328 | 329 | postaddr = 0x80 *((adap->nr)%4) +0x08; 330 | 331 | tmpbuf[0] = 0x31; //24cxx read; 332 | tmpbuf[1] = 6; //how many byte; 333 | tmpbuf[2] = (postaddr>>8); 334 | tmpbuf[3] = (postaddr &255); //24cxx sub_address,0x08 for mac 335 | 336 | 337 | tbs_write_ext( adap, BASE_ADDRESS_24CXX, CMD_24CXX, *(u32 *)&tmpbuf[0] ); 338 | //wait... until the data are received correctly; 339 | for(i=0;i<200;i++) 340 | { 341 | msleep(1); 342 | *(u32 *)tmpbuf = tbs_read_ext( adap, BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 343 | if((tmpbuf[0]&1) == 0) 344 | break; 345 | } 346 | if(i==200) 347 | { 348 | //printk(" the receiver always busy !\n"); 349 | ret = 0; 350 | //check mcu status 351 | *(u32 *)tmpbuf = tbs_read_ext(adap, BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 352 | if((tmpbuf[0]&0x4) == 1) // bit2==1 mcu busy 353 | { 354 | //printk("MCU status is busy!!!\n" ); 355 | // release cs; 356 | tbs_write_ext( adap,BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 357 | ret = 0; 358 | } 359 | 360 | } 361 | // release cs; 362 | tbs_write_ext( adap, BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 363 | //check the write finished; 364 | for(i=0;i<200;i++) 365 | { 366 | msleep(1); 367 | *(u32 *)tmpbuf = tbs_read_ext( adap, BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 368 | if((tmpbuf[0]&1) == 1) 369 | break; 370 | } 371 | if(i==200) 372 | { 373 | //printk(" wait wt_24cxx_done timeout! \n"); 374 | ret=0; 375 | } 376 | //read back to host; 377 | *(u32 *)rdbuffer = tbs_read_ext( adap, BASE_ADDRESS_24CXX, DATA0_24CXX ); 378 | *(u32 *)&rdbuffer[4] = tbs_read_ext( adap, BASE_ADDRESS_24CXX, DATA1_24CXX ); 379 | 380 | if(ret!=0) 381 | { 382 | memcpy(adap->dvb_adapter.proposed_mac, rdbuffer,6); 383 | printk("adapter %d ,mac address: %x,%x,%x,%x,%x,%x \n",adap->dvb_adapter.num,rdbuffer[0],rdbuffer[1],rdbuffer[2],rdbuffer[3],rdbuffer[4],rdbuffer[5]); 384 | } 385 | return ret; 386 | }; 387 | 388 | static void tbs6301_read_mac(struct tbsecp3_adapter *adap) 389 | { 390 | struct tbsecp3_dev *dev = adap->dev; 391 | 392 | int i =0; 393 | unsigned char tmpbuf[4]={0}; 394 | unsigned char rdbuffer[8]={0}; 395 | 396 | tmpbuf[0] = 0x31; //24cxx read; 397 | tmpbuf[1] = 6; //how many byte; 398 | tmpbuf[2] = 0; 399 | tmpbuf[3] = 0x08; //24cxx sub_address,0x08 for mac 400 | 401 | tbs_write( BASE_ADDRESS_24CXX, CMD_24CXX, *(u32 *)&tmpbuf[0] ); 402 | //wait... until the data are received correctly; 403 | for(i=0;i<100;i++) 404 | { 405 | msleep(1); 406 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 407 | if((tmpbuf[0]&1) == 0) 408 | break; 409 | } 410 | if(i==100) 411 | { 412 | printk(" the receiver always busy !\n"); 413 | //check mcu status 414 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 415 | if((tmpbuf[0]&0x4) == 1) // bit2==1 mcu busy 416 | { 417 | printk("MCU status is busy!!!\n" ); 418 | // release cs; 419 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 420 | return; 421 | } 422 | 423 | } 424 | // release cs; 425 | tbs_write( BASE_ADDRESS_24CXX, CS_RELEASE, *(u32 *)&tmpbuf[0] ); 426 | //check the write finished; 427 | for(i=0;i<100;i++) 428 | { 429 | msleep(1); 430 | *(u32 *)tmpbuf = tbs_read( BASE_ADDRESS_24CXX, STATUS_MAC16_24CXX ); 431 | if((tmpbuf[0]&1) == 1) 432 | break; 433 | } 434 | if(i==100) 435 | { 436 | printk(" wait wt_24cxx_done timeout! \n"); 437 | } 438 | //read back to host; 439 | *(u32 *)rdbuffer = tbs_read( BASE_ADDRESS_24CXX, DATA0_24CXX ); 440 | *(u32 *)&rdbuffer[4] = tbs_read( BASE_ADDRESS_24CXX, DATA1_24CXX ); 441 | memcpy(adap->dvb_adapter.proposed_mac, rdbuffer,6); 442 | printk(" tbs6301 mac address: %x,%x,%x,%x,%x,%x \n",rdbuffer[0],rdbuffer[1],rdbuffer[2],rdbuffer[3],rdbuffer[4],rdbuffer[5]); 443 | 444 | return ; 445 | }; 446 | 447 | 448 | static int tbsecp3_set_voltage(struct dvb_frontend* fe, 449 | enum fe_sec_voltage voltage) 450 | { 451 | struct sec_priv *priv = fe->sec_priv; 452 | struct tbsecp3_gpio_config *cfg = &priv->adap->cfg->gpio; 453 | struct tbsecp3_dev *dev = priv->adap->dev; 454 | 455 | dev_dbg(&dev->pci_dev->dev, "%s() %s\n", __func__, 456 | voltage == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" : 457 | voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : 458 | "SEC_VOLTAGE_OFF"); 459 | 460 | switch (voltage) { 461 | case SEC_VOLTAGE_13: 462 | tbsecp3_gpio_set_pin(dev, &cfg->lnb_power, 1); 463 | tbsecp3_gpio_set_pin(dev, &cfg->lnb_voltage, 0); 464 | break; 465 | case SEC_VOLTAGE_18: 466 | tbsecp3_gpio_set_pin(dev, &cfg->lnb_power, 1); 467 | tbsecp3_gpio_set_pin(dev, &cfg->lnb_voltage, 1); 468 | break; 469 | default: /* OFF */ 470 | tbsecp3_gpio_set_pin(dev, &cfg->lnb_power, 0); 471 | break; 472 | } 473 | 474 | if (priv->set_voltage) 475 | return priv->set_voltage(fe, voltage); 476 | else 477 | return 0; 478 | } 479 | 480 | static void tbsecp3_release_sec(struct dvb_frontend* fe) 481 | { 482 | struct sec_priv *priv; 483 | 484 | if (fe == NULL) 485 | return; 486 | 487 | priv = fe->sec_priv; 488 | if (priv == NULL) 489 | return; 490 | 491 | fe->ops.set_voltage = priv->set_voltage; 492 | fe->sec_priv = NULL; 493 | kfree(priv); 494 | } 495 | 496 | static struct dvb_frontend *tbsecp3_attach_sec(struct tbsecp3_adapter *adap, struct dvb_frontend *fe) 497 | { 498 | struct sec_priv *priv; 499 | 500 | priv = kzalloc(sizeof(struct sec_priv), GFP_KERNEL); 501 | if (!priv) 502 | return NULL; 503 | 504 | priv->set_voltage = fe->ops.set_voltage; 505 | priv->adap = adap; 506 | 507 | // fe->ops.release_sec = tbsecp3_release_sec; 508 | fe->ops.set_voltage = tbsecp3_set_voltage; 509 | fe->sec_priv = priv; 510 | 511 | return fe; 512 | } 513 | 514 | static int set_mac_address(struct tbsecp3_adapter *adap) 515 | { 516 | struct tbsecp3_dev *dev = adap->dev; 517 | u8 eeprom_bus_nr = dev->info->eeprom_i2c; 518 | struct i2c_adapter *i2c = &dev->i2c_bus[eeprom_bus_nr].i2c_adap; 519 | u8 eep_addr = 0xa0; 520 | int ret; 521 | 522 | struct i2c_msg msg[] = { 523 | { .addr = 0x50, .flags = 0, 524 | .buf = &eep_addr, .len = 1 }, 525 | { .addr = 0x50, .flags = I2C_M_RD, 526 | .buf = adap->dvb_adapter.proposed_mac, .len = 6 } 527 | }; 528 | 529 | if (dev->info->eeprom_addr) 530 | eep_addr = dev->info->eeprom_addr; 531 | 532 | eep_addr += 0x10 * adap->nr; 533 | 534 | ret = i2c_transfer(i2c, msg, 2); 535 | ret = i2c_transfer(i2c, msg, 2); 536 | if (ret != 2) { 537 | dev_warn(&dev->pci_dev->dev, 538 | "error reading MAC address for adapter %d\n", 539 | adap->nr); 540 | } else { 541 | dev_info(&dev->pci_dev->dev, 542 | "MAC address %pM\n", adap->dvb_adapter.proposed_mac); 543 | } 544 | return 0; 545 | }; 546 | 547 | static int start_feed(struct dvb_demux_feed *dvbdmxfeed) 548 | { 549 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 550 | struct tbsecp3_adapter *adapter = dvbdmx->priv; 551 | 552 | if (!adapter->feeds) 553 | tbsecp3_dma_enable(adapter); 554 | 555 | return ++adapter->feeds; 556 | } 557 | 558 | static int stop_feed(struct dvb_demux_feed *dvbdmxfeed) 559 | { 560 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 561 | struct tbsecp3_adapter *adapter = dvbdmx->priv; 562 | 563 | if (--adapter->feeds) 564 | return adapter->feeds; 565 | 566 | tbsecp3_dma_disable(adapter); 567 | return 0; 568 | } 569 | 570 | static void reset_demod(struct tbsecp3_adapter *adapter) 571 | { 572 | struct tbsecp3_dev *dev = adapter->dev; 573 | struct tbsecp3_gpio_pin *reset = &adapter->cfg->gpio.demod_reset; 574 | 575 | tbsecp3_gpio_set_pin(dev, reset, 1); 576 | usleep_range(10000, 20000); 577 | 578 | tbsecp3_gpio_set_pin(dev, reset, 0); 579 | usleep_range(50000, 100000); 580 | } 581 | 582 | 583 | #ifdef TBS_DVB_EXTENSION 584 | static struct tas2101_config tbs6902_demod_cfg[] = { 585 | { 586 | .i2c_address = 0x60, 587 | .id = ID_TAS2101, 588 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, 589 | .init2 = 0, 590 | .write_properties = ecp3_spi_write, 591 | .read_properties = ecp3_spi_read, 592 | 593 | }, 594 | { 595 | .i2c_address = 0x68, 596 | .id = ID_TAS2101, 597 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 598 | .init2 = 0, 599 | .write_properties = ecp3_spi_write, 600 | .read_properties = ecp3_spi_read, 601 | } 602 | }; 603 | 604 | static struct gx1133_config tbs6902_gx1133_cfg[] = { 605 | { 606 | .i2c_address = 0x52, 607 | .ts_mode = 0, 608 | .ts_cfg = {data_0,data_1,data_2,data_3,data_4,data_5,data_6, \ 609 | data_7,ts_sync,ts_valid,ts_clk,ts_err}, 610 | .write_properties = ecp3_spi_write, 611 | .read_properties = ecp3_spi_read, 612 | 613 | }, 614 | { 615 | .i2c_address = 0x5A, 616 | .ts_mode = 0, 617 | .ts_cfg = {data_0,data_1,data_2,data_3,data_4,data_5,data_6, \ 618 | data_7,ts_sync,ts_valid,ts_clk,ts_err}, 619 | .write_properties = ecp3_spi_write, 620 | .read_properties = ecp3_spi_read, 621 | } 622 | }; 623 | 624 | static struct av201x_config tbs6902_av201x_cfg = { 625 | .i2c_address = 0x62, 626 | .id = ID_AV2012, 627 | .xtal_freq = 27000, /* kHz */ 628 | }; 629 | 630 | static struct tas2101_config tbs6301se_demod_cfg = { 631 | .i2c_address = 0x60, 632 | .id = ID_TAS2101, 633 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 634 | .init2 = 0, 635 | .write_properties = ecp3_spi_write, 636 | .read_properties = ecp3_spi_read, 637 | 638 | .mcuWrite_properties = mcu_24cxx_write, 639 | .mcuRead_properties = mcu_24cxx_read, 640 | 641 | }; 642 | 643 | 644 | static struct tas2101_config tbs6302se_demod_cfg[] = { 645 | 646 | { 647 | .i2c_address = 0x68, 648 | .id = ID_TAS2101, 649 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 650 | .init2 = 0, 651 | .write_properties = ecp3_spi_write, 652 | .read_properties = ecp3_spi_read, 653 | 654 | .mcuWrite_properties = mcu_24cxx_write, 655 | .mcuRead_properties = mcu_24cxx_read, 656 | }, 657 | 658 | { 659 | .i2c_address = 0x68, 660 | .id = ID_TAS2101, 661 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 662 | .init2 = 0, 663 | .write_properties = ecp3_spi_write, 664 | .read_properties = ecp3_spi_read, 665 | 666 | .mcuWrite_properties = mcu_24cxx_write, 667 | .mcuRead_properties = mcu_24cxx_read, 668 | } 669 | }; 670 | static struct tas2101_config tbs6308_demod_cfg = { 671 | .i2c_address = 0x60, 672 | .id = ID_TAS2101, 673 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 674 | .init2 = 0, 675 | .write_properties = ecp3_spi_write, 676 | .read_properties = ecp3_spi_read, 677 | 678 | .mcuWrite_properties = mcu_24cxx_write, 679 | .mcuRead_properties = mcu_24cxx_read, 680 | 681 | }; 682 | 683 | static struct tas2101_config tbs6304_demod_cfg[] = { 684 | { 685 | .i2c_address = 0x60, 686 | .id = ID_TAS2101, 687 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 688 | .init2 = 0, 689 | .write_properties = ecp3_spi_write, 690 | .read_properties = ecp3_spi_read, 691 | 692 | .mcuWrite_properties = mcu_24cxx_write, 693 | .mcuRead_properties = mcu_24cxx_read, 694 | }, 695 | { 696 | .i2c_address = 0x68, 697 | .id = ID_TAS2101, 698 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 699 | .init2 = 0, 700 | .write_properties = ecp3_spi_write, 701 | .read_properties = ecp3_spi_read, 702 | 703 | .mcuWrite_properties = mcu_24cxx_write, 704 | .mcuRead_properties = mcu_24cxx_read, 705 | }, 706 | { 707 | .i2c_address = 0x60, 708 | .id = ID_TAS2101, 709 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 710 | .init2 = 0, 711 | .write_properties = ecp3_spi_write, 712 | .read_properties = ecp3_spi_read, 713 | 714 | .mcuWrite_properties = mcu_24cxx_write, 715 | .mcuRead_properties = mcu_24cxx_read, 716 | }, 717 | { 718 | .i2c_address = 0x68, 719 | .id = ID_TAS2101, 720 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 721 | .init2 = 0, 722 | .write_properties = ecp3_spi_write, 723 | .read_properties = ecp3_spi_read, 724 | 725 | .mcuWrite_properties = mcu_24cxx_write, 726 | .mcuRead_properties = mcu_24cxx_read, 727 | } 728 | }; 729 | static struct tas2101_config tbs6301_demod_cfg = { 730 | .i2c_address = 0x60, 731 | .id = ID_TAS2101, 732 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 733 | .init2 = 0, 734 | .write_properties = ecp3_spi_write, 735 | .read_properties = ecp3_spi_read, 736 | 737 | .mcuWrite_properties = mcu_24cxx_write, 738 | .mcuRead_properties = mcu_24cxx_read, 739 | 740 | }; 741 | 742 | 743 | static struct tas2101_config tbs6304x_demod_cfg = { 744 | .i2c_address = 0x60, 745 | .id = ID_TAS2101, 746 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 747 | .init2 = 0, 748 | .write_properties = ecp3_spi_write, 749 | .read_properties = ecp3_spi_read, 750 | 751 | .mcuWrite_properties = mcu_24cxx_write, 752 | .mcuRead_properties = mcu_24cxx_read, 753 | 754 | }; 755 | 756 | static struct tas2101_config tbs6904_demod_cfg[] = { 757 | { 758 | .i2c_address = 0x60, 759 | .id = ID_TAS2101, 760 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, // 0xb1 761 | .init2 = 0, 762 | .write_properties = ecp3_spi_write, 763 | .read_properties = ecp3_spi_read, 764 | }, 765 | { 766 | .i2c_address = 0x68, 767 | .id = ID_TAS2101, 768 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, 769 | .init2 = 0, 770 | .write_properties = ecp3_spi_write, 771 | .read_properties = ecp3_spi_read, 772 | .write_eeprom = ecp3_eeprom_write, 773 | .read_eeprom = ecp3_eeprom_read, 774 | }, 775 | { 776 | .i2c_address = 0x60, 777 | .id = ID_TAS2101, 778 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, 779 | .init2 = 0, 780 | .write_properties = ecp3_spi_write, 781 | .read_properties = ecp3_spi_read, 782 | .write_eeprom = ecp3_eeprom_write, 783 | .read_eeprom = ecp3_eeprom_read, 784 | }, 785 | { 786 | .i2c_address = 0x68, 787 | .id = ID_TAS2101, 788 | .init = {0xb0, 0x32, 0x81, 0x57, 0x64, 0x9a, 0x33}, 789 | .init2 = 0, 790 | .write_properties = ecp3_spi_write, 791 | .read_properties = ecp3_spi_read, 792 | .write_eeprom = ecp3_eeprom_write, 793 | .read_eeprom = ecp3_eeprom_read, 794 | } 795 | }; 796 | 797 | static struct av201x_config tbs6904_av201x_cfg = { 798 | .i2c_address = 0x63, 799 | .id = ID_AV2012, 800 | .xtal_freq = 27000, /* kHz */ 801 | }; 802 | 803 | 804 | static struct tas2101_config tbs6910_demod_cfg[] = { 805 | { 806 | .i2c_address = 0x68, 807 | .id = ID_TAS2101, 808 | .init = {0x21, 0x43, 0x65, 0xb0, 0xa8, 0x97, 0xb1}, 809 | .init2 = 0, 810 | .write_properties = ecp3_spi_write, 811 | .read_properties = ecp3_spi_read, 812 | .write_eeprom = ecp3_eeprom_write, 813 | .read_eeprom = ecp3_eeprom_read, 814 | }, 815 | { 816 | .i2c_address = 0x60, 817 | .id = ID_TAS2101, 818 | .init = {0xb0, 0xa8, 0x21, 0x43, 0x65, 0x97, 0xb1}, 819 | .init2 = 0, 820 | .write_properties = ecp3_spi_write, 821 | .read_properties = ecp3_spi_read, 822 | .write_eeprom = ecp3_eeprom_write, 823 | .read_eeprom = ecp3_eeprom_read, 824 | }, 825 | }; 826 | 827 | static struct av201x_config tbs6910_av201x_cfg = { 828 | .i2c_address = 0x62, 829 | .id = ID_AV2018, 830 | .xtal_freq = 27000, /* kHz */ 831 | }; 832 | 833 | 834 | static int max_set_voltage(struct i2c_adapter *i2c, 835 | enum fe_sec_voltage voltage, u8 rf_in) 836 | { 837 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 838 | struct tbsecp3_dev *dev = i2c_adap->dev; 839 | 840 | u32 val, reg; 841 | 842 | //printk("set voltage on %u = %d\n", rf_in, voltage); 843 | 844 | if (rf_in > 3) 845 | return -EINVAL; 846 | 847 | reg = rf_in * 4; 848 | val = tbs_read(TBSECP3_GPIO_BASE, reg) & ~4; 849 | 850 | switch (voltage) { 851 | case SEC_VOLTAGE_13: 852 | val &= ~2; 853 | break; 854 | case SEC_VOLTAGE_18: 855 | val |= 2; 856 | break; 857 | case SEC_VOLTAGE_OFF: 858 | default: 859 | //val |= 4; 860 | break; 861 | } 862 | 863 | tbs_write(TBSECP3_GPIO_BASE, reg, val); 864 | return 0; 865 | } 866 | 867 | static int max_send_master_cmd(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) 868 | { 869 | //printk("send master cmd\n"); 870 | return 0; 871 | } 872 | static int max_send_burst(struct dvb_frontend *fe, enum fe_sec_mini_cmd burst) 873 | { 874 | //printk("send burst: %d\n", burst); 875 | return 0; 876 | } 877 | static void RF_switch(struct i2c_adapter *i2c,u8 rf_in,u8 flag)//flag : 0: dvbs/s2 signal 1:Terrestrial and cable signal 878 | { 879 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 880 | struct tbsecp3_dev *dev = i2c_adap->dev; 881 | u32 val ,reg; 882 | 883 | if (flag) 884 | tbsecp3_gpio_set_pin(dev, &dev->adapter[rf_in].cfg->gpio.lnb_power, 0); 885 | 886 | reg = 0x8+rf_in*4; 887 | 888 | val = tbs_read(TBSECP3_GPIO_BASE, reg); 889 | if(flag) 890 | val |= 2; 891 | else 892 | val &= ~2; 893 | 894 | tbs_write(TBSECP3_GPIO_BASE, reg, val); 895 | 896 | } 897 | 898 | static struct mxl58x_cfg tbs6909_mxl58x_cfg = { 899 | .adr = 0x60, 900 | .type = 0x01, 901 | .clk = 24000000, 902 | .cap = 12, 903 | .fw_read = NULL, 904 | 905 | .set_voltage = max_set_voltage, 906 | .write_properties = ecp3_spi_write, 907 | .read_properties = ecp3_spi_read, 908 | .write_eeprom = ecp3_eeprom_write, 909 | .read_eeprom = ecp3_eeprom_read, 910 | }; 911 | 912 | static struct stv091x_cfg tbs6903_stv0910_cfg = { 913 | .adr = 0x68, 914 | .parallel = 1, 915 | .rptlvl = 3, 916 | .clk = 30000000, 917 | .dual_tuner = 1, 918 | .write_properties = ecp3_spi_write, 919 | .read_properties = ecp3_spi_read, 920 | .write_eeprom = ecp3_eeprom_write, 921 | .read_eeprom = ecp3_eeprom_read, 922 | }; 923 | 924 | struct stv6120_cfg tbs6903_stv6120_cfg = { 925 | .adr = 0x60, 926 | .Rdiv = 2, 927 | .xtal = 30000, 928 | }; 929 | 930 | 931 | static struct av201x_config tbs6522_av201x_cfg[] = { 932 | { 933 | .i2c_address = 0x63, 934 | .id = ID_AV2018, 935 | .xtal_freq = 27000, 936 | }, 937 | { 938 | .i2c_address = 0x62, 939 | .id = ID_AV2018, 940 | .xtal_freq = 27000, 941 | }, 942 | }; 943 | 944 | static void Set_TSsampling(struct i2c_adapter *i2c,int tuner,int time) 945 | { 946 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 947 | struct tbsecp3_dev *dev = i2c_adap->dev; 948 | 949 | u32 Many_cnt; 950 | u32 iobuffer; 951 | char tmp[4]; 952 | 953 | Many_cnt = 0x3B9ACA00/8*time; 954 | tmp[0] = (Many_cnt>>24)&0xff; 955 | tmp[1] = (Many_cnt>>16)&0xff; 956 | tmp[2] = (Many_cnt>>8)&0xff; 957 | tmp[3] = Many_cnt&0xff; 958 | 959 | iobuffer = tmp[0]|(tmp[1]<<8)|(tmp[2]<<16)|(tmp[3]<<24); 960 | 961 | tbs_write(TBSECP3_GPIO_BASE, (0xc+tuner)*4,iobuffer); 962 | 963 | } 964 | 965 | static u32 Set_TSparam(struct i2c_adapter *i2c,int tuner,int time,bool flag) 966 | { 967 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 968 | struct tbsecp3_dev *dev = i2c_adap->dev; 969 | 970 | u32 iobuffer; 971 | u32 Frm_cnt,Bit_rate,Many_cnt; 972 | int clk_preset; 973 | u8 tmp[4]; 974 | 975 | Many_cnt = 0x3B9ACA00/8*time; 976 | 977 | iobuffer = tbs_read(TBSECP3_GPIO_BASE, (0x10+tuner)*4); 978 | tmp[0] = (iobuffer>>24)&0xff; 979 | tmp[1] = (iobuffer>>16)&0xff; 980 | tmp[2] = (iobuffer>>8)&0xff; 981 | tmp[3] = iobuffer&0xff; 982 | 983 | Bit_rate= tmp[0]|(tmp[1]<<8)|(tmp[2]<<16)|(tmp[3]<<24); 984 | 985 | if(!flag) 986 | return Bit_rate; 987 | 988 | Frm_cnt = Many_cnt/(Bit_rate-50) -100; 989 | 990 | tmp[0] = (Frm_cnt>>24)&0xff; 991 | tmp[1] = (Frm_cnt>>16)&0xff; 992 | tmp[2] = (Frm_cnt>>8)&0xff; 993 | tmp[3] = Frm_cnt&0xff; 994 | 995 | iobuffer= tmp[0]|(tmp[1]<<8)|(tmp[2]<<16)|(tmp[3]<<24); 996 | 997 | tbs_write(TBSECP3_GPIO_BASE, (0xA+tuner)*4,iobuffer); 998 | 999 | if( Frm_cnt==0) return 0; 1000 | 1001 | //set ci clk preset 1002 | clk_preset = Frm_cnt/408; 1003 | if(clk_preset>0xf)clk_preset=0xf; 1004 | iobuffer = tbs_read(tuner?0x7000:0x6000,0x04*4); 1005 | iobuffer = (iobuffer&0xF0FFFFFF)|(clk_preset<<24); 1006 | 1007 | tbs_write(tuner?0x7000:0x6000,0x04*4,iobuffer); 1008 | 1009 | return 1; 1010 | 1011 | } 1012 | 1013 | static struct stid135_cfg tbs6903x_stid135_cfg = { 1014 | .adr = 0x68, 1015 | .clk = 27, 1016 | .ts_mode = TS_2PAR, 1017 | .set_voltage = NULL, 1018 | .write_properties = ecp3_spi_write, 1019 | .read_properties = ecp3_spi_read, 1020 | .write_eeprom = ecp3_eeprom_write, 1021 | .read_eeprom = ecp3_eeprom_read, 1022 | .set_TSsampling = NULL, 1023 | .set_TSparam = NULL, 1024 | .vglna = 0, 1025 | .control_22k = true, 1026 | }; 1027 | 1028 | static struct stid135_cfg tbs6909x_stid135_cfg = { 1029 | .adr = 0x68, 1030 | .clk = 27, 1031 | .ts_mode = TS_STFE, 1032 | .set_voltage = max_set_voltage, 1033 | .write_properties = ecp3_spi_write, 1034 | .read_properties = ecp3_spi_read, 1035 | .write_eeprom = ecp3_eeprom_write, 1036 | .read_eeprom = ecp3_eeprom_read, 1037 | .set_TSsampling = NULL, 1038 | .set_TSparam = NULL, 1039 | .vglna = 0, 1040 | .control_22k = true, 1041 | 1042 | }; 1043 | static struct stid135_cfg tbs6903x_V2_stid135_cfg = { 1044 | .adr = 0x68, 1045 | .clk = 27, 1046 | .ts_mode = TS_2PAR, 1047 | .set_voltage = NULL, 1048 | .write_properties = ecp3_spi_write, 1049 | .read_properties = ecp3_spi_read, 1050 | .write_eeprom = ecp3_eeprom_write, 1051 | .read_eeprom = ecp3_eeprom_read, 1052 | .set_TSsampling = NULL, 1053 | .set_TSparam = NULL, 1054 | .vglna = 1, 1055 | .control_22k = true, 1056 | }; 1057 | 1058 | static struct stid135_cfg tbs6909x_V2_stid135_cfg = { 1059 | .adr = 0x68, 1060 | .clk = 27, 1061 | .ts_mode = TS_STFE, 1062 | .set_voltage = max_set_voltage, 1063 | .write_properties = ecp3_spi_write, 1064 | .read_properties = ecp3_spi_read, 1065 | .write_eeprom = ecp3_eeprom_write, 1066 | .read_eeprom = ecp3_eeprom_read, 1067 | .set_TSsampling = NULL, 1068 | .set_TSparam = NULL, 1069 | .vglna = 2, 1070 | .control_22k = true, 1071 | }; 1072 | 1073 | static struct stid135_cfg tbs6912_stid135_cfg = { 1074 | .adr = 0x68, 1075 | .clk = 27, 1076 | .ts_mode = TS_2PAR, 1077 | .set_voltage = NULL, 1078 | .write_properties = ecp3_spi_write, 1079 | .read_properties = ecp3_spi_read, 1080 | .write_eeprom = ecp3_eeprom_write, 1081 | .read_eeprom = ecp3_eeprom_read, 1082 | .set_TSsampling = Set_TSsampling, 1083 | .set_TSparam = Set_TSparam, 1084 | .vglna = false, 1085 | .control_22k = true, 1086 | }; 1087 | 1088 | static struct stid135_cfg tbs6916_stid135_cfg[] = { 1089 | { 1090 | .adr = 0x68, 1091 | .clk = 27, 1092 | .ts_mode = TS_STFE, 1093 | .set_voltage = max_set_voltage, 1094 | .write_properties = ecp3_spi_write, 1095 | .read_properties = ecp3_spi_read, 1096 | .write_eeprom = ecp3_eeprom_write, 1097 | .read_eeprom = ecp3_eeprom_read, 1098 | .set_TSsampling = NULL, 1099 | .set_TSparam = NULL, 1100 | .vglna =false, 1101 | .control_22k = true, 1102 | }, 1103 | { 1104 | .adr = 0x68, 1105 | .clk = 27, 1106 | .ts_mode = TS_STFE, 1107 | .set_voltage = max_set_voltage, 1108 | .write_properties = NULL, 1109 | .read_properties = NULL, 1110 | .set_TSsampling = NULL, 1111 | .set_TSparam = NULL, 1112 | .vglna =false, 1113 | .control_22k = false, 1114 | }, 1115 | 1116 | }; 1117 | static struct rda5816_config rda5816_cfg[] = { 1118 | { 1119 | .i2c_adr = 0x8, 1120 | .xtal = 1, //1=27M 0=24M 1121 | }, 1122 | { 1123 | .i2c_adr = 0x9, 1124 | .xtal = 1, 1125 | }, 1126 | }; 1127 | static struct mndmd_config tbs6704_cfg={ 1128 | .tuner_address = 0x60, 1129 | }; 1130 | static void SetSpeedstatus(struct i2c_adapter *i2c,int tuner) 1131 | { 1132 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 1133 | struct tbsecp3_dev *dev = i2c_adap->dev; 1134 | 1135 | if(tuner) 1136 | tbs_write(0x7000, 0x1c,0x11111111); 1137 | else 1138 | tbs_write(0x6000, 0x1c,0x01010101); 1139 | 1140 | return ; 1141 | } 1142 | static int GetSpeedstatus(struct i2c_adapter *i2c,int tuner) 1143 | { 1144 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 1145 | struct tbsecp3_dev *dev = i2c_adap->dev; 1146 | u32 iobuffer; 1147 | u8 tmp; 1148 | if(tuner){ 1149 | iobuffer = tbs_read(0x7000,0x1c); 1150 | iobuffer = tbs_read(0x7000,0x1c); 1151 | } 1152 | else 1153 | { 1154 | iobuffer = tbs_read(0x6000,0x1c); 1155 | iobuffer = tbs_read(0x6000,0x1c); 1156 | } 1157 | 1158 | tmp = iobuffer&0xff; 1159 | 1160 | return tmp; 1161 | } 1162 | 1163 | static void Set_TSsamplingtimes(struct i2c_adapter *i2c,int tuner,int time) 1164 | { 1165 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 1166 | struct tbsecp3_dev *dev = i2c_adap->dev; 1167 | 1168 | u32 Many_cnt; 1169 | u32 iobuffer; 1170 | char tmp[4]; 1171 | 1172 | Many_cnt = time*1000000/8; 1173 | tmp[0] = (Many_cnt>>24)&0xff; 1174 | tmp[1] = (Many_cnt>>16)&0xff; 1175 | tmp[2] = (Many_cnt>>8)&0xff; 1176 | tmp[3] = Many_cnt&0xff; 1177 | 1178 | iobuffer = tmp[0]|(tmp[1]<<8)|(tmp[2]<<16)|(tmp[3]<<24); 1179 | 1180 | tbs_write(TBSECP3_GPIO_BASE, 0x30+tuner*4,iobuffer); 1181 | 1182 | } 1183 | static int GetTSSpeed(struct i2c_adapter *i2c,int tuner) 1184 | { 1185 | struct tbsecp3_i2c *i2c_adap = i2c_get_adapdata(i2c); 1186 | struct tbsecp3_dev *dev = i2c_adap->dev; 1187 | u32 iobuffer = 0; 1188 | u8 tmp[4]; 1189 | u32 bit_rate = 0; 1190 | iobuffer = tbs_read(TBSECP3_GPIO_BASE, 0x40+tuner*4); 1191 | tmp[0] = (iobuffer>>24)&0xff; 1192 | tmp[1] = (iobuffer>>16)&0xff; 1193 | tmp[2] = (iobuffer>>8)&0xff; 1194 | tmp[3] = iobuffer&0xff; 1195 | 1196 | bit_rate= tmp[0]|(tmp[1]<<8)|(tmp[2]<<16)|(tmp[3]<<24); 1197 | 1198 | return bit_rate; 1199 | } 1200 | static int SetCIClock(struct i2c_adapter *i2c,int tuner) 1201 | { 1202 | u32 clock = 0; 1203 | int stat = 0; 1204 | u32 speed = 0; 1205 | msleep(50); 1206 | SetSpeedstatus(i2c,tuner); 1207 | msleep(50); 1208 | while(!stat){ 1209 | stat=GetSpeedstatus(i2c,tuner); 1210 | msleep(10); 1211 | } 1212 | speed = GetTSSpeed(i2c,tuner); 1213 | clock = ((speed*4)*204*8/1024)+500; //khz 1214 | if(clock<42000) 1215 | clock = 42000; 1216 | 1217 | // printk("clock = %d,value = %d\n",clock,value); 1218 | return clock; 1219 | } 1220 | static struct cxd2878_config tbs6209se_cfg[] = { 1221 | { 1222 | .addr_slvt = 0x64, 1223 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1224 | .tuner_addr = 0x60, 1225 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1226 | .ts_mode = 0, 1227 | .ts_ser_data = 0, 1228 | .ts_clk = 1, 1229 | .ts_valid = 0, 1230 | .atscCoreDisable = 0, 1231 | .write_properties = ecp3_spi_write, 1232 | .read_properties = ecp3_spi_read, 1233 | .write_eeprom = ecp3_eeprom_write, 1234 | .read_eeprom = ecp3_eeprom_read, 1235 | }, 1236 | { 1237 | .addr_slvt = 0x6c, 1238 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1239 | .tuner_addr = 0x60, 1240 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1241 | .ts_mode = 0, 1242 | .ts_ser_data = 0, 1243 | .ts_clk = 1, 1244 | .ts_valid = 0, 1245 | .atscCoreDisable = 0, 1246 | .write_properties = ecp3_spi_write, 1247 | .read_properties = ecp3_spi_read, 1248 | .write_eeprom = ecp3_eeprom_write, 1249 | .read_eeprom = ecp3_eeprom_read, 1250 | }, 1251 | 1252 | { 1253 | .addr_slvt = 0x65, 1254 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1255 | .tuner_addr = 0x60, 1256 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1257 | .ts_mode = 0, 1258 | .ts_ser_data = 0, 1259 | .ts_clk = 1, 1260 | .ts_valid = 0, 1261 | .atscCoreDisable = 0, 1262 | .write_properties = ecp3_spi_write, 1263 | .read_properties = ecp3_spi_read, 1264 | .write_eeprom = ecp3_eeprom_write, 1265 | .read_eeprom = ecp3_eeprom_read, 1266 | }, 1267 | { 1268 | .addr_slvt = 0x6D, 1269 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1270 | .tuner_addr = 0x60, 1271 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1272 | .ts_mode = 0, 1273 | .ts_ser_data = 0, 1274 | .ts_clk = 1, 1275 | .ts_clk_mask = 0, 1276 | .ts_valid = 0, 1277 | .atscCoreDisable = 0, 1278 | .write_properties = ecp3_spi_write, 1279 | .read_properties = ecp3_spi_read, 1280 | .write_eeprom = ecp3_eeprom_write, 1281 | .read_eeprom = ecp3_eeprom_read, 1282 | } 1283 | }; 1284 | 1285 | static struct cxd2878_config tbsserial_cfg = { 1286 | 1287 | .addr_slvt = 0x64, 1288 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1289 | .tuner_addr = 0x60, 1290 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1291 | .ts_mode = 0, 1292 | .ts_ser_data = 0, 1293 | .ts_clk = 1, 1294 | .ts_clk_mask = 0, 1295 | .ts_valid = 0, 1296 | .atscCoreDisable = 0, 1297 | .write_properties = ecp3_spi_write, 1298 | .read_properties = ecp3_spi_read, 1299 | }; 1300 | 1301 | static struct cxd2878_config cxd6802_parallel_cfg = { 1302 | 1303 | .addr_slvt = 0x64, 1304 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1305 | .tuner_addr = 0x60, 1306 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1307 | .ts_mode = 1, 1308 | .ts_ser_data = 0, 1309 | .ts_clk = 1, 1310 | .ts_clk_mask= 1, 1311 | .ts_valid = 0, 1312 | .atscCoreDisable = 0, 1313 | .lock_flag = 0, 1314 | .write_properties = ecp3_spi_write, 1315 | .read_properties = ecp3_spi_read, 1316 | }; 1317 | static struct cxd2878_config tbs6504h_cfg[] = { 1318 | { 1319 | .addr_slvt = 0x6c, 1320 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1321 | .tuner_addr = 0x60, 1322 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1323 | .ts_mode = 0, 1324 | .ts_ser_data = 0, 1325 | .ts_clk = 1, 1326 | .ts_valid = 0, 1327 | .atscCoreDisable = 0, 1328 | .write_properties = ecp3_spi_write, 1329 | .read_properties = ecp3_spi_read, 1330 | .write_eeprom = ecp3_eeprom_write, 1331 | .read_eeprom = ecp3_eeprom_read, 1332 | }, 1333 | { 1334 | .addr_slvt = 0x64, 1335 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1336 | .tuner_addr = 0x60, 1337 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1338 | .ts_mode = 0, 1339 | .ts_ser_data = 0, 1340 | .ts_clk = 1, 1341 | .ts_valid = 0, 1342 | .atscCoreDisable = 0, 1343 | .write_properties = ecp3_spi_write, 1344 | .read_properties = ecp3_spi_read, 1345 | .write_eeprom = ecp3_eeprom_write, 1346 | .read_eeprom = ecp3_eeprom_read, 1347 | }, 1348 | 1349 | }; 1350 | 1351 | static struct cxd2878_config tbs6590se_cfg[] = { 1352 | { 1353 | .addr_slvt = 0x64, 1354 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1355 | .tuner_addr = 0x60, 1356 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1357 | .ts_mode = 1, 1358 | .ts_ser_data = 0, 1359 | .ts_clk = 1, 1360 | .ts_clk_mask= 1, 1361 | .ts_valid = 0, 1362 | .atscCoreDisable = 0, 1363 | .lock_flag = 0, 1364 | .write_properties = ecp3_spi_write, 1365 | .read_properties = ecp3_spi_read, 1366 | .write_eeprom = ecp3_eeprom_write, 1367 | .read_eeprom = ecp3_eeprom_read, 1368 | .RF_switch = RF_switch, 1369 | .rf_port = 0, 1370 | }, 1371 | { 1372 | .addr_slvt = 0x64, 1373 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1374 | .tuner_addr = 0x60, 1375 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1376 | .ts_mode = 1, 1377 | .ts_ser_data = 0, 1378 | .ts_clk = 1, 1379 | .ts_clk_mask= 1, 1380 | .ts_valid = 0, 1381 | .atscCoreDisable = 0, 1382 | .lock_flag = 0, 1383 | .write_properties = ecp3_spi_write, 1384 | .read_properties = ecp3_spi_read, 1385 | .write_eeprom = ecp3_eeprom_write, 1386 | .read_eeprom = ecp3_eeprom_read, 1387 | .RF_switch = RF_switch, 1388 | .rf_port = 1, 1389 | } 1390 | }; 1391 | #endif 1392 | 1393 | static struct cxd2857_config tbs6812_cfg[] = { 1394 | { 1395 | .addr_slvt = 0x64, 1396 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1397 | .tuner_addr = 0x60, 1398 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1399 | .tuner_index = 1, 1400 | .tlv_mode = 1, 1401 | }, 1402 | { 1403 | .addr_slvt = 0x64, 1404 | .xtal = SONY_DEMOD_XTAL_24000KHz, 1405 | .tuner_addr = 0x61, 1406 | .tuner_xtal = SONY_ASCOT3_XTAL_24000KHz, 1407 | .tuner_index = 2, 1408 | .tlv_mode = 1, 1409 | } 1410 | }; 1411 | static void tbs_octuples_reset_demod(struct tbsecp3_adapter *adapter) 1412 | { 1413 | struct tbsecp3_dev *dev = adapter->dev; 1414 | u32 tmp; 1415 | u32 gpio; 1416 | if(adapter->nr<4) 1417 | gpio= 0x4*(adapter->nr); 1418 | if(adapter->nr>3) 1419 | gpio = 0x2c+0x4*(adapter->nr-4); 1420 | 1421 | tmp = tbs_read(TBSECP3_GPIO_BASE, gpio); 1422 | tmp = tmp &0xfffffffe; 1423 | tbs_write(TBSECP3_GPIO_BASE, gpio, tmp); 1424 | msleep(50); 1425 | tmp = tmp|0x01; 1426 | tbs_write(TBSECP3_GPIO_BASE, gpio, tmp); 1427 | msleep(50); 1428 | } 1429 | static u32 tbs_FPGA_fireware_info(struct tbsecp3_adapter *adapter) 1430 | { 1431 | struct tbsecp3_dev *dev = adapter->dev; 1432 | u32 tmp; //hardware id 1433 | u32 data; //fw data; 1434 | tmp = tbs_read(TBSECP3_GPIO_BASE, 0x20); 1435 | data = tbs_read(TBSECP3_GPIO_BASE, 0x28); 1436 | printk("the device hardware id :%x,fw data: %x \n",tmp,data); 1437 | 1438 | if(ciclock){ 1439 | tbs_write(0x6000, 0x10, 0); //tuner 0 1440 | tbs_write(0x7000, 0x10, 0); //tuner 1 1441 | 1442 | }else{ 1443 | tbs_write(0x6000, 0x10, 0xffffffff); 1444 | tbs_write(0x7000, 0x10, 0xffffffff); 1445 | 1446 | } 1447 | 1448 | return data; 1449 | } 1450 | static void tbs6590se_reset_demod(struct tbsecp3_adapter *adapter) //for the cxd6802 1451 | { 1452 | struct tbsecp3_dev *dev = adapter->dev; 1453 | u32 tmp; 1454 | u32 gpio; 1455 | 1456 | gpio= 0x08+0x4*(adapter->nr); 1457 | 1458 | tmp = tbs_read(TBSECP3_GPIO_BASE, gpio); 1459 | tmp = tmp &0xfffffffe; 1460 | tbs_write(TBSECP3_GPIO_BASE, gpio, tmp); 1461 | msleep(50); 1462 | tmp = tmp|0x01; 1463 | tbs_write(TBSECP3_GPIO_BASE, gpio, tmp); 1464 | msleep(50); 1465 | 1466 | return ; 1467 | } 1468 | static int tbsecp3_frontend_attach(struct tbsecp3_adapter *adapter) 1469 | { 1470 | struct tbsecp3_dev *dev = adapter->dev; 1471 | struct pci_dev *pci = dev->pci_dev; 1472 | 1473 | #ifdef TBS_DVB_EXTENSION 1474 | struct si2168_config si2168_config; 1475 | struct si2183_config si2183_config; 1476 | struct si2157_config si2157_config; 1477 | //struct mn88436_config mn88436_config; 1478 | //struct mxl603_config mxl603_config; 1479 | struct mtv23x_config mtv23x_config; 1480 | struct gx1503_config gx1503_config; 1481 | struct m88rs6060_cfg m88rs6060_config; 1482 | #endif 1483 | struct i2c_board_info info; 1484 | struct i2c_adapter *i2c = &adapter->i2c->i2c_adap; 1485 | struct i2c_client *client_demod, *client_tuner; 1486 | 1487 | adapter->fe = NULL; 1488 | adapter->fe2 = NULL; 1489 | adapter->i2c_client_demod = NULL; 1490 | adapter->i2c_client_tuner = NULL; 1491 | 1492 | #ifdef TBS_DVB_EXTENSION 1493 | if((TBSECP3_BOARD_TBS6304 != dev->info->board_id) && (TBSECP3_BOARD_TBS6308 != dev->info->board_id) && (TBSECP3_BOARD_TBS6302SE != dev->info->board_id)&&(TBSECP3_BOARD_TBS6209SE != dev->info->board_id)&&(TBSECP3_BOARD_TBS6909SE != dev->info->board_id)&&(TBSECP3_BOARD_TBS6504H!= dev->info->board_id)&&(TBSECP3_BOARD_TBS6812!= dev->info->board_id)){ 1494 | reset_demod(adapter); 1495 | set_mac_address(adapter); 1496 | } 1497 | #endif 1498 | 1499 | switch (dev->info->board_id) { 1500 | case TBSECP3_BOARD_TBS6812: 1501 | tbs_octuples_reset_demod(adapter); 1502 | set_mac_address(adapter); 1503 | adapter->fe = dvb_attach(cxd2857_attach, &tbs6812_cfg[adapter->nr], i2c); 1504 | if (adapter->fe == NULL) 1505 | goto frontend_atach_fail; 1506 | break; 1507 | #ifdef TBS_DVB_EXTENSION 1508 | case TBSECP3_BOARD_TBS6590SE: 1509 | tbs6590se_reset_demod(adapter); 1510 | // adapter->fe2 = &adapter->_fe2; 1511 | //memcpy(adapter->fe2, adapter->fe, sizeof(struct dvb_frontend)); 1512 | /* terrestrial tuner */ 1513 | adapter->fe = dvb_attach(cxd2878_attach, &tbs6590se_cfg[adapter->nr], i2c); 1514 | if (adapter->fe == NULL) 1515 | goto frontend_atach_fail; 1516 | 1517 | /* sattelite tuner */ 1518 | /* attach frontend */ 1519 | memset(&m88rs6060_config, 0, sizeof(m88rs6060_config)); 1520 | m88rs6060_config.fe = &adapter->fe2; 1521 | m88rs6060_config.clk = 27000000; 1522 | m88rs6060_config.i2c_wr_max = 65; 1523 | m88rs6060_config.ts_mode = MtFeTsOutMode_Parallel; 1524 | m88rs6060_config.ts_pinswitch = 0; 1525 | m88rs6060_config.HAS_CI = 0; 1526 | m88rs6060_config.SetCIClock= NULL; 1527 | m88rs6060_config.envelope_mode = 0; 1528 | m88rs6060_config.demod_adr = 0x69; 1529 | m88rs6060_config.disable_22k = 0; 1530 | m88rs6060_config.tuner_adr = 0x2c; 1531 | m88rs6060_config.repeater_value = 0x12; 1532 | m88rs6060_config.num = adapter->nr; 1533 | m88rs6060_config.read_properties = ecp3_spi_read; 1534 | m88rs6060_config.write_properties = ecp3_spi_write; 1535 | m88rs6060_config.read_eeprom = ecp3_eeprom_read; 1536 | m88rs6060_config.write_eeprom = ecp3_eeprom_write; 1537 | m88rs6060_config.RF_switch = RF_switch; 1538 | memset(&info, 0, sizeof(struct i2c_board_info)); 1539 | strscpy(info.type, "m88rs6060", I2C_NAME_SIZE); 1540 | info.addr = m88rs6060_config.demod_adr; 1541 | info.platform_data = &m88rs6060_config; 1542 | request_module(info.type); 1543 | client_demod = i2c_new_client_device(i2c, &info); 1544 | if (!i2c_client_has_driver(client_demod)) 1545 | goto frontend_atach_fail; 1546 | if (!try_module_get(client_demod->dev.driver->owner)) { 1547 | i2c_unregister_device(client_demod); 1548 | goto frontend_atach_fail; 1549 | } 1550 | adapter->i2c_client_demod = client_demod; 1551 | 1552 | tbsecp3_ca_init(adapter, adapter->nr); 1553 | break; 1554 | case TBSECP3_BOARD_TBS6504H: 1555 | tbs_octuples_reset_demod(adapter); 1556 | set_mac_address(adapter); 1557 | 1558 | if(adapter->nr<4){ //for tuner#0~#3 1559 | memset(&m88rs6060_config, 0, sizeof(m88rs6060_config)); 1560 | m88rs6060_config.fe = &adapter->fe; 1561 | m88rs6060_config.clk = 27000000; 1562 | m88rs6060_config.i2c_wr_max = 65; 1563 | m88rs6060_config.ts_mode = MtFeTsOutMode_Parallel; 1564 | m88rs6060_config.ts_pinswitch = 0; 1565 | m88rs6060_config.HAS_CI = 0; 1566 | m88rs6060_config.SetCIClock= NULL; 1567 | m88rs6060_config.envelope_mode = 0; 1568 | m88rs6060_config.demod_adr = (adapter->nr%2)?0x6B:0x69; 1569 | m88rs6060_config.disable_22k = 0; 1570 | m88rs6060_config.tuner_adr = 0x2c; 1571 | m88rs6060_config.repeater_value = 0x12; 1572 | m88rs6060_config.num = adapter->nr; 1573 | m88rs6060_config.read_properties = ecp3_spi_read; 1574 | m88rs6060_config.write_properties = ecp3_spi_write; 1575 | m88rs6060_config.read_eeprom = ecp3_eeprom_read; 1576 | m88rs6060_config.write_eeprom = ecp3_eeprom_write; 1577 | memset(&info, 0, sizeof(struct i2c_board_info)); 1578 | strscpy(info.type, "m88rs6060", I2C_NAME_SIZE); 1579 | info.addr = m88rs6060_config.demod_adr; 1580 | info.platform_data = &m88rs6060_config; 1581 | request_module(info.type); 1582 | client_demod = i2c_new_client_device(i2c, &info); 1583 | if (!i2c_client_has_driver(client_demod)) 1584 | goto frontend_atach_fail; 1585 | if (!try_module_get(client_demod->dev.driver->owner)) { 1586 | i2c_unregister_device(client_demod); 1587 | goto frontend_atach_fail; 1588 | } 1589 | adapter->i2c_client_demod = client_demod; 1590 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 1591 | dev_warn(&dev->pci_dev->dev, 1592 | "error attaching lnb control on adapter %d\n", 1593 | adapter->nr); 1594 | } 1595 | }else{ 1596 | 1597 | adapter->fe = dvb_attach(cxd2878_attach, &tbs6504h_cfg[adapter->nr%2], i2c); 1598 | if (adapter->fe == NULL) 1599 | goto frontend_atach_fail; 1600 | } 1601 | break; 1602 | case TBSECP3_BOARD_TBS6522H: 1603 | if(adapter->nr<2){ //for tuner0/1 dvbt/c/isdbt/atsc 1604 | adapter->fe = dvb_attach(cxd2878_attach, &cxd6802_parallel_cfg, i2c); 1605 | if (adapter->fe == NULL) 1606 | goto frontend_atach_fail; 1607 | }else{ //for tuner2/3 dvbs/s2 1608 | memset(&m88rs6060_config, 0, sizeof(m88rs6060_config)); 1609 | m88rs6060_config.fe = &adapter->fe; 1610 | m88rs6060_config.clk = 27000000; 1611 | m88rs6060_config.i2c_wr_max = 65; 1612 | m88rs6060_config.ts_mode = MtFeTsOutMode_Parallel; 1613 | m88rs6060_config.ts_pinswitch = 0; 1614 | m88rs6060_config.HAS_CI = 0; 1615 | m88rs6060_config.SetCIClock= NULL; 1616 | m88rs6060_config.envelope_mode = 0; 1617 | m88rs6060_config.demod_adr = 0x69; 1618 | m88rs6060_config.disable_22k = 0; 1619 | m88rs6060_config.tuner_adr = 0x2c; 1620 | m88rs6060_config.repeater_value = 0x12; 1621 | m88rs6060_config.num = adapter->nr; 1622 | m88rs6060_config.read_properties = ecp3_spi_read; 1623 | m88rs6060_config.write_properties = ecp3_spi_write; 1624 | m88rs6060_config.read_eeprom = ecp3_eeprom_read; 1625 | m88rs6060_config.write_eeprom = ecp3_eeprom_write; 1626 | memset(&info, 0, sizeof(struct i2c_board_info)); 1627 | strscpy(info.type, "m88rs6060", I2C_NAME_SIZE); 1628 | info.addr = m88rs6060_config.demod_adr; 1629 | info.platform_data = &m88rs6060_config; 1630 | request_module(info.type); 1631 | client_demod = i2c_new_client_device(i2c, &info); 1632 | if (!i2c_client_has_driver(client_demod)) 1633 | goto frontend_atach_fail; 1634 | if (!try_module_get(client_demod->dev.driver->owner)) { 1635 | i2c_unregister_device(client_demod); 1636 | goto frontend_atach_fail; 1637 | } 1638 | adapter->i2c_client_demod = client_demod; 1639 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 1640 | dev_warn(&dev->pci_dev->dev, 1641 | "error attaching lnb control on adapter %d\n", 1642 | adapter->nr); 1643 | } 1644 | } 1645 | break; 1646 | case TBSECP3_BOARD_TBS6209SE: 1647 | tbs_octuples_reset_demod(adapter); 1648 | set_mac_address(adapter); 1649 | adapter->fe = dvb_attach(cxd2878_attach, &tbs6209se_cfg[(adapter->nr)%4], i2c); 1650 | 1651 | if (adapter->fe == NULL) 1652 | goto frontend_atach_fail; 1653 | break; 1654 | case TBSECP3_BOARD_TBS7230: 1655 | case TBSECP3_BOARD_TBS6290TD: 1656 | adapter->fe = dvb_attach(cxd2878_attach, &tbsserial_cfg, i2c); 1657 | if (adapter->fe == NULL) 1658 | goto frontend_atach_fail; 1659 | if(dev->info->board_id==TBSECP3_BOARD_TBS6290TD) 1660 | tbsecp3_ca_init(adapter, adapter->nr); 1661 | 1662 | break; 1663 | case TBSECP3_BOARD_TBS6281TD: 1664 | case TBSECP3_BOARD_TBS6205SE: 1665 | adapter->fe = dvb_attach(cxd2878_attach, &cxd6802_parallel_cfg, i2c); 1666 | if (adapter->fe == NULL) 1667 | goto frontend_atach_fail; 1668 | 1669 | break; 1670 | case TBSECP3_BOARD_TBS6910SE: 1671 | case TBSECP3_BOARD_TBS6904SE: 1672 | case TBSECP3_BOARD_TBS6902SE: 1673 | case TBSECP3_BOARD_TBS7901: 1674 | case TBSECP3_BOARD_TBS6909SE: 1675 | if(dev->info->board_id == TBSECP3_BOARD_TBS6909SE){ 1676 | tbs_octuples_reset_demod(adapter); 1677 | set_mac_address(adapter); 1678 | } 1679 | 1680 | memset(&m88rs6060_config, 0, sizeof(m88rs6060_config)); 1681 | m88rs6060_config.fe = &adapter->fe; 1682 | m88rs6060_config.clk = 27000000; 1683 | m88rs6060_config.i2c_wr_max = 65; 1684 | if((dev->info->board_id == TBSECP3_BOARD_TBS6910SE)|| 1685 | (dev->info->board_id == TBSECP3_BOARD_TBS6909SE)){ 1686 | 1687 | m88rs6060_config.ts_mode = MtFeTsOutMode_Serial; 1688 | m88rs6060_config.ts_pinswitch = 0; 1689 | 1690 | }else{ 1691 | m88rs6060_config.ts_mode = MtFeTsOutMode_Parallel; 1692 | m88rs6060_config.ts_pinswitch = 1; 1693 | m88rs6060_config.ts_autoclock = 1; 1694 | } 1695 | 1696 | if(dev->info->board_id == TBSECP3_BOARD_TBS6910SE){ 1697 | m88rs6060_config.HAS_CI = 1; 1698 | 1699 | if(tbs_FPGA_fireware_info(adapter)==0x22082220){ 1700 | if(!ciclock) 1701 | m88rs6060_config.HAS_CI = 0; 1702 | 1703 | m88rs6060_config.clk_port = adapter->nr; 1704 | } 1705 | else 1706 | m88rs6060_config.clk_port = 0; 1707 | 1708 | m88rs6060_config.SetTimes= Set_TSsamplingtimes; 1709 | m88rs6060_config.SetCIClock= SetCIClock; 1710 | }else{ 1711 | m88rs6060_config.HAS_CI = 0; 1712 | m88rs6060_config.SetCIClock= NULL; 1713 | 1714 | } 1715 | 1716 | m88rs6060_config.envelope_mode = 0; 1717 | if(dev->info->board_id == TBSECP3_BOARD_TBS6909SE) 1718 | m88rs6060_config.demod_adr = (adapter->nr%2)?0x6B:0x69; 1719 | else 1720 | m88rs6060_config.demod_adr = 0x69; 1721 | 1722 | if(m88rs6060_config.demod_adr!=0x6B) 1723 | m88rs6060_config.disable_22k = 0; 1724 | else 1725 | m88rs6060_config.disable_22k = 1; 1726 | 1727 | m88rs6060_config.tuner_adr = 0x2c; 1728 | m88rs6060_config.repeater_value = 0x12; 1729 | m88rs6060_config.num = adapter->nr; 1730 | m88rs6060_config.read_properties = ecp3_spi_read; 1731 | m88rs6060_config.write_properties = ecp3_spi_write; 1732 | m88rs6060_config.read_eeprom = ecp3_eeprom_read; 1733 | m88rs6060_config.write_eeprom = ecp3_eeprom_write; 1734 | memset(&info, 0, sizeof(struct i2c_board_info)); 1735 | strscpy(info.type, "m88rs6060", I2C_NAME_SIZE); 1736 | info.addr = m88rs6060_config.demod_adr; 1737 | info.platform_data = &m88rs6060_config; 1738 | request_module(info.type); 1739 | client_demod = i2c_new_client_device(i2c, &info); 1740 | if (!i2c_client_has_driver(client_demod)) 1741 | goto frontend_atach_fail; 1742 | if (!try_module_get(client_demod->dev.driver->owner)) { 1743 | i2c_unregister_device(client_demod); 1744 | goto frontend_atach_fail; 1745 | } 1746 | adapter->i2c_client_demod = client_demod; 1747 | //if(m88rs6060_config.demod_adr!=0x6B){ 1748 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 1749 | dev_warn(&dev->pci_dev->dev, 1750 | "error attaching lnb control on adapter %d\n", 1751 | adapter->nr); 1752 | } 1753 | //} 1754 | if(dev->info->board_id == TBSECP3_BOARD_TBS6910SE){ 1755 | tbsecp3_ca_init(adapter, adapter->nr); 1756 | } 1757 | break; 1758 | case TBSECP3_BOARD_TBS6508: 1759 | /* attach demod */ 1760 | memset(&si2183_config, 0, sizeof(si2183_config)); 1761 | si2183_config.i2c_adapter = &i2c; 1762 | si2183_config.fe = &adapter->fe; 1763 | si2183_config.ts_mode = SI2183_TS_PARALLEL; 1764 | si2183_config.ts_clock_gapped = true; 1765 | si2183_config.rf_in = adapter->nr; 1766 | si2183_config.RF_switch = NULL; 1767 | si2183_config.read_properties = ecp3_spi_read; 1768 | si2183_config.write_properties = ecp3_spi_write; 1769 | 1770 | memset(&info, 0, sizeof(struct i2c_board_info)); 1771 | strscpy(info.type, "si2183", I2C_NAME_SIZE); 1772 | info.addr = (adapter->nr %2) ? 0x67 : 0x64; 1773 | si2183_config.agc_mode = (adapter->nr %2)? 0x5 : 0x4; 1774 | info.platform_data = &si2183_config; 1775 | request_module(info.type); 1776 | client_demod = i2c_new_client_device(i2c, &info); 1777 | if (!i2c_client_has_driver(client_demod)) 1778 | goto frontend_atach_fail; 1779 | if (!try_module_get(client_demod->dev.driver->owner)) { 1780 | i2c_unregister_device(client_demod); 1781 | goto frontend_atach_fail; 1782 | } 1783 | adapter->i2c_client_demod = client_demod; 1784 | 1785 | /* dvb core doesn't support 2 tuners for 1 demod so 1786 | we split the adapter in 2 frontends */ 1787 | adapter->fe2 = &adapter->_fe2; 1788 | memcpy(adapter->fe2, adapter->fe, sizeof(struct dvb_frontend)); 1789 | 1790 | 1791 | /* terrestrial tuner */ 1792 | memset(adapter->fe->ops.delsys, 0, MAX_DELSYS); 1793 | adapter->fe->ops.delsys[0] = SYS_DVBT; 1794 | adapter->fe->ops.delsys[1] = SYS_DVBT2; 1795 | adapter->fe->ops.delsys[2] = SYS_DVBC_ANNEX_A; 1796 | adapter->fe->ops.delsys[3] = SYS_ISDBT; 1797 | adapter->fe->ops.delsys[4] = SYS_DVBC_ANNEX_B; 1798 | 1799 | /* attach tuner */ 1800 | memset(&si2157_config, 0, sizeof(si2157_config)); 1801 | si2157_config.fe = adapter->fe; 1802 | si2157_config.if_port = 1; 1803 | 1804 | memset(&info, 0, sizeof(struct i2c_board_info)); 1805 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 1806 | info.addr = (adapter->nr %2) ? 0x60 : 0x61; 1807 | info.platform_data = &si2157_config; 1808 | request_module(info.type); 1809 | client_tuner = i2c_new_client_device(i2c, &info); 1810 | if (!i2c_client_has_driver(client_tuner)) 1811 | goto frontend_atach_fail; 1812 | 1813 | if (!try_module_get(client_tuner->dev.driver->owner)) { 1814 | i2c_unregister_device(client_tuner); 1815 | goto frontend_atach_fail; 1816 | } 1817 | adapter->i2c_client_tuner = client_tuner; 1818 | 1819 | 1820 | /* sattelite tuner */ 1821 | memset(adapter->fe2->ops.delsys, 0, MAX_DELSYS); 1822 | adapter->fe2->ops.delsys[0] = SYS_DVBS; 1823 | adapter->fe2->ops.delsys[1] = SYS_DVBS2; 1824 | adapter->fe2->ops.delsys[2] = SYS_DSS; 1825 | adapter->fe2->id = 1; 1826 | if (dvb_attach(rda5816_attach, adapter->fe2, &rda5816_cfg[(adapter->nr %2)], 1827 | i2c) == NULL) { 1828 | dev_err(&dev->pci_dev->dev, 1829 | "frontend %d tuner attach failed\n", 1830 | adapter->nr); 1831 | goto frontend_atach_fail; 1832 | } 1833 | if (tbsecp3_attach_sec(adapter, adapter->fe2) == NULL) { 1834 | dev_warn(&dev->pci_dev->dev, 1835 | "error attaching lnb control on adapter %d\n", 1836 | adapter->nr); 1837 | } 1838 | break; 1839 | case TBSECP3_BOARD_TBS6904X: 1840 | memset(&si2183_config, 0, sizeof(si2183_config)); 1841 | si2183_config.i2c_adapter = &i2c; 1842 | si2183_config.fe = &adapter->fe; 1843 | si2183_config.ts_mode = SI2183_TS_PARALLEL ; 1844 | si2183_config.ts_clock_gapped = true; 1845 | si2183_config.rf_in = adapter->nr; 1846 | si2183_config.RF_switch = NULL; 1847 | si2183_config.start_clk_mode = 1; 1848 | si2183_config.read_properties = ecp3_spi_read; 1849 | si2183_config.write_properties = ecp3_spi_write; 1850 | memset(&info, 0, sizeof(struct i2c_board_info)); 1851 | strscpy(info.type, "si2183", I2C_NAME_SIZE); 1852 | 1853 | info.addr = (adapter->nr %2)? 0x64 : 0x67; 1854 | si2183_config.agc_mode = (adapter->nr%2)? 0x4 : 0x5; 1855 | 1856 | info.platform_data = &si2183_config; 1857 | request_module(info.type); 1858 | client_demod = i2c_new_client_device(i2c, &info); 1859 | if (!i2c_client_has_driver(client_demod)) 1860 | goto frontend_atach_fail; 1861 | if (!try_module_get(client_demod->dev.driver->owner)) { 1862 | i2c_unregister_device(client_demod); 1863 | goto frontend_atach_fail; 1864 | } 1865 | adapter->i2c_client_demod = client_demod; 1866 | 1867 | memset(adapter->fe->ops.delsys, 0, MAX_DELSYS); 1868 | adapter->fe->ops.delsys[0] = SYS_DVBS; 1869 | adapter->fe->ops.delsys[1] = SYS_DVBS2; 1870 | adapter->fe->ops.delsys[2] = SYS_DSS; 1871 | 1872 | if (dvb_attach(av201x_attach, adapter->fe, &tbs6522_av201x_cfg[(adapter->nr%2)], 1873 | i2c) == NULL) { 1874 | dvb_frontend_detach(adapter->fe); 1875 | adapter->fe = NULL; 1876 | dev_err(&dev->pci_dev->dev, 1877 | "frontend %d tuner attach failed\n", 1878 | adapter->nr); 1879 | goto frontend_atach_fail; 1880 | } 1881 | 1882 | 1883 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 1884 | dev_warn(&dev->pci_dev->dev, 1885 | "error attaching lnb control on adapter %d\n", 1886 | adapter->nr); 1887 | } 1888 | 1889 | break; 1890 | case TBSECP3_BOARD_TBS6308: 1891 | adapter->fe = dvb_attach(tas2971_attach, &tbs6308_demod_cfg, i2c); 1892 | if (adapter->fe == NULL) 1893 | goto frontend_atach_fail; 1894 | if(adapter->nr <4) 1895 | { 1896 | if(tbs6304_read_mac(adapter)==0) 1897 | tbs6304_read_mac(adapter); 1898 | } 1899 | else 1900 | { 1901 | if(tbs6308_read_mac_ext(adapter)==0) 1902 | tbs6308_read_mac_ext(adapter);//try again 1903 | } 1904 | break; 1905 | case TBSECP3_BOARD_TBS6308X: 1906 | adapter->fe = dvb_attach(tas2971_attach, &tbs6308_demod_cfg, i2c); 1907 | if (adapter->fe == NULL) 1908 | goto frontend_atach_fail; 1909 | 1910 | break; 1911 | case TBSECP3_BOARD_TBS6312X: 1912 | adapter->fe = dvb_attach(tas2971_attach, &tbs6308_demod_cfg, i2c); 1913 | if (adapter->fe == NULL) 1914 | goto frontend_atach_fail; 1915 | 1916 | break; 1917 | case TBSECP3_BOARD_TBS6304: 1918 | adapter->fe = dvb_attach(tas2971_attach, &tbs6304_demod_cfg[adapter->nr], i2c); 1919 | if (adapter->fe == NULL) 1920 | goto frontend_atach_fail; 1921 | if(tbs6304_read_mac(adapter)==0) 1922 | tbs6304_read_mac(adapter); 1923 | break; 1924 | case TBSECP3_BOARD_TBS6302SE: 1925 | adapter->fe = dvb_attach(tas2971_attach, &tbs6302se_demod_cfg[adapter->nr], i2c); 1926 | if (adapter->fe == NULL) 1927 | goto frontend_atach_fail; 1928 | if(tbs6302se_read_mac(adapter)==0) 1929 | tbs6302se_read_mac(adapter); 1930 | break; 1931 | case TBSECP3_BOARD_TBS6301: 1932 | adapter->fe = dvb_attach(tas2971_attach, &tbs6301_demod_cfg, i2c); 1933 | if (adapter->fe == NULL) 1934 | goto frontend_atach_fail; 1935 | 1936 | tbs6301_read_mac(adapter); 1937 | break; 1938 | case TBSECP3_BOARD_TBS6301SE: 1939 | adapter->fe = dvb_attach(tas2971_attach, &tbs6301se_demod_cfg, i2c); 1940 | if (adapter->fe == NULL) 1941 | goto frontend_atach_fail; 1942 | 1943 | break; 1944 | case TBSECP3_BOARD_TBS6302X: 1945 | case TBSECP3_BOARD_TBS6302T: 1946 | case TBSECP3_BOARD_TBS6322: 1947 | adapter->fe = dvb_attach(tas2971_attach, &tbs6302se_demod_cfg[adapter->nr], i2c); 1948 | if (adapter->fe == NULL) 1949 | goto frontend_atach_fail; 1950 | 1951 | break; 1952 | case TBSECP3_BOARD_TBS6304X: 1953 | case TBSECP3_BOARD_TBS6304T: 1954 | case TBSECP3_BOARD_TBS6324: 1955 | adapter->fe = dvb_attach(tas2971_attach, &tbs6304x_demod_cfg, i2c); 1956 | if (adapter->fe == NULL) 1957 | goto frontend_atach_fail; 1958 | 1959 | break; 1960 | 1961 | case TBSECP3_BOARD_TBS690a: 1962 | adapter->fe = dvb_attach(tas2971_attach, &tbs6904_demod_cfg[adapter->nr], i2c); 1963 | if (adapter->fe == NULL) 1964 | goto frontend_atach_fail; 1965 | 1966 | // init asi 1967 | int regdata; 1968 | u8 mpbuf[4]; 1969 | mpbuf[0] = adapter->nr; //0--3 select value 1970 | tbs_write( TBSECP3_GPIO_BASE, 0x34 , *(u32 *)&mpbuf[0]); // select chip : 13*8 =104=0x68 select address 1971 | //u32 mpbuf = adapter->nr; 1972 | //tbs_write( TBSECP3_GPIO_BASE, 0x34 , mpbuf); // select chip : 13*8 =104=0x68 select address 1973 | // ==*********************************************************************** 1974 | 1975 | asi_chip_reset(dev,ASI0_BASEADDRESS); //asi chip reset; 1976 | 1977 | mpbuf[0] = 1; //active spi bus from "z" 1978 | tbs_write( ASI0_BASEADDRESS, ASI_SPI_ENABLE, *(u32 *)&mpbuf[0]); 1979 | 1980 | regdata = asi_read16bit(dev,ASI0_BASEADDRESS,0x24); 1981 | asi_write16bit(dev,ASI0_BASEADDRESS,0x24,3); 1982 | regdata = asi_read16bit(dev,ASI0_BASEADDRESS, 0x24); 1983 | 1984 | mpbuf[0] = 0; //spi disable, enter "z" state; 1985 | tbs_write( ASI0_BASEADDRESS, ASI_SPI_ENABLE, *(u32 *)&mpbuf[0]); 1986 | 1987 | //==**************************************************************************************** 1988 | // ~~init asi 1989 | break; 1990 | 1991 | case TBSECP3_BOARD_TBS6514: 1992 | memset(&gx1503_config,0,sizeof(gx1503_config)); 1993 | gx1503_config.i2c_adapter =&i2c; 1994 | gx1503_config.fe = &adapter->fe; 1995 | gx1503_config.clk_freq = 30400;//KHZ 1996 | gx1503_config.ts_mode = 1; 1997 | gx1503_config.i2c_wr_max = 8; 1998 | 1999 | memset(&info, 0, sizeof(struct i2c_board_info)); 2000 | strscpy(info.type, "gx1503", I2C_NAME_SIZE); 2001 | info.addr = 0x30; 2002 | info.platform_data = &gx1503_config; 2003 | request_module(info.type); 2004 | client_demod = i2c_new_client_device(i2c,&info); 2005 | if(!i2c_client_has_driver(client_demod)) 2006 | goto frontend_atach_fail; 2007 | 2008 | if (!try_module_get(client_demod->dev.driver->owner)) { 2009 | i2c_unregister_device(client_demod); 2010 | goto frontend_atach_fail; 2011 | } 2012 | 2013 | adapter->i2c_client_demod = client_demod; 2014 | 2015 | /*attach tuner*/ 2016 | memset(&si2157_config, 0, sizeof(si2157_config)); 2017 | si2157_config.fe = adapter->fe; 2018 | si2157_config.if_port = 0; 2019 | 2020 | memset(&info, 0, sizeof(struct i2c_board_info)); 2021 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2022 | info.addr = 0x60; 2023 | info.platform_data = &si2157_config; 2024 | request_module(info.type); 2025 | client_tuner = i2c_new_client_device(i2c, &info); 2026 | if (!i2c_client_has_driver(client_tuner)) 2027 | goto frontend_atach_fail; 2028 | 2029 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2030 | i2c_unregister_device(client_tuner); 2031 | goto frontend_atach_fail; 2032 | } 2033 | adapter->i2c_client_tuner = client_tuner; 2034 | break; 2035 | 2036 | case TBSECP3_BOARD_TBS6814: 2037 | memset(&mtv23x_config, 0, sizeof(mtv23x_config)); 2038 | mtv23x_config.fe = &adapter->fe; 2039 | mtv23x_config.clk_freq = 32000; 2040 | mtv23x_config.ts_mode = 6; 2041 | mtv23x_config.i2c_wr_max = 32; 2042 | 2043 | memset(&info, 0, sizeof(struct i2c_board_info)); 2044 | strscpy(info.type, "mtv23x", I2C_NAME_SIZE); 2045 | info.addr = (adapter->nr%2)? 0x44 : 0x43; 2046 | info.platform_data = &mtv23x_config; 2047 | request_module(info.type); 2048 | client_demod = i2c_new_client_device(i2c, &info); 2049 | if (!i2c_client_has_driver(client_demod)) 2050 | goto frontend_atach_fail; 2051 | if (!try_module_get(client_demod->dev.driver->owner)) { 2052 | i2c_unregister_device(client_demod); 2053 | goto frontend_atach_fail; 2054 | } 2055 | adapter->i2c_client_demod = client_demod; 2056 | break; 2057 | 2058 | case TBSECP3_BOARD_TBS6209: 2059 | /* attach demod */ 2060 | memset(&si2183_config, 0, sizeof(si2183_config)); 2061 | si2183_config.i2c_adapter = &i2c; 2062 | si2183_config.fe = &adapter->fe; 2063 | si2183_config.ts_mode = SI2183_TS_SERIAL; 2064 | si2183_config.ts_clock_gapped = true; 2065 | si2183_config.rf_in = adapter->nr; 2066 | si2183_config.RF_switch = NULL; 2067 | si2183_config.read_properties = ecp3_spi_read; 2068 | si2183_config.write_properties = ecp3_spi_write; 2069 | 2070 | memset(&info, 0, sizeof(struct i2c_board_info)); 2071 | strscpy(info.type, "si2183", I2C_NAME_SIZE); 2072 | info.addr = (adapter->nr%2)? 0x67 : 0x64; 2073 | si2183_config.agc_mode = (adapter->nr%2)? 0x5 : 0x4; 2074 | info.platform_data = &si2183_config; 2075 | request_module(info.type); 2076 | client_demod = i2c_new_client_device(i2c, &info); 2077 | if (!i2c_client_has_driver(client_demod)) 2078 | goto frontend_atach_fail; 2079 | if (!try_module_get(client_demod->dev.driver->owner)) { 2080 | i2c_unregister_device(client_demod); 2081 | goto frontend_atach_fail; 2082 | } 2083 | adapter->i2c_client_demod = client_demod; 2084 | 2085 | /* terrestrial tuner */ 2086 | memset(adapter->fe->ops.delsys, 0, MAX_DELSYS); 2087 | adapter->fe->ops.delsys[0] = SYS_DVBT; 2088 | adapter->fe->ops.delsys[1] = SYS_DVBT2; 2089 | adapter->fe->ops.delsys[2] = SYS_DVBC_ANNEX_A; 2090 | adapter->fe->ops.delsys[3] = SYS_ISDBT; 2091 | adapter->fe->ops.delsys[4] = SYS_DVBC_ANNEX_B; 2092 | 2093 | /* attach tuner */ 2094 | memset(&si2157_config, 0, sizeof(si2157_config)); 2095 | si2157_config.fe = adapter->fe; 2096 | si2157_config.if_port = 1; 2097 | 2098 | memset(&info, 0, sizeof(struct i2c_board_info)); 2099 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2100 | info.addr = (adapter->nr %2)? 0x60 : 0x63; 2101 | info.platform_data = &si2157_config; 2102 | request_module(info.type); 2103 | client_tuner = i2c_new_client_device(i2c, &info); 2104 | if (!i2c_client_has_driver(client_tuner)) 2105 | goto frontend_atach_fail; 2106 | 2107 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2108 | i2c_unregister_device(client_tuner); 2109 | goto frontend_atach_fail; 2110 | } 2111 | adapter->i2c_client_tuner = client_tuner; 2112 | break; 2113 | 2114 | case TBSECP3_BOARD_TBS6704: 2115 | /* attach demod */ 2116 | adapter->fe = dvb_attach(mndmd_attach, &tbs6704_cfg, i2c); 2117 | if (adapter->fe == NULL) 2118 | goto frontend_atach_fail; 2119 | break; 2120 | 2121 | case TBSECP3_BOARD_TBS6205: 2122 | case TBSECP3_BOARD_TBS6281SE: 2123 | /* attach demod */ 2124 | memset(&si2168_config, 0, sizeof(si2168_config)); 2125 | si2168_config.i2c_adapter = &i2c; 2126 | si2168_config.fe = &adapter->fe; 2127 | si2168_config.ts_mode = SI2168_TS_PARALLEL; 2128 | si2168_config.ts_clock_gapped = true; 2129 | 2130 | memset(&info, 0, sizeof(struct i2c_board_info)); 2131 | strscpy(info.type, "si2168", I2C_NAME_SIZE); 2132 | info.addr = 0x64; 2133 | info.platform_data = &si2168_config; 2134 | request_module(info.type); 2135 | client_demod = i2c_new_client_device(i2c, &info); 2136 | if (!i2c_client_has_driver(client_demod)) 2137 | goto frontend_atach_fail; 2138 | if (!try_module_get(client_demod->dev.driver->owner)) { 2139 | i2c_unregister_device(client_demod); 2140 | goto frontend_atach_fail; 2141 | } 2142 | adapter->i2c_client_demod = client_demod; 2143 | 2144 | /* attach tuner */ 2145 | memset(&si2157_config, 0, sizeof(si2157_config)); 2146 | si2157_config.fe = adapter->fe; 2147 | si2157_config.if_port = 1; 2148 | 2149 | memset(&info, 0, sizeof(struct i2c_board_info)); 2150 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2151 | info.addr = 0x60; 2152 | info.platform_data = &si2157_config; 2153 | request_module(info.type); 2154 | client_tuner = i2c_new_client_device(i2c, &info); 2155 | if (!i2c_client_has_driver(client_tuner)) 2156 | goto frontend_atach_fail; 2157 | 2158 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2159 | i2c_unregister_device(client_tuner); 2160 | goto frontend_atach_fail; 2161 | } 2162 | adapter->i2c_client_tuner = client_tuner; 2163 | break; 2164 | 2165 | case TBSECP3_BOARD_TBS6290SE: 2166 | /* attach demod */ 2167 | memset(&si2168_config, 0, sizeof(si2168_config)); 2168 | si2168_config.i2c_adapter = &i2c; 2169 | si2168_config.fe = &adapter->fe; 2170 | si2168_config.ts_mode = SI2168_TS_SERIAL;//zc2016/07/20 2171 | si2168_config.ts_clock_gapped = true; 2172 | si2168_config.ts_clock_inv=0;//zc2016/07/20 2173 | 2174 | memset(&info, 0, sizeof(struct i2c_board_info)); 2175 | strscpy(info.type, "si2168", I2C_NAME_SIZE); 2176 | info.addr = 0x64; 2177 | info.platform_data = &si2168_config; 2178 | request_module(info.type); 2179 | client_demod = i2c_new_client_device(i2c, &info); 2180 | if (!i2c_client_has_driver(client_demod)) 2181 | goto frontend_atach_fail; 2182 | if (!try_module_get(client_demod->dev.driver->owner)) { 2183 | i2c_unregister_device(client_demod); 2184 | goto frontend_atach_fail; 2185 | } 2186 | adapter->i2c_client_demod = client_demod; 2187 | 2188 | /* attach tuner */ 2189 | memset(&si2157_config, 0, sizeof(si2157_config)); 2190 | si2157_config.fe = adapter->fe; 2191 | si2157_config.if_port = 1; 2192 | 2193 | memset(&info, 0, sizeof(struct i2c_board_info)); 2194 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2195 | info.addr = 0x60; 2196 | info.platform_data = &si2157_config; 2197 | request_module(info.type); 2198 | client_tuner = i2c_new_client_device(i2c, &info); 2199 | if (!i2c_client_has_driver(client_tuner)) 2200 | goto frontend_atach_fail; 2201 | 2202 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2203 | i2c_unregister_device(client_tuner); 2204 | goto frontend_atach_fail; 2205 | } 2206 | adapter->i2c_client_tuner = client_tuner; 2207 | tbsecp3_ca_init(adapter, adapter->nr); 2208 | break; 2209 | 2210 | case TBSECP3_BOARD_TBS6522: 2211 | case TBSECP3_BOARD_TBS6504: 2212 | /* attach demod */ 2213 | memset(&si2183_config, 0, sizeof(si2183_config)); 2214 | si2183_config.i2c_adapter = &i2c; 2215 | si2183_config.fe = &adapter->fe; 2216 | si2183_config.ts_mode = SI2183_TS_PARALLEL; 2217 | si2183_config.ts_clock_gapped = true; 2218 | si2183_config.rf_in = adapter->nr; 2219 | si2183_config.RF_switch = NULL; 2220 | si2183_config.read_properties = ecp3_spi_read; 2221 | si2183_config.write_properties = ecp3_spi_write; 2222 | 2223 | memset(&info, 0, sizeof(struct i2c_board_info)); 2224 | strscpy(info.type, "si2183", I2C_NAME_SIZE); 2225 | info.addr = (adapter->nr %2) ? 0x64 : 0x67; 2226 | si2183_config.agc_mode = (adapter->nr %2)? 0x4 : 0x5; 2227 | info.platform_data = &si2183_config; 2228 | request_module(info.type); 2229 | client_demod = i2c_new_client_device(i2c, &info); 2230 | if (!i2c_client_has_driver(client_demod)) 2231 | goto frontend_atach_fail; 2232 | if (!try_module_get(client_demod->dev.driver->owner)) { 2233 | i2c_unregister_device(client_demod); 2234 | goto frontend_atach_fail; 2235 | } 2236 | adapter->i2c_client_demod = client_demod; 2237 | 2238 | /* dvb core doesn't support 2 tuners for 1 demod so 2239 | we split the adapter in 2 frontends */ 2240 | adapter->fe2 = &adapter->_fe2; 2241 | memcpy(adapter->fe2, adapter->fe, sizeof(struct dvb_frontend)); 2242 | 2243 | 2244 | /* terrestrial tuner */ 2245 | memset(adapter->fe->ops.delsys, 0, MAX_DELSYS); 2246 | adapter->fe->ops.delsys[0] = SYS_DVBT; 2247 | adapter->fe->ops.delsys[1] = SYS_DVBT2; 2248 | adapter->fe->ops.delsys[2] = SYS_DVBC_ANNEX_A; 2249 | adapter->fe->ops.delsys[3] = SYS_ISDBT; 2250 | adapter->fe->ops.delsys[4] = SYS_DVBC_ANNEX_B; 2251 | 2252 | /* attach tuner */ 2253 | memset(&si2157_config, 0, sizeof(si2157_config)); 2254 | si2157_config.fe = adapter->fe; 2255 | si2157_config.if_port = 1; 2256 | 2257 | memset(&info, 0, sizeof(struct i2c_board_info)); 2258 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2259 | info.addr = (adapter->nr %2) ? 0x61 : 0x60; 2260 | info.platform_data = &si2157_config; 2261 | request_module(info.type); 2262 | client_tuner = i2c_new_client_device(i2c, &info); 2263 | if (!i2c_client_has_driver(client_tuner)) 2264 | goto frontend_atach_fail; 2265 | 2266 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2267 | i2c_unregister_device(client_tuner); 2268 | goto frontend_atach_fail; 2269 | } 2270 | adapter->i2c_client_tuner = client_tuner; 2271 | 2272 | 2273 | /* sattelite tuner */ 2274 | memset(adapter->fe2->ops.delsys, 0, MAX_DELSYS); 2275 | adapter->fe2->ops.delsys[0] = SYS_DVBS; 2276 | adapter->fe2->ops.delsys[1] = SYS_DVBS2; 2277 | adapter->fe2->ops.delsys[2] = SYS_DSS; 2278 | adapter->fe2->id = 1; 2279 | if (dvb_attach(av201x_attach, adapter->fe2, &tbs6522_av201x_cfg[(adapter->nr %2)], 2280 | i2c) == NULL) { 2281 | dev_err(&dev->pci_dev->dev, 2282 | "frontend %d tuner attach failed\n", 2283 | adapter->nr); 2284 | goto frontend_atach_fail; 2285 | } 2286 | if (tbsecp3_attach_sec(adapter, adapter->fe2) == NULL) { 2287 | dev_warn(&dev->pci_dev->dev, 2288 | "error attaching lnb control on adapter %d\n", 2289 | adapter->nr); 2290 | } 2291 | break; 2292 | 2293 | case TBSECP3_BOARD_TBS6528: 2294 | case TBSECP3_BOARD_TBS6590: 2295 | /* attach demod */ 2296 | memset(&si2183_config, 0, sizeof(si2183_config)); 2297 | si2183_config.i2c_adapter = &i2c; 2298 | si2183_config.fe = &adapter->fe; 2299 | si2183_config.ts_mode = pci->subsystem_vendor==0x6528 ? SI2183_TS_PARALLEL : SI2183_TS_SERIAL; 2300 | si2183_config.ts_clock_gapped = true; 2301 | si2183_config.rf_in = adapter->nr; 2302 | si2183_config.RF_switch = RF_switch; 2303 | si2183_config.read_properties = ecp3_spi_read; 2304 | si2183_config.write_properties = ecp3_spi_write; 2305 | 2306 | memset(&info, 0, sizeof(struct i2c_board_info)); 2307 | strscpy(info.type, "si2183", I2C_NAME_SIZE); 2308 | if(pci->subsystem_vendor==0x6528) 2309 | { 2310 | info.addr = 0x67; 2311 | si2183_config.agc_mode = 0x5 ; 2312 | } 2313 | else{ 2314 | info.addr = adapter->nr ? 0x67 : 0x64; 2315 | si2183_config.agc_mode = adapter->nr? 0x5 : 0x4; 2316 | } 2317 | info.platform_data = &si2183_config; 2318 | request_module(info.type); 2319 | client_demod = i2c_new_client_device(i2c, &info); 2320 | if (!i2c_client_has_driver(client_demod)) 2321 | goto frontend_atach_fail; 2322 | if (!try_module_get(client_demod->dev.driver->owner)) { 2323 | i2c_unregister_device(client_demod); 2324 | goto frontend_atach_fail; 2325 | } 2326 | adapter->i2c_client_demod = client_demod; 2327 | 2328 | /* dvb core doesn't support 2 tuners for 1 demod so 2329 | we split the adapter in 2 frontends */ 2330 | adapter->fe2 = &adapter->_fe2; 2331 | memcpy(adapter->fe2, adapter->fe, sizeof(struct dvb_frontend)); 2332 | 2333 | 2334 | /* terrestrial tuner */ 2335 | memset(adapter->fe->ops.delsys, 0, MAX_DELSYS); 2336 | adapter->fe->ops.delsys[0] = SYS_DVBT; 2337 | adapter->fe->ops.delsys[1] = SYS_DVBT2; 2338 | adapter->fe->ops.delsys[2] = SYS_DVBC_ANNEX_A; 2339 | adapter->fe->ops.delsys[3] = SYS_ISDBT; 2340 | adapter->fe->ops.delsys[4] = SYS_DVBC_ANNEX_B; 2341 | 2342 | /* attach tuner */ 2343 | memset(&si2157_config, 0, sizeof(si2157_config)); 2344 | si2157_config.fe = adapter->fe; 2345 | si2157_config.if_port = 1; 2346 | 2347 | memset(&info, 0, sizeof(struct i2c_board_info)); 2348 | strscpy(info.type, "si2157", I2C_NAME_SIZE); 2349 | if(pci->subsystem_vendor==0x6528)info.addr = 0x61; 2350 | else 2351 | info.addr = adapter->nr ? 0x61 : 0x60; 2352 | 2353 | info.platform_data = &si2157_config; 2354 | request_module(info.type); 2355 | client_tuner = i2c_new_client_device(i2c, &info); 2356 | if (!i2c_client_has_driver(client_tuner)) 2357 | goto frontend_atach_fail; 2358 | 2359 | if (!try_module_get(client_tuner->dev.driver->owner)) { 2360 | i2c_unregister_device(client_tuner); 2361 | goto frontend_atach_fail; 2362 | } 2363 | adapter->i2c_client_tuner = client_tuner; 2364 | 2365 | 2366 | /* sattelite tuner */ 2367 | memset(adapter->fe2->ops.delsys, 0, MAX_DELSYS); 2368 | adapter->fe2->ops.delsys[0] = SYS_DVBS; 2369 | adapter->fe2->ops.delsys[1] = SYS_DVBS2; 2370 | adapter->fe2->ops.delsys[2] = SYS_DSS; 2371 | adapter->fe2->id = 1; 2372 | if(pci->subsystem_vendor==0x6528) 2373 | { 2374 | if (dvb_attach(av201x_attach, adapter->fe2, &tbs6522_av201x_cfg[1], 2375 | i2c) == NULL) { 2376 | dev_err(&dev->pci_dev->dev, 2377 | "frontend %d tuner attach failed\n", 2378 | adapter->nr); 2379 | goto frontend_atach_fail; 2380 | } 2381 | } 2382 | else{ 2383 | if (dvb_attach(av201x_attach, adapter->fe2, &tbs6522_av201x_cfg[adapter->nr], 2384 | i2c) == NULL) { 2385 | dev_err(&dev->pci_dev->dev, 2386 | "frontend %d tuner attach failed\n", 2387 | adapter->nr); 2388 | goto frontend_atach_fail; 2389 | } 2390 | } 2391 | if (tbsecp3_attach_sec(adapter, adapter->fe2) == NULL) { 2392 | dev_warn(&dev->pci_dev->dev, 2393 | "error attaching lnb control on adapter %d\n", 2394 | adapter->nr); 2395 | } 2396 | 2397 | tbsecp3_ca_init(adapter, adapter->nr); 2398 | break; 2399 | 2400 | case TBSECP3_BOARD_TBS6902: 2401 | if(pci->subsystem_device!=0x0003){ 2402 | adapter->fe = dvb_attach(tas2101_attach, &tbs6902_demod_cfg[adapter->nr], i2c); 2403 | 2404 | if (adapter->fe == NULL) 2405 | goto frontend_atach_fail; 2406 | 2407 | if (dvb_attach(av201x_attach, adapter->fe, &tbs6902_av201x_cfg, 2408 | tas2101_get_i2c_adapter(adapter->fe, 2)) == NULL) { 2409 | dvb_frontend_detach(adapter->fe); 2410 | adapter->fe = NULL; 2411 | dev_err(&dev->pci_dev->dev, 2412 | "frontend %d tuner attach failed\n", 2413 | adapter->nr); 2414 | goto frontend_atach_fail; 2415 | } 2416 | 2417 | }else{ 2418 | adapter->fe = dvb_attach(gx1133_attach, &tbs6902_gx1133_cfg[adapter->nr], i2c); 2419 | 2420 | if (adapter->fe == NULL) 2421 | goto frontend_atach_fail; 2422 | 2423 | if (dvb_attach(av201x_attach, adapter->fe, &tbs6902_av201x_cfg, 2424 | gx1133_get_i2c_adapter(adapter->fe, 2)) == NULL) { 2425 | dvb_frontend_detach(adapter->fe); 2426 | adapter->fe = NULL; 2427 | dev_err(&dev->pci_dev->dev, 2428 | "frontend %d tuner attach failed\n", 2429 | adapter->nr); 2430 | goto frontend_atach_fail; 2431 | } 2432 | 2433 | } 2434 | 2435 | 2436 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2437 | dev_warn(&dev->pci_dev->dev, 2438 | "error attaching lnb control on adapter %d\n", 2439 | adapter->nr); 2440 | } 2441 | break; 2442 | 2443 | case TBSECP3_BOARD_TBS6903: 2444 | case TBSECP3_BOARD_TBS6905: 2445 | case TBSECP3_BOARD_TBS6908: 2446 | adapter->fe = dvb_attach(stv091x_attach, i2c, 2447 | &tbs6903_stv0910_cfg, adapter->nr & 1); 2448 | if (adapter->fe == NULL) 2449 | goto frontend_atach_fail; 2450 | 2451 | if (dvb_attach(stv6120_attach, adapter->fe, i2c, &tbs6903_stv6120_cfg, 1 - (adapter->nr & 1)) == NULL) { 2452 | dvb_frontend_detach(adapter->fe); 2453 | adapter->fe = NULL; 2454 | dev_err(&dev->pci_dev->dev, 2455 | "frontend %d tuner attach failed\n", 2456 | adapter->nr); 2457 | goto frontend_atach_fail; 2458 | } 2459 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2460 | dev_warn(&dev->pci_dev->dev, 2461 | "error attaching lnb control on adapter %d\n", 2462 | adapter->nr); 2463 | } 2464 | break; 2465 | 2466 | case TBSECP3_BOARD_TBS6904: 2467 | adapter->fe = dvb_attach(tas2101_attach, &tbs6904_demod_cfg[adapter->nr], i2c); 2468 | if (adapter->fe == NULL) 2469 | goto frontend_atach_fail; 2470 | 2471 | if (dvb_attach(av201x_attach, adapter->fe, &tbs6904_av201x_cfg, 2472 | tas2101_get_i2c_adapter(adapter->fe, 2)) == NULL) { 2473 | dvb_frontend_detach(adapter->fe); 2474 | adapter->fe = NULL; 2475 | dev_err(&dev->pci_dev->dev, 2476 | "frontend %d tuner attach failed\n", 2477 | adapter->nr); 2478 | goto frontend_atach_fail; 2479 | } 2480 | 2481 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2482 | dev_warn(&dev->pci_dev->dev, 2483 | "error attaching lnb control on adapter %d\n", 2484 | adapter->nr); 2485 | } 2486 | break; 2487 | 2488 | case TBSECP3_BOARD_TBS6909: 2489 | /* 2490 | tmp = tbs_read(TBS_GPIO_BASE, 0x20); 2491 | printk("RD 0x20 = %x\n", tmp); 2492 | tbs_write(TBS_GPIO_BASE, 0x20, tmp & 0xfffe); 2493 | tmp = tbs_read(TBS_GPIO_BASE, 0x20); 2494 | printk("RD 0x20 = %x\n", tmp); 2495 | 2496 | tmp = tbs_read(TBS_GPIO_BASE, 0x24); 2497 | printk("RD 0x24 = %x\n", tmp); 2498 | tbs_write(TBS_GPIO_BASE, 0x24, tmp & 0xfffc); 2499 | tmp = tbs_read(TBS_GPIO_BASE, 0x24); 2500 | printk("RD 0x24 = %x\n", tmp); 2501 | */ 2502 | 2503 | adapter->fe = dvb_attach(mxl58x_attach, i2c, 2504 | &tbs6909_mxl58x_cfg, adapter->nr); 2505 | if (adapter->fe == NULL) 2506 | goto frontend_atach_fail; 2507 | 2508 | // adapter->fe->ops.diseqc_send_master_cmd = max_send_master_cmd; 2509 | // adapter->fe->ops.diseqc_send_burst = max_send_burst; 2510 | 2511 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2512 | dev_warn(&dev->pci_dev->dev, 2513 | "error attaching lnb control on adapter %d\n", 2514 | adapter->nr); 2515 | } 2516 | break; 2517 | 2518 | case TBSECP3_BOARD_TBS6910: 2519 | adapter->fe = dvb_attach(tas2101_attach, &tbs6910_demod_cfg[adapter->nr], i2c); 2520 | if (adapter->fe == NULL) 2521 | goto frontend_atach_fail; 2522 | 2523 | if (dvb_attach(av201x_attach, adapter->fe, &tbs6910_av201x_cfg, 2524 | tas2101_get_i2c_adapter(adapter->fe, 2)) == NULL) { 2525 | dvb_frontend_detach(adapter->fe); 2526 | adapter->fe = NULL; 2527 | dev_err(&dev->pci_dev->dev, 2528 | "frontend %d tuner attach failed\n", 2529 | adapter->nr); 2530 | goto frontend_atach_fail; 2531 | } 2532 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2533 | dev_warn(&dev->pci_dev->dev, 2534 | "error attaching lnb control on adapter %d\n", 2535 | adapter->nr); 2536 | } 2537 | 2538 | tbsecp3_ca_init(adapter, adapter->nr); 2539 | break; 2540 | case TBSECP3_BOARD_TBS6916: 2541 | 2542 | if(adapter->nr<8) 2543 | adapter->fe = dvb_attach(stid135_attach, i2c, 2544 | &tbs6916_stid135_cfg[0], adapter->nr, adapter->nr/2); 2545 | else{ 2546 | 2547 | adapter->nr -= 8; 2548 | adapter->fe = dvb_attach(stid135_attach, i2c, 2549 | &tbs6916_stid135_cfg[1], adapter->nr, adapter->nr/2); 2550 | } 2551 | 2552 | if (adapter->fe == NULL) 2553 | goto frontend_atach_fail; 2554 | case TBSECP3_BOARD_TBS6909X: 2555 | if(pci->subsystem_device==0x0010) 2556 | adapter->fe = dvb_attach(stid135_attach, i2c, 2557 | &tbs6909x_stid135_cfg, adapter->nr, adapter->nr/2); 2558 | else 2559 | adapter->fe = dvb_attach(stid135_attach, i2c, 2560 | &tbs6909x_V2_stid135_cfg, adapter->nr, adapter->nr/2); 2561 | 2562 | if (adapter->fe == NULL) 2563 | goto frontend_atach_fail; 2564 | break; 2565 | 2566 | case TBSECP3_BOARD_TBS6903X: 2567 | case TBSECP3_BOARD_TBS6912: 2568 | if(pci->subsystem_vendor==0x6912) 2569 | adapter->fe = dvb_attach(stid135_attach, i2c, 2570 | &tbs6912_stid135_cfg, adapter->nr ? 2 : 0, adapter->nr ? 3 : 0); 2571 | else if(pci->subsystem_device==0x0021) 2572 | adapter->fe = dvb_attach(stid135_attach, i2c, 2573 | &tbs6903x_V2_stid135_cfg, adapter->nr ? 2 : 0, adapter->nr ? 3 : 0); 2574 | else 2575 | adapter->fe = dvb_attach(stid135_attach, i2c, 2576 | &tbs6903x_stid135_cfg, adapter->nr ? 2 : 0, adapter->nr ? 3 : 0); 2577 | 2578 | if (adapter->fe == NULL) 2579 | goto frontend_atach_fail; 2580 | 2581 | if (tbsecp3_attach_sec(adapter, adapter->fe) == NULL) { 2582 | dev_warn(&dev->pci_dev->dev, 2583 | "error attaching lnb control on adapter %d\n", 2584 | adapter->nr); 2585 | } 2586 | if(pci->subsystem_vendor==0x6912) 2587 | tbsecp3_ca_init(adapter, adapter->nr); 2588 | 2589 | break; 2590 | #endif 2591 | 2592 | default: 2593 | dev_warn(&dev->pci_dev->dev, "unknonw card\n"); 2594 | return -ENODEV; 2595 | break; 2596 | } 2597 | strscpy(adapter->fe->ops.info.name,dev->info->name,52); 2598 | if (adapter->fe2) 2599 | strscpy(adapter->fe2->ops.info.name,dev->info->name,52); 2600 | return 0; 2601 | 2602 | frontend_atach_fail: 2603 | tbsecp3_i2c_remove_clients(adapter); 2604 | if (adapter->fe != NULL) 2605 | dvb_frontend_detach(adapter->fe); 2606 | adapter->fe = NULL; 2607 | dev_err(&dev->pci_dev->dev, "TBSECP3 frontend %d attach failed\n", 2608 | adapter->nr); 2609 | 2610 | return -ENODEV; 2611 | } 2612 | 2613 | int tbsecp3_dvb_init(struct tbsecp3_adapter *adapter) 2614 | { 2615 | struct tbsecp3_dev *dev = adapter->dev; 2616 | struct dvb_adapter *adap = &adapter->dvb_adapter; 2617 | struct dvb_demux *dvbdemux = &adapter->demux; 2618 | struct dmxdev *dmxdev; 2619 | struct dvb_frontend *fe; 2620 | struct dmx_frontend *fe_hw; 2621 | struct dmx_frontend *fe_mem; 2622 | int ret; 2623 | 2624 | ret = dvb_register_adapter(adap, "TBSECP3 DVB Adapter", 2625 | THIS_MODULE, 2626 | &adapter->dev->pci_dev->dev, 2627 | adapter_nr); 2628 | if (ret < 0) { 2629 | dev_err(&dev->pci_dev->dev, "error registering adapter\n"); 2630 | if (ret == -ENFILE) 2631 | dev_err(&dev->pci_dev->dev, 2632 | "increase DVB_MAX_ADAPTERS (%d)\n", 2633 | DVB_MAX_ADAPTERS); 2634 | return ret; 2635 | } 2636 | 2637 | adap->priv = adapter; 2638 | dvbdemux->priv = adapter; 2639 | dvbdemux->filternum = 256; 2640 | dvbdemux->feednum = 256; 2641 | dvbdemux->start_feed = start_feed; 2642 | dvbdemux->stop_feed = stop_feed; 2643 | dvbdemux->write_to_decoder = NULL; 2644 | dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | 2645 | DMX_SECTION_FILTERING | 2646 | DMX_MEMORY_BASED_FILTERING); 2647 | 2648 | ret = dvb_dmx_init(dvbdemux); 2649 | if (ret < 0) { 2650 | dev_err(&dev->pci_dev->dev, "dvb_dmx_init failed\n"); 2651 | goto err0; 2652 | } 2653 | 2654 | dmxdev = &adapter->dmxdev; 2655 | 2656 | dmxdev->filternum = 256; 2657 | dmxdev->demux = &dvbdemux->dmx; 2658 | dmxdev->capabilities = 0; 2659 | 2660 | ret = dvb_dmxdev_init(dmxdev, adap); 2661 | if (ret < 0) { 2662 | dev_err(&dev->pci_dev->dev, "dvb_dmxdev_init failed\n"); 2663 | goto err1; 2664 | } 2665 | 2666 | fe_hw = &adapter->fe_hw; 2667 | fe_mem = &adapter->fe_mem; 2668 | 2669 | fe_hw->source = DMX_FRONTEND_0; 2670 | ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, fe_hw); 2671 | if ( ret < 0) { 2672 | dev_err(&dev->pci_dev->dev, "dvb_dmx_init failed"); 2673 | goto err2; 2674 | } 2675 | 2676 | fe_mem->source = DMX_MEMORY_FE; 2677 | ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, fe_mem); 2678 | if (ret < 0) { 2679 | dev_err(&dev->pci_dev->dev, "dvb_dmx_init failed"); 2680 | goto err3; 2681 | } 2682 | 2683 | ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, fe_hw); 2684 | if (ret < 0) { 2685 | dev_err(&dev->pci_dev->dev, "dvb_dmx_init failed"); 2686 | goto err4; 2687 | } 2688 | 2689 | ret = dvb_net_init(adap, &adapter->dvbnet, adapter->dmxdev.demux); 2690 | if (ret < 0) { 2691 | dev_err(&dev->pci_dev->dev, "dvb_net_init failed"); 2692 | goto err5; 2693 | } 2694 | 2695 | tbsecp3_frontend_attach(adapter); 2696 | if (adapter->fe == NULL) { 2697 | dev_err(&dev->pci_dev->dev, "frontend attach failed\n"); 2698 | ret = -ENODEV; 2699 | goto err6; 2700 | } 2701 | 2702 | if (adapter->fe && adapter->fe2 && swapfe) { 2703 | fe = adapter->fe; 2704 | adapter->fe = adapter->fe2; 2705 | adapter->fe2 = fe; 2706 | } 2707 | 2708 | ret = dvb_register_frontend(adap, adapter->fe); 2709 | if (ret < 0) { 2710 | dev_err(&dev->pci_dev->dev, "frontend register failed\n"); 2711 | goto err7; 2712 | } 2713 | 2714 | if (adapter->fe2 != NULL) { 2715 | ret = dvb_register_frontend(adap, adapter->fe2); 2716 | if (ret < 0) { 2717 | dev_err(&dev->pci_dev->dev, "frontend2 register failed\n"); 2718 | } 2719 | } 2720 | 2721 | 2722 | return ret; 2723 | 2724 | err7: 2725 | dvb_frontend_detach(adapter->fe); 2726 | err6: 2727 | tbsecp3_release_sec(adapter->fe); 2728 | 2729 | dvb_net_release(&adapter->dvbnet); 2730 | err5: 2731 | dvbdemux->dmx.close(&dvbdemux->dmx); 2732 | err4: 2733 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, fe_mem); 2734 | err3: 2735 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, fe_hw); 2736 | err2: 2737 | dvb_dmxdev_release(dmxdev); 2738 | err1: 2739 | dvb_dmx_release(dvbdemux); 2740 | err0: 2741 | dvb_unregister_adapter(adap); 2742 | return ret; 2743 | } 2744 | 2745 | void tbsecp3_dvb_exit(struct tbsecp3_adapter *adapter) 2746 | { 2747 | struct dvb_adapter *adap = &adapter->dvb_adapter; 2748 | struct dvb_demux *dvbdemux = &adapter->demux; 2749 | 2750 | if (adapter->fe) { 2751 | #ifdef TBS_DVB_EXTENSION 2752 | tbsecp3_ca_release(adapter); 2753 | #endif 2754 | dvb_unregister_frontend(adapter->fe); 2755 | tbsecp3_release_sec(adapter->fe); 2756 | dvb_frontend_detach(adapter->fe); 2757 | adapter->fe = NULL; 2758 | 2759 | if (adapter->fe2 != NULL) { 2760 | dvb_unregister_frontend(adapter->fe2); 2761 | tbsecp3_release_sec(adapter->fe2); 2762 | dvb_frontend_detach(adapter->fe2); 2763 | adapter->fe2 = NULL; 2764 | } 2765 | } 2766 | dvb_net_release(&adapter->dvbnet); 2767 | dvbdemux->dmx.close(&dvbdemux->dmx); 2768 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &adapter->fe_mem); 2769 | dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &adapter->fe_hw); 2770 | dvb_dmxdev_release(&adapter->dmxdev); 2771 | dvb_dmx_release(&adapter->demux); 2772 | dvb_unregister_adapter(adap); 2773 | } 2774 | -------------------------------------------------------------------------------- /tbsecp3-i2c.c: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "tbsecp3.h" 19 | 20 | union tbsecp3_i2c_ctrl { 21 | struct { 22 | u32 ctrl; 23 | u32 data; 24 | } raw; 25 | struct { 26 | u8 size:4; 27 | u8 saddr:2; 28 | u8 stop:1; 29 | u8 start:1; 30 | u8 read:1; 31 | u8 addr:7; 32 | u8 buf[6]; 33 | } bits; 34 | }; 35 | 36 | static int i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg, int num) 37 | { 38 | struct tbsecp3_i2c *bus = i2c_get_adapdata(adapter); 39 | struct tbsecp3_dev *dev = bus->dev; 40 | union tbsecp3_i2c_ctrl i2c_ctrl; 41 | int i, j, retval; 42 | u16 len, remaining, xfer_max; 43 | u8 *b; 44 | 45 | mutex_lock(&bus->lock); 46 | //clear the i2c status 47 | tbs_read(bus->base, 0x00); 48 | 49 | for (i = 0; i < num; i++) { 50 | 51 | b = msg[i].buf; 52 | remaining = msg[i].len; 53 | 54 | i2c_ctrl.raw.ctrl = 0; 55 | i2c_ctrl.bits.start = 1; 56 | i2c_ctrl.bits.addr = msg[i].addr; 57 | 58 | if (msg[i].flags & I2C_M_RD) { 59 | i2c_ctrl.bits.read = 1; 60 | xfer_max = 4; 61 | } else { 62 | xfer_max = 6; 63 | } 64 | 65 | do { 66 | if (remaining <= xfer_max) 67 | i2c_ctrl.bits.stop = 1; 68 | 69 | len = remaining > xfer_max ? xfer_max : remaining; 70 | i2c_ctrl.bits.size = len; 71 | 72 | if (!(msg[i].flags & I2C_M_RD)) { 73 | for (j = 0; j < len; j++) 74 | i2c_ctrl.bits.buf[j] = *b++; 75 | tbs_write(bus->base, TBSECP3_I2C_DATA, i2c_ctrl.raw.data); 76 | } 77 | bus->done = 0; 78 | tbs_write(bus->base, TBSECP3_I2C_CTRL, i2c_ctrl.raw.ctrl); 79 | retval = wait_event_timeout(bus->wq, bus->done == 1, HZ); 80 | if (retval == 0) { 81 | tbs_read(bus->base, TBSECP3_I2C_STAT); // restore iic to its original state 82 | dev_err(&dev->pci_dev->dev, "i2c xfer timeout\n"); 83 | retval = -EIO; 84 | goto i2c_xfer_exit; 85 | } 86 | 87 | j = tbs_read(bus->base, TBSECP3_I2C_CTRL); 88 | if (j & 0x04) { 89 | dev_err(&dev->pci_dev->dev, "i2c nack (%x)\n", j); 90 | retval = -EIO; 91 | goto i2c_xfer_exit; 92 | } 93 | 94 | if (msg[i].flags & I2C_M_RD) { 95 | i2c_ctrl.raw.data = tbs_read(bus->base, TBSECP3_I2C_DATA); 96 | memcpy(b, &i2c_ctrl.raw.data, len); 97 | b += len; 98 | } 99 | 100 | i2c_ctrl.bits.start = 0; 101 | remaining -= len; 102 | } while (remaining); 103 | 104 | } 105 | retval = num; 106 | i2c_xfer_exit: 107 | mutex_unlock(&bus->lock); 108 | return retval; 109 | } 110 | 111 | static u32 i2c_functionality(struct i2c_adapter *adap) 112 | { 113 | return I2C_FUNC_SMBUS_EMUL; 114 | } 115 | 116 | struct i2c_algorithm tbsecp3_i2c_algo_template = { 117 | .master_xfer = i2c_xfer, 118 | .functionality = i2c_functionality, 119 | }; 120 | 121 | static int tbsecp3_i2c_register(struct tbsecp3_i2c *bus) 122 | { 123 | struct tbsecp3_dev *dev = bus->dev; 124 | struct i2c_adapter *adap; 125 | 126 | init_waitqueue_head(&bus->wq); 127 | mutex_init(&bus->lock); 128 | 129 | adap = &bus->i2c_adap; 130 | strcpy(adap->name, "tbsecp3"); 131 | adap->algo = &tbsecp3_i2c_algo_template; 132 | adap->algo_data = (void*) bus; 133 | adap->dev.parent = &dev->pci_dev->dev; 134 | adap->owner = THIS_MODULE; 135 | 136 | strcpy(bus->i2c_client.name, "tbsecp3cli"); 137 | bus->i2c_client.adapter = adap; 138 | 139 | i2c_set_adapdata(&bus->i2c_adap, bus); 140 | return i2c_add_adapter(&bus->i2c_adap); 141 | } 142 | 143 | static void tbsecp3_i2c_unregister(struct tbsecp3_i2c *bus) 144 | { 145 | i2c_del_adapter(&bus->i2c_adap); 146 | } 147 | 148 | /* ----------------------------------------------------------------------- */ 149 | 150 | void tbsecp3_i2c_remove_clients(struct tbsecp3_adapter *adapter) 151 | { 152 | #if 0 153 | struct i2c_client *client_demod, *client_tuner; 154 | 155 | /* remove tuner I2C client */ 156 | client_tuner = adapter->i2c_client_tuner; 157 | if (client_tuner) { 158 | module_put(client_tuner->dev.driver->owner); 159 | i2c_unregister_device(client_tuner); 160 | adapter->i2c_client_tuner = NULL; 161 | } 162 | 163 | /* remove demodulator I2C client */ 164 | client_demod = adapter->i2c_client_demod; 165 | if (client_demod) { 166 | module_put(client_demod->dev.driver->owner); 167 | i2c_unregister_device(client_demod); 168 | adapter->i2c_client_demod = NULL; 169 | } 170 | #endif 171 | } 172 | 173 | void tbsecp3_i2c_reg_init(struct tbsecp3_dev *dev) 174 | { 175 | int i; 176 | u32 baud = dev->info->i2c_speed; 177 | 178 | /* default to 400kbps */ 179 | if (!baud) 180 | baud = 9; 181 | 182 | for (i = 0; i < 4; i++) { 183 | tbs_write(dev->i2c_bus[i].base, TBSECP3_I2C_BAUD, baud); 184 | tbs_read(dev->i2c_bus[i].base, TBSECP3_I2C_STAT); 185 | tbs_write(TBSECP3_INT_BASE, TBSECP3_I2C_IE(i), 1); 186 | } 187 | } 188 | 189 | int tbsecp3_i2c_init(struct tbsecp3_dev *dev) 190 | { 191 | int i, ret = 0; 192 | 193 | /* I2C Defaults / setup */ 194 | for (i = 0; i < 4; i++) { 195 | dev->i2c_bus[i].base = TBSECP3_I2C_BASE(i); 196 | dev->i2c_bus[i].dev = dev; 197 | ret = tbsecp3_i2c_register(&dev->i2c_bus[i]); 198 | if (ret) 199 | break; 200 | } 201 | if (ret) { 202 | do { 203 | tbsecp3_i2c_unregister(&dev->i2c_bus[i]); 204 | } while (i-- > 0); 205 | } else { 206 | tbsecp3_i2c_reg_init(dev); 207 | } 208 | return ret; 209 | } 210 | 211 | void tbsecp3_i2c_exit(struct tbsecp3_dev *dev) 212 | { 213 | int i; 214 | for (i = 0; i < 4; i++) 215 | tbsecp3_i2c_unregister(&dev->i2c_bus[i]); 216 | } 217 | 218 | -------------------------------------------------------------------------------- /tbsecp3-regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _TBSECP3_REGS_H_ 19 | #define _TBSECP3_REGS_H_ 20 | 21 | /* GPIO */ 22 | #define TBSECP3_GPIO_BASE 0x0000 23 | 24 | #define TBSECP3_GPIO_PIN(_bank, _pin) (((_bank) << 5) + _pin) 25 | 26 | /* I2C */ 27 | #define TBSECP3_I2C_BASE(_n) (0x4000 + 0x1000 * _n) 28 | #define TBSECP3_I2C_STAT 0x0000 29 | #define TBSECP3_I2C_CTRL 0x0000 30 | #define TBSECP3_I2C_DATA 0x0004 31 | #define TBSECP3_I2C_BAUD 0x0008 32 | 33 | /* CA */ 34 | #define TBSECP3_CA_BASE(_n) (0x6000 + 0x1000 * _n) 35 | 36 | /* DMA */ 37 | //#define TBSECP3_DMA_BASE(_n) (_n < 4) ? (0x8000 + 0x1000 * _n) : (0x8800 + 0x1000 * (_n - 4)) 38 | #define TBSECP3_DMA_BASE(_n) (_n<8)?((_n < 4) ? (0x8000 + 0x1000 * _n) : (0x8800 + 0x1000 * (_n - 4))): \ 39 | ((_n < 12) ? (0x8400 + 0x1000 *( _n - 8)) : (0x8C00 + 0x1000 * (_n - 12))) 40 | #define TBSECP3_DMA_STAT 0x0000 41 | #define TBSECP3_DMA_EN 0x0000 42 | #define TBSECP3_DMA_TSIZE 0x0004 43 | #define TBSECP3_DMA_ADDRH 0x0008 44 | #define TBSECP3_DMA_ADDRL 0x000c 45 | #define TBSECP3_DMA_BSIZE 0x0010 46 | #define TBSECP3_DMA_TLV_UNK 0x0014 47 | 48 | /* INTR */ 49 | #define TBSECP3_INT_BASE 0xc000 50 | #define TBSECP3_INT_STAT 0x0000 51 | #define TBSECP3_INT_EN 0x0004 52 | #define TBSECP3_I2C_IE(_n) (0x0008 + 4 * _n) 53 | #define TBSECP3_DMA_IE(_n) (0x0018 + 4 * _n) 54 | #define TBSECP3_I2C_IF(_n) (0x0001 << _n) 55 | #define TBSECP3_DMA_IF(_n) (0x0010 << _n) 56 | 57 | //spi flash 58 | #define SPI_CONFIG 0x10 59 | #define SPI_STATUS 0x10 60 | #define SPI_COMMAND 0x14 61 | #define SPI_WT_DATA 0x18 62 | #define SPI_RD_DATA 0x1c 63 | #define SPI_ENABLE 0x1c 64 | 65 | /* ASI */ 66 | #define ASI0_BASEADDRESS 0x4000 67 | #define ASI_CHIP_RST 0x00 68 | #define ASI_SPI_CONFIG 0x04 69 | #define ASI_SPI_CMD 0x08 70 | #define ASI_SPI_WT_32 0x0c 71 | #define ASI_SPI_ENABLE 0x10 72 | 73 | #define ASI_STATUS 0x00 74 | #define ASI_SPI_RD_32 0x04 75 | 76 | //-------------24cXX -------------------------------------------------------- 77 | #define BASE_ADDRESS_24CXX 0x4000 78 | #define CMD_24CXX 0*4 //write only 79 | #define DATA0_24CXX 1*4 //W/R 80 | #define DATA1_24CXX 2*4 //W/R 81 | #define CS_RELEASE 3*4 //write only 82 | 83 | #define STATUS_MAC16_24CXX 0*4 //read only 84 | #define MAC32_24CXX 3*4 //read only 85 | //--------------------------------------------------------------------- 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /tbsecp3.h: -------------------------------------------------------------------------------- 1 | /* 2 | TBS ECP3 FPGA based cards PCIe driver 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef _TBSECP3_H_ 19 | #define _TBSECP3_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "tbsecp3-regs.h" 40 | 41 | #define TBSECP3_VID 0x544d 42 | #define TBSECP3_PID 0x6178 43 | 44 | #ifdef TBS_DVB_EXTENSION 45 | #define TBSECP3_BOARD_TBS6205 0 46 | #define TBSECP3_BOARD_TBS6281SE 1 47 | #define TBSECP3_BOARD_TBS6290SE 2 48 | #define TBSECP3_BOARD_TBS6209 3 49 | #define TBSECP3_BOARD_TBS6522 4 50 | #define TBSECP3_BOARD_TBS6528 5 51 | #define TBSECP3_BOARD_TBS6590 6 52 | #define TBSECP3_BOARD_TBS6902 7 53 | #define TBSECP3_BOARD_TBS6903 8 54 | #define TBSECP3_BOARD_TBS6904 9 55 | #define TBSECP3_BOARD_TBS6905 10 56 | #define TBSECP3_BOARD_TBS6908 11 57 | #define TBSECP3_BOARD_TBS6909 12 58 | #define TBSECP3_BOARD_TBS6910 13 59 | #define TBSECP3_BOARD_TBS6704 14 60 | #define TBSECP3_BOARD_TBS6814 15 61 | #define TBSECP3_BOARD_TBS6514 16 62 | #define TBSECP3_BOARD_TBS690a 17 63 | #define TBSECP3_BOARD_TBS6301 18 64 | #define TBSECP3_BOARD_TBS6304 19 65 | #define TBSECP3_BOARD_TBS6308 20 66 | #define TBSECP3_BOARD_TBS6903X 21 67 | #define TBSECP3_BOARD_TBS6909X 22 68 | #define TBSECP3_BOARD_TBS6904X 23 69 | #define TBSECP3_BOARD_TBS6912 24 70 | #define TBSECP3_BOARD_TBS6504 25 71 | #define TBSECP3_BOARD_TBS6508 26 72 | #define TBSECP3_BOARD_TBS6302SE 27 73 | #define TBSECP3_BOARD_TBS6902SE 28 74 | #define TBSECP3_BOARD_TBS6904SE 29 75 | #define TBSECP3_BOARD_TBS6301SE 30 76 | #define TBSECP3_BOARD_TBS6910SE 31 77 | #define TBSECP3_BOARD_TBS7901 32 78 | #define TBSECP3_BOARD_TBS6209SE 33 79 | #define TBSECP3_BOARD_TBS7230 34 80 | #define TBSECP3_BOARD_TBS6302X 35 81 | #define TBSECP3_BOARD_TBS6302T 36 82 | #define TBSECP3_BOARD_TBS6304X 37 83 | #define TBSECP3_BOARD_TBS6290TD 38 84 | #define TBSECP3_BOARD_TBS6281TD 39 85 | #define TBSECP3_BOARD_TBS6205SE 40 86 | #define TBSECP3_BOARD_TBS6909SE 41 87 | #define TBSECP3_BOARD_TBS6304T 42 88 | #define TBSECP3_BOARD_TBS6522H 43 89 | #define TBSECP3_BOARD_TBS6504H 44 90 | #define TBSECP3_BOARD_TBS6590SE 45 91 | #define TBSECP3_BOARD_TBS6308X 46 92 | #define TBSECP3_BOARD_TBS6916 47 93 | #define TBSECP3_BOARD_TBS6312X 48 94 | #define TBSECP3_BOARD_TBS6324 49 95 | #define TBSECP3_BOARD_TBS6322 50 96 | #define TBSECP3_BOARD_TBS6812 51 97 | #else 98 | #define TBSECP3_BOARD_TBS6812 0 99 | #endif 100 | 101 | 102 | #define TBSECP3_MAX_ADAPTERS (16) 103 | #define TBSECP3_MAX_I2C_BUS (4) 104 | 105 | #define TBSECP3_GPIODEF_NONE (0) 106 | #define TBSECP3_GPIODEF_HIGH (1) 107 | #define TBSECP3_GPIODEF_LOW (2) 108 | 109 | #define TBSECP3_DMA_BUFFERS 16 110 | #define TBSECP3_DMA_PRE_BUFFERS 2 111 | 112 | 113 | struct tbsecp3_dev; 114 | 115 | 116 | struct tbsecp3_gpio_pin { 117 | u8 lvl; 118 | u8 nr; 119 | }; 120 | 121 | struct tbsecp3_gpio_config { 122 | struct tbsecp3_gpio_pin lnb_power; 123 | struct tbsecp3_gpio_pin lnb_voltage; 124 | struct tbsecp3_gpio_pin demod_reset; 125 | }; 126 | 127 | struct tbsecp3_adap_config { 128 | u32 ts_in; 129 | u8 i2c_bus_nr; 130 | bool tlv_dma; 131 | struct tbsecp3_gpio_config gpio; 132 | }; 133 | 134 | struct tbsecp3_board { 135 | u16 board_id; 136 | char *name; 137 | int adapters; 138 | u32 i2c_speed; 139 | u8 eeprom_i2c; 140 | u8 eeprom_addr; 141 | struct tbsecp3_adap_config adap_config[16]; 142 | }; 143 | 144 | struct tbsecp3_i2c { 145 | struct tbsecp3_dev *dev; 146 | u32 base; 147 | 148 | struct i2c_adapter i2c_adap; 149 | struct i2c_client i2c_client; 150 | 151 | struct mutex lock; 152 | wait_queue_head_t wq; 153 | bool done; 154 | }; 155 | 156 | struct tbsecp3_dma_channel { 157 | u32 base; 158 | dma_addr_t dma_addr; 159 | u32 page_size; 160 | u32 buffer_size; 161 | u32 buffer_pkts; 162 | u8 *buf[TBSECP3_DMA_BUFFERS + 1]; 163 | u8 offset; 164 | u8 cnt; 165 | u8 next_buffer; 166 | }; 167 | 168 | struct tbsecp3_ca { 169 | int nr; 170 | u32 base; 171 | struct dvb_ca_en50221 ca; 172 | 173 | struct tbsecp3_adapter *adapter; 174 | struct mutex lock; 175 | int status; 176 | }; 177 | 178 | struct tbsecp3_adapter { 179 | int nr; 180 | struct tbsecp3_adap_config *cfg; 181 | 182 | /* parent device */ 183 | struct tbsecp3_dev *dev; 184 | 185 | /* i2c */ 186 | struct tbsecp3_i2c *i2c; 187 | struct i2c_client *i2c_client_demod; 188 | struct i2c_client *i2c_client_tuner; 189 | 190 | /* dvb */ 191 | struct dvb_adapter dvb_adapter; 192 | struct dvb_frontend *fe; 193 | struct dvb_frontend *fe2; 194 | struct dvb_frontend _fe2; 195 | struct dvb_demux demux; 196 | struct dmxdev dmxdev; 197 | struct dvb_net dvbnet; 198 | struct dmx_frontend fe_hw; 199 | struct dmx_frontend fe_mem; 200 | int feeds; 201 | 202 | /* dma */ 203 | spinlock_t adap_lock; 204 | struct tasklet_struct tasklet; 205 | struct tbsecp3_dma_channel dma; 206 | 207 | /* ca interface */ 208 | struct tbsecp3_ca *tbsca; 209 | }; 210 | 211 | struct tbsecp3_dev { 212 | struct tbsecp3_board *info; 213 | 214 | /* pcie */ 215 | struct pci_dev *pci_dev; 216 | void __iomem *lmmio; 217 | bool msi; 218 | 219 | /* dvb adapters */ 220 | struct tbsecp3_adapter adapter[TBSECP3_MAX_ADAPTERS]; 221 | 222 | /* i2c */ 223 | struct tbsecp3_i2c i2c_bus[TBSECP3_MAX_I2C_BUS]; 224 | 225 | u8 mac_num; 226 | }; 227 | 228 | #define tbs_read(_b, _o) readl(dev->lmmio + (_b + _o)) 229 | #define tbs_write(_b, _o, _v) writel((_v), dev->lmmio + (_b + _o)) 230 | 231 | 232 | /* tbsecp3-core.c */ 233 | void tbsecp3_gpio_set_pin(struct tbsecp3_dev *dev, 234 | struct tbsecp3_gpio_pin *pin, int state); 235 | 236 | /* tbspcie-i2c.c */ 237 | extern int tbsecp3_i2c_init(struct tbsecp3_dev *dev); 238 | extern void tbsecp3_i2c_exit(struct tbsecp3_dev *dev); 239 | extern void tbsecp3_i2c_reg_init(struct tbsecp3_dev *dev); 240 | extern void tbsecp3_i2c_remove_clients(struct tbsecp3_adapter *adapter); 241 | 242 | /* tbspcie-cards.c */ 243 | extern struct tbsecp3_board tbsecp3_boards[]; 244 | 245 | /* tbspcie-dvb.c */ 246 | extern int tbsecp3_dvb_init(struct tbsecp3_adapter *adapter); 247 | extern void tbsecp3_dvb_exit(struct tbsecp3_adapter *adapter); 248 | 249 | /* tbsecp3-asi.c */ 250 | extern u8 asi_CheckFree(struct tbsecp3_dev *dev,int asi_base_addr, unsigned char OpbyteNum); 251 | extern bool asi_chip_reset(struct tbsecp3_dev *dev,int asi_base_addr); 252 | extern int asi_read16bit(struct tbsecp3_dev *dev,int asi_base_addr,int reg_addr); 253 | extern bool asi_write16bit(struct tbsecp3_dev *dev,int asi_base_addr, int reg_addr, int data16bit); 254 | 255 | /* tbsecp3-dma.c */ 256 | extern int tbsecp3_dma_init(struct tbsecp3_dev *dev); 257 | extern void tbsecp3_dma_free(struct tbsecp3_dev *dev); 258 | extern void tbsecp3_dma_reg_init(struct tbsecp3_dev *dev); 259 | extern void tbsecp3_dma_enable(struct tbsecp3_adapter *adap); 260 | extern void tbsecp3_dma_disable(struct tbsecp3_adapter *adap); 261 | 262 | /* tbsecp3-ca.c */ 263 | int tbsecp3_ca_init(struct tbsecp3_adapter *adap, int nr); 264 | void tbsecp3_ca_release(struct tbsecp3_adapter *adap); 265 | 266 | #endif 267 | --------------------------------------------------------------------------------