Path: blob/master/drivers/media/dvb/frontends/dib3000mb_priv.h
15112 views
/*1* dib3000mb_priv.h2*3* Copyright (C) 2004 Patrick Boettcher ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License as7* published by the Free Software Foundation, version 2.8*9* for more information see dib3000mb.c .10*/1112#ifndef __DIB3000MB_PRIV_H_INCLUDED__13#define __DIB3000MB_PRIV_H_INCLUDED__1415/* info and err, taken from usb.h, if there is anything available like by default. */16#define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)17#define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)18#define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)1920/* handy shortcuts */21#define rd(reg) dib3000_read_reg(state,reg)2223#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \24{ err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }2526#define wr_foreach(a,v) { int i; \27if (sizeof(a) != sizeof(v)) \28err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\29for (i=0; i < sizeof(a)/sizeof(u16); i++) \30wr(a[i],v[i]); \31}3233#define set_or(reg,val) wr(reg,rd(reg) | val)3435#define set_and(reg,val) wr(reg,rd(reg) & val)3637/* debug */3839#define dprintk(level,args...) \40do { if ((debug & level)) { printk(args); } } while (0)4142/* mask for enabling a specific pid for the pid_filter */43#define DIB3000_ACTIVATE_PID_FILTERING (0x2000)4445/* common values for tuning */46#define DIB3000_ALPHA_0 ( 0)47#define DIB3000_ALPHA_1 ( 1)48#define DIB3000_ALPHA_2 ( 2)49#define DIB3000_ALPHA_4 ( 4)5051#define DIB3000_CONSTELLATION_QPSK ( 0)52#define DIB3000_CONSTELLATION_16QAM ( 1)53#define DIB3000_CONSTELLATION_64QAM ( 2)5455#define DIB3000_GUARD_TIME_1_32 ( 0)56#define DIB3000_GUARD_TIME_1_16 ( 1)57#define DIB3000_GUARD_TIME_1_8 ( 2)58#define DIB3000_GUARD_TIME_1_4 ( 3)5960#define DIB3000_TRANSMISSION_MODE_2K ( 0)61#define DIB3000_TRANSMISSION_MODE_8K ( 1)6263#define DIB3000_SELECT_LP ( 0)64#define DIB3000_SELECT_HP ( 1)6566#define DIB3000_FEC_1_2 ( 1)67#define DIB3000_FEC_2_3 ( 2)68#define DIB3000_FEC_3_4 ( 3)69#define DIB3000_FEC_5_6 ( 5)70#define DIB3000_FEC_7_8 ( 7)7172#define DIB3000_HRCH_OFF ( 0)73#define DIB3000_HRCH_ON ( 1)7475#define DIB3000_DDS_INVERSION_OFF ( 0)76#define DIB3000_DDS_INVERSION_ON ( 1)7778#define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))79#define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))8081#define DIB3000_REG_MANUFACTOR_ID ( 1025)82#define DIB3000_I2C_ID_DIBCOM (0x01b3)8384#define DIB3000_REG_DEVICE_ID ( 1026)85#define DIB3000MB_DEVICE_ID (0x3000)86#define DIB3000MC_DEVICE_ID (0x3001)87#define DIB3000P_DEVICE_ID (0x3002)8889/* frontend state */90struct dib3000_state {91struct i2c_adapter* i2c;9293/* configuration settings */94struct dib3000_config config;9596struct dvb_frontend frontend;97int timing_offset;98int timing_offset_comp_done;99100fe_bandwidth_t last_tuned_bw;101u32 last_tuned_freq;102};103104/* register addresses and some of their default values */105106/* restart subsystems */107#define DIB3000MB_REG_RESTART ( 0)108109#define DIB3000MB_RESTART_OFF ( 0)110#define DIB3000MB_RESTART_AUTO_SEARCH (1 << 1)111#define DIB3000MB_RESTART_CTRL (1 << 2)112#define DIB3000MB_RESTART_AGC (1 << 3)113114/* FFT size */115#define DIB3000MB_REG_FFT ( 1)116117/* Guard time */118#define DIB3000MB_REG_GUARD_TIME ( 2)119120/* QAM */121#define DIB3000MB_REG_QAM ( 3)122123/* Alpha coefficient high priority Viterbi algorithm */124#define DIB3000MB_REG_VIT_ALPHA ( 4)125126/* spectrum inversion */127#define DIB3000MB_REG_DDS_INV ( 5)128129/* DDS frequency value (IF position) ad ? values don't match reg_3000mb.txt */130#define DIB3000MB_REG_DDS_FREQ_MSB ( 6)131#define DIB3000MB_REG_DDS_FREQ_LSB ( 7)132#define DIB3000MB_DDS_FREQ_MSB ( 178)133#define DIB3000MB_DDS_FREQ_LSB ( 8990)134135/* timing frequency (carrier spacing) */136static u16 dib3000mb_reg_timing_freq[] = { 8,9 };137static u16 dib3000mb_timing_freq[][2] = {138{ 126 , 48873 }, /* 6 MHz */139{ 147 , 57019 }, /* 7 MHz */140{ 168 , 65164 }, /* 8 MHz */141};142143/* impulse noise parameter */144/* 36 ??? */145146static u16 dib3000mb_reg_impulse_noise[] = { 10,11,12,15,36 };147148enum dib3000mb_impulse_noise_type {149DIB3000MB_IMPNOISE_OFF,150DIB3000MB_IMPNOISE_MOBILE,151DIB3000MB_IMPNOISE_FIXED,152DIB3000MB_IMPNOISE_DEFAULT153};154155static u16 dib3000mb_impulse_noise_values[][5] = {156{ 0x0000, 0x0004, 0x0014, 0x01ff, 0x0399 }, /* off */157{ 0x0001, 0x0004, 0x0014, 0x01ff, 0x037b }, /* mobile */158{ 0x0001, 0x0004, 0x0020, 0x01bd, 0x0399 }, /* fixed */159{ 0x0000, 0x0002, 0x000a, 0x01ff, 0x0399 }, /* default */160};161162/*163* Dual Automatic-Gain-Control164* - gains RF in tuner (AGC1)165* - gains IF after filtering (AGC2)166*/167168/* also from 16 to 18 */169static u16 dib3000mb_reg_agc_gain[] = {17019,20,21,22,23,24,25,26,27,28,29,30,31,32171};172173static u16 dib3000mb_default_agc_gain[] =174{ 0x0001, 52429, 623, 128, 166, 195, 61, /* RF ??? */1750x0001, 53766, 38011, 0, 90, 33, 23 }; /* IF ??? */176177/* phase noise */178/* 36 is set when setting the impulse noise */179static u16 dib3000mb_reg_phase_noise[] = { 33,34,35,37,38 };180181static u16 dib3000mb_default_noise_phase[] = { 2, 544, 0, 5, 4 };182183/* lock duration */184static u16 dib3000mb_reg_lock_duration[] = { 39,40 };185static u16 dib3000mb_default_lock_duration[] = { 135, 135 };186187/* AGC loop bandwidth */188static u16 dib3000mb_reg_agc_bandwidth[] = { 43,44,45,46,47,48,49,50 };189190static u16 dib3000mb_agc_bandwidth_low[] =191{ 2088, 10, 2088, 10, 3448, 5, 3448, 5 };192static u16 dib3000mb_agc_bandwidth_high[] =193{ 2349, 5, 2349, 5, 2586, 2, 2586, 2 };194195/*196* lock0 definition (coff_lock)197*/198#define DIB3000MB_REG_LOCK0_MASK ( 51)199#define DIB3000MB_LOCK0_DEFAULT ( 4)200201/*202* lock1 definition (cpil_lock)203* for auto search204* which values hide behind the lock masks205*/206#define DIB3000MB_REG_LOCK1_MASK ( 52)207#define DIB3000MB_LOCK1_SEARCH_4 (0x0004)208#define DIB3000MB_LOCK1_SEARCH_2048 (0x0800)209#define DIB3000MB_LOCK1_DEFAULT (0x0001)210211/*212* lock2 definition (fec_lock) */213#define DIB3000MB_REG_LOCK2_MASK ( 53)214#define DIB3000MB_LOCK2_DEFAULT (0x0080)215216/*217* SEQ ? what was that again ... :)218* changes when, inversion, guard time and fft is219* either automatically detected or not220*/221#define DIB3000MB_REG_SEQ ( 54)222223/* bandwidth */224static u16 dib3000mb_reg_bandwidth[] = { 55,56,57,58,59,60,61,62,63,64,65,66,67 };225static u16 dib3000mb_bandwidth_6mhz[] =226{ 0, 33, 53312, 112, 46635, 563, 36565, 0, 1000, 0, 1010, 1, 45264 };227228static u16 dib3000mb_bandwidth_7mhz[] =229{ 0, 28, 64421, 96, 39973, 483, 3255, 0, 1000, 0, 1010, 1, 45264 };230231static u16 dib3000mb_bandwidth_8mhz[] =232{ 0, 25, 23600, 84, 34976, 422, 43808, 0, 1000, 0, 1010, 1, 45264 };233234#define DIB3000MB_REG_UNK_68 ( 68)235#define DIB3000MB_UNK_68 ( 0)236237#define DIB3000MB_REG_UNK_69 ( 69)238#define DIB3000MB_UNK_69 ( 0)239240#define DIB3000MB_REG_UNK_71 ( 71)241#define DIB3000MB_UNK_71 ( 0)242243#define DIB3000MB_REG_UNK_77 ( 77)244#define DIB3000MB_UNK_77 ( 6)245246#define DIB3000MB_REG_UNK_78 ( 78)247#define DIB3000MB_UNK_78 (0x0080)248249/* isi */250#define DIB3000MB_REG_ISI ( 79)251#define DIB3000MB_ISI_ACTIVATE ( 0)252#define DIB3000MB_ISI_INHIBIT ( 1)253254/* sync impovement */255#define DIB3000MB_REG_SYNC_IMPROVEMENT ( 84)256#define DIB3000MB_SYNC_IMPROVE_2K_1_8 ( 3)257#define DIB3000MB_SYNC_IMPROVE_DEFAULT ( 0)258259/* phase noise compensation inhibition */260#define DIB3000MB_REG_PHASE_NOISE ( 87)261#define DIB3000MB_PHASE_NOISE_DEFAULT ( 0)262263#define DIB3000MB_REG_UNK_92 ( 92)264#define DIB3000MB_UNK_92 (0x0080)265266#define DIB3000MB_REG_UNK_96 ( 96)267#define DIB3000MB_UNK_96 (0x0010)268269#define DIB3000MB_REG_UNK_97 ( 97)270#define DIB3000MB_UNK_97 (0x0009)271272/* mobile mode ??? */273#define DIB3000MB_REG_MOBILE_MODE ( 101)274#define DIB3000MB_MOBILE_MODE_ON ( 1)275#define DIB3000MB_MOBILE_MODE_OFF ( 0)276277#define DIB3000MB_REG_UNK_106 ( 106)278#define DIB3000MB_UNK_106 (0x0080)279280#define DIB3000MB_REG_UNK_107 ( 107)281#define DIB3000MB_UNK_107 (0x0080)282283#define DIB3000MB_REG_UNK_108 ( 108)284#define DIB3000MB_UNK_108 (0x0080)285286/* fft */287#define DIB3000MB_REG_UNK_121 ( 121)288#define DIB3000MB_UNK_121_2K ( 7)289#define DIB3000MB_UNK_121_DEFAULT ( 5)290291#define DIB3000MB_REG_UNK_122 ( 122)292#define DIB3000MB_UNK_122 ( 2867)293294/* QAM for mobile mode */295#define DIB3000MB_REG_MOBILE_MODE_QAM ( 126)296#define DIB3000MB_MOBILE_MODE_QAM_64 ( 3)297#define DIB3000MB_MOBILE_MODE_QAM_QPSK_16 ( 1)298#define DIB3000MB_MOBILE_MODE_QAM_OFF ( 0)299300/*301* data diversity when having more than one chip on-board302* see also DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY303*/304#define DIB3000MB_REG_DATA_IN_DIVERSITY ( 127)305#define DIB3000MB_DATA_DIVERSITY_IN_OFF ( 0)306#define DIB3000MB_DATA_DIVERSITY_IN_ON ( 2)307308/* vit hrch */309#define DIB3000MB_REG_VIT_HRCH ( 128)310311/* vit code rate */312#define DIB3000MB_REG_VIT_CODE_RATE ( 129)313314/* vit select hp */315#define DIB3000MB_REG_VIT_HP ( 130)316317/* time frame for Bit-Error-Rate calculation */318#define DIB3000MB_REG_BERLEN ( 135)319#define DIB3000MB_BERLEN_LONG ( 0)320#define DIB3000MB_BERLEN_DEFAULT ( 1)321#define DIB3000MB_BERLEN_MEDIUM ( 2)322#define DIB3000MB_BERLEN_SHORT ( 3)323324/* 142 - 152 FIFO parameters325* which is what ?326*/327328#define DIB3000MB_REG_FIFO_142 ( 142)329#define DIB3000MB_FIFO_142 ( 0)330331/* MPEG2 TS output mode */332#define DIB3000MB_REG_MPEG2_OUT_MODE ( 143)333#define DIB3000MB_MPEG2_OUT_MODE_204 ( 0)334#define DIB3000MB_MPEG2_OUT_MODE_188 ( 1)335336#define DIB3000MB_REG_PID_PARSE ( 144)337#define DIB3000MB_PID_PARSE_INHIBIT ( 0)338#define DIB3000MB_PID_PARSE_ACTIVATE ( 1)339340#define DIB3000MB_REG_FIFO ( 145)341#define DIB3000MB_FIFO_INHIBIT ( 1)342#define DIB3000MB_FIFO_ACTIVATE ( 0)343344#define DIB3000MB_REG_FIFO_146 ( 146)345#define DIB3000MB_FIFO_146 ( 3)346347#define DIB3000MB_REG_FIFO_147 ( 147)348#define DIB3000MB_FIFO_147 (0x0100)349350/*351* pidfilter352* it is not a hardware pidfilter but a filter which drops all pids353* except the ones set. Necessary because of the limited USB1.1 bandwidth.354* regs 153-168355*/356357#define DIB3000MB_REG_FIRST_PID ( 153)358#define DIB3000MB_NUM_PIDS ( 16)359360/*361* output mode362* USB devices have to use 'slave'-mode363* see also DIB3000MB_REG_ELECT_OUT_MODE364*/365#define DIB3000MB_REG_OUTPUT_MODE ( 169)366#define DIB3000MB_OUTPUT_MODE_GATED_CLK ( 0)367#define DIB3000MB_OUTPUT_MODE_CONT_CLK ( 1)368#define DIB3000MB_OUTPUT_MODE_SERIAL ( 2)369#define DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY ( 5)370#define DIB3000MB_OUTPUT_MODE_SLAVE ( 6)371372/* irq event mask */373#define DIB3000MB_REG_IRQ_EVENT_MASK ( 170)374#define DIB3000MB_IRQ_EVENT_MASK ( 0)375376/* filter coefficients */377static u16 dib3000mb_reg_filter_coeffs[] = {378171, 172, 173, 174, 175, 176, 177, 178,379179, 180, 181, 182, 183, 184, 185, 186,380188, 189, 190, 191, 192, 194381};382383static u16 dib3000mb_filter_coeffs[] = {384226, 160, 29,385979, 998, 19,38622, 1019, 1006,3871022, 12, 6,3881017, 1017, 3,3896, 1019,3901021, 2, 3,3911, 0,392};393394/*395* mobile algorithm (when you are moving with your device)396* but not faster than 90 km/h397*/398#define DIB3000MB_REG_MOBILE_ALGO ( 195)399#define DIB3000MB_MOBILE_ALGO_ON ( 0)400#define DIB3000MB_MOBILE_ALGO_OFF ( 1)401402/* multiple demodulators algorithm */403#define DIB3000MB_REG_MULTI_DEMOD_MSB ( 206)404#define DIB3000MB_REG_MULTI_DEMOD_LSB ( 207)405406/* terminator, no more demods */407#define DIB3000MB_MULTI_DEMOD_MSB ( 32767)408#define DIB3000MB_MULTI_DEMOD_LSB ( 4095)409410/* bring the device into a known */411#define DIB3000MB_REG_RESET_DEVICE ( 1024)412#define DIB3000MB_RESET_DEVICE (0x812c)413#define DIB3000MB_RESET_DEVICE_RST ( 0)414415/* hardware clock configuration */416#define DIB3000MB_REG_CLOCK ( 1027)417#define DIB3000MB_CLOCK_DEFAULT (0x9000)418#define DIB3000MB_CLOCK_DIVERSITY (0x92b0)419420/* power down config */421#define DIB3000MB_REG_POWER_CONTROL ( 1028)422#define DIB3000MB_POWER_DOWN ( 1)423#define DIB3000MB_POWER_UP ( 0)424425/* electrical output mode */426#define DIB3000MB_REG_ELECT_OUT_MODE ( 1029)427#define DIB3000MB_ELECT_OUT_MODE_OFF ( 0)428#define DIB3000MB_ELECT_OUT_MODE_ON ( 1)429430/* set the tuner i2c address */431#define DIB3000MB_REG_TUNER ( 1089)432433/* monitoring registers (read only) */434435/* agc loop locked (size: 1) */436#define DIB3000MB_REG_AGC_LOCK ( 324)437438/* agc power (size: 16) */439#define DIB3000MB_REG_AGC_POWER ( 325)440441/* agc1 value (16) */442#define DIB3000MB_REG_AGC1_VALUE ( 326)443444/* agc2 value (16) */445#define DIB3000MB_REG_AGC2_VALUE ( 327)446447/* total RF power (16), can be used for signal strength */448#define DIB3000MB_REG_RF_POWER ( 328)449450/* dds_frequency with offset (24) */451#define DIB3000MB_REG_DDS_VALUE_MSB ( 339)452#define DIB3000MB_REG_DDS_VALUE_LSB ( 340)453454/* timing offset signed (24) */455#define DIB3000MB_REG_TIMING_OFFSET_MSB ( 341)456#define DIB3000MB_REG_TIMING_OFFSET_LSB ( 342)457458/* fft start position (13) */459#define DIB3000MB_REG_FFT_WINDOW_POS ( 353)460461/* carriers locked (1) */462#define DIB3000MB_REG_CARRIER_LOCK ( 355)463464/* noise power (24) */465#define DIB3000MB_REG_NOISE_POWER_MSB ( 372)466#define DIB3000MB_REG_NOISE_POWER_LSB ( 373)467468#define DIB3000MB_REG_MOBILE_NOISE_MSB ( 374)469#define DIB3000MB_REG_MOBILE_NOISE_LSB ( 375)470471/*472* signal power (16), this and the above can be473* used to calculate the signal/noise - ratio474*/475#define DIB3000MB_REG_SIGNAL_POWER ( 380)476477/* mer (24) */478#define DIB3000MB_REG_MER_MSB ( 381)479#define DIB3000MB_REG_MER_LSB ( 382)480481/*482* Transmission Parameter Signalling (TPS)483* the following registers can be used to get TPS-information.484* The values are according to the DVB-T standard.485*/486487/* TPS locked (1) */488#define DIB3000MB_REG_TPS_LOCK ( 394)489490/* QAM from TPS (2) (values according to DIB3000MB_REG_QAM) */491#define DIB3000MB_REG_TPS_QAM ( 398)492493/* hierarchy from TPS (1) */494#define DIB3000MB_REG_TPS_HRCH ( 399)495496/* alpha from TPS (3) (values according to DIB3000MB_REG_VIT_ALPHA) */497#define DIB3000MB_REG_TPS_VIT_ALPHA ( 400)498499/* code rate high priority from TPS (3) (values according to DIB3000MB_FEC_*) */500#define DIB3000MB_REG_TPS_CODE_RATE_HP ( 401)501502/* code rate low priority from TPS (3) if DIB3000MB_REG_TPS_VIT_ALPHA */503#define DIB3000MB_REG_TPS_CODE_RATE_LP ( 402)504505/* guard time from TPS (2) (values according to DIB3000MB_REG_GUARD_TIME */506#define DIB3000MB_REG_TPS_GUARD_TIME ( 403)507508/* fft size from TPS (2) (values according to DIB3000MB_REG_FFT) */509#define DIB3000MB_REG_TPS_FFT ( 404)510511/* cell id from TPS (16) */512#define DIB3000MB_REG_TPS_CELL_ID ( 406)513514/* TPS (68) */515#define DIB3000MB_REG_TPS_1 ( 408)516#define DIB3000MB_REG_TPS_2 ( 409)517#define DIB3000MB_REG_TPS_3 ( 410)518#define DIB3000MB_REG_TPS_4 ( 411)519#define DIB3000MB_REG_TPS_5 ( 412)520521/* bit error rate (before RS correction) (21) */522#define DIB3000MB_REG_BER_MSB ( 414)523#define DIB3000MB_REG_BER_LSB ( 415)524525/* packet error rate (uncorrected TS packets) (16) */526#define DIB3000MB_REG_PACKET_ERROR_RATE ( 417)527528/* uncorrected packet count (16) */529#define DIB3000MB_REG_UNC ( 420)530531/* viterbi locked (1) */532#define DIB3000MB_REG_VIT_LCK ( 421)533534/* viterbi inidcator (16) */535#define DIB3000MB_REG_VIT_INDICATOR ( 422)536537/* transport stream sync lock (1) */538#define DIB3000MB_REG_TS_SYNC_LOCK ( 423)539540/* transport stream RS lock (1) */541#define DIB3000MB_REG_TS_RS_LOCK ( 424)542543/* lock mask 0 value (1) */544#define DIB3000MB_REG_LOCK0_VALUE ( 425)545546/* lock mask 1 value (1) */547#define DIB3000MB_REG_LOCK1_VALUE ( 426)548549/* lock mask 2 value (1) */550#define DIB3000MB_REG_LOCK2_VALUE ( 427)551552/* interrupt pending for auto search */553#define DIB3000MB_REG_AS_IRQ_PENDING ( 434)554555#endif556557558