Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fmdrv.h
Go to the documentation of this file.
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 <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 /* Flag info */
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) /* 5 seconds */
53 #define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */
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 /* DEBUG */
63 #define fmdbg(format, ...)
64 #endif
65 enum {
70 };
71 
72 #define FM_RX_RDS_INFO_FIELD_MAX 8 /* 4 Group * 2 Bytes */
73 
74 /* RX RDS data format */
76  union {
77  struct {
79  } groupdatabuff;
80  struct {
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 /* FM region (Europe/US, Japan) info */
101 struct region_info {
106 };
107 struct fmdev;
108 typedef void (*int_handler_prototype) (struct fmdev *);
109 
110 /* FM Interrupt processing related info */
111 struct fm_irq {
113  u16 flag; /* FM interrupt flag */
114  u16 mask; /* FM interrupt mask */
115  /* Interrupt process timeout handler */
119 };
120 
121 /* RDS info */
122 struct fm_rds {
123  u8 flag; /* RX RDS on/off status */
124  u8 last_blk_idx; /* Last received RDS block */
125 
126  /* RDS buffer */
128  u32 buf_size; /* Size is always multiple of 3 */
132 };
133 
134 #define FM_RDS_MAX_AF_LIST 25
135 
136 /*
137  * Current RX channel Alternate Frequency cache.
138  * This info is used to switch to other freq (AF)
139  * when current channel signal strengh is below RSSI threshold.
140  */
146 };
147 
148 /* FM RX mode info */
149 struct fm_rx {
150  struct region_info region; /* Current selected band */
151  u32 freq; /* Current RX frquency */
152  u8 mute_mode; /* Current mute mode */
153  u8 deemphasis_mode; /* Current deemphasis mode */
154  /* RF dependent soft mute mode */
156  u16 volume; /* Current volume level */
157  u16 rssi_threshold; /* Current RSSI threshold level */
158  /* Holds the index of the current AF jump */
160  /* Will hold the frequency before the jump */
162  u8 rds_mode; /* RDS operation mode (RDS/RDBS) */
163  u8 af_mode; /* Alternate frequency on/off */
165  struct fm_rds rds;
166 };
167 
168 #define FMTX_RDS_TXT_STR_SIZE 25
169 /*
170  * FM TX RDS data
171  *
172  * @ text_type: is the text following PS or RT
173  * @ text: radio text string which could either be PS or RT
174  * @ af_freq: alternate frequency for Tx
175  * TODO: to be declared in application
176  */
177 struct tx_rds {
182 };
183 /*
184  * FM TX global data
185  *
186  * @ pwr_lvl: Power Level of the Transmission from mixer control
187  * @ xmit_state: Transmission state = Updated locally upon Start/Stop
188  * @ audio_io: i2S/Analog
189  * @ tx_frq: Transmission frequency
190  */
191 struct fmtx_data {
199  struct tx_rds rds;
200 };
201 
202 /* FM driver operation structure */
203 struct fmdev {
204  struct video_device *radio_dev; /* V4L2 video device pointer */
205  struct snd_card *card; /* Card which holds FM mixer controls */
207  spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
208  spinlock_t resp_skb_lock; /* To protect access to received SKB */
209 
210  long flag; /* FM driver state machine info */
211  u8 streg_cbdata; /* status of ST registration */
212 
213  struct sk_buff_head rx_q; /* RX queue */
214  struct tasklet_struct rx_task; /* RX Tasklet */
215 
216  struct sk_buff_head tx_q; /* TX queue */
217  struct tasklet_struct tx_task; /* TX Tasklet */
218  unsigned long last_tx_jiffies; /* Timestamp of last pkt sent */
219  atomic_t tx_cnt; /* Number of packets can send at a time */
220 
221  struct sk_buff *resp_skb; /* Response from the chip */
222  /* Main task completion handler */
224  /* Opcode of last command sent to the chip */
226  /* Handler used for wakeup when response packet is received */
228  struct fm_irq irq_info;
229  u8 curr_fmmode; /* Current FM chip mode (TX, RX, OFF) */
230  struct fm_rx rx; /* FM receiver info */
232 
233  /* V4L2 ctrl framwork handler*/
235 
236  /* For core assisted locking */
237  struct mutex mutex;
238 };
239 #endif