Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * Sony CXD2820R demodulator driver
  4 *
  5 * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  6 */
  7
  8
  9#ifndef CXD2820R_PRIV_H
 10#define CXD2820R_PRIV_H
 11
 12#include <linux/dvb/version.h>
 13#include <media/dvb_frontend.h>
 14#include <linux/int_log.h>
 15#include "cxd2820r.h"
 16#include <linux/gpio/driver.h> /* For gpio_chip */
 17#include <linux/math64.h>
 18#include <linux/regmap.h>
 19
 20struct reg_val_mask {
 21	u32 reg;
 22	u8  val;
 23	u8  mask;
 24};
 25
 26#define CXD2820R_CLK 41000000
 27
 28struct cxd2820r_priv {
 29	struct i2c_client *client[2];
 30	struct regmap *regmap[2];
 31	struct i2c_adapter *i2c;
 32	struct dvb_frontend fe;
 33	u8 ts_mode;
 34	bool ts_clk_inv;
 35	bool if_agc_polarity;
 36	bool spec_inv;
 37
 38	u64 post_bit_error_prev_dvbv3;
 39	u64 post_bit_error;
 40
 41	bool ber_running;
 42
 
 43#define GPIO_COUNT 3
 44	u8 gpio[GPIO_COUNT];
 45#ifdef CONFIG_GPIOLIB
 46	struct gpio_chip gpio_chip;
 47#endif
 48
 49	enum fe_delivery_system delivery_system;
 50	bool last_tune_failed; /* for switch between T and T2 tune */
 51};
 52
 53/* cxd2820r_core.c */
 54
 55int cxd2820r_gpio(struct dvb_frontend *fe, u8 *gpio);
 56
 57int cxd2820r_wr_reg_val_mask_tab(struct cxd2820r_priv *priv,
 58				 const struct reg_val_mask *tab, int tab_len);
 59
 60int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
 61	u8 mask);
 62
 63int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 64	int len);
 65
 
 
 66int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 67	int len);
 68
 69int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 70	int len);
 71
 72int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
 73
 74int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
 75
 76/* cxd2820r_c.c */
 77
 78int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
 79			    struct dtv_frontend_properties *p);
 80
 81int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
 82
 83int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status);
 
 
 
 
 
 
 
 
 84
 85int cxd2820r_init_c(struct dvb_frontend *fe);
 86
 87int cxd2820r_sleep_c(struct dvb_frontend *fe);
 88
 89int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
 90	struct dvb_frontend_tune_settings *s);
 91
 92/* cxd2820r_t.c */
 93
 94int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
 95			    struct dtv_frontend_properties *p);
 96
 97int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
 98
 99int cxd2820r_read_status_t(struct dvb_frontend *fe, enum fe_status *status);
 
 
 
 
 
 
 
 
100
101int cxd2820r_init_t(struct dvb_frontend *fe);
102
103int cxd2820r_sleep_t(struct dvb_frontend *fe);
104
105int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
106	struct dvb_frontend_tune_settings *s);
107
108/* cxd2820r_t2.c */
109
110int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
111			     struct dtv_frontend_properties *p);
112
113int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
114
115int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status);
 
 
 
 
 
 
 
 
116
117int cxd2820r_init_t2(struct dvb_frontend *fe);
118
119int cxd2820r_sleep_t2(struct dvb_frontend *fe);
120
121int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
122	struct dvb_frontend_tune_settings *s);
123
124#endif /* CXD2820R_PRIV_H */
v3.15
 
  1/*
  2 * Sony CXD2820R demodulator driver
  3 *
  4 * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
  5 *
  6 *    This program is free software; you can redistribute it and/or modify
  7 *    it under the terms of the GNU General Public License as published by
  8 *    the Free Software Foundation; either version 2 of the License, or
  9 *    (at your option) any later version.
 10 *
 11 *    This program is distributed in the hope that it will be useful,
 12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 *    GNU General Public License for more details.
 15 *
 16 *    You should have received a copy of the GNU General Public License along
 17 *    with this program; if not, write to the Free Software Foundation, Inc.,
 18 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 19 */
 20
 21
 22#ifndef CXD2820R_PRIV_H
 23#define CXD2820R_PRIV_H
 24
 25#include <linux/dvb/version.h>
 26#include "dvb_frontend.h"
 27#include "dvb_math.h"
 28#include "cxd2820r.h"
 29#include <linux/gpio.h>
 
 
 30
 31struct reg_val_mask {
 32	u32 reg;
 33	u8  val;
 34	u8  mask;
 35};
 36
 
 
 37struct cxd2820r_priv {
 
 
 38	struct i2c_adapter *i2c;
 39	struct dvb_frontend fe;
 40	struct cxd2820r_config cfg;
 
 
 
 
 
 
 41
 42	bool ber_running;
 43
 44	u8 bank[2];
 45#define GPIO_COUNT 3
 46	u8 gpio[GPIO_COUNT];
 47#ifdef CONFIG_GPIOLIB
 48	struct gpio_chip gpio_chip;
 49#endif
 50
 51	fe_delivery_system_t delivery_system;
 52	bool last_tune_failed; /* for switch between T and T2 tune */
 53};
 54
 55/* cxd2820r_core.c */
 56
 57extern int cxd2820r_debug;
 58
 59int cxd2820r_gpio(struct dvb_frontend *fe, u8 *gpio);
 
 60
 61int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
 62	u8 mask);
 63
 64int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 65	int len);
 66
 67u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor);
 68
 69int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 70	int len);
 71
 72int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
 73	int len);
 74
 75int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
 76
 77int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
 78
 79/* cxd2820r_c.c */
 80
 81int cxd2820r_get_frontend_c(struct dvb_frontend *fe);
 
 82
 83int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
 84
 85int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status);
 86
 87int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber);
 88
 89int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength);
 90
 91int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr);
 92
 93int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks);
 94
 95int cxd2820r_init_c(struct dvb_frontend *fe);
 96
 97int cxd2820r_sleep_c(struct dvb_frontend *fe);
 98
 99int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
100	struct dvb_frontend_tune_settings *s);
101
102/* cxd2820r_t.c */
103
104int cxd2820r_get_frontend_t(struct dvb_frontend *fe);
 
105
106int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
107
108int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status);
109
110int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber);
111
112int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength);
113
114int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr);
115
116int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks);
117
118int cxd2820r_init_t(struct dvb_frontend *fe);
119
120int cxd2820r_sleep_t(struct dvb_frontend *fe);
121
122int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
123	struct dvb_frontend_tune_settings *s);
124
125/* cxd2820r_t2.c */
126
127int cxd2820r_get_frontend_t2(struct dvb_frontend *fe);
 
128
129int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
130
131int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status);
132
133int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber);
134
135int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength);
136
137int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr);
138
139int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks);
140
141int cxd2820r_init_t2(struct dvb_frontend *fe);
142
143int cxd2820r_sleep_t2(struct dvb_frontend *fe);
144
145int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
146	struct dvb_frontend_tune_settings *s);
147
148#endif /* CXD2820R_PRIV_H */