diff options
author | Manjunatha Halli <manjunatha_halli@ti.com> | 2011-01-11 04:33:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:32:35 -0400 |
commit | 8d19824ba2ef37ff989bee5941c87b45c4c6f468 (patch) | |
tree | f6af459b90cbce4b4b40409c578a0e9e6f0d5a9c | |
parent | 7fd4b41f053681cccf188cc1731ae43fe38fa969 (diff) |
[media] drivers:media:radio: wl128x: FM Driver common header file
These are common headers used in FM submodules (FM V4L2,
FM common, FM Rx,and FM TX).
Signed-off-by: Manjunatha Halli <manjunatha_halli@ti.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/radio/wl128x/fmdrv.h | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h new file mode 100644 index 000000000000..5db6fd14cf3c --- /dev/null +++ b/drivers/media/radio/wl128x/fmdrv.h | |||
@@ -0,0 +1,244 @@ | |||
1 | /* | ||
2 | * FM Driver for Connectivity chip of Texas Instruments. | ||
3 | * | ||
4 | * Common header for all FM driver sub-modules. | ||
5 | * | ||
6 | * Copyright (C) 2011 Texas Instruments | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
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 <linux/version.h> | ||
32 | #include <media/v4l2-ioctl.h> | ||
33 | #include <media/v4l2-common.h> | ||
34 | #include <media/v4l2-ctrls.h> | ||
35 | |||
36 | #define FM_DRV_VERSION "0.10" | ||
37 | /* Should match with FM_DRV_VERSION */ | ||
38 | #define FM_DRV_RADIO_VERSION KERNEL_VERSION(0, 0, 1) | ||
39 | #define FM_DRV_NAME "ti_fmdrv" | ||
40 | #define FM_DRV_CARD_SHORT_NAME "TI FM Radio" | ||
41 | #define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio" | ||
42 | |||
43 | /* Flag info */ | ||
44 | #define FM_INTTASK_RUNNING 0 | ||
45 | #define FM_INTTASK_SCHEDULE_PENDING 1 | ||
46 | #define FM_FW_DW_INPROGRESS 2 | ||
47 | #define FM_CORE_READY 3 | ||
48 | #define FM_CORE_TRANSPORT_READY 4 | ||
49 | #define FM_AF_SWITCH_INPROGRESS 5 | ||
50 | #define FM_CORE_TX_XMITING 6 | ||
51 | |||
52 | #define FM_TUNE_COMPLETE 0x1 | ||
53 | #define FM_BAND_LIMIT 0x2 | ||
54 | |||
55 | #define FM_DRV_TX_TIMEOUT (5*HZ) /* 5 seconds */ | ||
56 | #define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */ | ||
57 | |||
58 | #define NO_OF_ENTRIES_IN_ARRAY(array) (sizeof(array) / sizeof(array[0])) | ||
59 | |||
60 | #define fmerr(format, ...) \ | ||
61 | printk(KERN_ERR "fmdrv: " format, ## __VA_ARGS__) | ||
62 | #define fmwarn(format, ...) \ | ||
63 | printk(KERN_WARNING "fmdrv: " format, ##__VA_ARGS__) | ||
64 | #ifdef DEBUG | ||
65 | #define fmdbg(format, ...) \ | ||
66 | printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__) | ||
67 | #else /* DEBUG */ | ||
68 | #define fmdbg(format, ...) | ||
69 | #endif | ||
70 | enum { | ||
71 | FM_MODE_OFF, | ||
72 | FM_MODE_TX, | ||
73 | FM_MODE_RX, | ||
74 | FM_MODE_ENTRY_MAX | ||
75 | }; | ||
76 | |||
77 | #define FM_RX_RDS_INFO_FIELD_MAX 8 /* 4 Group * 2 Bytes */ | ||
78 | |||
79 | /* RX RDS data format */ | ||
80 | struct fm_rdsdata_format { | ||
81 | union { | ||
82 | struct { | ||
83 | u8 buff[FM_RX_RDS_INFO_FIELD_MAX]; | ||
84 | } groupdatabuff; | ||
85 | struct { | ||
86 | u16 pidata; | ||
87 | u8 blk_b[2]; | ||
88 | u8 blk_c[2]; | ||
89 | u8 blk_d[2]; | ||
90 | } groupgeneral; | ||
91 | struct { | ||
92 | u16 pidata; | ||
93 | u8 blk_b[2]; | ||
94 | u8 af[2]; | ||
95 | u8 ps[2]; | ||
96 | } group0A; | ||
97 | struct { | ||
98 | u16 pi[2]; | ||
99 | u8 blk_b[2]; | ||
100 | u8 ps[2]; | ||
101 | } group0B; | ||
102 | } data; | ||
103 | }; | ||
104 | |||
105 | /* FM region (Europe/US, Japan) info */ | ||
106 | struct region_info { | ||
107 | u32 chanl_space; | ||
108 | u32 bot_freq; | ||
109 | u32 top_freq; | ||
110 | u8 fm_band; | ||
111 | }; | ||
112 | struct fmdev; | ||
113 | typedef void (*int_handler_prototype) (struct fmdev *); | ||
114 | |||
115 | /* FM Interrupt processing related info */ | ||
116 | struct fm_irq { | ||
117 | u8 stage; | ||
118 | u16 flag; /* FM interrupt flag */ | ||
119 | u16 mask; /* FM interrupt mask */ | ||
120 | /* Interrupt process timeout handler */ | ||
121 | struct timer_list timer; | ||
122 | u8 retry; | ||
123 | int_handler_prototype *handlers; | ||
124 | }; | ||
125 | |||
126 | /* RDS info */ | ||
127 | struct fm_rds { | ||
128 | u8 flag; /* RX RDS on/off status */ | ||
129 | u8 last_blk_idx; /* Last received RDS block */ | ||
130 | |||
131 | /* RDS buffer */ | ||
132 | wait_queue_head_t read_queue; | ||
133 | u32 buf_size; /* Size is always multiple of 3 */ | ||
134 | u32 wr_idx; | ||
135 | u32 rd_idx; | ||
136 | u8 *buff; | ||
137 | }; | ||
138 | |||
139 | #define FM_RDS_MAX_AF_LIST 25 | ||
140 | |||
141 | /* | ||
142 | * Current RX channel Alternate Frequency cache. | ||
143 | * This info is used to switch to other freq (AF) | ||
144 | * when current channel signal strengh is below RSSI threshold. | ||
145 | */ | ||
146 | struct tuned_station_info { | ||
147 | u16 picode; | ||
148 | u32 af_cache[FM_RDS_MAX_AF_LIST]; | ||
149 | u8 afcache_size; | ||
150 | u8 af_list_max; | ||
151 | }; | ||
152 | |||
153 | /* FM RX mode info */ | ||
154 | struct fm_rx { | ||
155 | struct region_info region; /* Current selected band */ | ||
156 | u32 freq; /* Current RX frquency */ | ||
157 | u8 mute_mode; /* Current mute mode */ | ||
158 | u8 deemphasis_mode; /* Current deemphasis mode */ | ||
159 | /* RF dependent soft mute mode */ | ||
160 | u8 rf_depend_mute; | ||
161 | u16 volume; /* Current volume level */ | ||
162 | u16 rssi_threshold; /* Current RSSI threshold level */ | ||
163 | /* Holds the index of the current AF jump */ | ||
164 | u8 afjump_idx; | ||
165 | /* Will hold the frequency before the jump */ | ||
166 | u32 freq_before_jump; | ||
167 | u8 rds_mode; /* RDS operation mode (RDS/RDBS) */ | ||
168 | u8 af_mode; /* Alternate frequency on/off */ | ||
169 | struct tuned_station_info stat_info; | ||
170 | struct fm_rds rds; | ||
171 | }; | ||
172 | |||
173 | #define FMTX_RDS_TXT_STR_SIZE 25 | ||
174 | /* | ||
175 | * FM TX RDS data | ||
176 | * | ||
177 | * @ text_type: is the text following PS or RT | ||
178 | * @ text: radio text string which could either be PS or RT | ||
179 | * @ af_freq: alternate frequency for Tx | ||
180 | * TODO: to be declared in application | ||
181 | */ | ||
182 | struct tx_rds { | ||
183 | u8 text_type; | ||
184 | u8 text[FMTX_RDS_TXT_STR_SIZE]; | ||
185 | u8 flag; | ||
186 | u32 af_freq; | ||
187 | }; | ||
188 | /* | ||
189 | * FM TX global data | ||
190 | * | ||
191 | * @ pwr_lvl: Power Level of the Transmission from mixer control | ||
192 | * @ xmit_state: Transmission state = Updated locally upon Start/Stop | ||
193 | * @ audio_io: i2S/Analog | ||
194 | * @ tx_frq: Transmission frequency | ||
195 | */ | ||
196 | struct fmtx_data { | ||
197 | u8 pwr_lvl; | ||
198 | u8 xmit_state; | ||
199 | u8 audio_io; | ||
200 | u8 region; | ||
201 | u16 aud_mode; | ||
202 | u32 preemph; | ||
203 | u32 tx_frq; | ||
204 | struct tx_rds rds; | ||
205 | }; | ||
206 | |||
207 | /* FM driver operation structure */ | ||
208 | struct fmdev { | ||
209 | struct video_device *radio_dev; /* V4L2 video device pointer */ | ||
210 | struct snd_card *card; /* Card which holds FM mixer controls */ | ||
211 | u16 asci_id; | ||
212 | spinlock_t rds_buff_lock; /* To protect access to RDS buffer */ | ||
213 | spinlock_t resp_skb_lock; /* To protect access to received SKB */ | ||
214 | |||
215 | long flag; /* FM driver state machine info */ | ||
216 | u8 streg_cbdata; /* status of ST registration */ | ||
217 | |||
218 | struct sk_buff_head rx_q; /* RX queue */ | ||
219 | struct tasklet_struct rx_task; /* RX Tasklet */ | ||
220 | |||
221 | struct sk_buff_head tx_q; /* TX queue */ | ||
222 | struct tasklet_struct tx_task; /* TX Tasklet */ | ||
223 | unsigned long last_tx_jiffies; /* Timestamp of last pkt sent */ | ||
224 | atomic_t tx_cnt; /* Number of packets can send at a time */ | ||
225 | |||
226 | struct sk_buff *resp_skb; /* Response from the chip */ | ||
227 | /* Main task completion handler */ | ||
228 | struct completion maintask_comp; | ||
229 | /* Opcode of last command sent to the chip */ | ||
230 | u8 pre_op; | ||
231 | /* Handler used for wakeup when response packet is received */ | ||
232 | struct completion *resp_comp; | ||
233 | struct fm_irq irq_info; | ||
234 | u8 curr_fmmode; /* Current FM chip mode (TX, RX, OFF) */ | ||
235 | struct fm_rx rx; /* FM receiver info */ | ||
236 | struct fmtx_data tx_data; | ||
237 | |||
238 | /* V4L2 ctrl framwork handler*/ | ||
239 | struct v4l2_ctrl_handler ctrl_handler; | ||
240 | |||
241 | /* For core assisted locking */ | ||
242 | struct mutex mutex; | ||
243 | }; | ||
244 | #endif | ||