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