Path: blob/master/drivers/media/common/tuners/tda18271-priv.h
15112 views
/*1tda18271-priv.h - private header for the NXP TDA18271 silicon tuner23Copyright (C) 2007, 2008 Michael Krufky <[email protected]>45This program is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation; either version 2 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program; if not, write to the Free Software17Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.18*/1920#ifndef __TDA18271_PRIV_H__21#define __TDA18271_PRIV_H__2223#include <linux/kernel.h>24#include <linux/types.h>25#include <linux/mutex.h>26#include "tuner-i2c.h"27#include "tda18271.h"2829#define R_ID 0x00 /* ID byte */30#define R_TM 0x01 /* Thermo byte */31#define R_PL 0x02 /* Power level byte */32#define R_EP1 0x03 /* Easy Prog byte 1 */33#define R_EP2 0x04 /* Easy Prog byte 2 */34#define R_EP3 0x05 /* Easy Prog byte 3 */35#define R_EP4 0x06 /* Easy Prog byte 4 */36#define R_EP5 0x07 /* Easy Prog byte 5 */37#define R_CPD 0x08 /* Cal Post-Divider byte */38#define R_CD1 0x09 /* Cal Divider byte 1 */39#define R_CD2 0x0a /* Cal Divider byte 2 */40#define R_CD3 0x0b /* Cal Divider byte 3 */41#define R_MPD 0x0c /* Main Post-Divider byte */42#define R_MD1 0x0d /* Main Divider byte 1 */43#define R_MD2 0x0e /* Main Divider byte 2 */44#define R_MD3 0x0f /* Main Divider byte 3 */45#define R_EB1 0x10 /* Extended byte 1 */46#define R_EB2 0x11 /* Extended byte 2 */47#define R_EB3 0x12 /* Extended byte 3 */48#define R_EB4 0x13 /* Extended byte 4 */49#define R_EB5 0x14 /* Extended byte 5 */50#define R_EB6 0x15 /* Extended byte 6 */51#define R_EB7 0x16 /* Extended byte 7 */52#define R_EB8 0x17 /* Extended byte 8 */53#define R_EB9 0x18 /* Extended byte 9 */54#define R_EB10 0x19 /* Extended byte 10 */55#define R_EB11 0x1a /* Extended byte 11 */56#define R_EB12 0x1b /* Extended byte 12 */57#define R_EB13 0x1c /* Extended byte 13 */58#define R_EB14 0x1d /* Extended byte 14 */59#define R_EB15 0x1e /* Extended byte 15 */60#define R_EB16 0x1f /* Extended byte 16 */61#define R_EB17 0x20 /* Extended byte 17 */62#define R_EB18 0x21 /* Extended byte 18 */63#define R_EB19 0x22 /* Extended byte 19 */64#define R_EB20 0x23 /* Extended byte 20 */65#define R_EB21 0x24 /* Extended byte 21 */66#define R_EB22 0x25 /* Extended byte 22 */67#define R_EB23 0x26 /* Extended byte 23 */6869#define TDA18271_NUM_REGS 397071/*---------------------------------------------------------------------*/7273struct tda18271_rf_tracking_filter_cal {74u32 rfmax;75u8 rfband;76u32 rf1_def;77u32 rf2_def;78u32 rf3_def;79u32 rf1;80u32 rf2;81u32 rf3;82s32 rf_a1;83s32 rf_b1;84s32 rf_a2;85s32 rf_b2;86};8788enum tda18271_pll {89TDA18271_MAIN_PLL,90TDA18271_CAL_PLL,91};9293struct tda18271_map_layout;9495enum tda18271_ver {96TDA18271HDC1,97TDA18271HDC2,98};99100struct tda18271_priv {101unsigned char tda18271_regs[TDA18271_NUM_REGS];102103struct list_head hybrid_tuner_instance_list;104struct tuner_i2c_props i2c_props;105106enum tda18271_mode mode;107enum tda18271_role role;108enum tda18271_i2c_gate gate;109enum tda18271_ver id;110enum tda18271_output_options output_opt;111enum tda18271_small_i2c small_i2c;112113unsigned int config; /* interface to saa713x / tda829x */114unsigned int cal_initialized:1;115116u8 tm_rfcal;117118struct tda18271_map_layout *maps;119struct tda18271_std_map std;120struct tda18271_rf_tracking_filter_cal rf_cal_state[8];121122struct mutex lock;123124u32 frequency;125u32 bandwidth;126};127128/*---------------------------------------------------------------------*/129130extern int tda18271_debug;131132#define DBG_INFO 1133#define DBG_MAP 2134#define DBG_REG 4135#define DBG_ADV 8136#define DBG_CAL 16137138#define tda_printk(st, kern, fmt, arg...) do {\139if (st) { \140struct tda18271_priv *state = st; \141printk(kern "%s: [%d-%04x|%s] " fmt, __func__, \142i2c_adapter_id(state->i2c_props.adap), \143state->i2c_props.addr, \144(state->role == TDA18271_MASTER) \145? "M" : "S", ##arg); \146} else \147printk(kern "%s: " fmt, __func__, ##arg); \148} while (0)149150#define tda_dprintk(st, lvl, fmt, arg...) do {\151if (tda18271_debug & lvl) \152tda_printk(st, KERN_DEBUG, fmt, ##arg); } while (0)153154#define tda_info(fmt, arg...) printk(KERN_INFO fmt, ##arg)155#define tda_warn(fmt, arg...) tda_printk(priv, KERN_WARNING, fmt, ##arg)156#define tda_err(fmt, arg...) tda_printk(priv, KERN_ERR, fmt, ##arg)157#define tda_dbg(fmt, arg...) tda_dprintk(priv, DBG_INFO, fmt, ##arg)158#define tda_map(fmt, arg...) tda_dprintk(priv, DBG_MAP, fmt, ##arg)159#define tda_reg(fmt, arg...) tda_dprintk(priv, DBG_REG, fmt, ##arg)160#define tda_cal(fmt, arg...) tda_dprintk(priv, DBG_CAL, fmt, ##arg)161162#define tda_fail(ret) \163({ \164int __ret; \165__ret = (ret < 0); \166if (__ret) \167tda_printk(priv, KERN_ERR, \168"error %d on line %d\n", ret, __LINE__); \169__ret; \170})171172/*---------------------------------------------------------------------*/173174enum tda18271_map_type {175/* tda18271_pll_map */176MAIN_PLL,177CAL_PLL,178/* tda18271_map */179RF_CAL,180RF_CAL_KMCO,181RF_CAL_DC_OVER_DT,182BP_FILTER,183RF_BAND,184GAIN_TAPER,185IR_MEASURE,186};187188extern int tda18271_lookup_pll_map(struct dvb_frontend *fe,189enum tda18271_map_type map_type,190u32 *freq, u8 *post_div, u8 *div);191extern int tda18271_lookup_map(struct dvb_frontend *fe,192enum tda18271_map_type map_type,193u32 *freq, u8 *val);194195extern int tda18271_lookup_thermometer(struct dvb_frontend *fe);196197extern int tda18271_lookup_rf_band(struct dvb_frontend *fe,198u32 *freq, u8 *rf_band);199200extern int tda18271_lookup_cid_target(struct dvb_frontend *fe,201u32 *freq, u8 *cid_target,202u16 *count_limit);203204extern int tda18271_assign_map_layout(struct dvb_frontend *fe);205206/*---------------------------------------------------------------------*/207208extern int tda18271_read_regs(struct dvb_frontend *fe);209extern int tda18271_read_extended(struct dvb_frontend *fe);210extern int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len);211extern int tda18271_init_regs(struct dvb_frontend *fe);212213extern int tda18271_charge_pump_source(struct dvb_frontend *fe,214enum tda18271_pll pll, int force);215extern int tda18271_set_standby_mode(struct dvb_frontend *fe,216int sm, int sm_lt, int sm_xt);217218extern int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq);219extern int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq);220221extern int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq);222extern int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq);223extern int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq);224extern int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq);225extern int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq);226extern int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq);227228#endif /* __TDA18271_PRIV_H__ */229230/*231* Overrides for Emacs so that we follow Linus's tabbing style.232* ---------------------------------------------------------------------------233* Local variables:234* c-basic-offset: 8235* End:236*/237238239