blob: ef1ebcb0420b2d5a4449a5717368763f9c25d664 [file] [log] [blame]
Steven Tothd19770e2007-03-11 20:44:05 -03001/*
2 * Driver for the Conexant CX23885 PCIe bridge
3 *
Steven Toth6d897612008-09-03 17:12:12 -03004 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
Steven Tothd19770e2007-03-11 20:44:05 -03005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
Steven Tothd19770e2007-03-11 20:44:05 -030016 */
17
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/fs.h>
22#include <linux/kthread.h>
23#include <linux/file.h>
24#include <linux/suspend.h>
25
26#include "cx23885.h"
Steven Tothd19770e2007-03-11 20:44:05 -030027#include <media/v4l2-common.h>
28
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030029#include "dvb_ca_en50221.h"
Steven Tothd19770e2007-03-11 20:44:05 -030030#include "s5h1409.h"
Michael Krufky52b50452008-07-09 02:18:49 -030031#include "s5h1411.h"
Steven Tothd19770e2007-03-11 20:44:05 -030032#include "mt2131.h"
Michael Krufky3ba71d22007-12-07 01:40:36 -030033#include "tda8290.h"
Michael Krufky4041f1a2007-12-24 04:52:08 -030034#include "tda18271.h"
Michael Krufky9bc37ca2007-09-08 15:17:13 -030035#include "lgdt330x.h"
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -030036#include "xc4000.h"
Steven Tothd1987d52007-12-18 01:57:06 -030037#include "xc5000.h"
David T. L. Wongea5697f2009-10-26 08:54:04 -030038#include "max2165.h"
Steven Tothb3ea0162008-04-19 01:14:19 -030039#include "tda10048.h"
Michael Krufky07b4a832007-12-18 01:09:11 -030040#include "tuner-xc2028.h"
Michael Krufky827855d2008-04-22 14:46:16 -030041#include "tuner-simple.h"
Steven Toth66762372008-04-22 15:38:26 -030042#include "dib7000p.h"
James Harper46b21bb2014-06-12 07:12:24 -030043#include "dib0070.h"
Steven Toth66762372008-04-22 15:38:26 -030044#include "dibx000_common.h"
Steven Tothaef2d182008-08-04 21:39:53 -030045#include "zl10353.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030046#include "stv0900.h"
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -030047#include "stv0900_reg.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030048#include "stv6110.h"
49#include "lnbh24.h"
Igor M. Liplianin96318d02009-01-17 12:11:20 -030050#include "cx24116.h"
Luis Alvese6001482013-10-01 22:11:35 -030051#include "cx24117.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030052#include "cimax2.h"
David Wong493b7122009-05-18 05:25:49 -030053#include "lgs8gxx.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030054#include "netup-eeprom.h"
55#include "netup-init.h"
Michael Krufkya5dbf452009-05-03 23:27:02 -030056#include "lgdt3305.h"
David T. L. Wongea5697f2009-10-26 08:54:04 -030057#include "atbm8830.h"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030058#include "ts2020.h"
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -030059#include "ds3000.h"
60#include "cx23885-f300.h"
Igor M. Liplianin78db8542011-01-25 17:04:00 -030061#include "altera-ci.h"
62#include "stv0367.h"
Stefan Ringel722c90e2012-01-07 09:20:48 -030063#include "drxk.h"
64#include "mt2063.h"
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -030065#include "stv090x.h"
66#include "stb6100.h"
67#include "stb6100_cfg.h"
Michael Krufky7c62f5a2012-12-15 23:34:09 -030068#include "tda10071.h"
69#include "a8293.h"
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -030070#include "mb86a20s.h"
Matthias Schwarzott36efec42014-07-22 17:12:13 -030071#include "si2165.h"
Olli Salonen29442262014-08-11 16:58:15 -030072#include "si2168.h"
73#include "si2157.h"
Olli Salonen24e77402014-10-04 03:59:30 -030074#include "sp2.h"
Olli Salonen29442262014-08-11 16:58:15 -030075#include "m88ds3103.h"
Antti Palosaari1fc77d02014-12-11 16:12:46 -030076#include "m88rs6000t.h"
Steven Tothd19770e2007-03-11 20:44:05 -030077
Steven Toth4513fc692008-01-12 11:36:36 -030078static unsigned int debug;
Steven Tothd19770e2007-03-11 20:44:05 -030079
Steven Toth4513fc692008-01-12 11:36:36 -030080#define dprintk(level, fmt, arg...)\
81 do { if (debug >= level)\
82 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
83 } while (0)
Steven Tothd19770e2007-03-11 20:44:05 -030084
85/* ------------------------------------------------------------------ */
86
Michael Krufky3ba71d22007-12-07 01:40:36 -030087static unsigned int alt_tuner;
88module_param(alt_tuner, int, 0644);
89MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
90
Janne Grunau78e92002008-04-09 19:13:13 -030091DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
92
Michael Krufky3ba71d22007-12-07 01:40:36 -030093/* ------------------------------------------------------------------ */
94
Hans Verkuil453afdd2014-08-14 06:43:01 -030095static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
96 unsigned int *num_buffers, unsigned int *num_planes,
97 unsigned int sizes[], void *alloc_ctxs[])
Steven Tothd19770e2007-03-11 20:44:05 -030098{
Hans Verkuil453afdd2014-08-14 06:43:01 -030099 struct cx23885_tsport *port = q->drv_priv;
Steven Tothd19770e2007-03-11 20:44:05 -0300100
101 port->ts_packet_size = 188 * 4;
102 port->ts_packet_count = 32;
Hans Verkuil453afdd2014-08-14 06:43:01 -0300103 *num_planes = 1;
104 sizes[0] = port->ts_packet_size * port->ts_packet_count;
Hans Verkuil0c3a14c2014-11-18 09:51:01 -0300105 alloc_ctxs[0] = port->dev->alloc_ctx;
Hans Verkuil453afdd2014-08-14 06:43:01 -0300106 *num_buffers = 32;
Steven Tothd19770e2007-03-11 20:44:05 -0300107 return 0;
108}
109
Hans Verkuil453afdd2014-08-14 06:43:01 -0300110
111static int buffer_prepare(struct vb2_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300112{
Hans Verkuil453afdd2014-08-14 06:43:01 -0300113 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
114 struct cx23885_buffer *buf =
115 container_of(vb, struct cx23885_buffer, vb);
116
117 return cx23885_buf_prepare(buf, port);
Steven Tothd19770e2007-03-11 20:44:05 -0300118}
119
Hans Verkuil453afdd2014-08-14 06:43:01 -0300120static void buffer_finish(struct vb2_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300121{
Hans Verkuil453afdd2014-08-14 06:43:01 -0300122 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
123 struct cx23885_dev *dev = port->dev;
124 struct cx23885_buffer *buf = container_of(vb,
125 struct cx23885_buffer, vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300126
127 cx23885_free_buffer(dev, buf);
Steven Tothd19770e2007-03-11 20:44:05 -0300128}
129
Hans Verkuil453afdd2014-08-14 06:43:01 -0300130static void buffer_queue(struct vb2_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300131{
Hans Verkuil453afdd2014-08-14 06:43:01 -0300132 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
133 struct cx23885_buffer *buf = container_of(vb,
134 struct cx23885_buffer, vb);
135
136 cx23885_buf_queue(port, buf);
Steven Tothd19770e2007-03-11 20:44:05 -0300137}
138
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300139static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
140{
Hans Verkuil453afdd2014-08-14 06:43:01 -0300141 struct vb2_dvb_frontends *f;
142 struct vb2_dvb_frontend *fe;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300143
144 f = &port->frontends;
145
146 if (f->gate <= 1) /* undefined or fe0 */
Hans Verkuil453afdd2014-08-14 06:43:01 -0300147 fe = vb2_dvb_get_frontend(f, 1);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300148 else
Hans Verkuil453afdd2014-08-14 06:43:01 -0300149 fe = vb2_dvb_get_frontend(f, f->gate);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300150
151 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
152 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
153}
154
Hans Verkuil453afdd2014-08-14 06:43:01 -0300155static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
156{
157 struct cx23885_tsport *port = q->drv_priv;
158 struct cx23885_dmaqueue *dmaq = &port->mpegq;
159 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
160 struct cx23885_buffer, queue);
161
162 cx23885_start_dma(port, dmaq, buf);
163 return 0;
164}
165
166static void cx23885_stop_streaming(struct vb2_queue *q)
167{
168 struct cx23885_tsport *port = q->drv_priv;
169
170 cx23885_cancel_buffers(port);
171}
172
173static struct vb2_ops dvb_qops = {
174 .queue_setup = queue_setup,
175 .buf_prepare = buffer_prepare,
176 .buf_finish = buffer_finish,
177 .buf_queue = buffer_queue,
178 .wait_prepare = vb2_ops_wait_prepare,
179 .wait_finish = vb2_ops_wait_finish,
180 .start_streaming = cx23885_start_streaming,
181 .stop_streaming = cx23885_stop_streaming,
Steven Tothd19770e2007-03-11 20:44:05 -0300182};
183
Steven Toth86184e02007-09-04 21:40:47 -0300184static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300185 .demod_address = 0x32 >> 1,
186 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300187 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300188 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300189 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300190 .status_mode = S5H1409_DEMODLOCKING,
191 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300192};
193
Steven Tothb3ea0162008-04-19 01:14:19 -0300194static struct tda10048_config hauppauge_hvr1200_config = {
195 .demod_address = 0x10 >> 1,
196 .output_mode = TDA10048_SERIAL_OUTPUT,
197 .fwbulkwritelen = TDA10048_BULKWRITE_200,
Steven Toth484d9e02009-05-02 11:08:23 -0300198 .inversion = TDA10048_INVERSION_ON,
Steven Toth8816bef2009-05-15 21:04:18 -0300199 .dtv6_if_freq_khz = TDA10048_IF_3300,
200 .dtv7_if_freq_khz = TDA10048_IF_3800,
201 .dtv8_if_freq_khz = TDA10048_IF_4300,
Steven Toth484d9e02009-05-02 11:08:23 -0300202 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300203};
204
Michael Krufky6b926ec2009-05-12 17:32:17 -0300205static struct tda10048_config hauppauge_hvr1210_config = {
206 .demod_address = 0x10 >> 1,
207 .output_mode = TDA10048_SERIAL_OUTPUT,
208 .fwbulkwritelen = TDA10048_BULKWRITE_200,
209 .inversion = TDA10048_INVERSION_ON,
Michael Krufkyc27586e2009-05-16 11:00:23 -0300210 .dtv6_if_freq_khz = TDA10048_IF_3300,
211 .dtv7_if_freq_khz = TDA10048_IF_3500,
212 .dtv8_if_freq_khz = TDA10048_IF_4000,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300213 .clk_freq_khz = TDA10048_CLK_16000,
214};
215
Michael Krufky3ba71d22007-12-07 01:40:36 -0300216static struct s5h1409_config hauppauge_ezqam_config = {
217 .demod_address = 0x32 >> 1,
218 .output_mode = S5H1409_SERIAL_OUTPUT,
219 .gpio = S5H1409_GPIO_OFF,
220 .qam_if = 4000,
221 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300222 .status_mode = S5H1409_DEMODLOCKING,
223 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300224};
225
Steven Tothfc959be2007-09-08 19:08:17 -0300226static struct s5h1409_config hauppauge_hvr1800lp_config = {
227 .demod_address = 0x32 >> 1,
228 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300229 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300230 .qam_if = 44000,
Steven Tothfe4751632007-03-20 15:27:53 -0300231 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300232 .status_mode = S5H1409_DEMODLOCKING,
233 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300234};
235
Michael Krufky07b4a832007-12-18 01:09:11 -0300236static struct s5h1409_config hauppauge_hvr1500_config = {
237 .demod_address = 0x32 >> 1,
238 .output_mode = S5H1409_SERIAL_OUTPUT,
239 .gpio = S5H1409_GPIO_OFF,
240 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300241 .status_mode = S5H1409_DEMODLOCKING,
242 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300243};
244
Steven Toth86184e02007-09-04 21:40:47 -0300245static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300246 0x61
247};
248
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300249static struct lgdt330x_config fusionhdtv_5_express = {
250 .demod_address = 0x0e,
251 .demod_chip = LGDT3303,
252 .serial_mpeg = 0x40,
253};
254
Steven Tothd1987d52007-12-18 01:57:06 -0300255static struct s5h1409_config hauppauge_hvr1500q_config = {
256 .demod_address = 0x32 >> 1,
257 .output_mode = S5H1409_SERIAL_OUTPUT,
258 .gpio = S5H1409_GPIO_ON,
259 .qam_if = 44000,
260 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300261 .status_mode = S5H1409_DEMODLOCKING,
262 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300263};
264
Michael Krufky335377b2008-05-07 01:43:10 -0300265static struct s5h1409_config dvico_s5h1409_config = {
266 .demod_address = 0x32 >> 1,
267 .output_mode = S5H1409_SERIAL_OUTPUT,
268 .gpio = S5H1409_GPIO_ON,
269 .qam_if = 44000,
270 .inversion = S5H1409_INVERSION_OFF,
271 .status_mode = S5H1409_DEMODLOCKING,
272 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
273};
274
Michael Krufky52b50452008-07-09 02:18:49 -0300275static struct s5h1411_config dvico_s5h1411_config = {
276 .output_mode = S5H1411_SERIAL_OUTPUT,
277 .gpio = S5H1411_GPIO_ON,
278 .qam_if = S5H1411_IF_44000,
279 .vsb_if = S5H1411_IF_44000,
280 .inversion = S5H1411_INVERSION_OFF,
281 .status_mode = S5H1411_DEMODLOCKING,
282 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
283};
284
Michael Krufky19bc5792009-05-08 16:05:29 -0300285static struct s5h1411_config hcw_s5h1411_config = {
286 .output_mode = S5H1411_SERIAL_OUTPUT,
287 .gpio = S5H1411_GPIO_OFF,
288 .vsb_if = S5H1411_IF_44000,
289 .qam_if = S5H1411_IF_4000,
290 .inversion = S5H1411_INVERSION_ON,
291 .status_mode = S5H1411_DEMODLOCKING,
292 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
293};
294
Steven Tothd1987d52007-12-18 01:57:06 -0300295static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300296 .i2c_address = 0x61,
297 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300298};
299
Michael Krufky335377b2008-05-07 01:43:10 -0300300static struct xc5000_config dvico_xc5000_tunerconfig = {
301 .i2c_address = 0x64,
302 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300303};
304
Michael Krufky4041f1a2007-12-24 04:52:08 -0300305static struct tda829x_config tda829x_no_probe = {
306 .probe_tuner = TDA829X_DONT_PROBE,
307};
308
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300309static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300310 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
311 .if_lvl = 6, .rfagc_top = 0x37 },
312 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
313 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300314};
315
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300316static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
317 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
318 .if_lvl = 1, .rfagc_top = 0x37, },
319 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
320 .if_lvl = 1, .rfagc_top = 0x37, },
321 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
322 .if_lvl = 1, .rfagc_top = 0x37, },
323};
324
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300325static struct tda18271_config hauppauge_tda18271_config = {
326 .std_map = &hauppauge_tda18271_std_map,
327 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300328 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300329};
330
Steven Tothb3ea0162008-04-19 01:14:19 -0300331static struct tda18271_config hauppauge_hvr1200_tuner_config = {
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300332 .std_map = &hauppauge_hvr1200_tda18271_std_map,
Steven Tothb3ea0162008-04-19 01:14:19 -0300333 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300334 .output_opt = TDA18271_OUTPUT_LT_OFF,
Steven Tothb3ea0162008-04-19 01:14:19 -0300335};
336
Michael Krufky6b926ec2009-05-12 17:32:17 -0300337static struct tda18271_config hauppauge_hvr1210_tuner_config = {
338 .gate = TDA18271_GATE_DIGITAL,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300339 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300340};
341
Matthias Schwarzott36efec42014-07-22 17:12:13 -0300342static struct tda18271_config hauppauge_hvr4400_tuner_config = {
343 .gate = TDA18271_GATE_DIGITAL,
344 .output_opt = TDA18271_OUTPUT_LT_OFF,
345};
346
Michael Krufky247bc542009-05-12 18:53:47 -0300347static struct tda18271_std_map hauppauge_hvr127x_std_map = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300348 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
349 .if_lvl = 1, .rfagc_top = 0x58 },
350 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
351 .if_lvl = 1, .rfagc_top = 0x58 },
352};
353
Michael Krufky247bc542009-05-12 18:53:47 -0300354static struct tda18271_config hauppauge_hvr127x_config = {
355 .std_map = &hauppauge_hvr127x_std_map,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300356 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300357};
358
Michael Krufky247bc542009-05-12 18:53:47 -0300359static struct lgdt3305_config hauppauge_lgdt3305_config = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300360 .i2c_addr = 0x0e,
361 .mpeg_mode = LGDT3305_MPEG_SERIAL,
362 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
363 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
364 .deny_i2c_rptr = 1,
365 .spectral_inversion = 1,
366 .qam_if_khz = 4000,
367 .vsb_if_khz = 3250,
368};
369
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700370static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300371 BAND_VHF | BAND_UHF, /* band_caps */
372
373 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
374 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
375 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
376 * P_agc_nb_est=2, P_agc_write=0
377 */
378 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
379 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
380
381 712, /* inv_gain */
382 21, /* time_stabiliz */
383
384 0, /* alpha_level */
385 118, /* thlock */
386
387 0, /* wbd_inv */
388 2867, /* wbd_ref */
389 0, /* wbd_sel */
390 2, /* wbd_alpha */
391
392 0, /* agc1_max */
393 0, /* agc1_min */
394 39718, /* agc2_max */
395 9930, /* agc2_min */
396 0, /* agc1_pt1 */
397 0, /* agc1_pt2 */
398 0, /* agc1_pt3 */
399 0, /* agc1_slope1 */
400 0, /* agc1_slope2 */
401 0, /* agc2_pt1 */
402 128, /* agc2_pt2 */
403 29, /* agc2_slope1 */
404 29, /* agc2_slope2 */
405
406 17, /* alpha_mant */
407 27, /* alpha_exp */
408 23, /* beta_mant */
409 51, /* beta_exp */
410
411 1, /* perform_agc_softsplit */
412};
413
414/* PLL Configuration for COFDM BW_MHz = 8.000000
415 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700416static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300417 60000, /* internal */
418 30000, /* sampling */
419 1, /* pll_cfg: prediv */
420 8, /* pll_cfg: ratio */
421 3, /* pll_cfg: range */
422 1, /* pll_cfg: reset */
423 0, /* pll_cfg: bypass */
424 0, /* misc: refdiv */
425 0, /* misc: bypclk_div */
426 1, /* misc: IO_CLK_en_core */
427 1, /* misc: ADClkSrc */
428 0, /* misc: modulo */
429 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
430 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
431 20452225, /* timf */
432 30000000 /* xtal_hz */
433};
434
435static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
436 .output_mpeg2_in_188_bytes = 1,
437 .hostbus_diversity = 1,
438 .tuner_is_baseband = 0,
439 .update_lna = NULL,
440
441 .agc_config_count = 1,
442 .agc = &xc3028_agc_config,
443 .bw = &xc3028_bw_config,
444
445 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
446 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
447 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
448
449 .pwm_freq_div = 0,
450 .agc_control = NULL,
451 .spur_protect = 0,
452
453 .output_mode = OUTMODE_MPEG2_SERIAL,
454};
455
Steven Tothaef2d182008-08-04 21:39:53 -0300456static struct zl10353_config dvico_fusionhdtv_xc3028 = {
457 .demod_address = 0x0f,
458 .if2 = 45600,
459 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300460 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300461};
462
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300463static struct stv0900_reg stv0900_ts_regs[] = {
464 { R0900_TSGENERAL, 0x00 },
465 { R0900_P1_TSSPEED, 0x40 },
466 { R0900_P2_TSSPEED, 0x40 },
467 { R0900_P1_TSCFGM, 0xc0 },
468 { R0900_P2_TSCFGM, 0xc0 },
469 { R0900_P1_TSCFGH, 0xe0 },
470 { R0900_P2_TSCFGH, 0xe0 },
471 { R0900_P1_TSCFGL, 0x20 },
472 { R0900_P2_TSCFGL, 0x20 },
473 { 0xffff, 0xff }, /* terminate */
474};
475
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300476static struct stv0900_config netup_stv0900_config = {
477 .demod_address = 0x68,
Igor M. Liplianin29372a82009-10-17 08:58:26 -0300478 .demod_mode = 1, /* dual */
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300479 .xtal = 8000000,
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300480 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
481 .diseqc_mode = 2,/* 2/3 PWM */
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300482 .ts_config_regs = stv0900_ts_regs,
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300483 .tun1_maddress = 0,/* 0x60 */
484 .tun2_maddress = 3,/* 0x63 */
485 .tun1_adc = 1,/* 1 Vpp */
486 .tun2_adc = 1,/* 1 Vpp */
487};
488
489static struct stv6110_config netup_stv6110_tunerconfig_a = {
490 .i2c_address = 0x60,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300491 .mclk = 16000000,
492 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300493 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300494};
495
496static struct stv6110_config netup_stv6110_tunerconfig_b = {
497 .i2c_address = 0x63,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300498 .mclk = 16000000,
499 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300500 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300501};
502
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300503static struct cx24116_config tbs_cx24116_config = {
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300504 .demod_address = 0x55,
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300505};
506
Luis Alvese6001482013-10-01 22:11:35 -0300507static struct cx24117_config tbs_cx24117_config = {
508 .demod_address = 0x55,
509};
510
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300511static struct ds3000_config tevii_ds3000_config = {
512 .demod_address = 0x68,
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300513};
514
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300515static struct ts2020_config tevii_ts2020_config = {
516 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300517 .clk_out_div = 1,
Joakim Hernberg8d2b0222014-01-31 07:15:48 -0300518 .frequency_div = 1146000,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300519};
520
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300521static struct cx24116_config dvbworld_cx24116_config = {
522 .demod_address = 0x05,
523};
524
David Wong493b7122009-05-18 05:25:49 -0300525static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
526 .prod = LGS8GXX_PROD_LGS8GL5,
527 .demod_address = 0x19,
528 .serial_ts = 0,
529 .ts_clk_pol = 1,
530 .ts_clk_gated = 1,
531 .if_clk_freq = 30400, /* 30.4 MHz */
532 .if_freq = 5380, /* 5.38 MHz */
533 .if_neg_center = 1,
534 .ext_adc = 0,
535 .adc_signed = 0,
536 .if_neg_edge = 0,
537};
538
539static struct xc5000_config mygica_x8506_xc5000_config = {
540 .i2c_address = 0x61,
541 .if_khz = 5380,
542};
543
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -0300544static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
545 .demod_address = 0x10,
546};
547
548static struct xc5000_config mygica_x8507_xc5000_config = {
549 .i2c_address = 0x61,
550 .if_khz = 4000,
551};
552
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300553static struct stv090x_config prof_8000_stv090x_config = {
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300554 .device = STV0903,
555 .demod_mode = STV090x_SINGLE,
556 .clk_mode = STV090x_CLK_EXT,
557 .xtal = 27000000,
558 .address = 0x6A,
559 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
560 .repeater_level = STV090x_RPTLEVEL_64,
561 .adc1_range = STV090x_ADC_2Vpp,
562 .diseqc_envelope_mode = false,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300563
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300564 .tuner_get_frequency = stb6100_get_frequency,
565 .tuner_set_frequency = stb6100_set_frequency,
566 .tuner_set_bandwidth = stb6100_set_bandwidth,
567 .tuner_get_bandwidth = stb6100_get_bandwidth,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300568};
569
570static struct stb6100_config prof_8000_stb6100_config = {
571 .tuner_address = 0x60,
572 .refclock = 27000000,
573};
574
575static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
576{
577 struct cx23885_tsport *port = fe->dvb->priv;
578 struct cx23885_dev *dev = port->dev;
579
580 if (voltage == SEC_VOLTAGE_18)
581 cx_write(MC417_RWD, 0x00001e00);
582 else if (voltage == SEC_VOLTAGE_13)
583 cx_write(MC417_RWD, 0x00001a00);
584 else
585 cx_write(MC417_RWD, 0x00001800);
586 return 0;
587}
588
Olli Salonen29442262014-08-11 16:58:15 -0300589static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
590 fe_sec_voltage_t voltage)
591{
592 struct cx23885_tsport *port = fe->dvb->priv;
593 struct cx23885_dev *dev = port->dev;
594
595 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
596
597 switch (voltage) {
598 case SEC_VOLTAGE_13:
599 cx23885_gpio_set(dev, GPIO_1);
600 cx23885_gpio_clear(dev, GPIO_0);
601 break;
602 case SEC_VOLTAGE_18:
603 cx23885_gpio_set(dev, GPIO_1);
604 cx23885_gpio_set(dev, GPIO_0);
605 break;
606 case SEC_VOLTAGE_OFF:
607 cx23885_gpio_clear(dev, GPIO_1);
608 cx23885_gpio_clear(dev, GPIO_0);
609 break;
610 }
611
612 /* call the frontend set_voltage function */
613 port->fe_set_voltage(fe, voltage);
614
615 return 0;
616}
617
nibble.maxc29d6a82014-11-05 11:58:38 -0300618static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
619 fe_sec_voltage_t voltage)
620{
621 struct cx23885_tsport *port = fe->dvb->priv;
622 struct cx23885_dev *dev = port->dev;
623
624 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
625
626 switch (voltage) {
627 case SEC_VOLTAGE_13:
628 cx23885_gpio_set(dev, GPIO_13);
629 cx23885_gpio_clear(dev, GPIO_12);
630 break;
631 case SEC_VOLTAGE_18:
632 cx23885_gpio_set(dev, GPIO_13);
633 cx23885_gpio_set(dev, GPIO_12);
634 break;
635 case SEC_VOLTAGE_OFF:
636 cx23885_gpio_clear(dev, GPIO_13);
637 cx23885_gpio_clear(dev, GPIO_12);
638 break;
639 }
640 /* call the frontend set_voltage function */
641 return port->fe_set_voltage(fe, voltage);
642}
643
Olli Salonen24e77402014-10-04 03:59:30 -0300644static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
645 u8 data, int *mem)
646{
647 /* MC417 */
648 #define SP2_DATA 0x000000ff
649 #define SP2_WR 0x00008000
650 #define SP2_RD 0x00004000
651 #define SP2_ACK 0x00001000
652 #define SP2_ADHI 0x00000800
653 #define SP2_ADLO 0x00000400
654 #define SP2_CS1 0x00000200
655 #define SP2_CS0 0x00000100
656 #define SP2_EN_ALL 0x00001000
657 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
658
659 struct cx23885_tsport *port = priv;
660 struct cx23885_dev *dev = port->dev;
661 int ret;
nibble.max0e6c7b02014-10-23 07:01:44 -0300662 int tmp = 0;
Olli Salonen24e77402014-10-04 03:59:30 -0300663 unsigned long timeout;
664
665 mutex_lock(&dev->gpio_lock);
666
667 /* write addr */
668 cx_write(MC417_OEN, SP2_EN_ALL);
669 cx_write(MC417_RWD, SP2_CTRL_OFF |
670 SP2_ADLO | (0xff & addr));
671 cx_clear(MC417_RWD, SP2_ADLO);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADHI | (0xff & (addr >> 8)));
674 cx_clear(MC417_RWD, SP2_ADHI);
675
676 if (read)
677 /* data in */
678 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
679 else
680 /* data out */
681 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
682
683 /* chip select 0 */
684 cx_clear(MC417_RWD, SP2_CS0);
685
686 /* read/write */
687 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
688
689 /* wait for a maximum of 1 msec */
690 timeout = jiffies + msecs_to_jiffies(1);
691 while (!time_after(jiffies, timeout)) {
692 tmp = cx_read(MC417_RWD);
693 if ((tmp & SP2_ACK) == 0)
694 break;
695 usleep_range(50, 100);
696 }
697
698 cx_set(MC417_RWD, SP2_CTRL_OFF);
699 *mem = tmp & 0xff;
700
701 mutex_unlock(&dev->gpio_lock);
702
703 if (!read) {
704 if (*mem < 0) {
705 ret = -EREMOTEIO;
706 goto err;
707 }
708 }
709
710 return 0;
711err:
712 return ret;
713}
714
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300715static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300716{
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300717 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300718 struct cx23885_tsport *port = fe->dvb->priv;
719 struct cx23885_dev *dev = port->dev;
720
721 switch (dev->board) {
722 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300723 switch (p->modulation) {
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300724 case VSB_8:
725 cx23885_gpio_clear(dev, GPIO_5);
726 break;
727 case QAM_64:
728 case QAM_256:
729 default:
730 cx23885_gpio_set(dev, GPIO_5);
731 break;
732 }
733 break;
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300734 case CX23885_BOARD_MYGICA_X8506:
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -0300735 case CX23885_BOARD_MYGICA_X8507:
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300736 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
737 /* Select Digital TV */
738 cx23885_gpio_set(dev, GPIO_0);
739 break;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300740 }
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -0300741
742 /* Call the real set_frontend */
743 if (port->set_frontend)
744 return port->set_frontend(fe);
745
Michael Krufky5bdd3962009-05-08 22:39:24 -0300746 return 0;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300747}
748
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -0300749static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
750 struct dvb_frontend *fe)
751{
752 port->set_frontend = fe->ops.set_frontend;
753 fe->ops.set_frontend = cx23885_dvb_set_frontend;
754}
755
David Wong2365b2d2009-06-17 01:38:12 -0300756static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
757 .prod = LGS8GXX_PROD_LGS8G75,
758 .demod_address = 0x19,
759 .serial_ts = 0,
760 .ts_clk_pol = 1,
761 .ts_clk_gated = 1,
762 .if_clk_freq = 30400, /* 30.4 MHz */
763 .if_freq = 6500, /* 6.50 MHz */
764 .if_neg_center = 1,
765 .ext_adc = 0,
766 .adc_signed = 1,
767 .adc_vpp = 2, /* 1.6 Vpp */
768 .if_neg_edge = 1,
769};
770
771static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
772 .i2c_address = 0x61,
773 .if_khz = 6500,
774};
775
David T. L. Wongea5697f2009-10-26 08:54:04 -0300776static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
777 .prod = ATBM8830_PROD_8830,
778 .demod_address = 0x44,
779 .serial_ts = 0,
780 .ts_sampling_edge = 1,
781 .ts_clk_gated = 0,
782 .osc_clk_freq = 30400, /* in kHz */
783 .if_freq = 0, /* zero IF */
784 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300785 .agc_min = 0x2E,
786 .agc_max = 0xFF,
787 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300788};
789
790static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
791 .i2c_address = 0x60,
792 .osc_clk = 20
793};
794
795static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
796 .prod = ATBM8830_PROD_8830,
797 .demod_address = 0x44,
798 .serial_ts = 1,
799 .ts_sampling_edge = 1,
800 .ts_clk_gated = 0,
801 .osc_clk_freq = 30400, /* in kHz */
802 .if_freq = 0, /* zero IF */
803 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300804 .agc_min = 0x2E,
805 .agc_max = 0xFF,
806 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300807};
808
809static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
810 .i2c_address = 0x60,
811 .osc_clk = 20
812};
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300813static struct stv0367_config netup_stv0367_config[] = {
814 {
815 .demod_address = 0x1c,
816 .xtal = 27000000,
817 .if_khz = 4500,
818 .if_iq_mode = 0,
819 .ts_mode = 1,
820 .clk_pol = 0,
821 }, {
822 .demod_address = 0x1d,
823 .xtal = 27000000,
824 .if_khz = 4500,
825 .if_iq_mode = 0,
826 .ts_mode = 1,
827 .clk_pol = 0,
828 },
829};
830
831static struct xc5000_config netup_xc5000_config[] = {
832 {
833 .i2c_address = 0x61,
834 .if_khz = 4500,
835 }, {
836 .i2c_address = 0x64,
837 .if_khz = 4500,
838 },
839};
840
Stefan Ringel722c90e2012-01-07 09:20:48 -0300841static struct drxk_config terratec_drxk_config[] = {
842 {
843 .adr = 0x29,
844 .no_i2c_bridge = 1,
845 }, {
846 .adr = 0x2a,
847 .no_i2c_bridge = 1,
848 },
849};
850
851static struct mt2063_config terratec_mt2063_config[] = {
852 {
853 .tuner_address = 0x60,
854 }, {
855 .tuner_address = 0x67,
856 },
857};
858
Antti Palosaari49bf0e62015-04-20 14:48:33 -0300859static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
860 .clk = 40444000, /* 40.444 MHz */
861 .i2c_wr_max = 64,
862 .ts_mode = TDA10071_TS_SERIAL,
863 .pll_multiplier = 20,
864 .tuner_i2c_addr = 0x54,
865};
866
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300867static const struct a8293_config hauppauge_a8293_config = {
868 .i2c_addr = 0x0b,
869};
870
Matthias Schwarzott36efec42014-07-22 17:12:13 -0300871static const struct si2165_config hauppauge_hvr4400_si2165_config = {
872 .i2c_addr = 0x64,
873 .chip_mode = SI2165_MODE_PLL_XTAL,
874 .ref_freq_Hz = 16000000,
875};
876
Olli Salonen29442262014-08-11 16:58:15 -0300877static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
878 .i2c_addr = 0x68,
879 .clock = 27000000,
880 .i2c_wr_max = 33,
881 .clock_out = 0,
882 .ts_mode = M88DS3103_TS_PARALLEL,
883 .ts_clk = 16000,
884 .ts_clk_pol = 1,
885 .lnb_en_pol = 1,
886 .lnb_hv_pol = 0,
887 .agc = 0x99,
888};
889
nibble.max0e6c7b02014-10-23 07:01:44 -0300890static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
891 .i2c_addr = 0x68,
892 .clock = 27000000,
893 .i2c_wr_max = 33,
894 .clock_out = 0,
895 .ts_mode = M88DS3103_TS_CI,
896 .ts_clk = 10000,
897 .ts_clk_pol = 1,
898 .lnb_en_pol = 1,
899 .lnb_hv_pol = 0,
900 .agc = 0x99,
901};
902
nibble.maxc29d6a82014-11-05 11:58:38 -0300903static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
904 .i2c_addr = 0x68,
905 .clock = 27000000,
906 .i2c_wr_max = 33,
907 .clock_out = 0,
908 .ts_mode = M88DS3103_TS_SERIAL,
909 .ts_clk = 96000,
910 .ts_clk_pol = 0,
911 .lnb_en_pol = 1,
912 .lnb_hv_pol = 0,
913 .agc = 0x99,
914};
915
Antti Palosaari1fc77d02014-12-11 16:12:46 -0300916static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
917 .i2c_addr = 0x69,
918 .clock = 27000000,
919 .i2c_wr_max = 33,
920 .ts_mode = M88DS3103_TS_PARALLEL,
921 .ts_clk = 16000,
922 .ts_clk_pol = 1,
923 .agc = 0x99,
924};
925
Mauro Carvalho Chehabada73ee2012-10-27 11:29:23 -0300926static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300927{
928 struct cx23885_dev *dev = (struct cx23885_dev *)device;
929 unsigned long timeout = jiffies + msecs_to_jiffies(1);
Abylay Ospand1644602011-01-02 09:10:00 -0300930 uint32_t mem = 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300931
Abylay Ospand1644602011-01-02 09:10:00 -0300932 mem = cx_read(MC417_RWD);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300933 if (read)
934 cx_set(MC417_OEN, ALT_DATA);
935 else {
936 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300937 mem &= ~ALT_DATA;
938 mem |= (data & ALT_DATA);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300939 }
940
941 if (flag)
Abylay Ospand1644602011-01-02 09:10:00 -0300942 mem |= ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300943 else
Abylay Ospand1644602011-01-02 09:10:00 -0300944 mem &= ~ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300945
Abylay Ospand1644602011-01-02 09:10:00 -0300946 mem &= ~ALT_CS;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300947 if (read)
Abylay Ospand1644602011-01-02 09:10:00 -0300948 mem = (mem & ~ALT_RD) | ALT_WR;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300949 else
Abylay Ospand1644602011-01-02 09:10:00 -0300950 mem = (mem & ~ALT_WR) | ALT_RD;
951
952 cx_write(MC417_RWD, mem); /* start RW cycle */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300953
954 for (;;) {
955 mem = cx_read(MC417_RWD);
956 if ((mem & ALT_RDY) == 0)
957 break;
958 if (time_after(jiffies, timeout))
959 break;
960 udelay(1);
961 }
962
963 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
964 if (read)
965 return mem & ALT_DATA;
966
967 return 0;
968};
David T. L. Wongea5697f2009-10-26 08:54:04 -0300969
James Harper46b21bb2014-06-12 07:12:24 -0300970static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
971{
972 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
973
974 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
975}
976
977static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
978{
979 return 0;
980}
981
982static struct dib0070_config dib7070p_dib0070_config = {
983 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
984 .reset = dib7070_tuner_reset,
985 .sleep = dib7070_tuner_sleep,
986 .clock_khz = 12000,
James Harper46b21bb2014-06-12 07:12:24 -0300987 .freq_offset_khz_vhf = 550,
988 /* .flip_chip = 1, */
989};
990
991/* DIB7070 generic */
992static struct dibx000_agc_config dib7070_agc_config = {
993 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
994
995 /*
996 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
997 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
998 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
999 */
1000 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1001 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1002 .inv_gain = 600,
1003 .time_stabiliz = 10,
1004 .alpha_level = 0,
1005 .thlock = 118,
1006 .wbd_inv = 0,
1007 .wbd_ref = 3530,
1008 .wbd_sel = 1,
1009 .wbd_alpha = 5,
1010 .agc1_max = 65535,
1011 .agc1_min = 0,
1012 .agc2_max = 65535,
1013 .agc2_min = 0,
1014 .agc1_pt1 = 0,
1015 .agc1_pt2 = 40,
1016 .agc1_pt3 = 183,
1017 .agc1_slope1 = 206,
1018 .agc1_slope2 = 255,
1019 .agc2_pt1 = 72,
1020 .agc2_pt2 = 152,
1021 .agc2_slope1 = 88,
1022 .agc2_slope2 = 90,
1023 .alpha_mant = 17,
1024 .alpha_exp = 27,
1025 .beta_mant = 23,
1026 .beta_exp = 51,
1027 .perform_agc_softsplit = 0,
1028};
1029
1030static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1031 .internal = 60000,
1032 .sampling = 15000,
1033 .pll_prediv = 1,
1034 .pll_ratio = 20,
1035 .pll_range = 3,
1036 .pll_reset = 1,
1037 .pll_bypass = 0,
1038 .enable_refdiv = 0,
1039 .bypclk_div = 0,
1040 .IO_CLK_en_core = 1,
1041 .ADClkSrc = 1,
1042 .modulo = 2,
1043 /* refsel, sel, freq_15k */
1044 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1045 .ifreq = (0 << 25) | 0,
1046 .timf = 20452225,
1047 .xtal_hz = 12000000,
1048};
1049
1050static struct dib7000p_config dib7070p_dib7000p_config = {
1051 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1052 .output_mode = OUTMODE_MPEG2_SERIAL,
1053 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1054 .output_mpeg2_in_188_bytes = 1,
1055
1056 .agc_config_count = 1,
1057 .agc = &dib7070_agc_config,
1058 .bw = &dib7070_bw_config_12_mhz,
1059 .tuner_is_baseband = 1,
1060 .spur_protect = 1,
1061
1062 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1063 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1064 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1065
1066 .hostbus_diversity = 1,
1067};
1068
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001069static int dvb_register_ci_mac(struct cx23885_tsport *port)
1070{
1071 struct cx23885_dev *dev = port->dev;
1072 struct i2c_client *client_ci = NULL;
1073 struct vb2_dvb_frontend *fe0;
1074
1075 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1076 if (!fe0)
1077 return -EINVAL;
1078
1079 switch (dev->board) {
1080 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1081 static struct netup_card_info cinfo;
1082
1083 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1084 memcpy(port->frontends.adapter.proposed_mac,
1085 cinfo.port[port->nr - 1].mac, 6);
1086 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1087 port->nr, port->frontends.adapter.proposed_mac);
1088
1089 netup_ci_init(port);
1090 return 0;
1091 }
1092 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1093 struct altera_ci_config netup_ci_cfg = {
1094 .dev = dev,/* magic number to identify*/
1095 .adapter = &port->frontends.adapter,/* for CI */
1096 .demux = &fe0->dvb.demux,/* for hw pid filter */
1097 .fpga_rw = netup_altera_fpga_rw,
1098 };
1099
1100 altera_ci_init(&netup_ci_cfg, port->nr);
1101 return 0;
1102 }
1103 case CX23885_BOARD_TEVII_S470: {
1104 u8 eeprom[256]; /* 24C02 i2c eeprom */
1105
1106 if (port->nr != 1)
1107 return 0;
1108
1109 /* Read entire EEPROM */
1110 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1111 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1112 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1113 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1114 return 0;
1115 }
1116 case CX23885_BOARD_DVBSKY_T9580:
1117 case CX23885_BOARD_DVBSKY_S950:
1118 case CX23885_BOARD_DVBSKY_S952:
1119 case CX23885_BOARD_DVBSKY_T982: {
1120 u8 eeprom[256]; /* 24C02 i2c eeprom */
1121
1122 if (port->nr > 2)
1123 return 0;
1124
1125 /* Read entire EEPROM */
1126 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1127 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1128 sizeof(eeprom));
1129 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1130 cx23885_boards[dev->board].name, port->nr,
1131 eeprom + 0xc0 + (port->nr-1) * 8);
1132 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1133 (port->nr-1) * 8, 6);
1134 return 0;
1135 }
1136 case CX23885_BOARD_DVBSKY_S950C:
1137 case CX23885_BOARD_DVBSKY_T980C:
1138 case CX23885_BOARD_TT_CT2_4500_CI: {
1139 u8 eeprom[256]; /* 24C02 i2c eeprom */
1140 struct sp2_config sp2_config;
1141 struct i2c_board_info info;
1142 struct cx23885_i2c *i2c_bus2 = &dev->i2c_bus[1];
1143
1144 /* attach CI */
1145 memset(&sp2_config, 0, sizeof(sp2_config));
1146 sp2_config.dvb_adap = &port->frontends.adapter;
1147 sp2_config.priv = port;
1148 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1149 memset(&info, 0, sizeof(struct i2c_board_info));
1150 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1151 info.addr = 0x40;
1152 info.platform_data = &sp2_config;
1153 request_module(info.type);
1154 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
1155 if (client_ci == NULL || client_ci->dev.driver == NULL)
1156 return -ENODEV;
1157 if (!try_module_get(client_ci->dev.driver->owner)) {
1158 i2c_unregister_device(client_ci);
1159 return -ENODEV;
1160 }
1161 port->i2c_client_ci = client_ci;
1162
1163 if (port->nr != 1)
1164 return 0;
1165
1166 /* Read entire EEPROM */
1167 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1168 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1169 sizeof(eeprom));
1170 printk(KERN_INFO "%s MAC address: %pM\n",
1171 cx23885_boards[dev->board].name, eeprom + 0xc0);
1172 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1173 return 0;
1174 }
1175 }
1176 return 0;
1177}
1178
Steven Tothd19770e2007-03-11 20:44:05 -03001179static int dvb_register(struct cx23885_tsport *port)
1180{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001181 struct dib7000p_ops dib7000p_ops;
Steven Tothd19770e2007-03-11 20:44:05 -03001182 struct cx23885_dev *dev = port->dev;
David Wong493b7122009-05-18 05:25:49 -03001183 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
Hans Verkuil453afdd2014-08-14 06:43:01 -03001184 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
Olli Salonen29442262014-08-11 16:58:15 -03001185 struct si2168_config si2168_config;
1186 struct si2157_config si2157_config;
Antti Palosaarid76e0872015-03-23 18:52:46 -03001187 struct ts2020_config ts2020_config;
Olli Salonen29442262014-08-11 16:58:15 -03001188 struct i2c_board_info info;
1189 struct i2c_adapter *adapter;
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001190 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03001191 struct i2c_client *client_sec = NULL;
nibble.maxc29d6a82014-11-05 11:58:38 -03001192 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1193 int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage) = NULL;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001194 int mfe_shared = 0; /* bus not shared by default */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001195 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -03001196
Darron Broadf972e0bd2008-10-11 11:24:30 -03001197 /* Get the first frontend */
Hans Verkuil453afdd2014-08-14 06:43:01 -03001198 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001199 if (!fe0)
1200 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001201
Hans Verkuil453afdd2014-08-14 06:43:01 -03001202 /* init struct vb2_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -03001203 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -03001204
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001205 /* multi-frontend gate control is undefined or defaults to fe0 */
1206 port->frontends.gate = 0;
1207
1208 /* Sets the gate control callback to be used by i2c command calls */
1209 port->gate_ctrl = cx23885_dvb_gate_ctrl;
1210
Steven Tothd19770e2007-03-11 20:44:05 -03001211 /* init frontend */
1212 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -03001213 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -03001214 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -03001215 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -03001216 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -03001217 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001218 if (fe0->dvb.frontend == NULL)
1219 break;
1220 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1221 &i2c_bus->i2c_adap,
1222 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03001223 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -03001224 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -03001225 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufkya5dbf452009-05-03 23:27:02 -03001226 i2c_bus = &dev->i2c_bus[0];
1227 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
Michael Krufky247bc542009-05-12 18:53:47 -03001228 &hauppauge_lgdt3305_config,
Michael Krufkya5dbf452009-05-03 23:27:02 -03001229 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001230 if (fe0->dvb.frontend == NULL)
1231 break;
1232 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1233 0x60, &dev->i2c_bus[1].i2c_adap,
1234 &hauppauge_hvr127x_config);
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -03001235 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
1236 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
Michael Krufkya5dbf452009-05-03 23:27:02 -03001237 break;
Michael Krufky19bc5792009-05-08 16:05:29 -03001238 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -03001239 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
Michael Krufky19bc5792009-05-08 16:05:29 -03001240 i2c_bus = &dev->i2c_bus[0];
1241 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1242 &hcw_s5h1411_config,
1243 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001244 if (fe0->dvb.frontend == NULL)
1245 break;
1246
1247 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1248 0x60, &dev->i2c_bus[1].i2c_adap,
1249 &hauppauge_tda18271_config);
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -03001250
1251 tda18271_attach(&dev->ts1.analog_fe,
1252 0x60, &dev->i2c_bus[1].i2c_adap,
1253 &hauppauge_tda18271_config);
1254
Michael Krufky19bc5792009-05-08 16:05:29 -03001255 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -03001256 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1257 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -03001258 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -03001259 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -03001260 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -03001261 dvb_attach(s5h1409_attach,
1262 &hauppauge_ezqam_config,
1263 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001264 if (fe0->dvb.frontend == NULL)
1265 break;
1266
1267 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1268 &dev->i2c_bus[1].i2c_adap, 0x42,
1269 &tda829x_no_probe);
1270 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1271 0x60, &dev->i2c_bus[1].i2c_adap,
1272 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -03001273 break;
1274 case 0:
1275 default:
Steven Toth363c35f2008-10-11 11:05:50 -03001276 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -03001277 dvb_attach(s5h1409_attach,
1278 &hauppauge_generic_config,
1279 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001280 if (fe0->dvb.frontend == NULL)
1281 break;
1282 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1283 &i2c_bus->i2c_adap,
1284 &hauppauge_generic_tunerconfig, 0);
Michael Krufky3ba71d22007-12-07 01:40:36 -03001285 }
1286 break;
Steven Tothfc959be2007-09-08 19:08:17 -03001287 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -03001288 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -03001289 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -03001290 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -03001291 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001292 if (fe0->dvb.frontend == NULL)
1293 break;
1294 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1295 &i2c_bus->i2c_adap,
1296 &hauppauge_generic_tunerconfig, 0);
Steven Tothfc959be2007-09-08 19:08:17 -03001297 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -03001298 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -03001299 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -03001300 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -03001301 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -03001302 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001303 if (fe0->dvb.frontend == NULL)
1304 break;
1305 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1306 &i2c_bus->i2c_adap, 0x61,
1307 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -03001308 break;
Steven Tothd1987d52007-12-18 01:57:06 -03001309 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1310 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -03001311 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -03001312 &hauppauge_hvr1500q_config,
1313 &dev->i2c_bus[0].i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001314 if (fe0->dvb.frontend == NULL)
1315 break;
1316 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1317 &i2c_bus->i2c_adap,
1318 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -03001319 break;
Michael Krufky07b4a832007-12-18 01:09:11 -03001320 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1321 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -03001322 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -03001323 &hauppauge_hvr1500_config,
1324 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001325 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -03001326 struct dvb_frontend *fe;
1327 struct xc2028_config cfg = {
1328 .i2c_adap = &i2c_bus->i2c_adap,
1329 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -03001330 };
1331 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001332 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -03001333 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -03001334 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -03001335 };
1336
1337 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001338 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -03001339 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1340 fe->ops.tuner_ops.set_config(fe, &ctl);
1341 }
1342 break;
Steven Tothb3ea0162008-04-19 01:14:19 -03001343 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -03001344 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -03001345 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -03001346 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -03001347 &hauppauge_hvr1200_config,
1348 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001349 if (fe0->dvb.frontend == NULL)
1350 break;
1351 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1352 &dev->i2c_bus[1].i2c_adap, 0x42,
1353 &tda829x_no_probe);
1354 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1355 0x60, &dev->i2c_bus[1].i2c_adap,
1356 &hauppauge_hvr1200_tuner_config);
Steven Tothb3ea0162008-04-19 01:14:19 -03001357 break;
Michael Krufky6b926ec2009-05-12 17:32:17 -03001358 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1359 i2c_bus = &dev->i2c_bus[0];
1360 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1361 &hauppauge_hvr1210_config,
1362 &i2c_bus->i2c_adap);
1363 if (fe0->dvb.frontend != NULL) {
1364 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1365 0x60, &dev->i2c_bus[1].i2c_adap,
1366 &hauppauge_hvr1210_tuner_config);
1367 }
1368 break;
Steven Toth66762372008-04-22 15:38:26 -03001369 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1370 i2c_bus = &dev->i2c_bus[0];
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001371
1372 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1373 return -ENODEV;
1374
1375 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
Steven Toth66762372008-04-22 15:38:26 -03001376 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -03001377 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -03001378 struct dvb_frontend *fe;
1379 struct xc2028_config cfg = {
1380 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1381 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -03001382 };
1383 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001384 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -03001385 .max_len = 64,
Mauro Carvalho Chehab9bed77e2011-07-28 16:38:54 -03001386 .demod = XC3028_FE_DIBCOM52,
Steven Toth9c8ced52008-10-16 20:18:44 -03001387 /* This is true for all demods with
1388 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -03001389 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -03001390 };
1391
1392 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001393 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -03001394 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1395 fe->ops.tuner_ops.set_config(fe, &ctl);
1396 }
1397 break;
Michael Krufky335377b2008-05-07 01:43:10 -03001398 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1399 i2c_bus = &dev->i2c_bus[port->nr - 1];
1400
Steven Toth363c35f2008-10-11 11:05:50 -03001401 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -03001402 &dvico_s5h1409_config,
1403 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001404 if (fe0->dvb.frontend == NULL)
1405 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -03001406 &dvico_s5h1411_config,
1407 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001408 if (fe0->dvb.frontend != NULL)
1409 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -03001410 &i2c_bus->i2c_adap,
1411 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -03001412 break;
Steven Tothaef2d182008-08-04 21:39:53 -03001413 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
1414 i2c_bus = &dev->i2c_bus[port->nr - 1];
1415
Steven Toth363c35f2008-10-11 11:05:50 -03001416 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -03001417 &dvico_fusionhdtv_xc3028,
1418 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001419 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -03001420 struct dvb_frontend *fe;
1421 struct xc2028_config cfg = {
1422 .i2c_adap = &i2c_bus->i2c_adap,
1423 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -03001424 };
1425 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001426 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -03001427 .max_len = 64,
1428 .demod = XC3028_FE_ZARLINK456,
1429 };
1430
Steven Toth363c35f2008-10-11 11:05:50 -03001431 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -03001432 &cfg);
1433 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1434 fe->ops.tuner_ops.set_config(fe, &ctl);
1435 }
1436 break;
1437 }
James Harper46b21bb2014-06-12 07:12:24 -03001438 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
1439 i2c_bus = &dev->i2c_bus[port->nr - 1];
1440 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1441 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1442
1443 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1444 return -ENODEV;
1445
1446 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1447 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1448 return -ENODEV;
1449 }
1450 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
1451 if (fe0->dvb.frontend != NULL) {
1452 struct i2c_adapter *tun_i2c;
1453
1454 fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
1455 memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
1456 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1457 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1458 return -ENODEV;
1459 }
1460 break;
1461 }
Steven Toth4c56b042008-08-12 13:30:03 -03001462 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -03001463 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -03001464 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth4c56b042008-08-12 13:30:03 -03001465 i2c_bus = &dev->i2c_bus[0];
1466
Steven Toth363c35f2008-10-11 11:05:50 -03001467 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -03001468 &dvico_fusionhdtv_xc3028,
1469 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001470 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -03001471 struct dvb_frontend *fe;
1472 struct xc2028_config cfg = {
1473 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1474 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -03001475 };
1476 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001477 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -03001478 .max_len = 64,
1479 .demod = XC3028_FE_ZARLINK456,
1480 };
1481
Steven Toth363c35f2008-10-11 11:05:50 -03001482 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -03001483 &cfg);
1484 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1485 fe->ops.tuner_ops.set_config(fe, &ctl);
1486 }
1487 break;
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -03001488 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1489 i2c_bus = &dev->i2c_bus[0];
1490
1491 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1492 &dvico_fusionhdtv_xc3028,
1493 &i2c_bus->i2c_adap);
1494 if (fe0->dvb.frontend != NULL) {
1495 struct dvb_frontend *fe;
1496 struct xc4000_config cfg = {
1497 .i2c_address = 0x61,
1498 .default_pm = 0,
1499 .dvb_amplitude = 134,
1500 .set_smoothedcvbs = 1,
1501 .if_khz = 4560
1502 };
1503
1504 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1505 &dev->i2c_bus[1].i2c_adap, &cfg);
Miroslav Slugena7c8aad2011-12-11 18:57:58 -03001506 if (!fe) {
1507 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1508 dev->name);
1509 goto frontend_detach;
1510 }
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -03001511 }
1512 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001513 case CX23885_BOARD_TBS_6920:
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001514 i2c_bus = &dev->i2c_bus[1];
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001515
1516 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001517 &tbs_cx24116_config,
1518 &i2c_bus->i2c_adap);
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001519 if (fe0->dvb.frontend != NULL)
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001520 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001521
1522 break;
Luis Alvese6001482013-10-01 22:11:35 -03001523 case CX23885_BOARD_TBS_6980:
1524 case CX23885_BOARD_TBS_6981:
1525 i2c_bus = &dev->i2c_bus[1];
1526
1527 switch (port->nr) {
1528 /* PORT B */
1529 case 1:
1530 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1531 &tbs_cx24117_config,
Luis Alvesd10e8282013-10-03 08:33:47 -03001532 &i2c_bus->i2c_adap);
Luis Alvese6001482013-10-01 22:11:35 -03001533 break;
1534 /* PORT C */
1535 case 2:
Luis Alvese6001482013-10-01 22:11:35 -03001536 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1537 &tbs_cx24117_config,
Luis Alvesd10e8282013-10-03 08:33:47 -03001538 &i2c_bus->i2c_adap);
Luis Alvese6001482013-10-01 22:11:35 -03001539 break;
1540 }
1541 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001542 case CX23885_BOARD_TEVII_S470:
1543 i2c_bus = &dev->i2c_bus[1];
1544
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001545 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1546 &tevii_ds3000_config,
1547 &i2c_bus->i2c_adap);
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001548 if (fe0->dvb.frontend != NULL) {
1549 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1550 &tevii_ts2020_config, &i2c_bus->i2c_adap);
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001551 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001552 }
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001553
1554 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -03001555 case CX23885_BOARD_DVBWORLD_2005:
1556 i2c_bus = &dev->i2c_bus[1];
1557
1558 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1559 &dvbworld_cx24116_config,
1560 &i2c_bus->i2c_adap);
1561 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001562 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1563 i2c_bus = &dev->i2c_bus[0];
1564 switch (port->nr) {
1565 /* port B */
1566 case 1:
1567 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1568 &netup_stv0900_config,
1569 &i2c_bus->i2c_adap, 0);
1570 if (fe0->dvb.frontend != NULL) {
1571 if (dvb_attach(stv6110_attach,
1572 fe0->dvb.frontend,
1573 &netup_stv6110_tunerconfig_a,
1574 &i2c_bus->i2c_adap)) {
1575 if (!dvb_attach(lnbh24_attach,
1576 fe0->dvb.frontend,
1577 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001578 LNBH24_PCL | LNBH24_TTX,
1579 LNBH24_TEN, 0x09))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001580 printk(KERN_ERR
1581 "No LNBH24 found!\n");
1582
1583 }
1584 }
1585 break;
1586 /* port C */
1587 case 2:
1588 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1589 &netup_stv0900_config,
1590 &i2c_bus->i2c_adap, 1);
1591 if (fe0->dvb.frontend != NULL) {
1592 if (dvb_attach(stv6110_attach,
1593 fe0->dvb.frontend,
1594 &netup_stv6110_tunerconfig_b,
1595 &i2c_bus->i2c_adap)) {
1596 if (!dvb_attach(lnbh24_attach,
1597 fe0->dvb.frontend,
1598 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001599 LNBH24_PCL | LNBH24_TTX,
1600 LNBH24_TEN, 0x0a))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001601 printk(KERN_ERR
1602 "No LNBH24 found!\n");
1603
1604 }
1605 }
1606 break;
1607 }
1608 break;
David Wong493b7122009-05-18 05:25:49 -03001609 case CX23885_BOARD_MYGICA_X8506:
1610 i2c_bus = &dev->i2c_bus[0];
1611 i2c_bus2 = &dev->i2c_bus[1];
1612 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1613 &mygica_x8506_lgs8gl5_config,
1614 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001615 if (fe0->dvb.frontend == NULL)
1616 break;
1617 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1618 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -03001619 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
David Wong493b7122009-05-18 05:25:49 -03001620 break;
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -03001621 case CX23885_BOARD_MYGICA_X8507:
1622 i2c_bus = &dev->i2c_bus[0];
1623 i2c_bus2 = &dev->i2c_bus[1];
1624 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1625 &mygica_x8507_mb86a20s_config,
1626 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001627 if (fe0->dvb.frontend == NULL)
1628 break;
1629
1630 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1631 &i2c_bus2->i2c_adap,
1632 &mygica_x8507_xc5000_config);
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -03001633 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1634 break;
David Wong2365b2d2009-06-17 01:38:12 -03001635 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1636 i2c_bus = &dev->i2c_bus[0];
1637 i2c_bus2 = &dev->i2c_bus[1];
1638 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1639 &magicpro_prohdtve2_lgs8g75_config,
1640 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001641 if (fe0->dvb.frontend == NULL)
1642 break;
1643 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1644 &i2c_bus2->i2c_adap,
1645 &magicpro_prohdtve2_xc5000_config);
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -03001646 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
David Wong2365b2d2009-06-17 01:38:12 -03001647 break;
Steven Toth136973802009-07-20 15:37:25 -03001648 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Steven Toth35045132012-01-04 21:08:35 -03001649 i2c_bus = &dev->i2c_bus[0];
1650 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1651 &hcw_s5h1411_config,
1652 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001653 if (fe0->dvb.frontend == NULL)
1654 break;
1655 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1656 0x60, &dev->i2c_bus[0].i2c_adap,
1657 &hauppauge_tda18271_config);
Steven Toth35045132012-01-04 21:08:35 -03001658
1659 tda18271_attach(&dev->ts1.analog_fe,
1660 0x60, &dev->i2c_bus[1].i2c_adap,
1661 &hauppauge_tda18271_config);
1662
1663 break;
Michael Krufkyaee0b242009-11-11 01:52:45 -03001664 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Toth136973802009-07-20 15:37:25 -03001665 i2c_bus = &dev->i2c_bus[0];
1666 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1667 &hcw_s5h1411_config,
1668 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001669 if (fe0->dvb.frontend == NULL)
1670 break;
1671 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1672 0x60, &dev->i2c_bus[0].i2c_adap,
1673 &hauppauge_tda18271_config);
Steven Toth136973802009-07-20 15:37:25 -03001674 break;
David T. L. Wongea5697f2009-10-26 08:54:04 -03001675 case CX23885_BOARD_MYGICA_X8558PRO:
1676 switch (port->nr) {
1677 /* port B */
1678 case 1:
1679 i2c_bus = &dev->i2c_bus[0];
1680 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1681 &mygica_x8558pro_atbm8830_cfg1,
1682 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001683 if (fe0->dvb.frontend == NULL)
1684 break;
1685 dvb_attach(max2165_attach, fe0->dvb.frontend,
1686 &i2c_bus->i2c_adap,
1687 &mygic_x8558pro_max2165_cfg1);
David T. L. Wongea5697f2009-10-26 08:54:04 -03001688 break;
1689 /* port C */
1690 case 2:
1691 i2c_bus = &dev->i2c_bus[1];
1692 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1693 &mygica_x8558pro_atbm8830_cfg2,
1694 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001695 if (fe0->dvb.frontend == NULL)
1696 break;
1697 dvb_attach(max2165_attach, fe0->dvb.frontend,
1698 &i2c_bus->i2c_adap,
1699 &mygic_x8558pro_max2165_cfg2);
David T. L. Wongea5697f2009-10-26 08:54:04 -03001700 }
1701 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001702 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1703 i2c_bus = &dev->i2c_bus[0];
1704 mfe_shared = 1;/* MFE */
1705 port->frontends.gate = 0;/* not clear for me yet */
1706 /* ports B, C */
1707 /* MFE frontend 1 DVB-T */
1708 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1709 &netup_stv0367_config[port->nr - 1],
1710 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001711 if (fe0->dvb.frontend == NULL)
1712 break;
1713 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001714 &i2c_bus->i2c_adap,
1715 &netup_xc5000_config[port->nr - 1]))
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001716 goto frontend_detach;
1717 /* load xc5000 firmware */
1718 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1719
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001720 /* MFE frontend 2 */
Hans Verkuil453afdd2014-08-14 06:43:01 -03001721 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001722 if (fe1 == NULL)
1723 goto frontend_detach;
1724 /* DVB-C init */
1725 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1726 &netup_stv0367_config[port->nr - 1],
1727 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001728 if (fe1->dvb.frontend == NULL)
1729 break;
1730
1731 fe1->dvb.frontend->id = 1;
1732 if (NULL == dvb_attach(xc5000_attach,
1733 fe1->dvb.frontend,
1734 &i2c_bus->i2c_adap,
1735 &netup_xc5000_config[port->nr - 1]))
1736 goto frontend_detach;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001737 break;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001738 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1739 i2c_bus = &dev->i2c_bus[0];
1740 i2c_bus2 = &dev->i2c_bus[1];
1741
1742 switch (port->nr) {
1743 /* port b */
1744 case 1:
1745 fe0->dvb.frontend = dvb_attach(drxk_attach,
1746 &terratec_drxk_config[0],
1747 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001748 if (fe0->dvb.frontend == NULL)
1749 break;
1750 if (!dvb_attach(mt2063_attach,
1751 fe0->dvb.frontend,
1752 &terratec_mt2063_config[0],
1753 &i2c_bus2->i2c_adap))
1754 goto frontend_detach;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001755 break;
1756 /* port c */
1757 case 2:
1758 fe0->dvb.frontend = dvb_attach(drxk_attach,
1759 &terratec_drxk_config[1],
1760 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001761 if (fe0->dvb.frontend == NULL)
1762 break;
1763 if (!dvb_attach(mt2063_attach,
1764 fe0->dvb.frontend,
1765 &terratec_mt2063_config[1],
1766 &i2c_bus2->i2c_adap))
1767 goto frontend_detach;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001768 break;
1769 }
1770 break;
Igor M. Liplianin7b134e82012-05-11 11:45:42 -03001771 case CX23885_BOARD_TEVII_S471:
1772 i2c_bus = &dev->i2c_bus[1];
1773
1774 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1775 &tevii_ds3000_config,
1776 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001777 if (fe0->dvb.frontend == NULL)
1778 break;
1779 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1780 &tevii_ts2020_config, &i2c_bus->i2c_adap);
Igor M. Liplianin7b134e82012-05-11 11:45:42 -03001781 break;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001782 case CX23885_BOARD_PROF_8000:
1783 i2c_bus = &dev->i2c_bus[0];
1784
1785 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1786 &prof_8000_stv090x_config,
1787 &i2c_bus->i2c_adap,
1788 STV090x_DEMODULATOR_0);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001789 if (fe0->dvb.frontend == NULL)
1790 break;
1791 if (!dvb_attach(stb6100_attach,
1792 fe0->dvb.frontend,
1793 &prof_8000_stb6100_config,
1794 &i2c_bus->i2c_adap))
1795 goto frontend_detach;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001796
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001797 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001798 break;
Antti Palosaaria45695072015-04-20 15:01:51 -03001799 case CX23885_BOARD_HAUPPAUGE_HVR4400: {
1800 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1801 struct a8293_platform_data a8293_pdata = {};
1802
Michael Krufky7c62f5a2012-12-15 23:34:09 -03001803 i2c_bus = &dev->i2c_bus[0];
Matthias Schwarzott36efec42014-07-22 17:12:13 -03001804 i2c_bus2 = &dev->i2c_bus[1];
1805 switch (port->nr) {
1806 /* port b */
1807 case 1:
Antti Palosaaria45695072015-04-20 15:01:51 -03001808 /* attach demod + tuner combo */
1809 memset(&info, 0, sizeof(info));
1810 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1811 info.addr = 0x05;
1812 info.platform_data = &tda10071_pdata;
1813 request_module("tda10071");
1814 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1815 if (!client_demod || !client_demod->dev.driver)
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001816 goto frontend_detach;
Antti Palosaaria45695072015-04-20 15:01:51 -03001817 if (!try_module_get(client_demod->dev.driver->owner)) {
1818 i2c_unregister_device(client_demod);
1819 goto frontend_detach;
1820 }
1821 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1822 port->i2c_client_demod = client_demod;
1823
1824 /* attach SEC */
1825 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1826 memset(&info, 0, sizeof(info));
1827 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1828 info.addr = 0x0b;
1829 info.platform_data = &a8293_pdata;
1830 request_module("a8293");
1831 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1832 if (!client_sec || !client_sec->dev.driver)
1833 goto frontend_detach;
1834 if (!try_module_get(client_sec->dev.driver->owner)) {
1835 i2c_unregister_device(client_sec);
1836 goto frontend_detach;
1837 }
1838 port->i2c_client_sec = client_sec;
Matthias Schwarzott36efec42014-07-22 17:12:13 -03001839 break;
1840 /* port c */
1841 case 2:
1842 fe0->dvb.frontend = dvb_attach(si2165_attach,
1843 &hauppauge_hvr4400_si2165_config,
1844 &i2c_bus->i2c_adap);
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03001845 if (fe0->dvb.frontend == NULL)
1846 break;
1847 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1848 if (!dvb_attach(tda18271_attach,
1849 fe0->dvb.frontend,
1850 0x60, &i2c_bus2->i2c_adap,
1851 &hauppauge_hvr4400_tuner_config))
1852 goto frontend_detach;
Matthias Schwarzott36efec42014-07-22 17:12:13 -03001853 break;
Michael Krufky7c62f5a2012-12-15 23:34:09 -03001854 }
1855 break;
Antti Palosaaria45695072015-04-20 15:01:51 -03001856 }
Antti Palosaari49bf0e62015-04-20 14:48:33 -03001857 case CX23885_BOARD_HAUPPAUGE_STARBURST: {
1858 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1859 struct a8293_platform_data a8293_pdata = {};
1860
Matthias Schwarzott721f3222014-12-22 19:51:39 -03001861 i2c_bus = &dev->i2c_bus[0];
Antti Palosaari49bf0e62015-04-20 14:48:33 -03001862
1863 /* attach demod + tuner combo */
1864 memset(&info, 0, sizeof(info));
1865 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1866 info.addr = 0x05;
1867 info.platform_data = &tda10071_pdata;
1868 request_module("tda10071");
1869 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1870 if (!client_demod || !client_demod->dev.driver)
1871 goto frontend_detach;
1872 if (!try_module_get(client_demod->dev.driver->owner)) {
1873 i2c_unregister_device(client_demod);
1874 goto frontend_detach;
Matthias Schwarzott721f3222014-12-22 19:51:39 -03001875 }
Antti Palosaari49bf0e62015-04-20 14:48:33 -03001876 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1877 port->i2c_client_demod = client_demod;
1878
1879 /* attach SEC */
1880 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1881 memset(&info, 0, sizeof(info));
1882 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1883 info.addr = 0x0b;
1884 info.platform_data = &a8293_pdata;
1885 request_module("a8293");
1886 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1887 if (!client_sec || !client_sec->dev.driver)
1888 goto frontend_detach;
1889 if (!try_module_get(client_sec->dev.driver->owner)) {
1890 i2c_unregister_device(client_sec);
1891 goto frontend_detach;
1892 }
1893 port->i2c_client_sec = client_sec;
Matthias Schwarzott721f3222014-12-22 19:51:39 -03001894 break;
Antti Palosaari49bf0e62015-04-20 14:48:33 -03001895 }
Olli Salonen29442262014-08-11 16:58:15 -03001896 case CX23885_BOARD_DVBSKY_T9580:
nibble.maxcba54802014-11-05 11:58:07 -03001897 case CX23885_BOARD_DVBSKY_S950:
Olli Salonen29442262014-08-11 16:58:15 -03001898 i2c_bus = &dev->i2c_bus[0];
1899 i2c_bus2 = &dev->i2c_bus[1];
1900 switch (port->nr) {
1901 /* port b - satellite */
1902 case 1:
1903 /* attach frontend */
1904 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1905 &dvbsky_t9580_m88ds3103_config,
1906 &i2c_bus2->i2c_adap, &adapter);
1907 if (fe0->dvb.frontend == NULL)
1908 break;
1909
1910 /* attach tuner */
Antti Palosaarid76e0872015-03-23 18:52:46 -03001911 memset(&ts2020_config, 0, sizeof(ts2020_config));
1912 ts2020_config.fe = fe0->dvb.frontend;
Olli Salonen29442262014-08-11 16:58:15 -03001913 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03001914 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
Olli Salonen29442262014-08-11 16:58:15 -03001915 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03001916 info.platform_data = &ts2020_config;
Olli Salonen29442262014-08-11 16:58:15 -03001917 request_module(info.type);
1918 client_tuner = i2c_new_device(adapter, &info);
1919 if (client_tuner == NULL ||
1920 client_tuner->dev.driver == NULL)
1921 goto frontend_detach;
1922 if (!try_module_get(client_tuner->dev.driver->owner)) {
1923 i2c_unregister_device(client_tuner);
1924 goto frontend_detach;
1925 }
1926
1927 /* delegate signal strength measurement to tuner */
1928 fe0->dvb.frontend->ops.read_signal_strength =
1929 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1930
1931 /*
1932 * for setting the voltage we need to set GPIOs on
1933 * the card.
1934 */
1935 port->fe_set_voltage =
1936 fe0->dvb.frontend->ops.set_voltage;
1937 fe0->dvb.frontend->ops.set_voltage =
1938 dvbsky_t9580_set_voltage;
1939
1940 port->i2c_client_tuner = client_tuner;
1941
1942 break;
1943 /* port c - terrestrial/cable */
1944 case 2:
1945 /* attach frontend */
Olli Salonen143800a2014-09-24 00:06:54 -03001946 memset(&si2168_config, 0, sizeof(si2168_config));
Olli Salonen29442262014-08-11 16:58:15 -03001947 si2168_config.i2c_adapter = &adapter;
1948 si2168_config.fe = &fe0->dvb.frontend;
1949 si2168_config.ts_mode = SI2168_TS_SERIAL;
1950 memset(&info, 0, sizeof(struct i2c_board_info));
1951 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1952 info.addr = 0x64;
1953 info.platform_data = &si2168_config;
1954 request_module(info.type);
1955 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1956 if (client_demod == NULL ||
1957 client_demod->dev.driver == NULL)
1958 goto frontend_detach;
1959 if (!try_module_get(client_demod->dev.driver->owner)) {
1960 i2c_unregister_device(client_demod);
1961 goto frontend_detach;
1962 }
1963 port->i2c_client_demod = client_demod;
1964
1965 /* attach tuner */
Olli Salonen143800a2014-09-24 00:06:54 -03001966 memset(&si2157_config, 0, sizeof(si2157_config));
Olli Salonen29442262014-08-11 16:58:15 -03001967 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03001968 si2157_config.if_port = 1;
Olli Salonen29442262014-08-11 16:58:15 -03001969 memset(&info, 0, sizeof(struct i2c_board_info));
1970 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1971 info.addr = 0x60;
1972 info.platform_data = &si2157_config;
1973 request_module(info.type);
1974 client_tuner = i2c_new_device(adapter, &info);
1975 if (client_tuner == NULL ||
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001976 client_tuner->dev.driver == NULL)
Olli Salonen29442262014-08-11 16:58:15 -03001977 goto frontend_detach;
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001978
Olli Salonen29442262014-08-11 16:58:15 -03001979 if (!try_module_get(client_tuner->dev.driver->owner)) {
1980 i2c_unregister_device(client_tuner);
Olli Salonen29442262014-08-11 16:58:15 -03001981 goto frontend_detach;
1982 }
1983 port->i2c_client_tuner = client_tuner;
1984 break;
1985 }
1986 break;
Olli Salonen82c10272014-09-29 04:44:16 -03001987 case CX23885_BOARD_DVBSKY_T980C:
Olli Salonen61b103e2014-10-30 17:48:27 -03001988 case CX23885_BOARD_TT_CT2_4500_CI:
Olli Salonen82c10272014-09-29 04:44:16 -03001989 i2c_bus = &dev->i2c_bus[1];
Olli Salonen24e77402014-10-04 03:59:30 -03001990 i2c_bus2 = &dev->i2c_bus[0];
Olli Salonen82c10272014-09-29 04:44:16 -03001991
1992 /* attach frontend */
1993 memset(&si2168_config, 0, sizeof(si2168_config));
1994 si2168_config.i2c_adapter = &adapter;
1995 si2168_config.fe = &fe0->dvb.frontend;
1996 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1997 memset(&info, 0, sizeof(struct i2c_board_info));
1998 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1999 info.addr = 0x64;
2000 info.platform_data = &si2168_config;
2001 request_module(info.type);
2002 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002003 if (client_demod == NULL || client_demod->dev.driver == NULL)
Olli Salonen82c10272014-09-29 04:44:16 -03002004 goto frontend_detach;
2005 if (!try_module_get(client_demod->dev.driver->owner)) {
2006 i2c_unregister_device(client_demod);
2007 goto frontend_detach;
2008 }
2009 port->i2c_client_demod = client_demod;
2010
2011 /* attach tuner */
2012 memset(&si2157_config, 0, sizeof(si2157_config));
2013 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002014 si2157_config.if_port = 1;
Olli Salonen82c10272014-09-29 04:44:16 -03002015 memset(&info, 0, sizeof(struct i2c_board_info));
2016 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2017 info.addr = 0x60;
2018 info.platform_data = &si2157_config;
2019 request_module(info.type);
2020 client_tuner = i2c_new_device(adapter, &info);
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002021 if (client_tuner == NULL ||
2022 client_tuner->dev.driver == NULL)
Olli Salonen82c10272014-09-29 04:44:16 -03002023 goto frontend_detach;
Olli Salonen82c10272014-09-29 04:44:16 -03002024 if (!try_module_get(client_tuner->dev.driver->owner)) {
2025 i2c_unregister_device(client_tuner);
Olli Salonen82c10272014-09-29 04:44:16 -03002026 goto frontend_detach;
2027 }
2028 port->i2c_client_tuner = client_tuner;
2029 break;
nibble.max0e6c7b02014-10-23 07:01:44 -03002030 case CX23885_BOARD_DVBSKY_S950C:
2031 i2c_bus = &dev->i2c_bus[1];
2032 i2c_bus2 = &dev->i2c_bus[0];
2033
2034 /* attach frontend */
2035 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2036 &dvbsky_s950c_m88ds3103_config,
2037 &i2c_bus->i2c_adap, &adapter);
2038 if (fe0->dvb.frontend == NULL)
2039 break;
2040
2041 /* attach tuner */
Antti Palosaarid76e0872015-03-23 18:52:46 -03002042 memset(&ts2020_config, 0, sizeof(ts2020_config));
2043 ts2020_config.fe = fe0->dvb.frontend;
nibble.max0e6c7b02014-10-23 07:01:44 -03002044 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03002045 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
nibble.max0e6c7b02014-10-23 07:01:44 -03002046 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03002047 info.platform_data = &ts2020_config;
nibble.max0e6c7b02014-10-23 07:01:44 -03002048 request_module(info.type);
2049 client_tuner = i2c_new_device(adapter, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002050 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
nibble.max0e6c7b02014-10-23 07:01:44 -03002051 goto frontend_detach;
2052 if (!try_module_get(client_tuner->dev.driver->owner)) {
2053 i2c_unregister_device(client_tuner);
2054 goto frontend_detach;
2055 }
2056
2057 /* delegate signal strength measurement to tuner */
2058 fe0->dvb.frontend->ops.read_signal_strength =
2059 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2060
2061 port->i2c_client_tuner = client_tuner;
2062 break;
nibble.maxc29d6a82014-11-05 11:58:38 -03002063 case CX23885_BOARD_DVBSKY_S952:
2064 switch (port->nr) {
2065 /* port b */
2066 case 1:
2067 i2c_bus = &dev->i2c_bus[1];
2068 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
2069 p_set_voltage = dvbsky_t9580_set_voltage;
2070 break;
2071 /* port c */
2072 case 2:
2073 i2c_bus = &dev->i2c_bus[0];
2074 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
2075 p_set_voltage = dvbsky_s952_portc_set_voltage;
2076 break;
2077 }
2078
2079 /* attach frontend */
2080 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2081 p_m88ds3103_config,
2082 &i2c_bus->i2c_adap, &adapter);
2083 if (fe0->dvb.frontend == NULL)
2084 break;
2085
2086 /* attach tuner */
Antti Palosaarid76e0872015-03-23 18:52:46 -03002087 memset(&ts2020_config, 0, sizeof(ts2020_config));
2088 ts2020_config.fe = fe0->dvb.frontend;
nibble.maxc29d6a82014-11-05 11:58:38 -03002089 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03002090 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
nibble.maxc29d6a82014-11-05 11:58:38 -03002091 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03002092 info.platform_data = &ts2020_config;
nibble.maxc29d6a82014-11-05 11:58:38 -03002093 request_module(info.type);
2094 client_tuner = i2c_new_device(adapter, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002095 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
nibble.maxc29d6a82014-11-05 11:58:38 -03002096 goto frontend_detach;
2097 if (!try_module_get(client_tuner->dev.driver->owner)) {
2098 i2c_unregister_device(client_tuner);
2099 goto frontend_detach;
2100 }
2101
2102 /* delegate signal strength measurement to tuner */
2103 fe0->dvb.frontend->ops.read_signal_strength =
2104 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2105
2106 /*
2107 * for setting the voltage we need to set GPIOs on
2108 * the card.
2109 */
2110 port->fe_set_voltage =
2111 fe0->dvb.frontend->ops.set_voltage;
2112 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2113
2114 port->i2c_client_tuner = client_tuner;
2115 break;
Nibble Maxc02ef642014-11-12 01:23:12 -03002116 case CX23885_BOARD_DVBSKY_T982:
2117 memset(&si2168_config, 0, sizeof(si2168_config));
2118 switch (port->nr) {
2119 /* port b */
2120 case 1:
2121 i2c_bus = &dev->i2c_bus[1];
2122 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2123 break;
2124 /* port c */
2125 case 2:
2126 i2c_bus = &dev->i2c_bus[0];
2127 si2168_config.ts_mode = SI2168_TS_SERIAL;
2128 break;
2129 }
2130
2131 /* attach frontend */
2132 si2168_config.i2c_adapter = &adapter;
2133 si2168_config.fe = &fe0->dvb.frontend;
2134 memset(&info, 0, sizeof(struct i2c_board_info));
2135 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2136 info.addr = 0x64;
2137 info.platform_data = &si2168_config;
2138 request_module(info.type);
2139 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002140 if (client_demod == NULL || client_demod->dev.driver == NULL)
Nibble Maxc02ef642014-11-12 01:23:12 -03002141 goto frontend_detach;
2142 if (!try_module_get(client_demod->dev.driver->owner)) {
2143 i2c_unregister_device(client_demod);
2144 goto frontend_detach;
2145 }
2146 port->i2c_client_demod = client_demod;
2147
2148 /* attach tuner */
2149 memset(&si2157_config, 0, sizeof(si2157_config));
2150 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002151 si2157_config.if_port = 1;
Nibble Maxc02ef642014-11-12 01:23:12 -03002152 memset(&info, 0, sizeof(struct i2c_board_info));
2153 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2154 info.addr = 0x60;
2155 info.platform_data = &si2157_config;
2156 request_module(info.type);
2157 client_tuner = i2c_new_device(adapter, &info);
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002158 if (client_tuner == NULL ||
2159 client_tuner->dev.driver == NULL)
Nibble Maxc02ef642014-11-12 01:23:12 -03002160 goto frontend_detach;
Nibble Maxc02ef642014-11-12 01:23:12 -03002161 if (!try_module_get(client_tuner->dev.driver->owner)) {
2162 i2c_unregister_device(client_tuner);
Nibble Maxc02ef642014-11-12 01:23:12 -03002163 goto frontend_detach;
2164 }
2165 port->i2c_client_tuner = client_tuner;
2166 break;
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002167 case CX23885_BOARD_HAUPPAUGE_HVR5525:
2168 switch (port->nr) {
2169 struct m88rs6000t_config m88rs6000t_config;
2170
2171 /* port b - satellite */
2172 case 1:
2173 /* attach frontend */
2174 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2175 &hauppauge_hvr5525_m88ds3103_config,
2176 &dev->i2c_bus[0].i2c_adap, &adapter);
2177 if (fe0->dvb.frontend == NULL)
2178 break;
2179
2180 /* attach SEC */
2181 if (!dvb_attach(a8293_attach, fe0->dvb.frontend,
2182 &dev->i2c_bus[0].i2c_adap,
2183 &hauppauge_a8293_config))
2184 goto frontend_detach;
2185
2186 /* attach tuner */
2187 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2188 m88rs6000t_config.fe = fe0->dvb.frontend;
2189 memset(&info, 0, sizeof(struct i2c_board_info));
2190 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2191 info.addr = 0x21;
2192 info.platform_data = &m88rs6000t_config;
2193 request_module("%s", info.type);
2194 client_tuner = i2c_new_device(adapter, &info);
2195 if (!client_tuner || !client_tuner->dev.driver)
2196 goto frontend_detach;
2197 if (!try_module_get(client_tuner->dev.driver->owner)) {
2198 i2c_unregister_device(client_tuner);
2199 goto frontend_detach;
2200 }
2201 port->i2c_client_tuner = client_tuner;
2202
2203 /* delegate signal strength measurement to tuner */
2204 fe0->dvb.frontend->ops.read_signal_strength =
2205 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2206 break;
2207 /* port c - terrestrial/cable */
2208 case 2:
2209 /* attach frontend */
2210 memset(&si2168_config, 0, sizeof(si2168_config));
2211 si2168_config.i2c_adapter = &adapter;
2212 si2168_config.fe = &fe0->dvb.frontend;
2213 si2168_config.ts_mode = SI2168_TS_SERIAL;
2214 memset(&info, 0, sizeof(struct i2c_board_info));
2215 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2216 info.addr = 0x64;
2217 info.platform_data = &si2168_config;
2218 request_module("%s", info.type);
2219 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2220 if (!client_demod || !client_demod->dev.driver)
2221 goto frontend_detach;
2222 if (!try_module_get(client_demod->dev.driver->owner)) {
2223 i2c_unregister_device(client_demod);
2224 goto frontend_detach;
2225 }
2226 port->i2c_client_demod = client_demod;
2227
2228 /* attach tuner */
2229 memset(&si2157_config, 0, sizeof(si2157_config));
2230 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002231 si2157_config.if_port = 1;
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002232 memset(&info, 0, sizeof(struct i2c_board_info));
2233 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2234 info.addr = 0x60;
2235 info.platform_data = &si2157_config;
2236 request_module("%s", info.type);
2237 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2238 if (!client_tuner || !client_tuner->dev.driver) {
2239 module_put(client_demod->dev.driver->owner);
2240 i2c_unregister_device(client_demod);
2241 port->i2c_client_demod = NULL;
2242 goto frontend_detach;
2243 }
2244 if (!try_module_get(client_tuner->dev.driver->owner)) {
2245 i2c_unregister_device(client_tuner);
2246 module_put(client_demod->dev.driver->owner);
2247 i2c_unregister_device(client_demod);
2248 port->i2c_client_demod = NULL;
2249 goto frontend_detach;
2250 }
2251 port->i2c_client_tuner = client_tuner;
2252 break;
2253 }
2254 break;
Steven Tothd19770e2007-03-11 20:44:05 -03002255 default:
Steven Toth9c8ced52008-10-16 20:18:44 -03002256 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2257 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -03002258 dev->name);
2259 break;
2260 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002261
2262 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
Steven Toth9c8ced52008-10-16 20:18:44 -03002263 printk(KERN_ERR "%s: frontend initialization failed\n",
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002264 dev->name);
2265 goto frontend_detach;
Steven Tothd19770e2007-03-11 20:44:05 -03002266 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002267
Michael Krufkyd7cba042008-09-12 13:31:45 -03002268 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03002269 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002270 if (fe1)
2271 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2272#if 0
2273 /* Ensure all frontends negotiate bus access */
2274 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2275 if (fe1)
2276 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2277#endif
Steven Tothd19770e2007-03-11 20:44:05 -03002278
2279 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03002280 call_all(dev, core, s_power, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03002281
Steven Toth363c35f2008-10-11 11:05:50 -03002282 if (fe0->dvb.frontend->ops.analog_ops.standby)
2283 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -03002284
Steven Tothd19770e2007-03-11 20:44:05 -03002285 /* register everything */
Hans Verkuil453afdd2014-08-14 06:43:01 -03002286 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03002287 &dev->pci->dev, adapter_nr, mfe_shared);
Abylay Ospanbee30192010-06-25 08:01:28 -03002288 if (ret)
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002289 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03002290
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002291 ret = dvb_register_ci_mac(port);
2292 if (ret)
2293 goto frontend_detach;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03002294
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002295 return 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002296
2297frontend_detach:
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03002298 /* remove I2C client for SEC */
2299 client_sec = port->i2c_client_sec;
2300 if (client_sec) {
2301 module_put(client_sec->dev.driver->owner);
2302 i2c_unregister_device(client_sec);
2303 port->i2c_client_sec = NULL;
2304 }
2305
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002306 /* remove I2C client for tuner */
2307 client_tuner = port->i2c_client_tuner;
2308 if (client_tuner) {
2309 module_put(client_tuner->dev.driver->owner);
2310 i2c_unregister_device(client_tuner);
2311 port->i2c_client_tuner = NULL;
2312 }
2313
2314 /* remove I2C client for demodulator */
2315 client_demod = port->i2c_client_demod;
2316 if (client_demod) {
2317 module_put(client_demod->dev.driver->owner);
2318 i2c_unregister_device(client_demod);
2319 port->i2c_client_demod = NULL;
2320 }
2321
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002322 port->gate_ctrl = NULL;
Hans Verkuil453afdd2014-08-14 06:43:01 -03002323 vb2_dvb_dealloc_frontends(&port->frontends);
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002324 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03002325}
2326
2327int cx23885_dvb_register(struct cx23885_tsport *port)
2328{
Steven Toth363c35f2008-10-11 11:05:50 -03002329
Hans Verkuil453afdd2014-08-14 06:43:01 -03002330 struct vb2_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -03002331 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -03002332 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -03002333
Steven Totheb0c58b2008-10-11 12:34:39 -03002334 /* Here we need to allocate the correct number of frontends,
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02002335 * as reflected in the cards struct. The reality is that currently
Steven Totheb0c58b2008-10-11 12:34:39 -03002336 * no cx23885 boards support this - yet. But, if we don't modify this
2337 * code then the second frontend would never be allocated (later)
2338 * and fail with error before the attach in dvb_register().
2339 * Without these changes we risk an OOPS later. The changes here
2340 * are for safety, and should provide a good foundation for the
2341 * future addition of any multi-frontend cx23885 based boards.
2342 */
2343 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
2344 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -03002345
Steven Totheb0c58b2008-10-11 12:34:39 -03002346 for (i = 1; i <= port->num_frontends; i++) {
Hans Verkuil453afdd2014-08-14 06:43:01 -03002347 struct vb2_queue *q;
2348
2349 if (vb2_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -03002350 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -03002351 printk(KERN_ERR "%s() failed to alloc\n", __func__);
2352 return -ENOMEM;
2353 }
Steven Tothd19770e2007-03-11 20:44:05 -03002354
Hans Verkuil453afdd2014-08-14 06:43:01 -03002355 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
Steven Totheb0c58b2008-10-11 12:34:39 -03002356 if (!fe0)
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03002357 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03002358
Steven Totheb0c58b2008-10-11 12:34:39 -03002359 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -03002360 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -03002361 dev->board,
2362 dev->name,
2363 dev->pci_bus,
2364 dev->pci_slot);
2365
2366 err = -ENODEV;
2367
2368 /* dvb stuff */
2369 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -03002370 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
Hans Verkuil453afdd2014-08-14 06:43:01 -03002371 q = &fe0->dvb.dvbq;
2372 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2373 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2374 q->gfp_flags = GFP_DMA32;
2375 q->min_buffers_needed = 2;
2376 q->drv_priv = port;
2377 q->buf_struct_size = sizeof(struct cx23885_buffer);
2378 q->ops = &dvb_qops;
2379 q->mem_ops = &vb2_dma_sg_memops;
2380 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2381 q->lock = &dev->lock;
2382
2383 err = vb2_queue_init(q);
2384 if (err < 0)
2385 return err;
Steven Totheb0c58b2008-10-11 12:34:39 -03002386 }
Steven Tothd19770e2007-03-11 20:44:05 -03002387 err = dvb_register(port);
2388 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -03002389 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
2390 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -03002391
Steven Tothd19770e2007-03-11 20:44:05 -03002392 return err;
2393}
2394
2395int cx23885_dvb_unregister(struct cx23885_tsport *port)
2396{
Hans Verkuil453afdd2014-08-14 06:43:01 -03002397 struct vb2_dvb_frontend *fe0;
Olli Salonenb0b12e62014-08-11 16:58:13 -03002398 struct i2c_client *client;
Steven Toth363c35f2008-10-11 11:05:50 -03002399
Olli Salonene450de42014-09-29 04:44:19 -03002400 /* remove I2C client for CI */
2401 client = port->i2c_client_ci;
2402 if (client) {
2403 module_put(client->dev.driver->owner);
2404 i2c_unregister_device(client);
2405 }
2406
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03002407 /* remove I2C client for SEC */
2408 client = port->i2c_client_sec;
2409 if (client) {
2410 module_put(client->dev.driver->owner);
2411 i2c_unregister_device(client);
2412 }
2413
Olli Salonenb0b12e62014-08-11 16:58:13 -03002414 /* remove I2C client for tuner */
2415 client = port->i2c_client_tuner;
2416 if (client) {
2417 module_put(client->dev.driver->owner);
2418 i2c_unregister_device(client);
2419 }
2420
2421 /* remove I2C client for demodulator */
2422 client = port->i2c_client_demod;
2423 if (client) {
2424 module_put(client->dev.driver->owner);
2425 i2c_unregister_device(client);
2426 }
2427
Hans Verkuil453afdd2014-08-14 06:43:01 -03002428 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
Olli Salonenb0b12e62014-08-11 16:58:13 -03002429
Abylay Ospane66131c2011-07-15 15:01:07 -03002430 if (fe0 && fe0->dvb.frontend)
Hans Verkuil453afdd2014-08-14 06:43:01 -03002431 vb2_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -03002432
Hans Verkuilafd96662009-03-13 13:24:19 -03002433 switch (port->dev->board) {
2434 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2435 netup_ci_exit(port);
2436 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002437 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2438 altera_ci_release(port->dev, port->nr);
2439 break;
Hans Verkuilafd96662009-03-13 13:24:19 -03002440 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03002441
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002442 port->gate_ctrl = NULL;
2443
Steven Tothd19770e2007-03-11 20:44:05 -03002444 return 0;
2445}