Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Conexant CX23885 PCIe bridge |
| 3 | * |
Steven Toth | 6d89761 | 2008-09-03 17:12:12 -0300 | [diff] [blame] | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 5 | * |
| 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 Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 16 | */ |
| 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 Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 27 | #include <media/v4l2-common.h> |
| 28 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 29 | #include "dvb_ca_en50221.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 30 | #include "s5h1409.h" |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 31 | #include "s5h1411.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 32 | #include "mt2131.h" |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 33 | #include "tda8290.h" |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 34 | #include "tda18271.h" |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 35 | #include "lgdt330x.h" |
istvan_v@mailbox.hu | 0cf8af5 | 2011-07-11 10:58:35 -0300 | [diff] [blame] | 36 | #include "xc4000.h" |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 37 | #include "xc5000.h" |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 38 | #include "max2165.h" |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 39 | #include "tda10048.h" |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 40 | #include "tuner-xc2028.h" |
Michael Krufky | 827855d | 2008-04-22 14:46:16 -0300 | [diff] [blame] | 41 | #include "tuner-simple.h" |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 42 | #include "dib7000p.h" |
James Harper | 46b21bb | 2014-06-12 07:12:24 -0300 | [diff] [blame] | 43 | #include "dib0070.h" |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 44 | #include "dibx000_common.h" |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 45 | #include "zl10353.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 46 | #include "stv0900.h" |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 47 | #include "stv0900_reg.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 48 | #include "stv6110.h" |
| 49 | #include "lnbh24.h" |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 50 | #include "cx24116.h" |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 51 | #include "cx24117.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 52 | #include "cimax2.h" |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 53 | #include "lgs8gxx.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 54 | #include "netup-eeprom.h" |
| 55 | #include "netup-init.h" |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 56 | #include "lgdt3305.h" |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 57 | #include "atbm8830.h" |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 58 | #include "ts2020.h" |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 59 | #include "ds3000.h" |
| 60 | #include "cx23885-f300.h" |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 61 | #include "altera-ci.h" |
| 62 | #include "stv0367.h" |
Stefan Ringel | 722c90e | 2012-01-07 09:20:48 -0300 | [diff] [blame] | 63 | #include "drxk.h" |
| 64 | #include "mt2063.h" |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 65 | #include "stv090x.h" |
| 66 | #include "stb6100.h" |
| 67 | #include "stb6100_cfg.h" |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 68 | #include "tda10071.h" |
| 69 | #include "a8293.h" |
Mauro Carvalho Chehab | 0d1b526 | 2013-08-09 08:53:27 -0300 | [diff] [blame] | 70 | #include "mb86a20s.h" |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 71 | #include "si2165.h" |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 72 | #include "si2168.h" |
| 73 | #include "si2157.h" |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 74 | #include "sp2.h" |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 75 | #include "m88ds3103.h" |
| 76 | #include "m88ts2022.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 77 | |
Steven Toth | 4513fc69 | 2008-01-12 11:36:36 -0300 | [diff] [blame] | 78 | static unsigned int debug; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 79 | |
Steven Toth | 4513fc69 | 2008-01-12 11:36:36 -0300 | [diff] [blame] | 80 | #define dprintk(level, fmt, arg...)\ |
| 81 | do { if (debug >= level)\ |
| 82 | printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ |
| 83 | } while (0) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 84 | |
| 85 | /* ------------------------------------------------------------------ */ |
| 86 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 87 | static unsigned int alt_tuner; |
| 88 | module_param(alt_tuner, int, 0644); |
| 89 | MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); |
| 90 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 91 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 92 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 93 | /* ------------------------------------------------------------------ */ |
| 94 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 95 | static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, |
| 96 | unsigned int *num_buffers, unsigned int *num_planes, |
| 97 | unsigned int sizes[], void *alloc_ctxs[]) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 98 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 99 | struct cx23885_tsport *port = q->drv_priv; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 100 | |
| 101 | port->ts_packet_size = 188 * 4; |
| 102 | port->ts_packet_count = 32; |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 103 | *num_planes = 1; |
| 104 | sizes[0] = port->ts_packet_size * port->ts_packet_count; |
Hans Verkuil | 0c3a14c | 2014-11-18 09:51:01 -0300 | [diff] [blame] | 105 | alloc_ctxs[0] = port->dev->alloc_ctx; |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 106 | *num_buffers = 32; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 107 | return 0; |
| 108 | } |
| 109 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 110 | |
| 111 | static int buffer_prepare(struct vb2_buffer *vb) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 112 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 113 | struct cx23885_tsport *port = vb->vb2_queue->drv_priv; |
| 114 | struct cx23885_buffer *buf = |
| 115 | container_of(vb, struct cx23885_buffer, vb); |
| 116 | |
| 117 | return cx23885_buf_prepare(buf, port); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 118 | } |
| 119 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 120 | static void buffer_finish(struct vb2_buffer *vb) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 121 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 122 | struct cx23885_tsport *port = vb->vb2_queue->drv_priv; |
| 123 | struct cx23885_dev *dev = port->dev; |
| 124 | struct cx23885_buffer *buf = container_of(vb, |
| 125 | struct cx23885_buffer, vb); |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 126 | |
| 127 | cx23885_free_buffer(dev, buf); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 128 | } |
| 129 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 130 | static void buffer_queue(struct vb2_buffer *vb) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 131 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 132 | struct cx23885_tsport *port = vb->vb2_queue->drv_priv; |
| 133 | struct cx23885_buffer *buf = container_of(vb, |
| 134 | struct cx23885_buffer, vb); |
| 135 | |
| 136 | cx23885_buf_queue(port, buf); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 137 | } |
| 138 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 139 | static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open) |
| 140 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 141 | struct vb2_dvb_frontends *f; |
| 142 | struct vb2_dvb_frontend *fe; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 143 | |
| 144 | f = &port->frontends; |
| 145 | |
| 146 | if (f->gate <= 1) /* undefined or fe0 */ |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 147 | fe = vb2_dvb_get_frontend(f, 1); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 148 | else |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 149 | fe = vb2_dvb_get_frontend(f, f->gate); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 150 | |
| 151 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) |
| 152 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open); |
| 153 | } |
| 154 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 155 | static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count) |
| 156 | { |
| 157 | struct cx23885_tsport *port = q->drv_priv; |
| 158 | struct cx23885_dmaqueue *dmaq = &port->mpegq; |
| 159 | struct cx23885_buffer *buf = list_entry(dmaq->active.next, |
| 160 | struct cx23885_buffer, queue); |
| 161 | |
| 162 | cx23885_start_dma(port, dmaq, buf); |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | static void cx23885_stop_streaming(struct vb2_queue *q) |
| 167 | { |
| 168 | struct cx23885_tsport *port = q->drv_priv; |
| 169 | |
| 170 | cx23885_cancel_buffers(port); |
| 171 | } |
| 172 | |
| 173 | static struct vb2_ops dvb_qops = { |
| 174 | .queue_setup = queue_setup, |
| 175 | .buf_prepare = buffer_prepare, |
| 176 | .buf_finish = buffer_finish, |
| 177 | .buf_queue = buffer_queue, |
| 178 | .wait_prepare = vb2_ops_wait_prepare, |
| 179 | .wait_finish = vb2_ops_wait_finish, |
| 180 | .start_streaming = cx23885_start_streaming, |
| 181 | .stop_streaming = cx23885_stop_streaming, |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 182 | }; |
| 183 | |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 184 | static struct s5h1409_config hauppauge_generic_config = { |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 185 | .demod_address = 0x32 >> 1, |
| 186 | .output_mode = S5H1409_SERIAL_OUTPUT, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 187 | .gpio = S5H1409_GPIO_ON, |
Michael Krufky | 2b03238 | 2007-12-13 10:04:10 -0300 | [diff] [blame] | 188 | .qam_if = 44000, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 189 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 190 | .status_mode = S5H1409_DEMODLOCKING, |
| 191 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 192 | }; |
| 193 | |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 194 | static struct tda10048_config hauppauge_hvr1200_config = { |
| 195 | .demod_address = 0x10 >> 1, |
| 196 | .output_mode = TDA10048_SERIAL_OUTPUT, |
| 197 | .fwbulkwritelen = TDA10048_BULKWRITE_200, |
Steven Toth | 484d9e0 | 2009-05-02 11:08:23 -0300 | [diff] [blame] | 198 | .inversion = TDA10048_INVERSION_ON, |
Steven Toth | 8816bef | 2009-05-15 21:04:18 -0300 | [diff] [blame] | 199 | .dtv6_if_freq_khz = TDA10048_IF_3300, |
| 200 | .dtv7_if_freq_khz = TDA10048_IF_3800, |
| 201 | .dtv8_if_freq_khz = TDA10048_IF_4300, |
Steven Toth | 484d9e0 | 2009-05-02 11:08:23 -0300 | [diff] [blame] | 202 | .clk_freq_khz = TDA10048_CLK_16000, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 203 | }; |
| 204 | |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 205 | static struct tda10048_config hauppauge_hvr1210_config = { |
| 206 | .demod_address = 0x10 >> 1, |
| 207 | .output_mode = TDA10048_SERIAL_OUTPUT, |
| 208 | .fwbulkwritelen = TDA10048_BULKWRITE_200, |
| 209 | .inversion = TDA10048_INVERSION_ON, |
Michael Krufky | c27586e | 2009-05-16 11:00:23 -0300 | [diff] [blame] | 210 | .dtv6_if_freq_khz = TDA10048_IF_3300, |
| 211 | .dtv7_if_freq_khz = TDA10048_IF_3500, |
| 212 | .dtv8_if_freq_khz = TDA10048_IF_4000, |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 213 | .clk_freq_khz = TDA10048_CLK_16000, |
| 214 | }; |
| 215 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 216 | static struct s5h1409_config hauppauge_ezqam_config = { |
| 217 | .demod_address = 0x32 >> 1, |
| 218 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 219 | .gpio = S5H1409_GPIO_OFF, |
| 220 | .qam_if = 4000, |
| 221 | .inversion = S5H1409_INVERSION_ON, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 222 | .status_mode = S5H1409_DEMODLOCKING, |
| 223 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 224 | }; |
| 225 | |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 226 | static struct s5h1409_config hauppauge_hvr1800lp_config = { |
| 227 | .demod_address = 0x32 >> 1, |
| 228 | .output_mode = S5H1409_SERIAL_OUTPUT, |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 229 | .gpio = S5H1409_GPIO_OFF, |
Michael Krufky | 2b03238 | 2007-12-13 10:04:10 -0300 | [diff] [blame] | 230 | .qam_if = 44000, |
Steven Toth | fe47516 | 2007-03-20 15:27:53 -0300 | [diff] [blame] | 231 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 232 | .status_mode = S5H1409_DEMODLOCKING, |
| 233 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 234 | }; |
| 235 | |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 236 | static struct s5h1409_config hauppauge_hvr1500_config = { |
| 237 | .demod_address = 0x32 >> 1, |
| 238 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 239 | .gpio = S5H1409_GPIO_OFF, |
| 240 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 241 | .status_mode = S5H1409_DEMODLOCKING, |
| 242 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 243 | }; |
| 244 | |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 245 | static struct mt2131_config hauppauge_generic_tunerconfig = { |
Steven Toth | a77743b | 2007-08-22 21:01:20 -0300 | [diff] [blame] | 246 | 0x61 |
| 247 | }; |
| 248 | |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 249 | static struct lgdt330x_config fusionhdtv_5_express = { |
| 250 | .demod_address = 0x0e, |
| 251 | .demod_chip = LGDT3303, |
| 252 | .serial_mpeg = 0x40, |
| 253 | }; |
| 254 | |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 255 | static struct s5h1409_config hauppauge_hvr1500q_config = { |
| 256 | .demod_address = 0x32 >> 1, |
| 257 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 258 | .gpio = S5H1409_GPIO_ON, |
| 259 | .qam_if = 44000, |
| 260 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 261 | .status_mode = S5H1409_DEMODLOCKING, |
| 262 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 263 | }; |
| 264 | |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 265 | static struct s5h1409_config dvico_s5h1409_config = { |
| 266 | .demod_address = 0x32 >> 1, |
| 267 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 268 | .gpio = S5H1409_GPIO_ON, |
| 269 | .qam_if = 44000, |
| 270 | .inversion = S5H1409_INVERSION_OFF, |
| 271 | .status_mode = S5H1409_DEMODLOCKING, |
| 272 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 273 | }; |
| 274 | |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 275 | static struct s5h1411_config dvico_s5h1411_config = { |
| 276 | .output_mode = S5H1411_SERIAL_OUTPUT, |
| 277 | .gpio = S5H1411_GPIO_ON, |
| 278 | .qam_if = S5H1411_IF_44000, |
| 279 | .vsb_if = S5H1411_IF_44000, |
| 280 | .inversion = S5H1411_INVERSION_OFF, |
| 281 | .status_mode = S5H1411_DEMODLOCKING, |
| 282 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 283 | }; |
| 284 | |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 285 | static struct s5h1411_config hcw_s5h1411_config = { |
| 286 | .output_mode = S5H1411_SERIAL_OUTPUT, |
| 287 | .gpio = S5H1411_GPIO_OFF, |
| 288 | .vsb_if = S5H1411_IF_44000, |
| 289 | .qam_if = S5H1411_IF_4000, |
| 290 | .inversion = S5H1411_INVERSION_ON, |
| 291 | .status_mode = S5H1411_DEMODLOCKING, |
| 292 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 293 | }; |
| 294 | |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 295 | static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { |
Steven Toth | e12671c | 2007-12-20 01:14:43 -0300 | [diff] [blame] | 296 | .i2c_address = 0x61, |
| 297 | .if_khz = 5380, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 298 | }; |
| 299 | |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 300 | static struct xc5000_config dvico_xc5000_tunerconfig = { |
| 301 | .i2c_address = 0x64, |
| 302 | .if_khz = 5380, |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 303 | }; |
| 304 | |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 305 | static struct tda829x_config tda829x_no_probe = { |
| 306 | .probe_tuner = TDA829X_DONT_PROBE, |
| 307 | }; |
| 308 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 309 | static struct tda18271_std_map hauppauge_tda18271_std_map = { |
Michael Krufky | c0dc0c1 | 2008-04-22 14:46:22 -0300 | [diff] [blame] | 310 | .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, |
| 311 | .if_lvl = 6, .rfagc_top = 0x37 }, |
| 312 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, |
| 313 | .if_lvl = 6, .rfagc_top = 0x37 }, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 314 | }; |
| 315 | |
Michael Krufky | b34cdc3 | 2009-05-21 12:49:28 -0300 | [diff] [blame] | 316 | static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = { |
| 317 | .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4, |
| 318 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 319 | .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5, |
| 320 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 321 | .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6, |
| 322 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 323 | }; |
| 324 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 325 | static struct tda18271_config hauppauge_tda18271_config = { |
| 326 | .std_map = &hauppauge_tda18271_std_map, |
| 327 | .gate = TDA18271_GATE_ANALOG, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 328 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 329 | }; |
| 330 | |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 331 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { |
Michael Krufky | b34cdc3 | 2009-05-21 12:49:28 -0300 | [diff] [blame] | 332 | .std_map = &hauppauge_hvr1200_tda18271_std_map, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 333 | .gate = TDA18271_GATE_ANALOG, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 334 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 335 | }; |
| 336 | |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 337 | static struct tda18271_config hauppauge_hvr1210_tuner_config = { |
| 338 | .gate = TDA18271_GATE_DIGITAL, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 339 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 340 | }; |
| 341 | |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 342 | static struct tda18271_config hauppauge_hvr4400_tuner_config = { |
| 343 | .gate = TDA18271_GATE_DIGITAL, |
| 344 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
| 345 | }; |
| 346 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 347 | static struct tda18271_std_map hauppauge_hvr127x_std_map = { |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 348 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4, |
| 349 | .if_lvl = 1, .rfagc_top = 0x58 }, |
| 350 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5, |
| 351 | .if_lvl = 1, .rfagc_top = 0x58 }, |
| 352 | }; |
| 353 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 354 | static struct tda18271_config hauppauge_hvr127x_config = { |
| 355 | .std_map = &hauppauge_hvr127x_std_map, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 356 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 357 | }; |
| 358 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 359 | static struct lgdt3305_config hauppauge_lgdt3305_config = { |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 360 | .i2c_addr = 0x0e, |
| 361 | .mpeg_mode = LGDT3305_MPEG_SERIAL, |
| 362 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, |
| 363 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, |
| 364 | .deny_i2c_rptr = 1, |
| 365 | .spectral_inversion = 1, |
| 366 | .qam_if_khz = 4000, |
| 367 | .vsb_if_khz = 3250, |
| 368 | }; |
| 369 | |
Harvey Harrison | b1721d0 | 2008-04-25 19:03:08 -0700 | [diff] [blame] | 370 | static struct dibx000_agc_config xc3028_agc_config = { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 371 | BAND_VHF | BAND_UHF, /* band_caps */ |
| 372 | |
| 373 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, |
| 374 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, |
| 375 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, |
| 376 | * P_agc_nb_est=2, P_agc_write=0 |
| 377 | */ |
| 378 | (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | |
| 379 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ |
| 380 | |
| 381 | 712, /* inv_gain */ |
| 382 | 21, /* time_stabiliz */ |
| 383 | |
| 384 | 0, /* alpha_level */ |
| 385 | 118, /* thlock */ |
| 386 | |
| 387 | 0, /* wbd_inv */ |
| 388 | 2867, /* wbd_ref */ |
| 389 | 0, /* wbd_sel */ |
| 390 | 2, /* wbd_alpha */ |
| 391 | |
| 392 | 0, /* agc1_max */ |
| 393 | 0, /* agc1_min */ |
| 394 | 39718, /* agc2_max */ |
| 395 | 9930, /* agc2_min */ |
| 396 | 0, /* agc1_pt1 */ |
| 397 | 0, /* agc1_pt2 */ |
| 398 | 0, /* agc1_pt3 */ |
| 399 | 0, /* agc1_slope1 */ |
| 400 | 0, /* agc1_slope2 */ |
| 401 | 0, /* agc2_pt1 */ |
| 402 | 128, /* agc2_pt2 */ |
| 403 | 29, /* agc2_slope1 */ |
| 404 | 29, /* agc2_slope2 */ |
| 405 | |
| 406 | 17, /* alpha_mant */ |
| 407 | 27, /* alpha_exp */ |
| 408 | 23, /* beta_mant */ |
| 409 | 51, /* beta_exp */ |
| 410 | |
| 411 | 1, /* perform_agc_softsplit */ |
| 412 | }; |
| 413 | |
| 414 | /* PLL Configuration for COFDM BW_MHz = 8.000000 |
| 415 | * With external clock = 30.000000 */ |
Harvey Harrison | b1721d0 | 2008-04-25 19:03:08 -0700 | [diff] [blame] | 416 | static struct dibx000_bandwidth_config xc3028_bw_config = { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 417 | 60000, /* internal */ |
| 418 | 30000, /* sampling */ |
| 419 | 1, /* pll_cfg: prediv */ |
| 420 | 8, /* pll_cfg: ratio */ |
| 421 | 3, /* pll_cfg: range */ |
| 422 | 1, /* pll_cfg: reset */ |
| 423 | 0, /* pll_cfg: bypass */ |
| 424 | 0, /* misc: refdiv */ |
| 425 | 0, /* misc: bypclk_div */ |
| 426 | 1, /* misc: IO_CLK_en_core */ |
| 427 | 1, /* misc: ADClkSrc */ |
| 428 | 0, /* misc: modulo */ |
| 429 | (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ |
| 430 | (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ |
| 431 | 20452225, /* timf */ |
| 432 | 30000000 /* xtal_hz */ |
| 433 | }; |
| 434 | |
| 435 | static struct dib7000p_config hauppauge_hvr1400_dib7000_config = { |
| 436 | .output_mpeg2_in_188_bytes = 1, |
| 437 | .hostbus_diversity = 1, |
| 438 | .tuner_is_baseband = 0, |
| 439 | .update_lna = NULL, |
| 440 | |
| 441 | .agc_config_count = 1, |
| 442 | .agc = &xc3028_agc_config, |
| 443 | .bw = &xc3028_bw_config, |
| 444 | |
| 445 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, |
| 446 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, |
| 447 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, |
| 448 | |
| 449 | .pwm_freq_div = 0, |
| 450 | .agc_control = NULL, |
| 451 | .spur_protect = 0, |
| 452 | |
| 453 | .output_mode = OUTMODE_MPEG2_SERIAL, |
| 454 | }; |
| 455 | |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 456 | static struct zl10353_config dvico_fusionhdtv_xc3028 = { |
| 457 | .demod_address = 0x0f, |
| 458 | .if2 = 45600, |
| 459 | .no_tuner = 1, |
Christopher Pascoe | d4dc673 | 2009-04-27 11:27:04 -0300 | [diff] [blame] | 460 | .disable_i2c_gate_ctrl = 1, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 461 | }; |
| 462 | |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 463 | static struct stv0900_reg stv0900_ts_regs[] = { |
| 464 | { R0900_TSGENERAL, 0x00 }, |
| 465 | { R0900_P1_TSSPEED, 0x40 }, |
| 466 | { R0900_P2_TSSPEED, 0x40 }, |
| 467 | { R0900_P1_TSCFGM, 0xc0 }, |
| 468 | { R0900_P2_TSCFGM, 0xc0 }, |
| 469 | { R0900_P1_TSCFGH, 0xe0 }, |
| 470 | { R0900_P2_TSCFGH, 0xe0 }, |
| 471 | { R0900_P1_TSCFGL, 0x20 }, |
| 472 | { R0900_P2_TSCFGL, 0x20 }, |
| 473 | { 0xffff, 0xff }, /* terminate */ |
| 474 | }; |
| 475 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 476 | static struct stv0900_config netup_stv0900_config = { |
| 477 | .demod_address = 0x68, |
Igor M. Liplianin | 29372a8 | 2009-10-17 08:58:26 -0300 | [diff] [blame] | 478 | .demod_mode = 1, /* dual */ |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 479 | .xtal = 8000000, |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 480 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 481 | .diseqc_mode = 2,/* 2/3 PWM */ |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 482 | .ts_config_regs = stv0900_ts_regs, |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 483 | .tun1_maddress = 0,/* 0x60 */ |
| 484 | .tun2_maddress = 3,/* 0x63 */ |
| 485 | .tun1_adc = 1,/* 1 Vpp */ |
| 486 | .tun2_adc = 1,/* 1 Vpp */ |
| 487 | }; |
| 488 | |
| 489 | static struct stv6110_config netup_stv6110_tunerconfig_a = { |
| 490 | .i2c_address = 0x60, |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 491 | .mclk = 16000000, |
| 492 | .clk_div = 1, |
Abylay Ospan | 873688c | 2009-10-17 08:23:00 -0300 | [diff] [blame] | 493 | .gain = 8, /* +16 dB - maximum gain */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 494 | }; |
| 495 | |
| 496 | static struct stv6110_config netup_stv6110_tunerconfig_b = { |
| 497 | .i2c_address = 0x63, |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 498 | .mclk = 16000000, |
| 499 | .clk_div = 1, |
Abylay Ospan | 873688c | 2009-10-17 08:23:00 -0300 | [diff] [blame] | 500 | .gain = 8, /* +16 dB - maximum gain */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 501 | }; |
| 502 | |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 503 | static struct cx24116_config tbs_cx24116_config = { |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 504 | .demod_address = 0x55, |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 505 | }; |
| 506 | |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 507 | static struct cx24117_config tbs_cx24117_config = { |
| 508 | .demod_address = 0x55, |
| 509 | }; |
| 510 | |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 511 | static struct ds3000_config tevii_ds3000_config = { |
| 512 | .demod_address = 0x68, |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 513 | }; |
| 514 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 515 | static struct ts2020_config tevii_ts2020_config = { |
| 516 | .tuner_address = 0x60, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 517 | .clk_out_div = 1, |
Joakim Hernberg | 8d2b022 | 2014-01-31 07:15:48 -0300 | [diff] [blame] | 518 | .frequency_div = 1146000, |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 519 | }; |
| 520 | |
Igor M. Liplianin | c9b8b04 | 2009-01-17 12:23:31 -0300 | [diff] [blame] | 521 | static struct cx24116_config dvbworld_cx24116_config = { |
| 522 | .demod_address = 0x05, |
| 523 | }; |
| 524 | |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 525 | static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = { |
| 526 | .prod = LGS8GXX_PROD_LGS8GL5, |
| 527 | .demod_address = 0x19, |
| 528 | .serial_ts = 0, |
| 529 | .ts_clk_pol = 1, |
| 530 | .ts_clk_gated = 1, |
| 531 | .if_clk_freq = 30400, /* 30.4 MHz */ |
| 532 | .if_freq = 5380, /* 5.38 MHz */ |
| 533 | .if_neg_center = 1, |
| 534 | .ext_adc = 0, |
| 535 | .adc_signed = 0, |
| 536 | .if_neg_edge = 0, |
| 537 | }; |
| 538 | |
| 539 | static struct xc5000_config mygica_x8506_xc5000_config = { |
| 540 | .i2c_address = 0x61, |
| 541 | .if_khz = 5380, |
| 542 | }; |
| 543 | |
Mauro Carvalho Chehab | 0d1b526 | 2013-08-09 08:53:27 -0300 | [diff] [blame] | 544 | static struct mb86a20s_config mygica_x8507_mb86a20s_config = { |
| 545 | .demod_address = 0x10, |
| 546 | }; |
| 547 | |
| 548 | static struct xc5000_config mygica_x8507_xc5000_config = { |
| 549 | .i2c_address = 0x61, |
| 550 | .if_khz = 4000, |
| 551 | }; |
| 552 | |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 553 | static struct stv090x_config prof_8000_stv090x_config = { |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 554 | .device = STV0903, |
| 555 | .demod_mode = STV090x_SINGLE, |
| 556 | .clk_mode = STV090x_CLK_EXT, |
| 557 | .xtal = 27000000, |
| 558 | .address = 0x6A, |
| 559 | .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED, |
| 560 | .repeater_level = STV090x_RPTLEVEL_64, |
| 561 | .adc1_range = STV090x_ADC_2Vpp, |
| 562 | .diseqc_envelope_mode = false, |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 563 | |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 564 | .tuner_get_frequency = stb6100_get_frequency, |
| 565 | .tuner_set_frequency = stb6100_set_frequency, |
| 566 | .tuner_set_bandwidth = stb6100_set_bandwidth, |
| 567 | .tuner_get_bandwidth = stb6100_get_bandwidth, |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 568 | }; |
| 569 | |
| 570 | static struct stb6100_config prof_8000_stb6100_config = { |
| 571 | .tuner_address = 0x60, |
| 572 | .refclock = 27000000, |
| 573 | }; |
| 574 | |
| 575 | static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 576 | { |
| 577 | struct cx23885_tsport *port = fe->dvb->priv; |
| 578 | struct cx23885_dev *dev = port->dev; |
| 579 | |
| 580 | if (voltage == SEC_VOLTAGE_18) |
| 581 | cx_write(MC417_RWD, 0x00001e00); |
| 582 | else if (voltage == SEC_VOLTAGE_13) |
| 583 | cx_write(MC417_RWD, 0x00001a00); |
| 584 | else |
| 585 | cx_write(MC417_RWD, 0x00001800); |
| 586 | return 0; |
| 587 | } |
| 588 | |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 589 | static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe, |
| 590 | fe_sec_voltage_t voltage) |
| 591 | { |
| 592 | struct cx23885_tsport *port = fe->dvb->priv; |
| 593 | struct cx23885_dev *dev = port->dev; |
| 594 | |
| 595 | cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1); |
| 596 | |
| 597 | switch (voltage) { |
| 598 | case SEC_VOLTAGE_13: |
| 599 | cx23885_gpio_set(dev, GPIO_1); |
| 600 | cx23885_gpio_clear(dev, GPIO_0); |
| 601 | break; |
| 602 | case SEC_VOLTAGE_18: |
| 603 | cx23885_gpio_set(dev, GPIO_1); |
| 604 | cx23885_gpio_set(dev, GPIO_0); |
| 605 | break; |
| 606 | case SEC_VOLTAGE_OFF: |
| 607 | cx23885_gpio_clear(dev, GPIO_1); |
| 608 | cx23885_gpio_clear(dev, GPIO_0); |
| 609 | break; |
| 610 | } |
| 611 | |
| 612 | /* call the frontend set_voltage function */ |
| 613 | port->fe_set_voltage(fe, voltage); |
| 614 | |
| 615 | return 0; |
| 616 | } |
| 617 | |
nibble.max | c29d6a8 | 2014-11-05 11:58:38 -0300 | [diff] [blame] | 618 | static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe, |
| 619 | fe_sec_voltage_t voltage) |
| 620 | { |
| 621 | struct cx23885_tsport *port = fe->dvb->priv; |
| 622 | struct cx23885_dev *dev = port->dev; |
| 623 | |
| 624 | cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1); |
| 625 | |
| 626 | switch (voltage) { |
| 627 | case SEC_VOLTAGE_13: |
| 628 | cx23885_gpio_set(dev, GPIO_13); |
| 629 | cx23885_gpio_clear(dev, GPIO_12); |
| 630 | break; |
| 631 | case SEC_VOLTAGE_18: |
| 632 | cx23885_gpio_set(dev, GPIO_13); |
| 633 | cx23885_gpio_set(dev, GPIO_12); |
| 634 | break; |
| 635 | case SEC_VOLTAGE_OFF: |
| 636 | cx23885_gpio_clear(dev, GPIO_13); |
| 637 | cx23885_gpio_clear(dev, GPIO_12); |
| 638 | break; |
| 639 | } |
| 640 | /* call the frontend set_voltage function */ |
| 641 | return port->fe_set_voltage(fe, voltage); |
| 642 | } |
| 643 | |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 644 | static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr, |
| 645 | u8 data, int *mem) |
| 646 | { |
| 647 | /* MC417 */ |
| 648 | #define SP2_DATA 0x000000ff |
| 649 | #define SP2_WR 0x00008000 |
| 650 | #define SP2_RD 0x00004000 |
| 651 | #define SP2_ACK 0x00001000 |
| 652 | #define SP2_ADHI 0x00000800 |
| 653 | #define SP2_ADLO 0x00000400 |
| 654 | #define SP2_CS1 0x00000200 |
| 655 | #define SP2_CS0 0x00000100 |
| 656 | #define SP2_EN_ALL 0x00001000 |
| 657 | #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD) |
| 658 | |
| 659 | struct cx23885_tsport *port = priv; |
| 660 | struct cx23885_dev *dev = port->dev; |
| 661 | int ret; |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 662 | int tmp = 0; |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 663 | unsigned long timeout; |
| 664 | |
| 665 | mutex_lock(&dev->gpio_lock); |
| 666 | |
| 667 | /* write addr */ |
| 668 | cx_write(MC417_OEN, SP2_EN_ALL); |
| 669 | cx_write(MC417_RWD, SP2_CTRL_OFF | |
| 670 | SP2_ADLO | (0xff & addr)); |
| 671 | cx_clear(MC417_RWD, SP2_ADLO); |
| 672 | cx_write(MC417_RWD, SP2_CTRL_OFF | |
| 673 | SP2_ADHI | (0xff & (addr >> 8))); |
| 674 | cx_clear(MC417_RWD, SP2_ADHI); |
| 675 | |
| 676 | if (read) |
| 677 | /* data in */ |
| 678 | cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA); |
| 679 | else |
| 680 | /* data out */ |
| 681 | cx_write(MC417_RWD, SP2_CTRL_OFF | data); |
| 682 | |
| 683 | /* chip select 0 */ |
| 684 | cx_clear(MC417_RWD, SP2_CS0); |
| 685 | |
| 686 | /* read/write */ |
| 687 | cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR); |
| 688 | |
| 689 | /* wait for a maximum of 1 msec */ |
| 690 | timeout = jiffies + msecs_to_jiffies(1); |
| 691 | while (!time_after(jiffies, timeout)) { |
| 692 | tmp = cx_read(MC417_RWD); |
| 693 | if ((tmp & SP2_ACK) == 0) |
| 694 | break; |
| 695 | usleep_range(50, 100); |
| 696 | } |
| 697 | |
| 698 | cx_set(MC417_RWD, SP2_CTRL_OFF); |
| 699 | *mem = tmp & 0xff; |
| 700 | |
| 701 | mutex_unlock(&dev->gpio_lock); |
| 702 | |
| 703 | if (!read) { |
| 704 | if (*mem < 0) { |
| 705 | ret = -EREMOTEIO; |
| 706 | goto err; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | return 0; |
| 711 | err: |
| 712 | return ret; |
| 713 | } |
| 714 | |
Mauro Carvalho Chehab | a7d44ba | 2011-12-26 20:48:54 -0300 | [diff] [blame] | 715 | static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 716 | { |
Mauro Carvalho Chehab | a7d44ba | 2011-12-26 20:48:54 -0300 | [diff] [blame] | 717 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 718 | struct cx23885_tsport *port = fe->dvb->priv; |
| 719 | struct cx23885_dev *dev = port->dev; |
| 720 | |
| 721 | switch (dev->board) { |
| 722 | case CX23885_BOARD_HAUPPAUGE_HVR1275: |
Mauro Carvalho Chehab | a7d44ba | 2011-12-26 20:48:54 -0300 | [diff] [blame] | 723 | switch (p->modulation) { |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 724 | case VSB_8: |
| 725 | cx23885_gpio_clear(dev, GPIO_5); |
| 726 | break; |
| 727 | case QAM_64: |
| 728 | case QAM_256: |
| 729 | default: |
| 730 | cx23885_gpio_set(dev, GPIO_5); |
| 731 | break; |
| 732 | } |
| 733 | break; |
David T.L. Wong | 6f0d8c0 | 2009-10-21 13:15:30 -0300 | [diff] [blame] | 734 | case CX23885_BOARD_MYGICA_X8506: |
Mauro Carvalho Chehab | 0d1b526 | 2013-08-09 08:53:27 -0300 | [diff] [blame] | 735 | case CX23885_BOARD_MYGICA_X8507: |
David T.L. Wong | 6f0d8c0 | 2009-10-21 13:15:30 -0300 | [diff] [blame] | 736 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: |
| 737 | /* Select Digital TV */ |
| 738 | cx23885_gpio_set(dev, GPIO_0); |
| 739 | break; |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 740 | } |
Mauro Carvalho Chehab | 15472fa | 2013-08-09 08:53:25 -0300 | [diff] [blame] | 741 | |
| 742 | /* Call the real set_frontend */ |
| 743 | if (port->set_frontend) |
| 744 | return port->set_frontend(fe); |
| 745 | |
Michael Krufky | 5bdd396 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 746 | return 0; |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 747 | } |
| 748 | |
Mauro Carvalho Chehab | 15472fa | 2013-08-09 08:53:25 -0300 | [diff] [blame] | 749 | static void cx23885_set_frontend_hook(struct cx23885_tsport *port, |
| 750 | struct dvb_frontend *fe) |
| 751 | { |
| 752 | port->set_frontend = fe->ops.set_frontend; |
| 753 | fe->ops.set_frontend = cx23885_dvb_set_frontend; |
| 754 | } |
| 755 | |
David Wong | 2365b2d | 2009-06-17 01:38:12 -0300 | [diff] [blame] | 756 | static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = { |
| 757 | .prod = LGS8GXX_PROD_LGS8G75, |
| 758 | .demod_address = 0x19, |
| 759 | .serial_ts = 0, |
| 760 | .ts_clk_pol = 1, |
| 761 | .ts_clk_gated = 1, |
| 762 | .if_clk_freq = 30400, /* 30.4 MHz */ |
| 763 | .if_freq = 6500, /* 6.50 MHz */ |
| 764 | .if_neg_center = 1, |
| 765 | .ext_adc = 0, |
| 766 | .adc_signed = 1, |
| 767 | .adc_vpp = 2, /* 1.6 Vpp */ |
| 768 | .if_neg_edge = 1, |
| 769 | }; |
| 770 | |
| 771 | static struct xc5000_config magicpro_prohdtve2_xc5000_config = { |
| 772 | .i2c_address = 0x61, |
| 773 | .if_khz = 6500, |
| 774 | }; |
| 775 | |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 776 | static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = { |
| 777 | .prod = ATBM8830_PROD_8830, |
| 778 | .demod_address = 0x44, |
| 779 | .serial_ts = 0, |
| 780 | .ts_sampling_edge = 1, |
| 781 | .ts_clk_gated = 0, |
| 782 | .osc_clk_freq = 30400, /* in kHz */ |
| 783 | .if_freq = 0, /* zero IF */ |
| 784 | .zif_swap_iq = 1, |
David Wong | c245c75 | 2009-11-28 08:36:31 -0300 | [diff] [blame] | 785 | .agc_min = 0x2E, |
| 786 | .agc_max = 0xFF, |
| 787 | .agc_hold_loop = 0, |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 788 | }; |
| 789 | |
| 790 | static struct max2165_config mygic_x8558pro_max2165_cfg1 = { |
| 791 | .i2c_address = 0x60, |
| 792 | .osc_clk = 20 |
| 793 | }; |
| 794 | |
| 795 | static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = { |
| 796 | .prod = ATBM8830_PROD_8830, |
| 797 | .demod_address = 0x44, |
| 798 | .serial_ts = 1, |
| 799 | .ts_sampling_edge = 1, |
| 800 | .ts_clk_gated = 0, |
| 801 | .osc_clk_freq = 30400, /* in kHz */ |
| 802 | .if_freq = 0, /* zero IF */ |
| 803 | .zif_swap_iq = 1, |
David Wong | c245c75 | 2009-11-28 08:36:31 -0300 | [diff] [blame] | 804 | .agc_min = 0x2E, |
| 805 | .agc_max = 0xFF, |
| 806 | .agc_hold_loop = 0, |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 807 | }; |
| 808 | |
| 809 | static struct max2165_config mygic_x8558pro_max2165_cfg2 = { |
| 810 | .i2c_address = 0x60, |
| 811 | .osc_clk = 20 |
| 812 | }; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 813 | static struct stv0367_config netup_stv0367_config[] = { |
| 814 | { |
| 815 | .demod_address = 0x1c, |
| 816 | .xtal = 27000000, |
| 817 | .if_khz = 4500, |
| 818 | .if_iq_mode = 0, |
| 819 | .ts_mode = 1, |
| 820 | .clk_pol = 0, |
| 821 | }, { |
| 822 | .demod_address = 0x1d, |
| 823 | .xtal = 27000000, |
| 824 | .if_khz = 4500, |
| 825 | .if_iq_mode = 0, |
| 826 | .ts_mode = 1, |
| 827 | .clk_pol = 0, |
| 828 | }, |
| 829 | }; |
| 830 | |
| 831 | static struct xc5000_config netup_xc5000_config[] = { |
| 832 | { |
| 833 | .i2c_address = 0x61, |
| 834 | .if_khz = 4500, |
| 835 | }, { |
| 836 | .i2c_address = 0x64, |
| 837 | .if_khz = 4500, |
| 838 | }, |
| 839 | }; |
| 840 | |
Stefan Ringel | 722c90e | 2012-01-07 09:20:48 -0300 | [diff] [blame] | 841 | static struct drxk_config terratec_drxk_config[] = { |
| 842 | { |
| 843 | .adr = 0x29, |
| 844 | .no_i2c_bridge = 1, |
| 845 | }, { |
| 846 | .adr = 0x2a, |
| 847 | .no_i2c_bridge = 1, |
| 848 | }, |
| 849 | }; |
| 850 | |
| 851 | static struct mt2063_config terratec_mt2063_config[] = { |
| 852 | { |
| 853 | .tuner_address = 0x60, |
| 854 | }, { |
| 855 | .tuner_address = 0x67, |
| 856 | }, |
| 857 | }; |
| 858 | |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 859 | static const struct tda10071_config hauppauge_tda10071_config = { |
Michael Krufky | 41f55d5 | 2012-12-16 19:37:11 -0300 | [diff] [blame] | 860 | .demod_i2c_addr = 0x05, |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 861 | .tuner_i2c_addr = 0x54, |
| 862 | .i2c_wr_max = 64, |
| 863 | .ts_mode = TDA10071_TS_SERIAL, |
| 864 | .spec_inv = 0, |
| 865 | .xtal = 40444000, /* 40.444 MHz */ |
| 866 | .pll_multiplier = 20, |
| 867 | }; |
| 868 | |
| 869 | static const struct a8293_config hauppauge_a8293_config = { |
| 870 | .i2c_addr = 0x0b, |
| 871 | }; |
| 872 | |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 873 | static const struct si2165_config hauppauge_hvr4400_si2165_config = { |
| 874 | .i2c_addr = 0x64, |
| 875 | .chip_mode = SI2165_MODE_PLL_XTAL, |
| 876 | .ref_freq_Hz = 16000000, |
| 877 | }; |
| 878 | |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 879 | static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = { |
| 880 | .i2c_addr = 0x68, |
| 881 | .clock = 27000000, |
| 882 | .i2c_wr_max = 33, |
| 883 | .clock_out = 0, |
| 884 | .ts_mode = M88DS3103_TS_PARALLEL, |
| 885 | .ts_clk = 16000, |
| 886 | .ts_clk_pol = 1, |
| 887 | .lnb_en_pol = 1, |
| 888 | .lnb_hv_pol = 0, |
| 889 | .agc = 0x99, |
| 890 | }; |
| 891 | |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 892 | static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = { |
| 893 | .i2c_addr = 0x68, |
| 894 | .clock = 27000000, |
| 895 | .i2c_wr_max = 33, |
| 896 | .clock_out = 0, |
| 897 | .ts_mode = M88DS3103_TS_CI, |
| 898 | .ts_clk = 10000, |
| 899 | .ts_clk_pol = 1, |
| 900 | .lnb_en_pol = 1, |
| 901 | .lnb_hv_pol = 0, |
| 902 | .agc = 0x99, |
| 903 | }; |
| 904 | |
nibble.max | c29d6a8 | 2014-11-05 11:58:38 -0300 | [diff] [blame] | 905 | static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = { |
| 906 | .i2c_addr = 0x68, |
| 907 | .clock = 27000000, |
| 908 | .i2c_wr_max = 33, |
| 909 | .clock_out = 0, |
| 910 | .ts_mode = M88DS3103_TS_SERIAL, |
| 911 | .ts_clk = 96000, |
| 912 | .ts_clk_pol = 0, |
| 913 | .lnb_en_pol = 1, |
| 914 | .lnb_hv_pol = 0, |
| 915 | .agc = 0x99, |
| 916 | }; |
| 917 | |
Mauro Carvalho Chehab | ada73ee | 2012-10-27 11:29:23 -0300 | [diff] [blame] | 918 | static int netup_altera_fpga_rw(void *device, int flag, int data, int read) |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 919 | { |
| 920 | struct cx23885_dev *dev = (struct cx23885_dev *)device; |
| 921 | unsigned long timeout = jiffies + msecs_to_jiffies(1); |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 922 | uint32_t mem = 0; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 923 | |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 924 | mem = cx_read(MC417_RWD); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 925 | if (read) |
| 926 | cx_set(MC417_OEN, ALT_DATA); |
| 927 | else { |
| 928 | cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */ |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 929 | mem &= ~ALT_DATA; |
| 930 | mem |= (data & ALT_DATA); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | if (flag) |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 934 | mem |= ALT_AD_RG; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 935 | else |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 936 | mem &= ~ALT_AD_RG; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 937 | |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 938 | mem &= ~ALT_CS; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 939 | if (read) |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 940 | mem = (mem & ~ALT_RD) | ALT_WR; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 941 | else |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame] | 942 | mem = (mem & ~ALT_WR) | ALT_RD; |
| 943 | |
| 944 | cx_write(MC417_RWD, mem); /* start RW cycle */ |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 945 | |
| 946 | for (;;) { |
| 947 | mem = cx_read(MC417_RWD); |
| 948 | if ((mem & ALT_RDY) == 0) |
| 949 | break; |
| 950 | if (time_after(jiffies, timeout)) |
| 951 | break; |
| 952 | udelay(1); |
| 953 | } |
| 954 | |
| 955 | cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS); |
| 956 | if (read) |
| 957 | return mem & ALT_DATA; |
| 958 | |
| 959 | return 0; |
| 960 | }; |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 961 | |
James Harper | 46b21bb | 2014-06-12 07:12:24 -0300 | [diff] [blame] | 962 | static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) |
| 963 | { |
| 964 | struct dib7000p_ops *dib7000p_ops = fe->sec_priv; |
| 965 | |
| 966 | return dib7000p_ops->set_gpio(fe, 8, 0, !onoff); |
| 967 | } |
| 968 | |
| 969 | static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) |
| 970 | { |
| 971 | return 0; |
| 972 | } |
| 973 | |
| 974 | static struct dib0070_config dib7070p_dib0070_config = { |
| 975 | .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, |
| 976 | .reset = dib7070_tuner_reset, |
| 977 | .sleep = dib7070_tuner_sleep, |
| 978 | .clock_khz = 12000, |
James Harper | 46b21bb | 2014-06-12 07:12:24 -0300 | [diff] [blame] | 979 | .freq_offset_khz_vhf = 550, |
| 980 | /* .flip_chip = 1, */ |
| 981 | }; |
| 982 | |
| 983 | /* DIB7070 generic */ |
| 984 | static struct dibx000_agc_config dib7070_agc_config = { |
| 985 | .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, |
| 986 | |
| 987 | /* |
| 988 | * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, |
| 989 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, |
| 990 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 |
| 991 | */ |
| 992 | .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | |
| 993 | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), |
| 994 | .inv_gain = 600, |
| 995 | .time_stabiliz = 10, |
| 996 | .alpha_level = 0, |
| 997 | .thlock = 118, |
| 998 | .wbd_inv = 0, |
| 999 | .wbd_ref = 3530, |
| 1000 | .wbd_sel = 1, |
| 1001 | .wbd_alpha = 5, |
| 1002 | .agc1_max = 65535, |
| 1003 | .agc1_min = 0, |
| 1004 | .agc2_max = 65535, |
| 1005 | .agc2_min = 0, |
| 1006 | .agc1_pt1 = 0, |
| 1007 | .agc1_pt2 = 40, |
| 1008 | .agc1_pt3 = 183, |
| 1009 | .agc1_slope1 = 206, |
| 1010 | .agc1_slope2 = 255, |
| 1011 | .agc2_pt1 = 72, |
| 1012 | .agc2_pt2 = 152, |
| 1013 | .agc2_slope1 = 88, |
| 1014 | .agc2_slope2 = 90, |
| 1015 | .alpha_mant = 17, |
| 1016 | .alpha_exp = 27, |
| 1017 | .beta_mant = 23, |
| 1018 | .beta_exp = 51, |
| 1019 | .perform_agc_softsplit = 0, |
| 1020 | }; |
| 1021 | |
| 1022 | static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = { |
| 1023 | .internal = 60000, |
| 1024 | .sampling = 15000, |
| 1025 | .pll_prediv = 1, |
| 1026 | .pll_ratio = 20, |
| 1027 | .pll_range = 3, |
| 1028 | .pll_reset = 1, |
| 1029 | .pll_bypass = 0, |
| 1030 | .enable_refdiv = 0, |
| 1031 | .bypclk_div = 0, |
| 1032 | .IO_CLK_en_core = 1, |
| 1033 | .ADClkSrc = 1, |
| 1034 | .modulo = 2, |
| 1035 | /* refsel, sel, freq_15k */ |
| 1036 | .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), |
| 1037 | .ifreq = (0 << 25) | 0, |
| 1038 | .timf = 20452225, |
| 1039 | .xtal_hz = 12000000, |
| 1040 | }; |
| 1041 | |
| 1042 | static struct dib7000p_config dib7070p_dib7000p_config = { |
| 1043 | /* .output_mode = OUTMODE_MPEG2_FIFO, */ |
| 1044 | .output_mode = OUTMODE_MPEG2_SERIAL, |
| 1045 | /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */ |
| 1046 | .output_mpeg2_in_188_bytes = 1, |
| 1047 | |
| 1048 | .agc_config_count = 1, |
| 1049 | .agc = &dib7070_agc_config, |
| 1050 | .bw = &dib7070_bw_config_12_mhz, |
| 1051 | .tuner_is_baseband = 1, |
| 1052 | .spur_protect = 1, |
| 1053 | |
| 1054 | .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */ |
| 1055 | .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */ |
| 1056 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, |
| 1057 | |
| 1058 | .hostbus_diversity = 1, |
| 1059 | }; |
| 1060 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1061 | static int dvb_register(struct cx23885_tsport *port) |
| 1062 | { |
Mauro Carvalho Chehab | 8abe4a0 | 2014-05-29 09:20:15 -0300 | [diff] [blame] | 1063 | struct dib7000p_ops dib7000p_ops; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1064 | struct cx23885_dev *dev = port->dev; |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 1065 | struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL; |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 1066 | struct vb2_dvb_frontend *fe0, *fe1 = NULL; |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1067 | struct si2168_config si2168_config; |
| 1068 | struct si2157_config si2157_config; |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 1069 | struct sp2_config sp2_config; |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1070 | struct m88ts2022_config m88ts2022_config; |
| 1071 | struct i2c_board_info info; |
| 1072 | struct i2c_adapter *adapter; |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 1073 | struct i2c_client *client_demod = NULL, *client_tuner = NULL, *client_ci = NULL; |
nibble.max | c29d6a8 | 2014-11-05 11:58:38 -0300 | [diff] [blame] | 1074 | const struct m88ds3103_config *p_m88ds3103_config = NULL; |
| 1075 | int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage) = NULL; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1076 | int mfe_shared = 0; /* bus not shared by default */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1077 | int ret; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1078 | |
Darron Broad | f972e0bd | 2008-10-11 11:24:30 -0300 | [diff] [blame] | 1079 | /* Get the first frontend */ |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 1080 | fe0 = vb2_dvb_get_frontend(&port->frontends, 1); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1081 | if (!fe0) |
| 1082 | return -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1083 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 1084 | /* init struct vb2_dvb */ |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1085 | fe0->dvb.name = dev->name; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1086 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1087 | /* multi-frontend gate control is undefined or defaults to fe0 */ |
| 1088 | port->frontends.gate = 0; |
| 1089 | |
| 1090 | /* Sets the gate control callback to be used by i2c command calls */ |
| 1091 | port->gate_ctrl = cx23885_dvb_gate_ctrl; |
| 1092 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1093 | /* init frontend */ |
| 1094 | switch (dev->board) { |
Steven Toth | a77743b | 2007-08-22 21:01:20 -0300 | [diff] [blame] | 1095 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1096 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1097 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 1098 | &hauppauge_generic_config, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1099 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1100 | if (fe0->dvb.frontend == NULL) |
| 1101 | break; |
| 1102 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
| 1103 | &i2c_bus->i2c_adap, |
| 1104 | &hauppauge_generic_tunerconfig, 0); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1105 | break; |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 1106 | case CX23885_BOARD_HAUPPAUGE_HVR1270: |
Michael Krufky | d099bec | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 1107 | case CX23885_BOARD_HAUPPAUGE_HVR1275: |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 1108 | i2c_bus = &dev->i2c_bus[0]; |
| 1109 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 1110 | &hauppauge_lgdt3305_config, |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 1111 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1112 | if (fe0->dvb.frontend == NULL) |
| 1113 | break; |
| 1114 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1115 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1116 | &hauppauge_hvr127x_config); |
Mauro Carvalho Chehab | 15472fa | 2013-08-09 08:53:25 -0300 | [diff] [blame] | 1117 | if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) |
| 1118 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 1119 | break; |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 1120 | case CX23885_BOARD_HAUPPAUGE_HVR1255: |
Devin Heitmueller | 0ac60ac | 2012-07-01 16:15:14 -0300 | [diff] [blame] | 1121 | case CX23885_BOARD_HAUPPAUGE_HVR1255_22111: |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 1122 | i2c_bus = &dev->i2c_bus[0]; |
| 1123 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
| 1124 | &hcw_s5h1411_config, |
| 1125 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1126 | if (fe0->dvb.frontend == NULL) |
| 1127 | break; |
| 1128 | |
| 1129 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1130 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1131 | &hauppauge_tda18271_config); |
Devin Heitmueller | 0ac60ac | 2012-07-01 16:15:14 -0300 | [diff] [blame] | 1132 | |
| 1133 | tda18271_attach(&dev->ts1.analog_fe, |
| 1134 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1135 | &hauppauge_tda18271_config); |
| 1136 | |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 1137 | break; |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1138 | case CX23885_BOARD_HAUPPAUGE_HVR1800: |
| 1139 | i2c_bus = &dev->i2c_bus[0]; |
Darron Broad | 92abe9e | 2008-10-11 11:18:53 -0300 | [diff] [blame] | 1140 | switch (alt_tuner) { |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1141 | case 1: |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1142 | fe0->dvb.frontend = |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1143 | dvb_attach(s5h1409_attach, |
| 1144 | &hauppauge_ezqam_config, |
| 1145 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1146 | if (fe0->dvb.frontend == NULL) |
| 1147 | break; |
| 1148 | |
| 1149 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
| 1150 | &dev->i2c_bus[1].i2c_adap, 0x42, |
| 1151 | &tda829x_no_probe); |
| 1152 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1153 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1154 | &hauppauge_tda18271_config); |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1155 | break; |
| 1156 | case 0: |
| 1157 | default: |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1158 | fe0->dvb.frontend = |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1159 | dvb_attach(s5h1409_attach, |
| 1160 | &hauppauge_generic_config, |
| 1161 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1162 | if (fe0->dvb.frontend == NULL) |
| 1163 | break; |
| 1164 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
| 1165 | &i2c_bus->i2c_adap, |
| 1166 | &hauppauge_generic_tunerconfig, 0); |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1167 | } |
| 1168 | break; |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 1169 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1170 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1171 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 1172 | &hauppauge_hvr1800lp_config, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1173 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1174 | if (fe0->dvb.frontend == NULL) |
| 1175 | break; |
| 1176 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
| 1177 | &i2c_bus->i2c_adap, |
| 1178 | &hauppauge_generic_tunerconfig, 0); |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 1179 | break; |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 1180 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1181 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1182 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 1183 | &fusionhdtv_5_express, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 1184 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1185 | if (fe0->dvb.frontend == NULL) |
| 1186 | break; |
| 1187 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
| 1188 | &i2c_bus->i2c_adap, 0x61, |
| 1189 | TUNER_LG_TDVS_H06XF); |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 1190 | break; |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 1191 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| 1192 | i2c_bus = &dev->i2c_bus[1]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1193 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 1194 | &hauppauge_hvr1500q_config, |
| 1195 | &dev->i2c_bus[0].i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1196 | if (fe0->dvb.frontend == NULL) |
| 1197 | break; |
| 1198 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
| 1199 | &i2c_bus->i2c_adap, |
| 1200 | &hauppauge_hvr1500q_tunerconfig); |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 1201 | break; |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1202 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
| 1203 | i2c_bus = &dev->i2c_bus[1]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1204 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1205 | &hauppauge_hvr1500_config, |
| 1206 | &dev->i2c_bus[0].i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1207 | if (fe0->dvb.frontend != NULL) { |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1208 | struct dvb_frontend *fe; |
| 1209 | struct xc2028_config cfg = { |
| 1210 | .i2c_adap = &i2c_bus->i2c_adap, |
| 1211 | .i2c_addr = 0x61, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1212 | }; |
| 1213 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 1214 | .fname = XC2028_DEFAULT_FIRMWARE, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1215 | .max_len = 64, |
Steven Toth | 52c3d29 | 2009-04-20 22:42:00 -0300 | [diff] [blame] | 1216 | .demod = XC3028_FE_OREN538, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1217 | }; |
| 1218 | |
| 1219 | fe = dvb_attach(xc2028_attach, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1220 | fe0->dvb.frontend, &cfg); |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 1221 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 1222 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 1223 | } |
| 1224 | break; |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 1225 | case CX23885_BOARD_HAUPPAUGE_HVR1200: |
Steven Toth | a780a31 | 2008-04-19 01:25:52 -0300 | [diff] [blame] | 1226 | case CX23885_BOARD_HAUPPAUGE_HVR1700: |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 1227 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1228 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 1229 | &hauppauge_hvr1200_config, |
| 1230 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1231 | if (fe0->dvb.frontend == NULL) |
| 1232 | break; |
| 1233 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
| 1234 | &dev->i2c_bus[1].i2c_adap, 0x42, |
| 1235 | &tda829x_no_probe); |
| 1236 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1237 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1238 | &hauppauge_hvr1200_tuner_config); |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 1239 | break; |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 1240 | case CX23885_BOARD_HAUPPAUGE_HVR1210: |
| 1241 | i2c_bus = &dev->i2c_bus[0]; |
| 1242 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
| 1243 | &hauppauge_hvr1210_config, |
| 1244 | &i2c_bus->i2c_adap); |
| 1245 | if (fe0->dvb.frontend != NULL) { |
| 1246 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1247 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1248 | &hauppauge_hvr1210_tuner_config); |
| 1249 | } |
| 1250 | break; |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1251 | case CX23885_BOARD_HAUPPAUGE_HVR1400: |
| 1252 | i2c_bus = &dev->i2c_bus[0]; |
Mauro Carvalho Chehab | 8abe4a0 | 2014-05-29 09:20:15 -0300 | [diff] [blame] | 1253 | |
| 1254 | if (!dvb_attach(dib7000p_attach, &dib7000p_ops)) |
| 1255 | return -ENODEV; |
| 1256 | |
| 1257 | fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1258 | 0x12, &hauppauge_hvr1400_dib7000_config); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1259 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1260 | struct dvb_frontend *fe; |
| 1261 | struct xc2028_config cfg = { |
| 1262 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
| 1263 | .i2c_addr = 0x64, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1264 | }; |
| 1265 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 1266 | .fname = XC3028L_DEFAULT_FIRMWARE, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1267 | .max_len = 64, |
Mauro Carvalho Chehab | 9bed77e | 2011-07-28 16:38:54 -0300 | [diff] [blame] | 1268 | .demod = XC3028_FE_DIBCOM52, |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1269 | /* This is true for all demods with |
| 1270 | v36 firmware? */ |
Mauro Carvalho Chehab | 0975fc6 | 2008-09-28 02:24:44 -0300 | [diff] [blame] | 1271 | .type = XC2028_D2633, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1272 | }; |
| 1273 | |
| 1274 | fe = dvb_attach(xc2028_attach, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1275 | fe0->dvb.frontend, &cfg); |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 1276 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 1277 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 1278 | } |
| 1279 | break; |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 1280 | case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: |
| 1281 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
| 1282 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1283 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 1284 | &dvico_s5h1409_config, |
| 1285 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1286 | if (fe0->dvb.frontend == NULL) |
| 1287 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 1288 | &dvico_s5h1411_config, |
| 1289 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1290 | if (fe0->dvb.frontend != NULL) |
| 1291 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
Michael Krufky | 3065096 | 2008-09-06 14:56:58 -0300 | [diff] [blame] | 1292 | &i2c_bus->i2c_adap, |
| 1293 | &dvico_xc5000_tunerconfig); |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 1294 | break; |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1295 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { |
| 1296 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
| 1297 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1298 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1299 | &dvico_fusionhdtv_xc3028, |
| 1300 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1301 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1302 | struct dvb_frontend *fe; |
| 1303 | struct xc2028_config cfg = { |
| 1304 | .i2c_adap = &i2c_bus->i2c_adap, |
| 1305 | .i2c_addr = 0x61, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1306 | }; |
| 1307 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 1308 | .fname = XC2028_DEFAULT_FIRMWARE, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1309 | .max_len = 64, |
| 1310 | .demod = XC3028_FE_ZARLINK456, |
| 1311 | }; |
| 1312 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1313 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 1314 | &cfg); |
| 1315 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 1316 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 1317 | } |
| 1318 | break; |
| 1319 | } |
James Harper | 46b21bb | 2014-06-12 07:12:24 -0300 | [diff] [blame] | 1320 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: { |
| 1321 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
| 1322 | /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */ |
| 1323 | /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */ |
| 1324 | |
| 1325 | if (!dvb_attach(dib7000p_attach, &dib7000p_ops)) |
| 1326 | return -ENODEV; |
| 1327 | |
| 1328 | if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) { |
| 1329 | printk(KERN_WARNING "Unable to enumerate dib7000p\n"); |
| 1330 | return -ENODEV; |
| 1331 | } |
| 1332 | fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config); |
| 1333 | if (fe0->dvb.frontend != NULL) { |
| 1334 | struct i2c_adapter *tun_i2c; |
| 1335 | |
| 1336 | fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL); |
| 1337 | memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops)); |
| 1338 | tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1); |
| 1339 | if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config)) |
| 1340 | return -ENODEV; |
| 1341 | } |
| 1342 | break; |
| 1343 | } |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1344 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: |
Igor M. Liplianin | 9bb1b7e | 2008-11-23 14:11:16 -0300 | [diff] [blame] | 1345 | case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: |
Vladimir Geroy | 34e383d | 2009-09-18 18:55:47 -0300 | [diff] [blame] | 1346 | case CX23885_BOARD_COMPRO_VIDEOMATE_E800: |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1347 | i2c_bus = &dev->i2c_bus[0]; |
| 1348 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1349 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1350 | &dvico_fusionhdtv_xc3028, |
| 1351 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1352 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1353 | struct dvb_frontend *fe; |
| 1354 | struct xc2028_config cfg = { |
| 1355 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
| 1356 | .i2c_addr = 0x61, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1357 | }; |
| 1358 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 1359 | .fname = XC2028_DEFAULT_FIRMWARE, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1360 | .max_len = 64, |
| 1361 | .demod = XC3028_FE_ZARLINK456, |
| 1362 | }; |
| 1363 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1364 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 1365 | &cfg); |
| 1366 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 1367 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 1368 | } |
| 1369 | break; |
istvan_v@mailbox.hu | 0cf8af5 | 2011-07-11 10:58:35 -0300 | [diff] [blame] | 1370 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000: |
| 1371 | i2c_bus = &dev->i2c_bus[0]; |
| 1372 | |
| 1373 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
| 1374 | &dvico_fusionhdtv_xc3028, |
| 1375 | &i2c_bus->i2c_adap); |
| 1376 | if (fe0->dvb.frontend != NULL) { |
| 1377 | struct dvb_frontend *fe; |
| 1378 | struct xc4000_config cfg = { |
| 1379 | .i2c_address = 0x61, |
| 1380 | .default_pm = 0, |
| 1381 | .dvb_amplitude = 134, |
| 1382 | .set_smoothedcvbs = 1, |
| 1383 | .if_khz = 4560 |
| 1384 | }; |
| 1385 | |
| 1386 | fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, |
| 1387 | &dev->i2c_bus[1].i2c_adap, &cfg); |
Miroslav Slugen | a7c8aad | 2011-12-11 18:57:58 -0300 | [diff] [blame] | 1388 | if (!fe) { |
| 1389 | printk(KERN_ERR "%s/2: xc4000 attach failed\n", |
| 1390 | dev->name); |
| 1391 | goto frontend_detach; |
| 1392 | } |
istvan_v@mailbox.hu | 0cf8af5 | 2011-07-11 10:58:35 -0300 | [diff] [blame] | 1393 | } |
| 1394 | break; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 1395 | case CX23885_BOARD_TBS_6920: |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 1396 | i2c_bus = &dev->i2c_bus[1]; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 1397 | |
| 1398 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 1399 | &tbs_cx24116_config, |
| 1400 | &i2c_bus->i2c_adap); |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 1401 | if (fe0->dvb.frontend != NULL) |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 1402 | fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 1403 | |
| 1404 | break; |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 1405 | case CX23885_BOARD_TBS_6980: |
| 1406 | case CX23885_BOARD_TBS_6981: |
| 1407 | i2c_bus = &dev->i2c_bus[1]; |
| 1408 | |
| 1409 | switch (port->nr) { |
| 1410 | /* PORT B */ |
| 1411 | case 1: |
| 1412 | fe0->dvb.frontend = dvb_attach(cx24117_attach, |
| 1413 | &tbs_cx24117_config, |
Luis Alves | d10e828 | 2013-10-03 08:33:47 -0300 | [diff] [blame] | 1414 | &i2c_bus->i2c_adap); |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 1415 | break; |
| 1416 | /* PORT C */ |
| 1417 | case 2: |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 1418 | fe0->dvb.frontend = dvb_attach(cx24117_attach, |
| 1419 | &tbs_cx24117_config, |
Luis Alves | d10e828 | 2013-10-03 08:33:47 -0300 | [diff] [blame] | 1420 | &i2c_bus->i2c_adap); |
Luis Alves | e600148 | 2013-10-01 22:11:35 -0300 | [diff] [blame] | 1421 | break; |
| 1422 | } |
| 1423 | break; |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 1424 | case CX23885_BOARD_TEVII_S470: |
| 1425 | i2c_bus = &dev->i2c_bus[1]; |
| 1426 | |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 1427 | fe0->dvb.frontend = dvb_attach(ds3000_attach, |
| 1428 | &tevii_ds3000_config, |
| 1429 | &i2c_bus->i2c_adap); |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1430 | if (fe0->dvb.frontend != NULL) { |
| 1431 | dvb_attach(ts2020_attach, fe0->dvb.frontend, |
| 1432 | &tevii_ts2020_config, &i2c_bus->i2c_adap); |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 1433 | fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1434 | } |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 1435 | |
| 1436 | break; |
Igor M. Liplianin | c9b8b04 | 2009-01-17 12:23:31 -0300 | [diff] [blame] | 1437 | case CX23885_BOARD_DVBWORLD_2005: |
| 1438 | i2c_bus = &dev->i2c_bus[1]; |
| 1439 | |
| 1440 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
| 1441 | &dvbworld_cx24116_config, |
| 1442 | &i2c_bus->i2c_adap); |
| 1443 | break; |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1444 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: |
| 1445 | i2c_bus = &dev->i2c_bus[0]; |
| 1446 | switch (port->nr) { |
| 1447 | /* port B */ |
| 1448 | case 1: |
| 1449 | fe0->dvb.frontend = dvb_attach(stv0900_attach, |
| 1450 | &netup_stv0900_config, |
| 1451 | &i2c_bus->i2c_adap, 0); |
| 1452 | if (fe0->dvb.frontend != NULL) { |
| 1453 | if (dvb_attach(stv6110_attach, |
| 1454 | fe0->dvb.frontend, |
| 1455 | &netup_stv6110_tunerconfig_a, |
| 1456 | &i2c_bus->i2c_adap)) { |
| 1457 | if (!dvb_attach(lnbh24_attach, |
| 1458 | fe0->dvb.frontend, |
| 1459 | &i2c_bus->i2c_adap, |
Abylay Ospan | 9329fb5 | 2009-10-17 08:38:45 -0300 | [diff] [blame] | 1460 | LNBH24_PCL | LNBH24_TTX, |
| 1461 | LNBH24_TEN, 0x09)) |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1462 | printk(KERN_ERR |
| 1463 | "No LNBH24 found!\n"); |
| 1464 | |
| 1465 | } |
| 1466 | } |
| 1467 | break; |
| 1468 | /* port C */ |
| 1469 | case 2: |
| 1470 | fe0->dvb.frontend = dvb_attach(stv0900_attach, |
| 1471 | &netup_stv0900_config, |
| 1472 | &i2c_bus->i2c_adap, 1); |
| 1473 | if (fe0->dvb.frontend != NULL) { |
| 1474 | if (dvb_attach(stv6110_attach, |
| 1475 | fe0->dvb.frontend, |
| 1476 | &netup_stv6110_tunerconfig_b, |
| 1477 | &i2c_bus->i2c_adap)) { |
| 1478 | if (!dvb_attach(lnbh24_attach, |
| 1479 | fe0->dvb.frontend, |
| 1480 | &i2c_bus->i2c_adap, |
Abylay Ospan | 9329fb5 | 2009-10-17 08:38:45 -0300 | [diff] [blame] | 1481 | LNBH24_PCL | LNBH24_TTX, |
| 1482 | LNBH24_TEN, 0x0a)) |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1483 | printk(KERN_ERR |
| 1484 | "No LNBH24 found!\n"); |
| 1485 | |
| 1486 | } |
| 1487 | } |
| 1488 | break; |
| 1489 | } |
| 1490 | break; |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 1491 | case CX23885_BOARD_MYGICA_X8506: |
| 1492 | i2c_bus = &dev->i2c_bus[0]; |
| 1493 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1494 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
| 1495 | &mygica_x8506_lgs8gl5_config, |
| 1496 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1497 | if (fe0->dvb.frontend == NULL) |
| 1498 | break; |
| 1499 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
| 1500 | &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config); |
Mauro Carvalho Chehab | 15472fa | 2013-08-09 08:53:25 -0300 | [diff] [blame] | 1501 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 1502 | break; |
Mauro Carvalho Chehab | 0d1b526 | 2013-08-09 08:53:27 -0300 | [diff] [blame] | 1503 | case CX23885_BOARD_MYGICA_X8507: |
| 1504 | i2c_bus = &dev->i2c_bus[0]; |
| 1505 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1506 | fe0->dvb.frontend = dvb_attach(mb86a20s_attach, |
| 1507 | &mygica_x8507_mb86a20s_config, |
| 1508 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1509 | if (fe0->dvb.frontend == NULL) |
| 1510 | break; |
| 1511 | |
| 1512 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
| 1513 | &i2c_bus2->i2c_adap, |
| 1514 | &mygica_x8507_xc5000_config); |
Mauro Carvalho Chehab | 0d1b526 | 2013-08-09 08:53:27 -0300 | [diff] [blame] | 1515 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
| 1516 | break; |
David Wong | 2365b2d | 2009-06-17 01:38:12 -0300 | [diff] [blame] | 1517 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: |
| 1518 | i2c_bus = &dev->i2c_bus[0]; |
| 1519 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1520 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
| 1521 | &magicpro_prohdtve2_lgs8g75_config, |
| 1522 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1523 | if (fe0->dvb.frontend == NULL) |
| 1524 | break; |
| 1525 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
| 1526 | &i2c_bus2->i2c_adap, |
| 1527 | &magicpro_prohdtve2_xc5000_config); |
Mauro Carvalho Chehab | 15472fa | 2013-08-09 08:53:25 -0300 | [diff] [blame] | 1528 | cx23885_set_frontend_hook(port, fe0->dvb.frontend); |
David Wong | 2365b2d | 2009-06-17 01:38:12 -0300 | [diff] [blame] | 1529 | break; |
Steven Toth | 13697380 | 2009-07-20 15:37:25 -0300 | [diff] [blame] | 1530 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
Steven Toth | 3504513 | 2012-01-04 21:08:35 -0300 | [diff] [blame] | 1531 | i2c_bus = &dev->i2c_bus[0]; |
| 1532 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
| 1533 | &hcw_s5h1411_config, |
| 1534 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1535 | if (fe0->dvb.frontend == NULL) |
| 1536 | break; |
| 1537 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1538 | 0x60, &dev->i2c_bus[0].i2c_adap, |
| 1539 | &hauppauge_tda18271_config); |
Steven Toth | 3504513 | 2012-01-04 21:08:35 -0300 | [diff] [blame] | 1540 | |
| 1541 | tda18271_attach(&dev->ts1.analog_fe, |
| 1542 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 1543 | &hauppauge_tda18271_config); |
| 1544 | |
| 1545 | break; |
Michael Krufky | aee0b24 | 2009-11-11 01:52:45 -0300 | [diff] [blame] | 1546 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
Steven Toth | 13697380 | 2009-07-20 15:37:25 -0300 | [diff] [blame] | 1547 | i2c_bus = &dev->i2c_bus[0]; |
| 1548 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
| 1549 | &hcw_s5h1411_config, |
| 1550 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1551 | if (fe0->dvb.frontend == NULL) |
| 1552 | break; |
| 1553 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1554 | 0x60, &dev->i2c_bus[0].i2c_adap, |
| 1555 | &hauppauge_tda18271_config); |
Steven Toth | 13697380 | 2009-07-20 15:37:25 -0300 | [diff] [blame] | 1556 | break; |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 1557 | case CX23885_BOARD_MYGICA_X8558PRO: |
| 1558 | switch (port->nr) { |
| 1559 | /* port B */ |
| 1560 | case 1: |
| 1561 | i2c_bus = &dev->i2c_bus[0]; |
| 1562 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
| 1563 | &mygica_x8558pro_atbm8830_cfg1, |
| 1564 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1565 | if (fe0->dvb.frontend == NULL) |
| 1566 | break; |
| 1567 | dvb_attach(max2165_attach, fe0->dvb.frontend, |
| 1568 | &i2c_bus->i2c_adap, |
| 1569 | &mygic_x8558pro_max2165_cfg1); |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 1570 | break; |
| 1571 | /* port C */ |
| 1572 | case 2: |
| 1573 | i2c_bus = &dev->i2c_bus[1]; |
| 1574 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
| 1575 | &mygica_x8558pro_atbm8830_cfg2, |
| 1576 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1577 | if (fe0->dvb.frontend == NULL) |
| 1578 | break; |
| 1579 | dvb_attach(max2165_attach, fe0->dvb.frontend, |
| 1580 | &i2c_bus->i2c_adap, |
| 1581 | &mygic_x8558pro_max2165_cfg2); |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 1582 | } |
| 1583 | break; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1584 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: |
| 1585 | i2c_bus = &dev->i2c_bus[0]; |
| 1586 | mfe_shared = 1;/* MFE */ |
| 1587 | port->frontends.gate = 0;/* not clear for me yet */ |
| 1588 | /* ports B, C */ |
| 1589 | /* MFE frontend 1 DVB-T */ |
| 1590 | fe0->dvb.frontend = dvb_attach(stv0367ter_attach, |
| 1591 | &netup_stv0367_config[port->nr - 1], |
| 1592 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1593 | if (fe0->dvb.frontend == NULL) |
| 1594 | break; |
| 1595 | if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend, |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1596 | &i2c_bus->i2c_adap, |
| 1597 | &netup_xc5000_config[port->nr - 1])) |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1598 | goto frontend_detach; |
| 1599 | /* load xc5000 firmware */ |
| 1600 | fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); |
| 1601 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1602 | /* MFE frontend 2 */ |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 1603 | fe1 = vb2_dvb_get_frontend(&port->frontends, 2); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1604 | if (fe1 == NULL) |
| 1605 | goto frontend_detach; |
| 1606 | /* DVB-C init */ |
| 1607 | fe1->dvb.frontend = dvb_attach(stv0367cab_attach, |
| 1608 | &netup_stv0367_config[port->nr - 1], |
| 1609 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1610 | if (fe1->dvb.frontend == NULL) |
| 1611 | break; |
| 1612 | |
| 1613 | fe1->dvb.frontend->id = 1; |
| 1614 | if (NULL == dvb_attach(xc5000_attach, |
| 1615 | fe1->dvb.frontend, |
| 1616 | &i2c_bus->i2c_adap, |
| 1617 | &netup_xc5000_config[port->nr - 1])) |
| 1618 | goto frontend_detach; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1619 | break; |
Stefan Ringel | 722c90e | 2012-01-07 09:20:48 -0300 | [diff] [blame] | 1620 | case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: |
| 1621 | i2c_bus = &dev->i2c_bus[0]; |
| 1622 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1623 | |
| 1624 | switch (port->nr) { |
| 1625 | /* port b */ |
| 1626 | case 1: |
| 1627 | fe0->dvb.frontend = dvb_attach(drxk_attach, |
| 1628 | &terratec_drxk_config[0], |
| 1629 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1630 | if (fe0->dvb.frontend == NULL) |
| 1631 | break; |
| 1632 | if (!dvb_attach(mt2063_attach, |
| 1633 | fe0->dvb.frontend, |
| 1634 | &terratec_mt2063_config[0], |
| 1635 | &i2c_bus2->i2c_adap)) |
| 1636 | goto frontend_detach; |
Stefan Ringel | 722c90e | 2012-01-07 09:20:48 -0300 | [diff] [blame] | 1637 | break; |
| 1638 | /* port c */ |
| 1639 | case 2: |
| 1640 | fe0->dvb.frontend = dvb_attach(drxk_attach, |
| 1641 | &terratec_drxk_config[1], |
| 1642 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1643 | if (fe0->dvb.frontend == NULL) |
| 1644 | break; |
| 1645 | if (!dvb_attach(mt2063_attach, |
| 1646 | fe0->dvb.frontend, |
| 1647 | &terratec_mt2063_config[1], |
| 1648 | &i2c_bus2->i2c_adap)) |
| 1649 | goto frontend_detach; |
Stefan Ringel | 722c90e | 2012-01-07 09:20:48 -0300 | [diff] [blame] | 1650 | break; |
| 1651 | } |
| 1652 | break; |
Igor M. Liplianin | 7b134e8 | 2012-05-11 11:45:42 -0300 | [diff] [blame] | 1653 | case CX23885_BOARD_TEVII_S471: |
| 1654 | i2c_bus = &dev->i2c_bus[1]; |
| 1655 | |
| 1656 | fe0->dvb.frontend = dvb_attach(ds3000_attach, |
| 1657 | &tevii_ds3000_config, |
| 1658 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1659 | if (fe0->dvb.frontend == NULL) |
| 1660 | break; |
| 1661 | dvb_attach(ts2020_attach, fe0->dvb.frontend, |
| 1662 | &tevii_ts2020_config, &i2c_bus->i2c_adap); |
Igor M. Liplianin | 7b134e8 | 2012-05-11 11:45:42 -0300 | [diff] [blame] | 1663 | break; |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 1664 | case CX23885_BOARD_PROF_8000: |
| 1665 | i2c_bus = &dev->i2c_bus[0]; |
| 1666 | |
| 1667 | fe0->dvb.frontend = dvb_attach(stv090x_attach, |
| 1668 | &prof_8000_stv090x_config, |
| 1669 | &i2c_bus->i2c_adap, |
| 1670 | STV090x_DEMODULATOR_0); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1671 | if (fe0->dvb.frontend == NULL) |
| 1672 | break; |
| 1673 | if (!dvb_attach(stb6100_attach, |
| 1674 | fe0->dvb.frontend, |
| 1675 | &prof_8000_stb6100_config, |
| 1676 | &i2c_bus->i2c_adap)) |
| 1677 | goto frontend_detach; |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 1678 | |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1679 | fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; |
Mariusz Bia?o?czyk | f667190 | 2012-09-12 07:59:18 -0300 | [diff] [blame] | 1680 | break; |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 1681 | case CX23885_BOARD_HAUPPAUGE_HVR4400: |
| 1682 | i2c_bus = &dev->i2c_bus[0]; |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 1683 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1684 | switch (port->nr) { |
| 1685 | /* port b */ |
| 1686 | case 1: |
| 1687 | fe0->dvb.frontend = dvb_attach(tda10071_attach, |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 1688 | &hauppauge_tda10071_config, |
| 1689 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1690 | if (fe0->dvb.frontend == NULL) |
| 1691 | break; |
| 1692 | if (!dvb_attach(a8293_attach, fe0->dvb.frontend, |
| 1693 | &i2c_bus->i2c_adap, |
| 1694 | &hauppauge_a8293_config)) |
| 1695 | goto frontend_detach; |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 1696 | break; |
| 1697 | /* port c */ |
| 1698 | case 2: |
| 1699 | fe0->dvb.frontend = dvb_attach(si2165_attach, |
| 1700 | &hauppauge_hvr4400_si2165_config, |
| 1701 | &i2c_bus->i2c_adap); |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 1702 | if (fe0->dvb.frontend == NULL) |
| 1703 | break; |
| 1704 | fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; |
| 1705 | if (!dvb_attach(tda18271_attach, |
| 1706 | fe0->dvb.frontend, |
| 1707 | 0x60, &i2c_bus2->i2c_adap, |
| 1708 | &hauppauge_hvr4400_tuner_config)) |
| 1709 | goto frontend_detach; |
Matthias Schwarzott | 36efec4 | 2014-07-22 17:12:13 -0300 | [diff] [blame] | 1710 | break; |
Michael Krufky | 7c62f5a | 2012-12-15 23:34:09 -0300 | [diff] [blame] | 1711 | } |
| 1712 | break; |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1713 | case CX23885_BOARD_DVBSKY_T9580: |
nibble.max | cba5480 | 2014-11-05 11:58:07 -0300 | [diff] [blame] | 1714 | case CX23885_BOARD_DVBSKY_S950: |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1715 | i2c_bus = &dev->i2c_bus[0]; |
| 1716 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1717 | switch (port->nr) { |
| 1718 | /* port b - satellite */ |
| 1719 | case 1: |
| 1720 | /* attach frontend */ |
| 1721 | fe0->dvb.frontend = dvb_attach(m88ds3103_attach, |
| 1722 | &dvbsky_t9580_m88ds3103_config, |
| 1723 | &i2c_bus2->i2c_adap, &adapter); |
| 1724 | if (fe0->dvb.frontend == NULL) |
| 1725 | break; |
| 1726 | |
| 1727 | /* attach tuner */ |
Olli Salonen | 143800a | 2014-09-24 00:06:54 -0300 | [diff] [blame] | 1728 | memset(&m88ts2022_config, 0, sizeof(m88ts2022_config)); |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1729 | m88ts2022_config.fe = fe0->dvb.frontend; |
| 1730 | m88ts2022_config.clock = 27000000; |
| 1731 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1732 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); |
| 1733 | info.addr = 0x60; |
| 1734 | info.platform_data = &m88ts2022_config; |
| 1735 | request_module(info.type); |
| 1736 | client_tuner = i2c_new_device(adapter, &info); |
| 1737 | if (client_tuner == NULL || |
| 1738 | client_tuner->dev.driver == NULL) |
| 1739 | goto frontend_detach; |
| 1740 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1741 | i2c_unregister_device(client_tuner); |
| 1742 | goto frontend_detach; |
| 1743 | } |
| 1744 | |
| 1745 | /* delegate signal strength measurement to tuner */ |
| 1746 | fe0->dvb.frontend->ops.read_signal_strength = |
| 1747 | fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; |
| 1748 | |
| 1749 | /* |
| 1750 | * for setting the voltage we need to set GPIOs on |
| 1751 | * the card. |
| 1752 | */ |
| 1753 | port->fe_set_voltage = |
| 1754 | fe0->dvb.frontend->ops.set_voltage; |
| 1755 | fe0->dvb.frontend->ops.set_voltage = |
| 1756 | dvbsky_t9580_set_voltage; |
| 1757 | |
| 1758 | port->i2c_client_tuner = client_tuner; |
| 1759 | |
| 1760 | break; |
| 1761 | /* port c - terrestrial/cable */ |
| 1762 | case 2: |
| 1763 | /* attach frontend */ |
Olli Salonen | 143800a | 2014-09-24 00:06:54 -0300 | [diff] [blame] | 1764 | memset(&si2168_config, 0, sizeof(si2168_config)); |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1765 | si2168_config.i2c_adapter = &adapter; |
| 1766 | si2168_config.fe = &fe0->dvb.frontend; |
| 1767 | si2168_config.ts_mode = SI2168_TS_SERIAL; |
| 1768 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1769 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); |
| 1770 | info.addr = 0x64; |
| 1771 | info.platform_data = &si2168_config; |
| 1772 | request_module(info.type); |
| 1773 | client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); |
| 1774 | if (client_demod == NULL || |
| 1775 | client_demod->dev.driver == NULL) |
| 1776 | goto frontend_detach; |
| 1777 | if (!try_module_get(client_demod->dev.driver->owner)) { |
| 1778 | i2c_unregister_device(client_demod); |
| 1779 | goto frontend_detach; |
| 1780 | } |
| 1781 | port->i2c_client_demod = client_demod; |
| 1782 | |
| 1783 | /* attach tuner */ |
Olli Salonen | 143800a | 2014-09-24 00:06:54 -0300 | [diff] [blame] | 1784 | memset(&si2157_config, 0, sizeof(si2157_config)); |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 1785 | si2157_config.fe = fe0->dvb.frontend; |
| 1786 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1787 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); |
| 1788 | info.addr = 0x60; |
| 1789 | info.platform_data = &si2157_config; |
| 1790 | request_module(info.type); |
| 1791 | client_tuner = i2c_new_device(adapter, &info); |
| 1792 | if (client_tuner == NULL || |
| 1793 | client_tuner->dev.driver == NULL) { |
| 1794 | module_put(client_demod->dev.driver->owner); |
| 1795 | i2c_unregister_device(client_demod); |
| 1796 | goto frontend_detach; |
| 1797 | } |
| 1798 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1799 | i2c_unregister_device(client_tuner); |
| 1800 | module_put(client_demod->dev.driver->owner); |
| 1801 | i2c_unregister_device(client_demod); |
| 1802 | goto frontend_detach; |
| 1803 | } |
| 1804 | port->i2c_client_tuner = client_tuner; |
| 1805 | break; |
| 1806 | } |
| 1807 | break; |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 1808 | case CX23885_BOARD_DVBSKY_T980C: |
Olli Salonen | 61b103e | 2014-10-30 17:48:27 -0300 | [diff] [blame] | 1809 | case CX23885_BOARD_TT_CT2_4500_CI: |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 1810 | i2c_bus = &dev->i2c_bus[1]; |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 1811 | i2c_bus2 = &dev->i2c_bus[0]; |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 1812 | |
| 1813 | /* attach frontend */ |
| 1814 | memset(&si2168_config, 0, sizeof(si2168_config)); |
| 1815 | si2168_config.i2c_adapter = &adapter; |
| 1816 | si2168_config.fe = &fe0->dvb.frontend; |
| 1817 | si2168_config.ts_mode = SI2168_TS_PARALLEL; |
| 1818 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1819 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); |
| 1820 | info.addr = 0x64; |
| 1821 | info.platform_data = &si2168_config; |
| 1822 | request_module(info.type); |
| 1823 | client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); |
| 1824 | if (client_demod == NULL || |
| 1825 | client_demod->dev.driver == NULL) |
| 1826 | goto frontend_detach; |
| 1827 | if (!try_module_get(client_demod->dev.driver->owner)) { |
| 1828 | i2c_unregister_device(client_demod); |
| 1829 | goto frontend_detach; |
| 1830 | } |
| 1831 | port->i2c_client_demod = client_demod; |
| 1832 | |
| 1833 | /* attach tuner */ |
| 1834 | memset(&si2157_config, 0, sizeof(si2157_config)); |
| 1835 | si2157_config.fe = fe0->dvb.frontend; |
| 1836 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1837 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); |
| 1838 | info.addr = 0x60; |
| 1839 | info.platform_data = &si2157_config; |
| 1840 | request_module(info.type); |
| 1841 | client_tuner = i2c_new_device(adapter, &info); |
| 1842 | if (client_tuner == NULL || |
| 1843 | client_tuner->dev.driver == NULL) { |
| 1844 | module_put(client_demod->dev.driver->owner); |
| 1845 | i2c_unregister_device(client_demod); |
| 1846 | goto frontend_detach; |
| 1847 | } |
| 1848 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1849 | i2c_unregister_device(client_tuner); |
| 1850 | module_put(client_demod->dev.driver->owner); |
| 1851 | i2c_unregister_device(client_demod); |
| 1852 | goto frontend_detach; |
| 1853 | } |
| 1854 | port->i2c_client_tuner = client_tuner; |
| 1855 | break; |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 1856 | case CX23885_BOARD_DVBSKY_S950C: |
| 1857 | i2c_bus = &dev->i2c_bus[1]; |
| 1858 | i2c_bus2 = &dev->i2c_bus[0]; |
| 1859 | |
| 1860 | /* attach frontend */ |
| 1861 | fe0->dvb.frontend = dvb_attach(m88ds3103_attach, |
| 1862 | &dvbsky_s950c_m88ds3103_config, |
| 1863 | &i2c_bus->i2c_adap, &adapter); |
| 1864 | if (fe0->dvb.frontend == NULL) |
| 1865 | break; |
| 1866 | |
| 1867 | /* attach tuner */ |
| 1868 | memset(&m88ts2022_config, 0, sizeof(m88ts2022_config)); |
| 1869 | m88ts2022_config.fe = fe0->dvb.frontend; |
| 1870 | m88ts2022_config.clock = 27000000; |
| 1871 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1872 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); |
| 1873 | info.addr = 0x60; |
| 1874 | info.platform_data = &m88ts2022_config; |
| 1875 | request_module(info.type); |
| 1876 | client_tuner = i2c_new_device(adapter, &info); |
| 1877 | if (client_tuner == NULL || |
| 1878 | client_tuner->dev.driver == NULL) |
| 1879 | goto frontend_detach; |
| 1880 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1881 | i2c_unregister_device(client_tuner); |
| 1882 | goto frontend_detach; |
| 1883 | } |
| 1884 | |
| 1885 | /* delegate signal strength measurement to tuner */ |
| 1886 | fe0->dvb.frontend->ops.read_signal_strength = |
| 1887 | fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; |
| 1888 | |
| 1889 | port->i2c_client_tuner = client_tuner; |
| 1890 | break; |
nibble.max | c29d6a8 | 2014-11-05 11:58:38 -0300 | [diff] [blame] | 1891 | case CX23885_BOARD_DVBSKY_S952: |
| 1892 | switch (port->nr) { |
| 1893 | /* port b */ |
| 1894 | case 1: |
| 1895 | i2c_bus = &dev->i2c_bus[1]; |
| 1896 | p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config; |
| 1897 | p_set_voltage = dvbsky_t9580_set_voltage; |
| 1898 | break; |
| 1899 | /* port c */ |
| 1900 | case 2: |
| 1901 | i2c_bus = &dev->i2c_bus[0]; |
| 1902 | p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config; |
| 1903 | p_set_voltage = dvbsky_s952_portc_set_voltage; |
| 1904 | break; |
| 1905 | } |
| 1906 | |
| 1907 | /* attach frontend */ |
| 1908 | fe0->dvb.frontend = dvb_attach(m88ds3103_attach, |
| 1909 | p_m88ds3103_config, |
| 1910 | &i2c_bus->i2c_adap, &adapter); |
| 1911 | if (fe0->dvb.frontend == NULL) |
| 1912 | break; |
| 1913 | |
| 1914 | /* attach tuner */ |
| 1915 | memset(&m88ts2022_config, 0, sizeof(m88ts2022_config)); |
| 1916 | m88ts2022_config.fe = fe0->dvb.frontend; |
| 1917 | m88ts2022_config.clock = 27000000; |
| 1918 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1919 | strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE); |
| 1920 | info.addr = 0x60; |
| 1921 | info.platform_data = &m88ts2022_config; |
| 1922 | request_module(info.type); |
| 1923 | client_tuner = i2c_new_device(adapter, &info); |
| 1924 | if (client_tuner == NULL || |
| 1925 | client_tuner->dev.driver == NULL) |
| 1926 | goto frontend_detach; |
| 1927 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1928 | i2c_unregister_device(client_tuner); |
| 1929 | goto frontend_detach; |
| 1930 | } |
| 1931 | |
| 1932 | /* delegate signal strength measurement to tuner */ |
| 1933 | fe0->dvb.frontend->ops.read_signal_strength = |
| 1934 | fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; |
| 1935 | |
| 1936 | /* |
| 1937 | * for setting the voltage we need to set GPIOs on |
| 1938 | * the card. |
| 1939 | */ |
| 1940 | port->fe_set_voltage = |
| 1941 | fe0->dvb.frontend->ops.set_voltage; |
| 1942 | fe0->dvb.frontend->ops.set_voltage = p_set_voltage; |
| 1943 | |
| 1944 | port->i2c_client_tuner = client_tuner; |
| 1945 | break; |
Nibble Max | c02ef64 | 2014-11-12 01:23:12 -0300 | [diff] [blame] | 1946 | case CX23885_BOARD_DVBSKY_T982: |
| 1947 | memset(&si2168_config, 0, sizeof(si2168_config)); |
| 1948 | switch (port->nr) { |
| 1949 | /* port b */ |
| 1950 | case 1: |
| 1951 | i2c_bus = &dev->i2c_bus[1]; |
| 1952 | si2168_config.ts_mode = SI2168_TS_PARALLEL; |
| 1953 | break; |
| 1954 | /* port c */ |
| 1955 | case 2: |
| 1956 | i2c_bus = &dev->i2c_bus[0]; |
| 1957 | si2168_config.ts_mode = SI2168_TS_SERIAL; |
| 1958 | break; |
| 1959 | } |
| 1960 | |
| 1961 | /* attach frontend */ |
| 1962 | si2168_config.i2c_adapter = &adapter; |
| 1963 | si2168_config.fe = &fe0->dvb.frontend; |
| 1964 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1965 | strlcpy(info.type, "si2168", I2C_NAME_SIZE); |
| 1966 | info.addr = 0x64; |
| 1967 | info.platform_data = &si2168_config; |
| 1968 | request_module(info.type); |
| 1969 | client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); |
| 1970 | if (client_demod == NULL || |
| 1971 | client_demod->dev.driver == NULL) |
| 1972 | goto frontend_detach; |
| 1973 | if (!try_module_get(client_demod->dev.driver->owner)) { |
| 1974 | i2c_unregister_device(client_demod); |
| 1975 | goto frontend_detach; |
| 1976 | } |
| 1977 | port->i2c_client_demod = client_demod; |
| 1978 | |
| 1979 | /* attach tuner */ |
| 1980 | memset(&si2157_config, 0, sizeof(si2157_config)); |
| 1981 | si2157_config.fe = fe0->dvb.frontend; |
| 1982 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 1983 | strlcpy(info.type, "si2157", I2C_NAME_SIZE); |
| 1984 | info.addr = 0x60; |
| 1985 | info.platform_data = &si2157_config; |
| 1986 | request_module(info.type); |
| 1987 | client_tuner = i2c_new_device(adapter, &info); |
| 1988 | if (client_tuner == NULL || |
| 1989 | client_tuner->dev.driver == NULL) { |
| 1990 | module_put(client_demod->dev.driver->owner); |
| 1991 | i2c_unregister_device(client_demod); |
| 1992 | goto frontend_detach; |
| 1993 | } |
| 1994 | if (!try_module_get(client_tuner->dev.driver->owner)) { |
| 1995 | i2c_unregister_device(client_tuner); |
| 1996 | module_put(client_demod->dev.driver->owner); |
| 1997 | i2c_unregister_device(client_demod); |
| 1998 | port->i2c_client_demod = NULL; |
| 1999 | goto frontend_detach; |
| 2000 | } |
| 2001 | port->i2c_client_tuner = client_tuner; |
| 2002 | break; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2003 | default: |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2004 | printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " |
| 2005 | " isn't supported yet\n", |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2006 | dev->name); |
| 2007 | break; |
| 2008 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2009 | |
| 2010 | if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) { |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2011 | printk(KERN_ERR "%s: frontend initialization failed\n", |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2012 | dev->name); |
| 2013 | goto frontend_detach; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2014 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2015 | |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 2016 | /* define general-purpose callback pointer */ |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2017 | fe0->dvb.frontend->callback = cx23885_tuner_callback; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2018 | if (fe1) |
| 2019 | fe1->dvb.frontend->callback = cx23885_tuner_callback; |
| 2020 | #if 0 |
| 2021 | /* Ensure all frontends negotiate bus access */ |
| 2022 | fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; |
| 2023 | if (fe1) |
| 2024 | fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; |
| 2025 | #endif |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2026 | |
| 2027 | /* Put the analog decoder in standby to keep it quiet */ |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 2028 | call_all(dev, core, s_power, 0); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2029 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2030 | if (fe0->dvb.frontend->ops.analog_ops.standby) |
| 2031 | fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 2032 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2033 | /* register everything */ |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2034 | ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port, |
Mauro Carvalho Chehab | 9adf613 | 2012-08-05 14:16:30 -0300 | [diff] [blame] | 2035 | &dev->pci->dev, adapter_nr, mfe_shared); |
Abylay Ospan | bee3019 | 2010-06-25 08:01:28 -0300 | [diff] [blame] | 2036 | if (ret) |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2037 | goto frontend_detach; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2038 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 2039 | /* init CI & MAC */ |
| 2040 | switch (dev->board) { |
| 2041 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: { |
| 2042 | static struct netup_card_info cinfo; |
| 2043 | |
| 2044 | netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo); |
| 2045 | memcpy(port->frontends.adapter.proposed_mac, |
| 2046 | cinfo.port[port->nr - 1].mac, 6); |
hartleys | be39515 | 2009-12-30 16:08:57 -0300 | [diff] [blame] | 2047 | printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n", |
| 2048 | port->nr, port->frontends.adapter.proposed_mac); |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 2049 | |
| 2050 | netup_ci_init(port); |
| 2051 | break; |
| 2052 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2053 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: { |
| 2054 | struct altera_ci_config netup_ci_cfg = { |
| 2055 | .dev = dev,/* magic number to identify*/ |
| 2056 | .adapter = &port->frontends.adapter,/* for CI */ |
| 2057 | .demux = &fe0->dvb.demux,/* for hw pid filter */ |
| 2058 | .fpga_rw = netup_altera_fpga_rw, |
| 2059 | }; |
| 2060 | |
| 2061 | altera_ci_init(&netup_ci_cfg, port->nr); |
| 2062 | break; |
| 2063 | } |
Pierre Gronlier | 16bfdaa4 | 2010-04-26 13:26:29 -0300 | [diff] [blame] | 2064 | case CX23885_BOARD_TEVII_S470: { |
| 2065 | u8 eeprom[256]; /* 24C02 i2c eeprom */ |
| 2066 | |
| 2067 | if (port->nr != 1) |
| 2068 | break; |
| 2069 | |
| 2070 | /* Read entire EEPROM */ |
| 2071 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
| 2072 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); |
Andy Shevchenko | 5cac1f66 | 2010-09-11 14:33:28 -0300 | [diff] [blame] | 2073 | printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0); |
Pierre Gronlier | 16bfdaa4 | 2010-04-26 13:26:29 -0300 | [diff] [blame] | 2074 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); |
| 2075 | break; |
| 2076 | } |
nibble.max | cba5480 | 2014-11-05 11:58:07 -0300 | [diff] [blame] | 2077 | case CX23885_BOARD_DVBSKY_T9580: |
nibble.max | c29d6a8 | 2014-11-05 11:58:38 -0300 | [diff] [blame] | 2078 | case CX23885_BOARD_DVBSKY_S950: |
Nibble Max | c02ef64 | 2014-11-12 01:23:12 -0300 | [diff] [blame] | 2079 | case CX23885_BOARD_DVBSKY_S952: |
| 2080 | case CX23885_BOARD_DVBSKY_T982: { |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 2081 | u8 eeprom[256]; /* 24C02 i2c eeprom */ |
| 2082 | |
| 2083 | if (port->nr > 2) |
| 2084 | break; |
| 2085 | |
| 2086 | /* Read entire EEPROM */ |
| 2087 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
| 2088 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, |
| 2089 | sizeof(eeprom)); |
nibble.max | cba5480 | 2014-11-05 11:58:07 -0300 | [diff] [blame] | 2090 | printk(KERN_INFO "%s port %d MAC address: %pM\n", |
| 2091 | cx23885_boards[dev->board].name, port->nr, |
| 2092 | eeprom + 0xc0 + (port->nr-1) * 8); |
Olli Salonen | 2944226 | 2014-08-11 16:58:15 -0300 | [diff] [blame] | 2093 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + |
| 2094 | (port->nr-1) * 8, 6); |
| 2095 | break; |
| 2096 | } |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 2097 | case CX23885_BOARD_DVBSKY_S950C: |
Olli Salonen | 61b103e | 2014-10-30 17:48:27 -0300 | [diff] [blame] | 2098 | case CX23885_BOARD_DVBSKY_T980C: |
| 2099 | case CX23885_BOARD_TT_CT2_4500_CI: { |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 2100 | u8 eeprom[256]; /* 24C02 i2c eeprom */ |
| 2101 | |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 2102 | /* attach CI */ |
| 2103 | memset(&sp2_config, 0, sizeof(sp2_config)); |
| 2104 | sp2_config.dvb_adap = &port->frontends.adapter; |
| 2105 | sp2_config.priv = port; |
| 2106 | sp2_config.ci_control = cx23885_sp2_ci_ctrl; |
| 2107 | memset(&info, 0, sizeof(struct i2c_board_info)); |
| 2108 | strlcpy(info.type, "sp2", I2C_NAME_SIZE); |
| 2109 | info.addr = 0x40; |
| 2110 | info.platform_data = &sp2_config; |
| 2111 | request_module(info.type); |
| 2112 | client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info); |
| 2113 | if (client_ci == NULL || |
| 2114 | client_ci->dev.driver == NULL) { |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 2115 | if (client_tuner) { |
| 2116 | module_put(client_tuner->dev.driver->owner); |
| 2117 | i2c_unregister_device(client_tuner); |
| 2118 | } |
| 2119 | if (client_demod) { |
| 2120 | module_put(client_demod->dev.driver->owner); |
| 2121 | i2c_unregister_device(client_demod); |
| 2122 | } |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 2123 | goto frontend_detach; |
| 2124 | } |
| 2125 | if (!try_module_get(client_ci->dev.driver->owner)) { |
| 2126 | i2c_unregister_device(client_ci); |
nibble.max | 0e6c7b0 | 2014-10-23 07:01:44 -0300 | [diff] [blame] | 2127 | if (client_tuner) { |
| 2128 | module_put(client_tuner->dev.driver->owner); |
| 2129 | i2c_unregister_device(client_tuner); |
| 2130 | } |
| 2131 | if (client_demod) { |
| 2132 | module_put(client_demod->dev.driver->owner); |
| 2133 | i2c_unregister_device(client_demod); |
| 2134 | } |
Olli Salonen | 24e7740 | 2014-10-04 03:59:30 -0300 | [diff] [blame] | 2135 | goto frontend_detach; |
| 2136 | } |
| 2137 | port->i2c_client_ci = client_ci; |
| 2138 | |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 2139 | if (port->nr != 1) |
| 2140 | break; |
| 2141 | |
| 2142 | /* Read entire EEPROM */ |
| 2143 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
| 2144 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, |
| 2145 | sizeof(eeprom)); |
Olli Salonen | 61b103e | 2014-10-30 17:48:27 -0300 | [diff] [blame] | 2146 | printk(KERN_INFO "%s MAC address: %pM\n", |
| 2147 | cx23885_boards[dev->board].name, eeprom + 0xc0); |
Olli Salonen | 82c1027 | 2014-09-29 04:44:16 -0300 | [diff] [blame] | 2148 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6); |
| 2149 | break; |
| 2150 | } |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 2151 | } |
| 2152 | |
| 2153 | return ret; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2154 | |
| 2155 | frontend_detach: |
| 2156 | port->gate_ctrl = NULL; |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2157 | vb2_dvb_dealloc_frontends(&port->frontends); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2158 | return -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2159 | } |
| 2160 | |
| 2161 | int cx23885_dvb_register(struct cx23885_tsport *port) |
| 2162 | { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2163 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2164 | struct vb2_dvb_frontend *fe0; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2165 | struct cx23885_dev *dev = port->dev; |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2166 | int err, i; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2167 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2168 | /* Here we need to allocate the correct number of frontends, |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 2169 | * as reflected in the cards struct. The reality is that currently |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2170 | * no cx23885 boards support this - yet. But, if we don't modify this |
| 2171 | * code then the second frontend would never be allocated (later) |
| 2172 | * and fail with error before the attach in dvb_register(). |
| 2173 | * Without these changes we risk an OOPS later. The changes here |
| 2174 | * are for safety, and should provide a good foundation for the |
| 2175 | * future addition of any multi-frontend cx23885 based boards. |
| 2176 | */ |
| 2177 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, |
| 2178 | port->num_frontends); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2179 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2180 | for (i = 1; i <= port->num_frontends; i++) { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2181 | struct vb2_queue *q; |
| 2182 | |
| 2183 | if (vb2_dvb_alloc_frontend( |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2184 | &port->frontends, i) == NULL) { |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2185 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
| 2186 | return -ENOMEM; |
| 2187 | } |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2188 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2189 | fe0 = vb2_dvb_get_frontend(&port->frontends, i); |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2190 | if (!fe0) |
Mauro Carvalho Chehab | ed3da2b | 2014-10-30 11:15:53 -0300 | [diff] [blame] | 2191 | return -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2192 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2193 | dprintk(1, "%s\n", __func__); |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2194 | dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2195 | dev->board, |
| 2196 | dev->name, |
| 2197 | dev->pci_bus, |
| 2198 | dev->pci_slot); |
| 2199 | |
| 2200 | err = -ENODEV; |
| 2201 | |
| 2202 | /* dvb stuff */ |
| 2203 | /* We have to init the queue for each frontend on a port. */ |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2204 | printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2205 | q = &fe0->dvb.dvbq; |
| 2206 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 2207 | q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; |
| 2208 | q->gfp_flags = GFP_DMA32; |
| 2209 | q->min_buffers_needed = 2; |
| 2210 | q->drv_priv = port; |
| 2211 | q->buf_struct_size = sizeof(struct cx23885_buffer); |
| 2212 | q->ops = &dvb_qops; |
| 2213 | q->mem_ops = &vb2_dma_sg_memops; |
| 2214 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
| 2215 | q->lock = &dev->lock; |
| 2216 | |
| 2217 | err = vb2_queue_init(q); |
| 2218 | if (err < 0) |
| 2219 | return err; |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 2220 | } |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2221 | err = dvb_register(port); |
| 2222 | if (err != 0) |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 2223 | printk(KERN_ERR "%s() dvb_register failed err = %d\n", |
| 2224 | __func__, err); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2225 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2226 | return err; |
| 2227 | } |
| 2228 | |
| 2229 | int cx23885_dvb_unregister(struct cx23885_tsport *port) |
| 2230 | { |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2231 | struct vb2_dvb_frontend *fe0; |
Olli Salonen | b0b12e6 | 2014-08-11 16:58:13 -0300 | [diff] [blame] | 2232 | struct i2c_client *client; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2233 | |
Olli Salonen | e450de4 | 2014-09-29 04:44:19 -0300 | [diff] [blame] | 2234 | /* remove I2C client for CI */ |
| 2235 | client = port->i2c_client_ci; |
| 2236 | if (client) { |
| 2237 | module_put(client->dev.driver->owner); |
| 2238 | i2c_unregister_device(client); |
| 2239 | } |
| 2240 | |
Olli Salonen | b0b12e6 | 2014-08-11 16:58:13 -0300 | [diff] [blame] | 2241 | /* remove I2C client for tuner */ |
| 2242 | client = port->i2c_client_tuner; |
| 2243 | if (client) { |
| 2244 | module_put(client->dev.driver->owner); |
| 2245 | i2c_unregister_device(client); |
| 2246 | } |
| 2247 | |
| 2248 | /* remove I2C client for demodulator */ |
| 2249 | client = port->i2c_client_demod; |
| 2250 | if (client) { |
| 2251 | module_put(client->dev.driver->owner); |
| 2252 | i2c_unregister_device(client); |
| 2253 | } |
| 2254 | |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2255 | fe0 = vb2_dvb_get_frontend(&port->frontends, 1); |
Olli Salonen | b0b12e6 | 2014-08-11 16:58:13 -0300 | [diff] [blame] | 2256 | |
Abylay Ospan | e66131c | 2011-07-15 15:01:07 -0300 | [diff] [blame] | 2257 | if (fe0 && fe0->dvb.frontend) |
Hans Verkuil | 453afdd | 2014-08-14 06:43:01 -0300 | [diff] [blame] | 2258 | vb2_dvb_unregister_bus(&port->frontends); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2259 | |
Hans Verkuil | afd9666 | 2009-03-13 13:24:19 -0300 | [diff] [blame] | 2260 | switch (port->dev->board) { |
| 2261 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: |
| 2262 | netup_ci_exit(port); |
| 2263 | break; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2264 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: |
| 2265 | altera_ci_release(port->dev, port->nr); |
| 2266 | break; |
Hans Verkuil | afd9666 | 2009-03-13 13:24:19 -0300 | [diff] [blame] | 2267 | } |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 2268 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 2269 | port->gate_ctrl = NULL; |
| 2270 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 2271 | return 0; |
| 2272 | } |