aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-rtrack2.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-08-08 08:10:02 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:12 -0400
commitf8c559f8c066a045fb3f70bbb35f9e7c2064b8ae (patch)
tree5fc41061bb9d84964b5107d7a65f11b32f0cb90a /drivers/media/radio/radio-rtrack2.c
parentb6055d7b1841e14ecc8c72a11490b42c85bf7bec (diff)
V4L/DVB (4352): V4L2 conversion: radio-rtrack2
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-rtrack2.c')
-rw-r--r--drivers/media/radio/radio-rtrack2.c162
1 files changed, 115 insertions, 47 deletions
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index e5e9d41e4bd0..b9e98483e58d 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -6,6 +6,7 @@
6 * 6 *
7 * TODO: Allow for more than one of these foolish entities :-) 7 * TODO: Allow for more than one of these foolish entities :-)
8 * 8 *
9 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
9 */ 10 */
10 11
11#include <linux/module.h> /* Modules */ 12#include <linux/module.h> /* Modules */
@@ -14,10 +15,32 @@
14#include <linux/delay.h> /* udelay */ 15#include <linux/delay.h> /* udelay */
15#include <asm/io.h> /* outb, outb_p */ 16#include <asm/io.h> /* outb, outb_p */
16#include <asm/uaccess.h> /* copy to/from user */ 17#include <asm/uaccess.h> /* copy to/from user */
17#include <linux/videodev.h> /* kernel radio structs */ 18#include <linux/videodev2.h> /* kernel radio structs */
18#include <media/v4l2-common.h> 19#include <media/v4l2-common.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20 21
22#include <linux/version.h> /* for KERNEL_VERSION MACRO */
23#define RADIO_VERSION KERNEL_VERSION(0,0,2)
24
25static struct v4l2_queryctrl radio_qctrl[] = {
26 {
27 .id = V4L2_CID_AUDIO_MUTE,
28 .name = "Mute",
29 .minimum = 0,
30 .maximum = 1,
31 .default_value = 1,
32 .type = V4L2_CTRL_TYPE_BOOLEAN,
33 },{
34 .id = V4L2_CID_AUDIO_VOLUME,
35 .name = "Volume",
36 .minimum = 0,
37 .maximum = 65535,
38 .step = 65535,
39 .default_value = 0xff,
40 .type = V4L2_CTRL_TYPE_INTEGER,
41 }
42};
43
21#ifndef CONFIG_RADIO_RTRACK2_PORT 44#ifndef CONFIG_RADIO_RTRACK2_PORT
22#define CONFIG_RADIO_RTRACK2_PORT -1 45#define CONFIG_RADIO_RTRACK2_PORT -1
23#endif 46#endif
@@ -114,75 +137,120 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
114 137
115 switch(cmd) 138 switch(cmd)
116 { 139 {
117 case VIDIOCGCAP: 140 case VIDIOC_QUERYCAP:
118 { 141 {
119 struct video_capability *v = arg; 142 struct v4l2_capability *v = arg;
120 memset(v,0,sizeof(*v)); 143 memset(v,0,sizeof(*v));
121 v->type=VID_TYPE_TUNER; 144 strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
122 v->channels=1; 145 strlcpy(v->card, "RadioTrack II", sizeof (v->card));
123 v->audios=1; 146 sprintf(v->bus_info,"ISA");
124 strcpy(v->name, "RadioTrack II"); 147 v->version = RADIO_VERSION;
148 v->capabilities = V4L2_CAP_TUNER;
149
125 return 0; 150 return 0;
126 } 151 }
127 case VIDIOCGTUNER: 152 case VIDIOC_G_TUNER:
128 { 153 {
129 struct video_tuner *v = arg; 154 struct v4l2_tuner *v = arg;
130 if(v->tuner) /* Only 1 tuner */ 155
156 if (v->index > 0)
131 return -EINVAL; 157 return -EINVAL;
132 v->rangelow=88*16000; 158
133 v->rangehigh=108*16000; 159 memset(v,0,sizeof(*v));
134 v->flags=VIDEO_TUNER_LOW;
135 v->mode=VIDEO_MODE_AUTO;
136 v->signal=0xFFFF*rt_getsigstr(rt);
137 strcpy(v->name, "FM"); 160 strcpy(v->name, "FM");
161 v->type = V4L2_TUNER_RADIO;
162
163 v->rangelow=(88*16000);
164 v->rangehigh=(108*16000);
165 v->rxsubchans =V4L2_TUNER_SUB_MONO;
166 v->capability=V4L2_TUNER_CAP_LOW;
167 v->audmode = V4L2_TUNER_MODE_MONO;
168 v->signal=0xFFFF*rt_getsigstr(rt);
169
138 return 0; 170 return 0;
139 } 171 }
140 case VIDIOCSTUNER: 172 case VIDIOC_S_TUNER:
141 { 173 {
142 struct video_tuner *v = arg; 174 struct v4l2_tuner *v = arg;
143 if(v->tuner!=0) 175
176 if (v->index > 0)
144 return -EINVAL; 177 return -EINVAL;
145 /* Only 1 tuner so no setting needed ! */ 178
146 return 0; 179 return 0;
147 } 180 }
148 case VIDIOCGFREQ: 181 case VIDIOC_S_FREQUENCY:
149 { 182 {
150 unsigned long *freq = arg; 183 struct v4l2_frequency *f = arg;
151 *freq = rt->curfreq; 184
185 rt->curfreq = f->frequency;
186 rt_setfreq(rt, rt->curfreq);
152 return 0; 187 return 0;
153 } 188 }
154 case VIDIOCSFREQ: 189 case VIDIOC_G_FREQUENCY:
155 { 190 {
156 unsigned long *freq = arg; 191 struct v4l2_frequency *f = arg;
157 rt->curfreq = *freq; 192
158 rt_setfreq(rt, rt->curfreq); 193 f->type = V4L2_TUNER_RADIO;
194 f->frequency = rt->curfreq;
195
159 return 0; 196 return 0;
160 } 197 }
161 case VIDIOCGAUDIO: 198 case VIDIOC_QUERYCTRL:
162 { 199 {
163 struct video_audio *v = arg; 200 struct v4l2_queryctrl *qc = arg;
164 memset(v,0, sizeof(*v)); 201 int i;
165 v->flags|=VIDEO_AUDIO_MUTABLE; 202
166 v->volume=1; 203 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
167 v->step=65535; 204 if (qc->id && qc->id == radio_qctrl[i].id) {
168 strcpy(v->name, "Radio"); 205 memcpy(qc, &(radio_qctrl[i]),
169 return 0; 206 sizeof(*qc));
207 return (0);
208 }
209 }
210 return -EINVAL;
170 } 211 }
171 case VIDIOCSAUDIO: 212 case VIDIOC_G_CTRL:
172 { 213 {
173 struct video_audio *v = arg; 214 struct v4l2_control *ctrl= arg;
174 if(v->audio) 215
175 return -EINVAL; 216 switch (ctrl->id) {
176 217 case V4L2_CID_AUDIO_MUTE:
177 if(v->flags&VIDEO_AUDIO_MUTE) 218 ctrl->value=rt->muted;
178 rt_mute(rt); 219 return (0);
179 else 220 case V4L2_CID_AUDIO_VOLUME:
180 rt_unmute(rt); 221 if (rt->muted)
181 222 ctrl->value=0;
182 return 0; 223 else
224 ctrl->value=65535;
225 return (0);
226 }
227 return -EINVAL;
228 }
229 case VIDIOC_S_CTRL:
230 {
231 struct v4l2_control *ctrl= arg;
232
233 switch (ctrl->id) {
234 case V4L2_CID_AUDIO_MUTE:
235 if (ctrl->value) {
236 rt_mute(rt);
237 } else {
238 rt_unmute(rt);
239 }
240 return (0);
241 case V4L2_CID_AUDIO_VOLUME:
242 if (ctrl->value) {
243 rt_unmute(rt);
244 } else {
245 rt_mute(rt);
246 }
247 return (0);
248 }
249 return -EINVAL;
183 } 250 }
184 default: 251 default:
185 return -ENOIOCTLCMD; 252 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
253 rt_do_ioctl);
186 } 254 }
187} 255}
188 256
@@ -208,7 +276,7 @@ static struct video_device rtrack2_radio=
208 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
209 .name = "RadioTrack II radio", 277 .name = "RadioTrack II radio",
210 .type = VID_TYPE_TUNER, 278 .type = VID_TYPE_TUNER,
211 .hardware = VID_HARDWARE_RTRACK2, 279 .hardware = 0,
212 .fops = &rtrack2_fops, 280 .fops = &rtrack2_fops,
213}; 281};
214 282