Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 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 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 25 | #include <linux/dvb/version.h> |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 26 | #include "dvb_frontend.h" |
| 27 | #include "dvb_math.h" |
| 28 | #include "cxd2820r.h" |
| 29 | |
| 30 | #define LOG_PREFIX "cxd2820r" |
| 31 | |
| 32 | #undef dbg |
| 33 | #define dbg(f, arg...) \ |
| 34 | if (cxd2820r_debug) \ |
| 35 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) |
| 36 | #undef err |
| 37 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) |
| 38 | #undef info |
| 39 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) |
| 40 | #undef warn |
| 41 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) |
| 42 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 43 | struct reg_val_mask { |
| 44 | u32 reg; |
| 45 | u8 val; |
| 46 | u8 mask; |
| 47 | }; |
| 48 | |
| 49 | struct cxd2820r_priv { |
| 50 | struct i2c_adapter *i2c; |
| 51 | struct dvb_frontend fe[2]; |
| 52 | struct cxd2820r_config cfg; |
| 53 | struct i2c_adapter tuner_i2c_adapter; |
| 54 | |
| 55 | struct mutex fe_lock; /* FE lock */ |
| 56 | int active_fe:2; /* FE lock, -1=NONE, 0=DVB-T/T2, 1=DVB-C */ |
| 57 | |
Antti Palosaari | 1d44ccb | 2011-05-25 12:42:52 -0300 | [diff] [blame^] | 58 | bool ber_running; |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 59 | |
| 60 | u8 bank[2]; |
| 61 | u8 gpio[3]; |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 62 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 63 | fe_delivery_system_t delivery_system; |
Antti Palosaari | 1d44ccb | 2011-05-25 12:42:52 -0300 | [diff] [blame^] | 64 | bool last_tune_failed; /* for switch between T and T2 tune */ |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 65 | }; |
| 66 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 67 | /* cxd2820r_core.c */ |
| 68 | |
| 69 | extern int cxd2820r_debug; |
| 70 | |
| 71 | int cxd2820r_gpio(struct dvb_frontend *fe); |
| 72 | |
| 73 | int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val, |
| 74 | u8 mask); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 75 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 76 | int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 77 | int len); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 78 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 79 | u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor); |
| 80 | |
| 81 | int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 82 | int len); |
| 83 | |
| 84 | int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val, |
| 85 | int len); |
| 86 | |
| 87 | int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val); |
| 88 | |
| 89 | int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val); |
| 90 | |
| 91 | /* cxd2820r_c.c */ |
| 92 | |
| 93 | int cxd2820r_get_frontend_c(struct dvb_frontend *fe, |
| 94 | struct dvb_frontend_parameters *p); |
| 95 | |
| 96 | int cxd2820r_set_frontend_c(struct dvb_frontend *fe, |
| 97 | struct dvb_frontend_parameters *params); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 98 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 99 | int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status); |
| 100 | |
| 101 | int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber); |
| 102 | |
| 103 | int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength); |
| 104 | |
| 105 | int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr); |
| 106 | |
| 107 | int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks); |
| 108 | |
| 109 | int cxd2820r_init_c(struct dvb_frontend *fe); |
| 110 | |
| 111 | int cxd2820r_sleep_c(struct dvb_frontend *fe); |
| 112 | |
| 113 | int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe, |
| 114 | struct dvb_frontend_tune_settings *s); |
| 115 | |
| 116 | /* cxd2820r_t.c */ |
| 117 | |
| 118 | int cxd2820r_get_frontend_t(struct dvb_frontend *fe, |
| 119 | struct dvb_frontend_parameters *p); |
| 120 | |
| 121 | int cxd2820r_set_frontend_t(struct dvb_frontend *fe, |
| 122 | struct dvb_frontend_parameters *params); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 123 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 124 | int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status); |
| 125 | |
| 126 | int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber); |
| 127 | |
| 128 | int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength); |
| 129 | |
| 130 | int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr); |
| 131 | |
| 132 | int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks); |
| 133 | |
| 134 | int cxd2820r_init_t(struct dvb_frontend *fe); |
| 135 | |
| 136 | int cxd2820r_sleep_t(struct dvb_frontend *fe); |
| 137 | |
| 138 | int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe, |
| 139 | struct dvb_frontend_tune_settings *s); |
| 140 | |
| 141 | /* cxd2820r_t2.c */ |
| 142 | |
| 143 | int cxd2820r_get_frontend_t2(struct dvb_frontend *fe, |
| 144 | struct dvb_frontend_parameters *p); |
| 145 | |
| 146 | int cxd2820r_set_frontend_t2(struct dvb_frontend *fe, |
| 147 | struct dvb_frontend_parameters *params); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 148 | |
Steve Kerrison | 9ac51c5 | 2011-05-02 18:19:13 -0300 | [diff] [blame] | 149 | int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status); |
| 150 | |
| 151 | int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber); |
| 152 | |
| 153 | int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength); |
| 154 | |
| 155 | int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr); |
| 156 | |
| 157 | int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks); |
| 158 | |
| 159 | int cxd2820r_init_t2(struct dvb_frontend *fe); |
| 160 | |
| 161 | int cxd2820r_sleep_t2(struct dvb_frontend *fe); |
| 162 | |
| 163 | int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe, |
| 164 | struct dvb_frontend_tune_settings *s); |
Antti Palosaari | 2e1ea06 | 2011-05-03 20:21:59 -0300 | [diff] [blame] | 165 | |
Antti Palosaari | 27cfc85 | 2011-04-07 16:27:43 -0300 | [diff] [blame] | 166 | #endif /* CXD2820R_PRIV_H */ |