diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-08-08 08:10:05 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-09-26 10:53:18 -0400 |
commit | 982eddb911b772295d5efc11f7c2b34c7fd6e60e (patch) | |
tree | a2b44c258e172b246416d391d6ff061ded5dc268 /drivers/media/radio | |
parent | 2acadefa311b480864d686fb3f7e5f79737d0187 (diff) |
V4L/DVB (4363): V4L2 conversion: radio-trust
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>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/radio/radio-trust.c | 187 |
2 files changed, 132 insertions, 57 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 1fe960c0f7e0..34d04b5b9988 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -268,7 +268,7 @@ config RADIO_TERRATEC_PORT | |||
268 | 268 | ||
269 | config RADIO_TRUST | 269 | config RADIO_TRUST |
270 | tristate "Trust FM radio card" | 270 | tristate "Trust FM radio card" |
271 | depends on ISA && VIDEO_V4L1 | 271 | depends on ISA && VIDEO_V4L2 |
272 | help | 272 | help |
273 | This is a driver for the Trust FM radio cards. Say Y if you have | 273 | This is a driver for the Trust FM radio cards. Say Y if you have |
274 | such a card and want to use it under Linux. | 274 | such a card and want to use it under Linux. |
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c index 696fae8dace0..bb03ad5a2033 100644 --- a/drivers/media/radio/radio-trust.c +++ b/drivers/media/radio/radio-trust.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) | 12 | * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) |
13 | * William McGrath (wmcgrath@twilight.vtc.vsc.edu) | 13 | * William McGrath (wmcgrath@twilight.vtc.vsc.edu) |
14 | * | 14 | * |
15 | * The basis for this code may be found at http://bigbang.vtc.vsc.edu/fmradio/ | 15 | * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <stdarg.h> | 18 | #include <stdarg.h> |
@@ -21,9 +21,47 @@ | |||
21 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #include <asm/uaccess.h> | 23 | #include <asm/uaccess.h> |
24 | #include <linux/videodev.h> | 24 | #include <linux/videodev2.h> |
25 | #include <media/v4l2-common.h> | 25 | #include <media/v4l2-common.h> |
26 | 26 | ||
27 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
28 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | ||
29 | |||
30 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
31 | { | ||
32 | .id = V4L2_CID_AUDIO_MUTE, | ||
33 | .name = "Mute", | ||
34 | .minimum = 0, | ||
35 | .maximum = 1, | ||
36 | .default_value = 1, | ||
37 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
38 | },{ | ||
39 | .id = V4L2_CID_AUDIO_VOLUME, | ||
40 | .name = "Volume", | ||
41 | .minimum = 0, | ||
42 | .maximum = 65535, | ||
43 | .step = 2048, | ||
44 | .default_value = 65535, | ||
45 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
46 | },{ | ||
47 | .id = V4L2_CID_AUDIO_BASS, | ||
48 | .name = "Bass", | ||
49 | .minimum = 0, | ||
50 | .maximum = 65535, | ||
51 | .step = 4370, | ||
52 | .default_value = 32768, | ||
53 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
54 | },{ | ||
55 | .id = V4L2_CID_AUDIO_TREBLE, | ||
56 | .name = "Treble", | ||
57 | .minimum = 0, | ||
58 | .maximum = 65535, | ||
59 | .step = 4370, | ||
60 | .default_value = 32768, | ||
61 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
62 | }, | ||
63 | }; | ||
64 | |||
27 | /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ | 65 | /* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ |
28 | 66 | ||
29 | #ifndef CONFIG_RADIO_TRUST_PORT | 67 | #ifndef CONFIG_RADIO_TRUST_PORT |
@@ -159,88 +197,125 @@ static int tr_do_ioctl(struct inode *inode, struct file *file, | |||
159 | { | 197 | { |
160 | switch(cmd) | 198 | switch(cmd) |
161 | { | 199 | { |
162 | case VIDIOCGCAP: | 200 | case VIDIOC_QUERYCAP: |
163 | { | 201 | { |
164 | struct video_capability *v = arg; | 202 | struct v4l2_capability *v = arg; |
165 | |||
166 | memset(v,0,sizeof(*v)); | 203 | memset(v,0,sizeof(*v)); |
167 | v->type=VID_TYPE_TUNER; | 204 | strlcpy(v->driver, "radio-trust", sizeof (v->driver)); |
168 | v->channels=1; | 205 | strlcpy(v->card, "Trust FM Radio", sizeof (v->card)); |
169 | v->audios=1; | 206 | sprintf(v->bus_info,"ISA"); |
170 | strcpy(v->name, "Trust FM Radio"); | 207 | v->version = RADIO_VERSION; |
208 | v->capabilities = V4L2_CAP_TUNER; | ||
171 | 209 | ||
172 | return 0; | 210 | return 0; |
173 | } | 211 | } |
174 | case VIDIOCGTUNER: | 212 | case VIDIOC_G_TUNER: |
175 | { | 213 | { |
176 | struct video_tuner *v = arg; | 214 | struct v4l2_tuner *v = arg; |
177 | 215 | ||
178 | if(v->tuner) /* Only 1 tuner */ | 216 | if (v->index > 0) |
179 | return -EINVAL; | 217 | return -EINVAL; |
180 | 218 | ||
181 | v->rangelow = 87500 * 16; | 219 | memset(v,0,sizeof(*v)); |
182 | v->rangehigh = 108000 * 16; | 220 | strcpy(v->name, "FM"); |
183 | v->flags = VIDEO_TUNER_LOW; | 221 | v->type = V4L2_TUNER_RADIO; |
184 | v->mode = VIDEO_MODE_AUTO; | ||
185 | 222 | ||
186 | v->signal = tr_getsigstr(); | 223 | v->rangelow=(87.5*16000); |
224 | v->rangehigh=(108*16000); | ||
225 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | ||
226 | v->capability=V4L2_TUNER_CAP_LOW; | ||
187 | if(tr_getstereo()) | 227 | if(tr_getstereo()) |
188 | v->flags |= VIDEO_TUNER_STEREO_ON; | 228 | v->audmode = V4L2_TUNER_MODE_STEREO; |
189 | 229 | else | |
190 | strcpy(v->name, "FM"); | 230 | v->audmode = V4L2_TUNER_MODE_MONO; |
231 | v->signal=tr_getsigstr(); | ||
191 | 232 | ||
192 | return 0; | 233 | return 0; |
193 | } | 234 | } |
194 | case VIDIOCSTUNER: | 235 | case VIDIOC_S_TUNER: |
195 | { | 236 | { |
196 | struct video_tuner *v = arg; | 237 | struct v4l2_tuner *v = arg; |
197 | if(v->tuner != 0) | 238 | |
239 | if (v->index > 0) | ||
198 | return -EINVAL; | 240 | return -EINVAL; |
241 | |||
199 | return 0; | 242 | return 0; |
200 | } | 243 | } |
201 | case VIDIOCGFREQ: | 244 | case VIDIOC_S_FREQUENCY: |
202 | { | 245 | { |
203 | unsigned long *freq = arg; | 246 | struct v4l2_frequency *f = arg; |
204 | *freq = curfreq; | 247 | |
248 | curfreq = f->frequency; | ||
249 | tr_setfreq(curfreq); | ||
205 | return 0; | 250 | return 0; |
206 | } | 251 | } |
207 | case VIDIOCSFREQ: | 252 | case VIDIOC_G_FREQUENCY: |
208 | { | 253 | { |
209 | unsigned long *freq = arg; | 254 | struct v4l2_frequency *f = arg; |
210 | tr_setfreq(*freq); | 255 | |
256 | f->type = V4L2_TUNER_RADIO; | ||
257 | f->frequency = curfreq; | ||
258 | |||
211 | return 0; | 259 | return 0; |
212 | } | 260 | } |
213 | case VIDIOCGAUDIO: | 261 | case VIDIOC_QUERYCTRL: |
214 | { | 262 | { |
215 | struct video_audio *v = arg; | 263 | struct v4l2_queryctrl *qc = arg; |
216 | 264 | int i; | |
217 | memset(v,0, sizeof(*v)); | 265 | |
218 | v->flags = VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME | | 266 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
219 | VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; | 267 | if (qc->id && qc->id == radio_qctrl[i].id) { |
220 | v->mode = curstereo? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | 268 | memcpy(qc, &(radio_qctrl[i]), |
221 | v->volume = curvol * 2048; | 269 | sizeof(*qc)); |
222 | v->step = 2048; | 270 | return (0); |
223 | v->bass = curbass * 4370; | 271 | } |
224 | v->treble = curtreble * 4370; | 272 | } |
225 | 273 | return -EINVAL; | |
226 | strcpy(v->name, "Trust FM Radio"); | ||
227 | return 0; | ||
228 | } | 274 | } |
229 | case VIDIOCSAUDIO: | 275 | case VIDIOC_G_CTRL: |
230 | { | 276 | { |
231 | struct video_audio *v = arg; | 277 | struct v4l2_control *ctrl= arg; |
232 | 278 | ||
233 | if(v->audio) | 279 | switch (ctrl->id) { |
234 | return -EINVAL; | 280 | case V4L2_CID_AUDIO_MUTE: |
235 | tr_setvol(v->volume); | 281 | ctrl->value=curmute; |
236 | tr_setbass(v->bass); | 282 | return (0); |
237 | tr_settreble(v->treble); | 283 | case V4L2_CID_AUDIO_VOLUME: |
238 | tr_setstereo(v->mode & VIDEO_SOUND_STEREO); | 284 | ctrl->value= curvol * 2048; |
239 | tr_setmute(v->flags & VIDEO_AUDIO_MUTE); | 285 | return (0); |
240 | return 0; | 286 | case V4L2_CID_AUDIO_BASS: |
287 | ctrl->value= curbass * 4370; | ||
288 | return (0); | ||
289 | case V4L2_CID_AUDIO_TREBLE: | ||
290 | ctrl->value= curtreble * 4370; | ||
291 | return (0); | ||
292 | } | ||
293 | return -EINVAL; | ||
241 | } | 294 | } |
295 | case VIDIOC_S_CTRL: | ||
296 | { | ||
297 | struct v4l2_control *ctrl= arg; | ||
298 | |||
299 | switch (ctrl->id) { | ||
300 | case V4L2_CID_AUDIO_MUTE: | ||
301 | tr_setmute(ctrl->value); | ||
302 | return 0; | ||
303 | case V4L2_CID_AUDIO_VOLUME: | ||
304 | tr_setvol(ctrl->value); | ||
305 | return 0; | ||
306 | case V4L2_CID_AUDIO_BASS: | ||
307 | tr_setbass(ctrl->value); | ||
308 | return 0; | ||
309 | case V4L2_CID_AUDIO_TREBLE: | ||
310 | tr_settreble(ctrl->value); | ||
311 | return (0); | ||
312 | } | ||
313 | return -EINVAL; | ||
314 | } | ||
315 | |||
242 | default: | 316 | default: |
243 | return -ENOIOCTLCMD; | 317 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
318 | tr_do_ioctl); | ||
244 | } | 319 | } |
245 | } | 320 | } |
246 | 321 | ||
@@ -264,7 +339,7 @@ static struct video_device trust_radio= | |||
264 | .owner = THIS_MODULE, | 339 | .owner = THIS_MODULE, |
265 | .name = "Trust FM Radio", | 340 | .name = "Trust FM Radio", |
266 | .type = VID_TYPE_TUNER, | 341 | .type = VID_TYPE_TUNER, |
267 | .hardware = VID_HARDWARE_TRUST, | 342 | .hardware = 0, |
268 | .fops = &trust_fops, | 343 | .fops = &trust_fops, |
269 | }; | 344 | }; |
270 | 345 | ||