Path: blob/master/drivers/media/radio/wl128x/fmdrv.h
15112 views
/*1* FM Driver for Connectivity chip of Texas Instruments.2*3* Common header for all FM driver sub-modules.4*5* Copyright (C) 2011 Texas Instruments6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*20*/2122#ifndef _FM_DRV_H23#define _FM_DRV_H2425#include <linux/skbuff.h>26#include <linux/interrupt.h>27#include <sound/core.h>28#include <sound/initval.h>29#include <linux/timer.h>30#include <linux/version.h>31#include <media/v4l2-ioctl.h>32#include <media/v4l2-common.h>33#include <media/v4l2-ctrls.h>3435#define FM_DRV_VERSION "0.10"36/* Should match with FM_DRV_VERSION */37#define FM_DRV_RADIO_VERSION KERNEL_VERSION(0, 0, 1)38#define FM_DRV_NAME "ti_fmdrv"39#define FM_DRV_CARD_SHORT_NAME "TI FM Radio"40#define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio"4142/* Flag info */43#define FM_INTTASK_RUNNING 044#define FM_INTTASK_SCHEDULE_PENDING 145#define FM_FW_DW_INPROGRESS 246#define FM_CORE_READY 347#define FM_CORE_TRANSPORT_READY 448#define FM_AF_SWITCH_INPROGRESS 549#define FM_CORE_TX_XMITING 65051#define FM_TUNE_COMPLETE 0x152#define FM_BAND_LIMIT 0x25354#define FM_DRV_TX_TIMEOUT (5*HZ) /* 5 seconds */55#define FM_DRV_RX_SEEK_TIMEOUT (20*HZ) /* 20 seconds */5657#define fmerr(format, ...) \58printk(KERN_ERR "fmdrv: " format, ## __VA_ARGS__)59#define fmwarn(format, ...) \60printk(KERN_WARNING "fmdrv: " format, ##__VA_ARGS__)61#ifdef DEBUG62#define fmdbg(format, ...) \63printk(KERN_DEBUG "fmdrv: " format, ## __VA_ARGS__)64#else /* DEBUG */65#define fmdbg(format, ...)66#endif67enum {68FM_MODE_OFF,69FM_MODE_TX,70FM_MODE_RX,71FM_MODE_ENTRY_MAX72};7374#define FM_RX_RDS_INFO_FIELD_MAX 8 /* 4 Group * 2 Bytes */7576/* RX RDS data format */77struct fm_rdsdata_format {78union {79struct {80u8 buff[FM_RX_RDS_INFO_FIELD_MAX];81} groupdatabuff;82struct {83u16 pidata;84u8 blk_b[2];85u8 blk_c[2];86u8 blk_d[2];87} groupgeneral;88struct {89u16 pidata;90u8 blk_b[2];91u8 af[2];92u8 ps[2];93} group0A;94struct {95u16 pi[2];96u8 blk_b[2];97u8 ps[2];98} group0B;99} data;100};101102/* FM region (Europe/US, Japan) info */103struct region_info {104u32 chanl_space;105u32 bot_freq;106u32 top_freq;107u8 fm_band;108};109struct fmdev;110typedef void (*int_handler_prototype) (struct fmdev *);111112/* FM Interrupt processing related info */113struct fm_irq {114u8 stage;115u16 flag; /* FM interrupt flag */116u16 mask; /* FM interrupt mask */117/* Interrupt process timeout handler */118struct timer_list timer;119u8 retry;120int_handler_prototype *handlers;121};122123/* RDS info */124struct fm_rds {125u8 flag; /* RX RDS on/off status */126u8 last_blk_idx; /* Last received RDS block */127128/* RDS buffer */129wait_queue_head_t read_queue;130u32 buf_size; /* Size is always multiple of 3 */131u32 wr_idx;132u32 rd_idx;133u8 *buff;134};135136#define FM_RDS_MAX_AF_LIST 25137138/*139* Current RX channel Alternate Frequency cache.140* This info is used to switch to other freq (AF)141* when current channel signal strengh is below RSSI threshold.142*/143struct tuned_station_info {144u16 picode;145u32 af_cache[FM_RDS_MAX_AF_LIST];146u8 afcache_size;147u8 af_list_max;148};149150/* FM RX mode info */151struct fm_rx {152struct region_info region; /* Current selected band */153u32 freq; /* Current RX frquency */154u8 mute_mode; /* Current mute mode */155u8 deemphasis_mode; /* Current deemphasis mode */156/* RF dependent soft mute mode */157u8 rf_depend_mute;158u16 volume; /* Current volume level */159u16 rssi_threshold; /* Current RSSI threshold level */160/* Holds the index of the current AF jump */161u8 afjump_idx;162/* Will hold the frequency before the jump */163u32 freq_before_jump;164u8 rds_mode; /* RDS operation mode (RDS/RDBS) */165u8 af_mode; /* Alternate frequency on/off */166struct tuned_station_info stat_info;167struct fm_rds rds;168};169170#define FMTX_RDS_TXT_STR_SIZE 25171/*172* FM TX RDS data173*174* @ text_type: is the text following PS or RT175* @ text: radio text string which could either be PS or RT176* @ af_freq: alternate frequency for Tx177* TODO: to be declared in application178*/179struct tx_rds {180u8 text_type;181u8 text[FMTX_RDS_TXT_STR_SIZE];182u8 flag;183u32 af_freq;184};185/*186* FM TX global data187*188* @ pwr_lvl: Power Level of the Transmission from mixer control189* @ xmit_state: Transmission state = Updated locally upon Start/Stop190* @ audio_io: i2S/Analog191* @ tx_frq: Transmission frequency192*/193struct fmtx_data {194u8 pwr_lvl;195u8 xmit_state;196u8 audio_io;197u8 region;198u16 aud_mode;199u32 preemph;200u32 tx_frq;201struct tx_rds rds;202};203204/* FM driver operation structure */205struct fmdev {206struct video_device *radio_dev; /* V4L2 video device pointer */207struct snd_card *card; /* Card which holds FM mixer controls */208u16 asci_id;209spinlock_t rds_buff_lock; /* To protect access to RDS buffer */210spinlock_t resp_skb_lock; /* To protect access to received SKB */211212long flag; /* FM driver state machine info */213u8 streg_cbdata; /* status of ST registration */214215struct sk_buff_head rx_q; /* RX queue */216struct tasklet_struct rx_task; /* RX Tasklet */217218struct sk_buff_head tx_q; /* TX queue */219struct tasklet_struct tx_task; /* TX Tasklet */220unsigned long last_tx_jiffies; /* Timestamp of last pkt sent */221atomic_t tx_cnt; /* Number of packets can send at a time */222223struct sk_buff *resp_skb; /* Response from the chip */224/* Main task completion handler */225struct completion maintask_comp;226/* Opcode of last command sent to the chip */227u8 pre_op;228/* Handler used for wakeup when response packet is received */229struct completion *resp_comp;230struct fm_irq irq_info;231u8 curr_fmmode; /* Current FM chip mode (TX, RX, OFF) */232struct fm_rx rx; /* FM receiver info */233struct fmtx_data tx_data;234235/* V4L2 ctrl framwork handler*/236struct v4l2_ctrl_handler ctrl_handler;237238/* For core assisted locking */239struct mutex mutex;240};241#endif242243244