Linux Audio

Check our new training course

Loading...
v4.10.11
  1/*
  2	STB0899 Multistandard Frontend driver
  3	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  4
  5	Copyright (C) ST Microelectronics
  6
  7	This program is free software; you can redistribute it and/or modify
  8	it under the terms of the GNU General Public License as published by
  9	the Free Software Foundation; either version 2 of the License, or
 10	(at your option) any later version.
 11
 12	This program is distributed in the hope that it will be useful,
 13	but WITHOUT ANY WARRANTY; without even the implied warranty of
 14	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15	GNU General Public License for more details.
 16
 17	You should have received a copy of the GNU General Public License
 18	along with this program; if not, write to the Free Software
 19	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 20*/
 21
 22#ifndef __STB0899_DRV_H
 23#define __STB0899_DRV_H
 24
 25#include <linux/kernel.h>
 26#include <linux/module.h>
 27
 28#include "dvb_frontend.h"
 29
 30#define STB0899_TSMODE_SERIAL		1
 31#define STB0899_CLKPOL_FALLING		2
 32#define STB0899_CLKNULL_PARITY		3
 33#define STB0899_SYNC_FORCED		4
 34#define STB0899_FECMODE_DSS		5
 35
 36struct stb0899_s1_reg {
 37	u16	address;
 38	u8	data;
 39};
 40
 41struct stb0899_s2_reg {
 42	u16	offset;
 43	u32	base_address;
 44	u32	data;
 45};
 46
 47enum stb0899_inversion {
 48	IQ_SWAP_OFF	= +1, /* inversion affects the sign of e. g. */
 49	IQ_SWAP_ON	= -1, /* the derotator frequency register    */
 50};
 51
 52#define STB0899_GPIO00				0xf140
 53#define STB0899_GPIO01				0xf141
 54#define STB0899_GPIO02				0xf142
 55#define STB0899_GPIO03				0xf143
 56#define STB0899_GPIO04				0xf144
 57#define STB0899_GPIO05				0xf145
 58#define STB0899_GPIO06				0xf146
 59#define STB0899_GPIO07				0xf147
 60#define STB0899_GPIO08				0xf148
 61#define STB0899_GPIO09				0xf149
 62#define STB0899_GPIO10				0xf14a
 63#define STB0899_GPIO11				0xf14b
 64#define STB0899_GPIO12				0xf14c
 65#define STB0899_GPIO13				0xf14d
 66#define STB0899_GPIO14				0xf14e
 67#define STB0899_GPIO15				0xf14f
 68#define STB0899_GPIO16				0xf150
 69#define STB0899_GPIO17				0xf151
 70#define STB0899_GPIO18				0xf152
 71#define STB0899_GPIO19				0xf153
 72#define STB0899_GPIO20				0xf154
 73
 74#define STB0899_GPIOPULLUP			0x01 /* Output device is connected to Vdd */
 75#define STB0899_GPIOPULLDN			0x00 /* Output device is connected to Vss */
 76
 77#define STB0899_POSTPROC_GPIO_POWER		0x00
 78#define STB0899_POSTPROC_GPIO_LOCK		0x01
 79
 80/*
 81 * Post process output configuration control
 82 * 1. POWER ON/OFF		(index 0)
 83 * 2. FE_HAS_LOCK/LOCK_LOSS	(index 1)
 84 *
 85 * @gpio 	= one of the above listed GPIO's
 86 * @level	= output state: pulled up or low
 87 */
 88struct stb0899_postproc {
 89	u16	gpio;
 90	u8	level;
 91};
 92
 93struct stb0899_config {
 94	const struct stb0899_s1_reg	*init_dev;
 95	const struct stb0899_s2_reg	*init_s2_demod;
 96	const struct stb0899_s1_reg	*init_s1_demod;
 97	const struct stb0899_s2_reg	*init_s2_fec;
 98	const struct stb0899_s1_reg	*init_tst;
 99
100	const struct stb0899_postproc	*postproc;
101
102	enum stb0899_inversion		inversion;
103
104	u32	xtal_freq;
105
106	u8	demod_address;
107	u8	ts_output_mode;
108	u8	block_sync_mode;
109	u8	ts_pfbit_toggle;
110
111	u8	clock_polarity;
112	u8	data_clk_parity;
113	u8	fec_mode;
114	u8	data_output_ctl;
115	u8	data_fifo_mode;
116	u8	out_rate_comp;
117	u8	i2c_repeater;
118//	int	inversion;
119	int	lo_clk;
120	int	hi_clk;
121
122	u32	esno_ave;
123	u32	esno_quant;
124	u32	avframes_coarse;
125	u32	avframes_fine;
126	u32	miss_threshold;
127	u32	uwp_threshold_acq;
128	u32	uwp_threshold_track;
129	u32	uwp_threshold_sof;
130	u32	sof_search_timeout;
131
132	u32	btr_nco_bits;
133	u32	btr_gain_shift_offset;
134	u32	crl_nco_bits;
135	u32	ldpc_max_iter;
136
137	int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
138	int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
139	int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
140	int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
141	int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
142};
143
144#if IS_REACHABLE(CONFIG_DVB_STB0899)
145
146extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
147					   struct i2c_adapter *i2c);
148
149#else
150
151static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
152						  struct i2c_adapter *i2c)
153{
154	printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
155	return NULL;
156}
157
158#endif //CONFIG_DVB_STB0899
159
160
161#endif
v4.17
  1/*
  2	STB0899 Multistandard Frontend driver
  3	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  4
  5	Copyright (C) ST Microelectronics
  6
  7	This program is free software; you can redistribute it and/or modify
  8	it under the terms of the GNU General Public License as published by
  9	the Free Software Foundation; either version 2 of the License, or
 10	(at your option) any later version.
 11
 12	This program is distributed in the hope that it will be useful,
 13	but WITHOUT ANY WARRANTY; without even the implied warranty of
 14	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15	GNU General Public License for more details.
 16
 17	You should have received a copy of the GNU General Public License
 18	along with this program; if not, write to the Free Software
 19	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 20*/
 21
 22#ifndef __STB0899_DRV_H
 23#define __STB0899_DRV_H
 24
 25#include <linux/kernel.h>
 26#include <linux/module.h>
 27
 28#include <media/dvb_frontend.h>
 29
 30#define STB0899_TSMODE_SERIAL		1
 31#define STB0899_CLKPOL_FALLING		2
 32#define STB0899_CLKNULL_PARITY		3
 33#define STB0899_SYNC_FORCED		4
 34#define STB0899_FECMODE_DSS		5
 35
 36struct stb0899_s1_reg {
 37	u16	address;
 38	u8	data;
 39};
 40
 41struct stb0899_s2_reg {
 42	u16	offset;
 43	u32	base_address;
 44	u32	data;
 45};
 46
 47enum stb0899_inversion {
 48	IQ_SWAP_OFF	= +1, /* inversion affects the sign of e. g. */
 49	IQ_SWAP_ON	= -1, /* the derotator frequency register    */
 50};
 51
 52#define STB0899_GPIO00				0xf140
 53#define STB0899_GPIO01				0xf141
 54#define STB0899_GPIO02				0xf142
 55#define STB0899_GPIO03				0xf143
 56#define STB0899_GPIO04				0xf144
 57#define STB0899_GPIO05				0xf145
 58#define STB0899_GPIO06				0xf146
 59#define STB0899_GPIO07				0xf147
 60#define STB0899_GPIO08				0xf148
 61#define STB0899_GPIO09				0xf149
 62#define STB0899_GPIO10				0xf14a
 63#define STB0899_GPIO11				0xf14b
 64#define STB0899_GPIO12				0xf14c
 65#define STB0899_GPIO13				0xf14d
 66#define STB0899_GPIO14				0xf14e
 67#define STB0899_GPIO15				0xf14f
 68#define STB0899_GPIO16				0xf150
 69#define STB0899_GPIO17				0xf151
 70#define STB0899_GPIO18				0xf152
 71#define STB0899_GPIO19				0xf153
 72#define STB0899_GPIO20				0xf154
 73
 74#define STB0899_GPIOPULLUP			0x01 /* Output device is connected to Vdd */
 75#define STB0899_GPIOPULLDN			0x00 /* Output device is connected to Vss */
 76
 77#define STB0899_POSTPROC_GPIO_POWER		0x00
 78#define STB0899_POSTPROC_GPIO_LOCK		0x01
 79
 80/*
 81 * Post process output configuration control
 82 * 1. POWER ON/OFF		(index 0)
 83 * 2. FE_HAS_LOCK/LOCK_LOSS	(index 1)
 84 *
 85 * @gpio	= one of the above listed GPIO's
 86 * @level	= output state: pulled up or low
 87 */
 88struct stb0899_postproc {
 89	u16	gpio;
 90	u8	level;
 91};
 92
 93struct stb0899_config {
 94	const struct stb0899_s1_reg	*init_dev;
 95	const struct stb0899_s2_reg	*init_s2_demod;
 96	const struct stb0899_s1_reg	*init_s1_demod;
 97	const struct stb0899_s2_reg	*init_s2_fec;
 98	const struct stb0899_s1_reg	*init_tst;
 99
100	const struct stb0899_postproc	*postproc;
101
102	enum stb0899_inversion		inversion;
103
104	u32	xtal_freq;
105
106	u8	demod_address;
107	u8	ts_output_mode;
108	u8	block_sync_mode;
109	u8	ts_pfbit_toggle;
110
111	u8	clock_polarity;
112	u8	data_clk_parity;
113	u8	fec_mode;
114	u8	data_output_ctl;
115	u8	data_fifo_mode;
116	u8	out_rate_comp;
117	u8	i2c_repeater;
118//	int	inversion;
119	int	lo_clk;
120	int	hi_clk;
121
122	u32	esno_ave;
123	u32	esno_quant;
124	u32	avframes_coarse;
125	u32	avframes_fine;
126	u32	miss_threshold;
127	u32	uwp_threshold_acq;
128	u32	uwp_threshold_track;
129	u32	uwp_threshold_sof;
130	u32	sof_search_timeout;
131
132	u32	btr_nco_bits;
133	u32	btr_gain_shift_offset;
134	u32	crl_nco_bits;
135	u32	ldpc_max_iter;
136
137	int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
138	int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
139	int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
140	int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
141	int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
142};
143
144#if IS_REACHABLE(CONFIG_DVB_STB0899)
145
146extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
147					   struct i2c_adapter *i2c);
148
149#else
150
151static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
152						  struct i2c_adapter *i2c)
153{
154	printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
155	return NULL;
156}
157
158#endif //CONFIG_DVB_STB0899
159
160
161#endif