1 /* SPDX-License-Identifier: GPL-2.0 */
3 * ddbridge-mci.h: Digital Devices micro code interface
5 * Copyright (C) 2017-2018 Digital Devices GmbH
6 * Marcus Metzler <mocm@metzlerbros.de>
7 * Ralph Metzler <rjkm@metzlerbros.de>
10 #ifndef _DDBRIDGE_MCI_H_
11 #define _DDBRIDGE_MCI_H_
13 #define MCI_DEMOD_MAX 8
14 #define MCI_TUNER_MAX 4
15 #define DEMOD_UNUSED (0xFF)
17 #define MCI_CONTROL (0x500)
18 #define MCI_COMMAND (0x600)
19 #define MCI_RESULT (0x680)
21 #define MCI_COMMAND_SIZE (0x80)
22 #define MCI_RESULT_SIZE (0x80)
24 #define MCI_CONTROL_START_COMMAND (0x00000001)
25 #define MCI_CONTROL_ENABLE_DONE_INTERRUPT (0x00000002)
26 #define MCI_CONTROL_RESET (0x00008000)
27 #define MCI_CONTROL_READY (0x00010000)
29 #define SX8_TSCONFIG (0x280)
31 #define SX8_TSCONFIG_MODE_MASK (0x00000003)
32 #define SX8_TSCONFIG_MODE_OFF (0x00000000)
33 #define SX8_TSCONFIG_MODE_NORMAL (0x00000001)
34 #define SX8_TSCONFIG_MODE_IQ (0x00000003)
37 * IQMode is only available on MaxSX8 on a single tuner
40 * sampling rate is 1550/24 MHz (64.583 MHz)
41 * channel agc is frozen, to allow stitching the FFT results together
44 * sampling rate is the supplied symbolrate
45 * channel agc is active
47 * in both cases down sampling is done with a RRC Filter (currently fixed to
48 * alpha = 0.05) which causes some (ca 5%) aliasing at the edges from
49 * outside the spectrum
52 #define SX8_TSCONFIG_TSHEADER (0x00000004)
53 #define SX8_TSCONFIG_BURST (0x00000008)
55 #define SX8_TSCONFIG_BURSTSIZE_MASK (0x00000030)
56 #define SX8_TSCONFIG_BURSTSIZE_2K (0x00000000)
57 #define SX8_TSCONFIG_BURSTSIZE_4K (0x00000010)
58 #define SX8_TSCONFIG_BURSTSIZE_8K (0x00000020)
59 #define SX8_TSCONFIG_BURSTSIZE_16K (0x00000030)
61 #define SX8_DEMOD_STOPPED (0)
62 #define SX8_DEMOD_IQ_MODE (1)
63 #define SX8_DEMOD_WAIT_SIGNAL (2)
64 #define SX8_DEMOD_WAIT_MATYPE (3)
65 #define SX8_DEMOD_TIMEOUT (14)
66 #define SX8_DEMOD_LOCKED (15)
68 #define MCI_CMD_STOP (0x01)
69 #define MCI_CMD_GETSTATUS (0x02)
70 #define MCI_CMD_GETSIGNALINFO (0x03)
71 #define MCI_CMD_RFPOWER (0x04)
73 #define MCI_CMD_SEARCH_DVBS (0x10)
75 #define MCI_CMD_GET_IQSYMBOL (0x30)
77 #define SX8_CMD_INPUT_ENABLE (0x40)
78 #define SX8_CMD_INPUT_DISABLE (0x41)
79 #define SX8_CMD_START_IQ (0x42)
80 #define SX8_CMD_STOP_IQ (0x43)
81 #define SX8_CMD_ENABLE_IQOUTPUT (0x44)
82 #define SX8_CMD_DISABLE_IQOUTPUT (0x45)
84 #define MCI_STATUS_OK (0x00)
85 #define MCI_STATUS_UNSUPPORTED (0x80)
86 #define MCI_STATUS_RETRY (0xFD)
87 #define MCI_STATUS_NOT_READY (0xFE)
88 #define MCI_STATUS_ERROR (0xFF)
90 #define MCI_SUCCESS(status) ((status & MCI_STATUS_UNSUPPORTED) == 0)
106 * Bit 0: DVB-S Enabled
107 * Bit 1: DVB-S2 Enabled
108 * Bit 7: InputStreamID
120 u8 s2_modulation_mask
;
127 u32 scrambling_sequence_index
;
139 * Bit 0: 0=VTM/1=SCAN
147 u32 symbol_rate
; /* Only in VTM mode */
153 * Bit 1:0 = STVVGLNA Gain.
154 * 0 = AGC, 1 = 0dB, 2 = Minimum, 3 = Maximum
173 /* 1 = DVB-S, 2 = DVB-S2X */
175 /* puncture rate for DVB-S */
180 /* actual frequency in Hz */
182 /* actual symbolrate in Hz */
184 /* channel power in dBm x 100 */
186 /* band power in dBm x 100 */
190 * Note: negative values are valid in DVB-S2
195 * Counter for packet errors
196 * (set to 0 on start command)
199 /* Bit error rate: PreRS in DVB-S, PreBCH in DVB-S2X */
213 struct list_head mci_list
;
215 struct ddb_link
*link
;
216 struct completion completion
;
218 struct mutex tuner_lock
; /* concurrent tuner access lock */
219 struct mutex mci_lock
; /* concurrent MCI access lock */
225 struct mci_base
*base
;
226 struct dvb_frontend fe
;
234 struct dvb_frontend_ops
*fe_ops
;
237 int (*init
)(struct mci
*mci
);
238 int (*base_init
)(struct mci_base
*mci_base
);
239 int (*set_input
)(struct dvb_frontend
*fe
, int input
);
242 /* defined in ddbridge-sx8.c */
243 extern const struct mci_cfg ddb_max_sx8_cfg
;
245 int ddb_mci_cmd(struct mci
*state
, struct mci_command
*command
,
246 struct mci_result
*result
);
247 int ddb_mci_config(struct mci
*state
, u32 config
);
250 *ddb_mci_attach(struct ddb_input
*input
, struct mci_cfg
*cfg
, int nr
,
251 int (**fn_set_input
)(struct dvb_frontend
*fe
, int input
));
253 #endif /* _DDBRIDGE_MCI_H_ */