Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1 | /* |
Sri Deevi | b925517 | 2009-03-04 17:49:01 -0300 | [diff] [blame] | 2 | cx231xx-cards.c - driver for Conexant Cx23100/101/102 |
| 3 | USB video capture devices |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 4 | |
| 5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> |
Sri Deevi | b925517 | 2009-03-04 17:49:01 -0300 | [diff] [blame] | 6 | Based on em28xx driver |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | */ |
| 22 | |
Mauro Carvalho Chehab | 589dadf | 2014-11-01 08:09:44 -0300 | [diff] [blame] | 23 | #include "cx231xx.h" |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 24 | #include <linux/init.h> |
| 25 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 27 | #include <linux/delay.h> |
| 28 | #include <linux/i2c.h> |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 29 | #include <media/tuner.h> |
| 30 | #include <media/tveeprom.h> |
| 31 | #include <media/v4l2-common.h> |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 32 | |
| 33 | #include <media/cx25840.h> |
Mauro Carvalho Chehab | 3bfb317 | 2010-09-03 10:50:24 -0300 | [diff] [blame] | 34 | #include "dvb-usb-ids.h" |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 35 | #include "xc5000.h" |
Mauro Carvalho Chehab | 55fa288 | 2010-09-29 11:07:08 -0300 | [diff] [blame] | 36 | #include "tda18271.h" |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 37 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 38 | |
| 39 | static int tuner = -1; |
| 40 | module_param(tuner, int, 0444); |
| 41 | MODULE_PARM_DESC(tuner, "tuner type"); |
| 42 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 43 | static int transfer_mode = 1; |
| 44 | module_param(transfer_mode, int, 0444); |
| 45 | MODULE_PARM_DESC(transfer_mode, "transfer mode (1-ISO or 0-BULK)"); |
| 46 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 47 | static unsigned int disable_ir; |
| 48 | module_param(disable_ir, int, 0444); |
| 49 | MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); |
| 50 | |
| 51 | /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */ |
| 52 | static unsigned long cx231xx_devused; |
| 53 | |
| 54 | /* |
| 55 | * Reset sequences for analog/digital modes |
| 56 | */ |
| 57 | |
| 58 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 59 | {0x03, 0x01, 10}, |
| 60 | {0x03, 0x00, 30}, |
| 61 | {0x03, 0x01, 10}, |
| 62 | {-1, -1, -1}, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 63 | }; |
| 64 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 65 | /* |
| 66 | * Board definitions |
| 67 | */ |
| 68 | struct cx231xx_board cx231xx_boards[] = { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 69 | [CX231XX_BOARD_UNKNOWN] = { |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 70 | .name = "Unknown CX231xx video grabber", |
| 71 | .tuner_type = TUNER_ABSENT, |
| 72 | .input = {{ |
| 73 | .type = CX231XX_VMUX_TELEVISION, |
| 74 | .vmux = CX231XX_VIN_3_1, |
| 75 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 76 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 77 | }, { |
| 78 | .type = CX231XX_VMUX_COMPOSITE1, |
| 79 | .vmux = CX231XX_VIN_2_1, |
| 80 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 81 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 82 | }, { |
| 83 | .type = CX231XX_VMUX_SVIDEO, |
| 84 | .vmux = CX231XX_VIN_1_1 | |
| 85 | (CX231XX_VIN_1_2 << 8) | |
| 86 | CX25840_SVIDEO_ON, |
| 87 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 88 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 89 | } |
| 90 | }, |
| 91 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 92 | [CX231XX_BOARD_CNXT_CARRAERA] = { |
| 93 | .name = "Conexant Hybrid TV - CARRAERA", |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 94 | .tuner_type = TUNER_XC5000, |
| 95 | .tuner_addr = 0x61, |
| 96 | .tuner_gpio = RDE250_XCV_TUNER, |
| 97 | .tuner_sif_gpio = 0x05, |
| 98 | .tuner_scl_gpio = 0x1a, |
| 99 | .tuner_sda_gpio = 0x1b, |
| 100 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 101 | .output_mode = OUT_MODE_VIP11, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 102 | .demod_xfer_mode = 0, |
| 103 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 104 | .agc_analog_digital_select_gpio = 0x0c, |
| 105 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 106 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 107 | .demod_i2c_master = I2C_2, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 108 | .has_dvb = 1, |
| 109 | .demod_addr = 0x02, |
| 110 | .norm = V4L2_STD_PAL, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 111 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 112 | .input = {{ |
| 113 | .type = CX231XX_VMUX_TELEVISION, |
| 114 | .vmux = CX231XX_VIN_3_1, |
| 115 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 116 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 117 | }, { |
| 118 | .type = CX231XX_VMUX_COMPOSITE1, |
| 119 | .vmux = CX231XX_VIN_2_1, |
| 120 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 121 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 122 | }, { |
| 123 | .type = CX231XX_VMUX_SVIDEO, |
| 124 | .vmux = CX231XX_VIN_1_1 | |
| 125 | (CX231XX_VIN_1_2 << 8) | |
| 126 | CX25840_SVIDEO_ON, |
| 127 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 128 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 129 | } |
| 130 | }, |
| 131 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 132 | [CX231XX_BOARD_CNXT_SHELBY] = { |
| 133 | .name = "Conexant Hybrid TV - SHELBY", |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 134 | .tuner_type = TUNER_XC5000, |
| 135 | .tuner_addr = 0x61, |
| 136 | .tuner_gpio = RDE250_XCV_TUNER, |
| 137 | .tuner_sif_gpio = 0x05, |
| 138 | .tuner_scl_gpio = 0x1a, |
| 139 | .tuner_sda_gpio = 0x1b, |
| 140 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 141 | .output_mode = OUT_MODE_VIP11, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 142 | .demod_xfer_mode = 0, |
| 143 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 144 | .agc_analog_digital_select_gpio = 0x0c, |
| 145 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 146 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 147 | .demod_i2c_master = I2C_2, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 148 | .has_dvb = 1, |
| 149 | .demod_addr = 0x32, |
| 150 | .norm = V4L2_STD_NTSC, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 151 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 152 | .input = {{ |
| 153 | .type = CX231XX_VMUX_TELEVISION, |
| 154 | .vmux = CX231XX_VIN_3_1, |
| 155 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 156 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 157 | }, { |
| 158 | .type = CX231XX_VMUX_COMPOSITE1, |
| 159 | .vmux = CX231XX_VIN_2_1, |
| 160 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 161 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 162 | }, { |
| 163 | .type = CX231XX_VMUX_SVIDEO, |
| 164 | .vmux = CX231XX_VIN_1_1 | |
| 165 | (CX231XX_VIN_1_2 << 8) | |
| 166 | CX25840_SVIDEO_ON, |
| 167 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 168 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 169 | } |
| 170 | }, |
| 171 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 172 | [CX231XX_BOARD_CNXT_RDE_253S] = { |
| 173 | .name = "Conexant Hybrid TV - RDE253S", |
| 174 | .tuner_type = TUNER_NXP_TDA18271, |
| 175 | .tuner_addr = 0x60, |
| 176 | .tuner_gpio = RDE250_XCV_TUNER, |
| 177 | .tuner_sif_gpio = 0x05, |
| 178 | .tuner_scl_gpio = 0x1a, |
| 179 | .tuner_sda_gpio = 0x1b, |
| 180 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 181 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 182 | .demod_xfer_mode = 0, |
| 183 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 184 | .agc_analog_digital_select_gpio = 0x1c, |
| 185 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 186 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 187 | .demod_i2c_master = I2C_2, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 188 | .has_dvb = 1, |
| 189 | .demod_addr = 0x02, |
| 190 | .norm = V4L2_STD_PAL, |
| 191 | |
| 192 | .input = {{ |
| 193 | .type = CX231XX_VMUX_TELEVISION, |
| 194 | .vmux = CX231XX_VIN_3_1, |
| 195 | .amux = CX231XX_AMUX_VIDEO, |
| 196 | .gpio = NULL, |
| 197 | }, { |
| 198 | .type = CX231XX_VMUX_COMPOSITE1, |
| 199 | .vmux = CX231XX_VIN_2_1, |
| 200 | .amux = CX231XX_AMUX_LINE_IN, |
| 201 | .gpio = NULL, |
| 202 | }, { |
| 203 | .type = CX231XX_VMUX_SVIDEO, |
| 204 | .vmux = CX231XX_VIN_1_1 | |
| 205 | (CX231XX_VIN_1_2 << 8) | |
| 206 | CX25840_SVIDEO_ON, |
| 207 | .amux = CX231XX_AMUX_LINE_IN, |
| 208 | .gpio = NULL, |
| 209 | } |
| 210 | }, |
| 211 | }, |
| 212 | |
| 213 | [CX231XX_BOARD_CNXT_RDU_253S] = { |
| 214 | .name = "Conexant Hybrid TV - RDU253S", |
| 215 | .tuner_type = TUNER_NXP_TDA18271, |
| 216 | .tuner_addr = 0x60, |
| 217 | .tuner_gpio = RDE250_XCV_TUNER, |
| 218 | .tuner_sif_gpio = 0x05, |
| 219 | .tuner_scl_gpio = 0x1a, |
| 220 | .tuner_sda_gpio = 0x1b, |
| 221 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 222 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 223 | .demod_xfer_mode = 0, |
| 224 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 225 | .agc_analog_digital_select_gpio = 0x1c, |
| 226 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 227 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 228 | .demod_i2c_master = I2C_2, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 229 | .has_dvb = 1, |
| 230 | .demod_addr = 0x02, |
| 231 | .norm = V4L2_STD_PAL, |
| 232 | |
| 233 | .input = {{ |
| 234 | .type = CX231XX_VMUX_TELEVISION, |
| 235 | .vmux = CX231XX_VIN_3_1, |
| 236 | .amux = CX231XX_AMUX_VIDEO, |
| 237 | .gpio = NULL, |
| 238 | }, { |
| 239 | .type = CX231XX_VMUX_COMPOSITE1, |
| 240 | .vmux = CX231XX_VIN_2_1, |
| 241 | .amux = CX231XX_AMUX_LINE_IN, |
| 242 | .gpio = NULL, |
| 243 | }, { |
| 244 | .type = CX231XX_VMUX_SVIDEO, |
| 245 | .vmux = CX231XX_VIN_1_1 | |
| 246 | (CX231XX_VIN_1_2 << 8) | |
| 247 | CX25840_SVIDEO_ON, |
| 248 | .amux = CX231XX_AMUX_LINE_IN, |
| 249 | .gpio = NULL, |
| 250 | } |
| 251 | }, |
| 252 | }, |
| 253 | [CX231XX_BOARD_CNXT_VIDEO_GRABBER] = { |
| 254 | .name = "Conexant VIDEO GRABBER", |
Devin Heitmueller | 9f51259 | 2010-08-18 18:04:04 -0300 | [diff] [blame] | 255 | .tuner_type = TUNER_ABSENT, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 256 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 257 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 258 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 259 | .agc_analog_digital_select_gpio = 0x1c, |
| 260 | .gpio_pin_status_mask = 0x4001000, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 261 | .norm = V4L2_STD_PAL, |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 262 | .no_alt_vanc = 1, |
| 263 | .external_av = 1, |
Hans Verkuil | b31077a | 2013-02-07 13:22:06 -0300 | [diff] [blame] | 264 | /* Actually, it has a 417, but it isn't working correctly. |
| 265 | * So set to 0 for now until someone can manage to get this |
| 266 | * to work reliably. */ |
| 267 | .has_417 = 0, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 268 | |
| 269 | .input = {{ |
| 270 | .type = CX231XX_VMUX_COMPOSITE1, |
| 271 | .vmux = CX231XX_VIN_2_1, |
| 272 | .amux = CX231XX_AMUX_LINE_IN, |
| 273 | .gpio = NULL, |
| 274 | }, { |
| 275 | .type = CX231XX_VMUX_SVIDEO, |
| 276 | .vmux = CX231XX_VIN_1_1 | |
| 277 | (CX231XX_VIN_1_2 << 8) | |
| 278 | CX25840_SVIDEO_ON, |
| 279 | .amux = CX231XX_AMUX_LINE_IN, |
| 280 | .gpio = NULL, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 281 | } |
| 282 | }, |
| 283 | }, |
| 284 | [CX231XX_BOARD_CNXT_RDE_250] = { |
| 285 | .name = "Conexant Hybrid TV - rde 250", |
| 286 | .tuner_type = TUNER_XC5000, |
| 287 | .tuner_addr = 0x61, |
| 288 | .tuner_gpio = RDE250_XCV_TUNER, |
| 289 | .tuner_sif_gpio = 0x05, |
| 290 | .tuner_scl_gpio = 0x1a, |
| 291 | .tuner_sda_gpio = 0x1b, |
| 292 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 293 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 294 | .demod_xfer_mode = 0, |
| 295 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 296 | .agc_analog_digital_select_gpio = 0x0c, |
| 297 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 298 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 299 | .demod_i2c_master = I2C_2, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 300 | .has_dvb = 1, |
| 301 | .demod_addr = 0x02, |
| 302 | .norm = V4L2_STD_PAL, |
| 303 | |
| 304 | .input = {{ |
| 305 | .type = CX231XX_VMUX_TELEVISION, |
| 306 | .vmux = CX231XX_VIN_2_1, |
| 307 | .amux = CX231XX_AMUX_VIDEO, |
| 308 | .gpio = NULL, |
| 309 | } |
| 310 | }, |
| 311 | }, |
| 312 | [CX231XX_BOARD_CNXT_RDU_250] = { |
| 313 | .name = "Conexant Hybrid TV - RDU 250", |
| 314 | .tuner_type = TUNER_XC5000, |
| 315 | .tuner_addr = 0x61, |
| 316 | .tuner_gpio = RDE250_XCV_TUNER, |
| 317 | .tuner_sif_gpio = 0x05, |
| 318 | .tuner_scl_gpio = 0x1a, |
| 319 | .tuner_sda_gpio = 0x1b, |
| 320 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 321 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 322 | .demod_xfer_mode = 0, |
| 323 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 324 | .agc_analog_digital_select_gpio = 0x0c, |
| 325 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 326 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 327 | .demod_i2c_master = I2C_2, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 328 | .has_dvb = 1, |
| 329 | .demod_addr = 0x32, |
| 330 | .norm = V4L2_STD_NTSC, |
| 331 | |
| 332 | .input = {{ |
| 333 | .type = CX231XX_VMUX_TELEVISION, |
| 334 | .vmux = CX231XX_VIN_2_1, |
| 335 | .amux = CX231XX_AMUX_VIDEO, |
| 336 | .gpio = NULL, |
| 337 | } |
| 338 | }, |
| 339 | }, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 340 | [CX231XX_BOARD_HAUPPAUGE_EXETER] = { |
| 341 | .name = "Hauppauge EXETER", |
| 342 | .tuner_type = TUNER_NXP_TDA18271, |
| 343 | .tuner_addr = 0x60, |
| 344 | .tuner_gpio = RDE250_XCV_TUNER, |
| 345 | .tuner_sif_gpio = 0x05, |
| 346 | .tuner_scl_gpio = 0x1a, |
| 347 | .tuner_sda_gpio = 0x1b, |
| 348 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 349 | .output_mode = OUT_MODE_VIP11, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 350 | .demod_xfer_mode = 0, |
| 351 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 352 | .agc_analog_digital_select_gpio = 0x0c, |
| 353 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 354 | .tuner_i2c_master = I2C_1_MUX_1, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 355 | .demod_i2c_master = I2C_2, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 356 | .has_dvb = 1, |
| 357 | .demod_addr = 0x0e, |
| 358 | .norm = V4L2_STD_NTSC, |
| 359 | |
| 360 | .input = {{ |
| 361 | .type = CX231XX_VMUX_TELEVISION, |
| 362 | .vmux = CX231XX_VIN_3_1, |
| 363 | .amux = CX231XX_AMUX_VIDEO, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 364 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 365 | }, { |
| 366 | .type = CX231XX_VMUX_COMPOSITE1, |
| 367 | .vmux = CX231XX_VIN_2_1, |
| 368 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 369 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 370 | }, { |
| 371 | .type = CX231XX_VMUX_SVIDEO, |
| 372 | .vmux = CX231XX_VIN_1_1 | |
| 373 | (CX231XX_VIN_1_2 << 8) | |
| 374 | CX25840_SVIDEO_ON, |
| 375 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 376 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 377 | } }, |
| 378 | }, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 379 | [CX231XX_BOARD_HAUPPAUGE_USBLIVE2] = { |
| 380 | .name = "Hauppauge USB Live 2", |
| 381 | .tuner_type = TUNER_ABSENT, |
| 382 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 383 | .output_mode = OUT_MODE_VIP11, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 384 | .demod_xfer_mode = 0, |
| 385 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 386 | .agc_analog_digital_select_gpio = 0x0c, |
| 387 | .gpio_pin_status_mask = 0x4001000, |
| 388 | .norm = V4L2_STD_NTSC, |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 389 | .no_alt_vanc = 1, |
| 390 | .external_av = 1, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 391 | .input = {{ |
| 392 | .type = CX231XX_VMUX_COMPOSITE1, |
| 393 | .vmux = CX231XX_VIN_2_1, |
| 394 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 395 | .gpio = NULL, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 396 | }, { |
| 397 | .type = CX231XX_VMUX_SVIDEO, |
| 398 | .vmux = CX231XX_VIN_1_1 | |
| 399 | (CX231XX_VIN_1_2 << 8) | |
| 400 | CX25840_SVIDEO_ON, |
| 401 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 402 | .gpio = NULL, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 403 | } }, |
| 404 | }, |
Márcio Alves | eeaaf81 | 2011-04-11 19:57:15 -0300 | [diff] [blame] | 405 | [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID] = { |
| 406 | .name = "Kworld UB430 USB Hybrid", |
| 407 | .tuner_type = TUNER_NXP_TDA18271, |
| 408 | .tuner_addr = 0x60, |
| 409 | .decoder = CX231XX_AVDECODER, |
| 410 | .output_mode = OUT_MODE_VIP11, |
| 411 | .demod_xfer_mode = 0, |
| 412 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 413 | .agc_analog_digital_select_gpio = 0x11, /* According with PV cxPolaris.inf file */ |
| 414 | .tuner_sif_gpio = -1, |
| 415 | .tuner_scl_gpio = -1, |
| 416 | .tuner_sda_gpio = -1, |
| 417 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 418 | .tuner_i2c_master = I2C_2, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 419 | .demod_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 420 | .ir_i2c_master = I2C_2, |
Márcio Alves | eeaaf81 | 2011-04-11 19:57:15 -0300 | [diff] [blame] | 421 | .has_dvb = 1, |
| 422 | .demod_addr = 0x10, |
| 423 | .norm = V4L2_STD_PAL_M, |
| 424 | .input = {{ |
| 425 | .type = CX231XX_VMUX_TELEVISION, |
| 426 | .vmux = CX231XX_VIN_3_1, |
| 427 | .amux = CX231XX_AMUX_VIDEO, |
| 428 | .gpio = NULL, |
| 429 | }, { |
| 430 | .type = CX231XX_VMUX_COMPOSITE1, |
| 431 | .vmux = CX231XX_VIN_2_1, |
| 432 | .amux = CX231XX_AMUX_LINE_IN, |
| 433 | .gpio = NULL, |
| 434 | }, { |
| 435 | .type = CX231XX_VMUX_SVIDEO, |
| 436 | .vmux = CX231XX_VIN_1_1 | |
| 437 | (CX231XX_VIN_1_2 << 8) | |
| 438 | CX25840_SVIDEO_ON, |
| 439 | .amux = CX231XX_AMUX_LINE_IN, |
| 440 | .gpio = NULL, |
| 441 | } }, |
| 442 | }, |
Johannes Erdfelt | 8b1255a | 2013-08-16 21:29:02 -0300 | [diff] [blame] | 443 | [CX231XX_BOARD_KWORLD_UB445_USB_HYBRID] = { |
| 444 | .name = "Kworld UB445 USB Hybrid", |
| 445 | .tuner_type = TUNER_NXP_TDA18271, |
| 446 | .tuner_addr = 0x60, |
| 447 | .decoder = CX231XX_AVDECODER, |
| 448 | .output_mode = OUT_MODE_VIP11, |
| 449 | .demod_xfer_mode = 0, |
| 450 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 451 | .agc_analog_digital_select_gpio = 0x11, /* According with PV cxPolaris.inf file */ |
| 452 | .tuner_sif_gpio = -1, |
| 453 | .tuner_scl_gpio = -1, |
| 454 | .tuner_sda_gpio = -1, |
| 455 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 456 | .tuner_i2c_master = I2C_2, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 457 | .demod_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 458 | .ir_i2c_master = I2C_2, |
Johannes Erdfelt | 8b1255a | 2013-08-16 21:29:02 -0300 | [diff] [blame] | 459 | .has_dvb = 1, |
| 460 | .demod_addr = 0x10, |
| 461 | .norm = V4L2_STD_NTSC_M, |
| 462 | .input = {{ |
| 463 | .type = CX231XX_VMUX_TELEVISION, |
| 464 | .vmux = CX231XX_VIN_3_1, |
| 465 | .amux = CX231XX_AMUX_VIDEO, |
| 466 | .gpio = NULL, |
| 467 | }, { |
| 468 | .type = CX231XX_VMUX_COMPOSITE1, |
| 469 | .vmux = CX231XX_VIN_2_1, |
| 470 | .amux = CX231XX_AMUX_LINE_IN, |
| 471 | .gpio = NULL, |
| 472 | }, { |
| 473 | .type = CX231XX_VMUX_SVIDEO, |
| 474 | .vmux = CX231XX_VIN_1_1 | |
| 475 | (CX231XX_VIN_1_2 << 8) | |
| 476 | CX25840_SVIDEO_ON, |
| 477 | .amux = CX231XX_AMUX_LINE_IN, |
| 478 | .gpio = NULL, |
| 479 | } }, |
| 480 | }, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 481 | [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID] = { |
| 482 | .name = "Pixelview PlayTV USB Hybrid", |
| 483 | .tuner_type = TUNER_NXP_TDA18271, |
| 484 | .tuner_addr = 0x60, |
| 485 | .decoder = CX231XX_AVDECODER, |
| 486 | .output_mode = OUT_MODE_VIP11, |
| 487 | .demod_xfer_mode = 0, |
| 488 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 489 | .agc_analog_digital_select_gpio = 0x00, /* According with PV cxPolaris.inf file */ |
| 490 | .tuner_sif_gpio = -1, |
| 491 | .tuner_scl_gpio = -1, |
| 492 | .tuner_sda_gpio = -1, |
| 493 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 494 | .tuner_i2c_master = I2C_2, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 495 | .demod_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 496 | .ir_i2c_master = I2C_2, |
Mauro Carvalho Chehab | 788e5d4 | 2010-12-17 14:47:27 -0300 | [diff] [blame] | 497 | .rc_map_name = RC_MAP_PIXELVIEW_002T, |
Mauro Carvalho Chehab | ede676c | 2010-09-27 23:44:27 -0300 | [diff] [blame] | 498 | .has_dvb = 1, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 499 | .demod_addr = 0x10, |
| 500 | .norm = V4L2_STD_PAL_M, |
| 501 | .input = {{ |
| 502 | .type = CX231XX_VMUX_TELEVISION, |
| 503 | .vmux = CX231XX_VIN_3_1, |
| 504 | .amux = CX231XX_AMUX_VIDEO, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 505 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 506 | }, { |
| 507 | .type = CX231XX_VMUX_COMPOSITE1, |
| 508 | .vmux = CX231XX_VIN_2_1, |
| 509 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 510 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 511 | }, { |
| 512 | .type = CX231XX_VMUX_SVIDEO, |
| 513 | .vmux = CX231XX_VIN_1_1 | |
| 514 | (CX231XX_VIN_1_2 << 8) | |
| 515 | CX25840_SVIDEO_ON, |
| 516 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame] | 517 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 518 | } }, |
| 519 | }, |
Mauro Carvalho Chehab | 4e10503 | 2011-01-31 22:18:21 -0300 | [diff] [blame] | 520 | [CX231XX_BOARD_PV_XCAPTURE_USB] = { |
| 521 | .name = "Pixelview Xcapture USB", |
| 522 | .tuner_type = TUNER_ABSENT, |
| 523 | .decoder = CX231XX_AVDECODER, |
| 524 | .output_mode = OUT_MODE_VIP11, |
| 525 | .demod_xfer_mode = 0, |
| 526 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 527 | .agc_analog_digital_select_gpio = 0x0c, |
| 528 | .gpio_pin_status_mask = 0x4001000, |
| 529 | .norm = V4L2_STD_NTSC, |
| 530 | .no_alt_vanc = 1, |
| 531 | .external_av = 1, |
Mauro Carvalho Chehab | 4e10503 | 2011-01-31 22:18:21 -0300 | [diff] [blame] | 532 | |
| 533 | .input = {{ |
| 534 | .type = CX231XX_VMUX_COMPOSITE1, |
| 535 | .vmux = CX231XX_VIN_2_1, |
| 536 | .amux = CX231XX_AMUX_LINE_IN, |
| 537 | .gpio = NULL, |
| 538 | }, { |
| 539 | .type = CX231XX_VMUX_SVIDEO, |
| 540 | .vmux = CX231XX_VIN_1_1 | |
| 541 | (CX231XX_VIN_1_2 << 8) | |
| 542 | CX25840_SVIDEO_ON, |
| 543 | .amux = CX231XX_AMUX_LINE_IN, |
| 544 | .gpio = NULL, |
| 545 | } |
| 546 | }, |
| 547 | }, |
Igor Novgorodov | 2a7b6a4 | 2011-05-17 13:46:36 -0300 | [diff] [blame] | 548 | |
| 549 | [CX231XX_BOARD_ICONBIT_U100] = { |
| 550 | .name = "Iconbit Analog Stick U100 FM", |
| 551 | .tuner_type = TUNER_ABSENT, |
| 552 | .decoder = CX231XX_AVDECODER, |
| 553 | .output_mode = OUT_MODE_VIP11, |
| 554 | .demod_xfer_mode = 0, |
| 555 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 556 | .agc_analog_digital_select_gpio = 0x1C, |
| 557 | .gpio_pin_status_mask = 0x4001000, |
| 558 | |
| 559 | .input = {{ |
| 560 | .type = CX231XX_VMUX_COMPOSITE1, |
| 561 | .vmux = CX231XX_VIN_2_1, |
| 562 | .amux = CX231XX_AMUX_LINE_IN, |
| 563 | .gpio = NULL, |
| 564 | }, { |
| 565 | .type = CX231XX_VMUX_SVIDEO, |
| 566 | .vmux = CX231XX_VIN_1_1 | |
| 567 | (CX231XX_VIN_1_2 << 8) | |
| 568 | CX25840_SVIDEO_ON, |
| 569 | .amux = CX231XX_AMUX_LINE_IN, |
| 570 | .gpio = NULL, |
| 571 | } }, |
| 572 | }, |
Peter Moon | de8ae0d | 2011-06-08 15:54:19 -0300 | [diff] [blame] | 573 | [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL] = { |
| 574 | .name = "Hauppauge WinTV USB2 FM (PAL)", |
| 575 | .tuner_type = TUNER_NXP_TDA18271, |
| 576 | .tuner_addr = 0x60, |
| 577 | .tuner_gpio = RDE250_XCV_TUNER, |
| 578 | .tuner_sif_gpio = 0x05, |
| 579 | .tuner_scl_gpio = 0x1a, |
| 580 | .tuner_sda_gpio = 0x1b, |
| 581 | .decoder = CX231XX_AVDECODER, |
| 582 | .output_mode = OUT_MODE_VIP11, |
| 583 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 584 | .agc_analog_digital_select_gpio = 0x0c, |
| 585 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 586 | .tuner_i2c_master = I2C_1_MUX_3, |
Peter Moon | de8ae0d | 2011-06-08 15:54:19 -0300 | [diff] [blame] | 587 | .norm = V4L2_STD_PAL, |
| 588 | |
| 589 | .input = {{ |
| 590 | .type = CX231XX_VMUX_TELEVISION, |
| 591 | .vmux = CX231XX_VIN_3_1, |
| 592 | .amux = CX231XX_AMUX_VIDEO, |
| 593 | .gpio = NULL, |
| 594 | }, { |
| 595 | .type = CX231XX_VMUX_COMPOSITE1, |
| 596 | .vmux = CX231XX_VIN_2_1, |
| 597 | .amux = CX231XX_AMUX_LINE_IN, |
| 598 | .gpio = NULL, |
| 599 | }, { |
| 600 | .type = CX231XX_VMUX_SVIDEO, |
| 601 | .vmux = CX231XX_VIN_1_1 | |
| 602 | (CX231XX_VIN_1_2 << 8) | |
| 603 | CX25840_SVIDEO_ON, |
| 604 | .amux = CX231XX_AMUX_LINE_IN, |
| 605 | .gpio = NULL, |
| 606 | } }, |
| 607 | }, |
| 608 | [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC] = { |
| 609 | .name = "Hauppauge WinTV USB2 FM (NTSC)", |
| 610 | .tuner_type = TUNER_NXP_TDA18271, |
| 611 | .tuner_addr = 0x60, |
| 612 | .tuner_gpio = RDE250_XCV_TUNER, |
| 613 | .tuner_sif_gpio = 0x05, |
| 614 | .tuner_scl_gpio = 0x1a, |
| 615 | .tuner_sda_gpio = 0x1b, |
| 616 | .decoder = CX231XX_AVDECODER, |
| 617 | .output_mode = OUT_MODE_VIP11, |
| 618 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 619 | .agc_analog_digital_select_gpio = 0x0c, |
| 620 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 621 | .tuner_i2c_master = I2C_1_MUX_3, |
Peter Moon | de8ae0d | 2011-06-08 15:54:19 -0300 | [diff] [blame] | 622 | .norm = V4L2_STD_NTSC, |
| 623 | |
| 624 | .input = {{ |
| 625 | .type = CX231XX_VMUX_TELEVISION, |
| 626 | .vmux = CX231XX_VIN_3_1, |
| 627 | .amux = CX231XX_AMUX_VIDEO, |
| 628 | .gpio = NULL, |
| 629 | }, { |
| 630 | .type = CX231XX_VMUX_COMPOSITE1, |
| 631 | .vmux = CX231XX_VIN_2_1, |
| 632 | .amux = CX231XX_AMUX_LINE_IN, |
| 633 | .gpio = NULL, |
| 634 | }, { |
| 635 | .type = CX231XX_VMUX_SVIDEO, |
| 636 | .vmux = CX231XX_VIN_1_1 | |
| 637 | (CX231XX_VIN_1_2 << 8) | |
| 638 | CX25840_SVIDEO_ON, |
| 639 | .amux = CX231XX_AMUX_LINE_IN, |
| 640 | .gpio = NULL, |
| 641 | } }, |
| 642 | }, |
Alf Høgemark | 68c97bf | 2012-11-28 14:29:16 -0300 | [diff] [blame] | 643 | [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2] = { |
| 644 | .name = "Elgato Video Capture V2", |
| 645 | .tuner_type = TUNER_ABSENT, |
| 646 | .decoder = CX231XX_AVDECODER, |
| 647 | .output_mode = OUT_MODE_VIP11, |
| 648 | .demod_xfer_mode = 0, |
| 649 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 650 | .agc_analog_digital_select_gpio = 0x0c, |
| 651 | .gpio_pin_status_mask = 0x4001000, |
| 652 | .norm = V4L2_STD_NTSC, |
| 653 | .no_alt_vanc = 1, |
| 654 | .external_av = 1, |
Alf Høgemark | 68c97bf | 2012-11-28 14:29:16 -0300 | [diff] [blame] | 655 | .input = {{ |
| 656 | .type = CX231XX_VMUX_COMPOSITE1, |
| 657 | .vmux = CX231XX_VIN_2_1, |
| 658 | .amux = CX231XX_AMUX_LINE_IN, |
| 659 | .gpio = NULL, |
| 660 | }, { |
| 661 | .type = CX231XX_VMUX_SVIDEO, |
| 662 | .vmux = CX231XX_VIN_1_1 | |
| 663 | (CX231XX_VIN_1_2 << 8) | |
| 664 | CX25840_SVIDEO_ON, |
| 665 | .amux = CX231XX_AMUX_LINE_IN, |
| 666 | .gpio = NULL, |
| 667 | } }, |
| 668 | }, |
Matt Gomboc | 3ead1ba31 | 2013-03-01 19:53:30 -0300 | [diff] [blame] | 669 | [CX231XX_BOARD_OTG102] = { |
| 670 | .name = "Geniatech OTG102", |
| 671 | .tuner_type = TUNER_ABSENT, |
| 672 | .decoder = CX231XX_AVDECODER, |
| 673 | .output_mode = OUT_MODE_VIP11, |
| 674 | .ctl_pin_status_mask = 0xFFFFFFC4, |
Mauro Carvalho Chehab | 589dadf | 2014-11-01 08:09:44 -0300 | [diff] [blame] | 675 | .agc_analog_digital_select_gpio = 0x0c, |
Matt Gomboc | 3ead1ba31 | 2013-03-01 19:53:30 -0300 | [diff] [blame] | 676 | /* According with PV CxPlrCAP.inf file */ |
| 677 | .gpio_pin_status_mask = 0x4001000, |
| 678 | .norm = V4L2_STD_NTSC, |
| 679 | .no_alt_vanc = 1, |
| 680 | .external_av = 1, |
Matt Gomboc | 3ead1ba31 | 2013-03-01 19:53:30 -0300 | [diff] [blame] | 681 | /*.has_417 = 1, */ |
| 682 | /* This board is believed to have a hardware encoding chip |
| 683 | * supporting mpeg1/2/4, but as the 417 is apparently not |
| 684 | * working for the reference board it is not here either. */ |
| 685 | |
| 686 | .input = {{ |
| 687 | .type = CX231XX_VMUX_COMPOSITE1, |
| 688 | .vmux = CX231XX_VIN_2_1, |
| 689 | .amux = CX231XX_AMUX_LINE_IN, |
| 690 | .gpio = NULL, |
| 691 | }, { |
| 692 | .type = CX231XX_VMUX_SVIDEO, |
| 693 | .vmux = CX231XX_VIN_1_1 | |
| 694 | (CX231XX_VIN_1_2 << 8) | |
| 695 | CX25840_SVIDEO_ON, |
| 696 | .amux = CX231XX_AMUX_LINE_IN, |
| 697 | .gpio = NULL, |
| 698 | } |
| 699 | }, |
| 700 | }, |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 701 | [CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx] = { |
Matthias Schwarzott | 57cbf3e | 2014-08-31 08:35:08 -0300 | [diff] [blame] | 702 | .name = "Hauppauge WinTV 930C-HD (1113xx) / HVR-900H (111xxx) / PCTV QuatroStick 521e", |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 703 | .tuner_type = TUNER_NXP_TDA18271, |
| 704 | .tuner_addr = 0x60, |
| 705 | .tuner_gpio = RDE250_XCV_TUNER, |
| 706 | .tuner_sif_gpio = 0x05, |
| 707 | .tuner_scl_gpio = 0x1a, |
| 708 | .tuner_sda_gpio = 0x1b, |
| 709 | .decoder = CX231XX_AVDECODER, |
| 710 | .output_mode = OUT_MODE_VIP11, |
| 711 | .demod_xfer_mode = 0, |
| 712 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 713 | .agc_analog_digital_select_gpio = 0x0c, |
| 714 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 715 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 716 | .demod_i2c_master = I2C_2, |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 717 | .has_dvb = 1, |
| 718 | .demod_addr = 0x0e, |
| 719 | .norm = V4L2_STD_PAL, |
| 720 | |
| 721 | .input = {{ |
| 722 | .type = CX231XX_VMUX_TELEVISION, |
| 723 | .vmux = CX231XX_VIN_3_1, |
| 724 | .amux = CX231XX_AMUX_VIDEO, |
| 725 | .gpio = NULL, |
| 726 | }, { |
| 727 | .type = CX231XX_VMUX_COMPOSITE1, |
| 728 | .vmux = CX231XX_VIN_2_1, |
| 729 | .amux = CX231XX_AMUX_LINE_IN, |
| 730 | .gpio = NULL, |
| 731 | }, { |
| 732 | .type = CX231XX_VMUX_SVIDEO, |
| 733 | .vmux = CX231XX_VIN_1_1 | |
| 734 | (CX231XX_VIN_1_2 << 8) | |
| 735 | CX25840_SVIDEO_ON, |
| 736 | .amux = CX231XX_AMUX_LINE_IN, |
| 737 | .gpio = NULL, |
| 738 | } }, |
| 739 | }, |
Matthias Schwarzott | 9e49f7c | 2014-07-22 17:12:16 -0300 | [diff] [blame] | 740 | [CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx] = { |
Matthias Schwarzott | 8618ac4 | 2014-08-31 08:35:09 -0300 | [diff] [blame] | 741 | .name = "Hauppauge WinTV 930C-HD (1114xx) / HVR-901H (1114xx) / PCTV QuatroStick 522e", |
Matthias Schwarzott | 9e49f7c | 2014-07-22 17:12:16 -0300 | [diff] [blame] | 742 | .tuner_type = TUNER_ABSENT, |
| 743 | .tuner_addr = 0x60, |
| 744 | .tuner_gpio = RDE250_XCV_TUNER, |
| 745 | .tuner_sif_gpio = 0x05, |
| 746 | .tuner_scl_gpio = 0x1a, |
| 747 | .tuner_sda_gpio = 0x1b, |
| 748 | .decoder = CX231XX_AVDECODER, |
| 749 | .output_mode = OUT_MODE_VIP11, |
| 750 | .demod_xfer_mode = 0, |
| 751 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 752 | .agc_analog_digital_select_gpio = 0x0c, |
| 753 | .gpio_pin_status_mask = 0x4001000, |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 754 | .tuner_i2c_master = I2C_1_MUX_3, |
Matthias Schwarzott | d032ca1 | 2014-10-02 02:20:58 -0300 | [diff] [blame] | 755 | .demod_i2c_master = I2C_2, |
Matthias Schwarzott | 9e49f7c | 2014-07-22 17:12:16 -0300 | [diff] [blame] | 756 | .has_dvb = 1, |
| 757 | .demod_addr = 0x0e, |
| 758 | .norm = V4L2_STD_PAL, |
| 759 | |
| 760 | .input = {{ |
| 761 | .type = CX231XX_VMUX_TELEVISION, |
| 762 | .vmux = CX231XX_VIN_3_1, |
| 763 | .amux = CX231XX_AMUX_VIDEO, |
| 764 | .gpio = NULL, |
| 765 | }, { |
| 766 | .type = CX231XX_VMUX_COMPOSITE1, |
| 767 | .vmux = CX231XX_VIN_2_1, |
| 768 | .amux = CX231XX_AMUX_LINE_IN, |
| 769 | .gpio = NULL, |
| 770 | }, { |
| 771 | .type = CX231XX_VMUX_SVIDEO, |
| 772 | .vmux = CX231XX_VIN_1_1 | |
| 773 | (CX231XX_VIN_1_2 << 8) | |
| 774 | CX25840_SVIDEO_ON, |
| 775 | .amux = CX231XX_AMUX_LINE_IN, |
| 776 | .gpio = NULL, |
| 777 | } }, |
| 778 | }, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 779 | }; |
| 780 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); |
| 781 | |
| 782 | /* table of devices that work with this driver */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 783 | struct usb_device_id cx231xx_id_table[] = { |
Links (Markus) | dad4c41 | 2014-01-04 19:44:34 -0300 | [diff] [blame] | 784 | {USB_DEVICE(0x1D19, 0x6109), |
| 785 | .driver_info = CX231XX_BOARD_PV_XCAPTURE_USB}, |
Sri Deevi | ed559ed | 2009-03-13 18:35:14 -0300 | [diff] [blame] | 786 | {USB_DEVICE(0x0572, 0x5A3C), |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 787 | .driver_info = CX231XX_BOARD_UNKNOWN}, |
| 788 | {USB_DEVICE(0x0572, 0x58A2), |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 789 | .driver_info = CX231XX_BOARD_CNXT_CARRAERA}, |
Sri Deevi | ed559ed | 2009-03-13 18:35:14 -0300 | [diff] [blame] | 790 | {USB_DEVICE(0x0572, 0x58A1), |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 791 | .driver_info = CX231XX_BOARD_CNXT_SHELBY}, |
| 792 | {USB_DEVICE(0x0572, 0x58A4), |
| 793 | .driver_info = CX231XX_BOARD_CNXT_RDE_253S}, |
| 794 | {USB_DEVICE(0x0572, 0x58A5), |
| 795 | .driver_info = CX231XX_BOARD_CNXT_RDU_253S}, |
| 796 | {USB_DEVICE(0x0572, 0x58A6), |
| 797 | .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER}, |
| 798 | {USB_DEVICE(0x0572, 0x589E), |
| 799 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, |
| 800 | {USB_DEVICE(0x0572, 0x58A0), |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 801 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, |
Peter Moon | de8ae0d | 2011-06-08 15:54:19 -0300 | [diff] [blame] | 802 | {USB_DEVICE(0x2040, 0xb110), |
| 803 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL}, |
| 804 | {USB_DEVICE(0x2040, 0xb111), |
| 805 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC}, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 806 | {USB_DEVICE(0x2040, 0xb120), |
| 807 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 808 | {USB_DEVICE(0x2040, 0xb130), |
| 809 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx}, |
Matthias Schwarzott | 9e49f7c | 2014-07-22 17:12:16 -0300 | [diff] [blame] | 810 | {USB_DEVICE(0x2040, 0xb131), |
| 811 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx}, |
Matthias Schwarzott | 57cbf3e | 2014-08-31 08:35:08 -0300 | [diff] [blame] | 812 | /* Hauppauge WinTV-HVR-900-H */ |
| 813 | {USB_DEVICE(0x2040, 0xb138), |
| 814 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx}, |
Matthias Schwarzott | 8618ac4 | 2014-08-31 08:35:09 -0300 | [diff] [blame] | 815 | /* Hauppauge WinTV-HVR-901-H */ |
| 816 | {USB_DEVICE(0x2040, 0xb139), |
| 817 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx}, |
Devin Heitmueller | d78148f | 2010-07-06 18:25:19 -0300 | [diff] [blame] | 818 | {USB_DEVICE(0x2040, 0xb140), |
| 819 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 820 | {USB_DEVICE(0x2040, 0xc200), |
| 821 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USBLIVE2}, |
Matthias Schwarzott | a141a88 | 2014-07-22 17:12:17 -0300 | [diff] [blame] | 822 | /* PCTV QuatroStick 521e */ |
| 823 | {USB_DEVICE(0x2013, 0x0259), |
| 824 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx}, |
Matthias Schwarzott | 140a798 | 2014-07-22 17:12:18 -0300 | [diff] [blame] | 825 | /* PCTV QuatroStick 522e */ |
| 826 | {USB_DEVICE(0x2013, 0x025e), |
| 827 | .driver_info = CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx}, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 828 | {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000, 0x4001), |
| 829 | .driver_info = CX231XX_BOARD_PV_PLAYTV_USB_HYBRID}, |
Mauro Carvalho Chehab | 4e10503 | 2011-01-31 22:18:21 -0300 | [diff] [blame] | 830 | {USB_DEVICE(USB_VID_PIXELVIEW, 0x5014), |
| 831 | .driver_info = CX231XX_BOARD_PV_XCAPTURE_USB}, |
Márcio Alves | eeaaf81 | 2011-04-11 19:57:15 -0300 | [diff] [blame] | 832 | {USB_DEVICE(0x1b80, 0xe424), |
| 833 | .driver_info = CX231XX_BOARD_KWORLD_UB430_USB_HYBRID}, |
Johannes Erdfelt | 8b1255a | 2013-08-16 21:29:02 -0300 | [diff] [blame] | 834 | {USB_DEVICE(0x1b80, 0xe421), |
| 835 | .driver_info = CX231XX_BOARD_KWORLD_UB445_USB_HYBRID}, |
Igor Novgorodov | 2a7b6a4 | 2011-05-17 13:46:36 -0300 | [diff] [blame] | 836 | {USB_DEVICE(0x1f4d, 0x0237), |
| 837 | .driver_info = CX231XX_BOARD_ICONBIT_U100}, |
Alf Høgemark | 68c97bf | 2012-11-28 14:29:16 -0300 | [diff] [blame] | 838 | {USB_DEVICE(0x0fd9, 0x0037), |
| 839 | .driver_info = CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2}, |
Matt Gomboc | 3ead1ba31 | 2013-03-01 19:53:30 -0300 | [diff] [blame] | 840 | {USB_DEVICE(0x1f4d, 0x0102), |
| 841 | .driver_info = CX231XX_BOARD_OTG102}, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 842 | {}, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 843 | }; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 844 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 845 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); |
| 846 | |
| 847 | /* cx231xx_tuner_callback |
| 848 | * will be used to reset XC5000 tuner using GPIO pin |
| 849 | */ |
| 850 | |
| 851 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) |
| 852 | { |
| 853 | int rc = 0; |
| 854 | struct cx231xx *dev = ptr; |
| 855 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 856 | if (dev->tuner_type == TUNER_XC5000) { |
| 857 | if (command == XC5000_TUNER_RESET) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 858 | dev_dbg(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 859 | "Tuner CB: RESET: cmd %d : tuner type %d\n", |
| 860 | command, dev->tuner_type); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 861 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 862 | 1); |
| 863 | msleep(10); |
| 864 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 865 | 0); |
| 866 | msleep(330); |
| 867 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 868 | 1); |
| 869 | msleep(10); |
| 870 | } |
Mauro Carvalho Chehab | 55fa288 | 2010-09-29 11:07:08 -0300 | [diff] [blame] | 871 | } else if (dev->tuner_type == TUNER_NXP_TDA18271) { |
| 872 | switch (command) { |
| 873 | case TDA18271_CALLBACK_CMD_AGC_ENABLE: |
| 874 | if (dev->model == CX231XX_BOARD_PV_PLAYTV_USB_HYBRID) |
| 875 | rc = cx231xx_set_agc_analog_digital_mux_select(dev, arg); |
| 876 | break; |
| 877 | default: |
| 878 | rc = -EINVAL; |
| 879 | break; |
| 880 | } |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 881 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 882 | return rc; |
| 883 | } |
| 884 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); |
| 885 | |
Mauro Carvalho Chehab | d4c0613 | 2012-10-27 14:02:49 -0300 | [diff] [blame] | 886 | static void cx231xx_reset_out(struct cx231xx *dev) |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 887 | { |
| 888 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); |
| 889 | msleep(200); |
| 890 | cx231xx_set_gpio_value(dev, CX23417_RESET, 0); |
| 891 | msleep(200); |
| 892 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); |
| 893 | } |
Mauro Carvalho Chehab | d4c0613 | 2012-10-27 14:02:49 -0300 | [diff] [blame] | 894 | |
| 895 | static void cx231xx_enable_OSC(struct cx231xx *dev) |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 896 | { |
| 897 | cx231xx_set_gpio_value(dev, CX23417_OSC_EN, 1); |
| 898 | } |
Mauro Carvalho Chehab | d4c0613 | 2012-10-27 14:02:49 -0300 | [diff] [blame] | 899 | |
| 900 | static void cx231xx_sleep_s5h1432(struct cx231xx *dev) |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 901 | { |
| 902 | cx231xx_set_gpio_value(dev, SLEEP_S5H1432, 0); |
| 903 | } |
| 904 | |
Sri Deevi | b925517 | 2009-03-04 17:49:01 -0300 | [diff] [blame] | 905 | static inline void cx231xx_set_model(struct cx231xx *dev) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 906 | { |
Ezequiel Garcia | 3724dde | 2012-10-23 15:57:05 -0300 | [diff] [blame] | 907 | dev->board = cx231xx_boards[dev->model]; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, |
| 911 | * this won't work for boards with generic PCI IDs |
| 912 | */ |
| 913 | void cx231xx_pre_card_setup(struct cx231xx *dev) |
| 914 | { |
| 915 | |
| 916 | cx231xx_set_model(dev); |
| 917 | |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 918 | dev_info(dev->dev, "Identified as %s (card=%d)\n", |
Mauro Carvalho Chehab | ed0e372 | 2014-11-01 08:59:03 -0300 | [diff] [blame] | 919 | dev->board.name, dev->model); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 920 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 921 | /* set the direction for GPIO pins */ |
Mauro Carvalho Chehab | c10469c | 2010-09-11 11:37:51 -0300 | [diff] [blame] | 922 | if (dev->board.tuner_gpio) { |
| 923 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); |
| 924 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); |
Mauro Carvalho Chehab | 78bb6df | 2010-09-26 20:48:38 -0300 | [diff] [blame] | 925 | } |
| 926 | if (dev->board.tuner_sif_gpio >= 0) |
Mauro Carvalho Chehab | c10469c | 2010-09-11 11:37:51 -0300 | [diff] [blame] | 927 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 928 | |
Mauro Carvalho Chehab | 78bb6df | 2010-09-26 20:48:38 -0300 | [diff] [blame] | 929 | /* request some modules if any required */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 930 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 931 | /* set the mode to Analog mode initially */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 932 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); |
| 933 | |
| 934 | /* Unlock device */ |
| 935 | /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */ |
| 936 | |
| 937 | } |
| 938 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 939 | static void cx231xx_config_tuner(struct cx231xx *dev) |
| 940 | { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 941 | struct tuner_setup tun_setup; |
| 942 | struct v4l2_frequency f; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 943 | |
| 944 | if (dev->tuner_type == TUNER_ABSENT) |
| 945 | return; |
| 946 | |
| 947 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; |
| 948 | tun_setup.type = dev->tuner_type; |
| 949 | tun_setup.addr = dev->tuner_addr; |
| 950 | tun_setup.tuner_callback = cx231xx_tuner_callback; |
| 951 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 952 | tuner_call(dev, tuner, s_type_addr, &tun_setup); |
| 953 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 954 | #if 0 |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 955 | if (tun_setup.type == TUNER_XC5000) { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 956 | static struct xc2028_ctrl ctrl = { |
| 957 | .fname = XC5000_DEFAULT_FIRMWARE, |
| 958 | .max_len = 64, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 959 | .demod = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 960 | }; |
| 961 | struct v4l2_priv_tun_config cfg = { |
| 962 | .tuner = dev->tuner_type, |
| 963 | .priv = &ctrl, |
| 964 | }; |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 965 | tuner_call(dev, tuner, s_config, &cfg); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 966 | } |
| 967 | #endif |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 968 | /* configure tuner */ |
| 969 | f.tuner = 0; |
| 970 | f.type = V4L2_TUNER_ANALOG_TV; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 971 | f.frequency = 9076; /* just a magic number */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 972 | dev->ctl_freq = f.frequency; |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 973 | call_all(dev, tuner, s_frequency, &f); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 974 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 975 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 976 | |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 977 | static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, |
| 978 | u8 *eedata, int len) |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 979 | { |
| 980 | int ret = 0; |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 981 | u8 start_offset = 0; |
| 982 | int len_todo = len; |
| 983 | u8 *eedata_cur = eedata; |
| 984 | int i; |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 985 | struct i2c_msg msg_write = { .addr = client->addr, .flags = 0, |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 986 | .buf = &start_offset, .len = 1 }; |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 987 | struct i2c_msg msg_read = { .addr = client->addr, .flags = I2C_M_RD }; |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 988 | |
| 989 | /* start reading at offset 0 */ |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 990 | ret = i2c_transfer(client->adapter, &msg_write, 1); |
Mauro Carvalho Chehab | 1f97947 | 2014-07-27 16:27:30 -0300 | [diff] [blame] | 991 | if (ret < 0) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 992 | dev_err(dev->dev, "Can't read eeprom\n"); |
Mauro Carvalho Chehab | 1f97947 | 2014-07-27 16:27:30 -0300 | [diff] [blame] | 993 | return ret; |
| 994 | } |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 995 | |
| 996 | while (len_todo > 0) { |
| 997 | msg_read.len = (len_todo > 64) ? 64 : len_todo; |
| 998 | msg_read.buf = eedata_cur; |
| 999 | |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 1000 | ret = i2c_transfer(client->adapter, &msg_read, 1); |
Mauro Carvalho Chehab | 1f97947 | 2014-07-27 16:27:30 -0300 | [diff] [blame] | 1001 | if (ret < 0) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1002 | dev_err(dev->dev, "Can't read eeprom\n"); |
Mauro Carvalho Chehab | 1f97947 | 2014-07-27 16:27:30 -0300 | [diff] [blame] | 1003 | return ret; |
| 1004 | } |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1005 | eedata_cur += msg_read.len; |
| 1006 | len_todo -= msg_read.len; |
| 1007 | } |
| 1008 | |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1009 | for (i = 0; i + 15 < len; i += 16) |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1010 | dev_dbg(dev->dev, "i2c eeprom %02x: %*ph\n", |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1011 | i, 16, &eedata[i]); |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1012 | |
| 1013 | return 0; |
| 1014 | } |
| 1015 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1016 | void cx231xx_card_setup(struct cx231xx *dev) |
| 1017 | { |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1018 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1019 | cx231xx_set_model(dev); |
| 1020 | |
| 1021 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; |
| 1022 | if (cx231xx_boards[dev->model].tuner_addr) |
| 1023 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; |
| 1024 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1025 | /* request some modules */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1026 | if (dev->board.decoder == CX231XX_AVDECODER) { |
Hans Verkuil | e6574f2 | 2009-04-01 03:57:53 -0300 | [diff] [blame] | 1027 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
Matthias Schwarzott | c3c3f1a | 2014-10-02 02:20:59 -0300 | [diff] [blame] | 1028 | cx231xx_get_i2c_adap(dev, I2C_0), |
Laurent Pinchart | 9a1f8b3 | 2010-09-24 10:16:44 -0300 | [diff] [blame] | 1029 | "cx25840", 0x88 >> 1, NULL); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1030 | if (dev->sd_cx25840 == NULL) |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1031 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1032 | "cx25840 subdev registration failure\n"); |
Hans Verkuil | cc26b07 | 2009-03-29 19:20:26 -0300 | [diff] [blame] | 1033 | cx25840_call(dev, core, load_fw); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1034 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1035 | } |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1036 | |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 1037 | /* Initialize the tuner */ |
| 1038 | if (dev->board.tuner_type != TUNER_ABSENT) { |
Matthias Schwarzott | c3c3f1a | 2014-10-02 02:20:59 -0300 | [diff] [blame] | 1039 | struct i2c_adapter *tuner_i2c = cx231xx_get_i2c_adap(dev, |
| 1040 | dev->board.tuner_i2c_master); |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 1041 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
Matthias Schwarzott | c3c3f1a | 2014-10-02 02:20:59 -0300 | [diff] [blame] | 1042 | tuner_i2c, |
Laurent Pinchart | 9a1f8b3 | 2010-09-24 10:16:44 -0300 | [diff] [blame] | 1043 | "tuner", |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 1044 | dev->tuner_addr, NULL); |
| 1045 | if (dev->sd_tuner == NULL) |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1046 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1047 | "tuner subdev registration failure\n"); |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 1048 | else |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1049 | cx231xx_config_tuner(dev); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1050 | } |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1051 | |
| 1052 | switch (dev->model) { |
| 1053 | case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx: |
Matthias Schwarzott | 9e49f7c | 2014-07-22 17:12:16 -0300 | [diff] [blame] | 1054 | case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx: |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1055 | { |
| 1056 | struct tveeprom tvee; |
| 1057 | static u8 eeprom[256]; |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 1058 | struct i2c_client client; |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1059 | |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 1060 | memset(&client, 0, sizeof(client)); |
Matthias Schwarzott | b9ce9df | 2014-10-02 02:21:02 -0300 | [diff] [blame] | 1061 | client.adapter = cx231xx_get_i2c_adap(dev, I2C_1_MUX_1); |
Matthias Schwarzott | 9c67289 | 2014-10-02 02:20:54 -0300 | [diff] [blame] | 1062 | client.addr = 0xa0 >> 1; |
| 1063 | |
| 1064 | read_eeprom(dev, &client, eeprom, sizeof(eeprom)); |
| 1065 | tveeprom_hauppauge_analog(&client, |
Matthias Schwarzott | dd2e7dd | 2014-07-22 17:12:15 -0300 | [diff] [blame] | 1066 | &tvee, eeprom + 0xc0); |
| 1067 | break; |
| 1068 | } |
| 1069 | } |
| 1070 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1071 | } |
| 1072 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1073 | /* |
| 1074 | * cx231xx_config() |
| 1075 | * inits registers with sane defaults |
| 1076 | */ |
| 1077 | int cx231xx_config(struct cx231xx *dev) |
| 1078 | { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1079 | /* TBD need to add cx231xx specific code */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1080 | |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | /* |
| 1085 | * cx231xx_config_i2c() |
| 1086 | * configure i2c attached devices |
| 1087 | */ |
| 1088 | void cx231xx_config_i2c(struct cx231xx *dev) |
| 1089 | { |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 1090 | /* u32 input = INPUT(dev->video_input)->vmux; */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1091 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1092 | call_all(dev, video, s_stream, 1); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | /* |
| 1096 | * cx231xx_realease_resources() |
| 1097 | * unregisters the v4l2,i2c and usb devices |
| 1098 | * called when the device gets disconected or at module unload |
| 1099 | */ |
| 1100 | void cx231xx_release_resources(struct cx231xx *dev) |
| 1101 | { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1102 | cx231xx_release_analog_resources(dev); |
| 1103 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1104 | cx231xx_remove_from_devlist(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1105 | |
Mauro Carvalho Chehab | 7528cd2 | 2012-01-10 09:20:01 -0200 | [diff] [blame] | 1106 | cx231xx_ir_exit(dev); |
| 1107 | |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 1108 | /* Release I2C buses */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1109 | cx231xx_dev_uninit(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1110 | |
Mauro Carvalho Chehab | 7528cd2 | 2012-01-10 09:20:01 -0200 | [diff] [blame] | 1111 | /* delete v4l2 device */ |
| 1112 | v4l2_device_unregister(&dev->v4l2_dev); |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 1113 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1114 | usb_put_dev(dev->udev); |
| 1115 | |
| 1116 | /* Mark device as unused */ |
Mauro Carvalho Chehab | db702a7 | 2012-01-10 09:33:47 -0200 | [diff] [blame] | 1117 | clear_bit(dev->devno, &cx231xx_devused); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1118 | } |
| 1119 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1120 | /* |
| 1121 | * cx231xx_init_dev() |
| 1122 | * allocates and inits the device structs, registers i2c bus and v4l device |
| 1123 | */ |
Thomas Petazzoni | 15cb6af | 2012-01-07 09:52:40 -0300 | [diff] [blame] | 1124 | static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1125 | int minor) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1126 | { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1127 | int retval = -ENOMEM; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1128 | unsigned int maxh, maxw; |
| 1129 | |
| 1130 | dev->udev = udev; |
| 1131 | mutex_init(&dev->lock); |
| 1132 | mutex_init(&dev->ctrl_urb_lock); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1133 | mutex_init(&dev->gpio_i2c_lock); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1134 | mutex_init(&dev->i2c_lock); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1135 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1136 | spin_lock_init(&dev->video_mode.slock); |
| 1137 | spin_lock_init(&dev->vbi_mode.slock); |
| 1138 | spin_lock_init(&dev->sliced_cc_mode.slock); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1139 | |
| 1140 | init_waitqueue_head(&dev->open); |
| 1141 | init_waitqueue_head(&dev->wait_frame); |
| 1142 | init_waitqueue_head(&dev->wait_stream); |
| 1143 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1144 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; |
| 1145 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; |
| 1146 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; |
| 1147 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; |
| 1148 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1149 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1150 | /* Query cx231xx to find what pcb config it is related to */ |
Mauro Carvalho Chehab | 52841e5 | 2014-07-27 16:27:32 -0300 | [diff] [blame] | 1151 | retval = initialize_cx231xx(dev); |
| 1152 | if (retval < 0) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1153 | dev_err(dev->dev, "Failed to read PCB config\n"); |
Mauro Carvalho Chehab | 52841e5 | 2014-07-27 16:27:32 -0300 | [diff] [blame] | 1154 | return retval; |
| 1155 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1156 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1157 | /*To workaround error number=-71 on EP0 for VideoGrabber, |
| 1158 | need set alt here.*/ |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 1159 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER || |
| 1160 | dev->model == CX231XX_BOARD_HAUPPAUGE_USBLIVE2) { |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1161 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); |
| 1162 | cx231xx_set_alt_setting(dev, INDEX_VANC, 1); |
| 1163 | } |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1164 | /* Cx231xx pre card setup */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1165 | cx231xx_pre_card_setup(dev); |
| 1166 | |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1167 | retval = cx231xx_config(dev); |
| 1168 | if (retval) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1169 | dev_err(dev->dev, "error configuring device\n"); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1170 | return -ENOMEM; |
| 1171 | } |
| 1172 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1173 | /* set default norm */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1174 | dev->norm = dev->board.norm; |
| 1175 | |
| 1176 | /* register i2c bus */ |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1177 | retval = cx231xx_dev_init(dev); |
| 1178 | if (retval) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1179 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1180 | "%s: cx231xx_i2c_register - errCode [%d]!\n", |
| 1181 | __func__, retval); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1182 | goto err_dev_init; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | /* Do board specific init */ |
| 1186 | cx231xx_card_setup(dev); |
| 1187 | |
| 1188 | /* configure the device */ |
| 1189 | cx231xx_config_i2c(dev); |
| 1190 | |
| 1191 | maxw = norm_maxw(dev); |
| 1192 | maxh = norm_maxh(dev); |
| 1193 | |
| 1194 | /* set default image size */ |
| 1195 | dev->width = maxw; |
| 1196 | dev->height = maxh; |
| 1197 | dev->interlaced = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1198 | dev->video_input = 0; |
| 1199 | |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1200 | retval = cx231xx_config(dev); |
| 1201 | if (retval) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1202 | dev_err(dev->dev, "%s: cx231xx_config - errCode [%d]!\n", |
| 1203 | __func__, retval); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1204 | goto err_dev_init; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1205 | } |
| 1206 | |
| 1207 | /* init video dma queues */ |
| 1208 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); |
| 1209 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); |
| 1210 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1211 | /* init vbi dma queues */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1212 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); |
| 1213 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); |
| 1214 | |
| 1215 | /* Reset other chips required if they are tied up with GPIO pins */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1216 | cx231xx_add_into_devlist(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1217 | |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 1218 | if (dev->board.has_417) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1219 | dev_info(dev->dev, "attach 417 %d\n", dev->model); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1220 | if (cx231xx_417_register(dev) < 0) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1221 | dev_err(dev->dev, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1222 | "%s() Failed to register 417 on VID_B\n", |
Mauro Carvalho Chehab | 3b795d0 | 2014-11-02 07:45:56 -0300 | [diff] [blame] | 1223 | __func__); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1224 | } |
| 1225 | } |
| 1226 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1227 | retval = cx231xx_register_analog_devices(dev); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1228 | if (retval) { |
| 1229 | cx231xx_release_analog_resources(dev); |
| 1230 | goto err_analog; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1231 | } |
| 1232 | |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 1233 | cx231xx_ir_init(dev); |
| 1234 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1235 | cx231xx_init_extension(dev); |
| 1236 | |
| 1237 | return 0; |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1238 | err_analog: |
| 1239 | cx231xx_remove_from_devlist(dev); |
| 1240 | err_dev_init: |
| 1241 | cx231xx_dev_uninit(dev); |
| 1242 | return retval; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | #if defined(CONFIG_MODULES) && defined(MODULE) |
| 1246 | static void request_module_async(struct work_struct *work) |
| 1247 | { |
| 1248 | struct cx231xx *dev = container_of(work, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1249 | struct cx231xx, request_module_wk); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1250 | |
| 1251 | if (dev->has_alsa_audio) |
| 1252 | request_module("cx231xx-alsa"); |
| 1253 | |
| 1254 | if (dev->board.has_dvb) |
| 1255 | request_module("cx231xx-dvb"); |
| 1256 | |
| 1257 | } |
| 1258 | |
| 1259 | static void request_modules(struct cx231xx *dev) |
| 1260 | { |
| 1261 | INIT_WORK(&dev->request_module_wk, request_module_async); |
| 1262 | schedule_work(&dev->request_module_wk); |
| 1263 | } |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 1264 | |
| 1265 | static void flush_request_modules(struct cx231xx *dev) |
| 1266 | { |
Tejun Heo | 4382973 | 2012-08-20 14:51:24 -0700 | [diff] [blame] | 1267 | flush_work(&dev->request_module_wk); |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 1268 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1269 | #else |
| 1270 | #define request_modules(dev) |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 1271 | #define flush_request_modules(dev) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1272 | #endif /* CONFIG_MODULES */ |
| 1273 | |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1274 | static int cx231xx_init_v4l2(struct cx231xx *dev, |
| 1275 | struct usb_device *udev, |
| 1276 | struct usb_interface *interface, |
| 1277 | int isoc_pipe) |
| 1278 | { |
| 1279 | struct usb_interface *uif; |
| 1280 | int i, idx; |
| 1281 | |
| 1282 | /* Video Init */ |
| 1283 | |
| 1284 | /* compute alternate max packet sizes for video */ |
| 1285 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.video_index + 1; |
| 1286 | if (idx >= dev->max_iad_interface_count) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1287 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1288 | "Video PCB interface #%d doesn't exist\n", idx); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1289 | return -ENODEV; |
| 1290 | } |
| 1291 | |
| 1292 | uif = udev->actconfig->interface[idx]; |
| 1293 | |
| 1294 | dev->video_mode.end_point_addr = uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress; |
| 1295 | dev->video_mode.num_alt = uif->num_altsetting; |
| 1296 | |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1297 | dev_info(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1298 | "video EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1299 | dev->video_mode.end_point_addr, |
| 1300 | dev->video_mode.num_alt); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1301 | |
| 1302 | dev->video_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->video_mode.num_alt, GFP_KERNEL); |
Mauro Carvalho Chehab | ed0e372 | 2014-11-01 08:59:03 -0300 | [diff] [blame] | 1303 | if (dev->video_mode.alt_max_pkt_size == NULL) |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1304 | return -ENOMEM; |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1305 | |
| 1306 | for (i = 0; i < dev->video_mode.num_alt; i++) { |
| 1307 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize); |
| 1308 | dev->video_mode.alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1309 | dev_dbg(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1310 | "Alternate setting %i, max size= %i\n", i, |
| 1311 | dev->video_mode.alt_max_pkt_size[i]); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | /* VBI Init */ |
| 1315 | |
| 1316 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index + 1; |
| 1317 | if (idx >= dev->max_iad_interface_count) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1318 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1319 | "VBI PCB interface #%d doesn't exist\n", idx); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1320 | return -ENODEV; |
| 1321 | } |
| 1322 | uif = udev->actconfig->interface[idx]; |
| 1323 | |
| 1324 | dev->vbi_mode.end_point_addr = |
| 1325 | uif->altsetting[0].endpoint[isoc_pipe].desc. |
| 1326 | bEndpointAddress; |
| 1327 | |
| 1328 | dev->vbi_mode.num_alt = uif->num_altsetting; |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1329 | dev_info(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1330 | "VBI EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1331 | dev->vbi_mode.end_point_addr, |
| 1332 | dev->vbi_mode.num_alt); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1333 | |
| 1334 | /* compute alternate max packet sizes for vbi */ |
| 1335 | dev->vbi_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->vbi_mode.num_alt, GFP_KERNEL); |
Mauro Carvalho Chehab | ed0e372 | 2014-11-01 08:59:03 -0300 | [diff] [blame] | 1336 | if (dev->vbi_mode.alt_max_pkt_size == NULL) |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1337 | return -ENOMEM; |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1338 | |
| 1339 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { |
| 1340 | u16 tmp = |
| 1341 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
| 1342 | desc.wMaxPacketSize); |
| 1343 | dev->vbi_mode.alt_max_pkt_size[i] = |
| 1344 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1345 | dev_dbg(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1346 | "Alternate setting %i, max size= %i\n", i, |
| 1347 | dev->vbi_mode.alt_max_pkt_size[i]); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | /* Sliced CC VBI init */ |
| 1351 | |
| 1352 | /* compute alternate max packet sizes for sliced CC */ |
| 1353 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index + 1; |
| 1354 | if (idx >= dev->max_iad_interface_count) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1355 | dev_err(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1356 | "Sliced CC PCB interface #%d doesn't exist\n", idx); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1357 | return -ENODEV; |
| 1358 | } |
| 1359 | uif = udev->actconfig->interface[idx]; |
| 1360 | |
| 1361 | dev->sliced_cc_mode.end_point_addr = |
| 1362 | uif->altsetting[0].endpoint[isoc_pipe].desc. |
| 1363 | bEndpointAddress; |
| 1364 | |
| 1365 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1366 | dev_info(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1367 | "sliced CC EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1368 | dev->sliced_cc_mode.end_point_addr, |
| 1369 | dev->sliced_cc_mode.num_alt); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1370 | dev->sliced_cc_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->sliced_cc_mode.num_alt, GFP_KERNEL); |
Mauro Carvalho Chehab | ed0e372 | 2014-11-01 08:59:03 -0300 | [diff] [blame] | 1371 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1372 | return -ENOMEM; |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1373 | |
| 1374 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { |
| 1375 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
| 1376 | desc.wMaxPacketSize); |
| 1377 | dev->sliced_cc_mode.alt_max_pkt_size[i] = |
| 1378 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1379 | dev_dbg(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1380 | "Alternate setting %i, max size= %i\n", i, |
| 1381 | dev->sliced_cc_mode.alt_max_pkt_size[i]); |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1387 | /* |
| 1388 | * cx231xx_usb_probe() |
| 1389 | * checks for supported devices |
| 1390 | */ |
| 1391 | static int cx231xx_usb_probe(struct usb_interface *interface, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1392 | const struct usb_device_id *id) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1393 | { |
| 1394 | struct usb_device *udev; |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1395 | struct device *d = &interface->dev; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1396 | struct usb_interface *uif; |
| 1397 | struct cx231xx *dev = NULL; |
| 1398 | int retval = -ENODEV; |
Hans Verkuil | d73abcf | 2009-03-12 18:38:40 -0300 | [diff] [blame] | 1399 | int nr = 0, ifnum; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1400 | int i, isoc_pipe = 0; |
| 1401 | char *speed; |
Mauro Carvalho Chehab | dcb78ac | 2014-07-27 16:27:28 -0300 | [diff] [blame] | 1402 | u8 idx; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1403 | struct usb_interface_assoc_descriptor *assoc_desc; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1404 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1405 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
| 1406 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1407 | /* |
| 1408 | * Interface number 0 - IR interface (handled by mceusb driver) |
| 1409 | * Interface number 1 - AV interface (handled by this driver) |
| 1410 | */ |
| 1411 | if (ifnum != 1) |
| 1412 | return -ENODEV; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1413 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1414 | /* Check to see next free device and mark as used */ |
Mauro Carvalho Chehab | db702a7 | 2012-01-10 09:33:47 -0200 | [diff] [blame] | 1415 | do { |
| 1416 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
| 1417 | if (nr >= CX231XX_MAXBOARDS) { |
| 1418 | /* No free device slots */ |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1419 | dev_err(d, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1420 | "Supports only %i devices.\n", |
| 1421 | CX231XX_MAXBOARDS); |
Mauro Carvalho Chehab | db702a7 | 2012-01-10 09:33:47 -0200 | [diff] [blame] | 1422 | return -ENOMEM; |
| 1423 | } |
| 1424 | } while (test_and_set_bit(nr, &cx231xx_devused)); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1425 | |
Alexey Khoroshilov | 5eeb301 | 2015-01-16 19:55:26 -0300 | [diff] [blame] | 1426 | udev = usb_get_dev(interface_to_usbdev(interface)); |
| 1427 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1428 | /* allocate memory for our device state and initialize it */ |
Mauro Carvalho Chehab | 184a827 | 2014-07-27 16:27:29 -0300 | [diff] [blame] | 1429 | dev = devm_kzalloc(&udev->dev, sizeof(*dev), GFP_KERNEL); |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1430 | if (dev == NULL) { |
Alexey Khoroshilov | 5eeb301 | 2015-01-16 19:55:26 -0300 | [diff] [blame] | 1431 | retval = -ENOMEM; |
| 1432 | goto err_if; |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1433 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1434 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1435 | snprintf(dev->name, 29, "cx231xx #%d", nr); |
| 1436 | dev->devno = nr; |
| 1437 | dev->model = id->driver_info; |
| 1438 | dev->video_mode.alt = -1; |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1439 | dev->dev = d; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1440 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1441 | dev->interface_count++; |
| 1442 | /* reset gpio dir and value */ |
| 1443 | dev->gpio_dir = 0; |
| 1444 | dev->gpio_val = 0; |
| 1445 | dev->xc_fw_load_done = 0; |
| 1446 | dev->has_alsa_audio = 1; |
| 1447 | dev->power_mode = -1; |
| 1448 | atomic_set(&dev->devlist_count, 0); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1449 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1450 | /* 0 - vbi ; 1 -sliced cc mode */ |
| 1451 | dev->vbi_or_sliced_cc_mode = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1452 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1453 | /* get maximum no.of IAD interfaces */ |
Mauro Carvalho Chehab | 139d288 | 2014-07-27 16:27:27 -0300 | [diff] [blame] | 1454 | dev->max_iad_interface_count = udev->config->desc.bNumInterfaces; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1455 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1456 | /* init CIR module TBD */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1457 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1458 | /*mode_tv: digital=1 or analog=0*/ |
| 1459 | dev->mode_tv = 0; |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1460 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1461 | dev->USE_ISO = transfer_mode; |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1462 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1463 | switch (udev->speed) { |
| 1464 | case USB_SPEED_LOW: |
| 1465 | speed = "1.5"; |
| 1466 | break; |
| 1467 | case USB_SPEED_UNKNOWN: |
| 1468 | case USB_SPEED_FULL: |
| 1469 | speed = "12"; |
| 1470 | break; |
| 1471 | case USB_SPEED_HIGH: |
| 1472 | speed = "480"; |
| 1473 | break; |
| 1474 | default: |
| 1475 | speed = "unknown"; |
| 1476 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1477 | |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1478 | dev_info(d, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1479 | "New device %s %s @ %s Mbps (%04x:%04x) with %d interfaces\n", |
| 1480 | udev->manufacturer ? udev->manufacturer : "", |
| 1481 | udev->product ? udev->product : "", |
| 1482 | speed, |
| 1483 | le16_to_cpu(udev->descriptor.idVendor), |
| 1484 | le16_to_cpu(udev->descriptor.idProduct), |
| 1485 | dev->max_iad_interface_count); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1486 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1487 | /* increment interface count */ |
| 1488 | dev->interface_count++; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1489 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1490 | /* get device number */ |
| 1491 | nr = dev->devno; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1492 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 1493 | assoc_desc = udev->actconfig->intf_assoc[0]; |
| 1494 | if (assoc_desc->bFirstInterface != ifnum) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1495 | dev_err(d, "Not found matching IAD interface\n"); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1496 | retval = -ENODEV; |
| 1497 | goto err_if; |
Mauro Carvalho Chehab | 10e4ebb | 2010-10-18 21:10:46 -0300 | [diff] [blame] | 1498 | } |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1499 | |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1500 | dev_dbg(d, "registering interface %d\n", ifnum); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1501 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1502 | /* save our data pointer in this interface device */ |
Thomas Petazzoni | a116a05 | 2012-01-07 09:52:38 -0300 | [diff] [blame] | 1503 | usb_set_intfdata(interface, dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1504 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1505 | /* Create v4l2 device */ |
Janne Grunau | 7231748 | 2009-04-01 08:39:29 -0300 | [diff] [blame] | 1506 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1507 | if (retval) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1508 | dev_err(d, "v4l2_device_register failed\n"); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1509 | goto err_v4l2; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1510 | } |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1511 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1512 | /* allocate device struct */ |
Thomas Petazzoni | 15cb6af | 2012-01-07 09:52:40 -0300 | [diff] [blame] | 1513 | retval = cx231xx_init_dev(dev, udev, nr); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1514 | if (retval) |
| 1515 | goto err_init; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1516 | |
Mauro Carvalho Chehab | 4d2a7d3 | 2014-07-27 16:27:31 -0300 | [diff] [blame] | 1517 | retval = cx231xx_init_v4l2(dev, udev, interface, isoc_pipe); |
| 1518 | if (retval) |
Mauro Carvalho Chehab | dcb78ac | 2014-07-27 16:27:28 -0300 | [diff] [blame] | 1519 | goto err_init; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1520 | |
| 1521 | if (dev->current_pcb_config.ts1_source != 0xff) { |
| 1522 | /* compute alternate max packet sizes for TS1 */ |
Mauro Carvalho Chehab | dcb78ac | 2014-07-27 16:27:28 -0300 | [diff] [blame] | 1523 | idx = dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index + 1; |
| 1524 | if (idx >= dev->max_iad_interface_count) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1525 | dev_err(d, "TS1 PCB interface #%d doesn't exist\n", |
| 1526 | idx); |
Mauro Carvalho Chehab | dcb78ac | 2014-07-27 16:27:28 -0300 | [diff] [blame] | 1527 | retval = -ENODEV; |
Mauro Carvalho Chehab | 184a827 | 2014-07-27 16:27:29 -0300 | [diff] [blame] | 1528 | goto err_video_alt; |
Mauro Carvalho Chehab | dcb78ac | 2014-07-27 16:27:28 -0300 | [diff] [blame] | 1529 | } |
| 1530 | uif = udev->actconfig->interface[idx]; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1531 | |
| 1532 | dev->ts1_mode.end_point_addr = |
Hans Verkuil | 69a11a3 | 2013-02-07 15:28:53 -0300 | [diff] [blame] | 1533 | uif->altsetting[0].endpoint[isoc_pipe]. |
| 1534 | desc.bEndpointAddress; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1535 | |
| 1536 | dev->ts1_mode.num_alt = uif->num_altsetting; |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1537 | dev_info(d, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1538 | "TS EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1539 | dev->ts1_mode.end_point_addr, |
| 1540 | dev->ts1_mode.num_alt); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1541 | |
Mauro Carvalho Chehab | 184a827 | 2014-07-27 16:27:29 -0300 | [diff] [blame] | 1542 | dev->ts1_mode.alt_max_pkt_size = devm_kmalloc_array(&udev->dev, 32, dev->ts1_mode.num_alt, GFP_KERNEL); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1543 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1544 | retval = -ENOMEM; |
Mauro Carvalho Chehab | 184a827 | 2014-07-27 16:27:29 -0300 | [diff] [blame] | 1545 | goto err_video_alt; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1546 | } |
| 1547 | |
| 1548 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { |
| 1549 | u16 tmp = le16_to_cpu(uif->altsetting[i]. |
| 1550 | endpoint[isoc_pipe].desc. |
| 1551 | wMaxPacketSize); |
| 1552 | dev->ts1_mode.alt_max_pkt_size[i] = |
| 1553 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1554 | dev_dbg(d, "Alternate setting %i, max size= %i\n", |
| 1555 | i, dev->ts1_mode.alt_max_pkt_size[i]); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1556 | } |
| 1557 | } |
| 1558 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1559 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) { |
| 1560 | cx231xx_enable_OSC(dev); |
| 1561 | cx231xx_reset_out(dev); |
| 1562 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); |
| 1563 | } |
| 1564 | |
| 1565 | if (dev->model == CX231XX_BOARD_CNXT_RDE_253S) |
| 1566 | cx231xx_sleep_s5h1432(dev); |
| 1567 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1568 | /* load other modules required */ |
| 1569 | request_modules(dev); |
| 1570 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1571 | return 0; |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1572 | err_video_alt: |
| 1573 | /* cx231xx_uninit_dev: */ |
| 1574 | cx231xx_close_extension(dev); |
| 1575 | cx231xx_ir_exit(dev); |
| 1576 | cx231xx_release_analog_resources(dev); |
| 1577 | cx231xx_417_unregister(dev); |
| 1578 | cx231xx_remove_from_devlist(dev); |
| 1579 | cx231xx_dev_uninit(dev); |
| 1580 | err_init: |
| 1581 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1582 | err_v4l2: |
| 1583 | usb_set_intfdata(interface, NULL); |
| 1584 | err_if: |
| 1585 | usb_put_dev(udev); |
Mauro Carvalho Chehab | b5603a9 | 2015-02-02 10:52:26 -0200 | [diff] [blame^] | 1586 | clear_bit(nr, &cx231xx_devused); |
Alexey Khoroshilov | 256d013 | 2013-10-07 18:06:04 -0300 | [diff] [blame] | 1587 | return retval; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1588 | } |
| 1589 | |
| 1590 | /* |
| 1591 | * cx231xx_usb_disconnect() |
| 1592 | * called when the device gets diconencted |
| 1593 | * video device will be unregistered on v4l2_close in case it is still open |
| 1594 | */ |
| 1595 | static void cx231xx_usb_disconnect(struct usb_interface *interface) |
| 1596 | { |
| 1597 | struct cx231xx *dev; |
| 1598 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1599 | dev = usb_get_intfdata(interface); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1600 | usb_set_intfdata(interface, NULL); |
| 1601 | |
| 1602 | if (!dev) |
| 1603 | return; |
| 1604 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1605 | if (!dev->udev) |
| 1606 | return; |
| 1607 | |
Mauro Carvalho Chehab | 990862a | 2012-01-10 09:48:50 -0200 | [diff] [blame] | 1608 | dev->state |= DEV_DISCONNECTED; |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 1609 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1610 | flush_request_modules(dev); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1611 | |
| 1612 | /* wait until all current v4l2 io is finished then deallocate |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1613 | resources */ |
| 1614 | mutex_lock(&dev->lock); |
| 1615 | |
| 1616 | wake_up_interruptible_all(&dev->open); |
| 1617 | |
| 1618 | if (dev->users) { |
Mauro Carvalho Chehab | 336fea9 | 2014-11-03 06:07:38 -0300 | [diff] [blame] | 1619 | dev_warn(dev->dev, |
Mauro Carvalho Chehab | b7085c0 | 2014-11-02 07:21:44 -0300 | [diff] [blame] | 1620 | "device %s is open! Deregistration and memory deallocation are deferred on close.\n", |
| 1621 | video_device_node_name(dev->vdev)); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1622 | |
Mauro Carvalho Chehab | 7528cd2 | 2012-01-10 09:20:01 -0200 | [diff] [blame] | 1623 | /* Even having users, it is safe to remove the RC i2c driver */ |
| 1624 | cx231xx_ir_exit(dev); |
| 1625 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1626 | if (dev->USE_ISO) |
| 1627 | cx231xx_uninit_isoc(dev); |
| 1628 | else |
| 1629 | cx231xx_uninit_bulk(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1630 | wake_up_interruptible(&dev->wait_frame); |
| 1631 | wake_up_interruptible(&dev->wait_stream); |
| 1632 | } else { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | cx231xx_close_extension(dev); |
| 1636 | |
| 1637 | mutex_unlock(&dev->lock); |
| 1638 | |
Mauro Carvalho Chehab | 7528cd2 | 2012-01-10 09:20:01 -0200 | [diff] [blame] | 1639 | if (!dev->users) |
| 1640 | cx231xx_release_resources(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | static struct usb_driver cx231xx_usb_driver = { |
| 1644 | .name = "cx231xx", |
| 1645 | .probe = cx231xx_usb_probe, |
| 1646 | .disconnect = cx231xx_usb_disconnect, |
| 1647 | .id_table = cx231xx_id_table, |
| 1648 | }; |
| 1649 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 1650 | module_usb_driver(cx231xx_usb_driver); |