aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-01-25 06:09:32 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:55 -0500
commit99218fe478e2ca6d5ee660a655690ab6496e6ab5 (patch)
treed730f2223b9f74d3ef73d766f1c47eee58792f87 /drivers/media
parentb50e7fe99317c05b0bb8ba6338bc6aa7da3b918e (diff)
V4L/DVB (5148): Convert radio-aztech to use video_ioctl2
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/radio/radio-aztech.c240
1 files changed, 122 insertions, 118 deletions
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 19d45cc940b5..91d69c8ad3cd 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -180,136 +180,129 @@ static int az_setfreq(struct az_device *dev, unsigned long frequency)
180 return 0; 180 return 0;
181} 181}
182 182
183static int az_do_ioctl(struct inode *inode, struct file *file, 183static int vidioc_querycap (struct file *file, void *priv,
184 unsigned int cmd, void *arg) 184 struct v4l2_capability *v)
185{
186 strlcpy(v->driver, "radio-aztech", sizeof (v->driver));
187 strlcpy(v->card, "Aztech Radio", sizeof (v->card));
188 sprintf(v->bus_info,"ISA");
189 v->version = RADIO_VERSION;
190 v->capabilities = V4L2_CAP_TUNER;
191 return 0;
192}
193
194static int vidioc_g_tuner (struct file *file, void *priv,
195 struct v4l2_tuner *v)
185{ 196{
186 struct video_device *dev = video_devdata(file); 197 struct video_device *dev = video_devdata(file);
187 struct az_device *az = dev->priv; 198 struct az_device *az = dev->priv;
188 199
189 switch(cmd) 200 if (v->index > 0)
190 { 201 return -EINVAL;
191 case VIDIOC_QUERYCAP:
192 {
193 struct v4l2_capability *v = arg;
194 memset(v,0,sizeof(*v));
195 strlcpy(v->driver, "radio-aztech", sizeof (v->driver));
196 strlcpy(v->card, "Aztech Radio", sizeof (v->card));
197 sprintf(v->bus_info,"ISA");
198 v->version = RADIO_VERSION;
199 v->capabilities = V4L2_CAP_TUNER;
200 202
201 return 0; 203 strcpy(v->name, "FM");
202 } 204 v->type = V4L2_TUNER_RADIO;
203 case VIDIOC_G_TUNER:
204 {
205 struct v4l2_tuner *v = arg;
206
207 if (v->index > 0)
208 return -EINVAL;
209
210 memset(v,0,sizeof(*v));
211 strcpy(v->name, "FM");
212 v->type = V4L2_TUNER_RADIO;
213
214 v->rangelow=(87*16000);
215 v->rangehigh=(108*16000);
216 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
217 v->capability=V4L2_TUNER_CAP_LOW;
218 if(az_getstereo(az))
219 v->audmode = V4L2_TUNER_MODE_STEREO;
220 else
221 v->audmode = V4L2_TUNER_MODE_MONO;
222 v->signal=0xFFFF*az_getsigstr(az);
223 205
224 return 0; 206 v->rangelow=(87*16000);
225 } 207 v->rangehigh=(108*16000);
226 case VIDIOC_S_TUNER: 208 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
227 { 209 v->capability=V4L2_TUNER_CAP_LOW;
228 struct v4l2_tuner *v = arg; 210 if(az_getstereo(az))
211 v->audmode = V4L2_TUNER_MODE_STEREO;
212 else
213 v->audmode = V4L2_TUNER_MODE_MONO;
214 v->signal=0xFFFF*az_getsigstr(az);
229 215
230 if (v->index > 0) 216 return 0;
231 return -EINVAL; 217}
232 218
233 return 0;
234 }
235 case VIDIOC_S_FREQUENCY:
236 {
237 struct v4l2_frequency *f = arg;
238 219
239 az->curfreq = f->frequency; 220static int vidioc_s_tuner (struct file *file, void *priv,
240 az_setfreq(az, az->curfreq); 221 struct v4l2_tuner *v)
241 return 0; 222{
242 } 223 if (v->index > 0)
243 case VIDIOC_G_FREQUENCY: 224 return -EINVAL;
244 {
245 struct v4l2_frequency *f = arg;
246 225
247 f->type = V4L2_TUNER_RADIO; 226 return 0;
248 f->frequency = az->curfreq; 227}
249 228
250 return 0; 229static int vidioc_s_frequency (struct file *file, void *priv,
251 } 230 struct v4l2_frequency *f)
231{
232 struct video_device *dev = video_devdata(file);
233 struct az_device *az = dev->priv;
252 234
253 case VIDIOC_QUERYCTRL: 235 az->curfreq = f->frequency;
254 { 236 az_setfreq(az, az->curfreq);
255 struct v4l2_queryctrl *qc = arg; 237 return 0;
256 int i; 238}
257 239
258 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 240static int vidioc_g_frequency (struct file *file, void *priv,
259 if (qc->id && qc->id == radio_qctrl[i].id) { 241 struct v4l2_frequency *f)
260 memcpy(qc, &(radio_qctrl[i]), 242{
261 sizeof(*qc)); 243 struct video_device *dev = video_devdata(file);
262 return (0); 244 struct az_device *az = dev->priv;
263 } 245
264 } 246 f->type = V4L2_TUNER_RADIO;
265 return -EINVAL; 247 f->frequency = az->curfreq;
266 } 248
267 case VIDIOC_G_CTRL: 249 return 0;
268 { 250}
269 struct v4l2_control *ctrl= arg; 251
270 252static int vidioc_queryctrl (struct file *file, void *priv,
271 switch (ctrl->id) { 253 struct v4l2_queryctrl *qc)
272 case V4L2_CID_AUDIO_MUTE: 254{
273 if (az->curvol==0) 255 int i;
274 ctrl->value=1; 256
275 else 257 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
276 ctrl->value=0; 258 if (qc->id && qc->id == radio_qctrl[i].id) {
277 return (0); 259 memcpy(qc, &(radio_qctrl[i]),
278 case V4L2_CID_AUDIO_VOLUME: 260 sizeof(*qc));
279 ctrl->value=az->curvol * 6554; 261 return (0);
280 return (0);
281 }
282 return -EINVAL;
283 }
284 case VIDIOC_S_CTRL:
285 {
286 struct v4l2_control *ctrl= arg;
287
288 switch (ctrl->id) {
289 case V4L2_CID_AUDIO_MUTE:
290 if (ctrl->value) {
291 az_setvol(az,0);
292 } else {
293 az_setvol(az,az->curvol);
294 }
295 return (0);
296 case V4L2_CID_AUDIO_VOLUME:
297 az_setvol(az,ctrl->value);
298 return (0);
299 }
300 return -EINVAL;
301 } 262 }
263 }
264 return -EINVAL;
265}
302 266
303 default: 267static int vidioc_g_ctrl (struct file *file, void *priv,
304 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 268 struct v4l2_control *ctrl)
305 az_do_ioctl); 269{
270 struct video_device *dev = video_devdata(file);
271 struct az_device *az = dev->priv;
272
273 switch (ctrl->id) {
274 case V4L2_CID_AUDIO_MUTE:
275 if (az->curvol==0)
276 ctrl->value=1;
277 else
278 ctrl->value=0;
279 return (0);
280 case V4L2_CID_AUDIO_VOLUME:
281 ctrl->value=az->curvol * 6554;
282 return (0);
306 } 283 }
284 return -EINVAL;
307} 285}
308 286
309static int az_ioctl(struct inode *inode, struct file *file, 287static int vidioc_s_ctrl (struct file *file, void *priv,
310 unsigned int cmd, unsigned long arg) 288 struct v4l2_control *ctrl)
311{ 289{
312 return video_usercopy(inode, file, cmd, arg, az_do_ioctl); 290 struct video_device *dev = video_devdata(file);
291 struct az_device *az = dev->priv;
292
293 switch (ctrl->id) {
294 case V4L2_CID_AUDIO_MUTE:
295 if (ctrl->value) {
296 az_setvol(az,0);
297 } else {
298 az_setvol(az,az->curvol);
299 }
300 return (0);
301 case V4L2_CID_AUDIO_VOLUME:
302 az_setvol(az,ctrl->value);
303 return (0);
304 }
305 return -EINVAL;
313} 306}
314 307
315static struct az_device aztech_unit; 308static struct az_device aztech_unit;
@@ -318,20 +311,31 @@ static const struct file_operations aztech_fops = {
318 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
319 .open = video_exclusive_open, 312 .open = video_exclusive_open,
320 .release = video_exclusive_release, 313 .release = video_exclusive_release,
321 .ioctl = az_ioctl, 314 .ioctl = video_ioctl2,
322 .compat_ioctl = v4l_compat_ioctl32, 315 .compat_ioctl = v4l_compat_ioctl32,
323 .llseek = no_llseek, 316 .llseek = no_llseek,
324}; 317};
325 318
326static struct video_device aztech_radio= 319static struct video_device aztech_radio=
327{ 320{
328 .owner = THIS_MODULE, 321 .owner = THIS_MODULE,
329 .name = "Aztech radio", 322 .name = "Aztech radio",
330 .type = VID_TYPE_TUNER, 323 .type = VID_TYPE_TUNER,
331 .hardware = 0, 324 .hardware = 0,
332 .fops = &aztech_fops, 325 .fops = &aztech_fops,
326 .vidioc_querycap = vidioc_querycap,
327 .vidioc_g_tuner = vidioc_g_tuner,
328 .vidioc_s_tuner = vidioc_s_tuner,
329 .vidioc_g_frequency = vidioc_g_frequency,
330 .vidioc_s_frequency = vidioc_s_frequency,
331 .vidioc_queryctrl = vidioc_queryctrl,
332 .vidioc_g_ctrl = vidioc_g_ctrl,
333 .vidioc_s_ctrl = vidioc_s_ctrl,
333}; 334};
334 335
336module_param_named(debug,aztech_radio.debug, int, 0644);
337MODULE_PARM_DESC(debug,"activates debug info");
338
335static int __init aztech_init(void) 339static int __init aztech_init(void)
336{ 340{
337 if(io==-1) 341 if(io==-1)