diff options
author | Len Brown <len.brown@intel.com> | 2006-06-29 19:57:46 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2006-06-29 19:57:46 -0400 |
commit | d120cfb544ed6161b9d32fb6c4648c471807ee6b (patch) | |
tree | 7757ad0198d8df76ff5c60f939a687687c41da00 /drivers/media/video/pvrusb2/pvrusb2-main.c | |
parent | 9dce0e950dbfab4148f35ac6f297d8638cdc63c4 (diff) | |
parent | bf7e8511088963078484132636839b59e25cf14f (diff) |
merge linus into release branch
Conflicts:
drivers/acpi/acpi_memhotplug.c
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-main.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-main.c | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c new file mode 100644 index 000000000000..b95248274ed0 --- /dev/null +++ b/drivers/media/video/pvrusb2/pvrusb2-main.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * | ||
3 | * $Id$ | ||
4 | * | ||
5 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> | ||
6 | * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License | ||
11 | * | ||
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. | ||
16 | * | ||
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 | ||
20 | * | ||
21 | */ | ||
22 | |||
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> | ||
32 | |||
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 */ | ||
40 | |||
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" | ||
44 | |||
45 | #define DEFAULT_DEBUG_MASK (PVR2_TRACE_ERROR_LEGS| \ | ||
46 | PVR2_TRACE_INFO| \ | ||
47 | PVR2_TRACE_TOLERANCE| \ | ||
48 | PVR2_TRACE_TRAP| \ | ||
49 | 0) | ||
50 | |||
51 | int pvrusb2_debug = DEFAULT_DEBUG_MASK; | ||
52 | |||
53 | module_param_named(debug,pvrusb2_debug,int,S_IRUGO|S_IWUSR); | ||
54 | MODULE_PARM_DESC(debug, "Debug trace mask"); | ||
55 | |||
56 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | ||
57 | static struct pvr2_sysfs_class *class_ptr = 0; | ||
58 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | ||
59 | |||
60 | static void pvr_setup_attach(struct pvr2_context *pvr) | ||
61 | { | ||
62 | /* Create association with v4l layer */ | ||
63 | pvr2_v4l2_create(pvr); | ||
64 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | ||
65 | pvr2_sysfs_create(pvr,class_ptr); | ||
66 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | ||
67 | } | ||
68 | |||
69 | static int pvr_probe(struct usb_interface *intf, | ||
70 | const struct usb_device_id *devid) | ||
71 | { | ||
72 | struct pvr2_context *pvr; | ||
73 | |||
74 | /* Create underlying hardware interface */ | ||
75 | pvr = pvr2_context_create(intf,devid,pvr_setup_attach); | ||
76 | if (!pvr) { | ||
77 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | ||
78 | "Failed to create hdw handler"); | ||
79 | return -ENOMEM; | ||
80 | } | ||
81 | |||
82 | pvr2_trace(PVR2_TRACE_INIT,"pvr_probe(pvr=%p)",pvr); | ||
83 | |||
84 | usb_set_intfdata(intf, pvr); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * pvr_disconnect() | ||
91 | * | ||
92 | */ | ||
93 | static void pvr_disconnect(struct usb_interface *intf) | ||
94 | { | ||
95 | struct pvr2_context *pvr = usb_get_intfdata(intf); | ||
96 | |||
97 | pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) BEGIN",pvr); | ||
98 | |||
99 | usb_set_intfdata (intf, NULL); | ||
100 | pvr2_context_disconnect(pvr); | ||
101 | |||
102 | pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) DONE",pvr); | ||
103 | |||
104 | } | ||
105 | |||
106 | static struct usb_driver pvr_driver = { | ||
107 | name: "pvrusb2", | ||
108 | id_table: pvr2_device_table, | ||
109 | probe: pvr_probe, | ||
110 | disconnect: pvr_disconnect | ||
111 | }; | ||
112 | |||
113 | /* | ||
114 | * pvr_init() / pvr_exit() | ||
115 | * | ||
116 | * This code is run to initialize/exit the driver. | ||
117 | * | ||
118 | */ | ||
119 | static int __init pvr_init(void) | ||
120 | { | ||
121 | int ret; | ||
122 | |||
123 | pvr2_trace(PVR2_TRACE_INIT,"pvr_init"); | ||
124 | |||
125 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | ||
126 | class_ptr = pvr2_sysfs_class_create(); | ||
127 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | ||
128 | |||
129 | ret = usb_register(&pvr_driver); | ||
130 | |||
131 | if (ret == 0) | ||
132 | info(DRIVER_DESC " : " DRIVER_VERSION); | ||
133 | if (pvrusb2_debug) info("Debug mask is %d (0x%x)", | ||
134 | pvrusb2_debug,pvrusb2_debug); | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | static void __exit pvr_exit(void) | ||
140 | { | ||
141 | |||
142 | pvr2_trace(PVR2_TRACE_INIT,"pvr_exit"); | ||
143 | |||
144 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | ||
145 | pvr2_sysfs_class_destroy(class_ptr); | ||
146 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | ||
147 | |||
148 | usb_deregister(&pvr_driver); | ||
149 | } | ||
150 | |||
151 | module_init(pvr_init); | ||
152 | module_exit(pvr_exit); | ||
153 | |||
154 | /* Mike Isely <mcisely@pobox.com> 11-Mar-2006: See pvrusb2-hdw.c for | ||
155 | MODULE_DEVICE_TABLE(). We have to declare that attribute there | ||
156 | because that's where the device table actually is now and it seems | ||
157 | that certain gcc configurations get angry if MODULE_DEVICE_TABLE() | ||
158 | is used on what ends up being an external symbol. */ | ||
159 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
160 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
161 | MODULE_LICENSE("GPL"); | ||
162 | |||
163 | |||
164 | /* | ||
165 | Stuff for Emacs to see, in order to encourage consistent editing style: | ||
166 | *** Local Variables: *** | ||
167 | *** mode: c *** | ||
168 | *** fill-column: 70 *** | ||
169 | *** tab-width: 8 *** | ||
170 | *** c-basic-offset: 8 *** | ||
171 | *** End: *** | ||
172 | */ | ||