aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-gemtek.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-08-08 08:10:01 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:11 -0400
commitd1c4ecdeec612a587e9b564839fc578f41d3049d (patch)
tree2c3ebef4c841c38520fec0d36de3efc3cff5c1ad /drivers/media/radio/radio-gemtek.c
parent38ee04f04340ffd6af868499862341d11ed2b331 (diff)
V4L/DVB (4349): V4L2 conversion: radio_gemtek
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/radio-gemtek.c')
-rw-r--r--drivers/media/radio/radio-gemtek.c164
1 files changed, 116 insertions, 48 deletions
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index ffabe02406b5..730fe16126cb 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -13,6 +13,7 @@
13 * 13 *
14 * TODO: Allow for more than one of these foolish entities :-) 14 * TODO: Allow for more than one of these foolish entities :-)
15 * 15 *
16 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
16 */ 17 */
17 18
18#include <linux/module.h> /* Modules */ 19#include <linux/module.h> /* Modules */
@@ -21,10 +22,32 @@
21#include <linux/delay.h> /* udelay */ 22#include <linux/delay.h> /* udelay */
22#include <asm/io.h> /* outb, outb_p */ 23#include <asm/io.h> /* outb, outb_p */
23#include <asm/uaccess.h> /* copy to/from user */ 24#include <asm/uaccess.h> /* copy to/from user */
24#include <linux/videodev.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
25#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27 28
29#include <linux/version.h> /* for KERNEL_VERSION MACRO */
30#define RADIO_VERSION KERNEL_VERSION(0,0,2)
31
32static struct v4l2_queryctrl radio_qctrl[] = {
33 {
34 .id = V4L2_CID_AUDIO_MUTE,
35 .name = "Mute",
36 .minimum = 0,
37 .maximum = 1,
38 .default_value = 1,
39 .type = V4L2_CTRL_TYPE_BOOLEAN,
40 },{
41 .id = V4L2_CID_AUDIO_VOLUME,
42 .name = "Volume",
43 .minimum = 0,
44 .maximum = 65535,
45 .step = 65535,
46 .default_value = 0xff,
47 .type = V4L2_CTRL_TYPE_INTEGER,
48 }
49};
50
28#ifndef CONFIG_RADIO_GEMTEK_PORT 51#ifndef CONFIG_RADIO_GEMTEK_PORT
29#define CONFIG_RADIO_GEMTEK_PORT -1 52#define CONFIG_RADIO_GEMTEK_PORT -1
30#endif 53#endif
@@ -146,77 +169,122 @@ static int gemtek_do_ioctl(struct inode *inode, struct file *file,
146 169
147 switch(cmd) 170 switch(cmd)
148 { 171 {
149 case VIDIOCGCAP: 172 case VIDIOC_QUERYCAP:
150 { 173 {
151 struct video_capability *v = arg; 174 struct v4l2_capability *v = arg;
152 memset(v,0,sizeof(*v)); 175 memset(v,0,sizeof(*v));
153 v->type=VID_TYPE_TUNER; 176 strlcpy(v->driver, "radio-gemtek", sizeof (v->driver));
154 v->channels=1; 177 strlcpy(v->card, "GemTek", sizeof (v->card));
155 v->audios=1; 178 sprintf(v->bus_info,"ISA");
156 strcpy(v->name, "GemTek"); 179 v->version = RADIO_VERSION;
180 v->capabilities = V4L2_CAP_TUNER;
181
157 return 0; 182 return 0;
158 } 183 }
159 case VIDIOCGTUNER: 184 case VIDIOC_G_TUNER:
160 { 185 {
161 struct video_tuner *v = arg; 186 struct v4l2_tuner *v = arg;
162 if(v->tuner) /* Only 1 tuner */ 187
188 if (v->index > 0)
163 return -EINVAL; 189 return -EINVAL;
164 v->rangelow=87*16000; 190
165 v->rangehigh=108*16000; 191 memset(v,0,sizeof(*v));
166 v->flags=VIDEO_TUNER_LOW;
167 v->mode=VIDEO_MODE_AUTO;
168 v->signal=0xFFFF*gemtek_getsigstr(rt);
169 strcpy(v->name, "FM"); 192 strcpy(v->name, "FM");
193 v->type = V4L2_TUNER_RADIO;
194
195 v->rangelow=(87*16000);
196 v->rangehigh=(108*16000);
197 v->rxsubchans =V4L2_TUNER_SUB_MONO;
198 v->capability=V4L2_TUNER_CAP_LOW;
199 v->audmode = V4L2_TUNER_MODE_MONO;
200 v->signal=0xFFFF*gemtek_getsigstr(rt);
201
170 return 0; 202 return 0;
171 } 203 }
172 case VIDIOCSTUNER: 204 case VIDIOC_S_TUNER:
173 { 205 {
174 struct video_tuner *v = arg; 206 struct v4l2_tuner *v = arg;
175 if(v->tuner!=0) 207
208 if (v->index > 0)
176 return -EINVAL; 209 return -EINVAL;
177 /* Only 1 tuner so no setting needed ! */ 210
178 return 0;
179 }
180 case VIDIOCGFREQ:
181 {
182 unsigned long *freq = arg;
183 *freq = rt->curfreq;
184 return 0; 211 return 0;
185 } 212 }
186 case VIDIOCSFREQ: 213 case VIDIOC_S_FREQUENCY:
187 { 214 {
188 unsigned long *freq = arg; 215 struct v4l2_frequency *f = arg;
189 rt->curfreq = *freq; 216
217 rt->curfreq = f->frequency;
190 /* needs to be called twice in order for getsigstr to work */ 218 /* needs to be called twice in order for getsigstr to work */
191 gemtek_setfreq(rt, rt->curfreq); 219 gemtek_setfreq(rt, rt->curfreq);
192 gemtek_setfreq(rt, rt->curfreq); 220 gemtek_setfreq(rt, rt->curfreq);
193 return 0; 221 return 0;
194 } 222 }
195 case VIDIOCGAUDIO: 223 case VIDIOC_G_FREQUENCY:
196 {
197 struct video_audio *v = arg;
198 memset(v,0, sizeof(*v));
199 v->flags|=VIDEO_AUDIO_MUTABLE;
200 v->volume=1;
201 v->step=65535;
202 strcpy(v->name, "Radio");
203 return 0;
204 }
205 case VIDIOCSAUDIO:
206 { 224 {
207 struct video_audio *v = arg; 225 struct v4l2_frequency *f = arg;
208 if(v->audio)
209 return -EINVAL;
210 226
211 if(v->flags&VIDEO_AUDIO_MUTE) 227 f->type = V4L2_TUNER_RADIO;
212 gemtek_mute(rt); 228 f->frequency = rt->curfreq;
213 else
214 gemtek_unmute(rt);
215 229
216 return 0; 230 return 0;
217 } 231 }
232 case VIDIOC_QUERYCTRL:
233 {
234 struct v4l2_queryctrl *qc = arg;
235 int i;
236
237 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
238 if (qc->id && qc->id == radio_qctrl[i].id) {
239 memcpy(qc, &(radio_qctrl[i]),
240 sizeof(*qc));
241 return (0);
242 }
243 }
244 return -EINVAL;
245 }
246 case VIDIOC_G_CTRL:
247 {
248 struct v4l2_control *ctrl= arg;
249
250 switch (ctrl->id) {
251 case V4L2_CID_AUDIO_MUTE:
252 ctrl->value=rt->muted;
253 return (0);
254 case V4L2_CID_AUDIO_VOLUME:
255 if (rt->muted)
256 ctrl->value=0;
257 else
258 ctrl->value=65535;
259 return (0);
260 }
261 return -EINVAL;
262 }
263 case VIDIOC_S_CTRL:
264 {
265 struct v4l2_control *ctrl= arg;
266
267 switch (ctrl->id) {
268 case V4L2_CID_AUDIO_MUTE:
269 if (ctrl->value) {
270 gemtek_mute(rt);
271 } else {
272 gemtek_unmute(rt);
273 }
274 return (0);
275 case V4L2_CID_AUDIO_VOLUME:
276 if (ctrl->value) {
277 gemtek_unmute(rt);
278 } else {
279 gemtek_mute(rt);
280 }
281 return (0);
282 }
283 return -EINVAL;
284 }
218 default: 285 default:
219 return -ENOIOCTLCMD; 286 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
287 gemtek_do_ioctl);
220 } 288 }
221} 289}
222 290
@@ -242,7 +310,7 @@ static struct video_device gemtek_radio=
242 .owner = THIS_MODULE, 310 .owner = THIS_MODULE,
243 .name = "GemTek radio", 311 .name = "GemTek radio",
244 .type = VID_TYPE_TUNER, 312 .type = VID_TYPE_TUNER,
245 .hardware = VID_HARDWARE_GEMTEK, 313 .hardware = 0,
246 .fops = &gemtek_fops, 314 .fops = &gemtek_fops,
247}; 315};
248 316