aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-maxiradio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-maxiradio.c')
-rw-r--r--drivers/media/radio/radio-maxiradio.c242
1 files changed, 121 insertions, 121 deletions
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 6beeb74004b1..2fc866086d13 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -27,7 +27,9 @@
27 * BUGS: 27 * BUGS:
28 * - card unmutes if you change frequency 28 * - card unmutes if you change frequency
29 * 29 *
30 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> 30 * (c) 2006, 2007 by Mauro Carvalho Chehab <mchehab@infradead.org>:
31 * - Conversion to V4L2 API
32 * - Uses video_ioctl2 for parsing and to add debug support
31 */ 33 */
32 34
33 35
@@ -87,24 +89,14 @@ module_param(radio_nr, int, 0);
87#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) 89#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)
88 90
89 91
90static int radio_ioctl(struct inode *inode, struct file *file,
91 unsigned int cmd, unsigned long arg);
92
93static const struct file_operations maxiradio_fops = { 92static const struct file_operations maxiradio_fops = {
94 .owner = THIS_MODULE, 93 .owner = THIS_MODULE,
95 .open = video_exclusive_open, 94 .open = video_exclusive_open,
96 .release = video_exclusive_release, 95 .release = video_exclusive_release,
97 .ioctl = radio_ioctl, 96 .ioctl = video_ioctl2,
98 .compat_ioctl = v4l_compat_ioctl32, 97 .compat_ioctl = v4l_compat_ioctl32,
99 .llseek = no_llseek, 98 .llseek = no_llseek,
100}; 99};
101static struct video_device maxiradio_radio =
102{
103 .owner = THIS_MODULE,
104 .name = "Maxi Radio FM2000 radio",
105 .type = VID_TYPE_TUNER,
106 .fops = &maxiradio_fops,
107};
108 100
109static struct radio_device 101static struct radio_device
110{ 102{
@@ -181,143 +173,144 @@ static int get_tune(__u16 io)
181} 173}
182 174
183 175
184static inline int radio_function(struct inode *inode, struct file *file, 176static int vidioc_querycap (struct file *file, void *priv,
185 unsigned int cmd, void *arg) 177 struct v4l2_capability *v)
178{
179 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
180 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
181 sprintf(v->bus_info,"ISA");
182 v->version = RADIO_VERSION;
183 v->capabilities = V4L2_CAP_TUNER;
184
185 return 0;
186}
187
188static int vidioc_g_tuner (struct file *file, void *priv,
189 struct v4l2_tuner *v)
186{ 190{
187 struct video_device *dev = video_devdata(file); 191 struct video_device *dev = video_devdata(file);
188 struct radio_device *card=dev->priv; 192 struct radio_device *card=dev->priv;
189 193
190 switch(cmd) { 194 if (v->index > 0)
191 case VIDIOC_QUERYCAP: 195 return -EINVAL;
192 {
193 struct v4l2_capability *v = arg;
194 memset(v,0,sizeof(*v));
195 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
196 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
197 sprintf(v->bus_info,"ISA");
198 v->version = RADIO_VERSION;
199 v->capabilities = V4L2_CAP_TUNER;
200 196
201 return 0; 197 memset(v,0,sizeof(*v));
202 } 198 strcpy(v->name, "FM");
203 case VIDIOC_G_TUNER: 199 v->type = V4L2_TUNER_RADIO;
204 {
205 struct v4l2_tuner *v = arg;
206 200
207 if (v->index > 0) 201 v->rangelow=FREQ_LO;
208 return -EINVAL; 202 v->rangehigh=FREQ_HI;
203 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
204 v->capability=V4L2_TUNER_CAP_LOW;
205 if(get_stereo(card->io))
206 v->audmode = V4L2_TUNER_MODE_STEREO;
207 else
208 v->audmode = V4L2_TUNER_MODE_MONO;
209 v->signal=0xffff*get_tune(card->io);
209 210
210 memset(v,0,sizeof(*v)); 211 return 0;
211 strcpy(v->name, "FM"); 212}
212 v->type = V4L2_TUNER_RADIO;
213 213
214 v->rangelow=FREQ_LO; 214static int vidioc_s_tuner (struct file *file, void *priv,
215 v->rangehigh=FREQ_HI; 215 struct v4l2_tuner *v)
216 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; 216{
217 v->capability=V4L2_TUNER_CAP_LOW; 217 if (v->index > 0)
218 if(get_stereo(card->io)) 218 return -EINVAL;
219 v->audmode = V4L2_TUNER_MODE_STEREO;
220 else
221 v->audmode = V4L2_TUNER_MODE_MONO;
222 v->signal=0xffff*get_tune(card->io);
223 219
224 return 0; 220 return 0;
225 } 221}
226 case VIDIOC_S_TUNER:
227 {
228 struct v4l2_tuner *v = arg;
229 222
230 if (v->index > 0) 223static int vidioc_s_frequency (struct file *file, void *priv,
231 return -EINVAL; 224 struct v4l2_frequency *f)
225{
226 struct video_device *dev = video_devdata(file);
227 struct radio_device *card=dev->priv;
232 228
233 return 0; 229 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
234 } 230 return -EINVAL;
235 case VIDIOC_S_FREQUENCY:
236 {
237 struct v4l2_frequency *f = arg;
238 231
239 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) 232 card->freq = f->frequency;
240 return -EINVAL; 233 set_freq(card->io, FREQ2BITS(card->freq));
234 msleep(125);
241 235
242 card->freq = f->frequency; 236 return 0;
243 set_freq(card->io, FREQ2BITS(card->freq)); 237}
244 msleep(125);
245 return 0;
246 }
247 case VIDIOC_G_FREQUENCY:
248 {
249 struct v4l2_frequency *f = arg;
250 238
251 f->type = V4L2_TUNER_RADIO; 239static int vidioc_g_frequency (struct file *file, void *priv,
252 f->frequency = card->freq; 240 struct v4l2_frequency *f)
241{
242 struct video_device *dev = video_devdata(file);
243 struct radio_device *card=dev->priv;
253 244
254 return 0; 245 f->type = V4L2_TUNER_RADIO;
255 } 246 f->frequency = card->freq;
256 case VIDIOC_QUERYCTRL: 247
257 { 248 return 0;
258 struct v4l2_queryctrl *qc = arg; 249}
259 int i; 250
260 251static int vidioc_queryctrl (struct file *file, void *priv,
261 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 252 struct v4l2_queryctrl *qc)
262 if (qc->id && qc->id == radio_qctrl[i].id) { 253{
263 memcpy(qc, &(radio_qctrl[i]), 254 int i;
264 sizeof(*qc)); 255
265 return (0); 256 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
266 } 257 if (qc->id && qc->id == radio_qctrl[i].id) {
267 } 258 memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
268 return -EINVAL; 259 return (0);
269 }
270 case VIDIOC_G_CTRL:
271 {
272 struct v4l2_control *ctrl= arg;
273
274 switch (ctrl->id) {
275 case V4L2_CID_AUDIO_MUTE:
276 ctrl->value=card->muted;
277 return (0);
278 }
279 return -EINVAL;
280 }
281 case VIDIOC_S_CTRL:
282 {
283 struct v4l2_control *ctrl= arg;
284
285 switch (ctrl->id) {
286 case V4L2_CID_AUDIO_MUTE:
287 card->muted = ctrl->value;
288 if(card->muted)
289 turn_power(card->io, 0);
290 else
291 set_freq(card->io, FREQ2BITS(card->freq));
292 return 0;
293 }
294 return -EINVAL;
295 } 260 }
261 }
262 return -EINVAL;
263}
296 264
297 default: 265static int vidioc_g_ctrl (struct file *file, void *priv,
298 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 266 struct v4l2_control *ctrl)
299 radio_function); 267{
268 struct video_device *dev = video_devdata(file);
269 struct radio_device *card=dev->priv;
300 270
271 switch (ctrl->id) {
272 case V4L2_CID_AUDIO_MUTE:
273 ctrl->value=card->muted;
274 return (0);
301 } 275 }
276 return -EINVAL;
302} 277}
303 278
304static int radio_ioctl(struct inode *inode, struct file *file, 279static int vidioc_s_ctrl (struct file *file, void *priv,
305 unsigned int cmd, unsigned long arg) 280 struct v4l2_control *ctrl)
306{ 281{
307 struct video_device *dev = video_devdata(file); 282 struct video_device *dev = video_devdata(file);
308 struct radio_device *card=dev->priv; 283 struct radio_device *card=dev->priv;
309 int ret;
310 284
311 mutex_lock(&card->lock); 285 switch (ctrl->id) {
312 ret = video_usercopy(inode, file, cmd, arg, radio_function); 286 case V4L2_CID_AUDIO_MUTE:
313 mutex_unlock(&card->lock); 287 card->muted = ctrl->value;
314 return ret; 288 if(card->muted)
289 turn_power(card->io, 0);
290 else
291 set_freq(card->io, FREQ2BITS(card->freq));
292 return 0;
293 }
294 return -EINVAL;
315} 295}
316 296
317MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net"); 297static struct video_device maxiradio_radio =
318MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio."); 298{
319MODULE_LICENSE("GPL"); 299 .owner = THIS_MODULE,
300 .name = "Maxi Radio FM2000 radio",
301 .type = VID_TYPE_TUNER,
302 .fops = &maxiradio_fops,
303
304 .vidioc_querycap = vidioc_querycap,
305 .vidioc_g_tuner = vidioc_g_tuner,
306 .vidioc_s_tuner = vidioc_s_tuner,
307 .vidioc_g_frequency = vidioc_g_frequency,
308 .vidioc_s_frequency = vidioc_s_frequency,
309 .vidioc_queryctrl = vidioc_queryctrl,
310 .vidioc_g_ctrl = vidioc_g_ctrl,
311 .vidioc_s_ctrl = vidioc_s_ctrl,
320 312
313};
321 314
322static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 315static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
323{ 316{
@@ -389,3 +382,10 @@ static void __exit maxiradio_radio_exit(void)
389 382
390module_init(maxiradio_radio_init); 383module_init(maxiradio_radio_init);
391module_exit(maxiradio_radio_exit); 384module_exit(maxiradio_radio_exit);
385
386MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
387MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
388MODULE_LICENSE("GPL");
389
390module_param_named(debug,maxiradio_radio.debug, int, 0644);
391MODULE_PARM_DESC(debug,"activates debug info");