1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * ddbridge-mci.h: Digital Devices micro code interface 4 * 5 * Copyright (C) 2017 Digital Devices GmbH 6 * Marcus Metzler <mocm@metzlerbros.de> 7 * Ralph Metzler <rjkm@metzlerbros.de> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * version 2 only, as published by the Free Software Foundation. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 */ 18 19 #ifndef _DDBRIDGE_MCI_H_ 20 #define _DDBRIDGE_MCI_H_ 21 22 #define MCI_DEMOD_MAX 8 23 #define MCI_TUNER_MAX 4 24 #define DEMOD_UNUSED (0xFF) 25 26 #define MCI_CONTROL (0x500) 27 #define MCI_COMMAND (0x600) 28 #define MCI_RESULT (0x680) 29 30 #define MCI_COMMAND_SIZE (0x80) 31 #define MCI_RESULT_SIZE (0x80) 32 33 #define MCI_CONTROL_START_COMMAND (0x00000001) 34 #define MCI_CONTROL_ENABLE_DONE_INTERRUPT (0x00000002) 35 #define MCI_CONTROL_RESET (0x00008000) 36 #define MCI_CONTROL_READY (0x00010000) 37 38 #define SX8_TSCONFIG (0x280) 39 40 #define SX8_TSCONFIG_MODE_MASK (0x00000003) 41 #define SX8_TSCONFIG_MODE_OFF (0x00000000) 42 #define SX8_TSCONFIG_MODE_NORMAL (0x00000001) 43 #define SX8_TSCONFIG_MODE_IQ (0x00000003) 44 45 #define SX8_TSCONFIG_TSHEADER (0x00000004) 46 #define SX8_TSCONFIG_BURST (0x00000008) 47 48 #define SX8_TSCONFIG_BURSTSIZE_MASK (0x00000030) 49 #define SX8_TSCONFIG_BURSTSIZE_2K (0x00000000) 50 #define SX8_TSCONFIG_BURSTSIZE_4K (0x00000010) 51 #define SX8_TSCONFIG_BURSTSIZE_8K (0x00000020) 52 #define SX8_TSCONFIG_BURSTSIZE_16K (0x00000030) 53 54 #define SX8_DEMOD_STOPPED (0) 55 #define SX8_DEMOD_IQ_MODE (1) 56 #define SX8_DEMOD_WAIT_SIGNAL (2) 57 #define SX8_DEMOD_WAIT_MATYPE (3) 58 #define SX8_DEMOD_TIMEOUT (14) 59 #define SX8_DEMOD_LOCKED (15) 60 61 #define MCI_CMD_STOP (0x01) 62 #define MCI_CMD_GETSTATUS (0x02) 63 #define MCI_CMD_GETSIGNALINFO (0x03) 64 #define MCI_CMD_RFPOWER (0x04) 65 66 #define MCI_CMD_SEARCH_DVBS (0x10) 67 68 #define MCI_CMD_GET_IQSYMBOL (0x30) 69 70 #define SX8_CMD_INPUT_ENABLE (0x40) 71 #define SX8_CMD_INPUT_DISABLE (0x41) 72 #define SX8_CMD_START_IQ (0x42) 73 #define SX8_CMD_STOP_IQ (0x43) 74 #define SX8_CMD_SELECT_IQOUT (0x44) 75 #define SX8_CMD_SELECT_TSOUT (0x45) 76 77 #define SX8_ERROR_UNSUPPORTED (0x80) 78 79 #define SX8_SUCCESS(status) (status < SX8_ERROR_UNSUPPORTED) 80 81 #define SX8_CMD_DIAG_READ8 (0xE0) 82 #define SX8_CMD_DIAG_READ32 (0xE1) 83 #define SX8_CMD_DIAG_WRITE8 (0xE2) 84 #define SX8_CMD_DIAG_WRITE32 (0xE3) 85 86 #define SX8_CMD_DIAG_READRF (0xE8) 87 #define SX8_CMD_DIAG_WRITERF (0xE9) 88 89 struct mci_command { 90 union { 91 u32 command_word; 92 struct { 93 u8 command; 94 u8 tuner; 95 u8 demod; 96 u8 output; 97 }; 98 }; 99 union { 100 u32 params[31]; 101 struct { 102 u8 flags; 103 u8 s2_modulation_mask; 104 u8 rsvd1; 105 u8 retry; 106 u32 frequency; 107 u32 symbol_rate; 108 u8 input_stream_id; 109 u8 rsvd2[3]; 110 u32 scrambling_sequence_index; 111 } dvbs2_search; 112 }; 113 }; 114 115 struct mci_result { 116 union { 117 u32 status_word; 118 struct { 119 u8 status; 120 u8 rsvd; 121 u16 time; 122 }; 123 }; 124 union { 125 u32 result[27]; 126 struct { 127 u8 standard; 128 /* puncture rate for DVB-S */ 129 u8 pls_code; 130 /* 7-6: rolloff, 5-2: rsrvd, 1:short, 0:pilots */ 131 u8 roll_off; 132 u8 rsvd; 133 u32 frequency; 134 u32 symbol_rate; 135 s16 channel_power; 136 s16 band_power; 137 s16 signal_to_noise; 138 s16 rsvd2; 139 u32 packet_errors; 140 u32 ber_numerator; 141 u32 ber_denominator; 142 } dvbs2_signal_info; 143 struct { 144 u8 i_symbol; 145 u8 q_symbol; 146 } dvbs2_signal_iq; 147 }; 148 u32 version[4]; 149 }; 150 151 struct dvb_frontend 152 *ddb_mci_attach(struct ddb_input *input, 153 int mci_type, int nr, 154 int (**fn_set_input)(struct dvb_frontend *fe, int input)); 155 156 #endif /* _DDBRIDGE_MCI_H_ */ 157