1
2
3
4
5
6
7
8
9
10 #ifndef _FM_DRV_H
11 #define _FM_DRV_H
12
13 #include <linux/skbuff.h>
14 #include <linux/interrupt.h>
15 #include <sound/core.h>
16 #include <sound/initval.h>
17 #include <linux/timer.h>
18 #include <media/v4l2-ioctl.h>
19 #include <media/v4l2-common.h>
20 #include <media/v4l2-device.h>
21 #include <media/v4l2-ctrls.h>
22
23 #define FM_DRV_VERSION "0.1.1"
24 #define FM_DRV_NAME "ti_fmdrv"
25 #define FM_DRV_CARD_SHORT_NAME "TI FM Radio"
26 #define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio"
27
28
29 #define FM_INTTASK_RUNNING 0
30 #define FM_INTTASK_SCHEDULE_PENDING 1
31 #define FM_FW_DW_INPROGRESS 2
32 #define FM_CORE_READY 3
33 #define FM_CORE_TRANSPORT_READY 4
34 #define FM_AF_SWITCH_INPROGRESS 5
35 #define FM_CORE_TX_XMITING 6
36
37 #define FM_TUNE_COMPLETE 0x1
38 #define FM_BAND_LIMIT 0x2
39
40 #define FM_DRV_TX_TIMEOUT (5*HZ)
41 #define FM_DRV_RX_SEEK_TIMEOUT (20*HZ)
42
43 #define fmerr(format, ...) \
44 printk(KERN_ERR "fmdrv: " format, ## __VA_ARGS__)
45 #define fmwarn(format, ...) \
46 printk(KERN_WARNING "fmdrv: " format, ##__VA_ARGS__)
47 #ifdef DEBUG
48 #define fmdbg(format, ...) \
49 printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__)
50 #else
51 #define fmdbg(format, ...) do {} while(0)
52 #endif
53 enum {
54 FM_MODE_OFF,
55 FM_MODE_TX,
56 FM_MODE_RX,
57 FM_MODE_ENTRY_MAX
58 };
59
60 #define FM_RX_RDS_INFO_FIELD_MAX 8
61
62
63 struct fm_rdsdata_format {
64 union {
65 struct {
66 u8 buff[FM_RX_RDS_INFO_FIELD_MAX];
67 } groupdatabuff;
68 struct {
69 u16 pidata;
70 u8 blk_b[2];
71 u8 blk_c[2];
72 u8 blk_d[2];
73 } groupgeneral;
74 struct {
75 u16 pidata;
76 u8 blk_b[2];
77 u8 af[2];
78 u8 ps[2];
79 } group0A;
80 struct {
81 u16 pi[2];
82 u8 blk_b[2];
83 u8 ps[2];
84 } group0B;
85 } data;
86 };
87
88
89 struct region_info {
90 u32 chanl_space;
91 u32 bot_freq;
92 u32 top_freq;
93 u8 fm_band;
94 };
95 struct fmdev;
96 typedef void (*int_handler_prototype) (struct fmdev *);
97
98
99 struct fm_irq {
100 u8 stage;
101 u16 flag;
102 u16 mask;
103
104 struct timer_list timer;
105 u8 retry;
106 int_handler_prototype *handlers;
107 };
108
109
110 struct fm_rds {
111 u8 flag;
112 u8 last_blk_idx;
113
114
115 wait_queue_head_t read_queue;
116 u32 buf_size;
117 u32 wr_idx;
118 u32 rd_idx;
119 u8 *buff;
120 };
121
122 #define FM_RDS_MAX_AF_LIST 25
123
124
125
126
127
128
129 struct tuned_station_info {
130 u16 picode;
131 u32 af_cache[FM_RDS_MAX_AF_LIST];
132 u8 afcache_size;
133 u8 af_list_max;
134 };
135
136
137 struct fm_rx {
138 struct region_info region;
139 u32 freq;
140 u8 mute_mode;
141 u8 deemphasis_mode;
142
143 u8 rf_depend_mute;
144 u16 volume;
145 u16 rssi_threshold;
146
147 u8 afjump_idx;
148
149 u32 freq_before_jump;
150 u8 rds_mode;
151 u8 af_mode;
152 struct tuned_station_info stat_info;
153 struct fm_rds rds;
154 };
155
156 #define FMTX_RDS_TXT_STR_SIZE 25
157
158
159
160
161
162
163
164
165 struct tx_rds {
166 u8 text_type;
167 u8 text[FMTX_RDS_TXT_STR_SIZE];
168 u8 flag;
169 u32 af_freq;
170 };
171
172
173
174
175
176
177
178
179 struct fmtx_data {
180 u8 pwr_lvl;
181 u8 xmit_state;
182 u8 audio_io;
183 u8 region;
184 u16 aud_mode;
185 u32 preemph;
186 u32 tx_frq;
187 struct tx_rds rds;
188 };
189
190
191 struct fmdev {
192 struct video_device *radio_dev;
193 struct v4l2_device v4l2_dev;
194 struct snd_card *card;
195 u16 asci_id;
196 spinlock_t rds_buff_lock;
197 spinlock_t resp_skb_lock;
198
199 long flag;
200 int streg_cbdata;
201
202 struct sk_buff_head rx_q;
203 struct tasklet_struct rx_task;
204
205 struct sk_buff_head tx_q;
206 struct tasklet_struct tx_task;
207 unsigned long last_tx_jiffies;
208 atomic_t tx_cnt;
209
210 struct sk_buff *resp_skb;
211
212 struct completion maintask_comp;
213
214 u8 pre_op;
215
216 struct completion *resp_comp;
217 struct fm_irq irq_info;
218 u8 curr_fmmode;
219 struct fm_rx rx;
220 struct fmtx_data tx_data;
221
222
223 struct v4l2_ctrl_handler ctrl_handler;
224
225
226 struct mutex mutex;
227 };
228 #endif