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