25 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/sched.h>
37 MODULE_DESCRIPTION(
"Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips");
44 #define TEA575X_BIT_SEARCH (1<<24)
45 #define TEA575X_BIT_UPDOWN (1<<23)
46 #define TEA575X_BIT_MONO (1<<22)
47 #define TEA575X_BIT_BAND_MASK (3<<20)
48 #define TEA575X_BIT_BAND_FM (0<<20)
49 #define TEA575X_BIT_BAND_MW (1<<20)
50 #define TEA575X_BIT_BAND_LW (2<<20)
51 #define TEA575X_BIT_BAND_SW (3<<20)
52 #define TEA575X_BIT_PORT_0 (1<<19)
53 #define TEA575X_BIT_PORT_1 (1<<18)
54 #define TEA575X_BIT_SEARCH_MASK (3<<16)
55 #define TEA575X_BIT_SEARCH_5_28 (0<<16)
56 #define TEA575X_BIT_SEARCH_10_40 (1<<16)
57 #define TEA575X_BIT_SEARCH_30_63 (2<<16)
58 #define TEA575X_BIT_SEARCH_150_1000 (3<<16)
59 #define TEA575X_BIT_DUMMY (1<<15)
60 #define TEA575X_BIT_FREQ_MASK 0x7fff
70 .rangelow = 87500 * 16,
71 .rangehigh = 108000 * 16,
79 .rangelow = 76000 * 16,
80 .rangehigh = 91000 * 16,
88 .rangehigh = 1710 * 16,
97 static void snd_tea575x_write(
struct snd_tea575x *tea,
unsigned int val)
102 if (tea->
ops->write_val)
103 return tea->
ops->write_val(tea, val);
105 tea->
ops->set_direction(tea, 1);
108 for (l = 25; l > 0; l--) {
120 tea->
ops->set_pins(tea, 0);
128 if (tea->
ops->read_val)
129 return tea->
ops->read_val(tea);
131 tea->
ops->set_direction(tea, 0);
132 tea->
ops->set_pins(tea, 0);
140 tea->
ops->set_pins(tea, 0);
143 rdata = tea->
ops->get_pins(tea);
191 return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea));
226 snd_tea575x_write(tea, tea->
val);
227 tea->
freq = snd_tea575x_val_to_freq(tea, tea->
val);
234 static int vidioc_querycap(
struct file *
file,
void *
priv,
250 static int vidioc_enum_freq_bands(
struct file *file,
void *priv,
256 if (band->
tuner != 0)
259 switch (band->
index) {
276 *band = bands[
index];
283 static int vidioc_g_tuner(
struct file *file,
void *priv,
292 snd_tea575x_read(tea);
293 vidioc_enum_freq_bands(file, priv, &band_fm);
308 static int vidioc_s_tuner(
struct file *file,
void *priv,
326 static int vidioc_g_frequency(
struct file *file,
void *priv,
338 static int vidioc_s_frequency(
struct file *file,
void *priv,
359 static int vidioc_s_hw_freq_seek(
struct file *file,
void *fh,
380 if (bands[i].rangelow == a->
rangelow &&
386 if (i != tea->
band) {
397 tea->
val &= ~TEA575X_BIT_FREQ_MASK;
403 snd_tea575x_write(tea, tea->
val);
418 for (i = 0; i < 100; i++) {
420 freq = snd_tea575x_get_freq(tea);
430 if (
abs(tea->
freq - freq) < 16 * spacing ||
433 snd_tea575x_write(tea, tea->
val);
437 tea->
val &= ~TEA575X_BIT_SEARCH;
441 tea->
val &= ~TEA575X_BIT_SEARCH;
481 .ioctl_ops = &tea575x_ioctl_ops,
486 .s_ctrl = tea575x_s_ctrl,
501 snd_tea575x_write(tea, 0x55AA);
502 if (snd_tea575x_read(tea) != 0x55AA)
507 tea->
freq = 90500 * 16;
510 tea->
vd = tea575x_radio;
511 video_set_drvdata(&tea->
vd, tea);
516 tea->
fops = tea575x_fops;
518 tea->
vd.fops = &tea->
fops;
563 static int __init alsa_tea575x_module_init(
void)
568 static void __exit alsa_tea575x_module_exit(
void)