blob: 95aaa2e2afebd0d5373f9e3ec992daaeafd72c0a [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. Liplianin5a23b0762009-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. Liplianin5a23b0762009-03-03 12:06:09 -030046#include "stv0900.h"
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -030047#include "stv0900_reg.h"
Igor M. Liplianin5a23b0762009-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. Liplianin5a23b0762009-03-03 12:06:09 -030052#include "cimax2.h"
David Wong493b7122009-05-18 05:25:49 -030053#include "lgs8gxx.h"
Igor M. Liplianin5a23b0762009-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 Verkuildf9ecb02015-10-28 00:50:37 -020095static int queue_setup(struct vb2_queue *q,
Hans Verkuil453afdd2014-08-14 06:43:01 -030096 unsigned int *num_buffers, unsigned int *num_planes,
Hans Verkuil36c0f8b2016-04-15 09:15:05 -030097 unsigned int sizes[], struct device *alloc_devs[])
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;
105 *num_buffers = 32;
Steven Tothd19770e2007-03-11 20:44:05 -0300106 return 0;
107}
108
Hans Verkuil453afdd2014-08-14 06:43:01 -0300109
110static int buffer_prepare(struct vb2_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300111{
Junghak Sung2d700712015-09-22 10:30:30 -0300112 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300113 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
114 struct cx23885_buffer *buf =
Junghak Sung2d700712015-09-22 10:30:30 -0300115 container_of(vbuf, struct cx23885_buffer, vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300116
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{
Junghak Sung2d700712015-09-22 10:30:30 -0300122 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300123 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
124 struct cx23885_dev *dev = port->dev;
Junghak Sung2d700712015-09-22 10:30:30 -0300125 struct cx23885_buffer *buf = container_of(vbuf,
Hans Verkuil453afdd2014-08-14 06:43:01 -0300126 struct cx23885_buffer, vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300127
128 cx23885_free_buffer(dev, buf);
Steven Tothd19770e2007-03-11 20:44:05 -0300129}
130
Hans Verkuil453afdd2014-08-14 06:43:01 -0300131static void buffer_queue(struct vb2_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300132{
Junghak Sung2d700712015-09-22 10:30:30 -0300133 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil453afdd2014-08-14 06:43:01 -0300134 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
Junghak Sung2d700712015-09-22 10:30:30 -0300135 struct cx23885_buffer *buf = container_of(vbuf,
Hans Verkuil453afdd2014-08-14 06:43:01 -0300136 struct cx23885_buffer, vb);
137
138 cx23885_buf_queue(port, buf);
Steven Tothd19770e2007-03-11 20:44:05 -0300139}
140
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300141static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
142{
Hans Verkuil453afdd2014-08-14 06:43:01 -0300143 struct vb2_dvb_frontends *f;
144 struct vb2_dvb_frontend *fe;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300145
146 f = &port->frontends;
147
148 if (f->gate <= 1) /* undefined or fe0 */
Hans Verkuil453afdd2014-08-14 06:43:01 -0300149 fe = vb2_dvb_get_frontend(f, 1);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300150 else
Hans Verkuil453afdd2014-08-14 06:43:01 -0300151 fe = vb2_dvb_get_frontend(f, f->gate);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300152
153 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
154 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
155}
156
Hans Verkuil453afdd2014-08-14 06:43:01 -0300157static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
158{
159 struct cx23885_tsport *port = q->drv_priv;
160 struct cx23885_dmaqueue *dmaq = &port->mpegq;
161 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
162 struct cx23885_buffer, queue);
163
164 cx23885_start_dma(port, dmaq, buf);
165 return 0;
166}
167
168static void cx23885_stop_streaming(struct vb2_queue *q)
169{
170 struct cx23885_tsport *port = q->drv_priv;
171
172 cx23885_cancel_buffers(port);
173}
174
175static struct vb2_ops dvb_qops = {
176 .queue_setup = queue_setup,
177 .buf_prepare = buffer_prepare,
178 .buf_finish = buffer_finish,
179 .buf_queue = buffer_queue,
180 .wait_prepare = vb2_ops_wait_prepare,
181 .wait_finish = vb2_ops_wait_finish,
182 .start_streaming = cx23885_start_streaming,
183 .stop_streaming = cx23885_stop_streaming,
Steven Tothd19770e2007-03-11 20:44:05 -0300184};
185
Steven Toth86184e02007-09-04 21:40:47 -0300186static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300187 .demod_address = 0x32 >> 1,
188 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300189 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300190 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300191 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300192 .status_mode = S5H1409_DEMODLOCKING,
193 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300194};
195
Steven Tothb3ea0162008-04-19 01:14:19 -0300196static struct tda10048_config hauppauge_hvr1200_config = {
197 .demod_address = 0x10 >> 1,
198 .output_mode = TDA10048_SERIAL_OUTPUT,
199 .fwbulkwritelen = TDA10048_BULKWRITE_200,
Steven Toth484d9e02009-05-02 11:08:23 -0300200 .inversion = TDA10048_INVERSION_ON,
Steven Toth8816bef2009-05-15 21:04:18 -0300201 .dtv6_if_freq_khz = TDA10048_IF_3300,
202 .dtv7_if_freq_khz = TDA10048_IF_3800,
203 .dtv8_if_freq_khz = TDA10048_IF_4300,
Steven Toth484d9e02009-05-02 11:08:23 -0300204 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300205};
206
Michael Krufky6b926ec2009-05-12 17:32:17 -0300207static struct tda10048_config hauppauge_hvr1210_config = {
208 .demod_address = 0x10 >> 1,
209 .output_mode = TDA10048_SERIAL_OUTPUT,
210 .fwbulkwritelen = TDA10048_BULKWRITE_200,
211 .inversion = TDA10048_INVERSION_ON,
Michael Krufkyc27586e2009-05-16 11:00:23 -0300212 .dtv6_if_freq_khz = TDA10048_IF_3300,
213 .dtv7_if_freq_khz = TDA10048_IF_3500,
214 .dtv8_if_freq_khz = TDA10048_IF_4000,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300215 .clk_freq_khz = TDA10048_CLK_16000,
216};
217
Michael Krufky3ba71d22007-12-07 01:40:36 -0300218static struct s5h1409_config hauppauge_ezqam_config = {
219 .demod_address = 0x32 >> 1,
220 .output_mode = S5H1409_SERIAL_OUTPUT,
221 .gpio = S5H1409_GPIO_OFF,
222 .qam_if = 4000,
223 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300224 .status_mode = S5H1409_DEMODLOCKING,
225 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300226};
227
Steven Tothfc959be2007-09-08 19:08:17 -0300228static struct s5h1409_config hauppauge_hvr1800lp_config = {
229 .demod_address = 0x32 >> 1,
230 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300231 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300232 .qam_if = 44000,
Steven Tothfe475162007-03-20 15:27:53 -0300233 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300234 .status_mode = S5H1409_DEMODLOCKING,
235 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300236};
237
Michael Krufky07b4a832007-12-18 01:09:11 -0300238static struct s5h1409_config hauppauge_hvr1500_config = {
239 .demod_address = 0x32 >> 1,
240 .output_mode = S5H1409_SERIAL_OUTPUT,
241 .gpio = S5H1409_GPIO_OFF,
242 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300243 .status_mode = S5H1409_DEMODLOCKING,
244 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300245};
246
Steven Toth86184e02007-09-04 21:40:47 -0300247static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300248 0x61
249};
250
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300251static struct lgdt330x_config fusionhdtv_5_express = {
252 .demod_address = 0x0e,
253 .demod_chip = LGDT3303,
254 .serial_mpeg = 0x40,
255};
256
Steven Tothd1987d52007-12-18 01:57:06 -0300257static struct s5h1409_config hauppauge_hvr1500q_config = {
258 .demod_address = 0x32 >> 1,
259 .output_mode = S5H1409_SERIAL_OUTPUT,
260 .gpio = S5H1409_GPIO_ON,
261 .qam_if = 44000,
262 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300263 .status_mode = S5H1409_DEMODLOCKING,
264 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300265};
266
Michael Krufky335377b2008-05-07 01:43:10 -0300267static struct s5h1409_config dvico_s5h1409_config = {
268 .demod_address = 0x32 >> 1,
269 .output_mode = S5H1409_SERIAL_OUTPUT,
270 .gpio = S5H1409_GPIO_ON,
271 .qam_if = 44000,
272 .inversion = S5H1409_INVERSION_OFF,
273 .status_mode = S5H1409_DEMODLOCKING,
274 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
275};
276
Michael Krufky52b50452008-07-09 02:18:49 -0300277static struct s5h1411_config dvico_s5h1411_config = {
278 .output_mode = S5H1411_SERIAL_OUTPUT,
279 .gpio = S5H1411_GPIO_ON,
280 .qam_if = S5H1411_IF_44000,
281 .vsb_if = S5H1411_IF_44000,
282 .inversion = S5H1411_INVERSION_OFF,
283 .status_mode = S5H1411_DEMODLOCKING,
284 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
285};
286
Michael Krufky19bc5792009-05-08 16:05:29 -0300287static struct s5h1411_config hcw_s5h1411_config = {
288 .output_mode = S5H1411_SERIAL_OUTPUT,
289 .gpio = S5H1411_GPIO_OFF,
290 .vsb_if = S5H1411_IF_44000,
291 .qam_if = S5H1411_IF_4000,
292 .inversion = S5H1411_INVERSION_ON,
293 .status_mode = S5H1411_DEMODLOCKING,
294 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
295};
296
Steven Tothd1987d52007-12-18 01:57:06 -0300297static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300298 .i2c_address = 0x61,
299 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300300};
301
Michael Krufky335377b2008-05-07 01:43:10 -0300302static struct xc5000_config dvico_xc5000_tunerconfig = {
303 .i2c_address = 0x64,
304 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300305};
306
Michael Krufky4041f1a2007-12-24 04:52:08 -0300307static struct tda829x_config tda829x_no_probe = {
308 .probe_tuner = TDA829X_DONT_PROBE,
309};
310
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300311static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300312 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
313 .if_lvl = 6, .rfagc_top = 0x37 },
314 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
315 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300316};
317
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300318static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
319 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
320 .if_lvl = 1, .rfagc_top = 0x37, },
321 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
322 .if_lvl = 1, .rfagc_top = 0x37, },
323 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
324 .if_lvl = 1, .rfagc_top = 0x37, },
325};
326
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300327static struct tda18271_config hauppauge_tda18271_config = {
328 .std_map = &hauppauge_tda18271_std_map,
329 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300330 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300331};
332
Steven Tothb3ea0162008-04-19 01:14:19 -0300333static struct tda18271_config hauppauge_hvr1200_tuner_config = {
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300334 .std_map = &hauppauge_hvr1200_tda18271_std_map,
Steven Tothb3ea0162008-04-19 01:14:19 -0300335 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300336 .output_opt = TDA18271_OUTPUT_LT_OFF,
Steven Tothb3ea0162008-04-19 01:14:19 -0300337};
338
Michael Krufky6b926ec2009-05-12 17:32:17 -0300339static struct tda18271_config hauppauge_hvr1210_tuner_config = {
340 .gate = TDA18271_GATE_DIGITAL,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300341 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300342};
343
Matthias Schwarzott36efec42014-07-22 17:12:13 -0300344static struct tda18271_config hauppauge_hvr4400_tuner_config = {
345 .gate = TDA18271_GATE_DIGITAL,
346 .output_opt = TDA18271_OUTPUT_LT_OFF,
347};
348
Michael Krufky247bc542009-05-12 18:53:47 -0300349static struct tda18271_std_map hauppauge_hvr127x_std_map = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300350 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
351 .if_lvl = 1, .rfagc_top = 0x58 },
352 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
353 .if_lvl = 1, .rfagc_top = 0x58 },
354};
355
Michael Krufky247bc542009-05-12 18:53:47 -0300356static struct tda18271_config hauppauge_hvr127x_config = {
357 .std_map = &hauppauge_hvr127x_std_map,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300358 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300359};
360
Michael Krufky247bc542009-05-12 18:53:47 -0300361static struct lgdt3305_config hauppauge_lgdt3305_config = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300362 .i2c_addr = 0x0e,
363 .mpeg_mode = LGDT3305_MPEG_SERIAL,
364 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
365 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
366 .deny_i2c_rptr = 1,
367 .spectral_inversion = 1,
368 .qam_if_khz = 4000,
369 .vsb_if_khz = 3250,
370};
371
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700372static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300373 BAND_VHF | BAND_UHF, /* band_caps */
374
375 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
376 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
377 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
378 * P_agc_nb_est=2, P_agc_write=0
379 */
380 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
381 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
382
383 712, /* inv_gain */
384 21, /* time_stabiliz */
385
386 0, /* alpha_level */
387 118, /* thlock */
388
389 0, /* wbd_inv */
390 2867, /* wbd_ref */
391 0, /* wbd_sel */
392 2, /* wbd_alpha */
393
394 0, /* agc1_max */
395 0, /* agc1_min */
396 39718, /* agc2_max */
397 9930, /* agc2_min */
398 0, /* agc1_pt1 */
399 0, /* agc1_pt2 */
400 0, /* agc1_pt3 */
401 0, /* agc1_slope1 */
402 0, /* agc1_slope2 */
403 0, /* agc2_pt1 */
404 128, /* agc2_pt2 */
405 29, /* agc2_slope1 */
406 29, /* agc2_slope2 */
407
408 17, /* alpha_mant */
409 27, /* alpha_exp */
410 23, /* beta_mant */
411 51, /* beta_exp */
412
413 1, /* perform_agc_softsplit */
414};
415
416/* PLL Configuration for COFDM BW_MHz = 8.000000
417 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700418static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300419 60000, /* internal */
420 30000, /* sampling */
421 1, /* pll_cfg: prediv */
422 8, /* pll_cfg: ratio */
423 3, /* pll_cfg: range */
424 1, /* pll_cfg: reset */
425 0, /* pll_cfg: bypass */
426 0, /* misc: refdiv */
427 0, /* misc: bypclk_div */
428 1, /* misc: IO_CLK_en_core */
429 1, /* misc: ADClkSrc */
430 0, /* misc: modulo */
431 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
432 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
433 20452225, /* timf */
434 30000000 /* xtal_hz */
435};
436
437static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
438 .output_mpeg2_in_188_bytes = 1,
439 .hostbus_diversity = 1,
440 .tuner_is_baseband = 0,
441 .update_lna = NULL,
442
443 .agc_config_count = 1,
444 .agc = &xc3028_agc_config,
445 .bw = &xc3028_bw_config,
446
447 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
448 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
449 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
450
451 .pwm_freq_div = 0,
452 .agc_control = NULL,
453 .spur_protect = 0,
454
455 .output_mode = OUTMODE_MPEG2_SERIAL,
456};
457
Steven Tothaef2d182008-08-04 21:39:53 -0300458static struct zl10353_config dvico_fusionhdtv_xc3028 = {
459 .demod_address = 0x0f,
460 .if2 = 45600,
461 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300462 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300463};
464
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300465static struct stv0900_reg stv0900_ts_regs[] = {
466 { R0900_TSGENERAL, 0x00 },
467 { R0900_P1_TSSPEED, 0x40 },
468 { R0900_P2_TSSPEED, 0x40 },
469 { R0900_P1_TSCFGM, 0xc0 },
470 { R0900_P2_TSCFGM, 0xc0 },
471 { R0900_P1_TSCFGH, 0xe0 },
472 { R0900_P2_TSCFGH, 0xe0 },
473 { R0900_P1_TSCFGL, 0x20 },
474 { R0900_P2_TSCFGL, 0x20 },
475 { 0xffff, 0xff }, /* terminate */
476};
477
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300478static struct stv0900_config netup_stv0900_config = {
479 .demod_address = 0x68,
Igor M. Liplianin29372a82009-10-17 08:58:26 -0300480 .demod_mode = 1, /* dual */
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300481 .xtal = 8000000,
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300482 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
483 .diseqc_mode = 2,/* 2/3 PWM */
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300484 .ts_config_regs = stv0900_ts_regs,
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300485 .tun1_maddress = 0,/* 0x60 */
486 .tun2_maddress = 3,/* 0x63 */
487 .tun1_adc = 1,/* 1 Vpp */
488 .tun2_adc = 1,/* 1 Vpp */
489};
490
491static struct stv6110_config netup_stv6110_tunerconfig_a = {
492 .i2c_address = 0x60,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300493 .mclk = 16000000,
494 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300495 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300496};
497
498static struct stv6110_config netup_stv6110_tunerconfig_b = {
499 .i2c_address = 0x63,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300500 .mclk = 16000000,
501 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300502 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300503};
504
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300505static struct cx24116_config tbs_cx24116_config = {
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300506 .demod_address = 0x55,
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300507};
508
Luis Alvese6001482013-10-01 22:11:35 -0300509static struct cx24117_config tbs_cx24117_config = {
510 .demod_address = 0x55,
511};
512
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300513static struct ds3000_config tevii_ds3000_config = {
514 .demod_address = 0x68,
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300515};
516
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300517static struct ts2020_config tevii_ts2020_config = {
518 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300519 .clk_out_div = 1,
Joakim Hernberg8d2b0222014-01-31 07:15:48 -0300520 .frequency_div = 1146000,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300521};
522
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300523static struct cx24116_config dvbworld_cx24116_config = {
524 .demod_address = 0x05,
525};
526
David Wong493b7122009-05-18 05:25:49 -0300527static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
528 .prod = LGS8GXX_PROD_LGS8GL5,
529 .demod_address = 0x19,
530 .serial_ts = 0,
531 .ts_clk_pol = 1,
532 .ts_clk_gated = 1,
533 .if_clk_freq = 30400, /* 30.4 MHz */
534 .if_freq = 5380, /* 5.38 MHz */
535 .if_neg_center = 1,
536 .ext_adc = 0,
537 .adc_signed = 0,
538 .if_neg_edge = 0,
539};
540
541static struct xc5000_config mygica_x8506_xc5000_config = {
542 .i2c_address = 0x61,
543 .if_khz = 5380,
544};
545
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -0300546static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
547 .demod_address = 0x10,
548};
549
550static struct xc5000_config mygica_x8507_xc5000_config = {
551 .i2c_address = 0x61,
552 .if_khz = 4000,
553};
554
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300555static struct stv090x_config prof_8000_stv090x_config = {
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300556 .device = STV0903,
557 .demod_mode = STV090x_SINGLE,
558 .clk_mode = STV090x_CLK_EXT,
559 .xtal = 27000000,
560 .address = 0x6A,
561 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
562 .repeater_level = STV090x_RPTLEVEL_64,
563 .adc1_range = STV090x_ADC_2Vpp,
564 .diseqc_envelope_mode = false,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300565
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300566 .tuner_get_frequency = stb6100_get_frequency,
567 .tuner_set_frequency = stb6100_set_frequency,
568 .tuner_set_bandwidth = stb6100_set_bandwidth,
569 .tuner_get_bandwidth = stb6100_get_bandwidth,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300570};
571
572static struct stb6100_config prof_8000_stb6100_config = {
573 .tuner_address = 0x60,
574 .refclock = 27000000,
575};
576
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300577static int p8000_set_voltage(struct dvb_frontend *fe,
578 enum fe_sec_voltage voltage)
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300579{
580 struct cx23885_tsport *port = fe->dvb->priv;
581 struct cx23885_dev *dev = port->dev;
582
583 if (voltage == SEC_VOLTAGE_18)
584 cx_write(MC417_RWD, 0x00001e00);
585 else if (voltage == SEC_VOLTAGE_13)
586 cx_write(MC417_RWD, 0x00001a00);
587 else
588 cx_write(MC417_RWD, 0x00001800);
589 return 0;
590}
591
Olli Salonen29442262014-08-11 16:58:15 -0300592static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300593 enum fe_sec_voltage voltage)
Olli Salonen29442262014-08-11 16:58:15 -0300594{
595 struct cx23885_tsport *port = fe->dvb->priv;
596 struct cx23885_dev *dev = port->dev;
597
598 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
599
600 switch (voltage) {
601 case SEC_VOLTAGE_13:
602 cx23885_gpio_set(dev, GPIO_1);
603 cx23885_gpio_clear(dev, GPIO_0);
604 break;
605 case SEC_VOLTAGE_18:
606 cx23885_gpio_set(dev, GPIO_1);
607 cx23885_gpio_set(dev, GPIO_0);
608 break;
609 case SEC_VOLTAGE_OFF:
610 cx23885_gpio_clear(dev, GPIO_1);
611 cx23885_gpio_clear(dev, GPIO_0);
612 break;
613 }
614
615 /* call the frontend set_voltage function */
616 port->fe_set_voltage(fe, voltage);
617
618 return 0;
619}
620
nibble.maxc29d6a82014-11-05 11:58:38 -0300621static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300622 enum fe_sec_voltage voltage)
nibble.maxc29d6a82014-11-05 11:58:38 -0300623{
624 struct cx23885_tsport *port = fe->dvb->priv;
625 struct cx23885_dev *dev = port->dev;
626
627 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
628
629 switch (voltage) {
630 case SEC_VOLTAGE_13:
631 cx23885_gpio_set(dev, GPIO_13);
632 cx23885_gpio_clear(dev, GPIO_12);
633 break;
634 case SEC_VOLTAGE_18:
635 cx23885_gpio_set(dev, GPIO_13);
636 cx23885_gpio_set(dev, GPIO_12);
637 break;
638 case SEC_VOLTAGE_OFF:
639 cx23885_gpio_clear(dev, GPIO_13);
640 cx23885_gpio_clear(dev, GPIO_12);
641 break;
642 }
643 /* call the frontend set_voltage function */
644 return port->fe_set_voltage(fe, voltage);
645}
646
Olli Salonen24e77402014-10-04 03:59:30 -0300647static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
648 u8 data, int *mem)
649{
650 /* MC417 */
651 #define SP2_DATA 0x000000ff
652 #define SP2_WR 0x00008000
653 #define SP2_RD 0x00004000
654 #define SP2_ACK 0x00001000
655 #define SP2_ADHI 0x00000800
656 #define SP2_ADLO 0x00000400
657 #define SP2_CS1 0x00000200
658 #define SP2_CS0 0x00000100
659 #define SP2_EN_ALL 0x00001000
660 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
661
662 struct cx23885_tsport *port = priv;
663 struct cx23885_dev *dev = port->dev;
664 int ret;
nibble.max0e6c7b02014-10-23 07:01:44 -0300665 int tmp = 0;
Olli Salonen24e77402014-10-04 03:59:30 -0300666 unsigned long timeout;
667
668 mutex_lock(&dev->gpio_lock);
669
670 /* write addr */
671 cx_write(MC417_OEN, SP2_EN_ALL);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADLO | (0xff & addr));
674 cx_clear(MC417_RWD, SP2_ADLO);
675 cx_write(MC417_RWD, SP2_CTRL_OFF |
676 SP2_ADHI | (0xff & (addr >> 8)));
677 cx_clear(MC417_RWD, SP2_ADHI);
678
679 if (read)
680 /* data in */
681 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
682 else
683 /* data out */
684 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
685
686 /* chip select 0 */
687 cx_clear(MC417_RWD, SP2_CS0);
688
689 /* read/write */
690 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
691
692 /* wait for a maximum of 1 msec */
693 timeout = jiffies + msecs_to_jiffies(1);
694 while (!time_after(jiffies, timeout)) {
695 tmp = cx_read(MC417_RWD);
696 if ((tmp & SP2_ACK) == 0)
697 break;
698 usleep_range(50, 100);
699 }
700
701 cx_set(MC417_RWD, SP2_CTRL_OFF);
702 *mem = tmp & 0xff;
703
704 mutex_unlock(&dev->gpio_lock);
705
706 if (!read) {
707 if (*mem < 0) {
708 ret = -EREMOTEIO;
709 goto err;
710 }
711 }
712
713 return 0;
714err:
715 return ret;
716}
717
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300718static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300719{
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300720 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300721 struct cx23885_tsport *port = fe->dvb->priv;
722 struct cx23885_dev *dev = port->dev;
723
724 switch (dev->board) {
725 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300726 switch (p->modulation) {
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300727 case VSB_8:
728 cx23885_gpio_clear(dev, GPIO_5);
729 break;
730 case QAM_64:
731 case QAM_256:
732 default:
733 cx23885_gpio_set(dev, GPIO_5);
734 break;
735 }
736 break;
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300737 case CX23885_BOARD_MYGICA_X8506:
Mauro Carvalho Chehab0d1b5262013-08-09 08:53:27 -0300738 case CX23885_BOARD_MYGICA_X8507:
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300739 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
740 /* Select Digital TV */
741 cx23885_gpio_set(dev, GPIO_0);
742 break;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300743 }
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -0300744
745 /* Call the real set_frontend */
746 if (port->set_frontend)
747 return port->set_frontend(fe);
748
Michael Krufky5bdd3962009-05-08 22:39:24 -0300749 return 0;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300750}
751
Mauro Carvalho Chehab15472fa2013-08-09 08:53:25 -0300752static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
753 struct dvb_frontend *fe)
754{
755 port->set_frontend = fe->ops.set_frontend;
756 fe->ops.set_frontend = cx23885_dvb_set_frontend;
757}
758
David Wong2365b2d2009-06-17 01:38:12 -0300759static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
760 .prod = LGS8GXX_PROD_LGS8G75,
761 .demod_address = 0x19,
762 .serial_ts = 0,
763 .ts_clk_pol = 1,
764 .ts_clk_gated = 1,
765 .if_clk_freq = 30400, /* 30.4 MHz */
766 .if_freq = 6500, /* 6.50 MHz */
767 .if_neg_center = 1,
768 .ext_adc = 0,
769 .adc_signed = 1,
770 .adc_vpp = 2, /* 1.6 Vpp */
771 .if_neg_edge = 1,
772};
773
774static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
775 .i2c_address = 0x61,
776 .if_khz = 6500,
777};
778
David T. L. Wongea5697f2009-10-26 08:54:04 -0300779static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
780 .prod = ATBM8830_PROD_8830,
781 .demod_address = 0x44,
782 .serial_ts = 0,
783 .ts_sampling_edge = 1,
784 .ts_clk_gated = 0,
785 .osc_clk_freq = 30400, /* in kHz */
786 .if_freq = 0, /* zero IF */
787 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300788 .agc_min = 0x2E,
789 .agc_max = 0xFF,
790 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300791};
792
793static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
794 .i2c_address = 0x60,
795 .osc_clk = 20
796};
797
798static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
799 .prod = ATBM8830_PROD_8830,
800 .demod_address = 0x44,
801 .serial_ts = 1,
802 .ts_sampling_edge = 1,
803 .ts_clk_gated = 0,
804 .osc_clk_freq = 30400, /* in kHz */
805 .if_freq = 0, /* zero IF */
806 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300807 .agc_min = 0x2E,
808 .agc_max = 0xFF,
809 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300810};
811
812static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
813 .i2c_address = 0x60,
814 .osc_clk = 20
815};
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300816static struct stv0367_config netup_stv0367_config[] = {
817 {
818 .demod_address = 0x1c,
819 .xtal = 27000000,
820 .if_khz = 4500,
821 .if_iq_mode = 0,
822 .ts_mode = 1,
823 .clk_pol = 0,
824 }, {
825 .demod_address = 0x1d,
826 .xtal = 27000000,
827 .if_khz = 4500,
828 .if_iq_mode = 0,
829 .ts_mode = 1,
830 .clk_pol = 0,
831 },
832};
833
834static struct xc5000_config netup_xc5000_config[] = {
835 {
836 .i2c_address = 0x61,
837 .if_khz = 4500,
838 }, {
839 .i2c_address = 0x64,
840 .if_khz = 4500,
841 },
842};
843
Stefan Ringel722c90e2012-01-07 09:20:48 -0300844static struct drxk_config terratec_drxk_config[] = {
845 {
846 .adr = 0x29,
847 .no_i2c_bridge = 1,
848 }, {
849 .adr = 0x2a,
850 .no_i2c_bridge = 1,
851 },
852};
853
854static struct mt2063_config terratec_mt2063_config[] = {
855 {
856 .tuner_address = 0x60,
857 }, {
858 .tuner_address = 0x67,
859 },
860};
861
Antti Palosaari49bf0e62015-04-20 14:48:33 -0300862static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
863 .clk = 40444000, /* 40.444 MHz */
864 .i2c_wr_max = 64,
865 .ts_mode = TDA10071_TS_SERIAL,
866 .pll_multiplier = 20,
867 .tuner_i2c_addr = 0x54,
868};
869
Matthias Schwarzott36efec42014-07-22 17:12:13 -0300870static const struct si2165_config hauppauge_hvr4400_si2165_config = {
871 .i2c_addr = 0x64,
872 .chip_mode = SI2165_MODE_PLL_XTAL,
873 .ref_freq_Hz = 16000000,
874};
875
Olli Salonen29442262014-08-11 16:58:15 -0300876static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
877 .i2c_addr = 0x68,
878 .clock = 27000000,
879 .i2c_wr_max = 33,
880 .clock_out = 0,
881 .ts_mode = M88DS3103_TS_PARALLEL,
882 .ts_clk = 16000,
883 .ts_clk_pol = 1,
884 .lnb_en_pol = 1,
885 .lnb_hv_pol = 0,
886 .agc = 0x99,
887};
888
nibble.max0e6c7b02014-10-23 07:01:44 -0300889static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
890 .i2c_addr = 0x68,
891 .clock = 27000000,
892 .i2c_wr_max = 33,
893 .clock_out = 0,
894 .ts_mode = M88DS3103_TS_CI,
895 .ts_clk = 10000,
896 .ts_clk_pol = 1,
897 .lnb_en_pol = 1,
898 .lnb_hv_pol = 0,
899 .agc = 0x99,
900};
901
nibble.maxc29d6a82014-11-05 11:58:38 -0300902static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
903 .i2c_addr = 0x68,
904 .clock = 27000000,
905 .i2c_wr_max = 33,
906 .clock_out = 0,
907 .ts_mode = M88DS3103_TS_SERIAL,
908 .ts_clk = 96000,
909 .ts_clk_pol = 0,
910 .lnb_en_pol = 1,
911 .lnb_hv_pol = 0,
912 .agc = 0x99,
913};
914
Antti Palosaari1fc77d02014-12-11 16:12:46 -0300915static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
916 .i2c_addr = 0x69,
917 .clock = 27000000,
918 .i2c_wr_max = 33,
919 .ts_mode = M88DS3103_TS_PARALLEL,
920 .ts_clk = 16000,
921 .ts_clk_pol = 1,
922 .agc = 0x99,
923};
924
Mauro Carvalho Chehabada73ee2012-10-27 11:29:23 -0300925static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300926{
927 struct cx23885_dev *dev = (struct cx23885_dev *)device;
928 unsigned long timeout = jiffies + msecs_to_jiffies(1);
Abylay Ospand1644602011-01-02 09:10:00 -0300929 uint32_t mem = 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300930
Abylay Ospand1644602011-01-02 09:10:00 -0300931 mem = cx_read(MC417_RWD);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300932 if (read)
933 cx_set(MC417_OEN, ALT_DATA);
934 else {
935 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300936 mem &= ~ALT_DATA;
937 mem |= (data & ALT_DATA);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300938 }
939
940 if (flag)
Abylay Ospand1644602011-01-02 09:10:00 -0300941 mem |= ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300942 else
Abylay Ospand1644602011-01-02 09:10:00 -0300943 mem &= ~ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300944
Abylay Ospand1644602011-01-02 09:10:00 -0300945 mem &= ~ALT_CS;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300946 if (read)
Abylay Ospand1644602011-01-02 09:10:00 -0300947 mem = (mem & ~ALT_RD) | ALT_WR;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300948 else
Abylay Ospand1644602011-01-02 09:10:00 -0300949 mem = (mem & ~ALT_WR) | ALT_RD;
950
951 cx_write(MC417_RWD, mem); /* start RW cycle */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300952
953 for (;;) {
954 mem = cx_read(MC417_RWD);
955 if ((mem & ALT_RDY) == 0)
956 break;
957 if (time_after(jiffies, timeout))
958 break;
959 udelay(1);
960 }
961
962 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
963 if (read)
964 return mem & ALT_DATA;
965
966 return 0;
967};
David T. L. Wongea5697f2009-10-26 08:54:04 -0300968
James Harper46b21bb2014-06-12 07:12:24 -0300969static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
970{
971 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
972
973 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
974}
975
976static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
977{
978 return 0;
979}
980
981static struct dib0070_config dib7070p_dib0070_config = {
982 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
983 .reset = dib7070_tuner_reset,
984 .sleep = dib7070_tuner_sleep,
985 .clock_khz = 12000,
James Harper46b21bb2014-06-12 07:12:24 -0300986 .freq_offset_khz_vhf = 550,
987 /* .flip_chip = 1, */
988};
989
990/* DIB7070 generic */
991static struct dibx000_agc_config dib7070_agc_config = {
992 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
993
994 /*
995 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
996 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
997 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
998 */
999 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1000 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1001 .inv_gain = 600,
1002 .time_stabiliz = 10,
1003 .alpha_level = 0,
1004 .thlock = 118,
1005 .wbd_inv = 0,
1006 .wbd_ref = 3530,
1007 .wbd_sel = 1,
1008 .wbd_alpha = 5,
1009 .agc1_max = 65535,
1010 .agc1_min = 0,
1011 .agc2_max = 65535,
1012 .agc2_min = 0,
1013 .agc1_pt1 = 0,
1014 .agc1_pt2 = 40,
1015 .agc1_pt3 = 183,
1016 .agc1_slope1 = 206,
1017 .agc1_slope2 = 255,
1018 .agc2_pt1 = 72,
1019 .agc2_pt2 = 152,
1020 .agc2_slope1 = 88,
1021 .agc2_slope2 = 90,
1022 .alpha_mant = 17,
1023 .alpha_exp = 27,
1024 .beta_mant = 23,
1025 .beta_exp = 51,
1026 .perform_agc_softsplit = 0,
1027};
1028
1029static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1030 .internal = 60000,
1031 .sampling = 15000,
1032 .pll_prediv = 1,
1033 .pll_ratio = 20,
1034 .pll_range = 3,
1035 .pll_reset = 1,
1036 .pll_bypass = 0,
1037 .enable_refdiv = 0,
1038 .bypclk_div = 0,
1039 .IO_CLK_en_core = 1,
1040 .ADClkSrc = 1,
1041 .modulo = 2,
1042 /* refsel, sel, freq_15k */
1043 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1044 .ifreq = (0 << 25) | 0,
1045 .timf = 20452225,
1046 .xtal_hz = 12000000,
1047};
1048
1049static struct dib7000p_config dib7070p_dib7000p_config = {
1050 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1051 .output_mode = OUTMODE_MPEG2_SERIAL,
1052 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1053 .output_mpeg2_in_188_bytes = 1,
1054
1055 .agc_config_count = 1,
1056 .agc = &dib7070_agc_config,
1057 .bw = &dib7070_bw_config_12_mhz,
1058 .tuner_is_baseband = 1,
1059 .spur_protect = 1,
1060
1061 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1062 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1063 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1064
1065 .hostbus_diversity = 1,
1066};
1067
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001068static int dvb_register_ci_mac(struct cx23885_tsport *port)
1069{
1070 struct cx23885_dev *dev = port->dev;
1071 struct i2c_client *client_ci = NULL;
1072 struct vb2_dvb_frontend *fe0;
1073
1074 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1075 if (!fe0)
1076 return -EINVAL;
1077
1078 switch (dev->board) {
1079 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1080 static struct netup_card_info cinfo;
1081
1082 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1083 memcpy(port->frontends.adapter.proposed_mac,
1084 cinfo.port[port->nr - 1].mac, 6);
1085 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1086 port->nr, port->frontends.adapter.proposed_mac);
1087
1088 netup_ci_init(port);
1089 return 0;
1090 }
1091 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1092 struct altera_ci_config netup_ci_cfg = {
1093 .dev = dev,/* magic number to identify*/
1094 .adapter = &port->frontends.adapter,/* for CI */
1095 .demux = &fe0->dvb.demux,/* for hw pid filter */
1096 .fpga_rw = netup_altera_fpga_rw,
1097 };
1098
1099 altera_ci_init(&netup_ci_cfg, port->nr);
1100 return 0;
1101 }
1102 case CX23885_BOARD_TEVII_S470: {
1103 u8 eeprom[256]; /* 24C02 i2c eeprom */
1104
1105 if (port->nr != 1)
1106 return 0;
1107
1108 /* Read entire EEPROM */
1109 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1110 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1111 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1112 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1113 return 0;
1114 }
1115 case CX23885_BOARD_DVBSKY_T9580:
1116 case CX23885_BOARD_DVBSKY_S950:
1117 case CX23885_BOARD_DVBSKY_S952:
1118 case CX23885_BOARD_DVBSKY_T982: {
1119 u8 eeprom[256]; /* 24C02 i2c eeprom */
1120
1121 if (port->nr > 2)
1122 return 0;
1123
1124 /* Read entire EEPROM */
1125 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1126 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1127 sizeof(eeprom));
1128 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1129 cx23885_boards[dev->board].name, port->nr,
1130 eeprom + 0xc0 + (port->nr-1) * 8);
1131 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1132 (port->nr-1) * 8, 6);
1133 return 0;
1134 }
1135 case CX23885_BOARD_DVBSKY_S950C:
1136 case CX23885_BOARD_DVBSKY_T980C:
1137 case CX23885_BOARD_TT_CT2_4500_CI: {
1138 u8 eeprom[256]; /* 24C02 i2c eeprom */
1139 struct sp2_config sp2_config;
1140 struct i2c_board_info info;
Olli Salonenab8b5e42014-12-23 13:48:07 -02001141 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001142
1143 /* attach CI */
1144 memset(&sp2_config, 0, sizeof(sp2_config));
1145 sp2_config.dvb_adap = &port->frontends.adapter;
1146 sp2_config.priv = port;
1147 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1148 memset(&info, 0, sizeof(struct i2c_board_info));
1149 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1150 info.addr = 0x40;
1151 info.platform_data = &sp2_config;
1152 request_module(info.type);
Olli Salonenab8b5e42014-12-23 13:48:07 -02001153 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001154 if (client_ci == NULL || client_ci->dev.driver == NULL)
1155 return -ENODEV;
1156 if (!try_module_get(client_ci->dev.driver->owner)) {
1157 i2c_unregister_device(client_ci);
1158 return -ENODEV;
1159 }
1160 port->i2c_client_ci = client_ci;
1161
1162 if (port->nr != 1)
1163 return 0;
1164
1165 /* Read entire EEPROM */
1166 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1167 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1168 sizeof(eeprom));
1169 printk(KERN_INFO "%s MAC address: %pM\n",
1170 cx23885_boards[dev->board].name, eeprom + 0xc0);
1171 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1172 return 0;
1173 }
1174 }
1175 return 0;
1176}
1177
Steven Tothd19770e2007-03-11 20:44:05 -03001178static int dvb_register(struct cx23885_tsport *port)
1179{
Mauro Carvalho Chehab8abe4a02014-05-29 09:20:15 -03001180 struct dib7000p_ops dib7000p_ops;
Steven Tothd19770e2007-03-11 20:44:05 -03001181 struct cx23885_dev *dev = port->dev;
David Wong493b7122009-05-18 05:25:49 -03001182 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
Hans Verkuil453afdd2014-08-14 06:43:01 -03001183 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
Olli Salonen29442262014-08-11 16:58:15 -03001184 struct si2168_config si2168_config;
1185 struct si2157_config si2157_config;
Antti Palosaarid76e0872015-03-23 18:52:46 -03001186 struct ts2020_config ts2020_config;
Olli Salonen29442262014-08-11 16:58:15 -03001187 struct i2c_board_info info;
1188 struct i2c_adapter *adapter;
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001189 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03001190 struct i2c_client *client_sec = NULL;
nibble.maxc29d6a82014-11-05 11:58:38 -03001191 const struct m88ds3103_config *p_m88ds3103_config = NULL;
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -03001192 int (*p_set_voltage)(struct dvb_frontend *fe,
1193 enum fe_sec_voltage voltage) = NULL;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001194 int mfe_shared = 0; /* bus not shared by default */
Igor M. Liplianin5a23b0762009-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. Liplianin5a23b0762009-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. Liplianin5a23b0762009-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. Liplianin5a23b0762009-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;
David Howells0f91c9d2015-05-26 12:04:00 -03001913 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
Olli Salonen29442262014-08-11 16:58:15 -03001914 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03001915 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
Olli Salonen29442262014-08-11 16:58:15 -03001916 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03001917 info.platform_data = &ts2020_config;
Olli Salonen29442262014-08-11 16:58:15 -03001918 request_module(info.type);
1919 client_tuner = i2c_new_device(adapter, &info);
1920 if (client_tuner == NULL ||
1921 client_tuner->dev.driver == NULL)
1922 goto frontend_detach;
1923 if (!try_module_get(client_tuner->dev.driver->owner)) {
1924 i2c_unregister_device(client_tuner);
1925 goto frontend_detach;
1926 }
1927
1928 /* delegate signal strength measurement to tuner */
1929 fe0->dvb.frontend->ops.read_signal_strength =
1930 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1931
1932 /*
1933 * for setting the voltage we need to set GPIOs on
1934 * the card.
1935 */
1936 port->fe_set_voltage =
1937 fe0->dvb.frontend->ops.set_voltage;
1938 fe0->dvb.frontend->ops.set_voltage =
1939 dvbsky_t9580_set_voltage;
1940
1941 port->i2c_client_tuner = client_tuner;
1942
1943 break;
1944 /* port c - terrestrial/cable */
1945 case 2:
1946 /* attach frontend */
Olli Salonen143800a2014-09-24 00:06:54 -03001947 memset(&si2168_config, 0, sizeof(si2168_config));
Olli Salonen29442262014-08-11 16:58:15 -03001948 si2168_config.i2c_adapter = &adapter;
1949 si2168_config.fe = &fe0->dvb.frontend;
1950 si2168_config.ts_mode = SI2168_TS_SERIAL;
1951 memset(&info, 0, sizeof(struct i2c_board_info));
1952 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1953 info.addr = 0x64;
1954 info.platform_data = &si2168_config;
1955 request_module(info.type);
1956 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1957 if (client_demod == NULL ||
1958 client_demod->dev.driver == NULL)
1959 goto frontend_detach;
1960 if (!try_module_get(client_demod->dev.driver->owner)) {
1961 i2c_unregister_device(client_demod);
1962 goto frontend_detach;
1963 }
1964 port->i2c_client_demod = client_demod;
1965
1966 /* attach tuner */
Olli Salonen143800a2014-09-24 00:06:54 -03001967 memset(&si2157_config, 0, sizeof(si2157_config));
Olli Salonen29442262014-08-11 16:58:15 -03001968 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03001969 si2157_config.if_port = 1;
Olli Salonen29442262014-08-11 16:58:15 -03001970 memset(&info, 0, sizeof(struct i2c_board_info));
1971 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1972 info.addr = 0x60;
1973 info.platform_data = &si2157_config;
1974 request_module(info.type);
1975 client_tuner = i2c_new_device(adapter, &info);
1976 if (client_tuner == NULL ||
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001977 client_tuner->dev.driver == NULL)
Olli Salonen29442262014-08-11 16:58:15 -03001978 goto frontend_detach;
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02001979
Olli Salonen29442262014-08-11 16:58:15 -03001980 if (!try_module_get(client_tuner->dev.driver->owner)) {
1981 i2c_unregister_device(client_tuner);
Olli Salonen29442262014-08-11 16:58:15 -03001982 goto frontend_detach;
1983 }
1984 port->i2c_client_tuner = client_tuner;
1985 break;
1986 }
1987 break;
Olli Salonen82c10272014-09-29 04:44:16 -03001988 case CX23885_BOARD_DVBSKY_T980C:
Olli Salonen61b103e2014-10-30 17:48:27 -03001989 case CX23885_BOARD_TT_CT2_4500_CI:
Olli Salonen37a35ce2016-02-16 18:17:45 -02001990 i2c_bus = &dev->i2c_bus[0];
1991 i2c_bus2 = &dev->i2c_bus[1];
Olli Salonen82c10272014-09-29 04:44:16 -03001992
1993 /* attach frontend */
1994 memset(&si2168_config, 0, sizeof(si2168_config));
1995 si2168_config.i2c_adapter = &adapter;
1996 si2168_config.fe = &fe0->dvb.frontend;
1997 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1998 memset(&info, 0, sizeof(struct i2c_board_info));
1999 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2000 info.addr = 0x64;
2001 info.platform_data = &si2168_config;
2002 request_module(info.type);
Olli Salonen37a35ce2016-02-16 18:17:45 -02002003 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002004 if (client_demod == NULL || client_demod->dev.driver == NULL)
Olli Salonen82c10272014-09-29 04:44:16 -03002005 goto frontend_detach;
2006 if (!try_module_get(client_demod->dev.driver->owner)) {
2007 i2c_unregister_device(client_demod);
2008 goto frontend_detach;
2009 }
2010 port->i2c_client_demod = client_demod;
2011
2012 /* attach tuner */
2013 memset(&si2157_config, 0, sizeof(si2157_config));
2014 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002015 si2157_config.if_port = 1;
Olli Salonen82c10272014-09-29 04:44:16 -03002016 memset(&info, 0, sizeof(struct i2c_board_info));
2017 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2018 info.addr = 0x60;
2019 info.platform_data = &si2157_config;
2020 request_module(info.type);
2021 client_tuner = i2c_new_device(adapter, &info);
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002022 if (client_tuner == NULL ||
2023 client_tuner->dev.driver == NULL)
Olli Salonen82c10272014-09-29 04:44:16 -03002024 goto frontend_detach;
Olli Salonen82c10272014-09-29 04:44:16 -03002025 if (!try_module_get(client_tuner->dev.driver->owner)) {
2026 i2c_unregister_device(client_tuner);
Olli Salonen82c10272014-09-29 04:44:16 -03002027 goto frontend_detach;
2028 }
2029 port->i2c_client_tuner = client_tuner;
2030 break;
nibble.max0e6c7b02014-10-23 07:01:44 -03002031 case CX23885_BOARD_DVBSKY_S950C:
Olli Salonen37a35ce2016-02-16 18:17:45 -02002032 i2c_bus = &dev->i2c_bus[0];
2033 i2c_bus2 = &dev->i2c_bus[1];
nibble.max0e6c7b02014-10-23 07:01:44 -03002034
2035 /* attach frontend */
2036 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2037 &dvbsky_s950c_m88ds3103_config,
Olli Salonen37a35ce2016-02-16 18:17:45 -02002038 &i2c_bus2->i2c_adap, &adapter);
nibble.max0e6c7b02014-10-23 07:01:44 -03002039 if (fe0->dvb.frontend == NULL)
2040 break;
2041
2042 /* attach tuner */
Antti Palosaarid76e0872015-03-23 18:52:46 -03002043 memset(&ts2020_config, 0, sizeof(ts2020_config));
2044 ts2020_config.fe = fe0->dvb.frontend;
David Howells0f91c9d2015-05-26 12:04:00 -03002045 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
nibble.max0e6c7b02014-10-23 07:01:44 -03002046 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03002047 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
nibble.max0e6c7b02014-10-23 07:01:44 -03002048 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03002049 info.platform_data = &ts2020_config;
nibble.max0e6c7b02014-10-23 07:01:44 -03002050 request_module(info.type);
2051 client_tuner = i2c_new_device(adapter, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002052 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
nibble.max0e6c7b02014-10-23 07:01:44 -03002053 goto frontend_detach;
2054 if (!try_module_get(client_tuner->dev.driver->owner)) {
2055 i2c_unregister_device(client_tuner);
2056 goto frontend_detach;
2057 }
2058
2059 /* delegate signal strength measurement to tuner */
2060 fe0->dvb.frontend->ops.read_signal_strength =
2061 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2062
2063 port->i2c_client_tuner = client_tuner;
2064 break;
nibble.maxc29d6a82014-11-05 11:58:38 -03002065 case CX23885_BOARD_DVBSKY_S952:
2066 switch (port->nr) {
2067 /* port b */
2068 case 1:
2069 i2c_bus = &dev->i2c_bus[1];
2070 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
2071 p_set_voltage = dvbsky_t9580_set_voltage;
2072 break;
2073 /* port c */
2074 case 2:
2075 i2c_bus = &dev->i2c_bus[0];
2076 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
2077 p_set_voltage = dvbsky_s952_portc_set_voltage;
2078 break;
2079 }
2080
2081 /* attach frontend */
2082 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2083 p_m88ds3103_config,
2084 &i2c_bus->i2c_adap, &adapter);
2085 if (fe0->dvb.frontend == NULL)
2086 break;
2087
2088 /* attach tuner */
Antti Palosaarid76e0872015-03-23 18:52:46 -03002089 memset(&ts2020_config, 0, sizeof(ts2020_config));
2090 ts2020_config.fe = fe0->dvb.frontend;
David Howells0f91c9d2015-05-26 12:04:00 -03002091 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
nibble.maxc29d6a82014-11-05 11:58:38 -03002092 memset(&info, 0, sizeof(struct i2c_board_info));
Antti Palosaarid76e0872015-03-23 18:52:46 -03002093 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
nibble.maxc29d6a82014-11-05 11:58:38 -03002094 info.addr = 0x60;
Antti Palosaarid76e0872015-03-23 18:52:46 -03002095 info.platform_data = &ts2020_config;
nibble.maxc29d6a82014-11-05 11:58:38 -03002096 request_module(info.type);
2097 client_tuner = i2c_new_device(adapter, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002098 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
nibble.maxc29d6a82014-11-05 11:58:38 -03002099 goto frontend_detach;
2100 if (!try_module_get(client_tuner->dev.driver->owner)) {
2101 i2c_unregister_device(client_tuner);
2102 goto frontend_detach;
2103 }
2104
2105 /* delegate signal strength measurement to tuner */
2106 fe0->dvb.frontend->ops.read_signal_strength =
2107 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2108
2109 /*
2110 * for setting the voltage we need to set GPIOs on
2111 * the card.
2112 */
2113 port->fe_set_voltage =
2114 fe0->dvb.frontend->ops.set_voltage;
2115 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2116
2117 port->i2c_client_tuner = client_tuner;
2118 break;
Nibble Maxc02ef642014-11-12 01:23:12 -03002119 case CX23885_BOARD_DVBSKY_T982:
2120 memset(&si2168_config, 0, sizeof(si2168_config));
2121 switch (port->nr) {
2122 /* port b */
2123 case 1:
2124 i2c_bus = &dev->i2c_bus[1];
2125 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2126 break;
2127 /* port c */
2128 case 2:
2129 i2c_bus = &dev->i2c_bus[0];
2130 si2168_config.ts_mode = SI2168_TS_SERIAL;
2131 break;
2132 }
2133
2134 /* attach frontend */
2135 si2168_config.i2c_adapter = &adapter;
2136 si2168_config.fe = &fe0->dvb.frontend;
2137 memset(&info, 0, sizeof(struct i2c_board_info));
2138 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2139 info.addr = 0x64;
2140 info.platform_data = &si2168_config;
2141 request_module(info.type);
2142 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
Antti Palosaaria593f2c2014-12-10 11:05:59 -03002143 if (client_demod == NULL || client_demod->dev.driver == NULL)
Nibble Maxc02ef642014-11-12 01:23:12 -03002144 goto frontend_detach;
2145 if (!try_module_get(client_demod->dev.driver->owner)) {
2146 i2c_unregister_device(client_demod);
2147 goto frontend_detach;
2148 }
2149 port->i2c_client_demod = client_demod;
2150
2151 /* attach tuner */
2152 memset(&si2157_config, 0, sizeof(si2157_config));
2153 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002154 si2157_config.if_port = 1;
Nibble Maxc02ef642014-11-12 01:23:12 -03002155 memset(&info, 0, sizeof(struct i2c_board_info));
2156 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2157 info.addr = 0x60;
2158 info.platform_data = &si2157_config;
2159 request_module(info.type);
2160 client_tuner = i2c_new_device(adapter, &info);
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002161 if (client_tuner == NULL ||
2162 client_tuner->dev.driver == NULL)
Nibble Maxc02ef642014-11-12 01:23:12 -03002163 goto frontend_detach;
Nibble Maxc02ef642014-11-12 01:23:12 -03002164 if (!try_module_get(client_tuner->dev.driver->owner)) {
2165 i2c_unregister_device(client_tuner);
Nibble Maxc02ef642014-11-12 01:23:12 -03002166 goto frontend_detach;
2167 }
2168 port->i2c_client_tuner = client_tuner;
2169 break;
Mauro Carvalho Chehabf0b0faff2015-12-18 14:22:21 -02002170 case CX23885_BOARD_HAUPPAUGE_HVR5525: {
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002171 struct m88rs6000t_config m88rs6000t_config;
Mauro Carvalho Chehabf0b0faff2015-12-18 14:22:21 -02002172 struct a8293_platform_data a8293_pdata = {};
2173
2174 switch (port->nr) {
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002175
2176 /* port b - satellite */
2177 case 1:
2178 /* attach frontend */
2179 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2180 &hauppauge_hvr5525_m88ds3103_config,
2181 &dev->i2c_bus[0].i2c_adap, &adapter);
2182 if (fe0->dvb.frontend == NULL)
2183 break;
2184
2185 /* attach SEC */
Antti Palosaari49b7cb52015-04-20 17:08:01 -03002186 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
2187 memset(&info, 0, sizeof(info));
2188 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
2189 info.addr = 0x0b;
2190 info.platform_data = &a8293_pdata;
2191 request_module("a8293");
2192 client_sec = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2193 if (!client_sec || !client_sec->dev.driver)
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002194 goto frontend_detach;
Antti Palosaari49b7cb52015-04-20 17:08:01 -03002195 if (!try_module_get(client_sec->dev.driver->owner)) {
2196 i2c_unregister_device(client_sec);
2197 goto frontend_detach;
2198 }
2199 port->i2c_client_sec = client_sec;
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002200
2201 /* attach tuner */
2202 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2203 m88rs6000t_config.fe = fe0->dvb.frontend;
2204 memset(&info, 0, sizeof(struct i2c_board_info));
2205 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2206 info.addr = 0x21;
2207 info.platform_data = &m88rs6000t_config;
2208 request_module("%s", info.type);
2209 client_tuner = i2c_new_device(adapter, &info);
2210 if (!client_tuner || !client_tuner->dev.driver)
2211 goto frontend_detach;
2212 if (!try_module_get(client_tuner->dev.driver->owner)) {
2213 i2c_unregister_device(client_tuner);
2214 goto frontend_detach;
2215 }
2216 port->i2c_client_tuner = client_tuner;
2217
2218 /* delegate signal strength measurement to tuner */
2219 fe0->dvb.frontend->ops.read_signal_strength =
2220 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2221 break;
2222 /* port c - terrestrial/cable */
2223 case 2:
2224 /* attach frontend */
2225 memset(&si2168_config, 0, sizeof(si2168_config));
2226 si2168_config.i2c_adapter = &adapter;
2227 si2168_config.fe = &fe0->dvb.frontend;
2228 si2168_config.ts_mode = SI2168_TS_SERIAL;
2229 memset(&info, 0, sizeof(struct i2c_board_info));
2230 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2231 info.addr = 0x64;
2232 info.platform_data = &si2168_config;
2233 request_module("%s", info.type);
2234 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2235 if (!client_demod || !client_demod->dev.driver)
2236 goto frontend_detach;
2237 if (!try_module_get(client_demod->dev.driver->owner)) {
2238 i2c_unregister_device(client_demod);
2239 goto frontend_detach;
2240 }
2241 port->i2c_client_demod = client_demod;
2242
2243 /* attach tuner */
2244 memset(&si2157_config, 0, sizeof(si2157_config));
2245 si2157_config.fe = fe0->dvb.frontend;
Olli Salonenee3c3e42015-05-05 13:54:17 -03002246 si2157_config.if_port = 1;
Antti Palosaari1fc77d02014-12-11 16:12:46 -03002247 memset(&info, 0, sizeof(struct i2c_board_info));
2248 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2249 info.addr = 0x60;
2250 info.platform_data = &si2157_config;
2251 request_module("%s", info.type);
2252 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2253 if (!client_tuner || !client_tuner->dev.driver) {
2254 module_put(client_demod->dev.driver->owner);
2255 i2c_unregister_device(client_demod);
2256 port->i2c_client_demod = NULL;
2257 goto frontend_detach;
2258 }
2259 if (!try_module_get(client_tuner->dev.driver->owner)) {
2260 i2c_unregister_device(client_tuner);
2261 module_put(client_demod->dev.driver->owner);
2262 i2c_unregister_device(client_demod);
2263 port->i2c_client_demod = NULL;
2264 goto frontend_detach;
2265 }
2266 port->i2c_client_tuner = client_tuner;
2267 break;
2268 }
2269 break;
Mauro Carvalho Chehabf0b0faff2015-12-18 14:22:21 -02002270 }
Steven Tothd19770e2007-03-11 20:44:05 -03002271 default:
Steven Toth9c8ced52008-10-16 20:18:44 -03002272 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2273 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -03002274 dev->name);
2275 break;
2276 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002277
2278 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
Steven Toth9c8ced52008-10-16 20:18:44 -03002279 printk(KERN_ERR "%s: frontend initialization failed\n",
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002280 dev->name);
2281 goto frontend_detach;
Steven Tothd19770e2007-03-11 20:44:05 -03002282 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002283
Michael Krufkyd7cba042008-09-12 13:31:45 -03002284 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03002285 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002286 if (fe1)
2287 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2288#if 0
2289 /* Ensure all frontends negotiate bus access */
2290 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2291 if (fe1)
2292 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2293#endif
Steven Tothd19770e2007-03-11 20:44:05 -03002294
2295 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03002296 call_all(dev, core, s_power, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03002297
Steven Toth363c35f2008-10-11 11:05:50 -03002298 if (fe0->dvb.frontend->ops.analog_ops.standby)
2299 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -03002300
Steven Tothd19770e2007-03-11 20:44:05 -03002301 /* register everything */
Hans Verkuil453afdd2014-08-14 06:43:01 -03002302 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Mauro Carvalho Chehab2773b0e2016-02-05 08:35:50 -02002303 &dev->pci->dev, NULL,
2304 adapter_nr, mfe_shared);
Abylay Ospanbee30192010-06-25 08:01:28 -03002305 if (ret)
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002306 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03002307
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002308 ret = dvb_register_ci_mac(port);
2309 if (ret)
2310 goto frontend_detach;
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03002311
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002312 return 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002313
2314frontend_detach:
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03002315 /* remove I2C client for SEC */
2316 client_sec = port->i2c_client_sec;
2317 if (client_sec) {
2318 module_put(client_sec->dev.driver->owner);
2319 i2c_unregister_device(client_sec);
2320 port->i2c_client_sec = NULL;
2321 }
2322
Mauro Carvalho Chehab2b0aac32014-12-23 13:48:07 -02002323 /* remove I2C client for tuner */
2324 client_tuner = port->i2c_client_tuner;
2325 if (client_tuner) {
2326 module_put(client_tuner->dev.driver->owner);
2327 i2c_unregister_device(client_tuner);
2328 port->i2c_client_tuner = NULL;
2329 }
2330
2331 /* remove I2C client for demodulator */
2332 client_demod = port->i2c_client_demod;
2333 if (client_demod) {
2334 module_put(client_demod->dev.driver->owner);
2335 i2c_unregister_device(client_demod);
2336 port->i2c_client_demod = NULL;
2337 }
2338
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002339 port->gate_ctrl = NULL;
Hans Verkuil453afdd2014-08-14 06:43:01 -03002340 vb2_dvb_dealloc_frontends(&port->frontends);
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002341 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03002342}
2343
2344int cx23885_dvb_register(struct cx23885_tsport *port)
2345{
Steven Toth363c35f2008-10-11 11:05:50 -03002346
Hans Verkuil453afdd2014-08-14 06:43:01 -03002347 struct vb2_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -03002348 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -03002349 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -03002350
Steven Totheb0c58b2008-10-11 12:34:39 -03002351 /* Here we need to allocate the correct number of frontends,
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02002352 * as reflected in the cards struct. The reality is that currently
Steven Totheb0c58b2008-10-11 12:34:39 -03002353 * no cx23885 boards support this - yet. But, if we don't modify this
2354 * code then the second frontend would never be allocated (later)
2355 * and fail with error before the attach in dvb_register().
2356 * Without these changes we risk an OOPS later. The changes here
2357 * are for safety, and should provide a good foundation for the
2358 * future addition of any multi-frontend cx23885 based boards.
2359 */
2360 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
2361 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -03002362
Steven Totheb0c58b2008-10-11 12:34:39 -03002363 for (i = 1; i <= port->num_frontends; i++) {
Hans Verkuil453afdd2014-08-14 06:43:01 -03002364 struct vb2_queue *q;
2365
2366 if (vb2_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -03002367 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -03002368 printk(KERN_ERR "%s() failed to alloc\n", __func__);
2369 return -ENOMEM;
2370 }
Steven Tothd19770e2007-03-11 20:44:05 -03002371
Hans Verkuil453afdd2014-08-14 06:43:01 -03002372 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
Steven Totheb0c58b2008-10-11 12:34:39 -03002373 if (!fe0)
Mauro Carvalho Chehabed3da2b2014-10-30 11:15:53 -03002374 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03002375
Steven Totheb0c58b2008-10-11 12:34:39 -03002376 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -03002377 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -03002378 dev->board,
2379 dev->name,
2380 dev->pci_bus,
2381 dev->pci_slot);
2382
2383 err = -ENODEV;
2384
2385 /* dvb stuff */
2386 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -03002387 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
Hans Verkuil453afdd2014-08-14 06:43:01 -03002388 q = &fe0->dvb.dvbq;
2389 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2390 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2391 q->gfp_flags = GFP_DMA32;
2392 q->min_buffers_needed = 2;
2393 q->drv_priv = port;
2394 q->buf_struct_size = sizeof(struct cx23885_buffer);
2395 q->ops = &dvb_qops;
2396 q->mem_ops = &vb2_dma_sg_memops;
2397 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2398 q->lock = &dev->lock;
Hans Verkuil2bc46b32016-02-15 12:37:15 -02002399 q->dev = &dev->pci->dev;
Hans Verkuil453afdd2014-08-14 06:43:01 -03002400
2401 err = vb2_queue_init(q);
2402 if (err < 0)
2403 return err;
Steven Totheb0c58b2008-10-11 12:34:39 -03002404 }
Steven Tothd19770e2007-03-11 20:44:05 -03002405 err = dvb_register(port);
2406 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -03002407 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
2408 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -03002409
Steven Tothd19770e2007-03-11 20:44:05 -03002410 return err;
2411}
2412
2413int cx23885_dvb_unregister(struct cx23885_tsport *port)
2414{
Hans Verkuil453afdd2014-08-14 06:43:01 -03002415 struct vb2_dvb_frontend *fe0;
Olli Salonenb0b12e62014-08-11 16:58:13 -03002416 struct i2c_client *client;
Steven Toth363c35f2008-10-11 11:05:50 -03002417
Olli Salonene450de42014-09-29 04:44:19 -03002418 /* remove I2C client for CI */
2419 client = port->i2c_client_ci;
2420 if (client) {
2421 module_put(client->dev.driver->owner);
2422 i2c_unregister_device(client);
2423 }
2424
Antti Palosaaribf5e3ef2015-04-16 13:59:46 -03002425 /* remove I2C client for SEC */
2426 client = port->i2c_client_sec;
2427 if (client) {
2428 module_put(client->dev.driver->owner);
2429 i2c_unregister_device(client);
2430 }
2431
Olli Salonenb0b12e62014-08-11 16:58:13 -03002432 /* remove I2C client for tuner */
2433 client = port->i2c_client_tuner;
2434 if (client) {
2435 module_put(client->dev.driver->owner);
2436 i2c_unregister_device(client);
2437 }
2438
2439 /* remove I2C client for demodulator */
2440 client = port->i2c_client_demod;
2441 if (client) {
2442 module_put(client->dev.driver->owner);
2443 i2c_unregister_device(client);
2444 }
2445
Hans Verkuil453afdd2014-08-14 06:43:01 -03002446 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
Olli Salonenb0b12e62014-08-11 16:58:13 -03002447
Abylay Ospane66131c2011-07-15 15:01:07 -03002448 if (fe0 && fe0->dvb.frontend)
Hans Verkuil453afdd2014-08-14 06:43:01 -03002449 vb2_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -03002450
Hans Verkuilafd96662009-03-13 13:24:19 -03002451 switch (port->dev->board) {
2452 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2453 netup_ci_exit(port);
2454 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002455 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2456 altera_ci_release(port->dev, port->nr);
2457 break;
Hans Verkuilafd96662009-03-13 13:24:19 -03002458 }
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03002459
Igor M. Liplianin78db8542011-01-25 17:04:00 -03002460 port->gate_ctrl = NULL;
2461
Steven Tothd19770e2007-03-11 20:44:05 -03002462 return 0;
2463}