Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* Terratec ActiveRadio ISA Standalone card driver for Linux radio support |
| 2 | * (c) 1999 R. Offermanns (rolf@offermanns.de) |
| 3 | * based on the aimslab radio driver from M. Kirkwood |
| 4 | * many thanks to Michael Becker and Friedhelm Birth (from TerraTec) |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * History: |
| 8 | * 1999-05-21 First preview release |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 9 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * Notes on the hardware: |
| 11 | * There are two "main" chips on the card: |
| 12 | * - Philips OM5610 (http://www-us.semiconductors.philips.com/acrobat/datasheets/OM5610_2.pdf) |
| 13 | * - Philips SAA6588 (http://www-us.semiconductors.philips.com/acrobat/datasheets/SAA6588_1.pdf) |
| 14 | * (you can get the datasheet at the above links) |
| 15 | * |
| 16 | * Frequency control is done digitally -- ie out(port,encodefreq(95.8)); |
| 17 | * Volume Control is done digitally |
| 18 | * |
| 19 | * there is a I2C controlled RDS decoder (SAA6588) onboard, which i would like to support someday |
| 20 | * (as soon i have understand how to get started :) |
| 21 | * If you can help me out with that, please contact me!! |
| 22 | * |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 23 | * |
Mauro Carvalho Chehab | 55ac7b6 | 2006-08-08 09:10:03 -0300 | [diff] [blame] | 24 | * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #include <linux/module.h> /* Modules */ |
| 28 | #include <linux/init.h> /* Initdata */ |
Peter Osterlund | fb911ee | 2005-09-13 01:25:15 -0700 | [diff] [blame] | 29 | #include <linux/ioport.h> /* request_region */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/delay.h> /* udelay */ |
| 31 | #include <asm/io.h> /* outb, outb_p */ |
| 32 | #include <asm/uaccess.h> /* copy to/from user */ |
Mauro Carvalho Chehab | 55ac7b6 | 2006-08-08 09:10:03 -0300 | [diff] [blame] | 33 | #include <linux/videodev2.h> /* kernel radio structs */ |
Mauro Carvalho Chehab | 5e87efa | 2006-06-05 10:26:32 -0300 | [diff] [blame] | 34 | #include <media/v4l2-common.h> |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 35 | #include <media/v4l2-ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/spinlock.h> |
| 37 | |
Mauro Carvalho Chehab | 55ac7b6 | 2006-08-08 09:10:03 -0300 | [diff] [blame] | 38 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
| 39 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) |
| 40 | |
| 41 | static struct v4l2_queryctrl radio_qctrl[] = { |
| 42 | { |
| 43 | .id = V4L2_CID_AUDIO_MUTE, |
| 44 | .name = "Mute", |
| 45 | .minimum = 0, |
| 46 | .maximum = 1, |
| 47 | .default_value = 1, |
| 48 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 49 | },{ |
| 50 | .id = V4L2_CID_AUDIO_VOLUME, |
| 51 | .name = "Volume", |
| 52 | .minimum = 0, |
| 53 | .maximum = 0xff, |
| 54 | .step = 1, |
| 55 | .default_value = 0xff, |
| 56 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 57 | } |
| 58 | }; |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #ifndef CONFIG_RADIO_TERRATEC_PORT |
| 61 | #define CONFIG_RADIO_TERRATEC_PORT 0x590 |
| 62 | #endif |
| 63 | |
| 64 | /**************** this ones are for the terratec *******************/ |
| 65 | #define BASEPORT 0x590 |
| 66 | #define VOLPORT 0x591 |
| 67 | #define WRT_DIS 0x00 |
| 68 | #define CLK_OFF 0x00 |
| 69 | #define IIC_DATA 0x01 |
| 70 | #define IIC_CLK 0x02 |
| 71 | #define DATA 0x04 |
| 72 | #define CLK_ON 0x08 |
| 73 | #define WRT_EN 0x10 |
| 74 | /*******************************************************************/ |
| 75 | |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 76 | static int io = CONFIG_RADIO_TERRATEC_PORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | static int radio_nr = -1; |
| 78 | static spinlock_t lock; |
| 79 | |
| 80 | struct tt_device |
| 81 | { |
| 82 | int port; |
| 83 | int curvol; |
| 84 | unsigned long curfreq; |
| 85 | int muted; |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | /* local things */ |
| 90 | |
| 91 | static void cardWriteVol(int volume) |
| 92 | { |
| 93 | int i; |
| 94 | volume = volume+(volume * 32); // change both channels |
| 95 | spin_lock(&lock); |
| 96 | for (i=0;i<8;i++) |
| 97 | { |
| 98 | if (volume & (0x80>>i)) |
| 99 | outb(0x80, VOLPORT); |
| 100 | else outb(0x00, VOLPORT); |
| 101 | } |
| 102 | spin_unlock(&lock); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | |
| 107 | static void tt_mute(struct tt_device *dev) |
| 108 | { |
| 109 | dev->muted = 1; |
| 110 | cardWriteVol(0); |
| 111 | } |
| 112 | |
| 113 | static int tt_setvol(struct tt_device *dev, int vol) |
| 114 | { |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | // printk(KERN_ERR "setvol called, vol = %d\n", vol); |
| 117 | |
| 118 | if(vol == dev->curvol) { /* requested volume = current */ |
| 119 | if (dev->muted) { /* user is unmuting the card */ |
| 120 | dev->muted = 0; |
| 121 | cardWriteVol(vol); /* enable card */ |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 122 | } |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | if(vol == 0) { /* volume = 0 means mute the card */ |
| 128 | cardWriteVol(0); /* "turn off card" by setting vol to 0 */ |
| 129 | dev->curvol = vol; /* track the volume state! */ |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | dev->muted = 0; |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | cardWriteVol(vol); |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | dev->curvol = vol; |
| 138 | |
| 139 | return 0; |
| 140 | |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /* this is the worst part in this driver */ |
| 145 | /* many more or less strange things are going on here, but hey, it works :) */ |
| 146 | |
| 147 | static int tt_setfreq(struct tt_device *dev, unsigned long freq1) |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 148 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | int freq; |
| 150 | int i; |
| 151 | int p; |
| 152 | int temp; |
| 153 | long rest; |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | unsigned char buffer[25]; /* we have to bit shift 25 registers */ |
| 156 | freq = freq1/160; /* convert the freq. to a nice to handle value */ |
| 157 | for(i=24;i>-1;i--) |
| 158 | buffer[i]=0; |
| 159 | |
| 160 | rest = freq*10+10700; /* i once had understood what is going on here */ |
| 161 | /* maybe some wise guy (friedhelm?) can comment this stuff */ |
| 162 | i=13; |
| 163 | p=10; |
| 164 | temp=102400; |
| 165 | while (rest!=0) |
| 166 | { |
| 167 | if (rest%temp == rest) |
| 168 | buffer[i] = 0; |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 169 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | { |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 171 | buffer[i] = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | rest = rest-temp; |
| 173 | } |
| 174 | i--; |
| 175 | p--; |
| 176 | temp = temp/2; |
Michael Krufky | b930e1d | 2007-08-27 18:16:54 -0300 | [diff] [blame] | 177 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | spin_lock(&lock); |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | for (i=24;i>-1;i--) /* bit shift the values to the radiocard */ |
| 182 | { |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 183 | if (buffer[i]==1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | outb(WRT_EN|DATA, BASEPORT); |
| 186 | outb(WRT_EN|DATA|CLK_ON , BASEPORT); |
| 187 | outb(WRT_EN|DATA, BASEPORT); |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | outb(WRT_EN|0x00, BASEPORT); |
| 192 | outb(WRT_EN|0x00|CLK_ON , BASEPORT); |
| 193 | } |
| 194 | } |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 195 | outb(0x00, BASEPORT); |
| 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | spin_unlock(&lock); |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 198 | |
| 199 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | static int tt_getsigstr(struct tt_device *dev) /* TODO */ |
| 203 | { |
| 204 | if (inb(io) & 2) /* bit set = no signal present */ |
| 205 | return 0; |
| 206 | return 1; /* signal present */ |
| 207 | } |
| 208 | |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 209 | static int vidioc_querycap(struct file *file, void *priv, |
| 210 | struct v4l2_capability *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 212 | strlcpy(v->driver, "radio-terratec", sizeof(v->driver)); |
| 213 | strlcpy(v->card, "ActiveRadio", sizeof(v->card)); |
| 214 | sprintf(v->bus_info, "ISA"); |
| 215 | v->version = RADIO_VERSION; |
| 216 | v->capabilities = V4L2_CAP_TUNER; |
| 217 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 220 | static int vidioc_g_tuner(struct file *file, void *priv, |
| 221 | struct v4l2_tuner *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 223 | struct video_device *dev = video_devdata(file); |
| 224 | struct tt_device *tt = dev->priv; |
| 225 | |
| 226 | if (v->index > 0) |
| 227 | return -EINVAL; |
| 228 | |
| 229 | strcpy(v->name, "FM"); |
| 230 | v->type = V4L2_TUNER_RADIO; |
| 231 | v->rangelow = (87*16000); |
| 232 | v->rangehigh = (108*16000); |
| 233 | v->rxsubchans = V4L2_TUNER_SUB_MONO; |
| 234 | v->capability = V4L2_TUNER_CAP_LOW; |
| 235 | v->audmode = V4L2_TUNER_MODE_MONO; |
| 236 | v->signal = 0xFFFF*tt_getsigstr(tt); |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | static int vidioc_s_tuner(struct file *file, void *priv, |
| 241 | struct v4l2_tuner *v) |
| 242 | { |
| 243 | if (v->index > 0) |
| 244 | return -EINVAL; |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | static int vidioc_s_frequency(struct file *file, void *priv, |
| 249 | struct v4l2_frequency *f) |
| 250 | { |
| 251 | struct video_device *dev = video_devdata(file); |
| 252 | struct tt_device *tt = dev->priv; |
| 253 | |
| 254 | tt->curfreq = f->frequency; |
| 255 | tt_setfreq(tt, tt->curfreq); |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | static int vidioc_g_frequency(struct file *file, void *priv, |
| 260 | struct v4l2_frequency *f) |
| 261 | { |
| 262 | struct video_device *dev = video_devdata(file); |
| 263 | struct tt_device *tt = dev->priv; |
| 264 | |
| 265 | f->type = V4L2_TUNER_RADIO; |
| 266 | f->frequency = tt->curfreq; |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | static int vidioc_queryctrl(struct file *file, void *priv, |
| 271 | struct v4l2_queryctrl *qc) |
| 272 | { |
| 273 | int i; |
| 274 | |
| 275 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
| 276 | if (qc->id && qc->id == radio_qctrl[i].id) { |
| 277 | memcpy(qc, &(radio_qctrl[i]), |
| 278 | sizeof(*qc)); |
| 279 | return 0; |
| 280 | } |
| 281 | } |
| 282 | return -EINVAL; |
| 283 | } |
| 284 | |
| 285 | static int vidioc_g_ctrl(struct file *file, void *priv, |
| 286 | struct v4l2_control *ctrl) |
| 287 | { |
| 288 | struct video_device *dev = video_devdata(file); |
| 289 | struct tt_device *tt = dev->priv; |
| 290 | |
| 291 | switch (ctrl->id) { |
| 292 | case V4L2_CID_AUDIO_MUTE: |
| 293 | if (tt->muted) |
| 294 | ctrl->value = 1; |
| 295 | else |
| 296 | ctrl->value = 0; |
| 297 | return 0; |
| 298 | case V4L2_CID_AUDIO_VOLUME: |
| 299 | ctrl->value = tt->curvol * 6554; |
| 300 | return 0; |
| 301 | } |
| 302 | return -EINVAL; |
| 303 | } |
| 304 | |
| 305 | static int vidioc_s_ctrl(struct file *file, void *priv, |
| 306 | struct v4l2_control *ctrl) |
| 307 | { |
| 308 | struct video_device *dev = video_devdata(file); |
| 309 | struct tt_device *tt = dev->priv; |
| 310 | |
| 311 | switch (ctrl->id) { |
| 312 | case V4L2_CID_AUDIO_MUTE: |
| 313 | if (ctrl->value) |
| 314 | tt_mute(tt); |
| 315 | else |
| 316 | tt_setvol(tt,tt->curvol); |
| 317 | return 0; |
| 318 | case V4L2_CID_AUDIO_VOLUME: |
| 319 | tt_setvol(tt,ctrl->value); |
| 320 | return 0; |
| 321 | } |
| 322 | return -EINVAL; |
| 323 | } |
| 324 | |
| 325 | static int vidioc_g_audio(struct file *file, void *priv, |
| 326 | struct v4l2_audio *a) |
| 327 | { |
| 328 | if (a->index > 1) |
| 329 | return -EINVAL; |
| 330 | |
| 331 | strcpy(a->name, "Radio"); |
| 332 | a->capability = V4L2_AUDCAP_STEREO; |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) |
| 337 | { |
| 338 | *i = 0; |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) |
| 343 | { |
| 344 | if (i != 0) |
| 345 | return -EINVAL; |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | static int vidioc_s_audio(struct file *file, void *priv, |
| 350 | struct v4l2_audio *a) |
| 351 | { |
| 352 | if (a->index != 0) |
| 353 | return -EINVAL; |
| 354 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | static struct tt_device terratec_unit; |
| 358 | |
Arjan van de Ven | fa027c2 | 2007-02-12 00:55:33 -0800 | [diff] [blame] | 359 | static const struct file_operations terratec_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | .owner = THIS_MODULE, |
| 361 | .open = video_exclusive_open, |
| 362 | .release = video_exclusive_release, |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 363 | .ioctl = video_ioctl2, |
Douglas Schilling Landgraf | 078ff79 | 2008-04-22 14:46:11 -0300 | [diff] [blame] | 364 | #ifdef CONFIG_COMPAT |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 365 | .compat_ioctl = v4l_compat_ioctl32, |
Douglas Schilling Landgraf | 078ff79 | 2008-04-22 14:46:11 -0300 | [diff] [blame] | 366 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | .llseek = no_llseek, |
| 368 | }; |
| 369 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 370 | static const struct v4l2_ioctl_ops terratec_ioctl_ops = { |
Douglas Landgraf | 1de6923 | 2007-04-22 23:15:47 -0300 | [diff] [blame] | 371 | .vidioc_querycap = vidioc_querycap, |
| 372 | .vidioc_g_tuner = vidioc_g_tuner, |
| 373 | .vidioc_s_tuner = vidioc_s_tuner, |
| 374 | .vidioc_g_frequency = vidioc_g_frequency, |
| 375 | .vidioc_s_frequency = vidioc_s_frequency, |
| 376 | .vidioc_queryctrl = vidioc_queryctrl, |
| 377 | .vidioc_g_ctrl = vidioc_g_ctrl, |
| 378 | .vidioc_s_ctrl = vidioc_s_ctrl, |
| 379 | .vidioc_g_audio = vidioc_g_audio, |
| 380 | .vidioc_s_audio = vidioc_s_audio, |
| 381 | .vidioc_g_input = vidioc_g_input, |
| 382 | .vidioc_s_input = vidioc_s_input, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | }; |
| 384 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 385 | static struct video_device terratec_radio = { |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 386 | .name = "TerraTec ActiveRadio", |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 387 | .fops = &terratec_fops, |
| 388 | .ioctl_ops = &terratec_ioctl_ops, |
| 389 | }; |
| 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | static int __init terratec_init(void) |
| 392 | { |
| 393 | if(io==-1) |
| 394 | { |
| 395 | printk(KERN_ERR "You must set an I/O address with io=0x???\n"); |
| 396 | return -EINVAL; |
| 397 | } |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 398 | if (!request_region(io, 2, "terratec")) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | { |
| 400 | printk(KERN_ERR "TerraTec: port 0x%x already in use\n", io); |
| 401 | return -EBUSY; |
| 402 | } |
| 403 | |
| 404 | terratec_radio.priv=&terratec_unit; |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 405 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | spin_lock_init(&lock); |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | if(video_register_device(&terratec_radio, VFL_TYPE_RADIO, radio_nr)==-1) |
| 409 | { |
| 410 | release_region(io,2); |
| 411 | return -EINVAL; |
| 412 | } |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 413 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver.\n"); |
| 415 | |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 416 | /* mute card - prevents noisy bootups */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | |
| 418 | /* this ensures that the volume is all the way down */ |
| 419 | cardWriteVol(0); |
| 420 | terratec_unit.curvol = 0; |
| 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | MODULE_AUTHOR("R.OFFERMANNS & others"); |
| 426 | MODULE_DESCRIPTION("A driver for the TerraTec ActiveRadio Standalone radio card."); |
| 427 | MODULE_LICENSE("GPL"); |
| 428 | module_param(io, int, 0); |
| 429 | MODULE_PARM_DESC(io, "I/O address of the TerraTec ActiveRadio card (0x590 or 0x591)"); |
| 430 | module_param(radio_nr, int, 0); |
| 431 | |
| 432 | static void __exit terratec_cleanup_module(void) |
| 433 | { |
| 434 | video_unregister_device(&terratec_radio); |
| 435 | release_region(io,2); |
Mauro Carvalho Chehab | 4286c6f | 2006-04-08 16:06:16 -0300 | [diff] [blame] | 436 | printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver unloaded.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | module_init(terratec_init); |
| 440 | module_exit(terratec_cleanup_module); |
| 441 | |