aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-rtrack2.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
commit49e1900d4cc2e7bcecb681fe60f0990bec2dcce8 (patch)
tree253801ebf57e0a23856a2c7be129c2c178f62fdf /drivers/media/radio/radio-rtrack2.c
parent34f6d749c0a328817d5e36274e53121c1db734dc (diff)
parentb9099ff63c75216d6ca10bce5a1abcd9293c27e6 (diff)
Merge branch 'linux-2.6' into for-2.6.22
Diffstat (limited to 'drivers/media/radio/radio-rtrack2.c')
-rw-r--r--drivers/media/radio/radio-rtrack2.c255
1 files changed, 144 insertions, 111 deletions
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index f6683872251e..9b493b3298cd 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -122,6 +122,26 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
122 return 0; 122 return 0;
123} 123}
124 124
125static int vidioc_querycap(struct file *file, void *priv,
126 struct v4l2_capability *v)
127{
128 strlcpy(v->driver, "radio-rtrack2", sizeof(v->driver));
129 strlcpy(v->card, "RadioTrack II", sizeof(v->card));
130 sprintf(v->bus_info, "ISA");
131 v->version = RADIO_VERSION;
132 v->capabilities = V4L2_CAP_TUNER;
133 return 0;
134}
135
136static int vidioc_s_tuner(struct file *file, void *priv,
137 struct v4l2_tuner *v)
138{
139 if (v->index > 0)
140 return -EINVAL;
141
142 return 0;
143}
144
125static int rt_getsigstr(struct rt_device *dev) 145static int rt_getsigstr(struct rt_device *dev)
126{ 146{
127 if (inb(io) & 2) /* bit set = no signal present */ 147 if (inb(io) & 2) /* bit set = no signal present */
@@ -129,135 +149,136 @@ static int rt_getsigstr(struct rt_device *dev)
129 return 1; /* signal present */ 149 return 1; /* signal present */
130} 150}
131 151
132static int rt_do_ioctl(struct inode *inode, struct file *file, 152static int vidioc_g_tuner(struct file *file, void *priv,
133 unsigned int cmd, void *arg) 153 struct v4l2_tuner *v)
134{ 154{
135 struct video_device *dev = video_devdata(file); 155 struct video_device *dev = video_devdata(file);
136 struct rt_device *rt=dev->priv; 156 struct rt_device *rt = dev->priv;
137 157
138 switch(cmd) 158 if (v->index > 0)
139 { 159 return -EINVAL;
140 case VIDIOC_QUERYCAP:
141 {
142 struct v4l2_capability *v = arg;
143 memset(v,0,sizeof(*v));
144 strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
145 strlcpy(v->card, "RadioTrack II", sizeof (v->card));
146 sprintf(v->bus_info,"ISA");
147 v->version = RADIO_VERSION;
148 v->capabilities = V4L2_CAP_TUNER;
149 160
150 return 0; 161 strcpy(v->name, "FM");
151 } 162 v->type = V4L2_TUNER_RADIO;
152 case VIDIOC_G_TUNER: 163 v->rangelow = (88*16000);
153 { 164 v->rangehigh = (108*16000);
154 struct v4l2_tuner *v = arg; 165 v->rxsubchans = V4L2_TUNER_SUB_MONO;
166 v->capability = V4L2_TUNER_CAP_LOW;
167 v->audmode = V4L2_TUNER_MODE_MONO;
168 v->signal = 0xFFFF*rt_getsigstr(rt);
169 return 0;
170}
155 171
156 if (v->index > 0) 172static int vidioc_s_frequency(struct file *file, void *priv,
157 return -EINVAL; 173 struct v4l2_frequency *f)
174{
175 struct video_device *dev = video_devdata(file);
176 struct rt_device *rt = dev->priv;
158 177
159 memset(v,0,sizeof(*v)); 178 rt->curfreq = f->frequency;
160 strcpy(v->name, "FM"); 179 rt_setfreq(rt, rt->curfreq);
161 v->type = V4L2_TUNER_RADIO; 180 return 0;
181}
162 182
163 v->rangelow=(88*16000); 183static int vidioc_g_frequency(struct file *file, void *priv,
164 v->rangehigh=(108*16000); 184 struct v4l2_frequency *f)
165 v->rxsubchans =V4L2_TUNER_SUB_MONO; 185{
166 v->capability=V4L2_TUNER_CAP_LOW; 186 struct video_device *dev = video_devdata(file);
167 v->audmode = V4L2_TUNER_MODE_MONO; 187 struct rt_device *rt = dev->priv;
168 v->signal=0xFFFF*rt_getsigstr(rt);
169 188
170 return 0; 189 f->type = V4L2_TUNER_RADIO;
171 } 190 f->frequency = rt->curfreq;
172 case VIDIOC_S_TUNER: 191 return 0;
173 { 192}
174 struct v4l2_tuner *v = arg;
175 193
176 if (v->index > 0) 194static int vidioc_queryctrl(struct file *file, void *priv,
177 return -EINVAL; 195 struct v4l2_queryctrl *qc)
196{
197 int i;
178 198
199 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
200 if (qc->id && qc->id == radio_qctrl[i].id) {
201 memcpy(qc, &(radio_qctrl[i]),
202 sizeof(*qc));
179 return 0; 203 return 0;
180 } 204 }
181 case VIDIOC_S_FREQUENCY: 205 }
182 { 206 return -EINVAL;
183 struct v4l2_frequency *f = arg; 207}
184 208
185 rt->curfreq = f->frequency; 209static int vidioc_g_ctrl(struct file *file, void *priv,
186 rt_setfreq(rt, rt->curfreq); 210 struct v4l2_control *ctrl)
187 return 0; 211{
188 } 212 struct video_device *dev = video_devdata(file);
189 case VIDIOC_G_FREQUENCY: 213 struct rt_device *rt = dev->priv;
190 {
191 struct v4l2_frequency *f = arg;
192 214
193 f->type = V4L2_TUNER_RADIO; 215 switch (ctrl->id) {
194 f->frequency = rt->curfreq; 216 case V4L2_CID_AUDIO_MUTE:
217 ctrl->value = rt->muted;
218 return 0;
219 case V4L2_CID_AUDIO_VOLUME:
220 if (rt->muted)
221 ctrl->value = 0;
222 else
223 ctrl->value = 65535;
224 return 0;
225 }
226 return -EINVAL;
227}
195 228
196 return 0; 229static int vidioc_s_ctrl(struct file *file, void *priv,
197 } 230 struct v4l2_control *ctrl)
198 case VIDIOC_QUERYCTRL: 231{
199 { 232 struct video_device *dev = video_devdata(file);
200 struct v4l2_queryctrl *qc = arg; 233 struct rt_device *rt = dev->priv;
201 int i; 234
202 235 switch (ctrl->id) {
203 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 236 case V4L2_CID_AUDIO_MUTE:
204 if (qc->id && qc->id == radio_qctrl[i].id) { 237 if (ctrl->value)
205 memcpy(qc, &(radio_qctrl[i]), 238 rt_mute(rt);
206 sizeof(*qc)); 239 else
207 return (0); 240 rt_unmute(rt);
208 } 241 return 0;
209 } 242 case V4L2_CID_AUDIO_VOLUME:
210 return -EINVAL; 243 if (ctrl->value)
211 } 244 rt_unmute(rt);
212 case VIDIOC_G_CTRL: 245 else
213 { 246 rt_mute(rt);
214 struct v4l2_control *ctrl= arg; 247 return 0;
215
216 switch (ctrl->id) {
217 case V4L2_CID_AUDIO_MUTE:
218 ctrl->value=rt->muted;
219 return (0);
220 case V4L2_CID_AUDIO_VOLUME:
221 if (rt->muted)
222 ctrl->value=0;
223 else
224 ctrl->value=65535;
225 return (0);
226 }
227 return -EINVAL;
228 }
229 case VIDIOC_S_CTRL:
230 {
231 struct v4l2_control *ctrl= arg;
232
233 switch (ctrl->id) {
234 case V4L2_CID_AUDIO_MUTE:
235 if (ctrl->value) {
236 rt_mute(rt);
237 } else {
238 rt_unmute(rt);
239 }
240 return (0);
241 case V4L2_CID_AUDIO_VOLUME:
242 if (ctrl->value) {
243 rt_unmute(rt);
244 } else {
245 rt_mute(rt);
246 }
247 return (0);
248 }
249 return -EINVAL;
250 }
251 default:
252 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
253 rt_do_ioctl);
254 } 248 }
249 return -EINVAL;
255} 250}
256 251
257static int rt_ioctl(struct inode *inode, struct file *file, 252static int vidioc_g_audio(struct file *file, void *priv,
258 unsigned int cmd, unsigned long arg) 253 struct v4l2_audio *a)
259{ 254{
260 return video_usercopy(inode, file, cmd, arg, rt_do_ioctl); 255 if (a->index > 1)
256 return -EINVAL;
257
258 strcpy(a->name, "Radio");
259 a->capability = V4L2_AUDCAP_STEREO;
260 return 0;
261}
262
263static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
264{
265 *i = 0;
266 return 0;
267}
268
269static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
270{
271 if (i != 0)
272 return -EINVAL;
273 return 0;
274}
275
276static int vidioc_s_audio(struct file *file, void *priv,
277 struct v4l2_audio *a)
278{
279 if (a->index != 0)
280 return -EINVAL;
281 return 0;
261} 282}
262 283
263static struct rt_device rtrack2_unit; 284static struct rt_device rtrack2_unit;
@@ -266,7 +287,7 @@ static const struct file_operations rtrack2_fops = {
266 .owner = THIS_MODULE, 287 .owner = THIS_MODULE,
267 .open = video_exclusive_open, 288 .open = video_exclusive_open,
268 .release = video_exclusive_release, 289 .release = video_exclusive_release,
269 .ioctl = rt_ioctl, 290 .ioctl = video_ioctl2,
270 .compat_ioctl = v4l_compat_ioctl32, 291 .compat_ioctl = v4l_compat_ioctl32,
271 .llseek = no_llseek, 292 .llseek = no_llseek,
272}; 293};
@@ -278,6 +299,18 @@ static struct video_device rtrack2_radio=
278 .type = VID_TYPE_TUNER, 299 .type = VID_TYPE_TUNER,
279 .hardware = 0, 300 .hardware = 0,
280 .fops = &rtrack2_fops, 301 .fops = &rtrack2_fops,
302 .vidioc_querycap = vidioc_querycap,
303 .vidioc_g_tuner = vidioc_g_tuner,
304 .vidioc_s_tuner = vidioc_s_tuner,
305 .vidioc_g_frequency = vidioc_g_frequency,
306 .vidioc_s_frequency = vidioc_s_frequency,
307 .vidioc_queryctrl = vidioc_queryctrl,
308 .vidioc_g_ctrl = vidioc_g_ctrl,
309 .vidioc_s_ctrl = vidioc_s_ctrl,
310 .vidioc_g_audio = vidioc_g_audio,
311 .vidioc_s_audio = vidioc_s_audio,
312 .vidioc_g_input = vidioc_g_input,
313 .vidioc_s_input = vidioc_s_input,
281}; 314};
282 315
283static int __init rtrack2_init(void) 316static int __init rtrack2_init(void)