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 | |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 26 | #include <linux/delay.h> |
| 27 | #include <linux/i2c.h> |
| 28 | #include <linux/usb.h> |
| 29 | #include <media/tuner.h> |
| 30 | #include <media/tveeprom.h> |
| 31 | #include <media/v4l2-common.h> |
| 32 | #include <media/v4l2-chip-ident.h> |
| 33 | |
| 34 | #include <media/cx25840.h> |
Mauro Carvalho Chehab | 3bfb317 | 2010-09-03 10:50:24 -0300 | [diff] [blame] | 35 | #include "dvb-usb-ids.h" |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 36 | #include "xc5000.h" |
Mauro Carvalho Chehab | 55fa288 | 2010-09-29 11:07:08 -0300 | [diff] [blame] | 37 | #include "tda18271.h" |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 38 | |
| 39 | #include "cx231xx.h" |
| 40 | |
| 41 | static int tuner = -1; |
| 42 | module_param(tuner, int, 0444); |
| 43 | MODULE_PARM_DESC(tuner, "tuner type"); |
| 44 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 45 | static int transfer_mode = 1; |
| 46 | module_param(transfer_mode, int, 0444); |
| 47 | MODULE_PARM_DESC(transfer_mode, "transfer mode (1-ISO or 0-BULK)"); |
| 48 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 49 | static unsigned int disable_ir; |
| 50 | module_param(disable_ir, int, 0444); |
| 51 | MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); |
| 52 | |
| 53 | /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */ |
| 54 | static unsigned long cx231xx_devused; |
| 55 | |
| 56 | /* |
| 57 | * Reset sequences for analog/digital modes |
| 58 | */ |
| 59 | |
| 60 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 61 | {0x03, 0x01, 10}, |
| 62 | {0x03, 0x00, 30}, |
| 63 | {0x03, 0x01, 10}, |
| 64 | {-1, -1, -1}, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 65 | }; |
| 66 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 67 | /* |
| 68 | * Board definitions |
| 69 | */ |
| 70 | struct cx231xx_board cx231xx_boards[] = { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 71 | [CX231XX_BOARD_UNKNOWN] = { |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 72 | .name = "Unknown CX231xx video grabber", |
| 73 | .tuner_type = TUNER_ABSENT, |
| 74 | .input = {{ |
| 75 | .type = CX231XX_VMUX_TELEVISION, |
| 76 | .vmux = CX231XX_VIN_3_1, |
| 77 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 78 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 79 | }, { |
| 80 | .type = CX231XX_VMUX_COMPOSITE1, |
| 81 | .vmux = CX231XX_VIN_2_1, |
| 82 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 83 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 84 | }, { |
| 85 | .type = CX231XX_VMUX_SVIDEO, |
| 86 | .vmux = CX231XX_VIN_1_1 | |
| 87 | (CX231XX_VIN_1_2 << 8) | |
| 88 | CX25840_SVIDEO_ON, |
| 89 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 90 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 91 | } |
| 92 | }, |
| 93 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 94 | [CX231XX_BOARD_CNXT_CARRAERA] = { |
| 95 | .name = "Conexant Hybrid TV - CARRAERA", |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 96 | .tuner_type = TUNER_XC5000, |
| 97 | .tuner_addr = 0x61, |
| 98 | .tuner_gpio = RDE250_XCV_TUNER, |
| 99 | .tuner_sif_gpio = 0x05, |
| 100 | .tuner_scl_gpio = 0x1a, |
| 101 | .tuner_sda_gpio = 0x1b, |
| 102 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 103 | .output_mode = OUT_MODE_VIP11, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 104 | .demod_xfer_mode = 0, |
| 105 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 106 | .agc_analog_digital_select_gpio = 0x0c, |
| 107 | .gpio_pin_status_mask = 0x4001000, |
| 108 | .tuner_i2c_master = 1, |
| 109 | .demod_i2c_master = 2, |
| 110 | .has_dvb = 1, |
| 111 | .demod_addr = 0x02, |
| 112 | .norm = V4L2_STD_PAL, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 113 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 114 | .input = {{ |
| 115 | .type = CX231XX_VMUX_TELEVISION, |
| 116 | .vmux = CX231XX_VIN_3_1, |
| 117 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 118 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 119 | }, { |
| 120 | .type = CX231XX_VMUX_COMPOSITE1, |
| 121 | .vmux = CX231XX_VIN_2_1, |
| 122 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 123 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 124 | }, { |
| 125 | .type = CX231XX_VMUX_SVIDEO, |
| 126 | .vmux = CX231XX_VIN_1_1 | |
| 127 | (CX231XX_VIN_1_2 << 8) | |
| 128 | CX25840_SVIDEO_ON, |
| 129 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 130 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 131 | } |
| 132 | }, |
| 133 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 134 | [CX231XX_BOARD_CNXT_SHELBY] = { |
| 135 | .name = "Conexant Hybrid TV - SHELBY", |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 136 | .tuner_type = TUNER_XC5000, |
| 137 | .tuner_addr = 0x61, |
| 138 | .tuner_gpio = RDE250_XCV_TUNER, |
| 139 | .tuner_sif_gpio = 0x05, |
| 140 | .tuner_scl_gpio = 0x1a, |
| 141 | .tuner_sda_gpio = 0x1b, |
| 142 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 143 | .output_mode = OUT_MODE_VIP11, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 144 | .demod_xfer_mode = 0, |
| 145 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 146 | .agc_analog_digital_select_gpio = 0x0c, |
| 147 | .gpio_pin_status_mask = 0x4001000, |
| 148 | .tuner_i2c_master = 1, |
| 149 | .demod_i2c_master = 2, |
| 150 | .has_dvb = 1, |
| 151 | .demod_addr = 0x32, |
| 152 | .norm = V4L2_STD_NTSC, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 153 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 154 | .input = {{ |
| 155 | .type = CX231XX_VMUX_TELEVISION, |
| 156 | .vmux = CX231XX_VIN_3_1, |
| 157 | .amux = CX231XX_AMUX_VIDEO, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 158 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 159 | }, { |
| 160 | .type = CX231XX_VMUX_COMPOSITE1, |
| 161 | .vmux = CX231XX_VIN_2_1, |
| 162 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 163 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 164 | }, { |
| 165 | .type = CX231XX_VMUX_SVIDEO, |
| 166 | .vmux = CX231XX_VIN_1_1 | |
| 167 | (CX231XX_VIN_1_2 << 8) | |
| 168 | CX25840_SVIDEO_ON, |
| 169 | .amux = CX231XX_AMUX_LINE_IN, |
Márton Németh | 7ee0a28 | 2009-12-13 17:06:10 -0300 | [diff] [blame] | 170 | .gpio = NULL, |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 171 | } |
| 172 | }, |
| 173 | }, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 174 | [CX231XX_BOARD_CNXT_RDE_253S] = { |
| 175 | .name = "Conexant Hybrid TV - RDE253S", |
| 176 | .tuner_type = TUNER_NXP_TDA18271, |
| 177 | .tuner_addr = 0x60, |
| 178 | .tuner_gpio = RDE250_XCV_TUNER, |
| 179 | .tuner_sif_gpio = 0x05, |
| 180 | .tuner_scl_gpio = 0x1a, |
| 181 | .tuner_sda_gpio = 0x1b, |
| 182 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 183 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 184 | .demod_xfer_mode = 0, |
| 185 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 186 | .agc_analog_digital_select_gpio = 0x1c, |
| 187 | .gpio_pin_status_mask = 0x4001000, |
| 188 | .tuner_i2c_master = 1, |
| 189 | .demod_i2c_master = 2, |
| 190 | .has_dvb = 1, |
| 191 | .demod_addr = 0x02, |
| 192 | .norm = V4L2_STD_PAL, |
| 193 | |
| 194 | .input = {{ |
| 195 | .type = CX231XX_VMUX_TELEVISION, |
| 196 | .vmux = CX231XX_VIN_3_1, |
| 197 | .amux = CX231XX_AMUX_VIDEO, |
| 198 | .gpio = NULL, |
| 199 | }, { |
| 200 | .type = CX231XX_VMUX_COMPOSITE1, |
| 201 | .vmux = CX231XX_VIN_2_1, |
| 202 | .amux = CX231XX_AMUX_LINE_IN, |
| 203 | .gpio = NULL, |
| 204 | }, { |
| 205 | .type = CX231XX_VMUX_SVIDEO, |
| 206 | .vmux = CX231XX_VIN_1_1 | |
| 207 | (CX231XX_VIN_1_2 << 8) | |
| 208 | CX25840_SVIDEO_ON, |
| 209 | .amux = CX231XX_AMUX_LINE_IN, |
| 210 | .gpio = NULL, |
| 211 | } |
| 212 | }, |
| 213 | }, |
| 214 | |
| 215 | [CX231XX_BOARD_CNXT_RDU_253S] = { |
| 216 | .name = "Conexant Hybrid TV - RDU253S", |
| 217 | .tuner_type = TUNER_NXP_TDA18271, |
| 218 | .tuner_addr = 0x60, |
| 219 | .tuner_gpio = RDE250_XCV_TUNER, |
| 220 | .tuner_sif_gpio = 0x05, |
| 221 | .tuner_scl_gpio = 0x1a, |
| 222 | .tuner_sda_gpio = 0x1b, |
| 223 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 224 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 225 | .demod_xfer_mode = 0, |
| 226 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 227 | .agc_analog_digital_select_gpio = 0x1c, |
| 228 | .gpio_pin_status_mask = 0x4001000, |
| 229 | .tuner_i2c_master = 1, |
| 230 | .demod_i2c_master = 2, |
| 231 | .has_dvb = 1, |
| 232 | .demod_addr = 0x02, |
| 233 | .norm = V4L2_STD_PAL, |
| 234 | |
| 235 | .input = {{ |
| 236 | .type = CX231XX_VMUX_TELEVISION, |
| 237 | .vmux = CX231XX_VIN_3_1, |
| 238 | .amux = CX231XX_AMUX_VIDEO, |
| 239 | .gpio = NULL, |
| 240 | }, { |
| 241 | .type = CX231XX_VMUX_COMPOSITE1, |
| 242 | .vmux = CX231XX_VIN_2_1, |
| 243 | .amux = CX231XX_AMUX_LINE_IN, |
| 244 | .gpio = NULL, |
| 245 | }, { |
| 246 | .type = CX231XX_VMUX_SVIDEO, |
| 247 | .vmux = CX231XX_VIN_1_1 | |
| 248 | (CX231XX_VIN_1_2 << 8) | |
| 249 | CX25840_SVIDEO_ON, |
| 250 | .amux = CX231XX_AMUX_LINE_IN, |
| 251 | .gpio = NULL, |
| 252 | } |
| 253 | }, |
| 254 | }, |
| 255 | [CX231XX_BOARD_CNXT_VIDEO_GRABBER] = { |
| 256 | .name = "Conexant VIDEO GRABBER", |
Devin Heitmueller | 9f51259 | 2010-08-18 18:04:04 -0300 | [diff] [blame] | 257 | .tuner_type = TUNER_ABSENT, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 258 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 259 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 260 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 261 | .agc_analog_digital_select_gpio = 0x1c, |
| 262 | .gpio_pin_status_mask = 0x4001000, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 263 | .norm = V4L2_STD_PAL, |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 264 | .no_alt_vanc = 1, |
| 265 | .external_av = 1, |
| 266 | .has_417 = 1, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 267 | |
| 268 | .input = {{ |
| 269 | .type = CX231XX_VMUX_COMPOSITE1, |
| 270 | .vmux = CX231XX_VIN_2_1, |
| 271 | .amux = CX231XX_AMUX_LINE_IN, |
| 272 | .gpio = NULL, |
| 273 | }, { |
| 274 | .type = CX231XX_VMUX_SVIDEO, |
| 275 | .vmux = CX231XX_VIN_1_1 | |
| 276 | (CX231XX_VIN_1_2 << 8) | |
| 277 | CX25840_SVIDEO_ON, |
| 278 | .amux = CX231XX_AMUX_LINE_IN, |
| 279 | .gpio = NULL, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 280 | } |
| 281 | }, |
| 282 | }, |
| 283 | [CX231XX_BOARD_CNXT_RDE_250] = { |
| 284 | .name = "Conexant Hybrid TV - rde 250", |
| 285 | .tuner_type = TUNER_XC5000, |
| 286 | .tuner_addr = 0x61, |
| 287 | .tuner_gpio = RDE250_XCV_TUNER, |
| 288 | .tuner_sif_gpio = 0x05, |
| 289 | .tuner_scl_gpio = 0x1a, |
| 290 | .tuner_sda_gpio = 0x1b, |
| 291 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 292 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 293 | .demod_xfer_mode = 0, |
| 294 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 295 | .agc_analog_digital_select_gpio = 0x0c, |
| 296 | .gpio_pin_status_mask = 0x4001000, |
| 297 | .tuner_i2c_master = 1, |
| 298 | .demod_i2c_master = 2, |
| 299 | .has_dvb = 1, |
| 300 | .demod_addr = 0x02, |
| 301 | .norm = V4L2_STD_PAL, |
| 302 | |
| 303 | .input = {{ |
| 304 | .type = CX231XX_VMUX_TELEVISION, |
| 305 | .vmux = CX231XX_VIN_2_1, |
| 306 | .amux = CX231XX_AMUX_VIDEO, |
| 307 | .gpio = NULL, |
| 308 | } |
| 309 | }, |
| 310 | }, |
| 311 | [CX231XX_BOARD_CNXT_RDU_250] = { |
| 312 | .name = "Conexant Hybrid TV - RDU 250", |
| 313 | .tuner_type = TUNER_XC5000, |
| 314 | .tuner_addr = 0x61, |
| 315 | .tuner_gpio = RDE250_XCV_TUNER, |
| 316 | .tuner_sif_gpio = 0x05, |
| 317 | .tuner_scl_gpio = 0x1a, |
| 318 | .tuner_sda_gpio = 0x1b, |
| 319 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 320 | .output_mode = OUT_MODE_VIP11, |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 321 | .demod_xfer_mode = 0, |
| 322 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 323 | .agc_analog_digital_select_gpio = 0x0c, |
| 324 | .gpio_pin_status_mask = 0x4001000, |
| 325 | .tuner_i2c_master = 1, |
| 326 | .demod_i2c_master = 2, |
| 327 | .has_dvb = 1, |
| 328 | .demod_addr = 0x32, |
| 329 | .norm = V4L2_STD_NTSC, |
| 330 | |
| 331 | .input = {{ |
| 332 | .type = CX231XX_VMUX_TELEVISION, |
| 333 | .vmux = CX231XX_VIN_2_1, |
| 334 | .amux = CX231XX_AMUX_VIDEO, |
| 335 | .gpio = NULL, |
| 336 | } |
| 337 | }, |
| 338 | }, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 339 | [CX231XX_BOARD_HAUPPAUGE_EXETER] = { |
| 340 | .name = "Hauppauge EXETER", |
| 341 | .tuner_type = TUNER_NXP_TDA18271, |
| 342 | .tuner_addr = 0x60, |
| 343 | .tuner_gpio = RDE250_XCV_TUNER, |
| 344 | .tuner_sif_gpio = 0x05, |
| 345 | .tuner_scl_gpio = 0x1a, |
| 346 | .tuner_sda_gpio = 0x1b, |
| 347 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 348 | .output_mode = OUT_MODE_VIP11, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 349 | .demod_xfer_mode = 0, |
| 350 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 351 | .agc_analog_digital_select_gpio = 0x0c, |
| 352 | .gpio_pin_status_mask = 0x4001000, |
| 353 | .tuner_i2c_master = 1, |
| 354 | .demod_i2c_master = 2, |
| 355 | .has_dvb = 1, |
| 356 | .demod_addr = 0x0e, |
| 357 | .norm = V4L2_STD_NTSC, |
| 358 | |
| 359 | .input = {{ |
| 360 | .type = CX231XX_VMUX_TELEVISION, |
| 361 | .vmux = CX231XX_VIN_3_1, |
| 362 | .amux = CX231XX_AMUX_VIDEO, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 363 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 364 | }, { |
| 365 | .type = CX231XX_VMUX_COMPOSITE1, |
| 366 | .vmux = CX231XX_VIN_2_1, |
| 367 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 368 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 369 | }, { |
| 370 | .type = CX231XX_VMUX_SVIDEO, |
| 371 | .vmux = CX231XX_VIN_1_1 | |
| 372 | (CX231XX_VIN_1_2 << 8) | |
| 373 | CX25840_SVIDEO_ON, |
| 374 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 375 | .gpio = NULL, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 376 | } }, |
| 377 | }, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 378 | [CX231XX_BOARD_HAUPPAUGE_USBLIVE2] = { |
| 379 | .name = "Hauppauge USB Live 2", |
| 380 | .tuner_type = TUNER_ABSENT, |
| 381 | .decoder = CX231XX_AVDECODER, |
Devin Heitmueller | 8880621 | 2010-08-18 17:50:07 -0300 | [diff] [blame] | 382 | .output_mode = OUT_MODE_VIP11, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 383 | .demod_xfer_mode = 0, |
| 384 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 385 | .agc_analog_digital_select_gpio = 0x0c, |
| 386 | .gpio_pin_status_mask = 0x4001000, |
| 387 | .norm = V4L2_STD_NTSC, |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 388 | .no_alt_vanc = 1, |
| 389 | .external_av = 1, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 390 | .input = {{ |
| 391 | .type = CX231XX_VMUX_COMPOSITE1, |
| 392 | .vmux = CX231XX_VIN_2_1, |
| 393 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 394 | .gpio = NULL, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 395 | }, { |
| 396 | .type = CX231XX_VMUX_SVIDEO, |
| 397 | .vmux = CX231XX_VIN_1_1 | |
| 398 | (CX231XX_VIN_1_2 << 8) | |
| 399 | CX25840_SVIDEO_ON, |
| 400 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 401 | .gpio = NULL, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 402 | } }, |
| 403 | }, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 404 | [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID] = { |
| 405 | .name = "Pixelview PlayTV USB Hybrid", |
| 406 | .tuner_type = TUNER_NXP_TDA18271, |
| 407 | .tuner_addr = 0x60, |
| 408 | .decoder = CX231XX_AVDECODER, |
| 409 | .output_mode = OUT_MODE_VIP11, |
| 410 | .demod_xfer_mode = 0, |
| 411 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 412 | .agc_analog_digital_select_gpio = 0x00, /* According with PV cxPolaris.inf file */ |
| 413 | .tuner_sif_gpio = -1, |
| 414 | .tuner_scl_gpio = -1, |
| 415 | .tuner_sda_gpio = -1, |
| 416 | .gpio_pin_status_mask = 0x4001000, |
| 417 | .tuner_i2c_master = 2, |
| 418 | .demod_i2c_master = 1, |
Mauro Carvalho Chehab | 1bc25f7 | 2010-10-23 13:35:58 -0300 | [diff] [blame] | 419 | .ir_i2c_master = 2, |
Mauro Carvalho Chehab | 788e5d4 | 2010-12-17 14:47:27 -0300 | [diff] [blame] | 420 | .rc_map_name = RC_MAP_PIXELVIEW_002T, |
Mauro Carvalho Chehab | ede676c | 2010-09-27 23:44:27 -0300 | [diff] [blame] | 421 | .has_dvb = 1, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 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, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 428 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 429 | }, { |
| 430 | .type = CX231XX_VMUX_COMPOSITE1, |
| 431 | .vmux = CX231XX_VIN_2_1, |
| 432 | .amux = CX231XX_AMUX_LINE_IN, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 433 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 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, |
Peter Huewe | f72cfd8 | 2011-01-25 17:38:52 -0300 | [diff] [blame^] | 440 | .gpio = NULL, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 441 | } }, |
| 442 | }, |
Mauro Carvalho Chehab | 4e10503 | 2011-01-31 22:18:21 -0300 | [diff] [blame] | 443 | [CX231XX_BOARD_PV_XCAPTURE_USB] = { |
| 444 | .name = "Pixelview Xcapture USB", |
| 445 | .tuner_type = TUNER_ABSENT, |
| 446 | .decoder = CX231XX_AVDECODER, |
| 447 | .output_mode = OUT_MODE_VIP11, |
| 448 | .demod_xfer_mode = 0, |
| 449 | .ctl_pin_status_mask = 0xFFFFFFC4, |
| 450 | .agc_analog_digital_select_gpio = 0x0c, |
| 451 | .gpio_pin_status_mask = 0x4001000, |
| 452 | .norm = V4L2_STD_NTSC, |
| 453 | .no_alt_vanc = 1, |
| 454 | .external_av = 1, |
| 455 | .dont_use_port_3 = 1, |
| 456 | |
| 457 | .input = {{ |
| 458 | .type = CX231XX_VMUX_COMPOSITE1, |
| 459 | .vmux = CX231XX_VIN_2_1, |
| 460 | .amux = CX231XX_AMUX_LINE_IN, |
| 461 | .gpio = NULL, |
| 462 | }, { |
| 463 | .type = CX231XX_VMUX_SVIDEO, |
| 464 | .vmux = CX231XX_VIN_1_1 | |
| 465 | (CX231XX_VIN_1_2 << 8) | |
| 466 | CX25840_SVIDEO_ON, |
| 467 | .amux = CX231XX_AMUX_LINE_IN, |
| 468 | .gpio = NULL, |
| 469 | } |
| 470 | }, |
| 471 | }, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 472 | }; |
| 473 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); |
| 474 | |
| 475 | /* table of devices that work with this driver */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 476 | struct usb_device_id cx231xx_id_table[] = { |
Sri Deevi | ed559ed | 2009-03-13 18:35:14 -0300 | [diff] [blame] | 477 | {USB_DEVICE(0x0572, 0x5A3C), |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 478 | .driver_info = CX231XX_BOARD_UNKNOWN}, |
| 479 | {USB_DEVICE(0x0572, 0x58A2), |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 480 | .driver_info = CX231XX_BOARD_CNXT_CARRAERA}, |
Sri Deevi | ed559ed | 2009-03-13 18:35:14 -0300 | [diff] [blame] | 481 | {USB_DEVICE(0x0572, 0x58A1), |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 482 | .driver_info = CX231XX_BOARD_CNXT_SHELBY}, |
| 483 | {USB_DEVICE(0x0572, 0x58A4), |
| 484 | .driver_info = CX231XX_BOARD_CNXT_RDE_253S}, |
| 485 | {USB_DEVICE(0x0572, 0x58A5), |
| 486 | .driver_info = CX231XX_BOARD_CNXT_RDU_253S}, |
| 487 | {USB_DEVICE(0x0572, 0x58A6), |
| 488 | .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER}, |
| 489 | {USB_DEVICE(0x0572, 0x589E), |
| 490 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, |
| 491 | {USB_DEVICE(0x0572, 0x58A0), |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 492 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, |
Michael Krufky | 1a50fdd | 2010-07-06 18:23:53 -0300 | [diff] [blame] | 493 | {USB_DEVICE(0x2040, 0xb120), |
| 494 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, |
Devin Heitmueller | d78148f | 2010-07-06 18:25:19 -0300 | [diff] [blame] | 495 | {USB_DEVICE(0x2040, 0xb140), |
| 496 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 497 | {USB_DEVICE(0x2040, 0xc200), |
| 498 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USBLIVE2}, |
Mauro Carvalho Chehab | 9417bc6 | 2010-09-26 20:44:31 -0300 | [diff] [blame] | 499 | {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000, 0x4001), |
| 500 | .driver_info = CX231XX_BOARD_PV_PLAYTV_USB_HYBRID}, |
Mauro Carvalho Chehab | 4e10503 | 2011-01-31 22:18:21 -0300 | [diff] [blame] | 501 | {USB_DEVICE(USB_VID_PIXELVIEW, 0x5014), |
| 502 | .driver_info = CX231XX_BOARD_PV_XCAPTURE_USB}, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 503 | {}, |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 504 | }; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 505 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 506 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); |
| 507 | |
| 508 | /* cx231xx_tuner_callback |
| 509 | * will be used to reset XC5000 tuner using GPIO pin |
| 510 | */ |
| 511 | |
| 512 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) |
| 513 | { |
| 514 | int rc = 0; |
| 515 | struct cx231xx *dev = ptr; |
| 516 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 517 | if (dev->tuner_type == TUNER_XC5000) { |
| 518 | if (command == XC5000_TUNER_RESET) { |
| 519 | cx231xx_info |
Sri Deevi | b925517 | 2009-03-04 17:49:01 -0300 | [diff] [blame] | 520 | ("Tuner CB: RESET: cmd %d : tuner type %d \n", |
| 521 | command, dev->tuner_type); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 522 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 523 | 1); |
| 524 | msleep(10); |
| 525 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 526 | 0); |
| 527 | msleep(330); |
| 528 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
| 529 | 1); |
| 530 | msleep(10); |
| 531 | } |
Mauro Carvalho Chehab | 55fa288 | 2010-09-29 11:07:08 -0300 | [diff] [blame] | 532 | } else if (dev->tuner_type == TUNER_NXP_TDA18271) { |
| 533 | switch (command) { |
| 534 | case TDA18271_CALLBACK_CMD_AGC_ENABLE: |
| 535 | if (dev->model == CX231XX_BOARD_PV_PLAYTV_USB_HYBRID) |
| 536 | rc = cx231xx_set_agc_analog_digital_mux_select(dev, arg); |
| 537 | break; |
| 538 | default: |
| 539 | rc = -EINVAL; |
| 540 | break; |
| 541 | } |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 542 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 543 | return rc; |
| 544 | } |
| 545 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); |
| 546 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 547 | void cx231xx_reset_out(struct cx231xx *dev) |
| 548 | { |
| 549 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); |
| 550 | msleep(200); |
| 551 | cx231xx_set_gpio_value(dev, CX23417_RESET, 0); |
| 552 | msleep(200); |
| 553 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); |
| 554 | } |
| 555 | void cx231xx_enable_OSC(struct cx231xx *dev) |
| 556 | { |
| 557 | cx231xx_set_gpio_value(dev, CX23417_OSC_EN, 1); |
| 558 | } |
| 559 | void cx231xx_sleep_s5h1432(struct cx231xx *dev) |
| 560 | { |
| 561 | cx231xx_set_gpio_value(dev, SLEEP_S5H1432, 0); |
| 562 | } |
| 563 | |
Sri Deevi | b925517 | 2009-03-04 17:49:01 -0300 | [diff] [blame] | 564 | static inline void cx231xx_set_model(struct cx231xx *dev) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 565 | { |
| 566 | memcpy(&dev->board, &cx231xx_boards[dev->model], sizeof(dev->board)); |
| 567 | } |
| 568 | |
| 569 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, |
| 570 | * this won't work for boards with generic PCI IDs |
| 571 | */ |
| 572 | void cx231xx_pre_card_setup(struct cx231xx *dev) |
| 573 | { |
| 574 | |
| 575 | cx231xx_set_model(dev); |
| 576 | |
| 577 | cx231xx_info("Identified as %s (card=%d)\n", |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 578 | dev->board.name, dev->model); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 579 | |
Sri Deevi | 6e4f574 | 2009-03-10 21:16:26 -0300 | [diff] [blame] | 580 | /* set the direction for GPIO pins */ |
Mauro Carvalho Chehab | c10469c | 2010-09-11 11:37:51 -0300 | [diff] [blame] | 581 | if (dev->board.tuner_gpio) { |
| 582 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); |
| 583 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); |
Mauro Carvalho Chehab | 78bb6df | 2010-09-26 20:48:38 -0300 | [diff] [blame] | 584 | } |
| 585 | if (dev->board.tuner_sif_gpio >= 0) |
Mauro Carvalho Chehab | c10469c | 2010-09-11 11:37:51 -0300 | [diff] [blame] | 586 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 587 | |
Mauro Carvalho Chehab | 78bb6df | 2010-09-26 20:48:38 -0300 | [diff] [blame] | 588 | /* request some modules if any required */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 589 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 590 | /* set the mode to Analog mode initially */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 591 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); |
| 592 | |
| 593 | /* Unlock device */ |
| 594 | /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */ |
| 595 | |
| 596 | } |
| 597 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 598 | static void cx231xx_config_tuner(struct cx231xx *dev) |
| 599 | { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 600 | struct tuner_setup tun_setup; |
| 601 | struct v4l2_frequency f; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 602 | |
| 603 | if (dev->tuner_type == TUNER_ABSENT) |
| 604 | return; |
| 605 | |
| 606 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; |
| 607 | tun_setup.type = dev->tuner_type; |
| 608 | tun_setup.addr = dev->tuner_addr; |
| 609 | tun_setup.tuner_callback = cx231xx_tuner_callback; |
| 610 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 611 | tuner_call(dev, tuner, s_type_addr, &tun_setup); |
| 612 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 613 | #if 0 |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 614 | if (tun_setup.type == TUNER_XC5000) { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 615 | static struct xc2028_ctrl ctrl = { |
| 616 | .fname = XC5000_DEFAULT_FIRMWARE, |
| 617 | .max_len = 64, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 618 | .demod = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 619 | }; |
| 620 | struct v4l2_priv_tun_config cfg = { |
| 621 | .tuner = dev->tuner_type, |
| 622 | .priv = &ctrl, |
| 623 | }; |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 624 | tuner_call(dev, tuner, s_config, &cfg); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 625 | } |
| 626 | #endif |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 627 | /* configure tuner */ |
| 628 | f.tuner = 0; |
| 629 | f.type = V4L2_TUNER_ANALOG_TV; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 630 | f.frequency = 9076; /* just a magic number */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 631 | dev->ctl_freq = f.frequency; |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 632 | call_all(dev, tuner, s_frequency, &f); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 633 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 634 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 635 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 636 | void cx231xx_card_setup(struct cx231xx *dev) |
| 637 | { |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 638 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 639 | cx231xx_set_model(dev); |
| 640 | |
| 641 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; |
| 642 | if (cx231xx_boards[dev->model].tuner_addr) |
| 643 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; |
| 644 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 645 | /* request some modules */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 646 | if (dev->board.decoder == CX231XX_AVDECODER) { |
Hans Verkuil | e6574f2 | 2009-04-01 03:57:53 -0300 | [diff] [blame] | 647 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
| 648 | &dev->i2c_bus[0].i2c_adap, |
Laurent Pinchart | 9a1f8b3 | 2010-09-24 10:16:44 -0300 | [diff] [blame] | 649 | "cx25840", 0x88 >> 1, NULL); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 650 | if (dev->sd_cx25840 == NULL) |
| 651 | cx231xx_info("cx25840 subdev registration failure\n"); |
Hans Verkuil | cc26b07 | 2009-03-29 19:20:26 -0300 | [diff] [blame] | 652 | cx25840_call(dev, core, load_fw); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 653 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 654 | } |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 655 | |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 656 | /* Initialize the tuner */ |
| 657 | if (dev->board.tuner_type != TUNER_ABSENT) { |
| 658 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, |
Mauro Carvalho Chehab | 1a4aa92 | 2010-09-26 20:01:51 -0300 | [diff] [blame] | 659 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, |
Laurent Pinchart | 9a1f8b3 | 2010-09-24 10:16:44 -0300 | [diff] [blame] | 660 | "tuner", |
Devin Heitmueller | e3e0aaa | 2010-07-08 17:05:30 -0300 | [diff] [blame] | 661 | dev->tuner_addr, NULL); |
| 662 | if (dev->sd_tuner == NULL) |
| 663 | cx231xx_info("tuner subdev registration failure\n"); |
| 664 | else |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 665 | cx231xx_config_tuner(dev); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 666 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 667 | } |
| 668 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 669 | /* |
| 670 | * cx231xx_config() |
| 671 | * inits registers with sane defaults |
| 672 | */ |
| 673 | int cx231xx_config(struct cx231xx *dev) |
| 674 | { |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 675 | /* TBD need to add cx231xx specific code */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 676 | dev->mute = 1; /* maybe not the right place... */ |
| 677 | dev->volume = 0x1f; |
| 678 | |
| 679 | return 0; |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | * cx231xx_config_i2c() |
| 684 | * configure i2c attached devices |
| 685 | */ |
| 686 | void cx231xx_config_i2c(struct cx231xx *dev) |
| 687 | { |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 688 | /* u32 input = INPUT(dev->video_input)->vmux; */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 689 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 690 | call_all(dev, video, s_stream, 1); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | /* |
| 694 | * cx231xx_realease_resources() |
| 695 | * unregisters the v4l2,i2c and usb devices |
| 696 | * called when the device gets disconected or at module unload |
| 697 | */ |
| 698 | void cx231xx_release_resources(struct cx231xx *dev) |
| 699 | { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 700 | cx231xx_release_analog_resources(dev); |
| 701 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 702 | cx231xx_remove_from_devlist(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 703 | |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 704 | /* Release I2C buses */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 705 | cx231xx_dev_uninit(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 706 | |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 707 | cx231xx_ir_exit(dev); |
| 708 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 709 | usb_put_dev(dev->udev); |
| 710 | |
| 711 | /* Mark device as unused */ |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 712 | cx231xx_devused &= ~(1 << dev->devno); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 713 | } |
| 714 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 715 | /* |
| 716 | * cx231xx_init_dev() |
| 717 | * allocates and inits the device structs, registers i2c bus and v4l device |
| 718 | */ |
| 719 | static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 720 | int minor) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 721 | { |
| 722 | struct cx231xx *dev = *devhandle; |
| 723 | int retval = -ENOMEM; |
| 724 | int errCode; |
| 725 | unsigned int maxh, maxw; |
| 726 | |
| 727 | dev->udev = udev; |
| 728 | mutex_init(&dev->lock); |
| 729 | mutex_init(&dev->ctrl_urb_lock); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 730 | mutex_init(&dev->gpio_i2c_lock); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 731 | mutex_init(&dev->i2c_lock); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 732 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 733 | spin_lock_init(&dev->video_mode.slock); |
| 734 | spin_lock_init(&dev->vbi_mode.slock); |
| 735 | spin_lock_init(&dev->sliced_cc_mode.slock); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 736 | |
| 737 | init_waitqueue_head(&dev->open); |
| 738 | init_waitqueue_head(&dev->wait_frame); |
| 739 | init_waitqueue_head(&dev->wait_stream); |
| 740 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 741 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; |
| 742 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; |
| 743 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; |
| 744 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; |
| 745 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 746 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 747 | /* Query cx231xx to find what pcb config it is related to */ |
| 748 | initialize_cx231xx(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 749 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 750 | /*To workaround error number=-71 on EP0 for VideoGrabber, |
| 751 | need set alt here.*/ |
Devin Heitmueller | 4270c3c | 2010-07-31 00:49:01 -0300 | [diff] [blame] | 752 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER || |
| 753 | dev->model == CX231XX_BOARD_HAUPPAUGE_USBLIVE2) { |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 754 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); |
| 755 | cx231xx_set_alt_setting(dev, INDEX_VANC, 1); |
| 756 | } |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 757 | /* Cx231xx pre card setup */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 758 | cx231xx_pre_card_setup(dev); |
| 759 | |
| 760 | errCode = cx231xx_config(dev); |
| 761 | if (errCode) { |
| 762 | cx231xx_errdev("error configuring device\n"); |
| 763 | return -ENOMEM; |
| 764 | } |
| 765 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 766 | /* set default norm */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 767 | dev->norm = dev->board.norm; |
| 768 | |
| 769 | /* register i2c bus */ |
| 770 | errCode = cx231xx_dev_init(dev); |
| 771 | if (errCode < 0) { |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 772 | cx231xx_dev_uninit(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 773 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 774 | __func__, errCode); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 775 | return errCode; |
| 776 | } |
| 777 | |
| 778 | /* Do board specific init */ |
| 779 | cx231xx_card_setup(dev); |
| 780 | |
| 781 | /* configure the device */ |
| 782 | cx231xx_config_i2c(dev); |
| 783 | |
| 784 | maxw = norm_maxw(dev); |
| 785 | maxh = norm_maxh(dev); |
| 786 | |
| 787 | /* set default image size */ |
| 788 | dev->width = maxw; |
| 789 | dev->height = maxh; |
| 790 | dev->interlaced = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 791 | dev->video_input = 0; |
| 792 | |
| 793 | errCode = cx231xx_config(dev); |
| 794 | if (errCode < 0) { |
| 795 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 796 | __func__, errCode); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 797 | return errCode; |
| 798 | } |
| 799 | |
| 800 | /* init video dma queues */ |
| 801 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); |
| 802 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); |
| 803 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 804 | /* init vbi dma queues */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 805 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); |
| 806 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); |
| 807 | |
| 808 | /* 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] | 809 | cx231xx_add_into_devlist(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 810 | |
Mauro Carvalho Chehab | 2f86138 | 2011-01-31 22:12:15 -0300 | [diff] [blame] | 811 | if (dev->board.has_417) { |
Devin Heitmueller | 2b43db3 | 2010-08-18 18:09:28 -0300 | [diff] [blame] | 812 | printk(KERN_INFO "attach 417 %d\n", dev->model); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 813 | if (cx231xx_417_register(dev) < 0) { |
| 814 | printk(KERN_ERR |
| 815 | "%s() Failed to register 417 on VID_B\n", |
| 816 | __func__); |
| 817 | } |
| 818 | } |
| 819 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 820 | retval = cx231xx_register_analog_devices(dev); |
| 821 | if (retval < 0) { |
| 822 | cx231xx_release_resources(dev); |
Dan Carpenter | 5ae094c | 2010-11-18 00:56:37 -0300 | [diff] [blame] | 823 | return retval; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 824 | } |
| 825 | |
Mauro Carvalho Chehab | 9ab6691 | 2010-10-23 13:28:33 -0300 | [diff] [blame] | 826 | cx231xx_ir_init(dev); |
| 827 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 828 | cx231xx_init_extension(dev); |
| 829 | |
| 830 | return 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | #if defined(CONFIG_MODULES) && defined(MODULE) |
| 834 | static void request_module_async(struct work_struct *work) |
| 835 | { |
| 836 | struct cx231xx *dev = container_of(work, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 837 | struct cx231xx, request_module_wk); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 838 | |
| 839 | if (dev->has_alsa_audio) |
| 840 | request_module("cx231xx-alsa"); |
| 841 | |
| 842 | if (dev->board.has_dvb) |
| 843 | request_module("cx231xx-dvb"); |
| 844 | |
| 845 | } |
| 846 | |
| 847 | static void request_modules(struct cx231xx *dev) |
| 848 | { |
| 849 | INIT_WORK(&dev->request_module_wk, request_module_async); |
| 850 | schedule_work(&dev->request_module_wk); |
| 851 | } |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 852 | |
| 853 | static void flush_request_modules(struct cx231xx *dev) |
| 854 | { |
| 855 | flush_work_sync(&dev->request_module_wk); |
| 856 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 857 | #else |
| 858 | #define request_modules(dev) |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 859 | #define flush_request_modules(dev) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 860 | #endif /* CONFIG_MODULES */ |
| 861 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 862 | /* |
| 863 | * cx231xx_usb_probe() |
| 864 | * checks for supported devices |
| 865 | */ |
| 866 | static int cx231xx_usb_probe(struct usb_interface *interface, |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 867 | const struct usb_device_id *id) |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 868 | { |
| 869 | struct usb_device *udev; |
| 870 | struct usb_interface *uif; |
| 871 | struct cx231xx *dev = NULL; |
| 872 | int retval = -ENODEV; |
Hans Verkuil | d73abcf | 2009-03-12 18:38:40 -0300 | [diff] [blame] | 873 | int nr = 0, ifnum; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 874 | int i, isoc_pipe = 0; |
| 875 | char *speed; |
| 876 | char descr[255] = ""; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 877 | struct usb_interface *lif = NULL; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 878 | struct usb_interface_assoc_descriptor *assoc_desc; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 879 | |
| 880 | udev = usb_get_dev(interface_to_usbdev(interface)); |
| 881 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
| 882 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 883 | /* |
| 884 | * Interface number 0 - IR interface (handled by mceusb driver) |
| 885 | * Interface number 1 - AV interface (handled by this driver) |
| 886 | */ |
| 887 | if (ifnum != 1) |
| 888 | return -ENODEV; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 889 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 890 | /* Check to see next free device and mark as used */ |
| 891 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
| 892 | cx231xx_devused |= 1 << nr; |
| 893 | |
| 894 | if (nr >= CX231XX_MAXBOARDS) { |
| 895 | cx231xx_err(DRIVER_NAME |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 896 | ": Supports only %i cx231xx boards.\n", CX231XX_MAXBOARDS); |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 897 | cx231xx_devused &= ~(1 << nr); |
| 898 | return -ENOMEM; |
| 899 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 900 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 901 | /* allocate memory for our device state and initialize it */ |
| 902 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 903 | if (dev == NULL) { |
| 904 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); |
| 905 | cx231xx_devused &= ~(1 << nr); |
| 906 | return -ENOMEM; |
| 907 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 908 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 909 | snprintf(dev->name, 29, "cx231xx #%d", nr); |
| 910 | dev->devno = nr; |
| 911 | dev->model = id->driver_info; |
| 912 | dev->video_mode.alt = -1; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 913 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 914 | dev->interface_count++; |
| 915 | /* reset gpio dir and value */ |
| 916 | dev->gpio_dir = 0; |
| 917 | dev->gpio_val = 0; |
| 918 | dev->xc_fw_load_done = 0; |
| 919 | dev->has_alsa_audio = 1; |
| 920 | dev->power_mode = -1; |
| 921 | atomic_set(&dev->devlist_count, 0); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 922 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 923 | /* 0 - vbi ; 1 -sliced cc mode */ |
| 924 | dev->vbi_or_sliced_cc_mode = 0; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 925 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 926 | /* get maximum no.of IAD interfaces */ |
| 927 | assoc_desc = udev->actconfig->intf_assoc[0]; |
| 928 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 929 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 930 | /* init CIR module TBD */ |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 931 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 932 | /* store the current interface */ |
| 933 | lif = interface; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 934 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 935 | /*mode_tv: digital=1 or analog=0*/ |
| 936 | dev->mode_tv = 0; |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 937 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 938 | dev->USE_ISO = transfer_mode; |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 939 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 940 | switch (udev->speed) { |
| 941 | case USB_SPEED_LOW: |
| 942 | speed = "1.5"; |
| 943 | break; |
| 944 | case USB_SPEED_UNKNOWN: |
| 945 | case USB_SPEED_FULL: |
| 946 | speed = "12"; |
| 947 | break; |
| 948 | case USB_SPEED_HIGH: |
| 949 | speed = "480"; |
| 950 | break; |
| 951 | default: |
| 952 | speed = "unknown"; |
| 953 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 954 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 955 | if (udev->manufacturer) |
| 956 | strlcpy(descr, udev->manufacturer, sizeof(descr)); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 957 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 958 | if (udev->product) { |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 959 | if (*descr) |
| 960 | strlcat(descr, " ", sizeof(descr)); |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 961 | strlcat(descr, udev->product, sizeof(descr)); |
| 962 | } |
| 963 | if (*descr) |
| 964 | strlcat(descr, " ", sizeof(descr)); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 965 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 966 | cx231xx_info("New device %s@ %s Mbps " |
| 967 | "(%04x:%04x) with %d interfaces\n", |
| 968 | descr, |
| 969 | speed, |
| 970 | le16_to_cpu(udev->descriptor.idVendor), |
| 971 | le16_to_cpu(udev->descriptor.idProduct), |
| 972 | dev->max_iad_interface_count); |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 973 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 974 | /* store the interface 0 back */ |
| 975 | lif = udev->actconfig->interface[0]; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 976 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 977 | /* increment interface count */ |
| 978 | dev->interface_count++; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 979 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 980 | /* get device number */ |
| 981 | nr = dev->devno; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 982 | |
Mauro Carvalho Chehab | 8bb8422 | 2011-01-29 22:10:56 -0300 | [diff] [blame] | 983 | assoc_desc = udev->actconfig->intf_assoc[0]; |
| 984 | if (assoc_desc->bFirstInterface != ifnum) { |
| 985 | cx231xx_err(DRIVER_NAME ": Not found " |
| 986 | "matching IAD interface\n"); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 987 | return -ENODEV; |
Mauro Carvalho Chehab | 10e4ebb | 2010-10-18 21:10:46 -0300 | [diff] [blame] | 988 | } |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 989 | |
| 990 | cx231xx_info("registering interface %d\n", ifnum); |
| 991 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 992 | /* save our data pointer in this interface device */ |
| 993 | usb_set_intfdata(lif, dev); |
| 994 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 995 | /* |
| 996 | * AV device initialization - only done at the last interface |
| 997 | */ |
| 998 | |
| 999 | /* Create v4l2 device */ |
Janne Grunau | 7231748 | 2009-04-01 08:39:29 -0300 | [diff] [blame] | 1000 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1001 | if (retval) { |
| 1002 | cx231xx_errdev("v4l2_device_register failed\n"); |
| 1003 | cx231xx_devused &= ~(1 << nr); |
| 1004 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1005 | dev = NULL; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1006 | return -EIO; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1007 | } |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1008 | /* allocate device struct */ |
| 1009 | retval = cx231xx_init_dev(&dev, udev, nr); |
| 1010 | if (retval) { |
| 1011 | cx231xx_devused &= ~(1 << dev->devno); |
| 1012 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1013 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1014 | dev = NULL; |
| 1015 | usb_set_intfdata(lif, NULL); |
| 1016 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1017 | return retval; |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1018 | } |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1019 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1020 | /* compute alternate max packet sizes for video */ |
| 1021 | uif = udev->actconfig->interface[dev->current_pcb_config. |
| 1022 | hs_config_info[0].interface_info.video_index + 1]; |
| 1023 | |
| 1024 | dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0]. |
| 1025 | endpoint[isoc_pipe].desc.bEndpointAddress); |
| 1026 | |
| 1027 | dev->video_mode.num_alt = uif->num_altsetting; |
| 1028 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1029 | dev->video_mode.end_point_addr, |
| 1030 | dev->video_mode.num_alt); |
| 1031 | dev->video_mode.alt_max_pkt_size = |
| 1032 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); |
| 1033 | |
| 1034 | if (dev->video_mode.alt_max_pkt_size == NULL) { |
| 1035 | cx231xx_errdev("out of memory!\n"); |
| 1036 | cx231xx_devused &= ~(1 << nr); |
| 1037 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1038 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1039 | dev = NULL; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1040 | return -ENOMEM; |
| 1041 | } |
| 1042 | |
| 1043 | for (i = 0; i < dev->video_mode.num_alt; i++) { |
| 1044 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
| 1045 | desc.wMaxPacketSize); |
| 1046 | dev->video_mode.alt_max_pkt_size[i] = |
| 1047 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
| 1048 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
| 1049 | dev->video_mode.alt_max_pkt_size[i]); |
| 1050 | } |
| 1051 | |
| 1052 | /* compute alternate max packet sizes for vbi */ |
| 1053 | uif = udev->actconfig->interface[dev->current_pcb_config. |
| 1054 | hs_config_info[0].interface_info. |
| 1055 | vanc_index + 1]; |
| 1056 | |
| 1057 | dev->vbi_mode.end_point_addr = |
| 1058 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
| 1059 | bEndpointAddress); |
| 1060 | |
| 1061 | dev->vbi_mode.num_alt = uif->num_altsetting; |
| 1062 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1063 | dev->vbi_mode.end_point_addr, |
| 1064 | dev->vbi_mode.num_alt); |
| 1065 | dev->vbi_mode.alt_max_pkt_size = |
| 1066 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); |
| 1067 | |
| 1068 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { |
| 1069 | cx231xx_errdev("out of memory!\n"); |
| 1070 | cx231xx_devused &= ~(1 << nr); |
| 1071 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1072 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1073 | dev = NULL; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1074 | return -ENOMEM; |
| 1075 | } |
| 1076 | |
| 1077 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { |
| 1078 | u16 tmp = |
| 1079 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
| 1080 | desc.wMaxPacketSize); |
| 1081 | dev->vbi_mode.alt_max_pkt_size[i] = |
| 1082 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
| 1083 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
| 1084 | dev->vbi_mode.alt_max_pkt_size[i]); |
| 1085 | } |
| 1086 | |
| 1087 | /* compute alternate max packet sizes for sliced CC */ |
| 1088 | uif = udev->actconfig->interface[dev->current_pcb_config. |
| 1089 | hs_config_info[0].interface_info. |
| 1090 | hanc_index + 1]; |
| 1091 | |
| 1092 | dev->sliced_cc_mode.end_point_addr = |
| 1093 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
| 1094 | bEndpointAddress); |
| 1095 | |
| 1096 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; |
| 1097 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1098 | dev->sliced_cc_mode.end_point_addr, |
| 1099 | dev->sliced_cc_mode.num_alt); |
| 1100 | dev->sliced_cc_mode.alt_max_pkt_size = |
| 1101 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); |
| 1102 | |
| 1103 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { |
| 1104 | cx231xx_errdev("out of memory!\n"); |
| 1105 | cx231xx_devused &= ~(1 << nr); |
| 1106 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1107 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1108 | dev = NULL; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1109 | return -ENOMEM; |
| 1110 | } |
| 1111 | |
| 1112 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { |
| 1113 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
| 1114 | desc.wMaxPacketSize); |
| 1115 | dev->sliced_cc_mode.alt_max_pkt_size[i] = |
| 1116 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
| 1117 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
| 1118 | dev->sliced_cc_mode.alt_max_pkt_size[i]); |
| 1119 | } |
| 1120 | |
| 1121 | if (dev->current_pcb_config.ts1_source != 0xff) { |
| 1122 | /* compute alternate max packet sizes for TS1 */ |
| 1123 | uif = udev->actconfig->interface[dev->current_pcb_config. |
| 1124 | hs_config_info[0]. |
| 1125 | interface_info. |
| 1126 | ts1_index + 1]; |
| 1127 | |
| 1128 | dev->ts1_mode.end_point_addr = |
| 1129 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. |
| 1130 | desc.bEndpointAddress); |
| 1131 | |
| 1132 | dev->ts1_mode.num_alt = uif->num_altsetting; |
| 1133 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 1134 | dev->ts1_mode.end_point_addr, |
| 1135 | dev->ts1_mode.num_alt); |
| 1136 | dev->ts1_mode.alt_max_pkt_size = |
| 1137 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); |
| 1138 | |
| 1139 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
| 1140 | cx231xx_errdev("out of memory!\n"); |
| 1141 | cx231xx_devused &= ~(1 << nr); |
| 1142 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1143 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1144 | dev = NULL; |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1145 | return -ENOMEM; |
| 1146 | } |
| 1147 | |
| 1148 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { |
| 1149 | u16 tmp = le16_to_cpu(uif->altsetting[i]. |
| 1150 | endpoint[isoc_pipe].desc. |
| 1151 | wMaxPacketSize); |
| 1152 | dev->ts1_mode.alt_max_pkt_size[i] = |
| 1153 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
| 1154 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
| 1155 | dev->ts1_mode.alt_max_pkt_size[i]); |
| 1156 | } |
| 1157 | } |
| 1158 | |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1159 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) { |
| 1160 | cx231xx_enable_OSC(dev); |
| 1161 | cx231xx_reset_out(dev); |
| 1162 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); |
| 1163 | } |
| 1164 | |
| 1165 | if (dev->model == CX231XX_BOARD_CNXT_RDE_253S) |
| 1166 | cx231xx_sleep_s5h1432(dev); |
| 1167 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1168 | /* load other modules required */ |
| 1169 | request_modules(dev); |
| 1170 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1171 | return 0; |
| 1172 | } |
| 1173 | |
| 1174 | /* |
| 1175 | * cx231xx_usb_disconnect() |
| 1176 | * called when the device gets diconencted |
| 1177 | * video device will be unregistered on v4l2_close in case it is still open |
| 1178 | */ |
| 1179 | static void cx231xx_usb_disconnect(struct usb_interface *interface) |
| 1180 | { |
| 1181 | struct cx231xx *dev; |
| 1182 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1183 | dev = usb_get_intfdata(interface); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1184 | usb_set_intfdata(interface, NULL); |
| 1185 | |
| 1186 | if (!dev) |
| 1187 | return; |
| 1188 | |
Mauro Carvalho Chehab | 9096074 | 2009-03-22 07:52:02 -0300 | [diff] [blame] | 1189 | if (!dev->udev) |
| 1190 | return; |
| 1191 | |
Tejun Heo | 707bcf3 | 2010-12-24 16:14:20 +0100 | [diff] [blame] | 1192 | flush_request_modules(dev); |
| 1193 | |
Sri Deevi | b119612 | 2009-03-20 23:33:48 -0300 | [diff] [blame] | 1194 | /* delete v4l2 device */ |
| 1195 | v4l2_device_unregister(&dev->v4l2_dev); |
| 1196 | |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1197 | /* wait until all current v4l2 io is finished then deallocate |
| 1198 | resources */ |
| 1199 | mutex_lock(&dev->lock); |
| 1200 | |
| 1201 | wake_up_interruptible_all(&dev->open); |
| 1202 | |
| 1203 | if (dev->users) { |
| 1204 | cx231xx_warn |
Laurent Pinchart | 38c7c03 | 2009-11-27 13:57:15 -0300 | [diff] [blame] | 1205 | ("device %s is open! Deregistration and memory " |
| 1206 | "deallocation are deferred on close.\n", |
| 1207 | video_device_node_name(dev->vdev)); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1208 | |
| 1209 | dev->state |= DEV_MISCONFIGURED; |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1210 | if (dev->USE_ISO) |
| 1211 | cx231xx_uninit_isoc(dev); |
| 1212 | else |
| 1213 | cx231xx_uninit_bulk(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1214 | dev->state |= DEV_DISCONNECTED; |
| 1215 | wake_up_interruptible(&dev->wait_frame); |
| 1216 | wake_up_interruptible(&dev->wait_stream); |
| 1217 | } else { |
| 1218 | dev->state |= DEV_DISCONNECTED; |
| 1219 | cx231xx_release_resources(dev); |
| 1220 | } |
| 1221 | |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1222 | cx231xx_close_extension(dev); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1223 | |
| 1224 | mutex_unlock(&dev->lock); |
| 1225 | |
| 1226 | if (!dev->users) { |
| 1227 | kfree(dev->video_mode.alt_max_pkt_size); |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1228 | kfree(dev->vbi_mode.alt_max_pkt_size); |
| 1229 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); |
| 1230 | kfree(dev->ts1_mode.alt_max_pkt_size); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1231 | kfree(dev); |
Palash Bandyopadhyay | 64fbf44 | 2010-07-06 18:12:25 -0300 | [diff] [blame] | 1232 | dev = NULL; |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | static struct usb_driver cx231xx_usb_driver = { |
| 1237 | .name = "cx231xx", |
| 1238 | .probe = cx231xx_usb_probe, |
| 1239 | .disconnect = cx231xx_usb_disconnect, |
| 1240 | .id_table = cx231xx_id_table, |
| 1241 | }; |
| 1242 | |
| 1243 | static int __init cx231xx_module_init(void) |
| 1244 | { |
| 1245 | int result; |
| 1246 | |
Mauro Carvalho Chehab | 818fdf3 | 2009-03-13 07:41:58 -0300 | [diff] [blame] | 1247 | printk(KERN_INFO DRIVER_NAME " v4l2 driver loaded.\n"); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1248 | |
| 1249 | /* register this driver with the USB subsystem */ |
| 1250 | result = usb_register(&cx231xx_usb_driver); |
| 1251 | if (result) |
| 1252 | cx231xx_err(DRIVER_NAME |
Mauro Carvalho Chehab | 84b5dbf | 2009-03-03 06:14:34 -0300 | [diff] [blame] | 1253 | " usb_register failed. Error number %d.\n", result); |
Sri Deevi | e0d3baf | 2009-03-03 14:37:50 -0300 | [diff] [blame] | 1254 | |
| 1255 | return result; |
| 1256 | } |
| 1257 | |
| 1258 | static void __exit cx231xx_module_exit(void) |
| 1259 | { |
| 1260 | /* deregister this driver with the USB subsystem */ |
| 1261 | usb_deregister(&cx231xx_usb_driver); |
| 1262 | } |
| 1263 | |
| 1264 | module_init(cx231xx_module_init); |
| 1265 | module_exit(cx231xx_module_exit); |