4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/kernel.h>
19 #include <linux/errno.h>
20 #include <linux/module.h>
21 #include <linux/usb.h>
22 #include <linux/videodev2.h>
24 #include "pvrusb2-hdw.h"
25 #include "pvrusb2-devattr.h"
26 #include "pvrusb2-context.h"
27 #include "pvrusb2-debug.h"
28 #include "pvrusb2-v4l2.h"
29 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
30 #include "pvrusb2-sysfs.h"
31 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
33 #define DRIVER_AUTHOR "Mike Isely <isely@pobox.com>"
34 #define DRIVER_DESC "Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner"
35 #define DRIVER_VERSION "V4L in-tree version"
37 #define DEFAULT_DEBUG_MASK (PVR2_TRACE_ERROR_LEGS| \
40 PVR2_TRACE_TOLERANCE| \
44 int pvrusb2_debug
= DEFAULT_DEBUG_MASK
;
46 module_param_named(debug
,pvrusb2_debug
,int,S_IRUGO
|S_IWUSR
);
47 MODULE_PARM_DESC(debug
, "Debug trace mask");
49 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
50 static struct pvr2_sysfs_class
*class_ptr
= NULL
;
51 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
53 static void pvr_setup_attach(struct pvr2_context
*pvr
)
55 /* Create association with v4l layer */
56 pvr2_v4l2_create(pvr
);
57 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
58 /* Create association with dvb layer */
61 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
62 pvr2_sysfs_create(pvr
,class_ptr
);
63 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
66 static int pvr_probe(struct usb_interface
*intf
,
67 const struct usb_device_id
*devid
)
69 struct pvr2_context
*pvr
;
71 /* Create underlying hardware interface */
72 pvr
= pvr2_context_create(intf
,devid
,pvr_setup_attach
);
74 pvr2_trace(PVR2_TRACE_ERROR_LEGS
,
75 "Failed to create hdw handler");
79 pvr2_trace(PVR2_TRACE_INIT
,"pvr_probe(pvr=%p)",pvr
);
81 usb_set_intfdata(intf
, pvr
);
90 static void pvr_disconnect(struct usb_interface
*intf
)
92 struct pvr2_context
*pvr
= usb_get_intfdata(intf
);
94 pvr2_trace(PVR2_TRACE_INIT
,"pvr_disconnect(pvr=%p) BEGIN",pvr
);
96 usb_set_intfdata (intf
, NULL
);
97 pvr2_context_disconnect(pvr
);
99 pvr2_trace(PVR2_TRACE_INIT
,"pvr_disconnect(pvr=%p) DONE",pvr
);
103 static struct usb_driver pvr_driver
= {
105 .id_table
= pvr2_device_table
,
107 .disconnect
= pvr_disconnect
111 * pvr_init() / pvr_exit()
113 * This code is run to initialize/exit the driver.
116 static int __init
pvr_init(void)
120 pvr2_trace(PVR2_TRACE_INIT
,"pvr_init");
122 ret
= pvr2_context_global_init();
124 pvr2_trace(PVR2_TRACE_INIT
,"pvr_init failure code=%d",ret
);
128 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
129 class_ptr
= pvr2_sysfs_class_create();
130 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
132 ret
= usb_register(&pvr_driver
);
135 printk(KERN_INFO
"pvrusb2: " DRIVER_VERSION
":"
138 printk(KERN_INFO
"pvrusb2: Debug mask is %d (0x%x)\n",
139 pvrusb2_debug
,pvrusb2_debug
);
141 pvr2_trace(PVR2_TRACE_INIT
,"pvr_init complete");
146 static void __exit
pvr_exit(void)
148 pvr2_trace(PVR2_TRACE_INIT
,"pvr_exit");
150 usb_deregister(&pvr_driver
);
152 pvr2_context_global_done();
154 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
155 pvr2_sysfs_class_destroy(class_ptr
);
156 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
158 pvr2_trace(PVR2_TRACE_INIT
,"pvr_exit complete");
161 module_init(pvr_init
);
162 module_exit(pvr_exit
);
164 MODULE_AUTHOR(DRIVER_AUTHOR
);
165 MODULE_DESCRIPTION(DRIVER_DESC
);
166 MODULE_LICENSE("GPL");
167 MODULE_VERSION("0.9.1");