aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-rtrack2.c
diff options
context:
space:
mode:
authorDouglas Landgraf <dougsland@gmail.com>2007-04-19 15:42:25 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:45:42 -0400
commit25f30389dd84dcaf54d7d76fdd84e85bec206db6 (patch)
tree6b30937407da3ae4a3a1f34a341c474f129a1fc2 /drivers/media/radio/radio-rtrack2.c
parent941491f3a52c34506137060716ce73e642ee326e (diff)
V4L/DVB (5534): Radio-rtrack2.c Replace rt_ioctl to use video_ioctl2
Convert radio-rtrack2 to use video_ioctl2 Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> 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.c221
1 files changed, 109 insertions, 112 deletions
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index f6683872251e..4239a7f3f7e5 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -122,6 +122,26 @@ static int rt_setfreq(struct rt_device *dev, unsigned long freq)
122 return 0; 122 return 0;
123} 123}
124 124
125static int vidioc_querycap(struct file *file, void *priv,
126 struct v4l2_capability *v)
127{
128 strlcpy(v->driver, "radio-rtrack2", sizeof(v->driver));
129 strlcpy(v->card, "RadioTrack II", sizeof(v->card));
130 sprintf(v->bus_info, "ISA");
131 v->version = RADIO_VERSION;
132 v->capabilities = V4L2_CAP_TUNER;
133 return 0;
134}
135
136static int vidioc_s_tuner(struct file *file, void *priv,
137 struct v4l2_tuner *v)
138{
139 if (v->index > 0)
140 return -EINVAL;
141
142 return 0;
143}
144
125static int rt_getsigstr(struct rt_device *dev) 145static int rt_getsigstr(struct rt_device *dev)
126{ 146{
127 if (inb(io) & 2) /* bit set = no signal present */ 147 if (inb(io) & 2) /* bit set = no signal present */
@@ -129,135 +149,104 @@ static int rt_getsigstr(struct rt_device *dev)
129 return 1; /* signal present */ 149 return 1; /* signal present */
130} 150}
131 151
132static int rt_do_ioctl(struct inode *inode, struct file *file, 152static int vidioc_g_tuner(struct file *file, void *priv,
133 unsigned int cmd, void *arg) 153 struct v4l2_tuner *v)
134{ 154{
135 struct video_device *dev = video_devdata(file); 155 struct video_device *dev = video_devdata(file);
136 struct rt_device *rt=dev->priv; 156 struct rt_device *rt = dev->priv;
137 157
138 switch(cmd) 158 if (v->index > 0)
139 { 159 return -EINVAL;
140 case VIDIOC_QUERYCAP:
141 {
142 struct v4l2_capability *v = arg;
143 memset(v,0,sizeof(*v));
144 strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
145 strlcpy(v->card, "RadioTrack II", sizeof (v->card));
146 sprintf(v->bus_info,"ISA");
147 v->version = RADIO_VERSION;
148 v->capabilities = V4L2_CAP_TUNER;
149
150 return 0;
151 }
152 case VIDIOC_G_TUNER:
153 {
154 struct v4l2_tuner *v = arg;
155 160
156 if (v->index > 0) 161 strcpy(v->name, "FM");
157 return -EINVAL; 162 v->type = V4L2_TUNER_RADIO;
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 return 0;
170}
158 171
159 memset(v,0,sizeof(*v)); 172static int vidioc_s_frequency(struct file *file, void *priv,
160 strcpy(v->name, "FM"); 173 struct v4l2_frequency *f)
161 v->type = V4L2_TUNER_RADIO; 174{
175 struct video_device *dev = video_devdata(file);
176 struct rt_device *rt = dev->priv;
162 177
163 v->rangelow=(88*16000); 178 rt->curfreq = f->frequency;
164 v->rangehigh=(108*16000); 179 rt_setfreq(rt, rt->curfreq);
165 v->rxsubchans =V4L2_TUNER_SUB_MONO; 180 return 0;
166 v->capability=V4L2_TUNER_CAP_LOW; 181}
167 v->audmode = V4L2_TUNER_MODE_MONO;
168 v->signal=0xFFFF*rt_getsigstr(rt);
169 182
170 return 0; 183static int vidioc_g_frequency(struct file *file, void *priv,
171 } 184 struct v4l2_frequency *f)
172 case VIDIOC_S_TUNER: 185{
173 { 186 struct video_device *dev = video_devdata(file);
174 struct v4l2_tuner *v = arg; 187 struct rt_device *rt = dev->priv;
175 188
176 if (v->index > 0) 189 f->type = V4L2_TUNER_RADIO;
177 return -EINVAL; 190 f->frequency = rt->curfreq;
191 return 0;
192}
178 193
179 return 0; 194static int vidioc_queryctrl(struct file *file, void *priv,
180 } 195 struct v4l2_queryctrl *qc)
181 case VIDIOC_S_FREQUENCY: 196{
182 { 197 int i;
183 struct v4l2_frequency *f = arg;
184 198
185 rt->curfreq = f->frequency; 199 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
186 rt_setfreq(rt, rt->curfreq); 200 if (qc->id && qc->id == radio_qctrl[i].id) {
201 memcpy(qc, &(radio_qctrl[i]),
202 sizeof(*qc));
187 return 0; 203 return 0;
188 } 204 }
189 case VIDIOC_G_FREQUENCY: 205 }
190 { 206 return -EINVAL;
191 struct v4l2_frequency *f = arg; 207}
192 208
193 f->type = V4L2_TUNER_RADIO; 209static int vidioc_g_ctrl(struct file *file, void *priv,
194 f->frequency = rt->curfreq; 210 struct v4l2_control *ctrl)
211{
212 struct video_device *dev = video_devdata(file);
213 struct rt_device *rt = dev->priv;
195 214
196 return 0; 215 switch (ctrl->id) {
197 } 216 case V4L2_CID_AUDIO_MUTE:
198 case VIDIOC_QUERYCTRL: 217 ctrl->value = rt->muted;
199 { 218 return 0;
200 struct v4l2_queryctrl *qc = arg; 219 case V4L2_CID_AUDIO_VOLUME:
201 int i; 220 if (rt->muted)
202 221 ctrl->value = 0;
203 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 222 else
204 if (qc->id && qc->id == radio_qctrl[i].id) { 223 ctrl->value = 65535;
205 memcpy(qc, &(radio_qctrl[i]), 224 return 0;
206 sizeof(*qc));
207 return (0);
208 }
209 }
210 return -EINVAL;
211 }
212 case VIDIOC_G_CTRL:
213 {
214 struct v4l2_control *ctrl= arg;
215
216 switch (ctrl->id) {
217 case V4L2_CID_AUDIO_MUTE:
218 ctrl->value=rt->muted;
219 return (0);
220 case V4L2_CID_AUDIO_VOLUME:
221 if (rt->muted)
222 ctrl->value=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;
250 }
251 default:
252 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
253 rt_do_ioctl);
254 } 225 }
226 return -EINVAL;
255} 227}
256 228
257static int rt_ioctl(struct inode *inode, struct file *file, 229static int vidioc_s_ctrl(struct file *file, void *priv,
258 unsigned int cmd, unsigned long arg) 230 struct v4l2_control *ctrl)
259{ 231{
260 return video_usercopy(inode, file, cmd, arg, rt_do_ioctl); 232 struct video_device *dev = video_devdata(file);
233 struct rt_device *rt = dev->priv;
234
235 switch (ctrl->id) {
236 case V4L2_CID_AUDIO_MUTE:
237 if (ctrl->value)
238 rt_mute(rt);
239 else
240 rt_unmute(rt);
241 return 0;
242 case V4L2_CID_AUDIO_VOLUME:
243 if (ctrl->value)
244 rt_unmute(rt);
245 else
246 rt_mute(rt);
247 return 0;
248 }
249 return -EINVAL;
261} 250}
262 251
263static struct rt_device rtrack2_unit; 252static struct rt_device rtrack2_unit;
@@ -266,7 +255,7 @@ static const struct file_operations rtrack2_fops = {
266 .owner = THIS_MODULE, 255 .owner = THIS_MODULE,
267 .open = video_exclusive_open, 256 .open = video_exclusive_open,
268 .release = video_exclusive_release, 257 .release = video_exclusive_release,
269 .ioctl = rt_ioctl, 258 .ioctl = video_ioctl2,
270 .compat_ioctl = v4l_compat_ioctl32, 259 .compat_ioctl = v4l_compat_ioctl32,
271 .llseek = no_llseek, 260 .llseek = no_llseek,
272}; 261};
@@ -278,6 +267,14 @@ static struct video_device rtrack2_radio=
278 .type = VID_TYPE_TUNER, 267 .type = VID_TYPE_TUNER,
279 .hardware = 0, 268 .hardware = 0,
280 .fops = &rtrack2_fops, 269 .fops = &rtrack2_fops,
270 .vidioc_querycap = vidioc_querycap,
271 .vidioc_g_tuner = vidioc_g_tuner,
272 .vidioc_s_tuner = vidioc_s_tuner,
273 .vidioc_g_frequency = vidioc_g_frequency,
274 .vidioc_s_frequency = vidioc_s_frequency,
275 .vidioc_queryctrl = vidioc_queryctrl,
276 .vidioc_g_ctrl = vidioc_g_ctrl,
277 .vidioc_s_ctrl = vidioc_s_ctrl,
281}; 278};
282 279
283static int __init rtrack2_init(void) 280static int __init rtrack2_init(void)