5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/config.h>
24 #include <linux/kernel.h>
25 #include <linux/errno.h>
26 #include <linux/slab.h>
27 #include <linux/module.h>
28 #include <linux/moduleparam.h>
29 #include <linux/smp_lock.h>
30 #include <linux/usb.h>
31 #include <linux/videodev2.h>
33 #include "pvrusb2-hdw.h"
34 #include "pvrusb2-context.h"
35 #include "pvrusb2-debug.h"
36 #include "pvrusb2-v4l2.h"
37 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
38 #include "pvrusb2-sysfs.h"
39 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
41 #define DRIVER_AUTHOR "Mike Isely <isely@pobox.com>"
42 #define DRIVER_DESC "Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner"
43 #define DRIVER_VERSION "V4L in-tree version"
45 #define DEFAULT_DEBUG_MASK (PVR2_TRACE_ERROR_LEGS| \
47 PVR2_TRACE_TOLERANCE| \
49 PVR2_TRACE_FIRMWARE| \
54 PVR2_TRACE_START_STOP | \
56 PVR2_TRACE_DEBUGIFC | \
59 int pvrusb2_debug = DEFAULT_DEBUG_MASK;
61 module_param_named(debug,pvrusb2_debug,int,S_IRUGO|S_IWUSR);
62 MODULE_PARM_DESC(debug, "Debug trace mask");
64 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
65 static struct pvr2_sysfs_class *class_ptr = 0;
66 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
68 static void pvr_setup_attach(struct pvr2_context *pvr)
70 /* Create association with v4l layer */
71 pvr2_v4l2_create(pvr);
72 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
73 pvr2_sysfs_create(pvr,class_ptr);
74 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
77 static int pvr_probe(struct usb_interface *intf,
78 const struct usb_device_id *devid)
80 struct pvr2_context *pvr;
82 /* Create underlying hardware interface */
83 pvr = pvr2_context_create(intf,devid,pvr_setup_attach);
85 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
86 "Failed to create hdw handler");
90 pvr2_trace(PVR2_TRACE_INIT,"pvr_probe(pvr=%p)",pvr);
92 usb_set_intfdata(intf, pvr);
101 static void pvr_disconnect(struct usb_interface *intf)
103 struct pvr2_context *pvr = usb_get_intfdata(intf);
105 pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) BEGIN",pvr);
107 usb_set_intfdata (intf, NULL);
108 pvr2_context_disconnect(pvr);
110 pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) DONE",pvr);
114 static struct usb_driver pvr_driver = {
116 id_table: pvr2_device_table,
118 disconnect: pvr_disconnect
122 * pvr_init() / pvr_exit()
124 * This code is run to initialize/exit the driver.
127 static int __init pvr_init(void)
131 pvr2_trace(PVR2_TRACE_INIT,"pvr_init");
133 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
134 class_ptr = pvr2_sysfs_class_create();
135 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
137 ret = usb_register(&pvr_driver);
140 info(DRIVER_DESC " : " DRIVER_VERSION);
141 if (pvrusb2_debug) info("Debug mask is %d (0x%x)",
142 pvrusb2_debug,pvrusb2_debug);
147 static void __exit pvr_exit(void)
150 pvr2_trace(PVR2_TRACE_INIT,"pvr_exit");
152 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
153 pvr2_sysfs_class_destroy(class_ptr);
154 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
156 usb_deregister(&pvr_driver);
159 module_init(pvr_init);
160 module_exit(pvr_exit);
162 /* Mike Isely <mcisely@pobox.com> 11-Mar-2006: See pvrusb2-hdw.c for
163 MODULE_DEVICE_TABLE(). We have to declare that attribute there
164 because that's where the device table actually is now and it seems
165 that certain gcc configurations get angry if MODULE_DEVICE_TABLE()
166 is used on what ends up being an external symbol. */
167 MODULE_AUTHOR(DRIVER_AUTHOR);
168 MODULE_DESCRIPTION(DRIVER_DESC);
169 MODULE_LICENSE("GPL");
173 Stuff for Emacs to see, in order to encourage consistent editing style:
174 *** Local Variables: ***
176 *** fill-column: 70 ***
178 *** c-basic-offset: 8 ***