diff options
author | Douglas Landgraf <dougsland@gmail.com> | 2007-04-24 07:40:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:45:55 -0400 |
commit | 3f6892aca5d23730a747ce88eb0b6848e7a52a2f (patch) | |
tree | dbad2594c57a65b9205d840250626015e83a4636 /drivers | |
parent | 74ea1c7a7e7b5dfe961f3ed08365f9deb899b163 (diff) |
V4L/DVB (5553): Replace typhoon_do_ioctl to use video_ioctl2
Convert radio-typhoon to use video_ioctl2
Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/radio/radio-typhoon.c | 239 |
1 files changed, 134 insertions, 105 deletions
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c index 3031fef178cb..8ff5a23a9f01 100644 --- a/drivers/media/radio/radio-typhoon.c +++ b/drivers/media/radio/radio-typhoon.c | |||
@@ -93,8 +93,6 @@ static int typhoon_setfreq(struct typhoon_device *dev, unsigned long frequency); | |||
93 | static void typhoon_mute(struct typhoon_device *dev); | 93 | static void typhoon_mute(struct typhoon_device *dev); |
94 | static void typhoon_unmute(struct typhoon_device *dev); | 94 | static void typhoon_unmute(struct typhoon_device *dev); |
95 | static int typhoon_setvol(struct typhoon_device *dev, int vol); | 95 | static int typhoon_setvol(struct typhoon_device *dev, int vol); |
96 | static int typhoon_ioctl(struct inode *inode, struct file *file, | ||
97 | unsigned int cmd, unsigned long arg); | ||
98 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS | 96 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS |
99 | static int typhoon_get_info(char *buf, char **start, off_t offset, int len); | 97 | static int typhoon_get_info(char *buf, char **start, off_t offset, int len); |
100 | #endif | 98 | #endif |
@@ -186,129 +184,148 @@ static int typhoon_setvol(struct typhoon_device *dev, int vol) | |||
186 | return 0; | 184 | return 0; |
187 | } | 185 | } |
188 | 186 | ||
187 | static int vidioc_querycap(struct file *file, void *priv, | ||
188 | struct v4l2_capability *v) | ||
189 | { | ||
190 | strlcpy(v->driver, "radio-typhoon", sizeof(v->driver)); | ||
191 | strlcpy(v->card, "Typhoon Radio", sizeof(v->card)); | ||
192 | sprintf(v->bus_info, "ISA"); | ||
193 | v->version = RADIO_VERSION; | ||
194 | v->capabilities = V4L2_CAP_TUNER; | ||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static int vidioc_g_tuner(struct file *file, void *priv, | ||
199 | struct v4l2_tuner *v) | ||
200 | { | ||
201 | if (v->index > 0) | ||
202 | return -EINVAL; | ||
203 | |||
204 | strcpy(v->name, "FM"); | ||
205 | v->type = V4L2_TUNER_RADIO; | ||
206 | v->rangelow = (87.5*16000); | ||
207 | v->rangehigh = (108*16000); | ||
208 | v->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
209 | v->capability = V4L2_TUNER_CAP_LOW; | ||
210 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
211 | v->signal = 0xFFFF; /* We can't get the signal strength */ | ||
212 | return 0; | ||
213 | } | ||
189 | 214 | ||
190 | static int typhoon_do_ioctl(struct inode *inode, struct file *file, | 215 | static int vidioc_s_tuner(struct file *file, void *priv, |
191 | unsigned int cmd, void *arg) | 216 | struct v4l2_tuner *v) |
217 | { | ||
218 | if (v->index > 0) | ||
219 | return -EINVAL; | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int vidioc_s_frequency(struct file *file, void *priv, | ||
225 | struct v4l2_frequency *f) | ||
192 | { | 226 | { |
193 | struct video_device *dev = video_devdata(file); | 227 | struct video_device *dev = video_devdata(file); |
194 | struct typhoon_device *typhoon = dev->priv; | 228 | struct typhoon_device *typhoon = dev->priv; |
195 | 229 | ||
196 | switch (cmd) { | 230 | typhoon->curfreq = f->frequency; |
197 | case VIDIOC_QUERYCAP: | 231 | typhoon_setfreq(typhoon, typhoon->curfreq); |
198 | { | 232 | return 0; |
199 | struct v4l2_capability *v = arg; | 233 | } |
200 | memset(v,0,sizeof(*v)); | ||
201 | strlcpy(v->driver, "radio-typhoon", sizeof (v->driver)); | ||
202 | strlcpy(v->card, "Typhoon Radio", sizeof (v->card)); | ||
203 | sprintf(v->bus_info,"ISA"); | ||
204 | v->version = RADIO_VERSION; | ||
205 | v->capabilities = V4L2_CAP_TUNER; | ||
206 | 234 | ||
207 | return 0; | 235 | static int vidioc_g_frequency(struct file *file, void *priv, |
208 | } | 236 | struct v4l2_frequency *f) |
209 | case VIDIOC_G_TUNER: | 237 | { |
210 | { | 238 | struct video_device *dev = video_devdata(file); |
211 | struct v4l2_tuner *v = arg; | 239 | struct typhoon_device *typhoon = dev->priv; |
212 | 240 | ||
213 | if (v->index > 0) | 241 | f->type = V4L2_TUNER_RADIO; |
214 | return -EINVAL; | 242 | f->frequency = typhoon->curfreq; |
215 | 243 | ||
216 | memset(v,0,sizeof(*v)); | 244 | return 0; |
217 | strcpy(v->name, "FM"); | 245 | } |
218 | v->type = V4L2_TUNER_RADIO; | ||
219 | 246 | ||
220 | v->rangelow=(87.5*16000); | 247 | static int vidioc_queryctrl(struct file *file, void *priv, |
221 | v->rangehigh=(108*16000); | 248 | struct v4l2_queryctrl *qc) |
222 | v->rxsubchans =V4L2_TUNER_SUB_MONO; | 249 | { |
223 | v->capability=V4L2_TUNER_CAP_LOW; | 250 | int i; |
224 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
225 | v->signal = 0xFFFF; /* We can't get the signal strength */ | ||
226 | 251 | ||
252 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
253 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
254 | memcpy(qc, &(radio_qctrl[i]), | ||
255 | sizeof(*qc)); | ||
227 | return 0; | 256 | return 0; |
228 | } | 257 | } |
229 | case VIDIOC_S_TUNER: | 258 | } |
230 | { | 259 | return -EINVAL; |
231 | struct v4l2_tuner *v = arg; | 260 | } |
232 | 261 | ||
233 | if (v->index > 0) | 262 | static int vidioc_g_ctrl(struct file *file, void *priv, |
234 | return -EINVAL; | 263 | struct v4l2_control *ctrl) |
264 | { | ||
265 | struct video_device *dev = video_devdata(file); | ||
266 | struct typhoon_device *typhoon = dev->priv; | ||
235 | 267 | ||
236 | return 0; | 268 | switch (ctrl->id) { |
237 | } | 269 | case V4L2_CID_AUDIO_MUTE: |
238 | case VIDIOC_S_FREQUENCY: | 270 | ctrl->value = typhoon->muted; |
239 | { | 271 | return 0; |
240 | struct v4l2_frequency *f = arg; | 272 | case V4L2_CID_AUDIO_VOLUME: |
273 | ctrl->value = typhoon->curvol; | ||
274 | return 0; | ||
275 | } | ||
276 | return -EINVAL; | ||
277 | } | ||
241 | 278 | ||
242 | typhoon->curfreq = f->frequency; | 279 | static int vidioc_s_ctrl (struct file *file, void *priv, |
243 | typhoon_setfreq(typhoon, typhoon->curfreq); | 280 | struct v4l2_control *ctrl) |
244 | return 0; | 281 | { |
245 | } | 282 | struct video_device *dev = video_devdata(file); |
246 | case VIDIOC_G_FREQUENCY: | 283 | struct typhoon_device *typhoon = dev->priv; |
247 | { | ||
248 | struct v4l2_frequency *f = arg; | ||
249 | 284 | ||
250 | f->type = V4L2_TUNER_RADIO; | 285 | switch (ctrl->id) { |
251 | f->frequency = typhoon->curfreq; | 286 | case V4L2_CID_AUDIO_MUTE: |
287 | if (ctrl->value) | ||
288 | typhoon_mute(typhoon); | ||
289 | else | ||
290 | typhoon_unmute(typhoon); | ||
291 | return 0; | ||
292 | case V4L2_CID_AUDIO_VOLUME: | ||
293 | typhoon_setvol(typhoon, ctrl->value); | ||
294 | return 0; | ||
295 | } | ||
296 | return -EINVAL; | ||
297 | } | ||
252 | 298 | ||
253 | return 0; | 299 | static int vidioc_g_audio(struct file *file, void *priv, |
254 | } | 300 | struct v4l2_audio *a) |
255 | case VIDIOC_QUERYCTRL: | 301 | { |
256 | { | 302 | if (a->index > 1) |
257 | struct v4l2_queryctrl *qc = arg; | 303 | return -EINVAL; |
258 | int i; | ||
259 | |||
260 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
261 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
262 | memcpy(qc, &(radio_qctrl[i]), | ||
263 | sizeof(*qc)); | ||
264 | return (0); | ||
265 | } | ||
266 | } | ||
267 | return -EINVAL; | ||
268 | } | ||
269 | case VIDIOC_G_CTRL: | ||
270 | { | ||
271 | struct v4l2_control *ctrl= arg; | ||
272 | |||
273 | switch (ctrl->id) { | ||
274 | case V4L2_CID_AUDIO_MUTE: | ||
275 | ctrl->value=typhoon->muted; | ||
276 | return (0); | ||
277 | case V4L2_CID_AUDIO_VOLUME: | ||
278 | ctrl->value=typhoon->curvol; | ||
279 | return (0); | ||
280 | } | ||
281 | return -EINVAL; | ||
282 | } | ||
283 | case VIDIOC_S_CTRL: | ||
284 | { | ||
285 | struct v4l2_control *ctrl= arg; | ||
286 | |||
287 | switch (ctrl->id) { | ||
288 | case V4L2_CID_AUDIO_MUTE: | ||
289 | if (ctrl->value) { | ||
290 | typhoon_mute(typhoon); | ||
291 | } else { | ||
292 | typhoon_unmute(typhoon); | ||
293 | } | ||
294 | return (0); | ||
295 | case V4L2_CID_AUDIO_VOLUME: | ||
296 | typhoon_setvol(typhoon, ctrl->value); | ||
297 | return (0); | ||
298 | } | ||
299 | return -EINVAL; | ||
300 | } | ||
301 | 304 | ||
302 | default: | 305 | strcpy(a->name, "Radio"); |
303 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | 306 | a->capability = V4L2_AUDCAP_STEREO; |
304 | typhoon_do_ioctl); | 307 | return 0; |
305 | } | 308 | } |
309 | |||
310 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) | ||
311 | { | ||
312 | *i = 0; | ||
313 | return 0; | ||
314 | } | ||
315 | |||
316 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | ||
317 | { | ||
318 | if (i != 0) | ||
319 | return -EINVAL; | ||
320 | return 0; | ||
306 | } | 321 | } |
307 | 322 | ||
308 | static int typhoon_ioctl(struct inode *inode, struct file *file, | 323 | static int vidioc_s_audio(struct file *file, void *priv, |
309 | unsigned int cmd, unsigned long arg) | 324 | struct v4l2_audio *a) |
310 | { | 325 | { |
311 | return video_usercopy(inode, file, cmd, arg, typhoon_do_ioctl); | 326 | if (a->index != 0) |
327 | return -EINVAL; | ||
328 | return 0; | ||
312 | } | 329 | } |
313 | 330 | ||
314 | static struct typhoon_device typhoon_unit = | 331 | static struct typhoon_device typhoon_unit = |
@@ -322,7 +339,7 @@ static const struct file_operations typhoon_fops = { | |||
322 | .owner = THIS_MODULE, | 339 | .owner = THIS_MODULE, |
323 | .open = video_exclusive_open, | 340 | .open = video_exclusive_open, |
324 | .release = video_exclusive_release, | 341 | .release = video_exclusive_release, |
325 | .ioctl = typhoon_ioctl, | 342 | .ioctl = video_ioctl2, |
326 | .compat_ioctl = v4l_compat_ioctl32, | 343 | .compat_ioctl = v4l_compat_ioctl32, |
327 | .llseek = no_llseek, | 344 | .llseek = no_llseek, |
328 | }; | 345 | }; |
@@ -334,6 +351,18 @@ static struct video_device typhoon_radio = | |||
334 | .type = VID_TYPE_TUNER, | 351 | .type = VID_TYPE_TUNER, |
335 | .hardware = 0, | 352 | .hardware = 0, |
336 | .fops = &typhoon_fops, | 353 | .fops = &typhoon_fops, |
354 | .vidioc_querycap = vidioc_querycap, | ||
355 | .vidioc_g_tuner = vidioc_g_tuner, | ||
356 | .vidioc_s_tuner = vidioc_s_tuner, | ||
357 | .vidioc_g_audio = vidioc_g_audio, | ||
358 | .vidioc_s_audio = vidioc_s_audio, | ||
359 | .vidioc_g_input = vidioc_g_input, | ||
360 | .vidioc_s_input = vidioc_s_input, | ||
361 | .vidioc_g_frequency = vidioc_g_frequency, | ||
362 | .vidioc_s_frequency = vidioc_s_frequency, | ||
363 | .vidioc_queryctrl = vidioc_queryctrl, | ||
364 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
365 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
337 | }; | 366 | }; |
338 | 367 | ||
339 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS | 368 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS |