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