0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _FM_DRV_H
0011 #define _FM_DRV_H
0012
0013 #include <linux/skbuff.h>
0014 #include <linux/interrupt.h>
0015 #include <sound/core.h>
0016 #include <sound/initval.h>
0017 #include <linux/timer.h>
0018 #include <media/v4l2-ioctl.h>
0019 #include <media/v4l2-common.h>
0020 #include <media/v4l2-device.h>
0021 #include <media/v4l2-ctrls.h>
0022
0023 #define FM_DRV_VERSION "0.1.1"
0024 #define FM_DRV_NAME "ti_fmdrv"
0025 #define FM_DRV_CARD_SHORT_NAME "TI FM Radio"
0026 #define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio"
0027
0028
0029 #define FM_INTTASK_RUNNING 0
0030 #define FM_INTTASK_SCHEDULE_PENDING 1
0031 #define FM_FW_DW_INPROGRESS 2
0032 #define FM_CORE_READY 3
0033 #define FM_CORE_TRANSPORT_READY 4
0034 #define FM_AF_SWITCH_INPROGRESS 5
0035 #define FM_CORE_TX_XMITING 6
0036
0037 #define FM_TUNE_COMPLETE 0x1
0038 #define FM_BAND_LIMIT 0x2
0039
0040 #define FM_DRV_TX_TIMEOUT (5*HZ)
0041 #define FM_DRV_RX_SEEK_TIMEOUT (20*HZ)
0042
0043 #define fmerr(format, ...) \
0044 printk(KERN_ERR "fmdrv: " format, ## __VA_ARGS__)
0045 #define fmwarn(format, ...) \
0046 printk(KERN_WARNING "fmdrv: " format, ##__VA_ARGS__)
0047 #ifdef DEBUG
0048 #define fmdbg(format, ...) \
0049 printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__)
0050 #else
0051 #define fmdbg(format, ...) do {} while(0)
0052 #endif
0053 enum {
0054 FM_MODE_OFF,
0055 FM_MODE_TX,
0056 FM_MODE_RX,
0057 FM_MODE_ENTRY_MAX
0058 };
0059
0060 #define FM_RX_RDS_INFO_FIELD_MAX 8
0061
0062
0063 struct fm_rdsdata_format {
0064 union {
0065 struct {
0066 u8 buff[FM_RX_RDS_INFO_FIELD_MAX];
0067 } groupdatabuff;
0068 struct {
0069 u16 pidata;
0070 u8 blk_b[2];
0071 u8 blk_c[2];
0072 u8 blk_d[2];
0073 } groupgeneral;
0074 struct {
0075 u16 pidata;
0076 u8 blk_b[2];
0077 u8 af[2];
0078 u8 ps[2];
0079 } group0A;
0080 struct {
0081 u16 pi[2];
0082 u8 blk_b[2];
0083 u8 ps[2];
0084 } group0B;
0085 } data;
0086 };
0087
0088
0089 struct region_info {
0090 u32 chanl_space;
0091 u32 bot_freq;
0092 u32 top_freq;
0093 u8 fm_band;
0094 };
0095 struct fmdev;
0096 typedef void (*int_handler_prototype) (struct fmdev *);
0097
0098
0099 struct fm_irq {
0100 u8 stage;
0101 u16 flag;
0102 u16 mask;
0103
0104 struct timer_list timer;
0105 u8 retry;
0106 int_handler_prototype *handlers;
0107 };
0108
0109
0110 struct fm_rds {
0111 u8 flag;
0112 u8 last_blk_idx;
0113
0114
0115 wait_queue_head_t read_queue;
0116 u32 buf_size;
0117 u32 wr_idx;
0118 u32 rd_idx;
0119 u8 *buff;
0120 };
0121
0122 #define FM_RDS_MAX_AF_LIST 25
0123
0124
0125
0126
0127
0128
0129 struct tuned_station_info {
0130 u16 picode;
0131 u32 af_cache[FM_RDS_MAX_AF_LIST];
0132 u8 afcache_size;
0133 u8 af_list_max;
0134 };
0135
0136
0137 struct fm_rx {
0138 struct region_info region;
0139 u32 freq;
0140 u8 mute_mode;
0141 u8 deemphasis_mode;
0142
0143 u8 rf_depend_mute;
0144 u16 volume;
0145 u16 rssi_threshold;
0146
0147 u8 afjump_idx;
0148
0149 u32 freq_before_jump;
0150 u8 rds_mode;
0151 u8 af_mode;
0152 struct tuned_station_info stat_info;
0153 struct fm_rds rds;
0154 };
0155
0156 #define FMTX_RDS_TXT_STR_SIZE 25
0157
0158
0159
0160
0161
0162
0163
0164
0165 struct tx_rds {
0166 u8 text_type;
0167 u8 text[FMTX_RDS_TXT_STR_SIZE];
0168 u8 flag;
0169 u32 af_freq;
0170 };
0171
0172
0173
0174
0175
0176
0177
0178
0179 struct fmtx_data {
0180 u8 pwr_lvl;
0181 u8 xmit_state;
0182 u8 audio_io;
0183 u8 region;
0184 u16 aud_mode;
0185 u32 preemph;
0186 u32 tx_frq;
0187 struct tx_rds rds;
0188 };
0189
0190
0191 struct fmdev {
0192 struct video_device *radio_dev;
0193 struct v4l2_device v4l2_dev;
0194 struct snd_card *card;
0195 u16 asci_id;
0196 spinlock_t rds_buff_lock;
0197 spinlock_t resp_skb_lock;
0198
0199 long flag;
0200 int streg_cbdata;
0201
0202 struct sk_buff_head rx_q;
0203 struct tasklet_struct rx_task;
0204
0205 struct sk_buff_head tx_q;
0206 struct tasklet_struct tx_task;
0207 unsigned long last_tx_jiffies;
0208 atomic_t tx_cnt;
0209
0210 struct sk_buff *resp_skb;
0211
0212 struct completion maintask_comp;
0213
0214 u8 pre_op;
0215
0216 struct completion *resp_comp;
0217 struct fm_irq irq_info;
0218 u8 curr_fmmode;
0219 struct fm_rx rx;
0220 struct fmtx_data tx_data;
0221
0222
0223 struct v4l2_ctrl_handler ctrl_handler;
0224
0225
0226 struct mutex mutex;
0227 };
0228 #endif