aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-aztech.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-aztech.c')
-rw-r--r--drivers/media/radio/radio-aztech.c166
1 files changed, 114 insertions, 52 deletions
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 95e6322133ee..3ba5fa8cf7e6 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -1,5 +1,6 @@
1/* radio-aztech.c - Aztech radio card driver for Linux 2.2 1/* radio-aztech.c - Aztech radio card driver for Linux 2.2
2 * 2 *
3 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
3 * Adapted to support the Video for Linux API by 4 * Adapted to support the Video for Linux API by
4 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by: 5 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
5 * 6 *
@@ -30,9 +31,30 @@
30#include <linux/delay.h> /* udelay */ 31#include <linux/delay.h> /* udelay */
31#include <asm/io.h> /* outb, outb_p */ 32#include <asm/io.h> /* outb, outb_p */
32#include <asm/uaccess.h> /* copy to/from user */ 33#include <asm/uaccess.h> /* copy to/from user */
33#include <linux/videodev.h> /* kernel radio structs */ 34#include <linux/videodev2.h> /* kernel radio structs */
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
35#include <linux/config.h> /* CONFIG_RADIO_AZTECH_PORT */ 36
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2)
39
40static struct v4l2_queryctrl radio_qctrl[] = {
41 {
42 .id = V4L2_CID_AUDIO_MUTE,
43 .name = "Mute",
44 .minimum = 0,
45 .maximum = 1,
46 .default_value = 1,
47 .type = V4L2_CTRL_TYPE_BOOLEAN,
48 },{
49 .id = V4L2_CID_AUDIO_VOLUME,
50 .name = "Volume",
51 .minimum = 0,
52 .maximum = 0xff,
53 .step = 1,
54 .default_value = 0xff,
55 .type = V4L2_CTRL_TYPE_INTEGER,
56 }
57};
36 58
37/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ 59/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
38 60
@@ -166,81 +188,121 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
166 188
167 switch(cmd) 189 switch(cmd)
168 { 190 {
169 case VIDIOCGCAP: 191 case VIDIOC_QUERYCAP:
170 { 192 {
171 struct video_capability *v = arg; 193 struct v4l2_capability *v = arg;
172 memset(v,0,sizeof(*v)); 194 memset(v,0,sizeof(*v));
173 v->type=VID_TYPE_TUNER; 195 strlcpy(v->driver, "radio-aztech", sizeof (v->driver));
174 v->channels=1; 196 strlcpy(v->card, "Aztech Radio", sizeof (v->card));
175 v->audios=1; 197 sprintf(v->bus_info,"ISA");
176 strcpy(v->name, "Aztech Radio"); 198 v->version = RADIO_VERSION;
199 v->capabilities = V4L2_CAP_TUNER;
200
177 return 0; 201 return 0;
178 } 202 }
179 case VIDIOCGTUNER: 203 case VIDIOC_G_TUNER:
180 { 204 {
181 struct video_tuner *v = arg; 205 struct v4l2_tuner *v = arg;
182 if(v->tuner) /* Only 1 tuner */ 206
207 if (v->index > 0)
183 return -EINVAL; 208 return -EINVAL;
209
210 memset(v,0,sizeof(*v));
211 strcpy(v->name, "FM");
212 v->type = V4L2_TUNER_RADIO;
213
184 v->rangelow=(87*16000); 214 v->rangelow=(87*16000);
185 v->rangehigh=(108*16000); 215 v->rangehigh=(108*16000);
186 v->flags=VIDEO_TUNER_LOW; 216 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
187 v->mode=VIDEO_MODE_AUTO; 217 v->capability=V4L2_TUNER_CAP_LOW;
188 v->signal=0xFFFF*az_getsigstr(az);
189 if(az_getstereo(az)) 218 if(az_getstereo(az))
190 v->flags|=VIDEO_TUNER_STEREO_ON; 219 v->audmode = V4L2_TUNER_MODE_STEREO;
191 strcpy(v->name, "FM"); 220 else
221 v->audmode = V4L2_TUNER_MODE_MONO;
222 v->signal=0xFFFF*az_getsigstr(az);
223
192 return 0; 224 return 0;
193 } 225 }
194 case VIDIOCSTUNER: 226 case VIDIOC_S_TUNER:
195 { 227 {
196 struct video_tuner *v = arg; 228 struct v4l2_tuner *v = arg;
197 if(v->tuner!=0) 229
230 if (v->index > 0)
198 return -EINVAL; 231 return -EINVAL;
232
199 return 0; 233 return 0;
200 } 234 }
201 case VIDIOCGFREQ: 235 case VIDIOC_S_FREQUENCY:
202 { 236 {
203 unsigned long *freq = arg; 237 struct v4l2_frequency *f = arg;
204 *freq = az->curfreq; 238
239 az->curfreq = f->frequency;
240 az_setfreq(az, az->curfreq);
205 return 0; 241 return 0;
206 } 242 }
207 case VIDIOCSFREQ: 243 case VIDIOC_G_FREQUENCY:
208 { 244 {
209 unsigned long *freq = arg; 245 struct v4l2_frequency *f = arg;
210 az->curfreq = *freq; 246
211 az_setfreq(az, az->curfreq); 247 f->type = V4L2_TUNER_RADIO;
248 f->frequency = az->curfreq;
249
212 return 0; 250 return 0;
213 } 251 }
214 case VIDIOCGAUDIO: 252
253 case VIDIOC_QUERYCTRL:
215 { 254 {
216 struct video_audio *v = arg; 255 struct v4l2_queryctrl *qc = arg;
217 memset(v,0, sizeof(*v)); 256 int i;
218 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 257
219 if(az->stereo) 258 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
220 v->mode=VIDEO_SOUND_STEREO; 259 if (qc->id && qc->id == radio_qctrl[i].id) {
221 else 260 memcpy(qc, &(radio_qctrl[i]),
222 v->mode=VIDEO_SOUND_MONO; 261 sizeof(*qc));
223 v->volume=az->curvol; 262 return (0);
224 v->step=16384; 263 }
225 strcpy(v->name, "Radio"); 264 }
226 return 0; 265 return -EINVAL;
227 } 266 }
228 case VIDIOCSAUDIO: 267 case VIDIOC_G_CTRL:
229 { 268 {
230 struct video_audio *v = arg; 269 struct v4l2_control *ctrl= arg;
231 if(v->audio) 270
232 return -EINVAL; 271 switch (ctrl->id) {
233 az->curvol=v->volume; 272 case V4L2_CID_AUDIO_MUTE:
234 273 if (az->curvol==0)
235 az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0; 274 ctrl->value=1;
236 if(v->flags&VIDEO_AUDIO_MUTE) 275 else
237 az_setvol(az,0); 276 ctrl->value=0;
238 else 277 return (0);
239 az_setvol(az,az->curvol); 278 case V4L2_CID_AUDIO_VOLUME:
240 return 0; 279 ctrl->value=az->curvol * 6554;
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;
241 } 301 }
302
242 default: 303 default:
243 return -ENOIOCTLCMD; 304 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
305 az_do_ioctl);
244 } 306 }
245} 307}
246 308
@@ -266,7 +328,7 @@ static struct video_device aztech_radio=
266 .owner = THIS_MODULE, 328 .owner = THIS_MODULE,
267 .name = "Aztech radio", 329 .name = "Aztech radio",
268 .type = VID_TYPE_TUNER, 330 .type = VID_TYPE_TUNER,
269 .hardware = VID_HARDWARE_AZTECH, 331 .hardware = 0,
270 .fops = &aztech_fops, 332 .fops = &aztech_fops,
271}; 333};
272 334