| 1 |
/* |
| 2 |
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab |
| 3 |
* Copyright (c) 2012 - Andre Roth <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU Lesser General Public License as published by |
| 7 |
* the Free Software Foundation version 2.1 of the License. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 |
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include <libdvbv5/desc_sat.h> |
| 22 |
#include <libdvbv5/dvb-fe.h> |
| 23 |
|
| 24 |
#if __GNUC__ >= 9 |
| 25 |
#pragma GCC diagnostic ignored "-Waddress-of-packed-member" |
| 26 |
#endif |
| 27 |
|
| 28 |
int dvb_desc_sat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc) |
| 29 |
{ |
| 30 |
struct dvb_desc_sat *sat = (struct dvb_desc_sat *) desc; |
| 31 |
ssize_t size = sizeof(struct dvb_desc_sat) - sizeof(struct dvb_desc); |
| 32 |
|
| 33 |
if (size > desc->length) { |
| 34 |
dvb_logerr("dvb_desc_sat_init short read %d/%zd bytes", desc->length, size); |
| 35 |
return -1; |
| 36 |
} |
| 37 |
|
| 38 |
memcpy(desc->data, buf, size); |
| 39 |
bswap16(sat->orbit); |
| 40 |
bswap32(sat->bitfield); |
| 41 |
bswap32(sat->frequency); |
| 42 |
sat->orbit = dvb_bcd(sat->orbit); |
| 43 |
sat->frequency = dvb_bcd(sat->frequency) * 10; |
| 44 |
sat->symbol_rate = dvb_bcd(sat->symbol_rate) * 100; |
| 45 |
|
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
void dvb_desc_sat_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) |
| 50 |
{ |
| 51 |
const struct dvb_desc_sat *sat = (const struct dvb_desc_sat *) desc; |
| 52 |
char pol; |
| 53 |
switch(sat->polarization) { |
| 54 |
case 0: |
| 55 |
pol = 'H'; |
| 56 |
break; |
| 57 |
case 1: |
| 58 |
pol = 'V'; |
| 59 |
break; |
| 60 |
case 2: |
| 61 |
pol = 'L'; |
| 62 |
break; |
| 63 |
case 3: |
| 64 |
pol = 'R'; |
| 65 |
break; |
| 66 |
} |
| 67 |
dvb_loginfo("| modulation_system %s", sat->modulation_system ? "DVB-S2" : "DVB-S"); |
| 68 |
dvb_loginfo("| frequency %d %c", sat->frequency, pol); |
| 69 |
dvb_loginfo("| symbol_rate %d", sat->symbol_rate); |
| 70 |
dvb_loginfo("| fec %d", sat->fec); |
| 71 |
dvb_loginfo("| modulation_type %d", sat->modulation_type); |
| 72 |
dvb_loginfo("| roll_off %d", sat->roll_off); |
| 73 |
dvb_loginfo("| orbit %.1f %c", (float) sat->orbit / 10.0, sat->west_east ? 'E' : 'W'); |
| 74 |
} |
| 75 |
|
| 76 |
const unsigned dvbs_dvbc_dvbs_freq_inner[] = { |
| 77 |
[0] = FEC_AUTO, |
| 78 |
[1] = FEC_1_2, |
| 79 |
[2] = FEC_2_3, |
| 80 |
[3] = FEC_3_4, |
| 81 |
[4] = FEC_5_6, |
| 82 |
[5] = FEC_7_8, |
| 83 |
[6] = FEC_8_9, |
| 84 |
[7] = FEC_3_5, |
| 85 |
[8] = FEC_4_5, |
| 86 |
[9] = FEC_9_10, |
| 87 |
[10 ...14] = FEC_AUTO, /* Currently, undefined */ |
| 88 |
[15] = FEC_NONE, |
| 89 |
}; |
| 90 |
|
| 91 |
const unsigned dvbs_polarization[] = { |
| 92 |
[0] = POLARIZATION_H, |
| 93 |
[1] = POLARIZATION_V, |
| 94 |
[2] = POLARIZATION_L, |
| 95 |
[3] = POLARIZATION_R |
| 96 |
}; |
| 97 |
|
| 98 |
const unsigned dvbs_rolloff[] = { |
| 99 |
[0] = ROLLOFF_35, |
| 100 |
[1] = ROLLOFF_25, |
| 101 |
[2] = ROLLOFF_20, |
| 102 |
[3] = ROLLOFF_AUTO, /* Reserved */ |
| 103 |
}; |
| 104 |
|
| 105 |
const unsigned dvbs_modulation[] = { |
| 106 |
[0] = QAM_AUTO, |
| 107 |
[1] = QPSK, |
| 108 |
[2] = PSK_8, |
| 109 |
[3] = QAM_16 |
| 110 |
}; |
| 111 |
|