aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-rtrack2.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-30 23:45:41 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-30 23:45:41 -0400
commit1c7da74c4aab595a994beb5fe728ebf0d0b41f59 (patch)
tree64128abdf9550ebb51d8f3ee6732d7350b9c62f2 /drivers/media/radio/radio-rtrack2.c
parentaebb1153ac54ddbbd3d3f0481a193f4bf0ead53b (diff)
parent1bdfd554be94def718323659173517c5d4a69d25 (diff)
Merge branch 'master' into upstream
Diffstat (limited to 'drivers/media/radio/radio-rtrack2.c')
-rw-r--r--drivers/media/radio/radio-rtrack2.c163
1 files changed, 115 insertions, 48 deletions
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 5b68ac4c7322..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,11 +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/config.h> /* CONFIG_RADIO_RTRACK2_PORT */
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21 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
22#ifndef CONFIG_RADIO_RTRACK2_PORT 44#ifndef CONFIG_RADIO_RTRACK2_PORT
23#define CONFIG_RADIO_RTRACK2_PORT -1 45#define CONFIG_RADIO_RTRACK2_PORT -1
24#endif 46#endif
@@ -115,75 +137,120 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
115 137
116 switch(cmd) 138 switch(cmd)
117 { 139 {
118 case VIDIOCGCAP: 140 case VIDIOC_QUERYCAP:
119 { 141 {
120 struct video_capability *v = arg; 142 struct v4l2_capability *v = arg;
121 memset(v,0,sizeof(*v)); 143 memset(v,0,sizeof(*v));
122 v->type=VID_TYPE_TUNER; 144 strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
123 v->channels=1; 145 strlcpy(v->card, "RadioTrack II", sizeof (v->card));
124 v->audios=1; 146 sprintf(v->bus_info,"ISA");
125 strcpy(v->name, "RadioTrack II"); 147 v->version = RADIO_VERSION;
148 v->capabilities = V4L2_CAP_TUNER;
149
126 return 0; 150 return 0;
127 } 151 }
128 case VIDIOCGTUNER: 152 case VIDIOC_G_TUNER:
129 { 153 {
130 struct video_tuner *v = arg; 154 struct v4l2_tuner *v = arg;
131 if(v->tuner) /* Only 1 tuner */ 155
156 if (v->index > 0)
132 return -EINVAL; 157 return -EINVAL;
133 v->rangelow=88*16000; 158
134 v->rangehigh=108*16000; 159 memset(v,0,sizeof(*v));
135 v->flags=VIDEO_TUNER_LOW;
136 v->mode=VIDEO_MODE_AUTO;
137 v->signal=0xFFFF*rt_getsigstr(rt);
138 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
139 return 0; 170 return 0;
140 } 171 }
141 case VIDIOCSTUNER: 172 case VIDIOC_S_TUNER:
142 { 173 {
143 struct video_tuner *v = arg; 174 struct v4l2_tuner *v = arg;
144 if(v->tuner!=0) 175
176 if (v->index > 0)
145 return -EINVAL; 177 return -EINVAL;
146 /* Only 1 tuner so no setting needed ! */ 178
147 return 0; 179 return 0;
148 } 180 }
149 case VIDIOCGFREQ: 181 case VIDIOC_S_FREQUENCY:
150 { 182 {
151 unsigned long *freq = arg; 183 struct v4l2_frequency *f = arg;
152 *freq = rt->curfreq; 184
185 rt->curfreq = f->frequency;
186 rt_setfreq(rt, rt->curfreq);
153 return 0; 187 return 0;
154 } 188 }
155 case VIDIOCSFREQ: 189 case VIDIOC_G_FREQUENCY:
156 { 190 {
157 unsigned long *freq = arg; 191 struct v4l2_frequency *f = arg;
158 rt->curfreq = *freq; 192
159 rt_setfreq(rt, rt->curfreq); 193 f->type = V4L2_TUNER_RADIO;
194 f->frequency = rt->curfreq;
195
160 return 0; 196 return 0;
161 } 197 }
162 case VIDIOCGAUDIO: 198 case VIDIOC_QUERYCTRL:
163 { 199 {
164 struct video_audio *v = arg; 200 struct v4l2_queryctrl *qc = arg;
165 memset(v,0, sizeof(*v)); 201 int i;
166 v->flags|=VIDEO_AUDIO_MUTABLE; 202
167 v->volume=1; 203 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
168 v->step=65535; 204 if (qc->id && qc->id == radio_qctrl[i].id) {
169 strcpy(v->name, "Radio"); 205 memcpy(qc, &(radio_qctrl[i]),
170 return 0; 206 sizeof(*qc));
207 return (0);
208 }
209 }
210 return -EINVAL;
171 } 211 }
172 case VIDIOCSAUDIO: 212 case VIDIOC_G_CTRL:
173 { 213 {
174 struct video_audio *v = arg; 214 struct v4l2_control *ctrl= arg;
175 if(v->audio) 215
176 return -EINVAL; 216 switch (ctrl->id) {
177 217 case V4L2_CID_AUDIO_MUTE:
178 if(v->flags&VIDEO_AUDIO_MUTE) 218 ctrl->value=rt->muted;
179 rt_mute(rt); 219 return (0);
180 else 220 case V4L2_CID_AUDIO_VOLUME:
181 rt_unmute(rt); 221 if (rt->muted)
182 222 ctrl->value=0;
183 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;
184 } 250 }
185 default: 251 default:
186 return -ENOIOCTLCMD; 252 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
253 rt_do_ioctl);
187 } 254 }
188} 255}
189 256
@@ -209,7 +276,7 @@ static struct video_device rtrack2_radio=
209 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
210 .name = "RadioTrack II radio", 277 .name = "RadioTrack II radio",
211 .type = VID_TYPE_TUNER, 278 .type = VID_TYPE_TUNER,
212 .hardware = VID_HARDWARE_RTRACK2, 279 .hardware = 0,
213 .fops = &rtrack2_fops, 280 .fops = &rtrack2_fops,
214}; 281};
215 282