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. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/device.h> |
| 25 | #include <linux/fs.h> |
| 26 | #include <linux/kthread.h> |
| 27 | #include <linux/file.h> |
| 28 | #include <linux/suspend.h> |
| 29 | |
| 30 | #include "cx23885.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 31 | #include <media/v4l2-common.h> |
| 32 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 33 | #include "dvb_ca_en50221.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 34 | #include "s5h1409.h" |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 35 | #include "s5h1411.h" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 36 | #include "mt2131.h" |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 37 | #include "tda8290.h" |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 38 | #include "tda18271.h" |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 39 | #include "lgdt330x.h" |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 40 | #include "xc5000.h" |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 41 | #include "max2165.h" |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 42 | #include "tda10048.h" |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 43 | #include "tuner-xc2028.h" |
Michael Krufky | 827855d | 2008-04-22 14:46:16 -0300 | [diff] [blame] | 44 | #include "tuner-simple.h" |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 45 | #include "dib7000p.h" |
| 46 | #include "dibx000_common.h" |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 47 | #include "zl10353.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 48 | #include "stv0900.h" |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 49 | #include "stv0900_reg.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 50 | #include "stv6110.h" |
| 51 | #include "lnbh24.h" |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 52 | #include "cx24116.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 53 | #include "cimax2.h" |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 54 | #include "lgs8gxx.h" |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 55 | #include "netup-eeprom.h" |
| 56 | #include "netup-init.h" |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 57 | #include "lgdt3305.h" |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 58 | #include "atbm8830.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" |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 63 | |
Steven Toth | 4513fc69 | 2008-01-12 11:36:36 -0300 | [diff] [blame] | 64 | static unsigned int debug; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 65 | |
Steven Toth | 4513fc69 | 2008-01-12 11:36:36 -0300 | [diff] [blame] | 66 | #define dprintk(level, fmt, arg...)\ |
| 67 | do { if (debug >= level)\ |
| 68 | printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ |
| 69 | } while (0) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 70 | |
| 71 | /* ------------------------------------------------------------------ */ |
| 72 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 73 | static unsigned int alt_tuner; |
| 74 | module_param(alt_tuner, int, 0644); |
| 75 | MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); |
| 76 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 77 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 78 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 79 | /* ------------------------------------------------------------------ */ |
| 80 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 81 | static int dvb_buf_setup(struct videobuf_queue *q, |
| 82 | unsigned int *count, unsigned int *size) |
| 83 | { |
| 84 | struct cx23885_tsport *port = q->priv_data; |
| 85 | |
| 86 | port->ts_packet_size = 188 * 4; |
| 87 | port->ts_packet_count = 32; |
| 88 | |
| 89 | *size = port->ts_packet_size * port->ts_packet_count; |
| 90 | *count = 32; |
| 91 | return 0; |
| 92 | } |
| 93 | |
Michael Krufky | 44a6481 | 2007-03-20 23:00:18 -0300 | [diff] [blame] | 94 | static int dvb_buf_prepare(struct videobuf_queue *q, |
| 95 | struct videobuf_buffer *vb, enum v4l2_field field) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 96 | { |
| 97 | struct cx23885_tsport *port = q->priv_data; |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 98 | return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 102 | { |
| 103 | struct cx23885_tsport *port = q->priv_data; |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 104 | cx23885_buf_queue(port, (struct cx23885_buffer *)vb); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 105 | } |
| 106 | |
Michael Krufky | 44a6481 | 2007-03-20 23:00:18 -0300 | [diff] [blame] | 107 | static void dvb_buf_release(struct videobuf_queue *q, |
| 108 | struct videobuf_buffer *vb) |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 109 | { |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 110 | cx23885_free_buffer(q, (struct cx23885_buffer *)vb); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 111 | } |
| 112 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 113 | static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open) |
| 114 | { |
| 115 | struct videobuf_dvb_frontends *f; |
| 116 | struct videobuf_dvb_frontend *fe; |
| 117 | |
| 118 | f = &port->frontends; |
| 119 | |
| 120 | if (f->gate <= 1) /* undefined or fe0 */ |
| 121 | fe = videobuf_dvb_get_frontend(f, 1); |
| 122 | else |
| 123 | fe = videobuf_dvb_get_frontend(f, f->gate); |
| 124 | |
| 125 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) |
| 126 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open); |
| 127 | } |
| 128 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 129 | static struct videobuf_queue_ops dvb_qops = { |
| 130 | .buf_setup = dvb_buf_setup, |
| 131 | .buf_prepare = dvb_buf_prepare, |
| 132 | .buf_queue = dvb_buf_queue, |
| 133 | .buf_release = dvb_buf_release, |
| 134 | }; |
| 135 | |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 136 | static struct s5h1409_config hauppauge_generic_config = { |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 137 | .demod_address = 0x32 >> 1, |
| 138 | .output_mode = S5H1409_SERIAL_OUTPUT, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 139 | .gpio = S5H1409_GPIO_ON, |
Michael Krufky | 2b03238 | 2007-12-13 10:04:10 -0300 | [diff] [blame] | 140 | .qam_if = 44000, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 141 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 142 | .status_mode = S5H1409_DEMODLOCKING, |
| 143 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 144 | }; |
| 145 | |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 146 | static struct tda10048_config hauppauge_hvr1200_config = { |
| 147 | .demod_address = 0x10 >> 1, |
| 148 | .output_mode = TDA10048_SERIAL_OUTPUT, |
| 149 | .fwbulkwritelen = TDA10048_BULKWRITE_200, |
Steven Toth | 484d9e0 | 2009-05-02 11:08:23 -0300 | [diff] [blame] | 150 | .inversion = TDA10048_INVERSION_ON, |
Steven Toth | 8816bef | 2009-05-15 21:04:18 -0300 | [diff] [blame] | 151 | .dtv6_if_freq_khz = TDA10048_IF_3300, |
| 152 | .dtv7_if_freq_khz = TDA10048_IF_3800, |
| 153 | .dtv8_if_freq_khz = TDA10048_IF_4300, |
Steven Toth | 484d9e0 | 2009-05-02 11:08:23 -0300 | [diff] [blame] | 154 | .clk_freq_khz = TDA10048_CLK_16000, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 155 | }; |
| 156 | |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 157 | static struct tda10048_config hauppauge_hvr1210_config = { |
| 158 | .demod_address = 0x10 >> 1, |
| 159 | .output_mode = TDA10048_SERIAL_OUTPUT, |
| 160 | .fwbulkwritelen = TDA10048_BULKWRITE_200, |
| 161 | .inversion = TDA10048_INVERSION_ON, |
Michael Krufky | c27586e | 2009-05-16 11:00:23 -0300 | [diff] [blame] | 162 | .dtv6_if_freq_khz = TDA10048_IF_3300, |
| 163 | .dtv7_if_freq_khz = TDA10048_IF_3500, |
| 164 | .dtv8_if_freq_khz = TDA10048_IF_4000, |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 165 | .clk_freq_khz = TDA10048_CLK_16000, |
| 166 | }; |
| 167 | |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 168 | static struct s5h1409_config hauppauge_ezqam_config = { |
| 169 | .demod_address = 0x32 >> 1, |
| 170 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 171 | .gpio = S5H1409_GPIO_OFF, |
| 172 | .qam_if = 4000, |
| 173 | .inversion = S5H1409_INVERSION_ON, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 174 | .status_mode = S5H1409_DEMODLOCKING, |
| 175 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 176 | }; |
| 177 | |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 178 | static struct s5h1409_config hauppauge_hvr1800lp_config = { |
| 179 | .demod_address = 0x32 >> 1, |
| 180 | .output_mode = S5H1409_SERIAL_OUTPUT, |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 181 | .gpio = S5H1409_GPIO_OFF, |
Michael Krufky | 2b03238 | 2007-12-13 10:04:10 -0300 | [diff] [blame] | 182 | .qam_if = 44000, |
Steven Toth | fe47516 | 2007-03-20 15:27:53 -0300 | [diff] [blame] | 183 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 184 | .status_mode = S5H1409_DEMODLOCKING, |
| 185 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 186 | }; |
| 187 | |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 188 | static struct s5h1409_config hauppauge_hvr1500_config = { |
| 189 | .demod_address = 0x32 >> 1, |
| 190 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 191 | .gpio = S5H1409_GPIO_OFF, |
| 192 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 193 | .status_mode = S5H1409_DEMODLOCKING, |
| 194 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 195 | }; |
| 196 | |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 197 | static struct mt2131_config hauppauge_generic_tunerconfig = { |
Steven Toth | a77743b | 2007-08-22 21:01:20 -0300 | [diff] [blame] | 198 | 0x61 |
| 199 | }; |
| 200 | |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 201 | static struct lgdt330x_config fusionhdtv_5_express = { |
| 202 | .demod_address = 0x0e, |
| 203 | .demod_chip = LGDT3303, |
| 204 | .serial_mpeg = 0x40, |
| 205 | }; |
| 206 | |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 207 | static struct s5h1409_config hauppauge_hvr1500q_config = { |
| 208 | .demod_address = 0x32 >> 1, |
| 209 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 210 | .gpio = S5H1409_GPIO_ON, |
| 211 | .qam_if = 44000, |
| 212 | .inversion = S5H1409_INVERSION_OFF, |
Steven Toth | dfc1c08 | 2008-01-15 21:35:22 -0300 | [diff] [blame] | 213 | .status_mode = S5H1409_DEMODLOCKING, |
| 214 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 215 | }; |
| 216 | |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 217 | static struct s5h1409_config dvico_s5h1409_config = { |
| 218 | .demod_address = 0x32 >> 1, |
| 219 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| 220 | .gpio = S5H1409_GPIO_ON, |
| 221 | .qam_if = 44000, |
| 222 | .inversion = S5H1409_INVERSION_OFF, |
| 223 | .status_mode = S5H1409_DEMODLOCKING, |
| 224 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 225 | }; |
| 226 | |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 227 | static struct s5h1411_config dvico_s5h1411_config = { |
| 228 | .output_mode = S5H1411_SERIAL_OUTPUT, |
| 229 | .gpio = S5H1411_GPIO_ON, |
| 230 | .qam_if = S5H1411_IF_44000, |
| 231 | .vsb_if = S5H1411_IF_44000, |
| 232 | .inversion = S5H1411_INVERSION_OFF, |
| 233 | .status_mode = S5H1411_DEMODLOCKING, |
| 234 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 235 | }; |
| 236 | |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 237 | static struct s5h1411_config hcw_s5h1411_config = { |
| 238 | .output_mode = S5H1411_SERIAL_OUTPUT, |
| 239 | .gpio = S5H1411_GPIO_OFF, |
| 240 | .vsb_if = S5H1411_IF_44000, |
| 241 | .qam_if = S5H1411_IF_4000, |
| 242 | .inversion = S5H1411_INVERSION_ON, |
| 243 | .status_mode = S5H1411_DEMODLOCKING, |
| 244 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 245 | }; |
| 246 | |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 247 | static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { |
Steven Toth | e12671c | 2007-12-20 01:14:43 -0300 | [diff] [blame] | 248 | .i2c_address = 0x61, |
| 249 | .if_khz = 5380, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 250 | }; |
| 251 | |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 252 | static struct xc5000_config dvico_xc5000_tunerconfig = { |
| 253 | .i2c_address = 0x64, |
| 254 | .if_khz = 5380, |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 255 | }; |
| 256 | |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 257 | static struct tda829x_config tda829x_no_probe = { |
| 258 | .probe_tuner = TDA829X_DONT_PROBE, |
| 259 | }; |
| 260 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 261 | static struct tda18271_std_map hauppauge_tda18271_std_map = { |
Michael Krufky | c0dc0c1 | 2008-04-22 14:46:22 -0300 | [diff] [blame] | 262 | .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, |
| 263 | .if_lvl = 6, .rfagc_top = 0x37 }, |
| 264 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, |
| 265 | .if_lvl = 6, .rfagc_top = 0x37 }, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 266 | }; |
| 267 | |
Michael Krufky | b34cdc3 | 2009-05-21 12:49:28 -0300 | [diff] [blame] | 268 | static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = { |
| 269 | .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4, |
| 270 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 271 | .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5, |
| 272 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 273 | .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6, |
| 274 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 275 | }; |
| 276 | |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 277 | static struct tda18271_config hauppauge_tda18271_config = { |
| 278 | .std_map = &hauppauge_tda18271_std_map, |
| 279 | .gate = TDA18271_GATE_ANALOG, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 280 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 281 | }; |
| 282 | |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 283 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { |
Michael Krufky | b34cdc3 | 2009-05-21 12:49:28 -0300 | [diff] [blame] | 284 | .std_map = &hauppauge_hvr1200_tda18271_std_map, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 285 | .gate = TDA18271_GATE_ANALOG, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 286 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 287 | }; |
| 288 | |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 289 | static struct tda18271_config hauppauge_hvr1210_tuner_config = { |
| 290 | .gate = TDA18271_GATE_DIGITAL, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 291 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 292 | }; |
| 293 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 294 | static struct tda18271_std_map hauppauge_hvr127x_std_map = { |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 295 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4, |
| 296 | .if_lvl = 1, .rfagc_top = 0x58 }, |
| 297 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5, |
| 298 | .if_lvl = 1, .rfagc_top = 0x58 }, |
| 299 | }; |
| 300 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 301 | static struct tda18271_config hauppauge_hvr127x_config = { |
| 302 | .std_map = &hauppauge_hvr127x_std_map, |
Michael Krufky | 04a68ba | 2009-09-06 14:11:09 -0300 | [diff] [blame] | 303 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 304 | }; |
| 305 | |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 306 | static struct lgdt3305_config hauppauge_lgdt3305_config = { |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 307 | .i2c_addr = 0x0e, |
| 308 | .mpeg_mode = LGDT3305_MPEG_SERIAL, |
| 309 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, |
| 310 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, |
| 311 | .deny_i2c_rptr = 1, |
| 312 | .spectral_inversion = 1, |
| 313 | .qam_if_khz = 4000, |
| 314 | .vsb_if_khz = 3250, |
| 315 | }; |
| 316 | |
Harvey Harrison | b1721d0 | 2008-04-25 19:03:08 -0700 | [diff] [blame] | 317 | static struct dibx000_agc_config xc3028_agc_config = { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 318 | BAND_VHF | BAND_UHF, /* band_caps */ |
| 319 | |
| 320 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, |
| 321 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, |
| 322 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, |
| 323 | * P_agc_nb_est=2, P_agc_write=0 |
| 324 | */ |
| 325 | (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | |
| 326 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ |
| 327 | |
| 328 | 712, /* inv_gain */ |
| 329 | 21, /* time_stabiliz */ |
| 330 | |
| 331 | 0, /* alpha_level */ |
| 332 | 118, /* thlock */ |
| 333 | |
| 334 | 0, /* wbd_inv */ |
| 335 | 2867, /* wbd_ref */ |
| 336 | 0, /* wbd_sel */ |
| 337 | 2, /* wbd_alpha */ |
| 338 | |
| 339 | 0, /* agc1_max */ |
| 340 | 0, /* agc1_min */ |
| 341 | 39718, /* agc2_max */ |
| 342 | 9930, /* agc2_min */ |
| 343 | 0, /* agc1_pt1 */ |
| 344 | 0, /* agc1_pt2 */ |
| 345 | 0, /* agc1_pt3 */ |
| 346 | 0, /* agc1_slope1 */ |
| 347 | 0, /* agc1_slope2 */ |
| 348 | 0, /* agc2_pt1 */ |
| 349 | 128, /* agc2_pt2 */ |
| 350 | 29, /* agc2_slope1 */ |
| 351 | 29, /* agc2_slope2 */ |
| 352 | |
| 353 | 17, /* alpha_mant */ |
| 354 | 27, /* alpha_exp */ |
| 355 | 23, /* beta_mant */ |
| 356 | 51, /* beta_exp */ |
| 357 | |
| 358 | 1, /* perform_agc_softsplit */ |
| 359 | }; |
| 360 | |
| 361 | /* PLL Configuration for COFDM BW_MHz = 8.000000 |
| 362 | * With external clock = 30.000000 */ |
Harvey Harrison | b1721d0 | 2008-04-25 19:03:08 -0700 | [diff] [blame] | 363 | static struct dibx000_bandwidth_config xc3028_bw_config = { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 364 | 60000, /* internal */ |
| 365 | 30000, /* sampling */ |
| 366 | 1, /* pll_cfg: prediv */ |
| 367 | 8, /* pll_cfg: ratio */ |
| 368 | 3, /* pll_cfg: range */ |
| 369 | 1, /* pll_cfg: reset */ |
| 370 | 0, /* pll_cfg: bypass */ |
| 371 | 0, /* misc: refdiv */ |
| 372 | 0, /* misc: bypclk_div */ |
| 373 | 1, /* misc: IO_CLK_en_core */ |
| 374 | 1, /* misc: ADClkSrc */ |
| 375 | 0, /* misc: modulo */ |
| 376 | (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ |
| 377 | (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ |
| 378 | 20452225, /* timf */ |
| 379 | 30000000 /* xtal_hz */ |
| 380 | }; |
| 381 | |
| 382 | static struct dib7000p_config hauppauge_hvr1400_dib7000_config = { |
| 383 | .output_mpeg2_in_188_bytes = 1, |
| 384 | .hostbus_diversity = 1, |
| 385 | .tuner_is_baseband = 0, |
| 386 | .update_lna = NULL, |
| 387 | |
| 388 | .agc_config_count = 1, |
| 389 | .agc = &xc3028_agc_config, |
| 390 | .bw = &xc3028_bw_config, |
| 391 | |
| 392 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, |
| 393 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, |
| 394 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, |
| 395 | |
| 396 | .pwm_freq_div = 0, |
| 397 | .agc_control = NULL, |
| 398 | .spur_protect = 0, |
| 399 | |
| 400 | .output_mode = OUTMODE_MPEG2_SERIAL, |
| 401 | }; |
| 402 | |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 403 | static struct zl10353_config dvico_fusionhdtv_xc3028 = { |
| 404 | .demod_address = 0x0f, |
| 405 | .if2 = 45600, |
| 406 | .no_tuner = 1, |
Christopher Pascoe | d4dc673 | 2009-04-27 11:27:04 -0300 | [diff] [blame] | 407 | .disable_i2c_gate_ctrl = 1, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 408 | }; |
| 409 | |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 410 | static struct stv0900_reg stv0900_ts_regs[] = { |
| 411 | { R0900_TSGENERAL, 0x00 }, |
| 412 | { R0900_P1_TSSPEED, 0x40 }, |
| 413 | { R0900_P2_TSSPEED, 0x40 }, |
| 414 | { R0900_P1_TSCFGM, 0xc0 }, |
| 415 | { R0900_P2_TSCFGM, 0xc0 }, |
| 416 | { R0900_P1_TSCFGH, 0xe0 }, |
| 417 | { R0900_P2_TSCFGH, 0xe0 }, |
| 418 | { R0900_P1_TSCFGL, 0x20 }, |
| 419 | { R0900_P2_TSCFGL, 0x20 }, |
| 420 | { 0xffff, 0xff }, /* terminate */ |
| 421 | }; |
| 422 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 423 | static struct stv0900_config netup_stv0900_config = { |
| 424 | .demod_address = 0x68, |
Igor M. Liplianin | 29372a8 | 2009-10-17 08:58:26 -0300 | [diff] [blame] | 425 | .demod_mode = 1, /* dual */ |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 426 | .xtal = 8000000, |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 427 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 428 | .diseqc_mode = 2,/* 2/3 PWM */ |
Igor M. Liplianin | f867c3f | 2009-06-19 05:45:23 -0300 | [diff] [blame] | 429 | .ts_config_regs = stv0900_ts_regs, |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 430 | .tun1_maddress = 0,/* 0x60 */ |
| 431 | .tun2_maddress = 3,/* 0x63 */ |
| 432 | .tun1_adc = 1,/* 1 Vpp */ |
| 433 | .tun2_adc = 1,/* 1 Vpp */ |
| 434 | }; |
| 435 | |
| 436 | static struct stv6110_config netup_stv6110_tunerconfig_a = { |
| 437 | .i2c_address = 0x60, |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 438 | .mclk = 16000000, |
| 439 | .clk_div = 1, |
Abylay Ospan | 873688c | 2009-10-17 08:23:00 -0300 | [diff] [blame] | 440 | .gain = 8, /* +16 dB - maximum gain */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 441 | }; |
| 442 | |
| 443 | static struct stv6110_config netup_stv6110_tunerconfig_b = { |
| 444 | .i2c_address = 0x63, |
Abylay Ospan | 644c7ef0 | 2009-07-19 18:06:00 -0300 | [diff] [blame] | 445 | .mclk = 16000000, |
| 446 | .clk_div = 1, |
Abylay Ospan | 873688c | 2009-10-17 08:23:00 -0300 | [diff] [blame] | 447 | .gain = 8, /* +16 dB - maximum gain */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 448 | }; |
| 449 | |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 450 | static struct cx24116_config tbs_cx24116_config = { |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 451 | .demod_address = 0x55, |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 452 | }; |
| 453 | |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 454 | static struct ds3000_config tevii_ds3000_config = { |
| 455 | .demod_address = 0x68, |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 456 | }; |
| 457 | |
Igor M. Liplianin | c9b8b04 | 2009-01-17 12:23:31 -0300 | [diff] [blame] | 458 | static struct cx24116_config dvbworld_cx24116_config = { |
| 459 | .demod_address = 0x05, |
| 460 | }; |
| 461 | |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 462 | static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = { |
| 463 | .prod = LGS8GXX_PROD_LGS8GL5, |
| 464 | .demod_address = 0x19, |
| 465 | .serial_ts = 0, |
| 466 | .ts_clk_pol = 1, |
| 467 | .ts_clk_gated = 1, |
| 468 | .if_clk_freq = 30400, /* 30.4 MHz */ |
| 469 | .if_freq = 5380, /* 5.38 MHz */ |
| 470 | .if_neg_center = 1, |
| 471 | .ext_adc = 0, |
| 472 | .adc_signed = 0, |
| 473 | .if_neg_edge = 0, |
| 474 | }; |
| 475 | |
| 476 | static struct xc5000_config mygica_x8506_xc5000_config = { |
| 477 | .i2c_address = 0x61, |
| 478 | .if_khz = 5380, |
| 479 | }; |
| 480 | |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 481 | static int cx23885_dvb_set_frontend(struct dvb_frontend *fe, |
| 482 | struct dvb_frontend_parameters *param) |
| 483 | { |
| 484 | struct cx23885_tsport *port = fe->dvb->priv; |
| 485 | struct cx23885_dev *dev = port->dev; |
| 486 | |
| 487 | switch (dev->board) { |
| 488 | case CX23885_BOARD_HAUPPAUGE_HVR1275: |
| 489 | switch (param->u.vsb.modulation) { |
| 490 | case VSB_8: |
| 491 | cx23885_gpio_clear(dev, GPIO_5); |
| 492 | break; |
| 493 | case QAM_64: |
| 494 | case QAM_256: |
| 495 | default: |
| 496 | cx23885_gpio_set(dev, GPIO_5); |
| 497 | break; |
| 498 | } |
| 499 | break; |
David T.L. Wong | 6f0d8c0 | 2009-10-21 13:15:30 -0300 | [diff] [blame] | 500 | case CX23885_BOARD_MYGICA_X8506: |
| 501 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: |
| 502 | /* Select Digital TV */ |
| 503 | cx23885_gpio_set(dev, GPIO_0); |
| 504 | break; |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 505 | } |
Michael Krufky | 5bdd396 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 506 | return 0; |
Michael Krufky | f35b9e8 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 507 | } |
| 508 | |
Michael Krufky | 5bdd396 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 509 | static int cx23885_dvb_fe_ioctl_override(struct dvb_frontend *fe, |
| 510 | unsigned int cmd, void *parg, |
| 511 | unsigned int stage) |
| 512 | { |
| 513 | int err = 0; |
| 514 | |
| 515 | switch (stage) { |
| 516 | case DVB_FE_IOCTL_PRE: |
| 517 | |
| 518 | switch (cmd) { |
| 519 | case FE_SET_FRONTEND: |
| 520 | err = cx23885_dvb_set_frontend(fe, |
| 521 | (struct dvb_frontend_parameters *) parg); |
| 522 | break; |
| 523 | } |
| 524 | break; |
| 525 | |
| 526 | case DVB_FE_IOCTL_POST: |
| 527 | /* no post-ioctl handling required */ |
| 528 | break; |
| 529 | } |
| 530 | return err; |
| 531 | }; |
| 532 | |
| 533 | |
David Wong | 2365b2d | 2009-06-17 01:38:12 -0300 | [diff] [blame] | 534 | static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = { |
| 535 | .prod = LGS8GXX_PROD_LGS8G75, |
| 536 | .demod_address = 0x19, |
| 537 | .serial_ts = 0, |
| 538 | .ts_clk_pol = 1, |
| 539 | .ts_clk_gated = 1, |
| 540 | .if_clk_freq = 30400, /* 30.4 MHz */ |
| 541 | .if_freq = 6500, /* 6.50 MHz */ |
| 542 | .if_neg_center = 1, |
| 543 | .ext_adc = 0, |
| 544 | .adc_signed = 1, |
| 545 | .adc_vpp = 2, /* 1.6 Vpp */ |
| 546 | .if_neg_edge = 1, |
| 547 | }; |
| 548 | |
| 549 | static struct xc5000_config magicpro_prohdtve2_xc5000_config = { |
| 550 | .i2c_address = 0x61, |
| 551 | .if_khz = 6500, |
| 552 | }; |
| 553 | |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 554 | static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = { |
| 555 | .prod = ATBM8830_PROD_8830, |
| 556 | .demod_address = 0x44, |
| 557 | .serial_ts = 0, |
| 558 | .ts_sampling_edge = 1, |
| 559 | .ts_clk_gated = 0, |
| 560 | .osc_clk_freq = 30400, /* in kHz */ |
| 561 | .if_freq = 0, /* zero IF */ |
| 562 | .zif_swap_iq = 1, |
David Wong | c245c75 | 2009-11-28 08:36:31 -0300 | [diff] [blame] | 563 | .agc_min = 0x2E, |
| 564 | .agc_max = 0xFF, |
| 565 | .agc_hold_loop = 0, |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 566 | }; |
| 567 | |
| 568 | static struct max2165_config mygic_x8558pro_max2165_cfg1 = { |
| 569 | .i2c_address = 0x60, |
| 570 | .osc_clk = 20 |
| 571 | }; |
| 572 | |
| 573 | static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = { |
| 574 | .prod = ATBM8830_PROD_8830, |
| 575 | .demod_address = 0x44, |
| 576 | .serial_ts = 1, |
| 577 | .ts_sampling_edge = 1, |
| 578 | .ts_clk_gated = 0, |
| 579 | .osc_clk_freq = 30400, /* in kHz */ |
| 580 | .if_freq = 0, /* zero IF */ |
| 581 | .zif_swap_iq = 1, |
David Wong | c245c75 | 2009-11-28 08:36:31 -0300 | [diff] [blame] | 582 | .agc_min = 0x2E, |
| 583 | .agc_max = 0xFF, |
| 584 | .agc_hold_loop = 0, |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 585 | }; |
| 586 | |
| 587 | static struct max2165_config mygic_x8558pro_max2165_cfg2 = { |
| 588 | .i2c_address = 0x60, |
| 589 | .osc_clk = 20 |
| 590 | }; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 591 | static struct stv0367_config netup_stv0367_config[] = { |
| 592 | { |
| 593 | .demod_address = 0x1c, |
| 594 | .xtal = 27000000, |
| 595 | .if_khz = 4500, |
| 596 | .if_iq_mode = 0, |
| 597 | .ts_mode = 1, |
| 598 | .clk_pol = 0, |
| 599 | }, { |
| 600 | .demod_address = 0x1d, |
| 601 | .xtal = 27000000, |
| 602 | .if_khz = 4500, |
| 603 | .if_iq_mode = 0, |
| 604 | .ts_mode = 1, |
| 605 | .clk_pol = 0, |
| 606 | }, |
| 607 | }; |
| 608 | |
| 609 | static struct xc5000_config netup_xc5000_config[] = { |
| 610 | { |
| 611 | .i2c_address = 0x61, |
| 612 | .if_khz = 4500, |
| 613 | }, { |
| 614 | .i2c_address = 0x64, |
| 615 | .if_khz = 4500, |
| 616 | }, |
| 617 | }; |
| 618 | |
| 619 | int netup_altera_fpga_rw(void *device, int flag, int data, int read) |
| 620 | { |
| 621 | struct cx23885_dev *dev = (struct cx23885_dev *)device; |
| 622 | unsigned long timeout = jiffies + msecs_to_jiffies(1); |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 623 | uint32_t mem = 0; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 624 | |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 625 | mem = cx_read(MC417_RWD); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 626 | if (read) |
| 627 | cx_set(MC417_OEN, ALT_DATA); |
| 628 | else { |
| 629 | cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */ |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 630 | mem &= ~ALT_DATA; |
| 631 | mem |= (data & ALT_DATA); |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | if (flag) |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 635 | mem |= ALT_AD_RG; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 636 | else |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 637 | mem &= ~ALT_AD_RG; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 638 | |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 639 | mem &= ~ALT_CS; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 640 | if (read) |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 641 | mem = (mem & ~ALT_RD) | ALT_WR; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 642 | else |
Abylay Ospan | d164460 | 2011-01-02 09:10:00 -0300 | [diff] [blame^] | 643 | mem = (mem & ~ALT_WR) | ALT_RD; |
| 644 | |
| 645 | cx_write(MC417_RWD, mem); /* start RW cycle */ |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 646 | |
| 647 | for (;;) { |
| 648 | mem = cx_read(MC417_RWD); |
| 649 | if ((mem & ALT_RDY) == 0) |
| 650 | break; |
| 651 | if (time_after(jiffies, timeout)) |
| 652 | break; |
| 653 | udelay(1); |
| 654 | } |
| 655 | |
| 656 | cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS); |
| 657 | if (read) |
| 658 | return mem & ALT_DATA; |
| 659 | |
| 660 | return 0; |
| 661 | }; |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 662 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 663 | static int dvb_register(struct cx23885_tsport *port) |
| 664 | { |
| 665 | struct cx23885_dev *dev = port->dev; |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 666 | struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 667 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; |
| 668 | int mfe_shared = 0; /* bus not shared by default */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 669 | int ret; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 670 | |
Darron Broad | f972e0b | 2008-10-11 11:24:30 -0300 | [diff] [blame] | 671 | /* Get the first frontend */ |
Darron Broad | 92abe9e | 2008-10-11 11:18:53 -0300 | [diff] [blame] | 672 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 673 | if (!fe0) |
| 674 | return -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 675 | |
| 676 | /* init struct videobuf_dvb */ |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 677 | fe0->dvb.name = dev->name; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 678 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 679 | /* multi-frontend gate control is undefined or defaults to fe0 */ |
| 680 | port->frontends.gate = 0; |
| 681 | |
| 682 | /* Sets the gate control callback to be used by i2c command calls */ |
| 683 | port->gate_ctrl = cx23885_dvb_gate_ctrl; |
| 684 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 685 | /* init frontend */ |
| 686 | switch (dev->board) { |
Steven Toth | a77743b | 2007-08-22 21:01:20 -0300 | [diff] [blame] | 687 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 688 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 689 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 690 | &hauppauge_generic_config, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 691 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 692 | if (fe0->dvb.frontend != NULL) { |
| 693 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 694 | &i2c_bus->i2c_adap, |
Steven Toth | 86184e0 | 2007-09-04 21:40:47 -0300 | [diff] [blame] | 695 | &hauppauge_generic_tunerconfig, 0); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 696 | } |
| 697 | break; |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 698 | case CX23885_BOARD_HAUPPAUGE_HVR1270: |
Michael Krufky | d099bec | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 699 | case CX23885_BOARD_HAUPPAUGE_HVR1275: |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 700 | i2c_bus = &dev->i2c_bus[0]; |
| 701 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 702 | &hauppauge_lgdt3305_config, |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 703 | &i2c_bus->i2c_adap); |
| 704 | if (fe0->dvb.frontend != NULL) { |
| 705 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 706 | 0x60, &dev->i2c_bus[1].i2c_adap, |
Michael Krufky | 247bc54 | 2009-05-12 18:53:47 -0300 | [diff] [blame] | 707 | &hauppauge_hvr127x_config); |
Michael Krufky | a5dbf45 | 2009-05-03 23:27:02 -0300 | [diff] [blame] | 708 | } |
| 709 | break; |
Michael Krufky | 19bc579 | 2009-05-08 16:05:29 -0300 | [diff] [blame] | 710 | case CX23885_BOARD_HAUPPAUGE_HVR1255: |
| 711 | i2c_bus = &dev->i2c_bus[0]; |
| 712 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
| 713 | &hcw_s5h1411_config, |
| 714 | &i2c_bus->i2c_adap); |
| 715 | if (fe0->dvb.frontend != NULL) { |
| 716 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 717 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 718 | &hauppauge_tda18271_config); |
| 719 | } |
| 720 | break; |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 721 | case CX23885_BOARD_HAUPPAUGE_HVR1800: |
| 722 | i2c_bus = &dev->i2c_bus[0]; |
Darron Broad | 92abe9e | 2008-10-11 11:18:53 -0300 | [diff] [blame] | 723 | switch (alt_tuner) { |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 724 | case 1: |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 725 | fe0->dvb.frontend = |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 726 | dvb_attach(s5h1409_attach, |
| 727 | &hauppauge_ezqam_config, |
| 728 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 729 | if (fe0->dvb.frontend != NULL) { |
| 730 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 731 | &dev->i2c_bus[1].i2c_adap, 0x42, |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 732 | &tda829x_no_probe); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 733 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
Michael Krufky | 4041f1a | 2007-12-24 04:52:08 -0300 | [diff] [blame] | 734 | 0x60, &dev->i2c_bus[1].i2c_adap, |
Michael Krufky | f21e0d7 | 2008-01-02 03:01:54 -0300 | [diff] [blame] | 735 | &hauppauge_tda18271_config); |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 736 | } |
| 737 | break; |
| 738 | case 0: |
| 739 | default: |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 740 | fe0->dvb.frontend = |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 741 | dvb_attach(s5h1409_attach, |
| 742 | &hauppauge_generic_config, |
| 743 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 744 | if (fe0->dvb.frontend != NULL) |
| 745 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 746 | &i2c_bus->i2c_adap, |
| 747 | &hauppauge_generic_tunerconfig, 0); |
| 748 | break; |
| 749 | } |
| 750 | break; |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 751 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 752 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 753 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 754 | &hauppauge_hvr1800lp_config, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 755 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 756 | if (fe0->dvb.frontend != NULL) { |
| 757 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 758 | &i2c_bus->i2c_adap, |
Steven Toth | fc959be | 2007-09-08 19:08:17 -0300 | [diff] [blame] | 759 | &hauppauge_generic_tunerconfig, 0); |
| 760 | } |
| 761 | break; |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 762 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 763 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 764 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 765 | &fusionhdtv_5_express, |
Michael Krufky | f139fa7 | 2007-09-09 03:55:34 -0300 | [diff] [blame] | 766 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 767 | if (fe0->dvb.frontend != NULL) { |
| 768 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
Michael Krufky | 827855d | 2008-04-22 14:46:16 -0300 | [diff] [blame] | 769 | &i2c_bus->i2c_adap, 0x61, |
| 770 | TUNER_LG_TDVS_H06XF); |
Michael Krufky | 9bc37ca | 2007-09-08 15:17:13 -0300 | [diff] [blame] | 771 | } |
| 772 | break; |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 773 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| 774 | i2c_bus = &dev->i2c_bus[1]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 775 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 776 | &hauppauge_hvr1500q_config, |
| 777 | &dev->i2c_bus[0].i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 778 | if (fe0->dvb.frontend != NULL) |
| 779 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
Michael Krufky | 3065096 | 2008-09-06 14:56:58 -0300 | [diff] [blame] | 780 | &i2c_bus->i2c_adap, |
| 781 | &hauppauge_hvr1500q_tunerconfig); |
Steven Toth | d1987d5 | 2007-12-18 01:57:06 -0300 | [diff] [blame] | 782 | break; |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 783 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
| 784 | i2c_bus = &dev->i2c_bus[1]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 785 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 786 | &hauppauge_hvr1500_config, |
| 787 | &dev->i2c_bus[0].i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 788 | if (fe0->dvb.frontend != NULL) { |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 789 | struct dvb_frontend *fe; |
| 790 | struct xc2028_config cfg = { |
| 791 | .i2c_adap = &i2c_bus->i2c_adap, |
| 792 | .i2c_addr = 0x61, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 793 | }; |
| 794 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 795 | .fname = XC2028_DEFAULT_FIRMWARE, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 796 | .max_len = 64, |
Steven Toth | 52c3d29 | 2009-04-20 22:42:00 -0300 | [diff] [blame] | 797 | .demod = XC3028_FE_OREN538, |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 798 | }; |
| 799 | |
| 800 | fe = dvb_attach(xc2028_attach, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 801 | fe0->dvb.frontend, &cfg); |
Michael Krufky | 07b4a83 | 2007-12-18 01:09:11 -0300 | [diff] [blame] | 802 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 803 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 804 | } |
| 805 | break; |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 806 | case CX23885_BOARD_HAUPPAUGE_HVR1200: |
Steven Toth | a780a31 | 2008-04-19 01:25:52 -0300 | [diff] [blame] | 807 | case CX23885_BOARD_HAUPPAUGE_HVR1700: |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 808 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 809 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 810 | &hauppauge_hvr1200_config, |
| 811 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 812 | if (fe0->dvb.frontend != NULL) { |
| 813 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 814 | &dev->i2c_bus[1].i2c_adap, 0x42, |
| 815 | &tda829x_no_probe); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 816 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
Steven Toth | b3ea016 | 2008-04-19 01:14:19 -0300 | [diff] [blame] | 817 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 818 | &hauppauge_hvr1200_tuner_config); |
| 819 | } |
| 820 | break; |
Michael Krufky | 6b926ec | 2009-05-12 17:32:17 -0300 | [diff] [blame] | 821 | case CX23885_BOARD_HAUPPAUGE_HVR1210: |
| 822 | i2c_bus = &dev->i2c_bus[0]; |
| 823 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
| 824 | &hauppauge_hvr1210_config, |
| 825 | &i2c_bus->i2c_adap); |
| 826 | if (fe0->dvb.frontend != NULL) { |
| 827 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 828 | 0x60, &dev->i2c_bus[1].i2c_adap, |
| 829 | &hauppauge_hvr1210_tuner_config); |
| 830 | } |
| 831 | break; |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 832 | case CX23885_BOARD_HAUPPAUGE_HVR1400: |
| 833 | i2c_bus = &dev->i2c_bus[0]; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 834 | fe0->dvb.frontend = dvb_attach(dib7000p_attach, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 835 | &i2c_bus->i2c_adap, |
| 836 | 0x12, &hauppauge_hvr1400_dib7000_config); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 837 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 838 | struct dvb_frontend *fe; |
| 839 | struct xc2028_config cfg = { |
| 840 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
| 841 | .i2c_addr = 0x64, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 842 | }; |
| 843 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 844 | .fname = XC3028L_DEFAULT_FIRMWARE, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 845 | .max_len = 64, |
| 846 | .demod = 5000, |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 847 | /* This is true for all demods with |
| 848 | v36 firmware? */ |
Mauro Carvalho Chehab | 0975fc6 | 2008-09-28 02:24:44 -0300 | [diff] [blame] | 849 | .type = XC2028_D2633, |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 850 | }; |
| 851 | |
| 852 | fe = dvb_attach(xc2028_attach, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 853 | fe0->dvb.frontend, &cfg); |
Steven Toth | 6676237 | 2008-04-22 15:38:26 -0300 | [diff] [blame] | 854 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 855 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 856 | } |
| 857 | break; |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 858 | case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: |
| 859 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
| 860 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 861 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 862 | &dvico_s5h1409_config, |
| 863 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 864 | if (fe0->dvb.frontend == NULL) |
| 865 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
Michael Krufky | 52b5045 | 2008-07-09 02:18:49 -0300 | [diff] [blame] | 866 | &dvico_s5h1411_config, |
| 867 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 868 | if (fe0->dvb.frontend != NULL) |
| 869 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
Michael Krufky | 3065096 | 2008-09-06 14:56:58 -0300 | [diff] [blame] | 870 | &i2c_bus->i2c_adap, |
| 871 | &dvico_xc5000_tunerconfig); |
Michael Krufky | 335377b | 2008-05-07 01:43:10 -0300 | [diff] [blame] | 872 | break; |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 873 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { |
| 874 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
| 875 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 876 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 877 | &dvico_fusionhdtv_xc3028, |
| 878 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 879 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 880 | struct dvb_frontend *fe; |
| 881 | struct xc2028_config cfg = { |
| 882 | .i2c_adap = &i2c_bus->i2c_adap, |
| 883 | .i2c_addr = 0x61, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 884 | }; |
| 885 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 886 | .fname = XC2028_DEFAULT_FIRMWARE, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 887 | .max_len = 64, |
| 888 | .demod = XC3028_FE_ZARLINK456, |
| 889 | }; |
| 890 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 891 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
Steven Toth | aef2d18 | 2008-08-04 21:39:53 -0300 | [diff] [blame] | 892 | &cfg); |
| 893 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 894 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 895 | } |
| 896 | break; |
| 897 | } |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 898 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: |
Igor M. Liplianin | 9bb1b7e | 2008-11-23 14:11:16 -0300 | [diff] [blame] | 899 | case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: |
Vladimir Geroy | 34e383d | 2009-09-18 18:55:47 -0300 | [diff] [blame] | 900 | case CX23885_BOARD_COMPRO_VIDEOMATE_E800: |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 901 | i2c_bus = &dev->i2c_bus[0]; |
| 902 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 903 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 904 | &dvico_fusionhdtv_xc3028, |
| 905 | &i2c_bus->i2c_adap); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 906 | if (fe0->dvb.frontend != NULL) { |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 907 | struct dvb_frontend *fe; |
| 908 | struct xc2028_config cfg = { |
| 909 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
| 910 | .i2c_addr = 0x61, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 911 | }; |
| 912 | static struct xc2028_ctrl ctl = { |
Michael Krufky | ef80bfe | 2008-09-16 02:15:30 -0300 | [diff] [blame] | 913 | .fname = XC2028_DEFAULT_FIRMWARE, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 914 | .max_len = 64, |
| 915 | .demod = XC3028_FE_ZARLINK456, |
| 916 | }; |
| 917 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 918 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
Steven Toth | 4c56b04 | 2008-08-12 13:30:03 -0300 | [diff] [blame] | 919 | &cfg); |
| 920 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
| 921 | fe->ops.tuner_ops.set_config(fe, &ctl); |
| 922 | } |
| 923 | break; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 924 | case CX23885_BOARD_TBS_6920: |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 925 | i2c_bus = &dev->i2c_bus[1]; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 926 | |
| 927 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 928 | &tbs_cx24116_config, |
| 929 | &i2c_bus->i2c_adap); |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 930 | if (fe0->dvb.frontend != NULL) |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 931 | fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; |
Igor M. Liplianin | 96318d0 | 2009-01-17 12:11:20 -0300 | [diff] [blame] | 932 | |
| 933 | break; |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 934 | case CX23885_BOARD_TEVII_S470: |
| 935 | i2c_bus = &dev->i2c_bus[1]; |
| 936 | |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 937 | fe0->dvb.frontend = dvb_attach(ds3000_attach, |
| 938 | &tevii_ds3000_config, |
| 939 | &i2c_bus->i2c_adap); |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 940 | if (fe0->dvb.frontend != NULL) |
Igor M. Liplianin | 09ea33e | 2009-11-24 20:16:04 -0300 | [diff] [blame] | 941 | fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; |
Igor M. Liplianin | 579943f | 2009-01-17 12:18:26 -0300 | [diff] [blame] | 942 | |
| 943 | break; |
Igor M. Liplianin | c9b8b04 | 2009-01-17 12:23:31 -0300 | [diff] [blame] | 944 | case CX23885_BOARD_DVBWORLD_2005: |
| 945 | i2c_bus = &dev->i2c_bus[1]; |
| 946 | |
| 947 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
| 948 | &dvbworld_cx24116_config, |
| 949 | &i2c_bus->i2c_adap); |
| 950 | break; |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 951 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: |
| 952 | i2c_bus = &dev->i2c_bus[0]; |
| 953 | switch (port->nr) { |
| 954 | /* port B */ |
| 955 | case 1: |
| 956 | fe0->dvb.frontend = dvb_attach(stv0900_attach, |
| 957 | &netup_stv0900_config, |
| 958 | &i2c_bus->i2c_adap, 0); |
| 959 | if (fe0->dvb.frontend != NULL) { |
| 960 | if (dvb_attach(stv6110_attach, |
| 961 | fe0->dvb.frontend, |
| 962 | &netup_stv6110_tunerconfig_a, |
| 963 | &i2c_bus->i2c_adap)) { |
| 964 | if (!dvb_attach(lnbh24_attach, |
| 965 | fe0->dvb.frontend, |
| 966 | &i2c_bus->i2c_adap, |
Abylay Ospan | 9329fb5 | 2009-10-17 08:38:45 -0300 | [diff] [blame] | 967 | LNBH24_PCL | LNBH24_TTX, |
| 968 | LNBH24_TEN, 0x09)) |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 969 | printk(KERN_ERR |
| 970 | "No LNBH24 found!\n"); |
| 971 | |
| 972 | } |
| 973 | } |
| 974 | break; |
| 975 | /* port C */ |
| 976 | case 2: |
| 977 | fe0->dvb.frontend = dvb_attach(stv0900_attach, |
| 978 | &netup_stv0900_config, |
| 979 | &i2c_bus->i2c_adap, 1); |
| 980 | if (fe0->dvb.frontend != NULL) { |
| 981 | if (dvb_attach(stv6110_attach, |
| 982 | fe0->dvb.frontend, |
| 983 | &netup_stv6110_tunerconfig_b, |
| 984 | &i2c_bus->i2c_adap)) { |
| 985 | if (!dvb_attach(lnbh24_attach, |
| 986 | fe0->dvb.frontend, |
| 987 | &i2c_bus->i2c_adap, |
Abylay Ospan | 9329fb5 | 2009-10-17 08:38:45 -0300 | [diff] [blame] | 988 | LNBH24_PCL | LNBH24_TTX, |
| 989 | LNBH24_TEN, 0x0a)) |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 990 | printk(KERN_ERR |
| 991 | "No LNBH24 found!\n"); |
| 992 | |
| 993 | } |
| 994 | } |
| 995 | break; |
| 996 | } |
| 997 | break; |
David Wong | 493b712 | 2009-05-18 05:25:49 -0300 | [diff] [blame] | 998 | case CX23885_BOARD_MYGICA_X8506: |
| 999 | i2c_bus = &dev->i2c_bus[0]; |
| 1000 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1001 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
| 1002 | &mygica_x8506_lgs8gl5_config, |
| 1003 | &i2c_bus->i2c_adap); |
| 1004 | if (fe0->dvb.frontend != NULL) { |
| 1005 | dvb_attach(xc5000_attach, |
| 1006 | fe0->dvb.frontend, |
| 1007 | &i2c_bus2->i2c_adap, |
| 1008 | &mygica_x8506_xc5000_config); |
| 1009 | } |
| 1010 | break; |
David Wong | 2365b2d | 2009-06-17 01:38:12 -0300 | [diff] [blame] | 1011 | case CX23885_BOARD_MAGICPRO_PROHDTVE2: |
| 1012 | i2c_bus = &dev->i2c_bus[0]; |
| 1013 | i2c_bus2 = &dev->i2c_bus[1]; |
| 1014 | fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, |
| 1015 | &magicpro_prohdtve2_lgs8g75_config, |
| 1016 | &i2c_bus->i2c_adap); |
| 1017 | if (fe0->dvb.frontend != NULL) { |
| 1018 | dvb_attach(xc5000_attach, |
| 1019 | fe0->dvb.frontend, |
| 1020 | &i2c_bus2->i2c_adap, |
| 1021 | &magicpro_prohdtve2_xc5000_config); |
| 1022 | } |
| 1023 | break; |
Steven Toth | 13697380 | 2009-07-20 15:37:25 -0300 | [diff] [blame] | 1024 | case CX23885_BOARD_HAUPPAUGE_HVR1850: |
Michael Krufky | aee0b24 | 2009-11-11 01:52:45 -0300 | [diff] [blame] | 1025 | case CX23885_BOARD_HAUPPAUGE_HVR1290: |
Steven Toth | 13697380 | 2009-07-20 15:37:25 -0300 | [diff] [blame] | 1026 | i2c_bus = &dev->i2c_bus[0]; |
| 1027 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
| 1028 | &hcw_s5h1411_config, |
| 1029 | &i2c_bus->i2c_adap); |
| 1030 | if (fe0->dvb.frontend != NULL) |
| 1031 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
| 1032 | 0x60, &dev->i2c_bus[0].i2c_adap, |
| 1033 | &hauppauge_tda18271_config); |
| 1034 | break; |
David T. L. Wong | ea5697f | 2009-10-26 08:54:04 -0300 | [diff] [blame] | 1035 | case CX23885_BOARD_MYGICA_X8558PRO: |
| 1036 | switch (port->nr) { |
| 1037 | /* port B */ |
| 1038 | case 1: |
| 1039 | i2c_bus = &dev->i2c_bus[0]; |
| 1040 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
| 1041 | &mygica_x8558pro_atbm8830_cfg1, |
| 1042 | &i2c_bus->i2c_adap); |
| 1043 | if (fe0->dvb.frontend != NULL) { |
| 1044 | dvb_attach(max2165_attach, |
| 1045 | fe0->dvb.frontend, |
| 1046 | &i2c_bus->i2c_adap, |
| 1047 | &mygic_x8558pro_max2165_cfg1); |
| 1048 | } |
| 1049 | break; |
| 1050 | /* port C */ |
| 1051 | case 2: |
| 1052 | i2c_bus = &dev->i2c_bus[1]; |
| 1053 | fe0->dvb.frontend = dvb_attach(atbm8830_attach, |
| 1054 | &mygica_x8558pro_atbm8830_cfg2, |
| 1055 | &i2c_bus->i2c_adap); |
| 1056 | if (fe0->dvb.frontend != NULL) { |
| 1057 | dvb_attach(max2165_attach, |
| 1058 | fe0->dvb.frontend, |
| 1059 | &i2c_bus->i2c_adap, |
| 1060 | &mygic_x8558pro_max2165_cfg2); |
| 1061 | } |
| 1062 | break; |
| 1063 | } |
| 1064 | break; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1065 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: |
| 1066 | i2c_bus = &dev->i2c_bus[0]; |
| 1067 | mfe_shared = 1;/* MFE */ |
| 1068 | port->frontends.gate = 0;/* not clear for me yet */ |
| 1069 | /* ports B, C */ |
| 1070 | /* MFE frontend 1 DVB-T */ |
| 1071 | fe0->dvb.frontend = dvb_attach(stv0367ter_attach, |
| 1072 | &netup_stv0367_config[port->nr - 1], |
| 1073 | &i2c_bus->i2c_adap); |
| 1074 | if (fe0->dvb.frontend != NULL) |
| 1075 | if (NULL == dvb_attach(xc5000_attach, |
| 1076 | fe0->dvb.frontend, |
| 1077 | &i2c_bus->i2c_adap, |
| 1078 | &netup_xc5000_config[port->nr - 1])) |
| 1079 | goto frontend_detach; |
| 1080 | /* MFE frontend 2 */ |
| 1081 | fe1 = videobuf_dvb_get_frontend(&port->frontends, 2); |
| 1082 | if (fe1 == NULL) |
| 1083 | goto frontend_detach; |
| 1084 | /* DVB-C init */ |
| 1085 | fe1->dvb.frontend = dvb_attach(stv0367cab_attach, |
| 1086 | &netup_stv0367_config[port->nr - 1], |
| 1087 | &i2c_bus->i2c_adap); |
| 1088 | if (fe1->dvb.frontend != NULL) { |
| 1089 | fe1->dvb.frontend->id = 1; |
| 1090 | if (NULL == dvb_attach(xc5000_attach, |
| 1091 | fe1->dvb.frontend, |
| 1092 | &i2c_bus->i2c_adap, |
| 1093 | &netup_xc5000_config[port->nr - 1])) |
| 1094 | goto frontend_detach; |
| 1095 | } |
| 1096 | break; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1097 | default: |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1098 | printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " |
| 1099 | " isn't supported yet\n", |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1100 | dev->name); |
| 1101 | break; |
| 1102 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1103 | |
| 1104 | if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) { |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1105 | printk(KERN_ERR "%s: frontend initialization failed\n", |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1106 | dev->name); |
| 1107 | goto frontend_detach; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1108 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1109 | |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 1110 | /* define general-purpose callback pointer */ |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1111 | fe0->dvb.frontend->callback = cx23885_tuner_callback; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1112 | if (fe1) |
| 1113 | fe1->dvb.frontend->callback = cx23885_tuner_callback; |
| 1114 | #if 0 |
| 1115 | /* Ensure all frontends negotiate bus access */ |
| 1116 | fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; |
| 1117 | if (fe1) |
| 1118 | fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; |
| 1119 | #endif |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1120 | |
| 1121 | /* Put the analog decoder in standby to keep it quiet */ |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 1122 | call_all(dev, core, s_power, 0); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1123 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1124 | if (fe0->dvb.frontend->ops.analog_ops.standby) |
| 1125 | fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); |
Michael Krufky | 3ba71d2 | 2007-12-07 01:40:36 -0300 | [diff] [blame] | 1126 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1127 | /* register everything */ |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1128 | ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port, |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1129 | &dev->pci->dev, adapter_nr, mfe_shared, |
Michael Krufky | 5bdd396 | 2009-05-08 22:39:24 -0300 | [diff] [blame] | 1130 | cx23885_dvb_fe_ioctl_override); |
Abylay Ospan | bee3019 | 2010-06-25 08:01:28 -0300 | [diff] [blame] | 1131 | if (ret) |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1132 | goto frontend_detach; |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1133 | |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1134 | /* init CI & MAC */ |
| 1135 | switch (dev->board) { |
| 1136 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: { |
| 1137 | static struct netup_card_info cinfo; |
| 1138 | |
| 1139 | netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo); |
| 1140 | memcpy(port->frontends.adapter.proposed_mac, |
| 1141 | cinfo.port[port->nr - 1].mac, 6); |
hartleys | be39515 | 2009-12-30 16:08:57 -0300 | [diff] [blame] | 1142 | printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n", |
| 1143 | port->nr, port->frontends.adapter.proposed_mac); |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1144 | |
| 1145 | netup_ci_init(port); |
| 1146 | break; |
| 1147 | } |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1148 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: { |
| 1149 | struct altera_ci_config netup_ci_cfg = { |
| 1150 | .dev = dev,/* magic number to identify*/ |
| 1151 | .adapter = &port->frontends.adapter,/* for CI */ |
| 1152 | .demux = &fe0->dvb.demux,/* for hw pid filter */ |
| 1153 | .fpga_rw = netup_altera_fpga_rw, |
| 1154 | }; |
| 1155 | |
| 1156 | altera_ci_init(&netup_ci_cfg, port->nr); |
| 1157 | break; |
| 1158 | } |
Pierre Gronlier | 16bfdaa4 | 2010-04-26 13:26:29 -0300 | [diff] [blame] | 1159 | case CX23885_BOARD_TEVII_S470: { |
| 1160 | u8 eeprom[256]; /* 24C02 i2c eeprom */ |
| 1161 | |
| 1162 | if (port->nr != 1) |
| 1163 | break; |
| 1164 | |
| 1165 | /* Read entire EEPROM */ |
| 1166 | dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; |
| 1167 | tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); |
Andy Shevchenko | 5cac1f6 | 2010-09-11 14:33:28 -0300 | [diff] [blame] | 1168 | printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0); |
Pierre Gronlier | 16bfdaa4 | 2010-04-26 13:26:29 -0300 | [diff] [blame] | 1169 | memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); |
| 1170 | break; |
| 1171 | } |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | return ret; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1175 | |
| 1176 | frontend_detach: |
| 1177 | port->gate_ctrl = NULL; |
| 1178 | videobuf_dvb_dealloc_frontends(&port->frontends); |
| 1179 | return -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | int cx23885_dvb_register(struct cx23885_tsport *port) |
| 1183 | { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1184 | |
| 1185 | struct videobuf_dvb_frontend *fe0; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1186 | struct cx23885_dev *dev = port->dev; |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1187 | int err, i; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1188 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1189 | /* Here we need to allocate the correct number of frontends, |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 1190 | * as reflected in the cards struct. The reality is that currently |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1191 | * no cx23885 boards support this - yet. But, if we don't modify this |
| 1192 | * code then the second frontend would never be allocated (later) |
| 1193 | * and fail with error before the attach in dvb_register(). |
| 1194 | * Without these changes we risk an OOPS later. The changes here |
| 1195 | * are for safety, and should provide a good foundation for the |
| 1196 | * future addition of any multi-frontend cx23885 based boards. |
| 1197 | */ |
| 1198 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, |
| 1199 | port->num_frontends); |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1200 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1201 | for (i = 1; i <= port->num_frontends; i++) { |
Darron Broad | 96b7a1a | 2008-10-15 20:26:34 -0300 | [diff] [blame] | 1202 | if (videobuf_dvb_alloc_frontend( |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1203 | &port->frontends, i) == NULL) { |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1204 | printk(KERN_ERR "%s() failed to alloc\n", __func__); |
| 1205 | return -ENOMEM; |
| 1206 | } |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1207 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1208 | fe0 = videobuf_dvb_get_frontend(&port->frontends, i); |
| 1209 | if (!fe0) |
| 1210 | err = -EINVAL; |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1211 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1212 | dprintk(1, "%s\n", __func__); |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1213 | dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1214 | dev->board, |
| 1215 | dev->name, |
| 1216 | dev->pci_bus, |
| 1217 | dev->pci_slot); |
| 1218 | |
| 1219 | err = -ENODEV; |
| 1220 | |
| 1221 | /* dvb stuff */ |
| 1222 | /* We have to init the queue for each frontend on a port. */ |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1223 | printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); |
| 1224 | videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, |
| 1225 | &dev->pci->dev, &port->slock, |
Michael Krufky | 44a6481 | 2007-03-20 23:00:18 -0300 | [diff] [blame] | 1226 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, |
Hans Verkuil | 08bff03 | 2010-09-20 17:39:46 -0300 | [diff] [blame] | 1227 | sizeof(struct cx23885_buffer), port, NULL); |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1228 | } |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1229 | err = dvb_register(port); |
| 1230 | if (err != 0) |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1231 | printk(KERN_ERR "%s() dvb_register failed err = %d\n", |
| 1232 | __func__, err); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1233 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1234 | return err; |
| 1235 | } |
| 1236 | |
| 1237 | int cx23885_dvb_unregister(struct cx23885_tsport *port) |
| 1238 | { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1239 | struct videobuf_dvb_frontend *fe0; |
| 1240 | |
Steven Toth | eb0c58b | 2008-10-11 12:34:39 -0300 | [diff] [blame] | 1241 | /* FIXME: in an error condition where the we have |
| 1242 | * an expected number of frontends (attach problem) |
| 1243 | * then this might not clean up correctly, if 1 |
| 1244 | * is invalid. |
| 1245 | * This comment only applies to future boards IF they |
| 1246 | * implement MFE support. |
| 1247 | */ |
Darron Broad | 92abe9e | 2008-10-11 11:18:53 -0300 | [diff] [blame] | 1248 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); |
Steven Toth | 9c8ced5 | 2008-10-16 20:18:44 -0300 | [diff] [blame] | 1249 | if (fe0->dvb.frontend) |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 1250 | videobuf_dvb_unregister_bus(&port->frontends); |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1251 | |
Hans Verkuil | afd9666 | 2009-03-13 13:24:19 -0300 | [diff] [blame] | 1252 | switch (port->dev->board) { |
| 1253 | case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: |
| 1254 | netup_ci_exit(port); |
| 1255 | break; |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1256 | case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: |
| 1257 | altera_ci_release(port->dev, port->nr); |
| 1258 | break; |
Hans Verkuil | afd9666 | 2009-03-13 13:24:19 -0300 | [diff] [blame] | 1259 | } |
Igor M. Liplianin | 5a23b07 | 2009-03-03 12:06:09 -0300 | [diff] [blame] | 1260 | |
Igor M. Liplianin | 78db854 | 2011-01-25 17:04:00 -0300 | [diff] [blame] | 1261 | port->gate_ctrl = NULL; |
| 1262 | |
Steven Toth | d19770e | 2007-03-11 20:44:05 -0300 | [diff] [blame] | 1263 | return 0; |
| 1264 | } |
Michael Krufky | 44a6481 | 2007-03-20 23:00:18 -0300 | [diff] [blame] | 1265 | |