This source file includes following definitions.
- rtrack_alloc
- rtrack_set_pins
- rtrack_s_frequency
- rtrack_g_signal
- rtrack_s_mute_volume
- rtrack_initialize
- rtrack_init
- rtrack_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/ioport.h>
33 #include <linux/delay.h>
34 #include <linux/videodev2.h>
35 #include <linux/io.h>
36 #include <linux/slab.h>
37 #include <media/v4l2-device.h>
38 #include <media/v4l2-ioctl.h>
39 #include <media/v4l2-ctrls.h>
40 #include "radio-isa.h"
41 #include "lm7000.h"
42
43 MODULE_AUTHOR("M. Kirkwood");
44 MODULE_DESCRIPTION("A driver for the RadioTrack/RadioReveal radio card.");
45 MODULE_LICENSE("GPL");
46 MODULE_VERSION("1.0.0");
47
48 #ifndef CONFIG_RADIO_RTRACK_PORT
49 #define CONFIG_RADIO_RTRACK_PORT -1
50 #endif
51
52 #define RTRACK_MAX 2
53
54 static int io[RTRACK_MAX] = { [0] = CONFIG_RADIO_RTRACK_PORT,
55 [1 ... (RTRACK_MAX - 1)] = -1 };
56 static int radio_nr[RTRACK_MAX] = { [0 ... (RTRACK_MAX - 1)] = -1 };
57
58 module_param_array(io, int, NULL, 0444);
59 MODULE_PARM_DESC(io, "I/O addresses of the RadioTrack card (0x20f or 0x30f)");
60 module_param_array(radio_nr, int, NULL, 0444);
61 MODULE_PARM_DESC(radio_nr, "Radio device numbers");
62
63 struct rtrack {
64 struct radio_isa_card isa;
65 int curvol;
66 };
67
68 static struct radio_isa_card *rtrack_alloc(void)
69 {
70 struct rtrack *rt = kzalloc(sizeof(struct rtrack), GFP_KERNEL);
71
72 if (rt)
73 rt->curvol = 0xff;
74 return rt ? &rt->isa : NULL;
75 }
76
77 #define AIMS_BIT_TUN_CE (1 << 0)
78 #define AIMS_BIT_TUN_CLK (1 << 1)
79 #define AIMS_BIT_TUN_DATA (1 << 2)
80 #define AIMS_BIT_VOL_CE (1 << 3)
81 #define AIMS_BIT_TUN_STRQ (1 << 4)
82
83 #define AIMS_BIT_VOL_UP (1 << 6)
84 #define AIMS_BIT_VOL_DN (1 << 7)
85
86 static void rtrack_set_pins(void *handle, u8 pins)
87 {
88 struct radio_isa_card *isa = handle;
89 struct rtrack *rt = container_of(isa, struct rtrack, isa);
90 u8 bits = AIMS_BIT_VOL_DN | AIMS_BIT_VOL_UP | AIMS_BIT_TUN_STRQ;
91
92 if (!v4l2_ctrl_g_ctrl(rt->isa.mute))
93 bits |= AIMS_BIT_VOL_CE;
94
95 if (pins & LM7000_DATA)
96 bits |= AIMS_BIT_TUN_DATA;
97 if (pins & LM7000_CLK)
98 bits |= AIMS_BIT_TUN_CLK;
99 if (pins & LM7000_CE)
100 bits |= AIMS_BIT_TUN_CE;
101
102 outb_p(bits, rt->isa.io);
103 }
104
105 static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq)
106 {
107 lm7000_set_freq(freq, isa, rtrack_set_pins);
108
109 return 0;
110 }
111
112 static u32 rtrack_g_signal(struct radio_isa_card *isa)
113 {
114
115 return 0xffff * !(inb(isa->io) & 2);
116 }
117
118 static int rtrack_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol)
119 {
120 struct rtrack *rt = container_of(isa, struct rtrack, isa);
121 int curvol = rt->curvol;
122
123 if (mute) {
124 outb(0xd0, isa->io);
125 return 0;
126 }
127 if (vol == 0) {
128 outb(0x48, isa->io);
129 msleep(curvol * 3);
130 } else if (curvol < vol) {
131 outb(0x98, isa->io);
132 for (; curvol < vol; curvol++)
133 mdelay(3);
134 } else if (curvol > vol) {
135 outb(0x58, isa->io);
136 for (; curvol > vol; curvol--)
137 mdelay(3);
138 }
139 outb(0xd8, isa->io);
140 rt->curvol = vol;
141 return 0;
142 }
143
144
145 static int rtrack_initialize(struct radio_isa_card *isa)
146 {
147
148 outb(0x90, isa->io);
149 msleep(3000);
150 outb(0xc0, isa->io);
151 return 0;
152 }
153
154 static const struct radio_isa_ops rtrack_ops = {
155 .alloc = rtrack_alloc,
156 .init = rtrack_initialize,
157 .s_mute_volume = rtrack_s_mute_volume,
158 .s_frequency = rtrack_s_frequency,
159 .g_signal = rtrack_g_signal,
160 };
161
162 static const int rtrack_ioports[] = { 0x20f, 0x30f };
163
164 static struct radio_isa_driver rtrack_driver = {
165 .driver = {
166 .match = radio_isa_match,
167 .probe = radio_isa_probe,
168 .remove = radio_isa_remove,
169 .driver = {
170 .name = "radio-aimslab",
171 },
172 },
173 .io_params = io,
174 .radio_nr_params = radio_nr,
175 .io_ports = rtrack_ioports,
176 .num_of_io_ports = ARRAY_SIZE(rtrack_ioports),
177 .region_size = 2,
178 .card = "AIMSlab RadioTrack/RadioReveal",
179 .ops = &rtrack_ops,
180 .has_stereo = true,
181 .max_volume = 0xff,
182 };
183
184 static int __init rtrack_init(void)
185 {
186 return isa_register_driver(&rtrack_driver.driver, RTRACK_MAX);
187 }
188
189 static void __exit rtrack_exit(void)
190 {
191 isa_unregister_driver(&rtrack_driver.driver);
192 }
193
194 module_init(rtrack_init);
195 module_exit(rtrack_exit);