1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef DIBX000_COMMON_H
3 #define DIBX000_COMMON_H
5 enum dibx000_i2c_interface {
6 DIBX000_I2C_INTERFACE_TUNER = 0,
7 DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
8 DIBX000_I2C_INTERFACE_GPIO_3_4 = 2,
9 DIBX000_I2C_INTERFACE_GPIO_6_7 = 3
12 struct dibx000_i2c_master {
20 enum dibx000_i2c_interface selected_interface;
22 /* struct i2c_adapter tuner_i2c_adap; */
23 struct i2c_adapter gated_tuner_i2c_adap;
24 struct i2c_adapter master_i2c_adap_gpio12;
25 struct i2c_adapter master_i2c_adap_gpio34;
26 struct i2c_adapter master_i2c_adap_gpio67;
28 struct i2c_adapter *i2c_adap;
33 /* for the I2C transfer */
34 struct i2c_msg msg[34];
35 u8 i2c_write_buffer[8];
36 u8 i2c_read_buffer[2];
37 struct mutex i2c_buffer_lock;
40 extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
41 u16 device_rev, struct i2c_adapter *i2c_adap,
43 extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
45 enum dibx000_i2c_interface
47 extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
48 extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
49 extern int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed);
51 #define BAND_LBAND 0x01
54 #define BAND_SBAND 0x08
56 #define BAND_CBAND 0x20
58 #define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \
59 (freq_kHz) <= 115000 ? BAND_FM : \
60 (freq_kHz) <= 250000 ? BAND_VHF : \
61 (freq_kHz) <= 863000 ? BAND_UHF : \
62 (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
64 struct dibx000_agc_config {
65 /* defines the capabilities of this AGC-setting - using the BAND_-defines */
105 u8 perform_agc_softsplit;
115 struct dibx000_bandwidth_config {
139 enum dibx000_adc_states {
140 DIBX000_SLOW_ADC_ON = 0,
141 DIBX000_SLOW_ADC_OFF,
148 #define BANDWIDTH_TO_KHZ(v) ((v) / 1000)
149 #define BANDWIDTH_TO_HZ(v) ((v) * 1000)
151 /* Chip output mode. */
152 #define OUTMODE_HIGH_Z 0
153 #define OUTMODE_MPEG2_PAR_GATED_CLK 1
154 #define OUTMODE_MPEG2_PAR_CONT_CLK 2
155 #define OUTMODE_MPEG2_SERIAL 7
156 #define OUTMODE_DIVERSITY 4
157 #define OUTMODE_MPEG2_FIFO 5
158 #define OUTMODE_ANALOG_ADC 6
160 #define INPUT_MODE_OFF 0x11
161 #define INPUT_MODE_DIVERSITY 0x12
162 #define INPUT_MODE_MPEG 0x13
164 enum frontend_tune_state {
196 CT_DEMOD_SEARCH_NEXT = 51,
197 CT_DEMOD_STEP_LOCKED,
205 struct dvb_frontend_parametersContext {
206 #define CHANNEL_STATUS_PARAMETERS_UNKNOWN 0x01
207 #define CHANNEL_STATUS_PARAMETERS_SET 0x02
209 u32 tune_time_estimation[2];
214 #define FE_STATUS_TUNE_FAILED 0
215 #define FE_STATUS_TUNE_TIMED_OUT -1
216 #define FE_STATUS_TUNE_TIME_TOO_SHORT -2
217 #define FE_STATUS_TUNE_PENDING -3
218 #define FE_STATUS_STD_SUCCESS -4
219 #define FE_STATUS_FFT_SUCCESS -5
220 #define FE_STATUS_DEMOD_SUCCESS -6
221 #define FE_STATUS_LOCKED -7
222 #define FE_STATUS_DATA_LOCKED -8
224 #define FE_CALLBACK_TIME_NEVER 0xffffffff
226 #define DATA_BUS_ACCESS_MODE_8BIT 0x01
227 #define DATA_BUS_ACCESS_MODE_16BIT 0x02
228 #define DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT 0x10
230 struct dibGPIOFunction {
231 #define BOARD_GPIO_COMPONENT_BUS_ADAPTER 1
232 #define BOARD_GPIO_COMPONENT_DEMOD 2
235 #define BOARD_GPIO_FUNCTION_BOARD_ON 1
236 #define BOARD_GPIO_FUNCTION_BOARD_OFF 2
237 #define BOARD_GPIO_FUNCTION_COMPONENT_ON 3
238 #define BOARD_GPIO_FUNCTION_COMPONENT_OFF 4
239 #define BOARD_GPIO_FUNCTION_SUBBAND_PWM 5
240 #define BOARD_GPIO_FUNCTION_SUBBAND_GPIO 6
243 /* mask, direction and value are used specify which GPIO to change GPIO0
244 * is LSB and possible GPIO31 is MSB. The same bit-position as in the
245 * mask is used for the direction and the value. Direction == 1 is OUT,
246 * 0 == IN. For direction "OUT" value is either 1 or 0, for direction IN
247 * value has no meaning.
249 * In case of BOARD_GPIO_FUNCTION_PWM mask is giving the GPIO to be
250 * used to do the PWM. Direction gives the PWModulator to be used.
251 * Value gives the PWM value in device-dependent scale.
258 #define MAX_NB_SUBBANDS 8
259 struct dibSubbandSelection {
260 u8 size; /* Actual number of subbands. */
263 struct dibGPIOFunction gpio;
264 } subband[MAX_NB_SUBBANDS];
267 #define DEMOD_TIMF_SET 0x00
268 #define DEMOD_TIMF_GET 0x01
269 #define DEMOD_TIMF_UPDATE 0x02
271 #define MPEG_ON_DIBTX 1
272 #define DIV_ON_DIBTX 2
273 #define ADC_ON_DIBTX 3
274 #define DEMOUT_ON_HOSTBUS 4
275 #define DIBTX_ON_HOSTBUS 5
276 #define MPEG_ON_HOSTBUS 6