18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * dib3000mb_priv.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@posteo.de)
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * for more information see dib3000mb.c .
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __DIB3000MB_PRIV_H_INCLUDED__
118c2ecf20Sopenharmony_ci#define __DIB3000MB_PRIV_H_INCLUDED__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* handy shortcuts */
148c2ecf20Sopenharmony_ci#define rd(reg) dib3000_read_reg(state,reg)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
178c2ecf20Sopenharmony_ci	{ pr_err("while sending 0x%04x to 0x%04x.", val, reg); return -EREMOTEIO; }
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define wr_foreach(a,v) { int i; \
208c2ecf20Sopenharmony_ci	if (sizeof(a) != sizeof(v)) \
218c2ecf20Sopenharmony_ci		pr_err("sizeof: %zu %zu is different", sizeof(a), sizeof(v));\
228c2ecf20Sopenharmony_ci	for (i=0; i < sizeof(a)/sizeof(u16); i++) \
238c2ecf20Sopenharmony_ci		wr(a[i],v[i]); \
248c2ecf20Sopenharmony_ci	}
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define set_or(reg,val) wr(reg,rd(reg) | val)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define set_and(reg,val) wr(reg,rd(reg) & val)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* debug */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define dprintk(level, fmt, arg...) do {				\
338c2ecf20Sopenharmony_ci	if (debug & level)						\
348c2ecf20Sopenharmony_ci		printk(KERN_DEBUG pr_fmt("%s: " fmt),			\
358c2ecf20Sopenharmony_ci		       __func__, ##arg);				\
368c2ecf20Sopenharmony_ci} while (0)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* mask for enabling a specific pid for the pid_filter */
398c2ecf20Sopenharmony_ci#define DIB3000_ACTIVATE_PID_FILTERING	(0x2000)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* common values for tuning */
428c2ecf20Sopenharmony_ci#define DIB3000_ALPHA_0					(     0)
438c2ecf20Sopenharmony_ci#define DIB3000_ALPHA_1					(     1)
448c2ecf20Sopenharmony_ci#define DIB3000_ALPHA_2					(     2)
458c2ecf20Sopenharmony_ci#define DIB3000_ALPHA_4					(     4)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define DIB3000_CONSTELLATION_QPSK		(     0)
488c2ecf20Sopenharmony_ci#define DIB3000_CONSTELLATION_16QAM		(     1)
498c2ecf20Sopenharmony_ci#define DIB3000_CONSTELLATION_64QAM		(     2)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define DIB3000_GUARD_TIME_1_32			(     0)
528c2ecf20Sopenharmony_ci#define DIB3000_GUARD_TIME_1_16			(     1)
538c2ecf20Sopenharmony_ci#define DIB3000_GUARD_TIME_1_8			(     2)
548c2ecf20Sopenharmony_ci#define DIB3000_GUARD_TIME_1_4			(     3)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define DIB3000_TRANSMISSION_MODE_2K	(     0)
578c2ecf20Sopenharmony_ci#define DIB3000_TRANSMISSION_MODE_8K	(     1)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define DIB3000_SELECT_LP				(     0)
608c2ecf20Sopenharmony_ci#define DIB3000_SELECT_HP				(     1)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define DIB3000_FEC_1_2					(     1)
638c2ecf20Sopenharmony_ci#define DIB3000_FEC_2_3					(     2)
648c2ecf20Sopenharmony_ci#define DIB3000_FEC_3_4					(     3)
658c2ecf20Sopenharmony_ci#define DIB3000_FEC_5_6					(     5)
668c2ecf20Sopenharmony_ci#define DIB3000_FEC_7_8					(     7)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define DIB3000_HRCH_OFF				(     0)
698c2ecf20Sopenharmony_ci#define DIB3000_HRCH_ON					(     1)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define DIB3000_DDS_INVERSION_OFF		(     0)
728c2ecf20Sopenharmony_ci#define DIB3000_DDS_INVERSION_ON		(     1)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define DIB3000_TUNER_WRITE_ENABLE(a)	(0xffff & (a << 8))
758c2ecf20Sopenharmony_ci#define DIB3000_TUNER_WRITE_DISABLE(a)	(0xffff & ((a << 8) | (1 << 7)))
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define DIB3000_REG_MANUFACTOR_ID		(  1025)
788c2ecf20Sopenharmony_ci#define DIB3000_I2C_ID_DIBCOM			(0x01b3)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define DIB3000_REG_DEVICE_ID			(  1026)
818c2ecf20Sopenharmony_ci#define DIB3000MB_DEVICE_ID				(0x3000)
828c2ecf20Sopenharmony_ci#define DIB3000MC_DEVICE_ID				(0x3001)
838c2ecf20Sopenharmony_ci#define DIB3000P_DEVICE_ID				(0x3002)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/* frontend state */
868c2ecf20Sopenharmony_cistruct dib3000_state {
878c2ecf20Sopenharmony_ci	struct i2c_adapter* i2c;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* configuration settings */
908c2ecf20Sopenharmony_ci	struct dib3000_config config;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	struct dvb_frontend frontend;
938c2ecf20Sopenharmony_ci	int timing_offset;
948c2ecf20Sopenharmony_ci	int timing_offset_comp_done;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	u32 last_tuned_bw;
978c2ecf20Sopenharmony_ci	u32 last_tuned_freq;
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* register addresses and some of their default values */
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/* restart subsystems */
1038c2ecf20Sopenharmony_ci#define DIB3000MB_REG_RESTART			(     0)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define DIB3000MB_RESTART_OFF			(     0)
1068c2ecf20Sopenharmony_ci#define DIB3000MB_RESTART_AUTO_SEARCH		(1 << 1)
1078c2ecf20Sopenharmony_ci#define DIB3000MB_RESTART_CTRL				(1 << 2)
1088c2ecf20Sopenharmony_ci#define DIB3000MB_RESTART_AGC				(1 << 3)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/* FFT size */
1118c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FFT				(     1)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci/* Guard time */
1148c2ecf20Sopenharmony_ci#define DIB3000MB_REG_GUARD_TIME		(     2)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/* QAM */
1178c2ecf20Sopenharmony_ci#define DIB3000MB_REG_QAM				(     3)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/* Alpha coefficient high priority Viterbi algorithm */
1208c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_ALPHA			(     4)
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci/* spectrum inversion */
1238c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DDS_INV			(     5)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* DDS frequency value (IF position) ad ? values don't match reg_3000mb.txt */
1268c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DDS_FREQ_MSB		(     6)
1278c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DDS_FREQ_LSB		(     7)
1288c2ecf20Sopenharmony_ci#define DIB3000MB_DDS_FREQ_MSB				(   178)
1298c2ecf20Sopenharmony_ci#define DIB3000MB_DDS_FREQ_LSB				(  8990)
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* timing frequency (carrier spacing) */
1328c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_timing_freq[] = { 8,9 };
1338c2ecf20Sopenharmony_cistatic u16 dib3000mb_timing_freq[][2] = {
1348c2ecf20Sopenharmony_ci	{ 126 , 48873 }, /* 6 MHz */
1358c2ecf20Sopenharmony_ci	{ 147 , 57019 }, /* 7 MHz */
1368c2ecf20Sopenharmony_ci	{ 168 , 65164 }, /* 8 MHz */
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* impulse noise parameter */
1408c2ecf20Sopenharmony_ci/* 36 ??? */
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_impulse_noise[] = { 10,11,12,15,36 };
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cienum dib3000mb_impulse_noise_type {
1458c2ecf20Sopenharmony_ci	DIB3000MB_IMPNOISE_OFF,
1468c2ecf20Sopenharmony_ci	DIB3000MB_IMPNOISE_MOBILE,
1478c2ecf20Sopenharmony_ci	DIB3000MB_IMPNOISE_FIXED,
1488c2ecf20Sopenharmony_ci	DIB3000MB_IMPNOISE_DEFAULT
1498c2ecf20Sopenharmony_ci};
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_cistatic u16 dib3000mb_impulse_noise_values[][5] = {
1528c2ecf20Sopenharmony_ci	{ 0x0000, 0x0004, 0x0014, 0x01ff, 0x0399 }, /* off */
1538c2ecf20Sopenharmony_ci	{ 0x0001, 0x0004, 0x0014, 0x01ff, 0x037b }, /* mobile */
1548c2ecf20Sopenharmony_ci	{ 0x0001, 0x0004, 0x0020, 0x01bd, 0x0399 }, /* fixed */
1558c2ecf20Sopenharmony_ci	{ 0x0000, 0x0002, 0x000a, 0x01ff, 0x0399 }, /* default */
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci/*
1598c2ecf20Sopenharmony_ci * Dual Automatic-Gain-Control
1608c2ecf20Sopenharmony_ci * - gains RF in tuner (AGC1)
1618c2ecf20Sopenharmony_ci * - gains IF after filtering (AGC2)
1628c2ecf20Sopenharmony_ci */
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/* also from 16 to 18 */
1658c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_agc_gain[] = {
1668c2ecf20Sopenharmony_ci	19,20,21,22,23,24,25,26,27,28,29,30,31,32
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistatic u16 dib3000mb_default_agc_gain[] =
1708c2ecf20Sopenharmony_ci	{ 0x0001, 52429,   623, 128, 166, 195, 61,   /* RF ??? */
1718c2ecf20Sopenharmony_ci	  0x0001, 53766, 38011,   0,  90,  33, 23 }; /* IF ??? */
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/* phase noise */
1748c2ecf20Sopenharmony_ci/* 36 is set when setting the impulse noise */
1758c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_phase_noise[] = { 33,34,35,37,38 };
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistatic u16 dib3000mb_default_noise_phase[] = { 2, 544, 0, 5, 4 };
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* lock duration */
1808c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_lock_duration[] = { 39,40 };
1818c2ecf20Sopenharmony_cistatic u16 dib3000mb_default_lock_duration[] = { 135, 135 };
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/* AGC loop bandwidth */
1848c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_agc_bandwidth[] = { 43,44,45,46,47,48,49,50 };
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistatic u16 dib3000mb_agc_bandwidth_low[]  =
1878c2ecf20Sopenharmony_ci	{ 2088, 10, 2088, 10, 3448, 5, 3448, 5 };
1888c2ecf20Sopenharmony_cistatic u16 dib3000mb_agc_bandwidth_high[] =
1898c2ecf20Sopenharmony_ci	{ 2349,  5, 2349,  5, 2586, 2, 2586, 2 };
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/*
1928c2ecf20Sopenharmony_ci * lock0 definition (coff_lock)
1938c2ecf20Sopenharmony_ci */
1948c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK0_MASK		(    51)
1958c2ecf20Sopenharmony_ci#define DIB3000MB_LOCK0_DEFAULT				(     4)
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/*
1988c2ecf20Sopenharmony_ci * lock1 definition (cpil_lock)
1998c2ecf20Sopenharmony_ci * for auto search
2008c2ecf20Sopenharmony_ci * which values hide behind the lock masks
2018c2ecf20Sopenharmony_ci */
2028c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK1_MASK		(    52)
2038c2ecf20Sopenharmony_ci#define DIB3000MB_LOCK1_SEARCH_4			(0x0004)
2048c2ecf20Sopenharmony_ci#define DIB3000MB_LOCK1_SEARCH_2048			(0x0800)
2058c2ecf20Sopenharmony_ci#define DIB3000MB_LOCK1_DEFAULT				(0x0001)
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/*
2088c2ecf20Sopenharmony_ci * lock2 definition (fec_lock) */
2098c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK2_MASK		(    53)
2108c2ecf20Sopenharmony_ci#define DIB3000MB_LOCK2_DEFAULT				(0x0080)
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci/*
2138c2ecf20Sopenharmony_ci * SEQ ? what was that again ... :)
2148c2ecf20Sopenharmony_ci * changes when, inversion, guard time and fft is
2158c2ecf20Sopenharmony_ci * either automatically detected or not
2168c2ecf20Sopenharmony_ci */
2178c2ecf20Sopenharmony_ci#define DIB3000MB_REG_SEQ				(    54)
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/* bandwidth */
2208c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_bandwidth[] = { 55,56,57,58,59,60,61,62,63,64,65,66,67 };
2218c2ecf20Sopenharmony_cistatic u16 dib3000mb_bandwidth_6mhz[] =
2228c2ecf20Sopenharmony_ci	{ 0, 33, 53312, 112, 46635, 563, 36565, 0, 1000, 0, 1010, 1, 45264 };
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cistatic u16 dib3000mb_bandwidth_7mhz[] =
2258c2ecf20Sopenharmony_ci	{ 0, 28, 64421,  96, 39973, 483,  3255, 0, 1000, 0, 1010, 1, 45264 };
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic u16 dib3000mb_bandwidth_8mhz[] =
2288c2ecf20Sopenharmony_ci	{ 0, 25, 23600,  84, 34976, 422, 43808, 0, 1000, 0, 1010, 1, 45264 };
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_68				(    68)
2318c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_68						(     0)
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_69				(    69)
2348c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_69						(     0)
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_71				(    71)
2378c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_71						(     0)
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_77				(    77)
2408c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_77						(     6)
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_78				(    78)
2438c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_78						(0x0080)
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci/* isi */
2468c2ecf20Sopenharmony_ci#define DIB3000MB_REG_ISI				(    79)
2478c2ecf20Sopenharmony_ci#define DIB3000MB_ISI_ACTIVATE				(     0)
2488c2ecf20Sopenharmony_ci#define DIB3000MB_ISI_INHIBIT				(     1)
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci/* sync impovement */
2518c2ecf20Sopenharmony_ci#define DIB3000MB_REG_SYNC_IMPROVEMENT	(    84)
2528c2ecf20Sopenharmony_ci#define DIB3000MB_SYNC_IMPROVE_2K_1_8		(     3)
2538c2ecf20Sopenharmony_ci#define DIB3000MB_SYNC_IMPROVE_DEFAULT		(     0)
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci/* phase noise compensation inhibition */
2568c2ecf20Sopenharmony_ci#define DIB3000MB_REG_PHASE_NOISE		(    87)
2578c2ecf20Sopenharmony_ci#define DIB3000MB_PHASE_NOISE_DEFAULT	(     0)
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_92				(    92)
2608c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_92						(0x0080)
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_96				(    96)
2638c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_96						(0x0010)
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_97				(    97)
2668c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_97						(0x0009)
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci/* mobile mode ??? */
2698c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MOBILE_MODE		(   101)
2708c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_MODE_ON			(     1)
2718c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_MODE_OFF			(     0)
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_106			(   106)
2748c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_106					(0x0080)
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_107			(   107)
2778c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_107					(0x0080)
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_108			(   108)
2808c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_108					(0x0080)
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/* fft */
2838c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_121			(   121)
2848c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_121_2K				(     7)
2858c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_121_DEFAULT			(     5)
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNK_122			(   122)
2888c2ecf20Sopenharmony_ci#define DIB3000MB_UNK_122					(  2867)
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci/* QAM for mobile mode */
2918c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MOBILE_MODE_QAM	(   126)
2928c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_MODE_QAM_64		(     3)
2938c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_MODE_QAM_QPSK_16	(     1)
2948c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_MODE_QAM_OFF		(     0)
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci/*
2978c2ecf20Sopenharmony_ci * data diversity when having more than one chip on-board
2988c2ecf20Sopenharmony_ci * see also DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY
2998c2ecf20Sopenharmony_ci */
3008c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DATA_IN_DIVERSITY		(   127)
3018c2ecf20Sopenharmony_ci#define DIB3000MB_DATA_DIVERSITY_IN_OFF			(     0)
3028c2ecf20Sopenharmony_ci#define DIB3000MB_DATA_DIVERSITY_IN_ON			(     2)
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* vit hrch */
3058c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_HRCH			(   128)
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/* vit code rate */
3088c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_CODE_RATE		(   129)
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci/* vit select hp */
3118c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_HP			(   130)
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci/* time frame for Bit-Error-Rate calculation */
3148c2ecf20Sopenharmony_ci#define DIB3000MB_REG_BERLEN			(   135)
3158c2ecf20Sopenharmony_ci#define DIB3000MB_BERLEN_LONG				(     0)
3168c2ecf20Sopenharmony_ci#define DIB3000MB_BERLEN_DEFAULT			(     1)
3178c2ecf20Sopenharmony_ci#define DIB3000MB_BERLEN_MEDIUM				(     2)
3188c2ecf20Sopenharmony_ci#define DIB3000MB_BERLEN_SHORT				(     3)
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci/* 142 - 152 FIFO parameters
3218c2ecf20Sopenharmony_ci * which is what ?
3228c2ecf20Sopenharmony_ci */
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FIFO_142			(   142)
3258c2ecf20Sopenharmony_ci#define DIB3000MB_FIFO_142					(     0)
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/* MPEG2 TS output mode */
3288c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MPEG2_OUT_MODE	(   143)
3298c2ecf20Sopenharmony_ci#define DIB3000MB_MPEG2_OUT_MODE_204		(     0)
3308c2ecf20Sopenharmony_ci#define DIB3000MB_MPEG2_OUT_MODE_188		(     1)
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci#define DIB3000MB_REG_PID_PARSE			(   144)
3338c2ecf20Sopenharmony_ci#define DIB3000MB_PID_PARSE_INHIBIT		(     0)
3348c2ecf20Sopenharmony_ci#define DIB3000MB_PID_PARSE_ACTIVATE	(     1)
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FIFO				(   145)
3378c2ecf20Sopenharmony_ci#define DIB3000MB_FIFO_INHIBIT				(     1)
3388c2ecf20Sopenharmony_ci#define DIB3000MB_FIFO_ACTIVATE				(     0)
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FIFO_146			(   146)
3418c2ecf20Sopenharmony_ci#define DIB3000MB_FIFO_146					(     3)
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FIFO_147			(   147)
3448c2ecf20Sopenharmony_ci#define DIB3000MB_FIFO_147					(0x0100)
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci/*
3478c2ecf20Sopenharmony_ci * pidfilter
3488c2ecf20Sopenharmony_ci * it is not a hardware pidfilter but a filter which drops all pids
3498c2ecf20Sopenharmony_ci * except the ones set. Necessary because of the limited USB1.1 bandwidth.
3508c2ecf20Sopenharmony_ci * regs 153-168
3518c2ecf20Sopenharmony_ci */
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FIRST_PID			(   153)
3548c2ecf20Sopenharmony_ci#define DIB3000MB_NUM_PIDS				(    16)
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci/*
3578c2ecf20Sopenharmony_ci * output mode
3588c2ecf20Sopenharmony_ci * USB devices have to use 'slave'-mode
3598c2ecf20Sopenharmony_ci * see also DIB3000MB_REG_ELECT_OUT_MODE
3608c2ecf20Sopenharmony_ci */
3618c2ecf20Sopenharmony_ci#define DIB3000MB_REG_OUTPUT_MODE		(   169)
3628c2ecf20Sopenharmony_ci#define DIB3000MB_OUTPUT_MODE_GATED_CLK		(     0)
3638c2ecf20Sopenharmony_ci#define DIB3000MB_OUTPUT_MODE_CONT_CLK		(     1)
3648c2ecf20Sopenharmony_ci#define DIB3000MB_OUTPUT_MODE_SERIAL		(     2)
3658c2ecf20Sopenharmony_ci#define DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY	(     5)
3668c2ecf20Sopenharmony_ci#define DIB3000MB_OUTPUT_MODE_SLAVE			(     6)
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci/* irq event mask */
3698c2ecf20Sopenharmony_ci#define DIB3000MB_REG_IRQ_EVENT_MASK		(   170)
3708c2ecf20Sopenharmony_ci#define DIB3000MB_IRQ_EVENT_MASK				(     0)
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci/* filter coefficients */
3738c2ecf20Sopenharmony_cistatic u16 dib3000mb_reg_filter_coeffs[] = {
3748c2ecf20Sopenharmony_ci	171, 172, 173, 174, 175, 176, 177, 178,
3758c2ecf20Sopenharmony_ci	179, 180, 181, 182, 183, 184, 185, 186,
3768c2ecf20Sopenharmony_ci	188, 189, 190, 191, 192, 194
3778c2ecf20Sopenharmony_ci};
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistatic u16 dib3000mb_filter_coeffs[] = {
3808c2ecf20Sopenharmony_ci	 226,  160,   29,
3818c2ecf20Sopenharmony_ci	 979,  998,   19,
3828c2ecf20Sopenharmony_ci	  22, 1019, 1006,
3838c2ecf20Sopenharmony_ci	1022,   12,    6,
3848c2ecf20Sopenharmony_ci	1017, 1017,    3,
3858c2ecf20Sopenharmony_ci	   6,       1019,
3868c2ecf20Sopenharmony_ci	1021,    2,    3,
3878c2ecf20Sopenharmony_ci	   1,          0,
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/*
3918c2ecf20Sopenharmony_ci * mobile algorithm (when you are moving with your device)
3928c2ecf20Sopenharmony_ci * but not faster than 90 km/h
3938c2ecf20Sopenharmony_ci */
3948c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MOBILE_ALGO		(   195)
3958c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_ALGO_ON			(     0)
3968c2ecf20Sopenharmony_ci#define DIB3000MB_MOBILE_ALGO_OFF			(     1)
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci/* multiple demodulators algorithm */
3998c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MULTI_DEMOD_MSB	(   206)
4008c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MULTI_DEMOD_LSB	(   207)
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci/* terminator, no more demods */
4038c2ecf20Sopenharmony_ci#define DIB3000MB_MULTI_DEMOD_MSB			( 32767)
4048c2ecf20Sopenharmony_ci#define DIB3000MB_MULTI_DEMOD_LSB			(  4095)
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci/* bring the device into a known  */
4078c2ecf20Sopenharmony_ci#define DIB3000MB_REG_RESET_DEVICE		(  1024)
4088c2ecf20Sopenharmony_ci#define DIB3000MB_RESET_DEVICE				(0x812c)
4098c2ecf20Sopenharmony_ci#define DIB3000MB_RESET_DEVICE_RST			(     0)
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci/* hardware clock configuration */
4128c2ecf20Sopenharmony_ci#define DIB3000MB_REG_CLOCK				(  1027)
4138c2ecf20Sopenharmony_ci#define DIB3000MB_CLOCK_DEFAULT				(0x9000)
4148c2ecf20Sopenharmony_ci#define DIB3000MB_CLOCK_DIVERSITY			(0x92b0)
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci/* power down config */
4178c2ecf20Sopenharmony_ci#define DIB3000MB_REG_POWER_CONTROL		(  1028)
4188c2ecf20Sopenharmony_ci#define DIB3000MB_POWER_DOWN				(     1)
4198c2ecf20Sopenharmony_ci#define DIB3000MB_POWER_UP					(     0)
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci/* electrical output mode */
4228c2ecf20Sopenharmony_ci#define DIB3000MB_REG_ELECT_OUT_MODE	(  1029)
4238c2ecf20Sopenharmony_ci#define DIB3000MB_ELECT_OUT_MODE_OFF		(     0)
4248c2ecf20Sopenharmony_ci#define DIB3000MB_ELECT_OUT_MODE_ON			(     1)
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci/* set the tuner i2c address */
4278c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TUNER				(  1089)
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci/* monitoring registers (read only) */
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci/* agc loop locked (size: 1) */
4328c2ecf20Sopenharmony_ci#define DIB3000MB_REG_AGC_LOCK			(   324)
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci/* agc power (size: 16) */
4358c2ecf20Sopenharmony_ci#define DIB3000MB_REG_AGC_POWER			(   325)
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci/* agc1 value (16) */
4388c2ecf20Sopenharmony_ci#define DIB3000MB_REG_AGC1_VALUE		(   326)
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci/* agc2 value (16) */
4418c2ecf20Sopenharmony_ci#define DIB3000MB_REG_AGC2_VALUE		(   327)
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci/* total RF power (16), can be used for signal strength */
4448c2ecf20Sopenharmony_ci#define DIB3000MB_REG_RF_POWER			(   328)
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci/* dds_frequency with offset (24) */
4478c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DDS_VALUE_MSB		(   339)
4488c2ecf20Sopenharmony_ci#define DIB3000MB_REG_DDS_VALUE_LSB		(   340)
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci/* timing offset signed (24) */
4518c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TIMING_OFFSET_MSB	(   341)
4528c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TIMING_OFFSET_LSB	(   342)
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/* fft start position (13) */
4558c2ecf20Sopenharmony_ci#define DIB3000MB_REG_FFT_WINDOW_POS	(   353)
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci/* carriers locked (1) */
4588c2ecf20Sopenharmony_ci#define DIB3000MB_REG_CARRIER_LOCK		(   355)
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci/* noise power (24) */
4618c2ecf20Sopenharmony_ci#define DIB3000MB_REG_NOISE_POWER_MSB	(   372)
4628c2ecf20Sopenharmony_ci#define DIB3000MB_REG_NOISE_POWER_LSB	(   373)
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MOBILE_NOISE_MSB	(   374)
4658c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MOBILE_NOISE_LSB	(   375)
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci/*
4688c2ecf20Sopenharmony_ci * signal power (16), this and the above can be
4698c2ecf20Sopenharmony_ci * used to calculate the signal/noise - ratio
4708c2ecf20Sopenharmony_ci */
4718c2ecf20Sopenharmony_ci#define DIB3000MB_REG_SIGNAL_POWER		(   380)
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci/* mer (24) */
4748c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MER_MSB			(   381)
4758c2ecf20Sopenharmony_ci#define DIB3000MB_REG_MER_LSB			(   382)
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci/*
4788c2ecf20Sopenharmony_ci * Transmission Parameter Signalling (TPS)
4798c2ecf20Sopenharmony_ci * the following registers can be used to get TPS-information.
4808c2ecf20Sopenharmony_ci * The values are according to the DVB-T standard.
4818c2ecf20Sopenharmony_ci */
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci/* TPS locked (1) */
4848c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_LOCK			(   394)
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci/* QAM from TPS (2) (values according to DIB3000MB_REG_QAM) */
4878c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_QAM			(   398)
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci/* hierarchy from TPS (1) */
4908c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_HRCH			(   399)
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci/* alpha from TPS (3) (values according to DIB3000MB_REG_VIT_ALPHA) */
4938c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_VIT_ALPHA		(   400)
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci/* code rate high priority from TPS (3) (values according to DIB3000MB_FEC_*) */
4968c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_CODE_RATE_HP	(   401)
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci/* code rate low priority from TPS (3) if DIB3000MB_REG_TPS_VIT_ALPHA */
4998c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_CODE_RATE_LP	(   402)
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_ci/* guard time from TPS (2) (values according to DIB3000MB_REG_GUARD_TIME */
5028c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_GUARD_TIME	(   403)
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci/* fft size from TPS (2) (values according to DIB3000MB_REG_FFT) */
5058c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_FFT			(   404)
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci/* cell id from TPS (16) */
5088c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_CELL_ID		(   406)
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci/* TPS (68) */
5118c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_1				(   408)
5128c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_2				(   409)
5138c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_3				(   410)
5148c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_4				(   411)
5158c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TPS_5				(   412)
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci/* bit error rate (before RS correction) (21) */
5188c2ecf20Sopenharmony_ci#define DIB3000MB_REG_BER_MSB			(   414)
5198c2ecf20Sopenharmony_ci#define DIB3000MB_REG_BER_LSB			(   415)
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci/* packet error rate (uncorrected TS packets) (16) */
5228c2ecf20Sopenharmony_ci#define DIB3000MB_REG_PACKET_ERROR_RATE	(   417)
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci/* uncorrected packet count (16) */
5258c2ecf20Sopenharmony_ci#define DIB3000MB_REG_UNC				(   420)
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci/* viterbi locked (1) */
5288c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_LCK			(   421)
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci/* viterbi inidcator (16) */
5318c2ecf20Sopenharmony_ci#define DIB3000MB_REG_VIT_INDICATOR		(   422)
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci/* transport stream sync lock (1) */
5348c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TS_SYNC_LOCK		(   423)
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci/* transport stream RS lock (1) */
5378c2ecf20Sopenharmony_ci#define DIB3000MB_REG_TS_RS_LOCK		(   424)
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci/* lock mask 0 value (1) */
5408c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK0_VALUE		(   425)
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci/* lock mask 1 value (1) */
5438c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK1_VALUE		(   426)
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci/* lock mask 2 value (1) */
5468c2ecf20Sopenharmony_ci#define DIB3000MB_REG_LOCK2_VALUE		(   427)
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci/* interrupt pending for auto search */
5498c2ecf20Sopenharmony_ci#define DIB3000MB_REG_AS_IRQ_PENDING	(   434)
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci#endif
552