blob: b3f45a019d82c875432e1d6c1c3ca6f47179af9e [file] [log] [blame]
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -03001/* radio-trust.c - Trust FM Radio card driver for Linux 2.2
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * by Eric Lammerts <eric@scintilla.utwente.nl>
3 *
4 * Based on radio-aztech.c. Original notes:
5 *
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -03006 * Adapted to support the Video for Linux API by
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
8 *
9 * Quay Ly
10 * Donald Song
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030011 * Jason Lewis (jlewis@twilight.vtc.vsc.edu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
14 *
Mauro Carvalho Chehab982eddb2006-08-08 09:10:05 -030015 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
18#include <stdarg.h>
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/ioport.h>
Mauro Carvalho Chehab982eddb2006-08-08 09:10:05 -030022#include <linux/videodev2.h>
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030023#include <linux/io.h>
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030024#include <media/v4l2-device.h>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030025#include <media/v4l2-ioctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030027MODULE_AUTHOR("Eric Lammerts, Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
28MODULE_DESCRIPTION("A driver for the Trust FM Radio card.");
29MODULE_LICENSE("GPL");
Mauro Carvalho Chehab29834c12011-06-25 10:15:42 -030030MODULE_VERSION("0.0.3");
Mauro Carvalho Chehab982eddb2006-08-08 09:10:05 -030031
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
33
34#ifndef CONFIG_RADIO_TRUST_PORT
35#define CONFIG_RADIO_TRUST_PORT -1
36#endif
37
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -030038static int io = CONFIG_RADIO_TRUST_PORT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static int radio_nr = -1;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030040
41module_param(io, int, 0);
42MODULE_PARM_DESC(io, "I/O address of the Trust FM Radio card (0x350 or 0x358)");
43module_param(radio_nr, int, 0);
44
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030045struct trust {
46 struct v4l2_device v4l2_dev;
47 struct video_device vdev;
48 int io;
49 int ioval;
50 __u16 curvol;
51 __u16 curbass;
52 __u16 curtreble;
53 int muted;
54 unsigned long curfreq;
55 int curstereo;
56 int curmute;
57 struct mutex lock;
58};
59
60static struct trust trust_card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62/* i2c addresses */
63#define TDA7318_ADDR 0x88
64#define TSA6060T_ADDR 0xc4
65
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030066#define TR_DELAY do { inb(tr->io); inb(tr->io); inb(tr->io); } while (0)
67#define TR_SET_SCL outb(tr->ioval |= 2, tr->io)
68#define TR_CLR_SCL outb(tr->ioval &= 0xfd, tr->io)
69#define TR_SET_SDA outb(tr->ioval |= 1, tr->io)
70#define TR_CLR_SDA outb(tr->ioval &= 0xfe, tr->io)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -030072static void write_i2c(struct trust *tr, int n, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
74 unsigned char val, mask;
75 va_list args;
76
77 va_start(args, n);
78
79 /* start condition */
80 TR_SET_SDA;
81 TR_SET_SCL;
82 TR_DELAY;
83 TR_CLR_SDA;
84 TR_CLR_SCL;
85 TR_DELAY;
86
87 for(; n; n--) {
88 val = va_arg(args, unsigned);
89 for(mask = 0x80; mask; mask >>= 1) {
90 if(val & mask)
91 TR_SET_SDA;
92 else
93 TR_CLR_SDA;
94 TR_SET_SCL;
95 TR_DELAY;
96 TR_CLR_SCL;
97 TR_DELAY;
98 }
99 /* acknowledge bit */
100 TR_SET_SDA;
101 TR_SET_SCL;
102 TR_DELAY;
103 TR_CLR_SCL;
104 TR_DELAY;
105 }
106
107 /* stop condition */
108 TR_CLR_SDA;
109 TR_DELAY;
110 TR_SET_SCL;
111 TR_DELAY;
112 TR_SET_SDA;
113 TR_DELAY;
114
115 va_end(args);
116}
117
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300118static void tr_setvol(struct trust *tr, __u16 vol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300120 mutex_lock(&tr->lock);
121 tr->curvol = vol / 2048;
122 write_i2c(tr, 2, TDA7318_ADDR, tr->curvol ^ 0x1f);
123 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}
125
126static int basstreble2chip[15] = {
127 0, 1, 2, 3, 4, 5, 6, 7, 14, 13, 12, 11, 10, 9, 8
128};
129
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300130static void tr_setbass(struct trust *tr, __u16 bass)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300132 mutex_lock(&tr->lock);
133 tr->curbass = bass / 4370;
134 write_i2c(tr, 2, TDA7318_ADDR, 0x60 | basstreble2chip[tr->curbass]);
135 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136}
137
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300138static void tr_settreble(struct trust *tr, __u16 treble)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300140 mutex_lock(&tr->lock);
141 tr->curtreble = treble / 4370;
142 write_i2c(tr, 2, TDA7318_ADDR, 0x70 | basstreble2chip[tr->curtreble]);
143 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300146static void tr_setstereo(struct trust *tr, int stereo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300148 mutex_lock(&tr->lock);
149 tr->curstereo = !!stereo;
150 tr->ioval = (tr->ioval & 0xfb) | (!tr->curstereo << 2);
151 outb(tr->ioval, tr->io);
152 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153}
154
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300155static void tr_setmute(struct trust *tr, int mute)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300157 mutex_lock(&tr->lock);
158 tr->curmute = !!mute;
159 tr->ioval = (tr->ioval & 0xf7) | (tr->curmute << 3);
160 outb(tr->ioval, tr->io);
161 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162}
163
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300164static int tr_getsigstr(struct trust *tr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
166 int i, v;
Mauro Carvalho Chehab4286c6f2006-04-08 16:06:16 -0300167
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300168 mutex_lock(&tr->lock);
169 for (i = 0, v = 0; i < 100; i++)
170 v |= inb(tr->io);
171 mutex_unlock(&tr->lock);
172 return (v & 1) ? 0 : 0xffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173}
174
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300175static int tr_getstereo(struct trust *tr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176{
177 /* don't know how to determine it, just return the setting */
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300178 return tr->curstereo;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179}
180
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300181static void tr_setfreq(struct trust *tr, unsigned long f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300183 mutex_lock(&tr->lock);
184 tr->curfreq = f;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 f /= 160; /* Convert to 10 kHz units */
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300186 f += 1070; /* Add 10.7 MHz IF */
187 write_i2c(tr, 5, TSA6060T_ADDR, (f << 1) | 1, f >> 7, 0x60 | ((f >> 15) & 1), 0);
188 mutex_unlock(&tr->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189}
190
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300191static int vidioc_querycap(struct file *file, void *priv,
192 struct v4l2_capability *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193{
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300194 strlcpy(v->driver, "radio-trust", sizeof(v->driver));
195 strlcpy(v->card, "Trust FM Radio", sizeof(v->card));
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300196 strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300197 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300198 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199}
200
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300201static int vidioc_g_tuner(struct file *file, void *priv,
202 struct v4l2_tuner *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300204 struct trust *tr = video_drvdata(file);
205
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300206 if (v->index > 0)
207 return -EINVAL;
208
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300209 strlcpy(v->name, "FM", sizeof(v->name));
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300210 v->type = V4L2_TUNER_RADIO;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300211 v->rangelow = 87.5 * 16000;
212 v->rangehigh = 108 * 16000;
213 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300214 v->capability = V4L2_TUNER_CAP_LOW;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300215 if (tr_getstereo(tr))
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300216 v->audmode = V4L2_TUNER_MODE_STEREO;
217 else
218 v->audmode = V4L2_TUNER_MODE_MONO;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300219 v->signal = tr_getsigstr(tr);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300220 return 0;
221}
222
223static int vidioc_s_tuner(struct file *file, void *priv,
224 struct v4l2_tuner *v)
225{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300226 struct trust *tr = video_drvdata(file);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300227
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300228 if (v->index)
229 return -EINVAL;
230 tr_setstereo(tr, v->audmode == V4L2_TUNER_MODE_STEREO);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300231 return 0;
232}
233
234static int vidioc_s_frequency(struct file *file, void *priv,
235 struct v4l2_frequency *f)
236{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300237 struct trust *tr = video_drvdata(file);
238
Hans Verkuila3a9e282009-11-27 04:33:25 -0300239 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
240 return -EINVAL;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300241 tr_setfreq(tr, f->frequency);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300242 return 0;
243}
244
245static int vidioc_g_frequency(struct file *file, void *priv,
246 struct v4l2_frequency *f)
247{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300248 struct trust *tr = video_drvdata(file);
249
Hans Verkuila3a9e282009-11-27 04:33:25 -0300250 if (f->tuner != 0)
251 return -EINVAL;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300252 f->type = V4L2_TUNER_RADIO;
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300253 f->frequency = tr->curfreq;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300254 return 0;
255}
256
257static int vidioc_queryctrl(struct file *file, void *priv,
258 struct v4l2_queryctrl *qc)
259{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300260 switch (qc->id) {
261 case V4L2_CID_AUDIO_MUTE:
262 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
263 case V4L2_CID_AUDIO_VOLUME:
264 return v4l2_ctrl_query_fill(qc, 0, 65535, 2048, 65535);
265 case V4L2_CID_AUDIO_BASS:
266 case V4L2_CID_AUDIO_TREBLE:
267 return v4l2_ctrl_query_fill(qc, 0, 65535, 4370, 32768);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300268 }
269 return -EINVAL;
270}
271
272static int vidioc_g_ctrl(struct file *file, void *priv,
273 struct v4l2_control *ctrl)
274{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300275 struct trust *tr = video_drvdata(file);
276
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300277 switch (ctrl->id) {
278 case V4L2_CID_AUDIO_MUTE:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300279 ctrl->value = tr->curmute;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300280 return 0;
281 case V4L2_CID_AUDIO_VOLUME:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300282 ctrl->value = tr->curvol * 2048;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300283 return 0;
284 case V4L2_CID_AUDIO_BASS:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300285 ctrl->value = tr->curbass * 4370;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300286 return 0;
287 case V4L2_CID_AUDIO_TREBLE:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300288 ctrl->value = tr->curtreble * 4370;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300289 return 0;
290 }
291 return -EINVAL;
292}
293
294static int vidioc_s_ctrl(struct file *file, void *priv,
295 struct v4l2_control *ctrl)
296{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300297 struct trust *tr = video_drvdata(file);
298
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300299 switch (ctrl->id) {
300 case V4L2_CID_AUDIO_MUTE:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300301 tr_setmute(tr, ctrl->value);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300302 return 0;
303 case V4L2_CID_AUDIO_VOLUME:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300304 tr_setvol(tr, ctrl->value);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300305 return 0;
306 case V4L2_CID_AUDIO_BASS:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300307 tr_setbass(tr, ctrl->value);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300308 return 0;
309 case V4L2_CID_AUDIO_TREBLE:
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300310 tr_settreble(tr, ctrl->value);
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300311 return 0;
312 }
313 return -EINVAL;
314}
315
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300316static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
317{
318 *i = 0;
319 return 0;
320}
321
322static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
323{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300324 return i ? -EINVAL : 0;
325}
326
327static int vidioc_g_audio(struct file *file, void *priv,
328 struct v4l2_audio *a)
329{
330 a->index = 0;
331 strlcpy(a->name, "Radio", sizeof(a->name));
332 a->capability = V4L2_AUDCAP_STEREO;
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300333 return 0;
334}
335
336static int vidioc_s_audio(struct file *file, void *priv,
337 struct v4l2_audio *a)
338{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300339 return a->index ? -EINVAL : 0;
340}
341
Hans Verkuilbec43662008-12-30 06:58:20 -0300342static const struct v4l2_file_operations trust_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 .owner = THIS_MODULE,
Hans Verkuil32958fd2010-11-14 09:36:23 -0300344 .unlocked_ioctl = video_ioctl2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345};
346
Hans Verkuila3998102008-07-21 02:57:38 -0300347static const struct v4l2_ioctl_ops trust_ioctl_ops = {
Douglas Landgrafc5f822b2007-04-20 18:22:19 -0300348 .vidioc_querycap = vidioc_querycap,
349 .vidioc_g_tuner = vidioc_g_tuner,
350 .vidioc_s_tuner = vidioc_s_tuner,
351 .vidioc_g_frequency = vidioc_g_frequency,
352 .vidioc_s_frequency = vidioc_s_frequency,
353 .vidioc_queryctrl = vidioc_queryctrl,
354 .vidioc_g_ctrl = vidioc_g_ctrl,
355 .vidioc_s_ctrl = vidioc_s_ctrl,
356 .vidioc_g_audio = vidioc_g_audio,
357 .vidioc_s_audio = vidioc_s_audio,
358 .vidioc_g_input = vidioc_g_input,
359 .vidioc_s_input = vidioc_s_input,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360};
361
362static int __init trust_init(void)
363{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300364 struct trust *tr = &trust_card;
365 struct v4l2_device *v4l2_dev = &tr->v4l2_dev;
366 int res;
367
368 strlcpy(v4l2_dev->name, "trust", sizeof(v4l2_dev->name));
369 tr->io = io;
370 tr->ioval = 0xf;
371 mutex_init(&tr->lock);
372
373 if (tr->io == -1) {
Hans Verkuilb24c20cc2009-03-09 08:11:21 -0300374 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x0x350 or 0x358\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 return -EINVAL;
376 }
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300377 if (!request_region(tr->io, 2, "Trust FM Radio")) {
378 v4l2_err(v4l2_dev, "port 0x%x already in use\n", tr->io);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 return -EBUSY;
380 }
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300381
382 res = v4l2_device_register(NULL, v4l2_dev);
383 if (res < 0) {
384 release_region(tr->io, 2);
385 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
386 return res;
387 }
388
389 strlcpy(tr->vdev.name, v4l2_dev->name, sizeof(tr->vdev.name));
390 tr->vdev.v4l2_dev = v4l2_dev;
391 tr->vdev.fops = &trust_fops;
392 tr->vdev.ioctl_ops = &trust_ioctl_ops;
393 tr->vdev.release = video_device_release_empty;
394 video_set_drvdata(&tr->vdev, tr);
395
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300396 write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */
397 write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */
398 write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */
399 write_i2c(tr, 2, TDA7318_ADDR, 0xe0); /* speaker att. RR = 0 dB */
400 write_i2c(tr, 2, TDA7318_ADDR, 0x40); /* stereo 1 input, gain = 18.75 dB */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300402 tr_setvol(tr, 0xffff);
403 tr_setbass(tr, 0x8000);
404 tr_settreble(tr, 0x8000);
405 tr_setstereo(tr, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407 /* mute card - prevents noisy bootups */
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300408 tr_setmute(tr, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Hans Verkuil32958fd2010-11-14 09:36:23 -0300410 if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
411 v4l2_device_unregister(v4l2_dev);
412 release_region(tr->io, 2);
413 return -EINVAL;
414 }
415
416 v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");
417
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 return 0;
419}
420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421static void __exit cleanup_trust_module(void)
422{
Hans Verkuil1dc8aaf2009-03-06 13:54:23 -0300423 struct trust *tr = &trust_card;
424
425 video_unregister_device(&tr->vdev);
426 v4l2_device_unregister(&tr->v4l2_dev);
427 release_region(tr->io, 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428}
429
430module_init(trust_init);
431module_exit(cleanup_trust_module);