Home | History | Annotate | Line # | Download | only in dtv
      1 /* $NetBSD: dtvio_frontend.h,v 1.3 2017/10/28 06:27:32 riastradh Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2011 Jared D. McNeill <jmcneill (at) invisible.ca>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *        This product includes software developed by Jared D. McNeill.
     18  * 4. Neither the name of The NetBSD Foundation nor the names of its
     19  *    contributors may be used to endorse or promote products derived
     20  *    from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32  * POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #ifndef _DEV_DTV_DTVIO_FRONTEND_H
     36 #define _DEV_DTV_DTVIO_FRONTEND_H
     37 
     38 #include <sys/types.h>
     39 #include <sys/ioccom.h>
     40 
     41 /*
     42  * DVB Frontend API
     43  */
     44 
     45 /* Frontend types */
     46 typedef enum fe_type {
     47 	FE_QPSK,	/* DVB-S */
     48 	FE_QAM,		/* DVB-C annex A/C */
     49 	FE_OFDM,	/* DVB-T */
     50 	FE_ATSC,	/* ATSC or DVB-C annex B */
     51 } fe_type_t;
     52 
     53 /* Frontend capabilities */
     54 typedef enum fe_caps {
     55 	FE_IS_STUPID			= 0,
     56 	FE_CAN_INVERSION_AUTO		= 0x1,
     57 	FE_CAN_FEC_1_2			= 0x2,
     58 	FE_CAN_FEC_2_3			= 0x4,
     59 	FE_CAN_FEC_3_4			= 0x8,
     60 	FE_CAN_FEC_4_5			= 0x10,
     61 	FE_CAN_FEC_5_6			= 0x20,
     62 	FE_CAN_FEC_6_7			= 0x40,
     63 	FE_CAN_FEC_7_8			= 0x80,
     64 	FE_CAN_FEC_8_9			= 0x100,
     65 	FE_CAN_FEC_AUTO			= 0x200,
     66 	FE_CAN_QPSK			= 0x400,
     67 	FE_CAN_QAM_16			= 0x800,
     68 	FE_CAN_QAM_32			= 0x1000,
     69 	FE_CAN_QAM_64			= 0x2000,
     70 	FE_CAN_QAM_128			= 0x4000,
     71 	FE_CAN_QAM_256			= 0x8000,
     72 	FE_CAN_QAM_AUTO			= 0x10000,
     73 	FE_CAN_TRANSMISSION_MODE_AUTO	= 0x20000,
     74 	FE_CAN_BANDWIDTH_AUTO		= 0x40000,
     75 	FE_CAN_GUARD_INTERVAL_AUTO	= 0x80000,
     76 	FE_CAN_HIERARCHY_AUTO		= 0x100000,
     77 	FE_CAN_8VSB			= 0x200000,
     78 	FE_CAN_16VSB			= 0x400000,
     79 	FE_HAS_EXTENDED_CAPS		= 0x800000,
     80 	FE_CAN_TURBO_FEC		= 0x8000000,
     81 	FE_CAN_2G_MODULATION		= 0x10000000,
     82 	FE_NEEDS_BENDING		= 0x20000000,
     83 	FE_CAN_RECOVER			= 0x40000000,
     84 	FE_CAN_MUTE_TS			= 0x80000000,
     85 } fe_caps_t;
     86 
     87 /* Frontend information */
     88 struct dvb_frontend_info {
     89 	char		name[128];
     90 	fe_type_t	type;
     91 	uint32_t	frequency_min;
     92 	uint32_t	frequency_max;
     93 	uint32_t	frequency_stepsize;
     94 	uint32_t	frequency_tolerance;
     95 	uint32_t	symbol_rate_min;
     96 	uint32_t	symbol_rate_max;
     97 	uint32_t	symbol_rate_tolerance;	/* ppm */
     98 	uint32_t	notifier_delay;		/* ms */
     99 	fe_caps_t	caps;
    100 };
    101 
    102 /* Frontend status */
    103 typedef enum fe_status {
    104 	FE_HAS_SIGNAL	= 0x01,	/* found something above the noise level */
    105 	FE_HAS_CARRIER	= 0x02,	/* found a DVB signal */
    106 	FE_HAS_VITERBI	= 0x04,	/* FEC is stable */
    107 	FE_HAS_SYNC	= 0x08,	/* found sync bytes */
    108 	FE_HAS_LOCK	= 0x10,	/* everything's working... */
    109 	FE_TIMEDOUT	= 0x20,	/* no lock within the last ~2 seconds */
    110 	FE_REINIT	= 0x40,	/* frontend was reinitialized */
    111 } fe_status_t;
    112 
    113 /* Frontend spectral inversion */
    114 typedef enum fe_spectral_inversion {
    115 	INVERSION_OFF,
    116 	INVERSION_ON,
    117 	INVERSION_AUTO,
    118 } fe_spectral_inversion_t;
    119 
    120 /* Frontend code rate */
    121 typedef enum fe_code_rate {
    122 	FEC_NONE = 0,
    123 	FEC_1_2,
    124 	FEC_2_3,
    125 	FEC_3_4,
    126 	FEC_4_5,
    127 	FEC_5_6,
    128 	FEC_6_7,
    129 	FEC_7_8,
    130 	FEC_8_9,
    131 	FEC_AUTO,
    132 	FEC_3_5,
    133 	FEC_9_10,
    134 } fe_code_rate_t;
    135 
    136 /* Frontend modulation type for QAM, OFDM, and VSB */
    137 typedef enum fe_modulation {
    138 	QPSK,
    139 	QAM_16,
    140 	QAM_32,
    141 	QAM_64,
    142 	QAM_128,
    143 	QAM_256,
    144 	QAM_AUTO,
    145 	VSB_8,
    146 	VSB_16,
    147 	PSK_8,
    148 	APSK_16,
    149 	APSK_32,
    150 	DQPSK,
    151 } fe_modulation_t;
    152 
    153 /* Number of carriers per channel */
    154 typedef enum fe_transmit_mode {
    155 	TRANSMISSION_MODE_2K,
    156 	TRANSMISSION_MODE_8K,
    157 	TRANSMISSION_MODE_AUTO,
    158 	TRANSMISSION_MODE_4K,
    159 	TRANSMISSION_MODE_1K,
    160 	TRANSMISSION_MODE_16K,
    161 	TRANSMISSION_MODE_32K,
    162 } fe_transmit_mode_t;
    163 
    164 /* Frontend bandwidth */
    165 typedef enum fe_bandwidth {
    166 	BANDWIDTH_8_MHZ,
    167 	BANDWIDTH_7_MHZ,
    168 	BANDWIDTH_6_MHZ,
    169 	BANDWIDTH_AUTO,
    170 	BANDWIDTH_5_MHZ,
    171 	BANDWIDTH_10_MHZ,
    172 	BANDWIDTH_1_172_MHZ,
    173 } fe_bandwidth_t;
    174 
    175 /* Frontend guard interval */
    176 typedef enum fe_guard_interval {
    177 	GUARD_INTERVAL_1_32,
    178 	GUARD_INTERVAL_1_16,
    179 	GUARD_INTERVAL_1_8,
    180 	GUARD_INTERVAL_1_4,
    181 	GUARD_INTERVAL_AUTO,
    182 	GUARD_INTERVAL_1_128,
    183 	GUARD_INTERVAL_19_128,
    184 	GUARD_INTERVAL_19_256,
    185 } fe_guard_interval_t;
    186 
    187 /* Frontend hierarchy */
    188 typedef enum fe_hierarchy {
    189 	HIERARCHY_NONE,
    190 	HIERARCHY_1,
    191 	HIERARCHY_2,
    192 	HIERARCHY_4,
    193 	HIERARCHY_AUTO
    194 } fe_hierarchy_t;
    195 
    196 /* QPSK parameters */
    197 struct dvb_qpsk_parameters {
    198 	uint32_t	symbol_rate;
    199 	fe_code_rate_t	fec_inner;
    200 };
    201 
    202 /* QAM parameters */
    203 struct dvb_qam_parameters {
    204 	uint32_t	symbol_rate;
    205 	fe_code_rate_t	fec_inner;
    206 	fe_modulation_t	modulation;
    207 };
    208 
    209 /* VSB parameters */
    210 struct dvb_vsb_parameters {
    211 	fe_modulation_t	modulation;
    212 };
    213 
    214 /* OFDM parameters */
    215 struct dvb_ofdm_parameters {
    216 	fe_bandwidth_t		bandwidth;
    217 	fe_code_rate_t		code_rate_HP;
    218 	fe_code_rate_t		code_rate_LP;
    219 	fe_modulation_t		constellation;
    220 	fe_transmit_mode_t	transmission_mode;
    221 	fe_guard_interval_t	guard_interval;
    222 	fe_hierarchy_t		hierarchy_information;
    223 };
    224 
    225 /* Frontend parameters */
    226 struct dvb_frontend_parameters {
    227 	uint32_t		frequency;
    228 	fe_spectral_inversion_t	inversion;
    229 	union {
    230 		struct dvb_qpsk_parameters	qpsk;
    231 		struct dvb_qam_parameters	qam;
    232 		struct dvb_ofdm_parameters	ofdm;
    233 		struct dvb_vsb_parameters	vsb;
    234 	} u;
    235 };
    236 
    237 /* Frontend events */
    238 struct dvb_frontend_event {
    239 	fe_status_t			status;
    240 	struct dvb_frontend_parameters	parameters;
    241 };
    242 
    243 /* DiSEqC master command */
    244 struct dvb_diseqc_master_cmd {
    245 	uint8_t		msg[6];
    246 	uint8_t		msg_len;
    247 };
    248 
    249 /* DiSEqC slave reply */
    250 struct dvb_diseqc_slave_reply {
    251 	uint8_t		msg[4];
    252 	uint8_t		msg_len;
    253 	int		timeout;
    254 };
    255 
    256 /* SEC voltage */
    257 typedef enum fe_sec_voltage {
    258 	SEC_VOLTAGE_13,
    259 	SEC_VOLTAGE_18,
    260 	SEC_VOLTAGE_OFF,
    261 } fe_sec_voltage_t;
    262 
    263 /* SEC continuous tone */
    264 typedef enum fe_sec_tone_mode {
    265 	SEC_TONE_ON,
    266 	SEC_TONE_OFF,
    267 } fe_sec_tone_mode_t;
    268 
    269 /* SEC tone burst */
    270 typedef enum fe_sec_mini_cmd {
    271 	SEC_MINI_A,
    272 	SEC_MINI_B,
    273 } fe_sec_mini_cmd_t;
    274 
    275 #define	FE_READ_STATUS		   _IOR('D', 0, fe_status_t)
    276 #define	FE_READ_BER		   _IOR('D', 1, uint32_t)
    277 #define	FE_READ_SNR		   _IOR('D', 2, uint16_t)
    278 #define	FE_READ_SIGNAL_STRENGTH	   _IOR('D', 3, uint16_t)
    279 #define	FE_READ_UNCORRECTED_BLOCKS _IOR('D', 4, uint32_t)
    280 #define	FE_SET_FRONTEND		   _IOWR('D', 5, struct dvb_frontend_parameters)
    281 #define	FE_GET_FRONTEND		   _IOR('D', 6, struct dvb_frontend_parameters)
    282 #define	FE_GET_EVENT		   _IOR('D', 7, struct dvb_frontend_event)
    283 #define	FE_GET_INFO		   _IOR('D', 8, struct dvb_frontend_info)
    284 #define	FE_DISEQC_RESET_OVERLOAD   _IO('D', 9)
    285 #define	FE_DISEQC_SEND_MASTER_CMD  _IOW('D', 10, struct dvb_diseqc_master_cmd)
    286 #define	FE_DISEQC_RECV_SLAVE_REPLY _IOR('D', 11, struct dvb_diseqc_slave_reply)
    287 #define	FE_DISEQC_SEND_BURST	   _IOW('D', 12, fe_sec_mini_cmd_t)
    288 #define	FE_SET_TONE		   _IOW('D', 13, fe_sec_tone_mode_t)
    289 #define	FE_SET_VOLTAGE		   _IOW('D', 14, fe_sec_voltage_t)
    290 #define	FE_ENABLE_HIGH_LNB_VOLTAGE _IOW('D', 15, int)
    291 #define	FE_SET_FRONTEND_TUNE_MODE  _IOW('D', 16, unsigned int)
    292 #define	FE_DISHNETWORK_SEND_LEGACY_CMD _IOW('D', 17, unsigned long)
    293 
    294 #endif /* !_DEV_DTV_DTVIO_FRONTEND_H */
    295