diff options
author | Mike Isely <isely@isely.net> | 2006-06-26 19:58:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-26 23:17:15 -0400 |
commit | d855497edbfbf9e19a17f4a1154bca69cb4bd9ba (patch) | |
tree | b39bef23fc00c91dac73ae171ad6ba7261170918 /drivers/media/video/pvrusb2/pvrusb2-wm8775.c | |
parent | eb99adde31b7d85c67a5e1c2fa5e098e1056dd79 (diff) |
V4L/DVB (4228a): pvrusb2 to kernel 2.6.18
Implement V4L2 driver for the Hauppauge PVR USB2 TV tuner.
The Hauppauge PVR USB2 is a USB connected TV tuner with an embedded
cx23416 hardware MPEG2 encoder. There are two major variants of this
device; this driver handles both. Any V4L2 application which
understands MPEG2 video stream data should be able to work with this
device.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-wm8775.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-wm8775.c | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c new file mode 100644 index 000000000000..fcad346e3955 --- /dev/null +++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c | |||
@@ -0,0 +1,170 @@ | |||
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 | /* | ||
24 | |||
25 | This source file is specifically designed to interface with the | ||
26 | wm8775. | ||
27 | |||
28 | */ | ||
29 | |||
30 | #include "pvrusb2-wm8775.h" | ||
31 | #include "pvrusb2-i2c-cmd-v4l2.h" | ||
32 | |||
33 | |||
34 | #include "pvrusb2-hdw-internal.h" | ||
35 | #include "pvrusb2-debug.h" | ||
36 | #include <linux/videodev2.h> | ||
37 | #include <media/v4l2-common.h> | ||
38 | #include <linux/errno.h> | ||
39 | #include <linux/slab.h> | ||
40 | |||
41 | struct pvr2_v4l_wm8775 { | ||
42 | struct pvr2_i2c_handler handler; | ||
43 | struct pvr2_i2c_client *client; | ||
44 | struct pvr2_hdw *hdw; | ||
45 | unsigned long stale_mask; | ||
46 | }; | ||
47 | |||
48 | |||
49 | static void set_input(struct pvr2_v4l_wm8775 *ctxt) | ||
50 | { | ||
51 | struct v4l2_routing route; | ||
52 | struct pvr2_hdw *hdw = ctxt->hdw; | ||
53 | int msk = 0; | ||
54 | |||
55 | memset(&route,0,sizeof(route)); | ||
56 | |||
57 | pvr2_trace(PVR2_TRACE_CHIPS,"i2c wm8775 set_input(val=%d msk=0x%x)", | ||
58 | hdw->input_val,msk); | ||
59 | |||
60 | // Always point to input #1 no matter what | ||
61 | route.input = 2; | ||
62 | pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route); | ||
63 | } | ||
64 | |||
65 | static int check_input(struct pvr2_v4l_wm8775 *ctxt) | ||
66 | { | ||
67 | struct pvr2_hdw *hdw = ctxt->hdw; | ||
68 | return hdw->input_dirty != 0; | ||
69 | } | ||
70 | |||
71 | |||
72 | struct pvr2_v4l_wm8775_ops { | ||
73 | void (*update)(struct pvr2_v4l_wm8775 *); | ||
74 | int (*check)(struct pvr2_v4l_wm8775 *); | ||
75 | }; | ||
76 | |||
77 | |||
78 | static const struct pvr2_v4l_wm8775_ops wm8775_ops[] = { | ||
79 | { .update = set_input, .check = check_input}, | ||
80 | }; | ||
81 | |||
82 | |||
83 | static unsigned int wm8775_describe(struct pvr2_v4l_wm8775 *ctxt, | ||
84 | char *buf,unsigned int cnt) | ||
85 | { | ||
86 | return scnprintf(buf,cnt,"handler: pvrusb2-wm8775"); | ||
87 | } | ||
88 | |||
89 | |||
90 | static void wm8775_detach(struct pvr2_v4l_wm8775 *ctxt) | ||
91 | { | ||
92 | ctxt->client->handler = 0; | ||
93 | kfree(ctxt); | ||
94 | } | ||
95 | |||
96 | |||
97 | static int wm8775_check(struct pvr2_v4l_wm8775 *ctxt) | ||
98 | { | ||
99 | unsigned long msk; | ||
100 | unsigned int idx; | ||
101 | |||
102 | for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]); | ||
103 | idx++) { | ||
104 | msk = 1 << idx; | ||
105 | if (ctxt->stale_mask & msk) continue; | ||
106 | if (wm8775_ops[idx].check(ctxt)) { | ||
107 | ctxt->stale_mask |= msk; | ||
108 | } | ||
109 | } | ||
110 | return ctxt->stale_mask != 0; | ||
111 | } | ||
112 | |||
113 | |||
114 | static void wm8775_update(struct pvr2_v4l_wm8775 *ctxt) | ||
115 | { | ||
116 | unsigned long msk; | ||
117 | unsigned int idx; | ||
118 | |||
119 | for (idx = 0; idx < sizeof(wm8775_ops)/sizeof(wm8775_ops[0]); | ||
120 | idx++) { | ||
121 | msk = 1 << idx; | ||
122 | if (!(ctxt->stale_mask & msk)) continue; | ||
123 | ctxt->stale_mask &= ~msk; | ||
124 | wm8775_ops[idx].update(ctxt); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | |||
129 | const static struct pvr2_i2c_handler_functions hfuncs = { | ||
130 | .detach = (void (*)(void *))wm8775_detach, | ||
131 | .check = (int (*)(void *))wm8775_check, | ||
132 | .update = (void (*)(void *))wm8775_update, | ||
133 | .describe = (unsigned int (*)(void *,char *,unsigned int))wm8775_describe, | ||
134 | }; | ||
135 | |||
136 | |||
137 | int pvr2_i2c_wm8775_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp) | ||
138 | { | ||
139 | struct pvr2_v4l_wm8775 *ctxt; | ||
140 | |||
141 | if (cp->handler) return 0; | ||
142 | |||
143 | ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL); | ||
144 | if (!ctxt) return 0; | ||
145 | memset(ctxt,0,sizeof(*ctxt)); | ||
146 | |||
147 | ctxt->handler.func_data = ctxt; | ||
148 | ctxt->handler.func_table = &hfuncs; | ||
149 | ctxt->client = cp; | ||
150 | ctxt->hdw = hdw; | ||
151 | ctxt->stale_mask = (1 << (sizeof(wm8775_ops)/ | ||
152 | sizeof(wm8775_ops[0]))) - 1; | ||
153 | cp->handler = &ctxt->handler; | ||
154 | pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x wm8775 V4L2 handler set up", | ||
155 | cp->client->addr); | ||
156 | return !0; | ||
157 | } | ||
158 | |||
159 | |||
160 | |||
161 | |||
162 | /* | ||
163 | Stuff for Emacs to see, in order to encourage consistent editing style: | ||
164 | *** Local Variables: *** | ||
165 | *** mode: c *** | ||
166 | *** fill-column: 70 *** | ||
167 | *** tab-width: 8 *** | ||
168 | *** c-basic-offset: 8 *** | ||
169 | *** End: *** | ||
170 | */ | ||