blob: 851d2a9caed3d7782e9d0ca7b8c50ede9fe28f8d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
Trent Piephoecf854d2007-05-05 20:11:32 -030038#include "cx88-vp3054-i2c.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030039#include "zl10353.h"
40#include "cx22702.h"
41#include "or51132.h"
42#include "lgdt330x.h"
Steven Toth60464da2008-01-05 16:53:01 -030043#include "s5h1409.h"
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -030044#include "xc4000.h"
Steven Toth60464da2008-01-05 16:53:01 -030045#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030046#include "nxt200x.h"
47#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030048#include "isl6421.h"
Michael Krufky0df31f82008-04-22 14:46:13 -030049#include "tuner-simple.h"
Michael Krufky827855d2008-04-22 14:46:16 -030050#include "tda9887.h"
Steven Tothd893d5d2008-04-25 03:46:43 -030051#include "s5h1411.h"
Igor M. Liplianine4aab642008-09-23 15:43:57 -030052#include "stv0299.h"
53#include "z0194a.h"
54#include "stv0288.h"
55#include "stb6000.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030056#include "cx24116.h"
Igor M. Liplianinb699c272009-11-16 22:22:32 -030057#include "stv0900.h"
58#include "stb6100.h"
59#include "stb6100_proc.h"
Sergey Ivanov111ac842010-08-09 10:18:32 -030060#include "mb86a16.h"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030061#include "ts2020.h"
Igor M. Liplianin0cb73632011-02-25 18:41:24 -030062#include "ds3000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
65MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
66MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
67MODULE_LICENSE("GPL");
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -030068MODULE_VERSION(CX88_VERSION);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030070static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071module_param(debug, int, 0644);
72MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
73
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030074static unsigned int dvb_buf_tscnt = 32;
75module_param(dvb_buf_tscnt, int, 0644);
76MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
77
Janne Grunau78e92002008-04-09 19:13:13 -030078DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020081 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/* ------------------------------------------------------------------ */
84
Hans Verkuildf9ecb02015-10-28 00:50:37 -020085static int queue_setup(struct vb2_queue *q,
Hans Verkuil0b6b6302014-09-20 09:22:18 -030086 unsigned int *num_buffers, unsigned int *num_planes,
87 unsigned int sizes[], void *alloc_ctxs[])
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
Hans Verkuil0b6b6302014-09-20 09:22:18 -030089 struct cx8802_dev *dev = q->drv_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Hans Verkuil0b6b6302014-09-20 09:22:18 -030091 *num_planes = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030093 dev->ts_packet_count = dvb_buf_tscnt;
Hans Verkuil0b6b6302014-09-20 09:22:18 -030094 sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
Hans Verkuil165d0042014-12-08 13:23:49 -030095 alloc_ctxs[0] = dev->alloc_ctx;
Hans Verkuil0b6b6302014-09-20 09:22:18 -030096 *num_buffers = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 return 0;
98}
99
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300100static int buffer_prepare(struct vb2_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
Junghak Sung2d700712015-09-22 10:30:30 -0300102 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300103 struct cx8802_dev *dev = vb->vb2_queue->drv_priv;
Junghak Sung2d700712015-09-22 10:30:30 -0300104 struct cx88_buffer *buf = container_of(vbuf, struct cx88_buffer, vb);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300105
Hans Verkuilccd6f1d2014-09-20 09:23:44 -0300106 return cx8802_buf_prepare(vb->vb2_queue, dev, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107}
108
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300109static void buffer_finish(struct vb2_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Junghak Sung2d700712015-09-22 10:30:30 -0300111 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300112 struct cx8802_dev *dev = vb->vb2_queue->drv_priv;
Junghak Sung2d700712015-09-22 10:30:30 -0300113 struct cx88_buffer *buf = container_of(vbuf, struct cx88_buffer, vb);
Hans Verkuil5e7045e2014-08-29 04:11:54 -0300114 struct cx88_riscmem *risc = &buf->risc;
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300115
Hans Verkuil5e7045e2014-08-29 04:11:54 -0300116 if (risc->cpu)
117 pci_free_consistent(dev->pci, risc->size, risc->cpu, risc->dma);
118 memset(risc, 0, sizeof(*risc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300121static void buffer_queue(struct vb2_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
Junghak Sung2d700712015-09-22 10:30:30 -0300123 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300124 struct cx8802_dev *dev = vb->vb2_queue->drv_priv;
Junghak Sung2d700712015-09-22 10:30:30 -0300125 struct cx88_buffer *buf = container_of(vbuf, struct cx88_buffer, vb);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300126
127 cx8802_buf_queue(dev, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300130static int start_streaming(struct vb2_queue *q, unsigned int count)
131{
132 struct cx8802_dev *dev = q->drv_priv;
133 struct cx88_dmaqueue *dmaq = &dev->mpegq;
134 struct cx88_buffer *buf;
135
136 buf = list_entry(dmaq->active.next, struct cx88_buffer, list);
137 cx8802_start_dma(dev, dmaq, buf);
138 return 0;
139}
140
141static void stop_streaming(struct vb2_queue *q)
142{
143 struct cx8802_dev *dev = q->drv_priv;
144 struct cx88_dmaqueue *dmaq = &dev->mpegq;
145 unsigned long flags;
146
147 cx8802_cancel_buffers(dev);
148
149 spin_lock_irqsave(&dev->slock, flags);
150 while (!list_empty(&dmaq->active)) {
151 struct cx88_buffer *buf = list_entry(dmaq->active.next,
152 struct cx88_buffer, list);
153
154 list_del(&buf->list);
Junghak Sung2d700712015-09-22 10:30:30 -0300155 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300156 }
157 spin_unlock_irqrestore(&dev->slock, flags);
158}
159
160static struct vb2_ops dvb_qops = {
161 .queue_setup = queue_setup,
162 .buf_prepare = buffer_prepare,
163 .buf_finish = buffer_finish,
164 .buf_queue = buffer_queue,
165 .wait_prepare = vb2_ops_wait_prepare,
166 .wait_finish = vb2_ops_wait_finish,
167 .start_streaming = start_streaming,
168 .stop_streaming = stop_streaming,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169};
170
171/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300172
173static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
174{
175 struct cx8802_dev *dev= fe->dvb->priv;
176 struct cx8802_driver *drv = NULL;
177 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300178 int fe_id;
179
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300180 fe_id = vb2_dvb_find_frontend(&dev->frontends, fe);
Steven Toth363c35f2008-10-11 11:05:50 -0300181 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300182 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300183 return -EINVAL;
184 }
185
Jonathan Nieder8a317a82011-05-01 06:29:16 -0300186 mutex_lock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300187 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
188 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300189 if (acquire){
190 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300191 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300192 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300193 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300194 dev->frontends.active_fe_id = 0;
195 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300196 }
Jonathan Nieder1fe70e92011-05-01 06:29:37 -0300197 mutex_unlock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300198
199 return ret;
200}
201
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300202static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
203{
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300204 struct vb2_dvb_frontends *f;
205 struct vb2_dvb_frontend *fe;
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300206
207 if (!core->dvbdev)
208 return;
209
210 f = &core->dvbdev->frontends;
211
212 if (!f)
213 return;
214
215 if (f->gate <= 1) /* undefined or fe0 */
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300216 fe = vb2_dvb_get_frontend(f, 1);
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300217 else
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300218 fe = vb2_dvb_get_frontend(f, f->gate);
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300219
220 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
221 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
222}
223
Michael Krufky22f3f172006-12-05 01:38:58 -0300224/* ------------------------------------------------------------------ */
225
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200226static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300228 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
229 static const u8 reset [] = { RESET, 0x80 };
230 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
231 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
232 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
233 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235 mt352_write(fe, clock_config, sizeof(clock_config));
236 udelay(200);
237 mt352_write(fe, reset, sizeof(reset));
238 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
239
240 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
241 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
242 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
243 return 0;
244}
245
Chris Pascoe43eabb42006-01-09 18:21:28 -0200246static int dvico_dual_demod_init(struct dvb_frontend *fe)
247{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300248 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
249 static const u8 reset [] = { RESET, 0x80 };
250 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
251 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
252 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
253 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200254
255 mt352_write(fe, clock_config, sizeof(clock_config));
256 udelay(200);
257 mt352_write(fe, reset, sizeof(reset));
258 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
259
260 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
261 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
262 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
263
264 return 0;
265}
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
268{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300269 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
270 static const u8 reset [] = { 0x50, 0x80 };
271 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
272 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800273 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300274 static const u8 dntv_extra[] = { 0xB5, 0x7A };
275 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277 mt352_write(fe, clock_config, sizeof(clock_config));
278 udelay(2000);
279 mt352_write(fe, reset, sizeof(reset));
280 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
281
282 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
283 udelay(2000);
284 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
285 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
286
287 return 0;
288}
289
lawrence rust2e4e98e2010-08-25 09:50:20 -0300290static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300291 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200292 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293};
294
lawrence rust2e4e98e2010-08-25 09:50:20 -0300295static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 .demod_address = 0x0f,
297 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298};
Chris Pascoefc40b262006-01-09 15:25:35 -0200299
lawrence rust2e4e98e2010-08-25 09:50:20 -0300300static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300301 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200302 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200303};
304
lawrence rust2e4e98e2010-08-25 09:50:20 -0300305static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300306 .demod_address = (0x1e >> 1),
307 .no_tuner = 1,
308 .if2 = 45600,
309};
310
Sergey Ivanov111ac842010-08-09 10:18:32 -0300311static struct mb86a16_config twinhan_vp1027 = {
312 .demod_address = 0x08,
313};
314
Peter Senna Tschudin7b34be72013-01-20 01:32:56 -0300315#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200316static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
317{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300318 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
319 static const u8 reset [] = { 0x50, 0x80 };
320 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
321 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200322 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300323 static const u8 dntv_extra[] = { 0xB5, 0x7A };
324 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200325
326 mt352_write(fe, clock_config, sizeof(clock_config));
327 udelay(2000);
328 mt352_write(fe, reset, sizeof(reset));
329 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
330
331 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
332 udelay(2000);
333 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
334 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
335
336 return 0;
337}
338
lawrence rust2e4e98e2010-08-25 09:50:20 -0300339static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200340 .demod_address = 0x0f,
341 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200342 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200343};
344#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
lawrence rust2e4e98e2010-08-25 09:50:20 -0300346static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300347 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300348 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300349};
350
lawrence rust2e4e98e2010-08-25 09:50:20 -0300351static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300352 .demod_address = 0x0f,
353 .if2 = 45600,
354 .no_tuner = 1,
355};
356
lawrence rust2e4e98e2010-08-25 09:50:20 -0300357static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300358 .demod_address = 0x0f,
359 .if2 = 4560,
360 .no_tuner = 1,
361 .demod_init = dvico_fusionhdtv_demod_init,
362};
363
lawrence rust2e4e98e2010-08-25 09:50:20 -0300364static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300365 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300366};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300367
lawrence rust2e4e98e2010-08-25 09:50:20 -0300368static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700370 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371};
372
lawrence rust2e4e98e2010-08-25 09:50:20 -0300373static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300374 .demod_address = 0x63,
375 .output_mode = CX22702_SERIAL_OUTPUT,
376};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
Michael Krufky4a390552006-12-05 02:00:53 -0300378static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
380 struct cx8802_dev *dev= fe->dvb->priv;
381 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
382 return 0;
383}
384
lawrence rust2e4e98e2010-08-25 09:50:20 -0300385static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300386 .demod_address = 0x15,
387 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Michael Krufky6ddcc912005-07-27 11:46:00 -0700390static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700391{
392 struct cx8802_dev *dev= fe->dvb->priv;
393 struct cx88_core *core = dev->core;
394
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300395 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700396 if (index == 0)
397 cx_clear(MO_GP0_IO, 8);
398 else
399 cx_set(MO_GP0_IO, 8);
400 return 0;
401}
402
Michael Krufky6ddcc912005-07-27 11:46:00 -0700403static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700404{
405 struct cx8802_dev *dev= fe->dvb->priv;
406 if (is_punctured)
407 dev->ts_gen_cntrl |= 0x04;
408 else
409 dev->ts_gen_cntrl &= ~0x04;
410 return 0;
411}
412
Michael Krufky6ddcc912005-07-27 11:46:00 -0700413static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300414 .demod_address = 0x0e,
415 .demod_chip = LGDT3302,
416 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
417 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700418};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700419
lawrence rust2e4e98e2010-08-25 09:50:20 -0300420static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300421 .demod_address = 0x0e,
422 .demod_chip = LGDT3303,
423 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
424 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700425};
Rusty Scottda215d22006-04-07 02:21:31 -0300426
lawrence rust2e4e98e2010-08-25 09:50:20 -0300427static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300428 .demod_address = 0x59,
429 .demod_chip = LGDT3303,
430 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
431 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300432};
Michael Krufkyf1798492005-07-07 17:58:39 -0700433
Michael Krufky4a390552006-12-05 02:00:53 -0300434static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800435{
436 struct cx8802_dev *dev= fe->dvb->priv;
437 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
438 return 0;
439}
440
lawrence rust2e4e98e2010-08-25 09:50:20 -0300441static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300442 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300443 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800444};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800445
Steven Toth0fa14aa2006-01-09 15:25:02 -0200446static int cx24123_set_ts_param(struct dvb_frontend* fe,
447 int is_punctured)
448{
449 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300450 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200451 return 0;
452}
453
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300454static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300455 enum fe_sec_voltage voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200456{
457 struct cx8802_dev *dev= fe->dvb->priv;
458 struct cx88_core *core = dev->core;
459
Michael Krufky4a390552006-12-05 02:00:53 -0300460 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300461 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300462 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300463 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300464
465 if (core->prev_set_voltage)
466 return core->prev_set_voltage(fe, voltage);
467 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200468}
469
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300470static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300471 enum fe_sec_voltage voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300472{
473 struct cx8802_dev *dev= fe->dvb->priv;
474 struct cx88_core *core = dev->core;
475
476 if (voltage == SEC_VOLTAGE_OFF) {
477 dprintk(1,"LNB Voltage OFF\n");
478 cx_write(MO_GP0_IO, 0x0000efff);
479 }
480
481 if (core->prev_set_voltage)
482 return core->prev_set_voltage(fe, voltage);
483 return 0;
484}
485
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300486static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300487 enum fe_sec_voltage voltage)
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300488{
489 struct cx8802_dev *dev= fe->dvb->priv;
490 struct cx88_core *core = dev->core;
491
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300492 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300493 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300494 case SEC_VOLTAGE_13:
495 cx_clear(MO_GP0_IO, 0x20);
496 break;
497 case SEC_VOLTAGE_18:
498 cx_set(MO_GP0_IO, 0x20);
499 break;
500 case SEC_VOLTAGE_OFF:
501 cx_clear(MO_GP0_IO, 0x20);
502 break;
503 }
504
505 if (core->prev_set_voltage)
506 return core->prev_set_voltage(fe, voltage);
507 return 0;
508}
509
510static int vp1027_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300511 enum fe_sec_voltage voltage)
Sergey Ivanov111ac842010-08-09 10:18:32 -0300512{
513 struct cx8802_dev *dev = fe->dvb->priv;
514 struct cx88_core *core = dev->core;
515
516 switch (voltage) {
517 case SEC_VOLTAGE_13:
518 dprintk(1, "LNB SEC Voltage=13\n");
519 cx_write(MO_GP0_IO, 0x00001220);
520 break;
521 case SEC_VOLTAGE_18:
522 dprintk(1, "LNB SEC Voltage=18\n");
523 cx_write(MO_GP0_IO, 0x00001222);
524 break;
525 case SEC_VOLTAGE_OFF:
526 dprintk(1, "LNB Voltage OFF\n");
527 cx_write(MO_GP0_IO, 0x00001230);
528 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300529 }
530
531 if (core->prev_set_voltage)
532 return core->prev_set_voltage(fe, voltage);
533 return 0;
534}
535
lawrence rust2e4e98e2010-08-25 09:50:20 -0300536static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300537 .demod_address = 0x55,
538 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300539};
540
lawrence rust2e4e98e2010-08-25 09:50:20 -0300541static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300542 .demod_address = 0x55,
543 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200544};
545
lawrence rust2e4e98e2010-08-25 09:50:20 -0300546static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300547 .demod_address = 0x15,
548 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300549 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200550};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200551
lawrence rust2e4e98e2010-08-25 09:50:20 -0300552static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300553 .demod_address = 0x32 >> 1,
554 .output_mode = S5H1409_PARALLEL_OUTPUT,
555 .gpio = S5H1409_GPIO_ON,
556 .qam_if = 44000,
557 .inversion = S5H1409_INVERSION_OFF,
558 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300559 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300560};
561
lawrence rust2e4e98e2010-08-25 09:50:20 -0300562static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300563 .demod_address = 0x32 >> 1,
564 .output_mode = S5H1409_SERIAL_OUTPUT,
565 .gpio = S5H1409_GPIO_OFF,
566 .inversion = S5H1409_INVERSION_OFF,
567 .status_mode = S5H1409_DEMODLOCKING,
568 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
569};
570
lawrence rust2e4e98e2010-08-25 09:50:20 -0300571static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300572 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300573 .output_mode = S5H1409_SERIAL_OUTPUT,
574 .gpio = S5H1409_GPIO_OFF,
575 .inversion = S5H1409_INVERSION_OFF,
576 .status_mode = S5H1409_DEMODLOCKING,
577 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
578};
579
lawrence rust2e4e98e2010-08-25 09:50:20 -0300580static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300581 .i2c_address = 0x64,
582 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300583};
584
lawrence rust2e4e98e2010-08-25 09:50:20 -0300585static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300586 .demod_address = (0x1e >> 1),
587 .no_tuner = 1,
588 .if2 = 45600,
589};
590
lawrence rust2e4e98e2010-08-25 09:50:20 -0300591static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300592 .demod_address = (0x1e >> 1),
593 .no_tuner = 1,
594 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300595};
596
lawrence rust2e4e98e2010-08-25 09:50:20 -0300597static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300598 .output_mode = S5H1411_SERIAL_OUTPUT,
599 .gpio = S5H1411_GPIO_ON,
600 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
601 .qam_if = S5H1411_IF_44000,
602 .vsb_if = S5H1411_IF_44000,
603 .inversion = S5H1411_INVERSION_OFF,
604 .status_mode = S5H1411_DEMODLOCKING
605};
606
lawrence rust2e4e98e2010-08-25 09:50:20 -0300607static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300608 .i2c_address = 0xc2 >> 1,
609 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300610};
611
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300612static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
613{
614 struct dvb_frontend *fe;
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300615 struct vb2_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300616 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300617 struct xc2028_config cfg = {
618 .i2c_adap = &dev->core->i2c_adap,
619 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300620 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300621 };
622
Darron Broad92abe9e2008-10-11 11:18:53 -0300623 /* Get the first frontend */
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300624 fe0 = vb2_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300625 if (!fe0)
626 return -EINVAL;
627
628 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300629 printk(KERN_ERR "%s/2: dvb frontend not attached. "
630 "Can't attach xc3028\n",
631 dev->core->name);
632 return -EINVAL;
633 }
634
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300635 /*
636 * Some xc3028 devices may be hidden by an I2C gate. This is known
637 * to happen with some s5h1409-based devices.
638 * Now that I2C gate is open, sets up xc3028 configuration
639 */
640 cx88_setup_xc3028(dev->core, &ctl);
641
Steven Toth363c35f2008-10-11 11:05:50 -0300642 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300643 if (!fe) {
644 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
645 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300646 dvb_frontend_detach(fe0->dvb.frontend);
647 dvb_unregister_frontend(fe0->dvb.frontend);
648 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300649 return -EINVAL;
650 }
651
652 printk(KERN_INFO "%s/2: xc3028 attached\n",
653 dev->core->name);
654
655 return 0;
656}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300657
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300658static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg)
659{
660 struct dvb_frontend *fe;
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300661 struct vb2_dvb_frontend *fe0 = NULL;
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300662
663 /* Get the first frontend */
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300664 fe0 = vb2_dvb_get_frontend(&dev->frontends, 1);
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300665 if (!fe0)
666 return -EINVAL;
667
668 if (!fe0->dvb.frontend) {
669 printk(KERN_ERR "%s/2: dvb frontend not attached. "
670 "Can't attach xc4000\n",
671 dev->core->name);
672 return -EINVAL;
673 }
674
675 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap,
676 cfg);
677 if (!fe) {
678 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
679 dev->core->name);
680 dvb_frontend_detach(fe0->dvb.frontend);
681 dvb_unregister_frontend(fe0->dvb.frontend);
682 fe0->dvb.frontend = NULL;
683 return -EINVAL;
684 }
685
686 printk(KERN_INFO "%s/2: xc4000 attached\n", dev->core->name);
687
688 return 0;
689}
690
Steven Toth5bd1b662008-09-04 01:17:33 -0300691static int cx24116_set_ts_param(struct dvb_frontend *fe,
692 int is_punctured)
693{
694 struct cx8802_dev *dev = fe->dvb->priv;
695 dev->ts_gen_cntrl = 0x2;
696
697 return 0;
698}
699
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300700static int stv0900_set_ts_param(struct dvb_frontend *fe,
701 int is_punctured)
702{
703 struct cx8802_dev *dev = fe->dvb->priv;
704 dev->ts_gen_cntrl = 0;
705
706 return 0;
707}
708
Steven Toth5bd1b662008-09-04 01:17:33 -0300709static int cx24116_reset_device(struct dvb_frontend *fe)
710{
711 struct cx8802_dev *dev = fe->dvb->priv;
712 struct cx88_core *core = dev->core;
713
714 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300715 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300716 cx_write(MO_SRST_IO, 0);
717 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300718 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300719 cx_write(MO_SRST_IO, 1);
720 msleep(10);
721
722 return 0;
723}
724
lawrence rust2e4e98e2010-08-25 09:50:20 -0300725static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300726 .demod_address = 0x05,
727 .set_ts_params = cx24116_set_ts_param,
728 .reset_device = cx24116_reset_device,
729};
730
lawrence rust2e4e98e2010-08-25 09:50:20 -0300731static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300732 .demod_address = 0x55,
733 .set_ts_params = cx24116_set_ts_param,
734 .reset_device = cx24116_reset_device,
735};
736
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300737static int ds3000_set_ts_param(struct dvb_frontend *fe,
738 int is_punctured)
739{
740 struct cx8802_dev *dev = fe->dvb->priv;
741 dev->ts_gen_cntrl = 4;
742
743 return 0;
744}
745
746static struct ds3000_config tevii_ds3000_config = {
747 .demod_address = 0x68,
748 .set_ts_params = ds3000_set_ts_param,
749};
750
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300751static struct ts2020_config tevii_ts2020_config = {
752 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300753 .clk_out_div = 1,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300754};
755
lawrence rust2e4e98e2010-08-25 09:50:20 -0300756static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300757 .demod_address = 0x6a,
758/* demod_mode = 0,*/
759 .xtal = 27000000,
760 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
761 .diseqc_mode = 2,/* 2/3 PWM */
762 .tun1_maddress = 0,/* 0x60 */
763 .tun1_adc = 0,/* 2 Vpp */
764 .path1_mode = 3,
765 .set_ts_params = stv0900_set_ts_param,
766};
767
lawrence rust2e4e98e2010-08-25 09:50:20 -0300768static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300769 .tuner_address = 0x60,
770 .refclock = 27000000,
771};
772
lawrence rust2e4e98e2010-08-25 09:50:20 -0300773static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300774 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300775 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300776 .mclk = 88000000UL,
777 .invert = 1,
778 .skip_reinit = 0,
779 .lock_output = 1,
780 .volt13_op0_op1 = STV0299_VOLT13_OP1,
781 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300782 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300783 .set_ts_params = cx24116_set_ts_param,
784};
785
lawrence rust2e4e98e2010-08-25 09:50:20 -0300786static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300787 .demod_address = 0x68,
788 .min_delay_ms = 100,
789 .set_ts_params = cx24116_set_ts_param,
790};
791
Andy Walls6e0e12f2009-01-11 21:18:04 -0300792static int cx8802_alloc_frontends(struct cx8802_dev *dev)
793{
794 struct cx88_core *core = dev->core;
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300795 struct vb2_dvb_frontend *fe = NULL;
Andy Walls6e0e12f2009-01-11 21:18:04 -0300796 int i;
797
798 mutex_init(&dev->frontends.lock);
799 INIT_LIST_HEAD(&dev->frontends.felist);
800
801 if (!core->board.num_frontends)
802 return -ENODEV;
803
804 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
805 core->board.num_frontends);
806 for (i = 1; i <= core->board.num_frontends; i++) {
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300807 fe = vb2_dvb_alloc_frontend(&dev->frontends, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -0300808 if (!fe) {
809 printk(KERN_ERR "%s() failed to alloc\n", __func__);
Hans Verkuil0b6b6302014-09-20 09:22:18 -0300810 vb2_dvb_dealloc_frontends(&dev->frontends);
Andy Walls6e0e12f2009-01-11 21:18:04 -0300811 return -ENOMEM;
812 }
813 }
814 return 0;
815}
816
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300817
818
lawrence rust2e4e98e2010-08-25 09:50:20 -0300819static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300820 0x01, 0x15,
821 0x02, 0x00,
822 0x03, 0x00,
823 0x04, 0x7D,
824 0x05, 0x0F,
825 0x06, 0x02,
826 0x07, 0x00,
827 0x08, 0x60,
828
829 0x0A, 0xC2,
830 0x0B, 0x00,
831 0x0C, 0x01,
832 0x0D, 0x81,
833 0x0E, 0x44,
834 0x0F, 0x09,
835 0x10, 0x3C,
836 0x11, 0x84,
837 0x12, 0xDA,
838 0x13, 0x99,
839 0x14, 0x8D,
840 0x15, 0xCE,
841 0x16, 0xE8,
842 0x17, 0x43,
843 0x18, 0x1C,
844 0x19, 0x1B,
845 0x1A, 0x1D,
846
847 0x1C, 0x12,
848 0x1D, 0x00,
849 0x1E, 0x00,
850 0x1F, 0x00,
851 0x20, 0x00,
852 0x21, 0x00,
853 0x22, 0x00,
854 0x23, 0x00,
855
856 0x28, 0x02,
857 0x29, 0x28,
858 0x2A, 0x14,
859 0x2B, 0x0F,
860 0x2C, 0x09,
861 0x2D, 0x05,
862
863 0x31, 0x1F,
864 0x32, 0x19,
865 0x33, 0xFC,
866 0x34, 0x13,
867 0xff, 0xff,
868};
869
870
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300871static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300872{
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300873 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300874 struct cx8802_dev *dev = fe->dvb->priv;
875 u8 buf[4];
876 u32 div;
877 struct i2c_msg msg = {
878 .addr = 0x61,
879 .flags = 0,
880 .buf = buf,
881 .len = sizeof(buf) };
882
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300883 div = c->frequency / 125;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300884
885 buf[0] = (div >> 8) & 0x7f;
886 buf[1] = div & 0xff;
887 buf[2] = 0x84; /* 0xC4 */
888 buf[3] = 0x00;
889
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300890 if (c->frequency < 1500000)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300891 buf[3] |= 0x10;
892
893 if (fe->ops.i2c_gate_ctrl)
894 fe->ops.i2c_gate_ctrl(fe, 1);
895
896 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
897 return -EIO;
898
899 return 0;
900}
901
902static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300903 enum fe_sec_tone_mode tone)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300904{
905 struct cx8802_dev *dev = fe->dvb->priv;
906 struct cx88_core *core = dev->core;
907
908 cx_set(MO_GP0_IO, 0x0800);
909
910 switch (tone) {
911 case SEC_TONE_ON:
912 cx_set(MO_GP0_IO, 0x08);
913 break;
914 case SEC_TONE_OFF:
915 cx_clear(MO_GP0_IO, 0x08);
916 break;
917 default:
918 return -EINVAL;
919 }
920
921 return 0;
922}
923
924static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300925 enum fe_sec_voltage voltage)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300926{
927 struct cx8802_dev *dev = fe->dvb->priv;
928 struct cx88_core *core = dev->core;
929
930 u8 data;
931 struct i2c_msg msg = {
932 .addr = 8,
933 .flags = 0,
934 .buf = &data,
935 .len = sizeof(data) };
936
937 cx_set(MO_GP0_IO, 0x8000);
938
939 switch (voltage) {
940 case SEC_VOLTAGE_OFF:
941 break;
942 case SEC_VOLTAGE_13:
943 data = ISL6421_EN1 | ISL6421_LLC1;
944 cx_clear(MO_GP0_IO, 0x80);
945 break;
946 case SEC_VOLTAGE_18:
947 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
948 cx_clear(MO_GP0_IO, 0x80);
949 break;
950 default:
951 return -EINVAL;
Peter Senna Tschudinc2c1b412012-09-28 05:37:22 -0300952 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300953
954 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
955}
956
957static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
958 u32 srate, u32 ratio)
959{
960 u8 aclk = 0;
961 u8 bclk = 0;
962
963 if (srate < 1500000) {
964 aclk = 0xb7;
965 bclk = 0x47;
966 } else if (srate < 3000000) {
967 aclk = 0xb7;
968 bclk = 0x4b;
969 } else if (srate < 7000000) {
970 aclk = 0xb7;
971 bclk = 0x4f;
972 } else if (srate < 14000000) {
973 aclk = 0xb7;
974 bclk = 0x53;
975 } else if (srate < 30000000) {
976 aclk = 0xb6;
977 bclk = 0x53;
978 } else if (srate < 45000000) {
979 aclk = 0xb4;
980 bclk = 0x51;
981 }
982
983 stv0299_writereg(fe, 0x13, aclk);
984 stv0299_writereg(fe, 0x14, bclk);
985 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
986 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
987 stv0299_writereg(fe, 0x21, ratio & 0xf0);
988
989 return 0;
990}
991
992
lawrence rust2e4e98e2010-08-25 09:50:20 -0300993static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300994 .demod_address = 0x68,
995 .inittab = samsung_smt_7020_inittab,
996 .mclk = 88000000UL,
997 .invert = 0,
998 .skip_reinit = 0,
999 .lock_output = STV0299_LOCKOUTPUT_LK,
1000 .volt13_op0_op1 = STV0299_VOLT13_OP1,
1001 .min_delay_ms = 100,
1002 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
1003};
1004
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005static int dvb_register(struct cx8802_dev *dev)
1006{
Steven Toth363c35f2008-10-11 11:05:50 -03001007 struct cx88_core *core = dev->core;
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001008 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -03001009 int mfe_shared = 0; /* bus not shared by default */
David Fries7b0962d2011-12-15 01:59:20 -03001010 int res = -EINVAL;
Steven Toth363c35f2008-10-11 11:05:50 -03001011
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -03001012 if (0 != core->i2c_rc) {
1013 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
1014 goto frontend_detach;
1015 }
1016
Steven Toth363c35f2008-10-11 11:05:50 -03001017 /* Get the first frontend */
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001018 fe0 = vb2_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001019 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -03001020 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021
Darron Broad8e739092008-10-11 11:31:41 -03001022 /* multi-frontend gate control is undefined or defaults to fe0 */
1023 dev->frontends.gate = 0;
1024
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001025 /* Sets the gate control callback to be used by i2c command calls */
1026 core->gate_ctrl = cx88_dvb_gate_ctrl;
1027
Darron Broad8e739092008-10-11 11:31:41 -03001028 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001029 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001031 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed3552602006-12-05 01:34:56 -03001032 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001033 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001034 if (fe0->dvb.frontend != NULL) {
1035 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001036 0x61, &core->i2c_adap,
1037 DVB_PLL_THOMSON_DTT759X))
1038 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001039 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 break;
Michael Krufkye057ee12005-07-07 17:58:40 -07001041 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -02001043 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -08001044 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -03001045 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001046 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001047 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001048 if (fe0->dvb.frontend != NULL) {
1049 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001050 0x60, &core->i2c_adap,
1051 DVB_PLL_THOMSON_DTT7579))
1052 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001053 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -03001055 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -02001056 case CX88_BOARD_HAUPPAUGE_HVR1100:
1057 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -03001058 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -03001059 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed3552602006-12-05 01:34:56 -03001060 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001061 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001062 if (fe0->dvb.frontend != NULL) {
1063 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001064 &core->i2c_adap, 0x61,
1065 TUNER_PHILIPS_FMD1216ME_MK3))
1066 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001067 }
Steven Toth611900c2006-01-09 15:25:12 -02001068 break;
Miroslav Slugen27b93d82011-12-13 15:36:15 -03001069 case CX88_BOARD_WINFAST_DTV2000H_J:
1070 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1071 &hauppauge_hvr_config,
1072 &core->i2c_adap);
1073 if (fe0->dvb.frontend != NULL) {
1074 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1075 &core->i2c_adap, 0x61,
1076 TUNER_PHILIPS_FMD1216MEX_MK3))
1077 goto frontend_detach;
1078 }
1079 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001080 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -03001081 /* MFE frontend 1 */
1082 mfe_shared = 1;
1083 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001084 /* DVB-S init */
1085 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001086 &hauppauge_novas_config,
1087 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001088 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001089 if (!dvb_attach(isl6421_attach,
1090 fe0->dvb.frontend,
1091 &dev->core->i2c_adap,
Mauro Carvalho Chehab48a8a032013-04-05 12:18:54 -03001092 0x08, ISL6421_DCL, 0x00, false))
Darron Broad60a5a922008-11-11 08:48:27 -03001093 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001094 }
Darron Broad60a5a922008-11-11 08:48:27 -03001095 /* MFE frontend 2 */
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001096 fe1 = vb2_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001097 if (!fe1)
1098 goto frontend_detach;
1099 /* DVB-T init */
1100 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1101 &hauppauge_hvr_config,
1102 &dev->core->i2c_adap);
1103 if (fe1->dvb.frontend) {
1104 fe1->dvb.frontend->id = 1;
1105 if (!dvb_attach(simple_tuner_attach,
1106 fe1->dvb.frontend,
1107 &dev->core->i2c_adap,
1108 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1109 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001110 }
1111 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001112 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001113 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001114 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001115 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001116 if (fe0->dvb.frontend != NULL) {
1117 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001118 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1119 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001120 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001121 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001122 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001123 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001124 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001125 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001126 if (fe0->dvb.frontend != NULL) {
1127 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001128 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1129 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001130 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001131 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001132 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001133 /* The tin box says DEE1601, but it seems to be DTT7579
1134 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001135 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001136 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001137 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001138 if (fe0->dvb.frontend != NULL) {
1139 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001140 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1141 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001142 break;
1143 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001144 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001145 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001146 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001147 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001148 if (fe0->dvb.frontend != NULL) {
1149 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001150 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1151 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001152 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001153 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001155 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001156 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001157 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001158 if (fe0->dvb.frontend != NULL) {
1159 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001160 0x61, NULL, DVB_PLL_LG_Z201))
1161 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001162 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 case CX88_BOARD_KWORLD_DVB_T:
1165 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001166 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001167 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001168 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001169 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001170 if (fe0->dvb.frontend != NULL) {
1171 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001172 0x61, NULL, DVB_PLL_UNKNOWN_1))
1173 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001174 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001176 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Peter Senna Tschudin7b34be72013-01-20 01:32:56 -03001177#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054)
Trent Piephof0ad9092007-10-14 02:52:16 -03001178 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001180 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001181 if (fe0->dvb.frontend != NULL) {
1182 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001183 &core->i2c_adap, 0x61,
1184 TUNER_PHILIPS_FMD1216ME_MK3))
1185 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001186 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001187#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001188 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1189 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001190#endif
1191 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001192 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001193 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001194 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001195 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001196 if (fe0->dvb.frontend != NULL) {
1197 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001198 &core->i2c_adap, 0x61,
1199 TUNER_THOMSON_FE6600))
1200 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001201 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001202 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001203 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001204 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001205 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001206 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001207 if (fe0->dvb.frontend == NULL)
1208 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001209 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001210 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001211 /*
1212 * On this board, the demod provides the I2C bus pullup.
1213 * We must not permit gate_ctrl to be performed, or
1214 * the xc3028 cannot communicate on the bus.
1215 */
Steven Toth363c35f2008-10-11 11:05:50 -03001216 if (fe0->dvb.frontend)
1217 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001218 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001219 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001220 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001222 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001223 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001224 if (fe0->dvb.frontend != NULL) {
1225 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001226 &core->i2c_adap, 0x61,
1227 TUNER_THOMSON_DTT761X))
1228 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001229 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001231 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1232 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001233
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001234 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001235 cx_clear(MO_GP0_IO, 1);
1236 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001237 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001238 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001239
1240 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001241 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001242 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001243 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001244 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001245 if (fe0->dvb.frontend != NULL) {
1246 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001247 &core->i2c_adap, 0x61,
1248 TUNER_MICROTUNE_4042FI5))
1249 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001250 }
1251 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001252 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1253 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001254
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001255 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001256 cx_clear(MO_GP0_IO, 1);
1257 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001258 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001259 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001260 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001261 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001262 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001263 if (fe0->dvb.frontend != NULL) {
1264 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001265 &core->i2c_adap, 0x61,
1266 TUNER_THOMSON_DTT761X))
1267 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001268 }
1269 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001270 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1271 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001272
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001273 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001274 cx_clear(MO_GP0_IO, 1);
1275 mdelay(100);
1276 cx_set(MO_GP0_IO, 1);
1277 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001278 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001279 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001280 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001281 if (fe0->dvb.frontend != NULL) {
1282 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001283 &core->i2c_adap, 0x61,
1284 TUNER_LG_TDVS_H06XF))
1285 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001286 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001287 &core->i2c_adap, 0x43))
1288 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001289 }
1290 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001291 case CX88_BOARD_PCHDTV_HD5500:
1292 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001293
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001294 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001295 cx_clear(MO_GP0_IO, 1);
1296 mdelay(100);
1297 cx_set(MO_GP0_IO, 1);
1298 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001299 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001300 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001301 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001302 if (fe0->dvb.frontend != NULL) {
1303 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001304 &core->i2c_adap, 0x61,
1305 TUNER_LG_TDVS_H06XF))
1306 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001307 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001308 &core->i2c_adap, 0x43))
1309 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001310 }
1311 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001312 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001313 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001314 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001315 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001316 if (fe0->dvb.frontend != NULL) {
1317 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001318 &core->i2c_adap, 0x61,
1319 TUNER_PHILIPS_TUV1236D))
1320 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001321 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001322 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001323 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1324 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001325 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001326 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001327 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001328 if (fe0->dvb.frontend) {
Mauro Carvalho Chehab48a8a032013-04-05 12:18:54 -03001329 bool override_tone;
1330
1331 if (core->model == 92001)
1332 override_tone = true;
1333 else
1334 override_tone = false;
1335
Steven Toth363c35f2008-10-11 11:05:50 -03001336 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab48a8a032013-04-05 12:18:54 -03001337 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00,
1338 override_tone))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001339 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001340 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001341 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001342 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001343 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001344 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001345 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001346 if (fe0->dvb.frontend) {
1347 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1348 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001349 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001350 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001351 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001352 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001353 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001354 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001355 if (fe0->dvb.frontend) {
1356 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1357 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001358 }
1359 break;
Steven Toth60464da2008-01-05 16:53:01 -03001360 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001361 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001362 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001363 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001364 if (fe0->dvb.frontend != NULL) {
1365 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001366 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001367 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001368 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001369 }
1370 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001371 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001372 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001373 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001374 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001375 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001376 struct dvb_frontend *fe;
1377 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001378 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001379 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001380 };
1381 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001382 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001383 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001384 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001385 };
1386
1387 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001388 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001389 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1390 fe->ops.tuner_ops.set_config(fe, &ctl);
1391 }
1392 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001393 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001394 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001395 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001396 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001397 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001398 if (fe0->dvb.frontend) {
1399 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001400 if (attach_xc3028(0x61, dev) < 0)
1401 goto frontend_detach;
1402 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001403 break;
istvan_v@mailbox.hu8eb79c02011-06-07 13:16:56 -03001404 case CX88_BOARD_WINFAST_DTV1800H_XC4000:
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001405 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1406 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1407 &cx88_pinnacle_hybrid_pctv,
1408 &core->i2c_adap);
1409 if (fe0->dvb.frontend) {
1410 struct xc4000_config cfg = {
1411 .i2c_address = 0x61,
1412 .default_pm = 0,
1413 .dvb_amplitude = 134,
1414 .set_smoothedcvbs = 1,
1415 .if_khz = 4560
1416 };
1417 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1418 if (attach_xc4000(dev, &cfg) < 0)
1419 goto frontend_detach;
1420 }
1421 break;
1422 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001423 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001424
Steven Toth363c35f2008-10-11 11:05:50 -03001425 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001426 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001427 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001428 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001429 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001430 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001431 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001432 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001433 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001434 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001435 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001436 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001437 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001438 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001439 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001440 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001441 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001442 if (fe0->dvb.frontend != NULL) {
1443 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001444 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001445 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001446 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001447 }
1448 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001449 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001450 /* MFE frontend 1 */
1451 mfe_shared = 1;
1452 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001453 /* DVB-S/S2 Init */
1454 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001455 &hauppauge_hvr4000_config,
1456 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001457 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001458 if (!dvb_attach(isl6421_attach,
1459 fe0->dvb.frontend,
1460 &dev->core->i2c_adap,
Mauro Carvalho Chehab48a8a032013-04-05 12:18:54 -03001461 0x08, ISL6421_DCL, 0x00, false))
Darron Broad60a5a922008-11-11 08:48:27 -03001462 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001463 }
Darron Broad60a5a922008-11-11 08:48:27 -03001464 /* MFE frontend 2 */
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001465 fe1 = vb2_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001466 if (!fe1)
1467 goto frontend_detach;
1468 /* DVB-T Init */
1469 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1470 &hauppauge_hvr_config,
1471 &dev->core->i2c_adap);
1472 if (fe1->dvb.frontend) {
1473 fe1->dvb.frontend->id = 1;
1474 if (!dvb_attach(simple_tuner_attach,
1475 fe1->dvb.frontend,
1476 &dev->core->i2c_adap,
1477 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1478 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001479 }
1480 break;
1481 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1482 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001483 &hauppauge_hvr4000_config,
1484 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001485 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001486 if (!dvb_attach(isl6421_attach,
1487 fe0->dvb.frontend,
1488 &dev->core->i2c_adap,
Mauro Carvalho Chehab48a8a032013-04-05 12:18:54 -03001489 0x08, ISL6421_DCL, 0x00, false))
Darron Broad60a5a922008-11-11 08:48:27 -03001490 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001491 }
1492 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001493 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001494 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001495 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001496 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001497 &tevii_tuner_sharp_config,
1498 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001499 if (fe0->dvb.frontend != NULL) {
1500 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001501 &core->i2c_adap, DVB_PLL_OPERA1))
1502 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001503 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1504 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001505
1506 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001507 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001508 &tevii_tuner_earda_config,
1509 &core->i2c_adap);
Mauro Carvalho Chehab86c330f2014-12-23 13:47:47 -03001510 if (fe0->dvb.frontend != NULL) {
1511 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001512 &core->i2c_adap))
1513 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001514 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1515 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001516 }
1517 }
1518 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001519 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001520 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001521 &tevii_s460_config,
1522 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001523 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001524 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001525 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001526 case CX88_BOARD_TEVII_S464:
1527 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1528 &tevii_ds3000_config,
1529 &core->i2c_adap);
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001530 if (fe0->dvb.frontend != NULL) {
1531 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1532 &tevii_ts2020_config, &core->i2c_adap);
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001533 fe0->dvb.frontend->ops.set_voltage =
1534 tevii_dvbs_set_voltage;
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001535 }
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001536 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001537 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001538 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001539 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001540 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001541 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001542 &hauppauge_hvr4000_config,
1543 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001544 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001545 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001546 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001547 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1548 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1549 &cx88_terratec_cinergy_ht_pci_mkii_config,
1550 &core->i2c_adap);
1551 if (fe0->dvb.frontend) {
1552 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1553 if (attach_xc3028(0x61, dev) < 0)
1554 goto frontend_detach;
1555 }
1556 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001557 case CX88_BOARD_PROF_7301:{
1558 struct dvb_tuner_ops *tuner_ops = NULL;
1559
1560 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1561 &prof_7301_stv0900_config,
1562 &core->i2c_adap, 0);
1563 if (fe0->dvb.frontend != NULL) {
1564 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1565 &prof_7301_stb6100_config,
1566 &core->i2c_adap))
1567 goto frontend_detach;
1568
1569 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1570 tuner_ops->set_frequency = stb6100_set_freq;
1571 tuner_ops->get_frequency = stb6100_get_freq;
1572 tuner_ops->set_bandwidth = stb6100_set_bandw;
1573 tuner_ops->get_bandwidth = stb6100_get_bandw;
1574
1575 core->prev_set_voltage =
1576 fe0->dvb.frontend->ops.set_voltage;
1577 fe0->dvb.frontend->ops.set_voltage =
1578 tevii_dvbs_set_voltage;
1579 }
1580 break;
1581 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001582 case CX88_BOARD_SAMSUNG_SMT_7020:
1583 dev->ts_gen_cntrl = 0x08;
1584
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001585 cx_set(MO_GP0_IO, 0x0101);
1586
1587 cx_clear(MO_GP0_IO, 0x01);
1588 mdelay(100);
1589 cx_set(MO_GP0_IO, 0x01);
1590 mdelay(200);
1591
1592 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1593 &samsung_stv0299_config,
1594 &dev->core->i2c_adap);
1595 if (fe0->dvb.frontend) {
1596 fe0->dvb.frontend->ops.tuner_ops.set_params =
1597 samsung_smt_7020_tuner_set_params;
1598 fe0->dvb.frontend->tuner_priv =
1599 &dev->core->i2c_adap;
1600 fe0->dvb.frontend->ops.set_voltage =
1601 samsung_smt_7020_set_voltage;
1602 fe0->dvb.frontend->ops.set_tone =
1603 samsung_smt_7020_set_tone;
1604 }
1605
1606 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001607 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1608 dev->ts_gen_cntrl = 0x00;
1609 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1610 &twinhan_vp1027,
1611 &core->i2c_adap);
1612 if (fe0->dvb.frontend) {
1613 core->prev_set_voltage =
1614 fe0->dvb.frontend->ops.set_voltage;
1615 fe0->dvb.frontend->ops.set_voltage =
1616 vp1027_set_voltage;
1617 }
1618 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001619
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001621 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001622 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 break;
1624 }
Steven Toth363c35f2008-10-11 11:05:50 -03001625
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001626 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001627 printk(KERN_ERR
1628 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001629 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001630 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001631 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001632 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001633 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001634
Steven Toth6c5be742006-12-02 21:15:51 -02001635 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001636 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1637 if (fe1)
1638 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001640 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001641 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001642
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643 /* register everything */
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001644 res = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Mauro Carvalho Chehab2773b0e2016-02-05 08:35:50 -02001645 &dev->pci->dev, NULL, adapter_nr,
1646 mfe_shared);
David Fries7b0962d2011-12-15 01:59:20 -03001647 if (res)
1648 goto frontend_detach;
1649 return res;
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001650
1651frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001652 core->gate_ctrl = NULL;
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001653 vb2_dvb_dealloc_frontends(&dev->frontends);
David Fries7b0962d2011-12-15 01:59:20 -03001654 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655}
1656
1657/* ----------------------------------------------------------- */
1658
Steven Toth6c5be742006-12-02 21:15:51 -02001659/* CX8802 MPEG -> mini driver - We have been given the hardware */
1660static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661{
Steven Toth6c5be742006-12-02 21:15:51 -02001662 struct cx88_core *core = drv->core;
1663 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001664 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001665
Trent Piepho6a59d642007-08-15 14:41:57 -03001666 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001667 case CX88_BOARD_HAUPPAUGE_HVR1300:
1668 /* We arrive here with either the cx23416 or the cx22702
1669 * on the bus. Take the bus from the cx23416 and enable the
1670 * cx22702 demod
1671 */
Darron Broad79392732008-12-18 06:28:35 -03001672 /* Toggle reset on cx22702 leaving i2c active */
1673 cx_set(MO_GP0_IO, 0x00000080);
1674 udelay(1000);
1675 cx_clear(MO_GP0_IO, 0x00000080);
1676 udelay(50);
1677 cx_set(MO_GP0_IO, 0x00000080);
1678 udelay(1000);
1679 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001680 cx_clear(MO_GP0_IO, 0x00000004);
1681 udelay(1000);
1682 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001683
Darron Broad92abe9e2008-10-11 11:18:53 -03001684 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001685 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001686 /* Toggle reset on cx22702 leaving i2c active */
1687 cx_set(MO_GP0_IO, 0x00000080);
1688 udelay(1000);
1689 cx_clear(MO_GP0_IO, 0x00000080);
1690 udelay(50);
1691 cx_set(MO_GP0_IO, 0x00000080);
1692 udelay(1000);
1693 switch (core->dvbdev->frontends.active_fe_id) {
1694 case 1: /* DVB-S/S2 Enabled */
1695 /* tri-state the cx22702 pins */
1696 cx_set(MO_GP0_IO, 0x00000004);
1697 /* Take the cx24116/cx24123 out of reset */
1698 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001699 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001700 break;
1701 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001702 /* Put the cx24116/cx24123 into reset */
1703 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001704 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001705 cx_clear(MO_GP0_IO, 0x00000004);
1706 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001707 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001708 }
Darron Broad79392732008-12-18 06:28:35 -03001709 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001710 break;
1711
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001712 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1713 /* set RF input to AIR for DVB-T (GPIO 16) */
1714 cx_write(MO_GP2_IO, 0x0101);
1715 break;
1716
Steven Toth6c5be742006-12-02 21:15:51 -02001717 default:
1718 err = -ENODEV;
1719 }
1720 return err;
1721}
1722
1723/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1724static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1725{
1726 struct cx88_core *core = drv->core;
1727 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001728 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001729
Trent Piepho6a59d642007-08-15 14:41:57 -03001730 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001731 case CX88_BOARD_HAUPPAUGE_HVR1300:
1732 /* Do Nothing, leave the cx22702 on the bus. */
1733 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001734 case CX88_BOARD_HAUPPAUGE_HVR3000:
1735 case CX88_BOARD_HAUPPAUGE_HVR4000:
1736 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001737 default:
1738 err = -ENODEV;
1739 }
1740 return err;
1741}
1742
1743static int cx8802_dvb_probe(struct cx8802_driver *drv)
1744{
1745 struct cx88_core *core = drv->core;
1746 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001747 int err;
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001748 struct vb2_dvb_frontend *fe;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001749 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001751 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001752 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001753 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001754 core->name,
1755 core->pci_bus,
1756 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757
1758 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001759 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 goto fail_core;
1761
Trent Piephoecf854d2007-05-05 20:11:32 -03001762 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001763 err = vp3054_i2c_probe(dev);
1764 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001765 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001766
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001768 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001769 dev->ts_gen_cntrl = 0x0c;
1770
Andy Walls6e0e12f2009-01-11 21:18:04 -03001771 err = cx8802_alloc_frontends(dev);
1772 if (err)
1773 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001774
Andy Walls6e0e12f2009-01-11 21:18:04 -03001775 err = -ENODEV;
1776 for (i = 1; i <= core->board.num_frontends; i++) {
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001777 struct vb2_queue *q;
1778
1779 fe = vb2_dvb_get_frontend(&core->dvbdev->frontends, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001780 if (fe == NULL) {
1781 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001782 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001783 goto fail_probe;
1784 }
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001785 q = &fe->dvb.dvbq;
1786 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1787 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
1788 q->gfp_flags = GFP_DMA32;
1789 q->min_buffers_needed = 2;
1790 q->drv_priv = dev;
1791 q->buf_struct_size = sizeof(struct cx88_buffer);
1792 q->ops = &dvb_qops;
1793 q->mem_ops = &vb2_dma_sg_memops;
1794 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1795 q->lock = &core->lock;
1796
1797 err = vb2_queue_init(q);
1798 if (err < 0)
1799 goto fail_probe;
1800
1801 /* init struct vb2_dvb */
Andy Walls6e0e12f2009-01-11 21:18:04 -03001802 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001803 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001804
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001806 if (err)
1807 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001808 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1809 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001810 return err;
1811fail_probe:
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001812 vb2_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001813fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 return err;
1815}
1816
Steven Toth6c5be742006-12-02 21:15:51 -02001817static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818{
Darron Broad0fcd4882008-10-21 11:18:47 -03001819 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001820 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001821
Darron Broad0fcd4882008-10-21 11:18:47 -03001822 dprintk( 1, "%s\n", __func__);
1823
Hans Verkuil0b6b6302014-09-20 09:22:18 -03001824 vb2_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825
Chris Pascoefc40b262006-01-09 15:25:35 -02001826 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001827
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001828 core->gate_ctrl = NULL;
1829
Steven Toth6c5be742006-12-02 21:15:51 -02001830 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831}
1832
Steven Toth6c5be742006-12-02 21:15:51 -02001833static struct cx8802_driver cx8802_dvb_driver = {
1834 .type_id = CX88_MPEG_DVB,
1835 .hw_access = CX8802_DRVCTL_SHARED,
1836 .probe = cx8802_dvb_probe,
1837 .remove = cx8802_dvb_remove,
1838 .advise_acquire = cx8802_dvb_advise_acquire,
1839 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840};
1841
Peter Huewe31d0f842009-07-17 01:00:01 +02001842static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843{
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -03001844 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %s loaded\n",
1845 CX88_VERSION);
Steven Toth6c5be742006-12-02 21:15:51 -02001846 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847}
1848
Peter Huewe31d0f842009-07-17 01:00:01 +02001849static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850{
Steven Toth6c5be742006-12-02 21:15:51 -02001851 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852}
1853
1854module_init(dvb_init);
1855module_exit(dvb_fini);