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