cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

stv090x_priv.h (5878B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3	STV0900/0903 Multistandard Broadcast Frontend driver
      4	Copyright (C) Manu Abraham <abraham.manu@gmail.com>
      5
      6	Copyright (C) ST Microelectronics
      7
      8*/
      9
     10#ifndef __STV090x_PRIV_H
     11#define __STV090x_PRIV_H
     12
     13#include <media/dvb_frontend.h>
     14
     15#define FE_ERROR				0
     16#define FE_NOTICE				1
     17#define FE_INFO					2
     18#define FE_DEBUG				3
     19#define FE_DEBUGREG				4
     20
     21#define dprintk(__y, __z, format, arg...) do {						\
     22	if (__z) {									\
     23		if	((verbose > FE_ERROR) && (verbose > __y))			\
     24			printk(KERN_ERR "%s: " format "\n", __func__ , ##arg);		\
     25		else if	((verbose > FE_NOTICE) && (verbose > __y))			\
     26			printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg);	\
     27		else if ((verbose > FE_INFO) && (verbose > __y))			\
     28			printk(KERN_INFO "%s: " format "\n", __func__ , ##arg);		\
     29		else if ((verbose > FE_DEBUG) && (verbose > __y))			\
     30			printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg);	\
     31	} else {									\
     32		if (verbose > __y)							\
     33			printk(format, ##arg);						\
     34	}										\
     35} while (0)
     36
     37#define STV090x_READ_DEMOD(__state, __reg) ((			\
     38	(__state)->demod == STV090x_DEMODULATOR_1)	?	\
     39	stv090x_read_reg(__state, STV090x_P2_##__reg) :		\
     40	stv090x_read_reg(__state, STV090x_P1_##__reg))
     41
     42#define STV090x_WRITE_DEMOD(__state, __reg, __data) ((		\
     43	(__state)->demod == STV090x_DEMODULATOR_1)	?	\
     44	stv090x_write_reg(__state, STV090x_P2_##__reg, __data) :\
     45	stv090x_write_reg(__state, STV090x_P1_##__reg, __data))
     46
     47#define STV090x_ADDR_OFFST(__state, __x) ((			\
     48	(__state->demod) == STV090x_DEMODULATOR_1)	?	\
     49		STV090x_P1_##__x :				\
     50		STV090x_P2_##__x)
     51
     52
     53#define STV090x_SETFIELD(mask, bitf, val)	(mask = (mask & (~(((1 << STV090x_WIDTH_##bitf) - 1) <<\
     54							 STV090x_OFFST_##bitf))) | \
     55							 (val << STV090x_OFFST_##bitf))
     56
     57#define STV090x_GETFIELD(val, bitf)		((val >> STV090x_OFFST_##bitf) & ((1 << STV090x_WIDTH_##bitf) - 1))
     58
     59
     60#define STV090x_SETFIELD_Px(mask, bitf, val)	(mask = (mask & (~(((1 << STV090x_WIDTH_Px_##bitf) - 1) <<\
     61							 STV090x_OFFST_Px_##bitf))) | \
     62							 (val << STV090x_OFFST_Px_##bitf))
     63
     64#define STV090x_GETFIELD_Px(val, bitf)		((val >> STV090x_OFFST_Px_##bitf) & ((1 << STV090x_WIDTH_Px_##bitf) - 1))
     65
     66#define MAKEWORD16(__a, __b)			(((__a) << 8) | (__b))
     67
     68#define MSB(__x)				((__x >> 8) & 0xff)
     69#define LSB(__x)				(__x & 0xff)
     70
     71
     72#define STV090x_IQPOWER_THRESHOLD	  30
     73#define STV090x_SEARCH_AGC2_TH_CUT20	 700
     74#define STV090x_SEARCH_AGC2_TH_CUT30	1400
     75
     76#define STV090x_SEARCH_AGC2_TH(__ver)	\
     77	((__ver <= 0x20) ?		\
     78	STV090x_SEARCH_AGC2_TH_CUT20 :	\
     79	STV090x_SEARCH_AGC2_TH_CUT30)
     80
     81enum stv090x_signal_state {
     82	STV090x_NOAGC1,
     83	STV090x_NOCARRIER,
     84	STV090x_NODATA,
     85	STV090x_DATAOK,
     86	STV090x_RANGEOK,
     87	STV090x_OUTOFRANGE
     88};
     89
     90enum stv090x_fec {
     91	STV090x_PR12 = 0,
     92	STV090x_PR23,
     93	STV090x_PR34,
     94	STV090x_PR45,
     95	STV090x_PR56,
     96	STV090x_PR67,
     97	STV090x_PR78,
     98	STV090x_PR89,
     99	STV090x_PR910,
    100	STV090x_PRERR
    101};
    102
    103enum stv090x_modulation {
    104	STV090x_QPSK,
    105	STV090x_8PSK,
    106	STV090x_16APSK,
    107	STV090x_32APSK,
    108	STV090x_UNKNOWN
    109};
    110
    111enum stv090x_frame {
    112	STV090x_LONG_FRAME,
    113	STV090x_SHORT_FRAME
    114};
    115
    116enum stv090x_pilot {
    117	STV090x_PILOTS_OFF,
    118	STV090x_PILOTS_ON
    119};
    120
    121enum stv090x_rolloff {
    122	STV090x_RO_35,
    123	STV090x_RO_25,
    124	STV090x_RO_20
    125};
    126
    127enum stv090x_inversion {
    128	STV090x_IQ_AUTO,
    129	STV090x_IQ_NORMAL,
    130	STV090x_IQ_SWAP
    131};
    132
    133enum stv090x_modcod {
    134	STV090x_DUMMY_PLF = 0,
    135	STV090x_QPSK_14,
    136	STV090x_QPSK_13,
    137	STV090x_QPSK_25,
    138	STV090x_QPSK_12,
    139	STV090x_QPSK_35,
    140	STV090x_QPSK_23,
    141	STV090x_QPSK_34,
    142	STV090x_QPSK_45,
    143	STV090x_QPSK_56,
    144	STV090x_QPSK_89,
    145	STV090x_QPSK_910,
    146	STV090x_8PSK_35,
    147	STV090x_8PSK_23,
    148	STV090x_8PSK_34,
    149	STV090x_8PSK_56,
    150	STV090x_8PSK_89,
    151	STV090x_8PSK_910,
    152	STV090x_16APSK_23,
    153	STV090x_16APSK_34,
    154	STV090x_16APSK_45,
    155	STV090x_16APSK_56,
    156	STV090x_16APSK_89,
    157	STV090x_16APSK_910,
    158	STV090x_32APSK_34,
    159	STV090x_32APSK_45,
    160	STV090x_32APSK_56,
    161	STV090x_32APSK_89,
    162	STV090x_32APSK_910,
    163	STV090x_MODCODE_UNKNOWN
    164};
    165
    166enum stv090x_search {
    167	STV090x_SEARCH_DSS = 0,
    168	STV090x_SEARCH_DVBS1,
    169	STV090x_SEARCH_DVBS2,
    170	STV090x_SEARCH_AUTO
    171};
    172
    173enum stv090x_algo {
    174	STV090x_BLIND_SEARCH,
    175	STV090x_COLD_SEARCH,
    176	STV090x_WARM_SEARCH
    177};
    178
    179enum stv090x_delsys {
    180	STV090x_ERROR = 0,
    181	STV090x_DVBS1 = 1,
    182	STV090x_DVBS2,
    183	STV090x_DSS
    184};
    185
    186struct stv090x_long_frame_crloop {
    187	enum stv090x_modcod	modcod;
    188
    189	u8 crl_pilots_on_2;
    190	u8 crl_pilots_off_2;
    191	u8 crl_pilots_on_5;
    192	u8 crl_pilots_off_5;
    193	u8 crl_pilots_on_10;
    194	u8 crl_pilots_off_10;
    195	u8 crl_pilots_on_20;
    196	u8 crl_pilots_off_20;
    197	u8 crl_pilots_on_30;
    198	u8 crl_pilots_off_30;
    199};
    200
    201struct stv090x_short_frame_crloop {
    202	enum stv090x_modulation	modulation;
    203
    204	u8 crl_2;  /*      SR <   3M */
    205	u8 crl_5;  /*  3 < SR <=  7M */
    206	u8 crl_10; /*  7 < SR <= 15M */
    207	u8 crl_20; /* 10 < SR <= 25M */
    208	u8 crl_30; /* 10 < SR <= 45M */
    209};
    210
    211struct stv090x_reg {
    212	u16 addr;
    213	u8  data;
    214};
    215
    216struct stv090x_tab {
    217	s32 real;
    218	s32 read;
    219};
    220
    221struct stv090x_internal {
    222	struct i2c_adapter	*i2c_adap;
    223	u8			i2c_addr;
    224
    225	struct mutex		demod_lock; /* Lock access to shared register */
    226	struct mutex		tuner_lock; /* Lock access to tuners */
    227	s32			mclk; /* Masterclock Divider factor */
    228	u32			dev_ver;
    229
    230	int			num_used;
    231};
    232
    233struct stv090x_state {
    234	enum stv090x_device		device;
    235	enum stv090x_demodulator	demod;
    236	enum stv090x_mode		demod_mode;
    237	struct stv090x_internal		*internal;
    238
    239	struct i2c_adapter		*i2c;
    240	struct stv090x_config	*config;
    241	struct dvb_frontend		frontend;
    242
    243	u32				*verbose; /* Cached module verbosity */
    244
    245	enum stv090x_delsys		delsys;
    246	enum stv090x_fec		fec;
    247	enum stv090x_modulation		modulation;
    248	enum stv090x_modcod		modcod;
    249	enum stv090x_search		search_mode;
    250	enum stv090x_frame		frame_len;
    251	enum stv090x_pilot		pilots;
    252	enum stv090x_rolloff		rolloff;
    253	enum stv090x_inversion		inversion;
    254	enum stv090x_algo		algo;
    255
    256	u32				frequency;
    257	u32				srate;
    258
    259	s32				tuner_bw;
    260
    261	s32				search_range;
    262
    263	s32				DemodTimeout;
    264	s32				FecTimeout;
    265};
    266
    267#endif /* __STV090x_PRIV_H */