diff options
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-cards.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 976 |
1 files changed, 514 insertions, 462 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index c567e5a9eec..a1f6ed645ad 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -2,7 +2,7 @@ | |||
2 | cx231xx-cards.c - driver for Conexant Cx23100/101/102 USB video capture devices | 2 | cx231xx-cards.c - driver for Conexant Cx23100/101/102 USB video capture devices |
3 | 3 | ||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | 4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> |
5 | Based on em28xx driver | 5 | Based on em28xx driver |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
@@ -50,131 +50,151 @@ static unsigned long cx231xx_devused; | |||
50 | */ | 50 | */ |
51 | 51 | ||
52 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { | 52 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { |
53 | { 0x03, 0x01, 10 }, | 53 | {0x03, 0x01, 10}, |
54 | { 0x03, 0x00, 30 }, | 54 | {0x03, 0x00, 30}, |
55 | { 0x03, 0x01, 10 }, | 55 | {0x03, 0x01, 10}, |
56 | { -1, -1, -1 }, | 56 | {-1, -1, -1}, |
57 | }; | 57 | }; |
58 | 58 | ||
59 | |||
60 | |||
61 | /* | 59 | /* |
62 | * Board definitions | 60 | * Board definitions |
63 | */ | 61 | */ |
64 | struct cx231xx_board cx231xx_boards[] = { | 62 | struct cx231xx_board cx231xx_boards[] = { |
65 | 63 | ||
66 | [CX231XX_BOARD_UNKNOWN] = { | 64 | [CX231XX_BOARD_UNKNOWN] = { |
67 | .name = "Unknown CX231xx video grabber", | 65 | .name = "Unknown CX231xx video grabber", |
68 | .tuner_type = TUNER_ABSENT, | 66 | .tuner_type = TUNER_ABSENT, |
69 | .input = { { | 67 | .input = {{ |
70 | .type = CX231XX_VMUX_TELEVISION, | 68 | .type = CX231XX_VMUX_TELEVISION, |
71 | .vmux = CX231XX_VIN_3_1, | 69 | .vmux = CX231XX_VIN_3_1, |
72 | .amux = CX231XX_AMUX_VIDEO, | 70 | .amux = CX231XX_AMUX_VIDEO, |
73 | .gpio = 0, | 71 | .gpio = 0, |
74 | }, { | 72 | }, { |
75 | .type = CX231XX_VMUX_COMPOSITE1, | 73 | .type = |
76 | .vmux = CX231XX_VIN_2_1, | 74 | CX231XX_VMUX_COMPOSITE1, |
77 | .amux = CX231XX_AMUX_LINE_IN, | 75 | .vmux = CX231XX_VIN_2_1, |
78 | .gpio = 0, | 76 | .amux = CX231XX_AMUX_LINE_IN, |
79 | }, { | 77 | .gpio = 0, |
80 | .type = CX231XX_VMUX_SVIDEO, | 78 | }, { |
81 | .vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | | 79 | .type = |
82 | CX25840_SVIDEO_ON, | 80 | CX231XX_VMUX_SVIDEO, |
83 | .amux = CX231XX_AMUX_LINE_IN, | 81 | .vmux = |
84 | .gpio = 0, | 82 | CX231XX_VIN_1_1 | |
85 | } }, | 83 | (CX231XX_VIN_1_2 << 8) | |
86 | }, | 84 | CX25840_SVIDEO_ON, |
85 | .amux = | ||
86 | CX231XX_AMUX_LINE_IN, | ||
87 | .gpio = 0, | ||
88 | }}, | ||
89 | }, | ||
87 | 90 | ||
88 | [CX231XX_BOARD_CNXT_RDE_250] = { | 91 | [CX231XX_BOARD_CNXT_RDE_250] = { |
89 | .name = "Conexant Hybrid TV - RDE250", | 92 | .name = "Conexant Hybrid TV - RDE250", |
90 | .valid = CX231XX_BOARD_VALIDATED, | 93 | .valid = CX231XX_BOARD_VALIDATED, |
91 | .tuner_type = TUNER_XC5000, | 94 | .tuner_type = TUNER_XC5000, |
92 | .tuner_addr = 0x61, | 95 | .tuner_addr = 0x61, |
93 | .tuner_gpio = RDE250_XCV_TUNER, | 96 | .tuner_gpio = RDE250_XCV_TUNER, |
94 | .tuner_sif_gpio = 0x05, | 97 | .tuner_sif_gpio = 0x05, |
95 | .tuner_scl_gpio = 0x1a, | 98 | .tuner_scl_gpio = 0x1a, |
96 | .tuner_sda_gpio = 0x1b, | 99 | .tuner_sda_gpio = 0x1b, |
97 | .decoder = CX231XX_AVDECODER, | 100 | .decoder = CX231XX_AVDECODER, |
98 | .demod_xfer_mode = 0, | 101 | .demod_xfer_mode = 0, |
99 | .ctl_pin_status_mask = 0xFFFFFFC4, | 102 | .ctl_pin_status_mask = 0xFFFFFFC4, |
100 | .agc_analog_digital_select_gpio = 0x0c, | 103 | .agc_analog_digital_select_gpio = 0x0c, |
101 | .gpio_pin_status_mask = 0x4001000, | 104 | .gpio_pin_status_mask = 0x4001000, |
102 | .tuner_i2c_master = 1, | 105 | .tuner_i2c_master = 1, |
103 | .demod_i2c_master = 2, | 106 | .demod_i2c_master = 2, |
104 | .has_dvb = 1, | 107 | .has_dvb = 1, |
105 | .demod_addr = 0x02, | 108 | .demod_addr = 0x02, |
106 | .norm = V4L2_STD_PAL, | 109 | .norm = V4L2_STD_PAL, |
107 | 110 | ||
108 | .input = { { | 111 | .input = {{ |
109 | .type = CX231XX_VMUX_TELEVISION, | 112 | .type = |
110 | .vmux = CX231XX_VIN_3_1, | 113 | CX231XX_VMUX_TELEVISION, |
111 | .amux = CX231XX_AMUX_VIDEO, | 114 | .vmux = CX231XX_VIN_3_1, |
112 | .gpio = 0, | 115 | .amux = CX231XX_AMUX_VIDEO, |
113 | }, { | 116 | .gpio = 0, |
114 | .type = CX231XX_VMUX_COMPOSITE1, | 117 | }, { |
115 | .vmux = CX231XX_VIN_2_1, | 118 | .type = |
116 | .amux = CX231XX_AMUX_LINE_IN, | 119 | CX231XX_VMUX_COMPOSITE1, |
117 | .gpio = 0, | 120 | .vmux = CX231XX_VIN_2_1, |
118 | }, { | 121 | .amux = |
119 | .type = CX231XX_VMUX_SVIDEO, | 122 | CX231XX_AMUX_LINE_IN, |
120 | .vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | | 123 | .gpio = 0, |
121 | CX25840_SVIDEO_ON, | 124 | }, { |
122 | .amux = CX231XX_AMUX_LINE_IN, | 125 | .type = |
123 | .gpio = 0, | 126 | CX231XX_VMUX_SVIDEO, |
124 | } }, | 127 | .vmux = |
125 | }, | 128 | CX231XX_VIN_1_1 | |
126 | 129 | (CX231XX_VIN_1_2 << | |
127 | [CX231XX_BOARD_CNXT_RDU_250] = { | 130 | 8) | |
128 | .name = "Conexant Hybrid TV - RDU250", | 131 | CX25840_SVIDEO_ON, |
129 | .valid = CX231XX_BOARD_VALIDATED, | 132 | .amux = |
130 | .tuner_type = TUNER_XC5000, | 133 | CX231XX_AMUX_LINE_IN, |
131 | .tuner_addr = 0x61, | 134 | .gpio = 0, |
132 | .tuner_gpio = RDE250_XCV_TUNER, | 135 | }}, |
133 | .tuner_sif_gpio = 0x05, | 136 | }, |
134 | .tuner_scl_gpio = 0x1a, | 137 | |
135 | .tuner_sda_gpio = 0x1b, | 138 | [CX231XX_BOARD_CNXT_RDU_250] = { |
136 | .decoder = CX231XX_AVDECODER, | 139 | .name = "Conexant Hybrid TV - RDU250", |
137 | .demod_xfer_mode = 0, | 140 | .valid = CX231XX_BOARD_VALIDATED, |
138 | .ctl_pin_status_mask = 0xFFFFFFC4, | 141 | .tuner_type = TUNER_XC5000, |
139 | .agc_analog_digital_select_gpio = 0x0c, | 142 | .tuner_addr = 0x61, |
140 | .gpio_pin_status_mask = 0x4001000, | 143 | .tuner_gpio = RDE250_XCV_TUNER, |
141 | .tuner_i2c_master = 1, | 144 | .tuner_sif_gpio = 0x05, |
142 | .demod_i2c_master = 2, | 145 | .tuner_scl_gpio = 0x1a, |
143 | .has_dvb = 1, | 146 | .tuner_sda_gpio = 0x1b, |
144 | .demod_addr = 0x32, | 147 | .decoder = CX231XX_AVDECODER, |
145 | .norm = V4L2_STD_NTSC, | 148 | .demod_xfer_mode = 0, |
146 | 149 | .ctl_pin_status_mask = 0xFFFFFFC4, | |
147 | .input = { { | 150 | .agc_analog_digital_select_gpio = 0x0c, |
148 | .type = CX231XX_VMUX_TELEVISION, | 151 | .gpio_pin_status_mask = 0x4001000, |
149 | .vmux = CX231XX_VIN_3_1, | 152 | .tuner_i2c_master = 1, |
150 | .amux = CX231XX_AMUX_VIDEO, | 153 | .demod_i2c_master = 2, |
151 | .gpio = 0, | 154 | .has_dvb = 1, |
152 | }, { | 155 | .demod_addr = 0x32, |
153 | .type = CX231XX_VMUX_COMPOSITE1, | 156 | .norm = V4L2_STD_NTSC, |
154 | .vmux = CX231XX_VIN_2_1, | 157 | |
155 | .amux = CX231XX_AMUX_LINE_IN, | 158 | .input = {{ |
156 | .gpio = 0, | 159 | .type = |
157 | }, { | 160 | CX231XX_VMUX_TELEVISION, |
158 | .type = CX231XX_VMUX_SVIDEO, | 161 | .vmux = CX231XX_VIN_3_1, |
159 | .vmux = CX231XX_VIN_1_1 | (CX231XX_VIN_1_2 << 8 ) | | 162 | .amux = CX231XX_AMUX_VIDEO, |
160 | CX25840_SVIDEO_ON, | 163 | .gpio = 0, |
161 | .amux = CX231XX_AMUX_LINE_IN, | 164 | }, { |
162 | .gpio = 0, | 165 | .type = |
163 | } }, | 166 | CX231XX_VMUX_COMPOSITE1, |
164 | }, | 167 | .vmux = CX231XX_VIN_2_1, |
168 | .amux = | ||
169 | CX231XX_AMUX_LINE_IN, | ||
170 | .gpio = 0, | ||
171 | }, { | ||
172 | .type = | ||
173 | CX231XX_VMUX_SVIDEO, | ||
174 | .vmux = | ||
175 | CX231XX_VIN_1_1 | | ||
176 | (CX231XX_VIN_1_2 << | ||
177 | 8) | | ||
178 | CX25840_SVIDEO_ON, | ||
179 | .amux = | ||
180 | CX231XX_AMUX_LINE_IN, | ||
181 | .gpio = 0, | ||
182 | }}, | ||
183 | }, | ||
165 | }; | 184 | }; |
166 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); | 185 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); |
167 | 186 | ||
168 | /* table of devices that work with this driver */ | 187 | /* table of devices that work with this driver */ |
169 | struct usb_device_id cx231xx_id_table [] = { | 188 | struct usb_device_id cx231xx_id_table[] = { |
170 | { USB_DEVICE(0x0572, 0x58A0), | 189 | {USB_DEVICE(0x0572, 0x58A0), |
171 | .driver_info = CX231XX_BOARD_UNKNOWN }, | 190 | .driver_info = CX231XX_BOARD_UNKNOWN}, |
172 | { USB_DEVICE(0x0572, 0x58A2), | 191 | {USB_DEVICE(0x0572, 0x58A2), |
173 | .driver_info = CX231XX_BOARD_CNXT_RDE_250 }, | 192 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, |
174 | { USB_DEVICE(0x0572, 0x5A3C), | 193 | {USB_DEVICE(0x0572, 0x5A3C), |
175 | .driver_info = CX231XX_BOARD_CNXT_RDU_250 }, | 194 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, |
176 | { }, | 195 | {}, |
177 | }; | 196 | }; |
197 | |||
178 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); | 198 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); |
179 | 199 | ||
180 | /* cx231xx_tuner_callback | 200 | /* cx231xx_tuner_callback |
@@ -186,21 +206,26 @@ int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) | |||
186 | int rc = 0; | 206 | int rc = 0; |
187 | struct cx231xx *dev = ptr; | 207 | struct cx231xx *dev = ptr; |
188 | 208 | ||
189 | if (dev->tuner_type == TUNER_XC5000) { | 209 | if (dev->tuner_type == TUNER_XC5000) { |
190 | if (command == XC5000_TUNER_RESET) { | 210 | if (command == XC5000_TUNER_RESET) { |
191 | cx231xx_info("Tuner Call back : RESET : command %d : tuner type %d \n", | 211 | cx231xx_info |
192 | command, dev->tuner_type); | 212 | ("Tuner Call back : RESET : command %d : tuner type %d \n", |
193 | 213 | command, dev->tuner_type); | |
194 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); | 214 | |
195 | msleep(10); | 215 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
196 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,0); | 216 | 1); |
197 | msleep(330); | 217 | msleep(10); |
198 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); | 218 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
199 | msleep(10); | 219 | 0); |
200 | } | 220 | msleep(330); |
201 | } | 221 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, |
222 | 1); | ||
223 | msleep(10); | ||
224 | } | ||
225 | } | ||
202 | return rc; | 226 | return rc; |
203 | } | 227 | } |
228 | |||
204 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); | 229 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); |
205 | 230 | ||
206 | static void inline cx231xx_set_model(struct cx231xx *dev) | 231 | static void inline cx231xx_set_model(struct cx231xx *dev) |
@@ -217,34 +242,34 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) | |||
217 | cx231xx_set_model(dev); | 242 | cx231xx_set_model(dev); |
218 | 243 | ||
219 | cx231xx_info("Identified as %s (card=%d)\n", | 244 | cx231xx_info("Identified as %s (card=%d)\n", |
220 | dev->board.name, dev->model); | 245 | dev->board.name, dev->model); |
221 | 246 | ||
222 | /* Do card specific if any */ | 247 | /* Do card specific if any */ |
223 | switch (dev->model) { | 248 | switch (dev->model) { |
224 | case CX231XX_BOARD_CNXT_RDE_250: | 249 | case CX231XX_BOARD_CNXT_RDE_250: |
225 | /* do card specific GPIO settings if required */ | 250 | /* do card specific GPIO settings if required */ |
226 | cx231xx_info("Precard: Board is Conexnat RDE 250\n"); | 251 | cx231xx_info("Precard: Board is Conexnat RDE 250\n"); |
227 | /* set the direction for GPIO pins */ | 252 | /* set the direction for GPIO pins */ |
228 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit,1); | 253 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); |
229 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); | 254 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); |
230 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio,1); | 255 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); |
231 | break; | 256 | break; |
232 | case CX231XX_BOARD_CNXT_RDU_250: | 257 | case CX231XX_BOARD_CNXT_RDU_250: |
233 | /* do card specific GPIO settings if required */ | 258 | /* do card specific GPIO settings if required */ |
234 | cx231xx_info("Precard: Board is Conexnat RDU 250\n"); | 259 | cx231xx_info("Precard: Board is Conexnat RDU 250\n"); |
235 | /* set the direction for GPIO pins */ | 260 | /* set the direction for GPIO pins */ |
236 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit,1); | 261 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); |
237 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,1); | 262 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); |
238 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio,1); | 263 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); |
239 | break; | 264 | break; |
240 | } | 265 | } |
241 | 266 | ||
242 | /* request some modules if any required */ | 267 | /* request some modules if any required */ |
243 | 268 | ||
244 | /* reset the Tuner */ | 269 | /* reset the Tuner */ |
245 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 270 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); |
246 | 271 | ||
247 | /* set the mode to Analog mode initially */ | 272 | /* set the mode to Analog mode initially */ |
248 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | 273 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); |
249 | 274 | ||
250 | /* Unlock device */ | 275 | /* Unlock device */ |
@@ -256,8 +281,8 @@ void cx231xx_pre_card_setup(struct cx231xx *dev) | |||
256 | 281 | ||
257 | static void cx231xx_config_tuner(struct cx231xx *dev) | 282 | static void cx231xx_config_tuner(struct cx231xx *dev) |
258 | { | 283 | { |
259 | struct tuner_setup tun_setup; | 284 | struct tuner_setup tun_setup; |
260 | struct v4l2_frequency f; | 285 | struct v4l2_frequency f; |
261 | 286 | ||
262 | if (dev->tuner_type == TUNER_ABSENT) | 287 | if (dev->tuner_type == TUNER_ABSENT) |
263 | return; | 288 | return; |
@@ -267,26 +292,28 @@ static void cx231xx_config_tuner(struct cx231xx *dev) | |||
267 | tun_setup.addr = dev->tuner_addr; | 292 | tun_setup.addr = dev->tuner_addr; |
268 | tun_setup.tuner_callback = cx231xx_tuner_callback; | 293 | tun_setup.tuner_callback = cx231xx_tuner_callback; |
269 | 294 | ||
270 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR, &tun_setup); | 295 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_TYPE_ADDR, |
296 | &tun_setup); | ||
271 | #if 0 | 297 | #if 0 |
272 | if (tun_setup.type == TUNER_XC5000) { | 298 | if (tun_setup.type == TUNER_XC5000) { |
273 | static struct xc2028_ctrl ctrl = { | 299 | static struct xc2028_ctrl ctrl = { |
274 | .fname = XC5000_DEFAULT_FIRMWARE, | 300 | .fname = XC5000_DEFAULT_FIRMWARE, |
275 | .max_len = 64, | 301 | .max_len = 64, |
276 | .demod = 0; | 302 | .demod = 0; |
277 | }; | 303 | }; |
278 | struct v4l2_priv_tun_config cfg = { | 304 | struct v4l2_priv_tun_config cfg = { |
279 | .tuner = dev->tuner_type, | 305 | .tuner = dev->tuner_type, |
280 | .priv = &ctrl, | 306 | .priv = &ctrl, |
281 | }; | 307 | }; |
282 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG, &cfg); | 308 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], TUNER_SET_CONFIG, |
309 | &cfg); | ||
283 | } | 310 | } |
284 | #endif | 311 | #endif |
285 | 312 | ||
286 | /* configure tuner */ | 313 | /* configure tuner */ |
287 | f.tuner = 0; | 314 | f.tuner = 0; |
288 | f.type = V4L2_TUNER_ANALOG_TV; | 315 | f.type = V4L2_TUNER_ANALOG_TV; |
289 | f.frequency = 9076; /* just a magic number */ | 316 | f.frequency = 9076; /* just a magic number */ |
290 | dev->ctl_freq = f.frequency; | 317 | dev->ctl_freq = f.frequency; |
291 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f); | 318 | cx231xx_i2c_call_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, &f); |
292 | } | 319 | } |
@@ -298,18 +325,18 @@ void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir) | |||
298 | { | 325 | { |
299 | if (disable_ir) { | 326 | if (disable_ir) { |
300 | ir->get_key = NULL; | 327 | ir->get_key = NULL; |
301 | return ; | 328 | return; |
302 | } | 329 | } |
303 | 330 | ||
304 | /* detect & configure */ | 331 | /* detect & configure */ |
305 | switch (dev->model) { | 332 | switch (dev->model) { |
306 | 333 | ||
307 | case CX231XX_BOARD_CNXT_RDE_250: | 334 | case CX231XX_BOARD_CNXT_RDE_250: |
308 | break; | 335 | break; |
309 | case CX231XX_BOARD_CNXT_RDU_250: | 336 | case CX231XX_BOARD_CNXT_RDU_250: |
310 | break; | 337 | break; |
311 | default: | 338 | default: |
312 | break; | 339 | break; |
313 | } | 340 | } |
314 | } | 341 | } |
315 | 342 | ||
@@ -321,58 +348,55 @@ void cx231xx_card_setup(struct cx231xx *dev) | |||
321 | if (cx231xx_boards[dev->model].tuner_addr) | 348 | if (cx231xx_boards[dev->model].tuner_addr) |
322 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; | 349 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; |
323 | 350 | ||
324 | cx231xx_info(": tuner type %d, tuner address %d \n", | 351 | cx231xx_info(": tuner type %d, tuner address %d \n", |
325 | dev->tuner_type, dev->tuner_addr); | 352 | dev->tuner_type, dev->tuner_addr); |
326 | 353 | ||
327 | /* Do card specific if any */ | 354 | /* Do card specific if any */ |
328 | switch (dev->model) { | 355 | switch (dev->model) { |
329 | case CX231XX_BOARD_CNXT_RDE_250: | 356 | case CX231XX_BOARD_CNXT_RDE_250: |
330 | /* do card specific GPIO settings if required */ | 357 | /* do card specific GPIO settings if required */ |
331 | cx231xx_info("Board is Conexnat RDE 250\n"); | 358 | cx231xx_info("Board is Conexnat RDE 250\n"); |
332 | break; | 359 | break; |
333 | case CX231XX_BOARD_CNXT_RDU_250: | 360 | case CX231XX_BOARD_CNXT_RDU_250: |
334 | /* do card specific GPIO settings if required */ | 361 | /* do card specific GPIO settings if required */ |
335 | cx231xx_info("Board is Conexnat RDU 250\n"); | 362 | cx231xx_info("Board is Conexnat RDU 250\n"); |
336 | break; | 363 | break; |
337 | } | 364 | } |
338 | 365 | ||
339 | if (dev->board.valid == CX231XX_BOARD_NOT_VALIDATED) { | 366 | if (dev->board.valid == CX231XX_BOARD_NOT_VALIDATED) { |
340 | cx231xx_errdev("\n\n"); | 367 | cx231xx_errdev("\n\n"); |
341 | cx231xx_errdev("The support for this board weren't " | 368 | cx231xx_errdev("The support for this board weren't " |
342 | "valid yet.\n"); | 369 | "valid yet.\n"); |
343 | cx231xx_errdev("Please send a report of having this working\n"); | 370 | cx231xx_errdev("Please send a report of having this working\n"); |
344 | cx231xx_errdev("not to V4L mailing list (and/or to other " | 371 | cx231xx_errdev("not to V4L mailing list (and/or to other " |
345 | "addresses)\n\n"); | 372 | "addresses)\n\n"); |
346 | } | 373 | } |
347 | 374 | ||
348 | |||
349 | /* request some modules */ | 375 | /* request some modules */ |
350 | if (dev->board.decoder == CX231XX_AVDECODER) { | 376 | if (dev->board.decoder == CX231XX_AVDECODER) { |
351 | cx231xx_info(": Requesting cx25840 module\n"); | 377 | cx231xx_info(": Requesting cx25840 module\n"); |
352 | request_module("cx25840"); | 378 | request_module("cx25840"); |
353 | } | 379 | } |
354 | #if 0 | 380 | #if 0 |
355 | if (dev->board.tuner_type != TUNER_ABSENT) { | 381 | if (dev->board.tuner_type != TUNER_ABSENT) { |
356 | cx231xx_info(": Requesting Tuner module\n"); | 382 | cx231xx_info(": Requesting Tuner module\n"); |
357 | request_module("tuner"); | 383 | request_module("tuner"); |
358 | } | 384 | } |
359 | 385 | ||
360 | cx231xx_config_tuner(dev); | 386 | cx231xx_config_tuner(dev); |
361 | 387 | ||
362 | /* TBD IR will be added later */ | 388 | /* TBD IR will be added later */ |
363 | cx231xx_ir_init(dev); | 389 | cx231xx_ir_init(dev); |
364 | #endif | 390 | #endif |
365 | } | 391 | } |
366 | 392 | ||
367 | |||
368 | |||
369 | /* | 393 | /* |
370 | * cx231xx_config() | 394 | * cx231xx_config() |
371 | * inits registers with sane defaults | 395 | * inits registers with sane defaults |
372 | */ | 396 | */ |
373 | int cx231xx_config(struct cx231xx *dev) | 397 | int cx231xx_config(struct cx231xx *dev) |
374 | { | 398 | { |
375 | /* TBD need to add cx231xx specific code */ | 399 | /* TBD need to add cx231xx specific code */ |
376 | dev->mute = 1; /* maybe not the right place... */ | 400 | dev->mute = 1; /* maybe not the right place... */ |
377 | dev->volume = 0x1f; | 401 | dev->volume = 0x1f; |
378 | 402 | ||
@@ -401,30 +425,29 @@ void cx231xx_config_i2c(struct cx231xx *dev) | |||
401 | void cx231xx_release_resources(struct cx231xx *dev) | 425 | void cx231xx_release_resources(struct cx231xx *dev) |
402 | { | 426 | { |
403 | 427 | ||
404 | #if 0 /* TBD IR related */ | 428 | #if 0 /* TBD IR related */ |
405 | if (dev->ir) | 429 | if (dev->ir) |
406 | cx231xx_ir_fini(dev); | 430 | cx231xx_ir_fini(dev); |
407 | #endif | 431 | #endif |
408 | 432 | ||
409 | cx231xx_release_analog_resources(dev); | 433 | cx231xx_release_analog_resources(dev); |
410 | 434 | ||
411 | cx231xx_remove_from_devlist(dev); | 435 | cx231xx_remove_from_devlist(dev); |
412 | 436 | ||
413 | cx231xx_dev_uninit(dev); | 437 | cx231xx_dev_uninit(dev); |
414 | 438 | ||
415 | usb_put_dev(dev->udev); | 439 | usb_put_dev(dev->udev); |
416 | 440 | ||
417 | /* Mark device as unused */ | 441 | /* Mark device as unused */ |
418 | cx231xx_devused &= ~(1<<dev->devno); | 442 | cx231xx_devused &= ~(1 << dev->devno); |
419 | } | 443 | } |
420 | 444 | ||
421 | |||
422 | /* | 445 | /* |
423 | * cx231xx_init_dev() | 446 | * cx231xx_init_dev() |
424 | * allocates and inits the device structs, registers i2c bus and v4l device | 447 | * allocates and inits the device structs, registers i2c bus and v4l device |
425 | */ | 448 | */ |
426 | static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | 449 | static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, |
427 | int minor) | 450 | int minor) |
428 | { | 451 | { |
429 | struct cx231xx *dev = *devhandle; | 452 | struct cx231xx *dev = *devhandle; |
430 | int retval = -ENOMEM; | 453 | int retval = -ENOMEM; |
@@ -434,26 +457,26 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | |||
434 | dev->udev = udev; | 457 | dev->udev = udev; |
435 | mutex_init(&dev->lock); | 458 | mutex_init(&dev->lock); |
436 | mutex_init(&dev->ctrl_urb_lock); | 459 | mutex_init(&dev->ctrl_urb_lock); |
437 | mutex_init(&dev->gpio_i2c_lock); | 460 | mutex_init(&dev->gpio_i2c_lock); |
438 | 461 | ||
439 | spin_lock_init(&dev->video_mode.slock); | 462 | spin_lock_init(&dev->video_mode.slock); |
440 | spin_lock_init(&dev->vbi_mode.slock); | 463 | spin_lock_init(&dev->vbi_mode.slock); |
441 | spin_lock_init(&dev->sliced_cc_mode.slock); | 464 | spin_lock_init(&dev->sliced_cc_mode.slock); |
442 | 465 | ||
443 | init_waitqueue_head(&dev->open); | 466 | init_waitqueue_head(&dev->open); |
444 | init_waitqueue_head(&dev->wait_frame); | 467 | init_waitqueue_head(&dev->wait_frame); |
445 | init_waitqueue_head(&dev->wait_stream); | 468 | init_waitqueue_head(&dev->wait_stream); |
446 | 469 | ||
447 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; | 470 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; |
448 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; | 471 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; |
449 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; | 472 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; |
450 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; | 473 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; |
451 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; | 474 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; |
452 | 475 | ||
453 | /* Query cx231xx to find what pcb config it is related to */ | 476 | /* Query cx231xx to find what pcb config it is related to */ |
454 | initialize_cx231xx(dev); | 477 | initialize_cx231xx(dev); |
455 | 478 | ||
456 | /* Cx231xx pre card setup */ | 479 | /* Cx231xx pre card setup */ |
457 | cx231xx_pre_card_setup(dev); | 480 | cx231xx_pre_card_setup(dev); |
458 | 481 | ||
459 | errCode = cx231xx_config(dev); | 482 | errCode = cx231xx_config(dev); |
@@ -462,14 +485,14 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | |||
462 | return -ENOMEM; | 485 | return -ENOMEM; |
463 | } | 486 | } |
464 | 487 | ||
465 | /* set default norm */ | 488 | /* set default norm */ |
466 | dev->norm = dev->board.norm; | 489 | dev->norm = dev->board.norm; |
467 | 490 | ||
468 | /* register i2c bus */ | 491 | /* register i2c bus */ |
469 | errCode = cx231xx_dev_init(dev); | 492 | errCode = cx231xx_dev_init(dev); |
470 | if (errCode < 0) { | 493 | if (errCode < 0) { |
471 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", | 494 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", |
472 | __func__, errCode); | 495 | __func__, errCode); |
473 | return errCode; | 496 | return errCode; |
474 | } | 497 | } |
475 | 498 | ||
@@ -493,7 +516,7 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | |||
493 | errCode = cx231xx_config(dev); | 516 | errCode = cx231xx_config(dev); |
494 | if (errCode < 0) { | 517 | if (errCode < 0) { |
495 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", | 518 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", |
496 | __func__, errCode); | 519 | __func__, errCode); |
497 | return errCode; | 520 | return errCode; |
498 | } | 521 | } |
499 | 522 | ||
@@ -501,13 +524,13 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | |||
501 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); | 524 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); |
502 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); | 525 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); |
503 | 526 | ||
504 | /* init vbi dma queues */ | 527 | /* init vbi dma queues */ |
505 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); | 528 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); |
506 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); | 529 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); |
507 | 530 | ||
508 | /* Reset other chips required if they are tied up with GPIO pins */ | 531 | /* Reset other chips required if they are tied up with GPIO pins */ |
509 | 532 | ||
510 | cx231xx_add_into_devlist(dev); | 533 | cx231xx_add_into_devlist(dev); |
511 | 534 | ||
512 | retval = cx231xx_register_analog_devices(dev); | 535 | retval = cx231xx_register_analog_devices(dev); |
513 | if (retval < 0) { | 536 | if (retval < 0) { |
@@ -519,7 +542,7 @@ static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | |||
519 | 542 | ||
520 | return 0; | 543 | return 0; |
521 | 544 | ||
522 | fail_reg_devices: | 545 | fail_reg_devices: |
523 | mutex_unlock(&dev->lock); | 546 | mutex_unlock(&dev->lock); |
524 | return retval; | 547 | return retval; |
525 | } | 548 | } |
@@ -528,8 +551,7 @@ fail_reg_devices: | |||
528 | static void request_module_async(struct work_struct *work) | 551 | static void request_module_async(struct work_struct *work) |
529 | { | 552 | { |
530 | struct cx231xx *dev = container_of(work, | 553 | struct cx231xx *dev = container_of(work, |
531 | struct cx231xx, request_module_wk); | 554 | struct cx231xx, request_module_wk); |
532 | |||
533 | 555 | ||
534 | if (dev->has_alsa_audio) | 556 | if (dev->has_alsa_audio) |
535 | request_module("cx231xx-alsa"); | 557 | request_module("cx231xx-alsa"); |
@@ -548,130 +570,130 @@ static void request_modules(struct cx231xx *dev) | |||
548 | #define request_modules(dev) | 570 | #define request_modules(dev) |
549 | #endif /* CONFIG_MODULES */ | 571 | #endif /* CONFIG_MODULES */ |
550 | 572 | ||
551 | |||
552 | |||
553 | /* | 573 | /* |
554 | * cx231xx_usb_probe() | 574 | * cx231xx_usb_probe() |
555 | * checks for supported devices | 575 | * checks for supported devices |
556 | */ | 576 | */ |
557 | static int cx231xx_usb_probe(struct usb_interface *interface, | 577 | static int cx231xx_usb_probe(struct usb_interface *interface, |
558 | const struct usb_device_id *id) | 578 | const struct usb_device_id *id) |
559 | { | 579 | { |
560 | struct usb_device *udev; | 580 | struct usb_device *udev; |
561 | struct usb_interface *uif; | 581 | struct usb_interface *uif; |
562 | struct cx231xx *dev = NULL; | 582 | struct cx231xx *dev = NULL; |
563 | int retval = -ENODEV; | 583 | int retval = -ENODEV; |
564 | int nr, ifnum; | 584 | int nr, ifnum; |
565 | int i, isoc_pipe = 0; | 585 | int i, isoc_pipe = 0; |
566 | char *speed; | 586 | char *speed; |
567 | char descr[255] = ""; | 587 | char descr[255] = ""; |
568 | struct usb_interface *lif = NULL; | 588 | struct usb_interface *lif = NULL; |
569 | int skip_interface = 0; | 589 | int skip_interface = 0; |
570 | struct usb_interface_assoc_descriptor *assoc_desc; | 590 | struct usb_interface_assoc_descriptor *assoc_desc; |
571 | 591 | ||
572 | udev = usb_get_dev(interface_to_usbdev(interface)); | 592 | udev = usb_get_dev(interface_to_usbdev(interface)); |
573 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 593 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
574 | 594 | ||
575 | cx231xx_info(": Interface Number %d\n", ifnum); | 595 | cx231xx_info(": Interface Number %d\n", ifnum); |
576 | 596 | ||
577 | /* Interface number 0 - IR interface */ | 597 | /* Interface number 0 - IR interface */ |
578 | if(ifnum == 0 ){ | 598 | if (ifnum == 0) { |
579 | /* Check to see next free device and mark as used */ | 599 | /* Check to see next free device and mark as used */ |
580 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | 600 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
581 | cx231xx_devused |= 1<<nr; | 601 | cx231xx_devused |= 1 << nr; |
582 | 602 | ||
583 | if (nr >= CX231XX_MAXBOARDS) { | 603 | if (nr >= CX231XX_MAXBOARDS) { |
584 | cx231xx_info(": Supports only %i cx231xx boards.\n", | 604 | cx231xx_info(": Supports only %i cx231xx boards.\n", |
585 | CX231XX_MAXBOARDS); | 605 | CX231XX_MAXBOARDS); |
586 | cx231xx_devused &= ~(1<<nr); | 606 | cx231xx_devused &= ~(1 << nr); |
587 | return -ENOMEM; | 607 | return -ENOMEM; |
588 | } | 608 | } |
589 | 609 | ||
590 | /* allocate memory for our device state and initialize it */ | 610 | /* allocate memory for our device state and initialize it */ |
591 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 611 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
592 | if (dev == NULL) { | 612 | if (dev == NULL) { |
593 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); | 613 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); |
594 | cx231xx_devused &= ~(1<<nr); | 614 | cx231xx_devused &= ~(1 << nr); |
595 | return -ENOMEM; | 615 | return -ENOMEM; |
596 | } | 616 | } |
597 | 617 | ||
598 | snprintf(dev->name, 29, "cx231xx #%d", nr); | 618 | snprintf(dev->name, 29, "cx231xx #%d", nr); |
599 | dev->devno = nr; | 619 | dev->devno = nr; |
600 | dev->model = id->driver_info; | 620 | dev->model = id->driver_info; |
601 | dev->video_mode.alt = -1; | 621 | dev->video_mode.alt = -1; |
602 | dev->interface_count++; | 622 | dev->interface_count++; |
603 | 623 | ||
604 | /* reset gpio dir and value */ | 624 | /* reset gpio dir and value */ |
605 | dev->gpio_dir = 0; | 625 | dev->gpio_dir = 0; |
606 | dev->gpio_val = 0; | 626 | dev->gpio_val = 0; |
607 | dev->xc_fw_load_done = 0; | 627 | dev->xc_fw_load_done = 0; |
608 | dev->has_alsa_audio = 1; | 628 | dev->has_alsa_audio = 1; |
609 | dev->power_mode = -1; | 629 | dev->power_mode = -1; |
610 | 630 | ||
611 | dev->vbi_or_sliced_cc_mode = 0; /* 0 - vbi ; 1 -sliced cc mode */ | 631 | dev->vbi_or_sliced_cc_mode = 0; /* 0 - vbi ; 1 -sliced cc mode */ |
612 | 632 | ||
613 | /* get maximum no.of IAD interfaces */ | 633 | /* get maximum no.of IAD interfaces */ |
614 | assoc_desc = udev->actconfig->intf_assoc[0]; | 634 | assoc_desc = udev->actconfig->intf_assoc[0]; |
615 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; | 635 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; |
616 | cx231xx_info(": Found IAD interface count %d\n", dev->max_iad_interface_count); | 636 | cx231xx_info(": Found IAD interface count %d\n", |
617 | 637 | dev->max_iad_interface_count); | |
618 | /* init CIR module TBD */ | 638 | |
619 | 639 | /* init CIR module TBD */ | |
620 | /* store the current interface */ | 640 | |
621 | lif = interface; | 641 | /* store the current interface */ |
622 | 642 | lif = interface; | |
623 | } | 643 | |
624 | else if(ifnum == 1 ){ | 644 | } else if (ifnum == 1) { |
625 | 645 | ||
626 | /* Get dev structure first */ | 646 | /* Get dev structure first */ |
627 | dev = usb_get_intfdata(udev->actconfig->interface[0]); | 647 | dev = usb_get_intfdata(udev->actconfig->interface[0]); |
628 | if(dev == NULL){ | 648 | if (dev == NULL) { |
629 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); | 649 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); |
630 | return -ENODEV; | 650 | return -ENODEV; |
631 | } | 651 | } |
632 | 652 | ||
633 | /* store the interface 0 back */ | 653 | /* store the interface 0 back */ |
634 | lif = udev->actconfig->interface[0]; | 654 | lif = udev->actconfig->interface[0]; |
635 | 655 | ||
636 | /* increment interface count */ | 656 | /* increment interface count */ |
637 | dev->interface_count++; | 657 | dev->interface_count++; |
638 | 658 | ||
639 | /* get device number */ | 659 | /* get device number */ |
640 | nr = dev->devno; | 660 | nr = dev->devno; |
641 | 661 | ||
642 | assoc_desc = udev->actconfig->intf_assoc[0]; | 662 | assoc_desc = udev->actconfig->intf_assoc[0]; |
643 | if(assoc_desc->bFirstInterface == ifnum){ | 663 | if (assoc_desc->bFirstInterface == ifnum) { |
644 | cx231xx_info(": Found IAD interface match: AV Descriptor Start!! \n"); | 664 | cx231xx_info |
645 | } else { | 665 | (": Found IAD interface match: AV Descriptor Start!! \n"); |
646 | cx231xx_err(DRIVER_NAME " Not found matching interface\n"); | 666 | } else { |
647 | return -ENODEV; | 667 | cx231xx_err(DRIVER_NAME |
648 | } | 668 | " Not found matching interface\n"); |
649 | 669 | return -ENODEV; | |
650 | } | 670 | } |
651 | else if(ifnum >= 2) { | 671 | |
652 | /* Get dev structure first */ | 672 | } else if (ifnum >= 2) { |
653 | dev = usb_get_intfdata(udev->actconfig->interface[0]); | 673 | /* Get dev structure first */ |
654 | if(dev == NULL){ | 674 | dev = usb_get_intfdata(udev->actconfig->interface[0]); |
655 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); | 675 | if (dev == NULL) { |
656 | return -ENODEV; | 676 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); |
657 | } | 677 | return -ENODEV; |
658 | 678 | } | |
659 | /* store the interface 0 back */ | 679 | |
660 | lif = udev->actconfig->interface[0]; | 680 | /* store the interface 0 back */ |
661 | 681 | lif = udev->actconfig->interface[0]; | |
662 | /* increment interface count */ | 682 | |
663 | dev->interface_count++; | 683 | /* increment interface count */ |
664 | 684 | dev->interface_count++; | |
665 | /* get device number */ | 685 | |
666 | nr = dev->devno; | 686 | /* get device number */ |
667 | 687 | nr = dev->devno; | |
668 | /* set skip interface */ | 688 | |
669 | if((dev->interface_count -1) != dev->max_iad_interface_count ) | 689 | /* set skip interface */ |
670 | skip_interface = 1; /* set skipping */ | 690 | if ((dev->interface_count - 1) != dev->max_iad_interface_count) |
671 | else{ | 691 | skip_interface = 1; /* set skipping */ |
672 | cx231xx_info(": Found IAD interface number match with AV Device number!! \n"); | 692 | else { |
673 | } | 693 | cx231xx_info |
674 | } | 694 | (": Found IAD interface number match with AV Device number!! \n"); |
695 | } | ||
696 | } | ||
675 | 697 | ||
676 | switch (udev->speed) { | 698 | switch (udev->speed) { |
677 | case USB_SPEED_LOW: | 699 | case USB_SPEED_LOW: |
@@ -700,153 +722,184 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
700 | strlcat(descr, " ", sizeof(descr)); | 722 | strlcat(descr, " ", sizeof(descr)); |
701 | 723 | ||
702 | cx231xx_info("New device %s@ %s Mbps " | 724 | cx231xx_info("New device %s@ %s Mbps " |
703 | "(%04x:%04x, interface %d, class %d)\n", | 725 | "(%04x:%04x, interface %d, class %d)\n", |
704 | descr, | 726 | descr, |
705 | speed, | 727 | speed, |
706 | le16_to_cpu(udev->descriptor.idVendor), | 728 | le16_to_cpu(udev->descriptor.idVendor), |
707 | le16_to_cpu(udev->descriptor.idProduct), | 729 | le16_to_cpu(udev->descriptor.idProduct), |
708 | ifnum, | 730 | ifnum, interface->altsetting->desc.bInterfaceNumber); |
709 | interface->altsetting->desc.bInterfaceNumber); | 731 | |
710 | 732 | /* AV device initialization */ | |
711 | /* AV device initialization */ | 733 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { |
712 | if((dev->interface_count -1) == dev->max_iad_interface_count ) { | 734 | cx231xx_info(" Calling init_dev\n"); |
713 | cx231xx_info(" Calling init_dev\n"); | 735 | /* allocate device struct */ |
714 | /* allocate device struct */ | 736 | retval = cx231xx_init_dev(&dev, udev, nr); |
715 | retval = cx231xx_init_dev(&dev, udev, nr); | 737 | if (retval) { |
716 | if (retval) { | 738 | cx231xx_devused &= ~(1 << dev->devno); |
717 | cx231xx_devused &= ~(1<<dev->devno); | 739 | kfree(dev); |
718 | kfree(dev); | 740 | |
719 | 741 | return retval; | |
720 | return retval; | 742 | } |
721 | } | 743 | |
722 | 744 | /* compute alternate max packet sizes for video */ | |
723 | /* compute alternate max packet sizes for video */ | 745 | uif = |
724 | uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.video_index+1]; | 746 | udev->actconfig->interface[dev->current_pcb_config. |
725 | 747 | hs_config_info[0].interface_info. | |
726 | dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); | 748 | video_index + 1]; |
727 | 749 | ||
728 | dev->video_mode.num_alt = uif->num_altsetting; | 750 | dev->video_mode.end_point_addr = |
729 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->video_mode.end_point_addr, | 751 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
730 | dev->video_mode.num_alt); | 752 | bEndpointAddress); |
731 | dev->video_mode.alt_max_pkt_size = kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); | 753 | |
732 | 754 | dev->video_mode.num_alt = uif->num_altsetting; | |
733 | if (dev->video_mode.alt_max_pkt_size == NULL) { | 755 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", |
734 | cx231xx_errdev("out of memory!\n"); | 756 | dev->video_mode.end_point_addr, |
735 | cx231xx_devused &= ~(1<<nr); | 757 | dev->video_mode.num_alt); |
736 | kfree(dev); | 758 | dev->video_mode.alt_max_pkt_size = |
737 | return -ENOMEM; | 759 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); |
738 | } | 760 | |
739 | 761 | if (dev->video_mode.alt_max_pkt_size == NULL) { | |
740 | for (i = 0; i < dev->video_mode.num_alt ; i++) { | 762 | cx231xx_errdev("out of memory!\n"); |
741 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | 763 | cx231xx_devused &= ~(1 << nr); |
742 | wMaxPacketSize); | 764 | kfree(dev); |
743 | dev->video_mode.alt_max_pkt_size[i] = | 765 | return -ENOMEM; |
744 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 766 | } |
745 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 767 | |
746 | dev->video_mode.alt_max_pkt_size[i]); | 768 | for (i = 0; i < dev->video_mode.num_alt; i++) { |
747 | } | 769 | u16 tmp = |
748 | 770 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | |
749 | 771 | desc.wMaxPacketSize); | |
750 | /* compute alternate max packet sizes for vbi */ | 772 | dev->video_mode.alt_max_pkt_size[i] = |
751 | uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.vanc_index+1]; | 773 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
752 | 774 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | |
753 | dev->vbi_mode.end_point_addr = | 775 | dev->video_mode.alt_max_pkt_size[i]); |
754 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); | 776 | } |
755 | 777 | ||
756 | dev->vbi_mode.num_alt = uif->num_altsetting; | 778 | /* compute alternate max packet sizes for vbi */ |
757 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->vbi_mode.end_point_addr, | 779 | uif = |
758 | dev->vbi_mode.num_alt); | 780 | udev->actconfig->interface[dev->current_pcb_config. |
759 | dev->vbi_mode.alt_max_pkt_size = kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); | 781 | hs_config_info[0].interface_info. |
760 | 782 | vanc_index + 1]; | |
761 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | 783 | |
762 | cx231xx_errdev("out of memory!\n"); | 784 | dev->vbi_mode.end_point_addr = |
763 | cx231xx_devused &= ~(1<<nr); | 785 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
764 | kfree(dev); | 786 | bEndpointAddress); |
765 | return -ENOMEM; | 787 | |
766 | } | 788 | dev->vbi_mode.num_alt = uif->num_altsetting; |
767 | 789 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", | |
768 | for (i = 0; i < dev->vbi_mode.num_alt ; i++) { | 790 | dev->vbi_mode.end_point_addr, |
769 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | 791 | dev->vbi_mode.num_alt); |
770 | wMaxPacketSize); | 792 | dev->vbi_mode.alt_max_pkt_size = |
771 | dev->vbi_mode.alt_max_pkt_size[i] = | 793 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); |
772 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 794 | |
773 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 795 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { |
774 | dev->vbi_mode.alt_max_pkt_size[i]); | 796 | cx231xx_errdev("out of memory!\n"); |
775 | } | 797 | cx231xx_devused &= ~(1 << nr); |
776 | 798 | kfree(dev); | |
777 | /* compute alternate max packet sizes for sliced CC */ | 799 | return -ENOMEM; |
778 | uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.hanc_index+1]; | 800 | } |
779 | 801 | ||
780 | dev->sliced_cc_mode.end_point_addr = | 802 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { |
781 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); | 803 | u16 tmp = |
782 | 804 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | |
783 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | 805 | desc.wMaxPacketSize); |
784 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->sliced_cc_mode.end_point_addr, | 806 | dev->vbi_mode.alt_max_pkt_size[i] = |
785 | dev->sliced_cc_mode.num_alt); | 807 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
786 | dev->sliced_cc_mode.alt_max_pkt_size = kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | 808 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
787 | 809 | dev->vbi_mode.alt_max_pkt_size[i]); | |
788 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | 810 | } |
789 | cx231xx_errdev("out of memory!\n"); | 811 | |
790 | cx231xx_devused &= ~(1<<nr); | 812 | /* compute alternate max packet sizes for sliced CC */ |
791 | kfree(dev); | 813 | uif = |
792 | return -ENOMEM; | 814 | udev->actconfig->interface[dev->current_pcb_config. |
793 | } | 815 | hs_config_info[0].interface_info. |
794 | 816 | hanc_index + 1]; | |
795 | for (i = 0; i < dev->sliced_cc_mode.num_alt ; i++) { | 817 | |
796 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | 818 | dev->sliced_cc_mode.end_point_addr = |
797 | wMaxPacketSize); | 819 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
798 | dev->sliced_cc_mode.alt_max_pkt_size[i] = | 820 | bEndpointAddress); |
799 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 821 | |
800 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 822 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; |
801 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | 823 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", |
802 | } | 824 | dev->sliced_cc_mode.end_point_addr, |
803 | 825 | dev->sliced_cc_mode.num_alt); | |
804 | if(dev->current_pcb_config.ts1_source != 0xff ) { | 826 | dev->sliced_cc_mode.alt_max_pkt_size = |
805 | 827 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | |
806 | /* compute alternate max packet sizes for TS1 */ | 828 | |
807 | uif = udev->actconfig->interface[dev->current_pcb_config.hs_config_info[0].interface_info.ts1_index+1]; | 829 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { |
808 | 830 | cx231xx_errdev("out of memory!\n"); | |
809 | dev->ts1_mode.end_point_addr = | 831 | cx231xx_devused &= ~(1 << nr); |
810 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.bEndpointAddress); | 832 | kfree(dev); |
811 | 833 | return -ENOMEM; | |
812 | dev->ts1_mode.num_alt = uif->num_altsetting; | 834 | } |
813 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", dev->ts1_mode.end_point_addr, | 835 | |
814 | dev->ts1_mode.num_alt); | 836 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { |
815 | dev->ts1_mode.alt_max_pkt_size = kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); | 837 | u16 tmp = |
816 | 838 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | |
817 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | 839 | desc.wMaxPacketSize); |
818 | cx231xx_errdev("out of memory!\n"); | 840 | dev->sliced_cc_mode.alt_max_pkt_size[i] = |
819 | cx231xx_devused &= ~(1<<nr); | 841 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
820 | kfree(dev); | 842 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
821 | return -ENOMEM; | 843 | dev->sliced_cc_mode.alt_max_pkt_size[i]); |
822 | } | 844 | } |
823 | 845 | ||
824 | for (i = 0; i < dev->ts1_mode.num_alt ; i++) { | 846 | if (dev->current_pcb_config.ts1_source != 0xff) { |
825 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | 847 | |
826 | wMaxPacketSize); | 848 | /* compute alternate max packet sizes for TS1 */ |
827 | dev->ts1_mode.alt_max_pkt_size[i] = | 849 | uif = |
828 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 850 | udev->actconfig->interface[dev->current_pcb_config. |
829 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 851 | hs_config_info[0]. |
830 | dev->ts1_mode.alt_max_pkt_size[i]); | 852 | interface_info. |
831 | } | 853 | ts1_index + 1]; |
832 | } | 854 | |
833 | 855 | dev->ts1_mode.end_point_addr = | |
834 | } | 856 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. |
857 | desc.bEndpointAddress); | ||
858 | |||
859 | dev->ts1_mode.num_alt = uif->num_altsetting; | ||
860 | cx231xx_info | ||
861 | (": EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
862 | dev->ts1_mode.end_point_addr, | ||
863 | dev->ts1_mode.num_alt); | ||
864 | dev->ts1_mode.alt_max_pkt_size = | ||
865 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); | ||
866 | |||
867 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | ||
868 | cx231xx_errdev("out of memory!\n"); | ||
869 | cx231xx_devused &= ~(1 << nr); | ||
870 | kfree(dev); | ||
871 | return -ENOMEM; | ||
872 | } | ||
873 | |||
874 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { | ||
875 | u16 tmp = | ||
876 | le16_to_cpu(uif->altsetting[i]. | ||
877 | endpoint[isoc_pipe].desc. | ||
878 | wMaxPacketSize); | ||
879 | dev->ts1_mode.alt_max_pkt_size[i] = | ||
880 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + | ||
881 | 1); | ||
882 | cx231xx_info | ||
883 | ("Alternate setting %i, max size= %i\n", i, | ||
884 | dev->ts1_mode.alt_max_pkt_size[i]); | ||
885 | } | ||
886 | } | ||
887 | |||
888 | } | ||
835 | 889 | ||
836 | /* save our data pointer in this interface device */ | 890 | /* save our data pointer in this interface device */ |
837 | usb_set_intfdata(lif, dev); | 891 | usb_set_intfdata(lif, dev); |
838 | 892 | ||
839 | /* load other modules required */ | 893 | /* load other modules required */ |
840 | if((dev->interface_count -1) == dev->max_iad_interface_count ) | 894 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { |
841 | { | 895 | cx231xx_info("Calling request modules\n"); |
842 | cx231xx_info("Calling request modules\n"); | 896 | request_modules(dev); |
843 | request_modules(dev); | 897 | } |
844 | } | ||
845 | 898 | ||
846 | if(skip_interface ) { | 899 | if (skip_interface) { |
847 | cx231xx_info("Skipping the interface\n"); | 900 | cx231xx_info("Skipping the interface\n"); |
848 | return -ENODEV; | 901 | return -ENODEV; |
849 | } | 902 | } |
850 | 903 | ||
851 | return 0; | 904 | return 0; |
852 | } | 905 | } |
@@ -860,7 +913,7 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
860 | { | 913 | { |
861 | struct cx231xx *dev; | 914 | struct cx231xx *dev; |
862 | 915 | ||
863 | dev = usb_get_intfdata(interface); | 916 | dev = usb_get_intfdata(interface); |
864 | usb_set_intfdata(interface, NULL); | 917 | usb_set_intfdata(interface, NULL); |
865 | 918 | ||
866 | if (!dev) | 919 | if (!dev) |
@@ -875,8 +928,7 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
875 | if (dev->users) { | 928 | if (dev->users) { |
876 | cx231xx_warn | 929 | cx231xx_warn |
877 | ("device /dev/video%d is open! Deregistration and memory " | 930 | ("device /dev/video%d is open! Deregistration and memory " |
878 | "deallocation are deferred on close.\n", | 931 | "deallocation are deferred on close.\n", dev->vdev->num); |
879 | dev->vdev->num); | ||
880 | 932 | ||
881 | dev->state |= DEV_MISCONFIGURED; | 933 | dev->state |= DEV_MISCONFIGURED; |
882 | cx231xx_uninit_isoc(dev); | 934 | cx231xx_uninit_isoc(dev); |
@@ -888,15 +940,15 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
888 | cx231xx_release_resources(dev); | 940 | cx231xx_release_resources(dev); |
889 | } | 941 | } |
890 | 942 | ||
891 | cx231xx_close_extension(dev); | 943 | cx231xx_close_extension(dev); |
892 | 944 | ||
893 | mutex_unlock(&dev->lock); | 945 | mutex_unlock(&dev->lock); |
894 | 946 | ||
895 | if (!dev->users) { | 947 | if (!dev->users) { |
896 | kfree(dev->video_mode.alt_max_pkt_size); | 948 | kfree(dev->video_mode.alt_max_pkt_size); |
897 | kfree(dev->vbi_mode.alt_max_pkt_size); | 949 | kfree(dev->vbi_mode.alt_max_pkt_size); |
898 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); | 950 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); |
899 | kfree(dev->ts1_mode.alt_max_pkt_size); | 951 | kfree(dev->ts1_mode.alt_max_pkt_size); |
900 | kfree(dev); | 952 | kfree(dev); |
901 | } | 953 | } |
902 | } | 954 | } |
@@ -920,7 +972,7 @@ static int __init cx231xx_module_init(void) | |||
920 | result = usb_register(&cx231xx_usb_driver); | 972 | result = usb_register(&cx231xx_usb_driver); |
921 | if (result) | 973 | if (result) |
922 | cx231xx_err(DRIVER_NAME | 974 | cx231xx_err(DRIVER_NAME |
923 | " usb_register failed. Error number %d.\n", result); | 975 | " usb_register failed. Error number %d.\n", result); |
924 | 976 | ||
925 | return result; | 977 | return result; |
926 | } | 978 | } |