1 /*- 2 * Copyright (c) 2011 Hans Petter Selasky. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26 /* 27 * BSD vTuner API 28 * 29 * Inspired by code written by: 30 * Honza Petrous <jpetrous@smartimp.cz> 31 */ 32 33 #ifndef _VTUNER_H_ 34 #define _VTUNER_H_ 35 36 #include <linux/dvb/version.h> 37 #include <linux/dvb/frontend.h> 38 #include <linux/dvb/dmx.h> 39 40 #define VTUNER_VERSION_00010001 0x00010001 41 #define VTUNER_VERSION VTUNER_VERSION_00010001 42 #define VTUNER_MAGIC 0x5654554EU /* 'VTUN' */ 43 #define VTUNER_DEFAULT_PORT "5100" 44 #define VTUNER_BUFFER_MAX (2 * 65536) 45 #define VTUNER_PROP_MAX 64 46 47 enum { 48 MSG_UNDEFINED = 0, 49 50 MSG_DMX_START = 16, 51 MSG_DMX_STOP, 52 MSG_DMX_SET_FILTER, 53 MSG_DMX_SET_PES_FILTER, 54 MSG_DMX_SET_BUFFER_SIZE, 55 MSG_DMX_GET_PES_PIDS, 56 MSG_DMX_GET_CAPS, 57 MSG_DMX_SET_SOURCE, 58 MSG_DMX_GET_STC, 59 MSG_DMX_ADD_PID, 60 MSG_DMX_REMOVE_PID, 61 62 MSG_FE_SET_PROPERTY = 32, 63 MSG_FE_GET_PROPERTY, 64 MSG_FE_GET_INFO, 65 MSG_FE_DISEQC_RESET_OVERLOAD, 66 MSG_FE_DISEQC_SEND_MASTER_CMD, 67 MSG_FE_DISEQC_RECV_SLAVE_REPLY, 68 MSG_FE_DISEQC_SEND_BURST, 69 MSG_FE_SET_TONE, 70 MSG_FE_SET_VOLTAGE, 71 MSG_FE_ENABLE_HIGH_LNB_VOLTAGE, 72 73 MSG_FE_READ_STATUS, 74 MSG_FE_READ_BER, 75 MSG_FE_READ_SIGNAL_STRENGTH, 76 MSG_FE_READ_SNR, 77 MSG_FE_READ_UNCORRECTED_BLOCKS, 78 79 MSG_FE_SET_FRONTEND, 80 MSG_FE_GET_FRONTEND, 81 MSG_FE_SET_FRONTEND_TUNE_MODE, 82 MSG_FE_GET_EVENT, 83 MSG_FE_DISHNETWORK_SEND_LEGACY_CMD, 84 }; 85 86 /* define platform independant types */ 87 88 typedef uint8_t v8 __aligned(1); 89 typedef uint16_t v16 __aligned(2); 90 typedef uint32_t v32 __aligned(4); 91 typedef uint64_t v64 __aligned(8); 92 93 /* 94 * ==== DMX data header ==== 95 */ 96 97 struct vtuner_data_hdr { 98 v32 magic; /* VTUNER_MAGIC */ 99 v32 length; /* must be <= VTUNER_BUFFER_MAX */ 100 }; 101 102 /* 103 * ==== DMX device structures ==== 104 */ 105 106 struct vtuner_dmx_filter { 107 v8 filter[DMX_FILTER_SIZE]; 108 v8 mask [DMX_FILTER_SIZE]; 109 v8 mode [DMX_FILTER_SIZE]; 110 }; 111 112 struct vtuner_dmx_sct_filter_params { 113 v16 pid; 114 struct vtuner_dmx_filter filter; 115 v32 timeout; 116 v32 flags; 117 }; 118 119 struct vtuner_dmx_pes_filter_params { 120 v16 pid; 121 v32 input; 122 v32 output; 123 v32 pes_type; 124 v32 flags; 125 }; 126 127 struct vtuner_dmx_pes_pid { 128 uint16_t pids[5]; 129 }; 130 131 struct vtuner_dmx_stc { 132 v32 num; 133 v32 base; 134 v64 stc; 135 }; 136 137 /* 138 * ==== Frontend device structures ==== 139 */ 140 141 struct vtuner_dvb_frontend_info { 142 v8 name [128]; 143 v32 type; 144 v32 frequency_min; 145 v32 frequency_max; 146 v32 frequency_stepsize; 147 v32 frequency_tolerance; 148 v32 symbol_rate_min; 149 v32 symbol_rate_max; 150 v32 symbol_rate_tolerance; 151 v32 notifier_delay; 152 v32 caps; 153 }; 154 155 struct vtuner_dvb_diseqc_master_cmd { 156 v8 msg [6]; 157 v8 msg_len; 158 }; 159 160 struct vtuner_dvb_diseqc_slave_reply { 161 v8 msg [4]; 162 v8 msg_len; 163 v32 timeout; 164 }; 165 166 struct vtuner_dvb_qpsk_parameters { 167 v32 symbol_rate; 168 v32 fec_inner; 169 }; 170 171 struct vtuner_dvb_qam_parameters { 172 v32 symbol_rate; 173 v32 fec_inner; 174 v32 modulation; 175 }; 176 177 struct vtuner_dvb_vsb_parameters { 178 v32 modulation; 179 }; 180 181 struct vtuner_dvb_ofdm_parameters { 182 v32 bandwidth; 183 v32 code_rate_HP; 184 v32 code_rate_LP; 185 v32 constellation; 186 v32 transmission_mode; 187 v32 guard_interval; 188 v32 hierarchy_information; 189 }; 190 191 struct vtuner_dvb_frontend_parameters { 192 v32 frequency; 193 v32 inversion; 194 union { 195 struct vtuner_dvb_qpsk_parameters qpsk; 196 struct vtuner_dvb_qam_parameters qam; 197 struct vtuner_dvb_ofdm_parameters ofdm; 198 struct vtuner_dvb_vsb_parameters vsb; 199 } u; 200 }; 201 202 struct vtuner_dvb_frontend_event { 203 v32 status; 204 struct vtuner_dvb_frontend_parameters parameters; 205 }; 206 207 struct vtuner_dtv_property { 208 v32 cmd; 209 v32 reserved[3]; 210 union { 211 v32 data; 212 struct { 213 v8 data [32]; 214 v32 len; 215 } buffer; 216 } u; 217 int result; 218 }; 219 220 struct vtuner_dtv_properties { 221 v32 num; 222 struct vtuner_dtv_property props[VTUNER_PROP_MAX]; 223 }; 224 225 struct vtuner_message { 226 struct { 227 v32 magic; /* VTUNER_MAGIC */ 228 v32 mtype; 229 v16 rx_size; 230 v16 tx_size; 231 v16 error; 232 v16 padding; 233 } hdr; 234 union { 235 v32 value32; 236 v16 value16; 237 struct vtuner_dmx_sct_filter_params dmx_sct_filter_params; 238 struct vtuner_dmx_pes_filter_params dmx_pes_filter_params; 239 struct vtuner_dmx_pes_pid dmx_pes_pid; 240 struct vtuner_dmx_stc dmx_stc; 241 struct vtuner_dvb_frontend_info dvb_frontend_info; 242 struct vtuner_dvb_diseqc_master_cmd dvb_diseqc_master_cmd; 243 struct vtuner_dvb_diseqc_slave_reply dvb_diseqc_slave_reply; 244 struct vtuner_dvb_frontend_parameters dvb_frontend_parameters; 245 struct vtuner_dvb_frontend_event dvb_frontend_event; 246 struct vtuner_dtv_properties dtv_properties; 247 } body; 248 }; 249 250 union vtuner_dvb_message { 251 u32 value32; 252 u16 value16; 253 struct { 254 u16 pids[5]; 255 } dmx_pes_pid; 256 struct dmx_sct_filter_params dmx_sct_filter_params; 257 struct dmx_pes_filter_params dmx_pes_filter_params; 258 struct dmx_stc dmx_stc; 259 struct dvb_frontend_info dvb_frontend_info; 260 struct dvb_diseqc_master_cmd dvb_diseqc_master_cmd; 261 struct dvb_diseqc_slave_reply dvb_diseqc_slave_reply; 262 struct dvb_frontend_parameters dvb_frontend_parameters; 263 struct dvb_frontend_event dvb_frontend_event; 264 struct dtv_properties dtv_properties; 265 }; 266 267 #endif /* _VTUNER_H_ */ 268