28 #include <linux/module.h>
29 #include <linux/sched.h>
30 #include <linux/slab.h>
42 #define TEA5777_FM_IF 150
43 #define TEA5777_FM_FREQ_STEP 50
45 #define TEA5777_AM_IF 21
46 #define TEA5777_AM_FREQ_STEP 1
49 #define TEA5777_W_MUTE_MASK (1LL << 47)
50 #define TEA5777_W_MUTE_SHIFT 47
51 #define TEA5777_W_AM_FM_MASK (1LL << 46)
52 #define TEA5777_W_AM_FM_SHIFT 46
53 #define TEA5777_W_STB_MASK (1LL << 45)
54 #define TEA5777_W_STB_SHIFT 45
56 #define TEA5777_W_IFCE_MASK (1LL << 29)
57 #define TEA5777_W_IFCE_SHIFT 29
58 #define TEA5777_W_IFW_MASK (1LL << 28)
59 #define TEA5777_W_IFW_SHIFT 28
60 #define TEA5777_W_HILO_MASK (1LL << 27)
61 #define TEA5777_W_HILO_SHIFT 27
62 #define TEA5777_W_DBUS_MASK (1LL << 26)
63 #define TEA5777_W_DBUS_SHIFT 26
65 #define TEA5777_W_INTEXT_MASK (1LL << 24)
66 #define TEA5777_W_INTEXT_SHIFT 24
67 #define TEA5777_W_P1_MASK (1LL << 23)
68 #define TEA5777_W_P1_SHIFT 23
69 #define TEA5777_W_P0_MASK (1LL << 22)
70 #define TEA5777_W_P0_SHIFT 22
71 #define TEA5777_W_PEN1_MASK (1LL << 21)
72 #define TEA5777_W_PEN1_SHIFT 21
73 #define TEA5777_W_PEN0_MASK (1LL << 20)
74 #define TEA5777_W_PEN0_SHIFT 20
76 #define TEA5777_W_CHP0_MASK (1LL << 18)
77 #define TEA5777_W_CHP0_SHIFT 18
78 #define TEA5777_W_DEEM_MASK (1LL << 17)
79 #define TEA5777_W_DEEM_SHIFT 17
81 #define TEA5777_W_SEARCH_MASK (1LL << 7)
82 #define TEA5777_W_SEARCH_SHIFT 7
83 #define TEA5777_W_PROGBLIM_MASK (1LL << 6)
84 #define TEA5777_W_PROGBLIM_SHIFT 6
85 #define TEA5777_W_UPDWN_MASK (1LL << 5)
86 #define TEA5777_W_UPDWN_SHIFT 5
87 #define TEA5777_W_SLEV_MASK (3LL << 3)
88 #define TEA5777_W_SLEV_SHIFT 3
91 #define TEA5777_W_FM_PLL_MASK (0x1fffLL << 32)
92 #define TEA5777_W_FM_PLL_SHIFT 32
93 #define TEA5777_W_FM_FREF_MASK (0x03LL << 30)
94 #define TEA5777_W_FM_FREF_SHIFT 30
95 #define TEA5777_W_FM_FREF_VALUE 0LL
97 #define TEA5777_W_FM_FORCEMONO_MASK (1LL << 15)
98 #define TEA5777_W_FM_FORCEMONO_SHIFT 15
99 #define TEA5777_W_FM_SDSOFF_MASK (1LL << 14)
100 #define TEA5777_W_FM_SDSOFF_SHIFT 14
101 #define TEA5777_W_FM_DOFF_MASK (1LL << 13)
102 #define TEA5777_W_FM_DOFF_SHIFT 13
104 #define TEA5777_W_FM_STEP_MASK (3LL << 1)
105 #define TEA5777_W_FM_STEP_SHIFT 1
108 #define TEA5777_W_AM_PLL_MASK (0x7ffLL << 34)
109 #define TEA5777_W_AM_PLL_SHIFT 34
110 #define TEA5777_W_AM_AGCRF_MASK (1LL << 33)
111 #define TEA5777_W_AM_AGCRF_SHIFT 33
112 #define TEA5777_W_AM_AGCIF_MASK (1LL << 32)
113 #define TEA5777_W_AM_AGCIF_SHIFT 32
114 #define TEA5777_W_AM_MWLW_MASK (1LL << 31)
115 #define TEA5777_W_AM_MWLW_SHIFT 31
116 #define TEA5777_W_AM_LW 0LL
117 #define TEA5777_W_AM_MW 1LL
118 #define TEA5777_W_AM_LNA_MASK (1LL << 30)
119 #define TEA5777_W_AM_LNA_SHIFT 30
121 #define TEA5777_W_AM_PEAK_MASK (1LL << 25)
122 #define TEA5777_W_AM_PEAK_SHIFT 25
124 #define TEA5777_W_AM_RFB_MASK (1LL << 16)
125 #define TEA5777_W_AM_RFB_SHIFT 16
126 #define TEA5777_W_AM_CALLIGN_MASK (1LL << 15)
127 #define TEA5777_W_AM_CALLIGN_SHIFT 15
128 #define TEA5777_W_AM_CBANK_MASK (0x7fLL << 8)
129 #define TEA5777_W_AM_CBANK_SHIFT 8
131 #define TEA5777_W_AM_DELAY_MASK (1LL << 2)
132 #define TEA5777_W_AM_DELAY_SHIFT 2
133 #define TEA5777_W_AM_STEP_MASK (1LL << 1)
134 #define TEA5777_W_AM_STEP_SHIFT 1
137 #define TEA5777_R_LEVEL_MASK (0x0f << 17)
138 #define TEA5777_R_LEVEL_SHIFT 17
139 #define TEA5777_R_SFOUND_MASK (0x01 << 16)
140 #define TEA5777_R_SFOUND_SHIFT 16
141 #define TEA5777_R_BLIM_MASK (0x01 << 15)
142 #define TEA5777_R_BLIM_SHIFT 15
145 #define TEA5777_R_FM_STEREO_MASK (0x01 << 21)
146 #define TEA5777_R_FM_STEREO_SHIFT 21
147 #define TEA5777_R_FM_PLL_MASK 0x1fff
148 #define TEA5777_R_FM_PLL_SHIFT 0
160 .rangelow = 76000 * 16,
161 .rangehigh = 108000 * 16,
170 .rangelow = 530 * 16,
171 .rangehigh = 1710 * 16,
194 freq = (freq + 8) / 16;
233 tea->
freq = tea5777_freq_to_v4l2_freq(tea, freq);
268 static int vidioc_querycap(
struct file *
file,
void *
priv,
283 static int vidioc_enum_freq_bands(
struct file *
file,
void *
priv,
292 *band = bands[band->
index];
296 static int vidioc_g_tuner(
struct file *file,
void *priv,
305 res = radio_tea5777_update_read_reg(tea, 0);
338 static int vidioc_s_tuner(
struct file *file,
void *priv,
358 static int vidioc_g_frequency(
struct file *file,
void *priv,
370 static int vidioc_s_frequency(
struct file *file,
void *priv,
387 static int vidioc_s_hw_freq_seek(
struct file *file,
void *fh,
403 if (rangelow || rangehigh) {
407 if (bands[i].rangelow >= rangelow &&
408 bands[i].rangehigh <= rangehigh)
415 if (tea->
freq < rangelow || tea->
freq > rangehigh) {
427 spacing = (tea->
band ==
BAND_AM) ? (5 * 16) : (200 * 16);
428 orig_freq = tea->
freq;
433 tea->
freq = rangelow;
441 tea->
freq = rangehigh;
452 tea->
freq = orig_freq + spacing;
455 tea->
freq = orig_freq - spacing;
468 res = radio_tea5777_update_read_reg(tea, 100);
478 tea->
freq = tea5777_freq_to_v4l2_freq(tea, tea->
freq);
496 tea->
freq = orig_freq;
501 static int tea575x_s_ctrl(
struct v4l2_ctrl *
c)
540 .ioctl_ops = &tea575x_ioctl_ops,
545 .s_ctrl = tea575x_s_ctrl,
557 tea->
freq = 90500 * 16;
565 tea->
vd = tea575x_radio;
566 video_set_drvdata(&tea->
vd, tea);
571 tea->
fops = tea575x_fops;
573 tea->
vd.fops = &tea->
fops;