diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-08-08 08:10:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-09-26 08:03:18 -0400 |
commit | a4366af40d7d2021499b84b8311336c944a9a71c (patch) | |
tree | 2ceff5d9e7f341b7c4dff0327085a45dddc7fb63 | |
parent | 46ff2c7250eece24974ddb2198421c83a69a6289 (diff) |
V4L/DVB (4347): V4L2 conversion: radio_aztech
Driver conversion to V4L2 API.
Require some testing, since this obsolete hardware is not
common those days.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/radio/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/radio/radio-aztech.c | 163 |
2 files changed, 114 insertions, 51 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index f17fc21247e7..81e2f35aeae8 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -82,7 +82,7 @@ config RADIO_RTRACK2_PORT | |||
82 | 82 | ||
83 | config RADIO_AZTECH | 83 | config RADIO_AZTECH |
84 | tristate "Aztech/Packard Bell Radio" | 84 | tristate "Aztech/Packard Bell Radio" |
85 | depends on ISA && VIDEO_V4L1 | 85 | depends on ISA && VIDEO_V4L2 |
86 | ---help--- | 86 | ---help--- |
87 | Choose Y here if you have one of these FM radio cards, and then fill | 87 | Choose Y here if you have one of these FM radio cards, and then fill |
88 | in the port address below. | 88 | in the port address below. |
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 63697ab517f9..f21d918b3f99 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,31 @@ | |||
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 | 36 | ||
37 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
38 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | ||
39 | |||
40 | static 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 | }; | ||
58 | |||
36 | /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ | 59 | /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ |
37 | 60 | ||
38 | #ifndef CONFIG_RADIO_AZTECH_PORT | 61 | #ifndef CONFIG_RADIO_AZTECH_PORT |
@@ -165,81 +188,121 @@ static int az_do_ioctl(struct inode *inode, struct file *file, | |||
165 | 188 | ||
166 | switch(cmd) | 189 | switch(cmd) |
167 | { | 190 | { |
168 | case VIDIOCGCAP: | 191 | case VIDIOC_QUERYCAP: |
169 | { | 192 | { |
170 | struct video_capability *v = arg; | 193 | struct v4l2_capability *v = arg; |
171 | memset(v,0,sizeof(*v)); | 194 | memset(v,0,sizeof(*v)); |
172 | v->type=VID_TYPE_TUNER; | 195 | strlcpy(v->driver, "radio-aztech", sizeof (v->driver)); |
173 | v->channels=1; | 196 | strlcpy(v->card, "Aztech Radio", sizeof (v->card)); |
174 | v->audios=1; | 197 | sprintf(v->bus_info,"ISA"); |
175 | strcpy(v->name, "Aztech Radio"); | 198 | v->version = RADIO_VERSION; |
199 | v->capabilities = V4L2_CAP_TUNER; | ||
200 | |||
176 | return 0; | 201 | return 0; |
177 | } | 202 | } |
178 | case VIDIOCGTUNER: | 203 | case VIDIOC_G_TUNER: |
179 | { | 204 | { |
180 | struct video_tuner *v = arg; | 205 | struct v4l2_tuner *v = arg; |
181 | if(v->tuner) /* Only 1 tuner */ | 206 | |
207 | if (v->index > 0) | ||
182 | return -EINVAL; | 208 | return -EINVAL; |
209 | |||
210 | memset(v,0,sizeof(*v)); | ||
211 | strcpy(v->name, "FM"); | ||
212 | v->type = V4L2_TUNER_RADIO; | ||
213 | |||
183 | v->rangelow=(87*16000); | 214 | v->rangelow=(87*16000); |
184 | v->rangehigh=(108*16000); | 215 | v->rangehigh=(108*16000); |
185 | v->flags=VIDEO_TUNER_LOW; | 216 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; |
186 | v->mode=VIDEO_MODE_AUTO; | 217 | v->capability=V4L2_TUNER_CAP_LOW; |
187 | v->signal=0xFFFF*az_getsigstr(az); | ||
188 | if(az_getstereo(az)) | 218 | if(az_getstereo(az)) |
189 | v->flags|=VIDEO_TUNER_STEREO_ON; | 219 | v->audmode = V4L2_TUNER_MODE_STEREO; |
190 | strcpy(v->name, "FM"); | 220 | else |
221 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
222 | v->signal=0xFFFF*az_getsigstr(az); | ||
223 | |||
191 | return 0; | 224 | return 0; |
192 | } | 225 | } |
193 | case VIDIOCSTUNER: | 226 | case VIDIOC_S_TUNER: |
194 | { | 227 | { |
195 | struct video_tuner *v = arg; | 228 | struct v4l2_tuner *v = arg; |
196 | if(v->tuner!=0) | 229 | |
230 | if (v->index > 0) | ||
197 | return -EINVAL; | 231 | return -EINVAL; |
232 | |||
198 | return 0; | 233 | return 0; |
199 | } | 234 | } |
200 | case VIDIOCGFREQ: | 235 | case VIDIOC_S_FREQUENCY: |
201 | { | 236 | { |
202 | unsigned long *freq = arg; | 237 | struct v4l2_frequency *f = arg; |
203 | *freq = az->curfreq; | 238 | |
239 | az->curfreq = f->frequency; | ||
240 | az_setfreq(az, az->curfreq); | ||
204 | return 0; | 241 | return 0; |
205 | } | 242 | } |
206 | case VIDIOCSFREQ: | 243 | case VIDIOC_G_FREQUENCY: |
207 | { | 244 | { |
208 | unsigned long *freq = arg; | 245 | struct v4l2_frequency *f = arg; |
209 | az->curfreq = *freq; | 246 | |
210 | az_setfreq(az, az->curfreq); | 247 | f->type = V4L2_TUNER_RADIO; |
248 | f->frequency = az->curfreq; | ||
249 | |||
211 | return 0; | 250 | return 0; |
212 | } | 251 | } |
213 | case VIDIOCGAUDIO: | 252 | |
253 | case VIDIOC_QUERYCTRL: | ||
214 | { | 254 | { |
215 | struct video_audio *v = arg; | 255 | struct v4l2_queryctrl *qc = arg; |
216 | memset(v,0, sizeof(*v)); | 256 | int i; |
217 | v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; | 257 | |
218 | if(az->stereo) | 258 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
219 | v->mode=VIDEO_SOUND_STEREO; | 259 | if (qc->id && qc->id == radio_qctrl[i].id) { |
220 | else | 260 | memcpy(qc, &(radio_qctrl[i]), |
221 | v->mode=VIDEO_SOUND_MONO; | 261 | sizeof(*qc)); |
222 | v->volume=az->curvol; | 262 | return (0); |
223 | v->step=16384; | 263 | } |
224 | strcpy(v->name, "Radio"); | 264 | } |
225 | return 0; | 265 | return -EINVAL; |
226 | } | 266 | } |
227 | case VIDIOCSAUDIO: | 267 | case VIDIOC_G_CTRL: |
228 | { | 268 | { |
229 | struct video_audio *v = arg; | 269 | struct v4l2_control *ctrl= arg; |
230 | if(v->audio) | 270 | |
231 | return -EINVAL; | 271 | switch (ctrl->id) { |
232 | az->curvol=v->volume; | 272 | case V4L2_CID_AUDIO_MUTE: |
233 | 273 | if (az->curvol==0) | |
234 | az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0; | 274 | ctrl->value=1; |
235 | if(v->flags&VIDEO_AUDIO_MUTE) | 275 | else |
236 | az_setvol(az,0); | 276 | ctrl->value=0; |
237 | else | 277 | return (0); |
238 | az_setvol(az,az->curvol); | 278 | case V4L2_CID_AUDIO_VOLUME: |
239 | 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; | ||
240 | } | 301 | } |
302 | |||
241 | default: | 303 | default: |
242 | return -ENOIOCTLCMD; | 304 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
305 | az_do_ioctl); | ||
243 | } | 306 | } |
244 | } | 307 | } |
245 | 308 | ||