blob: f2a4900014bc5c1dace49615b123cb86184ba814 [file] [log] [blame]
Sri Deevie0d3baf2009-03-03 14:37:50 -03001/*
Sri Deevib9255172009-03-04 17:49:01 -03002 cx231xx-cards.c - driver for Conexant Cx23100/101/102
3 USB video capture devices
Sri Deevie0d3baf2009-03-03 14:37:50 -03004
5 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
Sri Deevib9255172009-03-04 17:49:01 -03006 Based on em28xx driver
Sri Deevie0d3baf2009-03-03 14:37:50 -03007
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 Heo5a0e3ad2010-03-24 17:04:11 +090025#include <linux/slab.h>
Sri Deevie0d3baf2009-03-03 14:37:50 -030026#include <linux/delay.h>
27#include <linux/i2c.h>
28#include <linux/usb.h>
29#include <media/tuner.h>
30#include <media/tveeprom.h>
31#include <media/v4l2-common.h>
32#include <media/v4l2-chip-ident.h>
33
34#include <media/cx25840.h>
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -030035#include "dvb-usb-ids.h"
Sri Deevie0d3baf2009-03-03 14:37:50 -030036#include "xc5000.h"
37
38#include "cx231xx.h"
39
40static int tuner = -1;
41module_param(tuner, int, 0444);
42MODULE_PARM_DESC(tuner, "tuner type");
43
44static unsigned int disable_ir;
45module_param(disable_ir, int, 0444);
46MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
47
48/* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */
49static unsigned long cx231xx_devused;
50
51/*
52 * Reset sequences for analog/digital modes
53 */
54
55static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = {
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -030056 {0x03, 0x01, 10},
57 {0x03, 0x00, 30},
58 {0x03, 0x01, 10},
59 {-1, -1, -1},
Sri Deevie0d3baf2009-03-03 14:37:50 -030060};
61
Sri Deevie0d3baf2009-03-03 14:37:50 -030062/*
63 * Board definitions
64 */
65struct cx231xx_board cx231xx_boards[] = {
Sri Deevie0d3baf2009-03-03 14:37:50 -030066 [CX231XX_BOARD_UNKNOWN] = {
Sri Deevi6e4f5742009-03-10 21:16:26 -030067 .name = "Unknown CX231xx video grabber",
68 .tuner_type = TUNER_ABSENT,
69 .input = {{
70 .type = CX231XX_VMUX_TELEVISION,
71 .vmux = CX231XX_VIN_3_1,
72 .amux = CX231XX_AMUX_VIDEO,
Márton Németh7ee0a282009-12-13 17:06:10 -030073 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -030074 }, {
75 .type = CX231XX_VMUX_COMPOSITE1,
76 .vmux = CX231XX_VIN_2_1,
77 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -030078 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -030079 }, {
80 .type = CX231XX_VMUX_SVIDEO,
81 .vmux = CX231XX_VIN_1_1 |
82 (CX231XX_VIN_1_2 << 8) |
83 CX25840_SVIDEO_ON,
84 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -030085 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -030086 }
87 },
88 },
Sri Deevie0d3baf2009-03-03 14:37:50 -030089 [CX231XX_BOARD_CNXT_RDE_250] = {
Sri Deevi6e4f5742009-03-10 21:16:26 -030090 .name = "Conexant Hybrid TV - RDE250",
91 .tuner_type = TUNER_XC5000,
92 .tuner_addr = 0x61,
93 .tuner_gpio = RDE250_XCV_TUNER,
94 .tuner_sif_gpio = 0x05,
95 .tuner_scl_gpio = 0x1a,
96 .tuner_sda_gpio = 0x1b,
97 .decoder = CX231XX_AVDECODER,
98 .demod_xfer_mode = 0,
99 .ctl_pin_status_mask = 0xFFFFFFC4,
100 .agc_analog_digital_select_gpio = 0x0c,
101 .gpio_pin_status_mask = 0x4001000,
102 .tuner_i2c_master = 1,
103 .demod_i2c_master = 2,
104 .has_dvb = 1,
105 .demod_addr = 0x02,
106 .norm = V4L2_STD_PAL,
Sri Deevie0d3baf2009-03-03 14:37:50 -0300107
Sri Deevi6e4f5742009-03-10 21:16:26 -0300108 .input = {{
109 .type = CX231XX_VMUX_TELEVISION,
110 .vmux = CX231XX_VIN_3_1,
111 .amux = CX231XX_AMUX_VIDEO,
Márton Németh7ee0a282009-12-13 17:06:10 -0300112 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300113 }, {
114 .type = CX231XX_VMUX_COMPOSITE1,
115 .vmux = CX231XX_VIN_2_1,
116 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -0300117 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300118 }, {
119 .type = CX231XX_VMUX_SVIDEO,
120 .vmux = CX231XX_VIN_1_1 |
121 (CX231XX_VIN_1_2 << 8) |
122 CX25840_SVIDEO_ON,
123 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -0300124 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300125 }
126 },
127 },
Sri Deevie0d3baf2009-03-03 14:37:50 -0300128
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300129 [CX231XX_BOARD_CNXT_RDU_250] = {
Sri Deevi6e4f5742009-03-10 21:16:26 -0300130 .name = "Conexant Hybrid TV - RDU250",
131 .tuner_type = TUNER_XC5000,
132 .tuner_addr = 0x61,
133 .tuner_gpio = RDE250_XCV_TUNER,
134 .tuner_sif_gpio = 0x05,
135 .tuner_scl_gpio = 0x1a,
136 .tuner_sda_gpio = 0x1b,
137 .decoder = CX231XX_AVDECODER,
138 .demod_xfer_mode = 0,
139 .ctl_pin_status_mask = 0xFFFFFFC4,
140 .agc_analog_digital_select_gpio = 0x0c,
141 .gpio_pin_status_mask = 0x4001000,
142 .tuner_i2c_master = 1,
143 .demod_i2c_master = 2,
144 .has_dvb = 1,
145 .demod_addr = 0x32,
146 .norm = V4L2_STD_NTSC,
Sri Deevie0d3baf2009-03-03 14:37:50 -0300147
Sri Deevi6e4f5742009-03-10 21:16:26 -0300148 .input = {{
149 .type = CX231XX_VMUX_TELEVISION,
150 .vmux = CX231XX_VIN_3_1,
151 .amux = CX231XX_AMUX_VIDEO,
Márton Németh7ee0a282009-12-13 17:06:10 -0300152 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300153 }, {
154 .type = CX231XX_VMUX_COMPOSITE1,
155 .vmux = CX231XX_VIN_2_1,
156 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -0300157 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300158 }, {
159 .type = CX231XX_VMUX_SVIDEO,
160 .vmux = CX231XX_VIN_1_1 |
161 (CX231XX_VIN_1_2 << 8) |
162 CX25840_SVIDEO_ON,
163 .amux = CX231XX_AMUX_LINE_IN,
Márton Németh7ee0a282009-12-13 17:06:10 -0300164 .gpio = NULL,
Sri Deevi6e4f5742009-03-10 21:16:26 -0300165 }
166 },
167 },
Sri Deevie0d3baf2009-03-03 14:37:50 -0300168};
169const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards);
170
171/* table of devices that work with this driver */
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300172struct usb_device_id cx231xx_id_table[] = {
Sri Deevied559ed2009-03-13 18:35:14 -0300173 {USB_DEVICE(0x0572, 0x5A3C),
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300174 .driver_info = CX231XX_BOARD_UNKNOWN},
175 {USB_DEVICE(0x0572, 0x58A2),
176 .driver_info = CX231XX_BOARD_CNXT_RDE_250},
Sri Deevied559ed2009-03-13 18:35:14 -0300177 {USB_DEVICE(0x0572, 0x58A1),
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300178 .driver_info = CX231XX_BOARD_CNXT_RDU_250},
Mauro Carvalho Chehab3bfb3172010-09-03 10:50:24 -0300179 {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000,0x4fff),
180 .driver_info = CX231XX_BOARD_UNKNOWN},
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300181 {},
Sri Deevie0d3baf2009-03-03 14:37:50 -0300182};
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300183
Sri Deevie0d3baf2009-03-03 14:37:50 -0300184MODULE_DEVICE_TABLE(usb, cx231xx_id_table);
185
186/* cx231xx_tuner_callback
187 * will be used to reset XC5000 tuner using GPIO pin
188 */
189
190int cx231xx_tuner_callback(void *ptr, int component, int command, int arg)
191{
192 int rc = 0;
193 struct cx231xx *dev = ptr;
194
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300195 if (dev->tuner_type == TUNER_XC5000) {
196 if (command == XC5000_TUNER_RESET) {
197 cx231xx_info
Sri Deevib9255172009-03-04 17:49:01 -0300198 ("Tuner CB: RESET: cmd %d : tuner type %d \n",
199 command, dev->tuner_type);
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300200 cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
201 1);
202 msleep(10);
203 cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
204 0);
205 msleep(330);
206 cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit,
207 1);
208 msleep(10);
209 }
210 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300211 return rc;
212}
213EXPORT_SYMBOL_GPL(cx231xx_tuner_callback);
214
Sri Deevib9255172009-03-04 17:49:01 -0300215static inline void cx231xx_set_model(struct cx231xx *dev)
Sri Deevie0d3baf2009-03-03 14:37:50 -0300216{
217 memcpy(&dev->board, &cx231xx_boards[dev->model], sizeof(dev->board));
218}
219
220/* Since cx231xx_pre_card_setup() requires a proper dev->model,
221 * this won't work for boards with generic PCI IDs
222 */
223void cx231xx_pre_card_setup(struct cx231xx *dev)
224{
225
226 cx231xx_set_model(dev);
227
228 cx231xx_info("Identified as %s (card=%d)\n",
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300229 dev->board.name, dev->model);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300230
Sri Deevi6e4f5742009-03-10 21:16:26 -0300231 /* set the direction for GPIO pins */
Mauro Carvalho Chehabc10469c2010-09-11 11:37:51 -0300232 if (dev->board.tuner_gpio) {
233 cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1);
234 cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1);
235 cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300236
Mauro Carvalho Chehabc10469c2010-09-11 11:37:51 -0300237 /* request some modules if any required */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300238
Mauro Carvalho Chehabc10469c2010-09-11 11:37:51 -0300239 /* reset the Tuner */
240 cx231xx_gpio_set(dev, dev->board.tuner_gpio);
241 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300242
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300243 /* set the mode to Analog mode initially */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300244 cx231xx_set_mode(dev, CX231XX_ANALOG_MODE);
245
246 /* Unlock device */
247 /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */
248
249}
250
Sri Deevie0d3baf2009-03-03 14:37:50 -0300251static void cx231xx_config_tuner(struct cx231xx *dev)
252{
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300253 struct tuner_setup tun_setup;
254 struct v4l2_frequency f;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300255
256 if (dev->tuner_type == TUNER_ABSENT)
257 return;
258
259 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
260 tun_setup.type = dev->tuner_type;
261 tun_setup.addr = dev->tuner_addr;
262 tun_setup.tuner_callback = cx231xx_tuner_callback;
263
Sri Deevib1196122009-03-20 23:33:48 -0300264 tuner_call(dev, tuner, s_type_addr, &tun_setup);
265
Sri Deevie0d3baf2009-03-03 14:37:50 -0300266#if 0
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300267 if (tun_setup.type == TUNER_XC5000) {
Sri Deevie0d3baf2009-03-03 14:37:50 -0300268 static struct xc2028_ctrl ctrl = {
269 .fname = XC5000_DEFAULT_FIRMWARE,
270 .max_len = 64,
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300271 .demod = 0;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300272 };
273 struct v4l2_priv_tun_config cfg = {
274 .tuner = dev->tuner_type,
275 .priv = &ctrl,
276 };
Sri Deevib1196122009-03-20 23:33:48 -0300277 tuner_call(dev, tuner, s_config, &cfg);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300278 }
279#endif
Sri Deevie0d3baf2009-03-03 14:37:50 -0300280 /* configure tuner */
281 f.tuner = 0;
282 f.type = V4L2_TUNER_ANALOG_TV;
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300283 f.frequency = 9076; /* just a magic number */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300284 dev->ctl_freq = f.frequency;
Sri Deevib1196122009-03-20 23:33:48 -0300285 call_all(dev, tuner, s_frequency, &f);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300286
Sri Deevib1196122009-03-20 23:33:48 -0300287}
Sri Deevie0d3baf2009-03-03 14:37:50 -0300288
289/* ----------------------------------------------------------------------- */
Jean Delvarec668f322009-05-13 16:48:50 -0300290void cx231xx_register_i2c_ir(struct cx231xx *dev)
291{
292 if (disable_ir)
293 return;
294
295 /* REVISIT: instantiate IR device */
Jean Delvarec668f322009-05-13 16:48:50 -0300296
Sri Deevie0d3baf2009-03-03 14:37:50 -0300297 /* detect & configure */
298 switch (dev->model) {
299
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300300 case CX231XX_BOARD_CNXT_RDE_250:
301 break;
302 case CX231XX_BOARD_CNXT_RDU_250:
303 break;
304 default:
305 break;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300306 }
307}
308
309void cx231xx_card_setup(struct cx231xx *dev)
310{
Sri Deevib1196122009-03-20 23:33:48 -0300311
Sri Deevie0d3baf2009-03-03 14:37:50 -0300312 cx231xx_set_model(dev);
313
314 dev->tuner_type = cx231xx_boards[dev->model].tuner_type;
315 if (cx231xx_boards[dev->model].tuner_addr)
316 dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr;
317
Sri Deevie0d3baf2009-03-03 14:37:50 -0300318 /* request some modules */
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300319 if (dev->board.decoder == CX231XX_AVDECODER) {
Hans Verkuile6574f22009-04-01 03:57:53 -0300320 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
321 &dev->i2c_bus[0].i2c_adap,
Hans Verkuil53dacb12009-08-10 02:49:08 -0300322 "cx25840", "cx25840", 0x88 >> 1, NULL);
Sri Deevib1196122009-03-20 23:33:48 -0300323 if (dev->sd_cx25840 == NULL)
324 cx231xx_info("cx25840 subdev registration failure\n");
Hans Verkuilcc26b072009-03-29 19:20:26 -0300325 cx25840_call(dev, core, load_fw);
Sri Deevib1196122009-03-20 23:33:48 -0300326
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300327 }
Sri Deevib1196122009-03-20 23:33:48 -0300328
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300329 if (dev->board.tuner_type != TUNER_ABSENT) {
Hans Verkuile6574f22009-04-01 03:57:53 -0300330 dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
331 &dev->i2c_bus[1].i2c_adap,
Hans Verkuil53dacb12009-08-10 02:49:08 -0300332 "tuner", "tuner", 0xc2 >> 1, NULL);
Sri Deevib1196122009-03-20 23:33:48 -0300333 if (dev->sd_tuner == NULL)
334 cx231xx_info("tuner subdev registration failure\n");
335
336 cx231xx_config_tuner(dev);
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300337 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300338
339 cx231xx_config_tuner(dev);
340
Sri Deevib1196122009-03-20 23:33:48 -0300341#if 0
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300342 /* TBD IR will be added later */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300343 cx231xx_ir_init(dev);
344#endif
345}
346
Sri Deevie0d3baf2009-03-03 14:37:50 -0300347/*
348 * cx231xx_config()
349 * inits registers with sane defaults
350 */
351int cx231xx_config(struct cx231xx *dev)
352{
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300353 /* TBD need to add cx231xx specific code */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300354 dev->mute = 1; /* maybe not the right place... */
355 dev->volume = 0x1f;
356
357 return 0;
358}
359
360/*
361 * cx231xx_config_i2c()
362 * configure i2c attached devices
363 */
364void cx231xx_config_i2c(struct cx231xx *dev)
365{
Hans Verkuil5325b422009-04-02 11:26:22 -0300366 /* u32 input = INPUT(dev->video_input)->vmux; */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300367
Sri Deevib1196122009-03-20 23:33:48 -0300368 call_all(dev, video, s_stream, 1);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300369}
370
371/*
372 * cx231xx_realease_resources()
373 * unregisters the v4l2,i2c and usb devices
374 * called when the device gets disconected or at module unload
375*/
376void cx231xx_release_resources(struct cx231xx *dev)
377{
378
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300379#if 0 /* TBD IR related */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300380 if (dev->ir)
381 cx231xx_ir_fini(dev);
382#endif
383
384 cx231xx_release_analog_resources(dev);
385
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300386 cx231xx_remove_from_devlist(dev);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300387
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300388 cx231xx_dev_uninit(dev);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300389
390 usb_put_dev(dev->udev);
391
392 /* Mark device as unused */
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300393 cx231xx_devused &= ~(1 << dev->devno);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300394}
395
Sri Deevie0d3baf2009-03-03 14:37:50 -0300396/*
397 * cx231xx_init_dev()
398 * allocates and inits the device structs, registers i2c bus and v4l device
399 */
400static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev,
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300401 int minor)
Sri Deevie0d3baf2009-03-03 14:37:50 -0300402{
403 struct cx231xx *dev = *devhandle;
404 int retval = -ENOMEM;
405 int errCode;
406 unsigned int maxh, maxw;
407
408 dev->udev = udev;
409 mutex_init(&dev->lock);
410 mutex_init(&dev->ctrl_urb_lock);
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300411 mutex_init(&dev->gpio_i2c_lock);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300412
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300413 spin_lock_init(&dev->video_mode.slock);
414 spin_lock_init(&dev->vbi_mode.slock);
415 spin_lock_init(&dev->sliced_cc_mode.slock);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300416
417 init_waitqueue_head(&dev->open);
418 init_waitqueue_head(&dev->wait_frame);
419 init_waitqueue_head(&dev->wait_stream);
420
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300421 dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg;
422 dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg;
423 dev->cx231xx_send_usb_command = cx231xx_send_usb_command;
424 dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read;
425 dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300426
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300427 /* Query cx231xx to find what pcb config it is related to */
428 initialize_cx231xx(dev);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300429
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300430 /* Cx231xx pre card setup */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300431 cx231xx_pre_card_setup(dev);
432
433 errCode = cx231xx_config(dev);
434 if (errCode) {
435 cx231xx_errdev("error configuring device\n");
436 return -ENOMEM;
437 }
438
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300439 /* set default norm */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300440 dev->norm = dev->board.norm;
441
442 /* register i2c bus */
443 errCode = cx231xx_dev_init(dev);
444 if (errCode < 0) {
445 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n",
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300446 __func__, errCode);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300447 return errCode;
448 }
449
450 /* Do board specific init */
451 cx231xx_card_setup(dev);
452
453 /* configure the device */
454 cx231xx_config_i2c(dev);
455
456 maxw = norm_maxw(dev);
457 maxh = norm_maxh(dev);
458
459 /* set default image size */
460 dev->width = maxw;
461 dev->height = maxh;
462 dev->interlaced = 0;
463 dev->hscale = 0;
464 dev->vscale = 0;
465 dev->video_input = 0;
466
467 errCode = cx231xx_config(dev);
468 if (errCode < 0) {
469 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n",
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300470 __func__, errCode);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300471 return errCode;
472 }
473
474 /* init video dma queues */
475 INIT_LIST_HEAD(&dev->video_mode.vidq.active);
476 INIT_LIST_HEAD(&dev->video_mode.vidq.queued);
477
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300478 /* init vbi dma queues */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300479 INIT_LIST_HEAD(&dev->vbi_mode.vidq.active);
480 INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued);
481
482 /* Reset other chips required if they are tied up with GPIO pins */
483
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300484 cx231xx_add_into_devlist(dev);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300485
486 retval = cx231xx_register_analog_devices(dev);
487 if (retval < 0) {
488 cx231xx_release_resources(dev);
489 goto fail_reg_devices;
490 }
491
492 cx231xx_init_extension(dev);
493
494 return 0;
495
Sri Deevib9255172009-03-04 17:49:01 -0300496fail_reg_devices:
Sri Deevie0d3baf2009-03-03 14:37:50 -0300497 mutex_unlock(&dev->lock);
498 return retval;
499}
500
501#if defined(CONFIG_MODULES) && defined(MODULE)
502static void request_module_async(struct work_struct *work)
503{
504 struct cx231xx *dev = container_of(work,
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300505 struct cx231xx, request_module_wk);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300506
507 if (dev->has_alsa_audio)
508 request_module("cx231xx-alsa");
509
510 if (dev->board.has_dvb)
511 request_module("cx231xx-dvb");
512
513}
514
515static void request_modules(struct cx231xx *dev)
516{
517 INIT_WORK(&dev->request_module_wk, request_module_async);
518 schedule_work(&dev->request_module_wk);
519}
520#else
521#define request_modules(dev)
522#endif /* CONFIG_MODULES */
523
Sri Deevie0d3baf2009-03-03 14:37:50 -0300524/*
525 * cx231xx_usb_probe()
526 * checks for supported devices
527 */
528static int cx231xx_usb_probe(struct usb_interface *interface,
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300529 const struct usb_device_id *id)
Sri Deevie0d3baf2009-03-03 14:37:50 -0300530{
531 struct usb_device *udev;
532 struct usb_interface *uif;
533 struct cx231xx *dev = NULL;
534 int retval = -ENODEV;
Hans Verkuild73abcf2009-03-12 18:38:40 -0300535 int nr = 0, ifnum;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300536 int i, isoc_pipe = 0;
537 char *speed;
538 char descr[255] = "";
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300539 struct usb_interface *lif = NULL;
540 int skip_interface = 0;
541 struct usb_interface_assoc_descriptor *assoc_desc;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300542
543 udev = usb_get_dev(interface_to_usbdev(interface));
544 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
545
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300546 if (!ifnum) {
547 /*
548 * Interface number 0 - IR interface
549 */
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300550 /* Check to see next free device and mark as used */
551 nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS);
552 cx231xx_devused |= 1 << nr;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300553
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300554 if (nr >= CX231XX_MAXBOARDS) {
Mauro Carvalho Chehabb905de32009-03-22 05:46:36 -0300555 cx231xx_err(DRIVER_NAME ": Supports only %i cx231xx boards.\n",
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300556 CX231XX_MAXBOARDS);
557 cx231xx_devused &= ~(1 << nr);
558 return -ENOMEM;
559 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300560
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300561 /* allocate memory for our device state and initialize it */
562 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
563 if (dev == NULL) {
564 cx231xx_err(DRIVER_NAME ": out of memory!\n");
565 cx231xx_devused &= ~(1 << nr);
566 return -ENOMEM;
567 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300568
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300569 snprintf(dev->name, 29, "cx231xx #%d", nr);
570 dev->devno = nr;
571 dev->model = id->driver_info;
572 dev->video_mode.alt = -1;
573 dev->interface_count++;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300574
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300575 /* reset gpio dir and value */
576 dev->gpio_dir = 0;
577 dev->gpio_val = 0;
578 dev->xc_fw_load_done = 0;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300579 dev->has_alsa_audio = 1;
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300580 dev->power_mode = -1;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300581
Sri Deevib9255172009-03-04 17:49:01 -0300582 /* 0 - vbi ; 1 -sliced cc mode */
583 dev->vbi_or_sliced_cc_mode = 0;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300584
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300585 /* get maximum no.of IAD interfaces */
586 assoc_desc = udev->actconfig->intf_assoc[0];
587 dev->max_iad_interface_count = assoc_desc->bInterfaceCount;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300588
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300589 /* init CIR module TBD */
Sri Deevie0d3baf2009-03-03 14:37:50 -0300590
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300591 /* store the current interface */
592 lif = interface;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300593
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300594 switch (udev->speed) {
595 case USB_SPEED_LOW:
596 speed = "1.5";
597 break;
598 case USB_SPEED_UNKNOWN:
599 case USB_SPEED_FULL:
600 speed = "12";
601 break;
602 case USB_SPEED_HIGH:
603 speed = "480";
604 break;
605 default:
606 speed = "unknown";
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300607 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300608
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300609 if (udev->manufacturer)
610 strlcpy(descr, udev->manufacturer, sizeof(descr));
Sri Deevie0d3baf2009-03-03 14:37:50 -0300611
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300612 if (udev->product) {
613 if (*descr)
614 strlcat(descr, " ", sizeof(descr));
615 strlcat(descr, udev->product, sizeof(descr));
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300616 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300617 if (*descr)
618 strlcat(descr, " ", sizeof(descr));
Sri Deevie0d3baf2009-03-03 14:37:50 -0300619
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300620 cx231xx_info("New device %s@ %s Mbps "
621 "(%04x:%04x) with %d interfaces\n",
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300622 descr,
623 speed,
624 le16_to_cpu(udev->descriptor.idVendor),
625 le16_to_cpu(udev->descriptor.idProduct),
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300626 dev->max_iad_interface_count);
627 } else {
628 /* Get dev structure first */
629 dev = usb_get_intfdata(udev->actconfig->interface[0]);
630 if (dev == NULL) {
631 cx231xx_err(DRIVER_NAME ": out of first interface!\n");
632 return -ENODEV;
Sri Deevib1196122009-03-20 23:33:48 -0300633 }
634
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300635 /* store the interface 0 back */
636 lif = udev->actconfig->interface[0];
Sri Deevie0d3baf2009-03-03 14:37:50 -0300637
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300638 /* increment interface count */
639 dev->interface_count++;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300640
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300641 /* get device number */
642 nr = dev->devno;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300643
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300644 /*
645 * set skip interface, for all interfaces but
646 * interface 1 and the last one
647 */
648 if ((ifnum != 1) && ((dev->interface_count - 1)
649 != dev->max_iad_interface_count))
650 skip_interface = 1;
Sri Deevie0d3baf2009-03-03 14:37:50 -0300651
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300652 if (ifnum == 1) {
653 assoc_desc = udev->actconfig->intf_assoc[0];
654 if (assoc_desc->bFirstInterface != ifnum) {
655 cx231xx_err(DRIVER_NAME ": Not found "
656 "matching IAD interface\n");
657 return -ENODEV;
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300658 }
659 }
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300660 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300661
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300662 if (skip_interface)
663 return -ENODEV;
664
665 cx231xx_info("registering interface %d\n", ifnum);
666
Sri Deevie0d3baf2009-03-03 14:37:50 -0300667 /* save our data pointer in this interface device */
668 usb_set_intfdata(lif, dev);
669
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300670 if ((dev->interface_count - 1) != dev->max_iad_interface_count)
671 return 0;
672
673 /*
674 * AV device initialization - only done at the last interface
675 */
676
677 /* Create v4l2 device */
Janne Grunau72317482009-04-01 08:39:29 -0300678 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300679 if (retval) {
680 cx231xx_errdev("v4l2_device_register failed\n");
681 cx231xx_devused &= ~(1 << nr);
682 kfree(dev);
683 return -EIO;
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300684 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300685
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300686 /* allocate device struct */
687 retval = cx231xx_init_dev(&dev, udev, nr);
688 if (retval) {
689 cx231xx_devused &= ~(1 << dev->devno);
690 v4l2_device_unregister(&dev->v4l2_dev);
691 kfree(dev);
692 return retval;
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300693 }
Sri Deevie0d3baf2009-03-03 14:37:50 -0300694
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300695 /* compute alternate max packet sizes for video */
696 uif = udev->actconfig->interface[dev->current_pcb_config.
697 hs_config_info[0].interface_info.video_index + 1];
698
699 dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0].
700 endpoint[isoc_pipe].desc.bEndpointAddress);
701
702 dev->video_mode.num_alt = uif->num_altsetting;
703 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
704 dev->video_mode.end_point_addr,
705 dev->video_mode.num_alt);
706 dev->video_mode.alt_max_pkt_size =
707 kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL);
708
709 if (dev->video_mode.alt_max_pkt_size == NULL) {
710 cx231xx_errdev("out of memory!\n");
711 cx231xx_devused &= ~(1 << nr);
712 v4l2_device_unregister(&dev->v4l2_dev);
713 kfree(dev);
714 return -ENOMEM;
715 }
716
717 for (i = 0; i < dev->video_mode.num_alt; i++) {
718 u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
719 desc.wMaxPacketSize);
720 dev->video_mode.alt_max_pkt_size[i] =
721 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
722 cx231xx_info("Alternate setting %i, max size= %i\n", i,
723 dev->video_mode.alt_max_pkt_size[i]);
724 }
725
726 /* compute alternate max packet sizes for vbi */
727 uif = udev->actconfig->interface[dev->current_pcb_config.
728 hs_config_info[0].interface_info.
729 vanc_index + 1];
730
731 dev->vbi_mode.end_point_addr =
732 le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
733 bEndpointAddress);
734
735 dev->vbi_mode.num_alt = uif->num_altsetting;
736 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
737 dev->vbi_mode.end_point_addr,
738 dev->vbi_mode.num_alt);
739 dev->vbi_mode.alt_max_pkt_size =
740 kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL);
741
742 if (dev->vbi_mode.alt_max_pkt_size == NULL) {
743 cx231xx_errdev("out of memory!\n");
744 cx231xx_devused &= ~(1 << nr);
745 v4l2_device_unregister(&dev->v4l2_dev);
746 kfree(dev);
747 return -ENOMEM;
748 }
749
750 for (i = 0; i < dev->vbi_mode.num_alt; i++) {
751 u16 tmp =
752 le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
753 desc.wMaxPacketSize);
754 dev->vbi_mode.alt_max_pkt_size[i] =
755 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
756 cx231xx_info("Alternate setting %i, max size= %i\n", i,
757 dev->vbi_mode.alt_max_pkt_size[i]);
758 }
759
760 /* compute alternate max packet sizes for sliced CC */
761 uif = udev->actconfig->interface[dev->current_pcb_config.
762 hs_config_info[0].interface_info.
763 hanc_index + 1];
764
765 dev->sliced_cc_mode.end_point_addr =
766 le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
767 bEndpointAddress);
768
769 dev->sliced_cc_mode.num_alt = uif->num_altsetting;
770 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
771 dev->sliced_cc_mode.end_point_addr,
772 dev->sliced_cc_mode.num_alt);
773 dev->sliced_cc_mode.alt_max_pkt_size =
774 kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL);
775
776 if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) {
777 cx231xx_errdev("out of memory!\n");
778 cx231xx_devused &= ~(1 << nr);
779 v4l2_device_unregister(&dev->v4l2_dev);
780 kfree(dev);
781 return -ENOMEM;
782 }
783
784 for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) {
785 u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
786 desc.wMaxPacketSize);
787 dev->sliced_cc_mode.alt_max_pkt_size[i] =
788 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
789 cx231xx_info("Alternate setting %i, max size= %i\n", i,
790 dev->sliced_cc_mode.alt_max_pkt_size[i]);
791 }
792
793 if (dev->current_pcb_config.ts1_source != 0xff) {
794 /* compute alternate max packet sizes for TS1 */
795 uif = udev->actconfig->interface[dev->current_pcb_config.
796 hs_config_info[0].
797 interface_info.
798 ts1_index + 1];
799
800 dev->ts1_mode.end_point_addr =
801 le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].
802 desc.bEndpointAddress);
803
804 dev->ts1_mode.num_alt = uif->num_altsetting;
805 cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
806 dev->ts1_mode.end_point_addr,
807 dev->ts1_mode.num_alt);
808 dev->ts1_mode.alt_max_pkt_size =
809 kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL);
810
811 if (dev->ts1_mode.alt_max_pkt_size == NULL) {
812 cx231xx_errdev("out of memory!\n");
813 cx231xx_devused &= ~(1 << nr);
814 v4l2_device_unregister(&dev->v4l2_dev);
815 kfree(dev);
816 return -ENOMEM;
817 }
818
819 for (i = 0; i < dev->ts1_mode.num_alt; i++) {
820 u16 tmp = le16_to_cpu(uif->altsetting[i].
821 endpoint[isoc_pipe].desc.
822 wMaxPacketSize);
823 dev->ts1_mode.alt_max_pkt_size[i] =
824 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
825 cx231xx_info("Alternate setting %i, max size= %i\n", i,
826 dev->ts1_mode.alt_max_pkt_size[i]);
827 }
828 }
829
830 /* load other modules required */
831 request_modules(dev);
832
Sri Deevie0d3baf2009-03-03 14:37:50 -0300833 return 0;
834}
835
836/*
837 * cx231xx_usb_disconnect()
838 * called when the device gets diconencted
839 * video device will be unregistered on v4l2_close in case it is still open
840 */
841static void cx231xx_usb_disconnect(struct usb_interface *interface)
842{
843 struct cx231xx *dev;
844
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300845 dev = usb_get_intfdata(interface);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300846 usb_set_intfdata(interface, NULL);
847
848 if (!dev)
849 return;
850
Mauro Carvalho Chehab90960742009-03-22 07:52:02 -0300851 if (!dev->udev)
852 return;
853
Sri Deevib1196122009-03-20 23:33:48 -0300854 /* delete v4l2 device */
855 v4l2_device_unregister(&dev->v4l2_dev);
856
Sri Deevie0d3baf2009-03-03 14:37:50 -0300857 /* wait until all current v4l2 io is finished then deallocate
858 resources */
859 mutex_lock(&dev->lock);
860
861 wake_up_interruptible_all(&dev->open);
862
863 if (dev->users) {
864 cx231xx_warn
Laurent Pinchart38c7c032009-11-27 13:57:15 -0300865 ("device %s is open! Deregistration and memory "
866 "deallocation are deferred on close.\n",
867 video_device_node_name(dev->vdev));
Sri Deevie0d3baf2009-03-03 14:37:50 -0300868
869 dev->state |= DEV_MISCONFIGURED;
870 cx231xx_uninit_isoc(dev);
871 dev->state |= DEV_DISCONNECTED;
872 wake_up_interruptible(&dev->wait_frame);
873 wake_up_interruptible(&dev->wait_stream);
874 } else {
875 dev->state |= DEV_DISCONNECTED;
876 cx231xx_release_resources(dev);
877 }
878
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300879 cx231xx_close_extension(dev);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300880
881 mutex_unlock(&dev->lock);
882
883 if (!dev->users) {
884 kfree(dev->video_mode.alt_max_pkt_size);
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300885 kfree(dev->vbi_mode.alt_max_pkt_size);
886 kfree(dev->sliced_cc_mode.alt_max_pkt_size);
887 kfree(dev->ts1_mode.alt_max_pkt_size);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300888 kfree(dev);
889 }
890}
891
892static struct usb_driver cx231xx_usb_driver = {
893 .name = "cx231xx",
894 .probe = cx231xx_usb_probe,
895 .disconnect = cx231xx_usb_disconnect,
896 .id_table = cx231xx_id_table,
897};
898
899static int __init cx231xx_module_init(void)
900{
901 int result;
902
Mauro Carvalho Chehab818fdf32009-03-13 07:41:58 -0300903 printk(KERN_INFO DRIVER_NAME " v4l2 driver loaded.\n");
Sri Deevie0d3baf2009-03-03 14:37:50 -0300904
905 /* register this driver with the USB subsystem */
906 result = usb_register(&cx231xx_usb_driver);
907 if (result)
908 cx231xx_err(DRIVER_NAME
Mauro Carvalho Chehab84b5dbf2009-03-03 06:14:34 -0300909 " usb_register failed. Error number %d.\n", result);
Sri Deevie0d3baf2009-03-03 14:37:50 -0300910
911 return result;
912}
913
914static void __exit cx231xx_module_exit(void)
915{
916 /* deregister this driver with the USB subsystem */
917 usb_deregister(&cx231xx_usb_driver);
918}
919
920module_init(cx231xx_module_init);
921module_exit(cx231xx_module_exit);