3 * Copyright 1998 Ben Pfaff
5 * Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
6 * Converted to new API by Alan Cox <alan@lxorguk.ukuu.org.uk>
7 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
9 * Converted to the radio-isa framework by Hans Verkuil <hans.verkuil@cisco.com>
10 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
13 #include <linux/module.h> /* Modules */
14 #include <linux/init.h> /* Initdata */
15 #include <linux/ioport.h> /* request_region */
16 #include <linux/delay.h> /* udelay */
17 #include <linux/videodev2.h> /* kernel radio structs */
18 #include <linux/mutex.h>
19 #include <linux/io.h> /* outb, outb_p */
20 #include <media/v4l2-device.h>
21 #include <media/v4l2-ioctl.h>
22 #include "radio-isa.h"
24 MODULE_AUTHOR("Ben Pfaff");
25 MODULE_DESCRIPTION("A driver for the RadioTrack II radio card.");
26 MODULE_LICENSE("GPL");
27 MODULE_VERSION("0.1.99");
29 #ifndef CONFIG_RADIO_RTRACK2_PORT
30 #define CONFIG_RADIO_RTRACK2_PORT -1
35 static int io
[RTRACK2_MAX
] = { [0] = CONFIG_RADIO_RTRACK2_PORT
,
36 [1 ... (RTRACK2_MAX
- 1)] = -1 };
37 static int radio_nr
[RTRACK2_MAX
] = { [0 ... (RTRACK2_MAX
- 1)] = -1 };
39 module_param_array(io
, int, NULL
, 0444);
40 MODULE_PARM_DESC(io
, "I/O addresses of the RadioTrack card (0x20f or 0x30f)");
41 module_param_array(radio_nr
, int, NULL
, 0444);
42 MODULE_PARM_DESC(radio_nr
, "Radio device numbers");
44 static struct radio_isa_card
*rtrack2_alloc(void)
46 return kzalloc(sizeof(struct radio_isa_card
), GFP_KERNEL
);
49 static void zero(struct radio_isa_card
*isa
)
56 static void one(struct radio_isa_card
*isa
)
63 static int rtrack2_s_frequency(struct radio_isa_card
*isa
, u32 freq
)
67 freq
= freq
/ 200 + 856;
69 outb_p(0xc8, isa
->io
);
70 outb_p(0xc9, isa
->io
);
71 outb_p(0xc9, isa
->io
);
73 for (i
= 0; i
< 10; i
++)
76 for (i
= 14; i
>= 0; i
--)
82 outb_p(0xc8, isa
->io
);
83 if (!v4l2_ctrl_g_ctrl(isa
->mute
))
88 static u32
rtrack2_g_signal(struct radio_isa_card
*isa
)
90 /* bit set = no signal present */
91 return (inb(isa
->io
) & 2) ? 0 : 0xffff;
94 static int rtrack2_s_mute_volume(struct radio_isa_card
*isa
, bool mute
, int vol
)
100 static const struct radio_isa_ops rtrack2_ops
= {
101 .alloc
= rtrack2_alloc
,
102 .s_mute_volume
= rtrack2_s_mute_volume
,
103 .s_frequency
= rtrack2_s_frequency
,
104 .g_signal
= rtrack2_g_signal
,
107 static const int rtrack2_ioports
[] = { 0x20f, 0x30f };
109 static struct radio_isa_driver rtrack2_driver
= {
111 .match
= radio_isa_match
,
112 .probe
= radio_isa_probe
,
113 .remove
= radio_isa_remove
,
115 .name
= "radio-rtrack2",
119 .radio_nr_params
= radio_nr
,
120 .io_ports
= rtrack2_ioports
,
121 .num_of_io_ports
= ARRAY_SIZE(rtrack2_ioports
),
123 .card
= "AIMSlab RadioTrack II",
128 static int __init
rtrack2_init(void)
130 return isa_register_driver(&rtrack2_driver
.driver
, RTRACK2_MAX
);
133 static void __exit
rtrack2_exit(void)
135 isa_unregister_driver(&rtrack2_driver
.driver
);
138 module_init(rtrack2_init
);
139 module_exit(rtrack2_exit
);