From 31ad4d80bf0c1ef7beeac29dbd3e1a8814974381 Mon Sep 17 00:00:00 2001 From: Tom Richardson Date: Tue, 10 Jan 2023 09:14:31 -0500 Subject: [PATCH] AVL62X1: refactor update_fe_props to use new S2X enums when available AVL68X2: fix bug in avl68x2_demod_get_ssi() Firmware: AVL62X1 FW 1.8.28971 --- .vscode/c_cpp_properties.json | 6 +- availink/avl62x1/avl62x1.h | 9 + availink/avl62x1/avl62x1_top.c | 216 +++++++++++++++----- availink/avl62x1/sdk_src/avl62x1_lib.h | 2 +- availink/avl68x2/sdk_src/avl68x2_common.c | 3 +- availink/avl68x2/sdk_src/avl68x2_internal.h | 2 +- availink/common/avl_bsp.h | 2 +- firmware | 2 +- 8 files changed, 179 insertions(+), 63 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 427f804..c5922ff 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,14 +5,14 @@ "name": "Linux-5.3.0", "includePath": [ "${workspaceFolder}/**", - "/usr/src/linux-headers-5.3.0-26-lowlatency/include/**", - "/usr/src/linux-headers-5.3.0-26-lowlatency/arch/x86/include/**" + "${HOME}/linux/include/**", + "${HOME}/linux/arch/x86/include/**" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c99", "cppStandard": "c++17", - "intelliSenseMode": "clang-x64" + "intelliSenseMode": "linux-gcc-x64" } ], "version": 4 diff --git a/availink/avl62x1/avl62x1.h b/availink/avl62x1/avl62x1.h index 3b5a8b3..b38f654 100644 --- a/availink/avl62x1/avl62x1.h +++ b/availink/avl62x1/avl62x1.h @@ -10,6 +10,7 @@ #ifndef _AVL62X1_H_ #define _AVL62X1_H_ +#include #include #include #include @@ -20,6 +21,8 @@ #define str(a) #a #define xstr(a) str(a) +#define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) + #define DVB_VER_INT(maj,min) (((maj) << 16) + (min)) #define DVB_VER_ATLEAST(maj, min) \ (DVB_VER_INT(DVB_API_VERSION, DVB_API_VERSION_MINOR) >= DVB_VER_INT(maj, min)) @@ -28,6 +31,12 @@ #define AVL62X1_VERSION xstr(AVL62X1_VER_MAJOR) "." xstr(AVL62X1_VER_MINOR) "." xstr(AVL62X1_VER_BUILD) +#ifndef AVL_S2X_ENUMS +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)) //because nobody bothered to rev DVB_API_VERSION_MINOR :shrug: +#define AVL_S2X_ENUMS +#endif +#endif + #define AVL62X1_BS_CTRL_PROP isdbt_sb_segment_idx //isdbt_sb_segment_idx fields #define AVL62X1_BS_CTRL_VALID_STREAM_MASK (0x80000000) diff --git a/availink/avl62x1/avl62x1_top.c b/availink/avl62x1/avl62x1_top.c index 9acce16..5547e12 100644 --- a/availink/avl62x1/avl62x1_top.c +++ b/availink/avl62x1/avl62x1_top.c @@ -108,6 +108,133 @@ static ssize_t i2cctl_dev_read(struct file *, char *, size_t, loff_t *); static ssize_t i2cctl_dev_write(struct file *, const char *, size_t, loff_t *); static long i2cctl_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg); +static unsigned char modcod[32][2] = //indexed by PLS/4 +{ + {QAM_AUTO, FEC_AUTO}, //0 DUMMY PLFRAME + +#ifdef AVL_S2X_ENUMS //Even though 1/4 and 1/3 are NOT S2X specific!!! + {QPSK, FEC_1_4}, //1 + {QPSK, FEC_1_3}, //2 +#else + {QPSK, FEC_AUTO}, + {QPSK, FEC_AUTO}, +#endif + {QPSK, FEC_2_5}, //3 + {QPSK, FEC_1_2}, + {QPSK, FEC_3_5}, + {QPSK, FEC_2_3}, + {QPSK, FEC_3_4}, + {QPSK, FEC_4_5}, + {QPSK, FEC_5_6}, + {QPSK, FEC_8_9}, + {QPSK, FEC_9_10}, //11 + + {PSK_8, FEC_3_5}, //12 + {PSK_8, FEC_2_3}, + {PSK_8, FEC_3_4}, + {PSK_8, FEC_5_6}, + {PSK_8, FEC_8_9}, + {PSK_8, FEC_9_10}, + + {APSK_16, FEC_2_3}, //18 + {APSK_16, FEC_3_4}, + {APSK_16, FEC_4_5}, + {APSK_16, FEC_5_6}, + {APSK_16, FEC_8_9}, + {APSK_16, FEC_9_10}, + + {APSK_32, FEC_3_4}, //24 + {APSK_32, FEC_4_5}, + {APSK_32, FEC_5_6}, + {APSK_32, FEC_8_9}, + {APSK_32, FEC_9_10}, + + {QAM_AUTO, FEC_AUTO}, //29 Reserved + {QAM_AUTO, FEC_AUTO}, //30 Reserved + {QAM_AUTO, FEC_AUTO}, //31 Reserved +}; + +#ifdef AVL_S2X_ENUMS +static unsigned char s2x_modcod[][2] = //indexed by (PLS-128)/2 +{ + {QAM_AUTO, FEC_AUTO}, //128 VL SNR set 1 UNIMP + {QAM_AUTO, FEC_AUTO}, //130 VL SNR set 2 UNIMP + + //Long code + {QPSK, FEC_13_45}, //132 + {QPSK, FEC_9_20}, + {QPSK, FEC_11_20}, + + {APSK_8_L, FEC_5_9}, //138 + {APSK_8_L, FEC_26_45}, + {PSK_8, FEC_23_36}, //142 + {PSK_8, FEC_25_36}, + {PSK_8, FEC_13_18}, + + {APSK_16_L, FEC_1_2}, //148 + {APSK_16_L, FEC_8_15}, + {APSK_16_L, FEC_5_9}, + {APSK_16, FEC_26_45}, //154 + {APSK_16, FEC_3_5}, + {APSK_16_L, FEC_3_5}, //158 + {APSK_16, FEC_28_45}, //160 + {APSK_16, FEC_23_36}, + {APSK_16_L, FEC_2_3}, //164 + {APSK_16, FEC_25_36}, //166 + {APSK_16, FEC_13_18}, + {APSK_16, FEC_7_9}, + {APSK_16, FEC_77_90}, + + {APSK_32_L, FEC_2_3}, //174 + {QAM_AUTO, FEC_AUTO}, //176 UNUSED + {APSK_32, FEC_32_45}, //178 + {APSK_32, FEC_11_15}, + {APSK_32, FEC_7_9}, + + {APSK_64_L, FEC_32_45}, //184 + {APSK_64, FEC_11_15}, + {QAM_AUTO, FEC_AUTO}, //188 UNUSED + {APSK_64, FEC_7_9}, //190 + {QAM_AUTO, FEC_AUTO}, //192 UNUSED + {APSK_64, FEC_4_5}, //194 + {QAM_AUTO, FEC_AUTO}, //196 UNUSED + {APSK_64, FEC_5_6}, //198 + + {QAM_AUTO, FEC_AUTO}, //200-202 UNIMP 128APSK + {QAM_AUTO, FEC_AUTO}, + + {QAM_AUTO, FEC_AUTO}, //204 UNIMP 256APSK(L) + {QAM_AUTO, FEC_AUTO}, + {QAM_AUTO, FEC_AUTO}, + {QAM_AUTO, FEC_AUTO}, + {QAM_AUTO, FEC_AUTO}, + {QAM_AUTO, FEC_AUTO}, //214 + + //Short code + //11/45, 4/15, 14/15, 7/15 not included in S2X additions to DVB (?!!) + {QPSK, FEC_AUTO/*FEC_11_45*/}, //216 + {QPSK, FEC_AUTO/*FEC_4_15*/}, + {QPSK, FEC_AUTO/*FEC_14_15*/}, + {QPSK, FEC_AUTO/*FEC_7_15*/}, + {QPSK, FEC_8_15}, + {QPSK, FEC_32_45}, + + {PSK_8, FEC_AUTO/*FEC_7_15*/}, //228 + {PSK_8, FEC_8_15}, + {PSK_8, FEC_26_45}, + {PSK_8, FEC_32_45}, + + {APSK_16, FEC_AUTO/*FEC_7_15*/}, //236 + {APSK_16, FEC_8_15}, + {APSK_16, FEC_26_45}, + {APSK_16, FEC_3_5}, + {APSK_16, FEC_32_45}, + + {APSK_32, FEC_2_3}, //246 + {APSK_32, FEC_32_45} +}; +#endif + static struct file_operations i2cctl_fops = { .owner = THIS_MODULE, @@ -749,22 +876,6 @@ static int update_fe_props( props->frequency = carrier_info->rf_freq_khz + carrier_info->carrier_freq_offset_hz/1000; - switch (carrier_info->modulation) - { - case avl62x1_qpsk: - props->modulation = QPSK; - break; - case avl62x1_8psk: - props->modulation = PSK_8; - break; - case avl62x1_16apsk: - props->modulation = APSK_16; - break; - default: //DVBv5 has no >=APSK_64 - props->modulation = APSK_32; - break; - } - props->inversion = (carrier_info->spectrum_invert == avl62x1_specpol_inverted) ? INVERSION_ON @@ -772,15 +883,6 @@ static int update_fe_props( props->symbol_rate = carrier_info->symbol_rate_hz; - if (carrier_info->pilot == avl62x1_pilot_on) - { - props->pilot = PILOT_ON; - } - else - { - props->pilot = PILOT_OFF; - } - switch (carrier_info->roll_off) { case avl62x1_rolloff_35: @@ -792,6 +894,17 @@ static int update_fe_props( case avl62x1_rolloff_20: props->rolloff = ROLLOFF_20; break; +#ifdef AVL_S2X_ENUMS + case avl62x1_rolloff_15: + props->rolloff = ROLLOFF_15; + break; + case avl62x1_rolloff_10: + props->rolloff = ROLLOFF_10; + break; + case avl62x1_rolloff_05: + props->rolloff = ROLLOFF_5; + break; +#endif default: props->rolloff = ROLLOFF_20; } @@ -799,37 +912,32 @@ static int update_fe_props( if (carrier_info->signal_type == avl62x1_dvbs2) { props->delivery_system = SYS_DVBS2; - switch (carrier_info->code_rate.dvbs2_code_rate) + if(carrier_info->dvbs2_ccm_acm == avl62x1_dvbs2_ccm) { - case avl62x1_dvbs2_cr_2_5: - props->fec_inner = FEC_2_5; - break; - case avl62x1_dvbs2_cr_1_2: - props->fec_inner = FEC_1_2; - break; - case avl62x1_dvbs2_cr_3_5: - props->fec_inner = FEC_3_5; - break; - case avl62x1_dvbs2_cr_2_3: - props->fec_inner = FEC_2_3; - break; - case avl62x1_dvbs2_cr_3_4: - props->fec_inner = FEC_3_4; - break; - case avl62x1_dvbs2_cr_4_5: - props->fec_inner = FEC_4_5; - break; - case avl62x1_dvbs2_cr_5_6: - props->fec_inner = FEC_5_6; - break; - case avl62x1_dvbs2_cr_8_9: - props->fec_inner = FEC_8_9; - break; - case avl62x1_dvbs2_cr_9_10: - props->fec_inner = FEC_9_10; - break; - default: //DVBv5 missing many rates (e.g. all S2/X) +#ifdef AVL_S2X_ENUMS + if(carrier_info->pls_acm >= 128) + { + int idx = (carrier_info->pls_acm-128)/2; + idx = (idx >= ARRAY_LENGTH(s2x_modcod)) ? 0 : idx; + props->modulation = s2x_modcod[idx][0]; + props->fec_inner = s2x_modcod[idx][1]; + } + else +#endif + { + int idx = carrier_info->pls_acm / 4; + idx = (idx >= ARRAY_LENGTH(modcod)) ? 0 : idx; + props->modulation = modcod[idx][0]; + props->fec_inner = modcod[idx][1]; + } + + props->pilot = (carrier_info->pls_acm & 1) ? PILOT_ON : PILOT_OFF; + } + else + { + props->modulation = QAM_AUTO; props->fec_inner = FEC_AUTO; + props->pilot = PILOT_ON; } } else diff --git a/availink/avl62x1/sdk_src/avl62x1_lib.h b/availink/avl62x1/sdk_src/avl62x1_lib.h index 5788abc..cb37f6e 100644 --- a/availink/avl62x1/sdk_src/avl62x1_lib.h +++ b/availink/avl62x1/sdk_src/avl62x1_lib.h @@ -19,7 +19,7 @@ //build number = increment on every change to implementation #define AVL62X1_VER_MAJOR 3 #define AVL62X1_VER_MINOR 8 -#define AVL62X1_VER_BUILD 5 +#define AVL62X1_VER_BUILD 6 #define AVL62X1_CHIP_ID 0x62615ca8 diff --git a/availink/avl68x2/sdk_src/avl68x2_common.c b/availink/avl68x2/sdk_src/avl68x2_common.c index 33747ff..61961a7 100644 --- a/availink/avl68x2/sdk_src/avl68x2_common.c +++ b/availink/avl68x2/sdk_src/avl68x2_common.c @@ -115,7 +115,6 @@ avl_error_code_t avl68x2_demod_get_sqi (uint16_t * pusSQI, avl68x2_chip *chip) avl_error_code_t avl68x2_demod_get_ssi(uint16_t *pusSSI, avl68x2_chip *chip) { avl_error_code_t r = AVL_EC_OK; - uint32_t rx_aagc_control; AVL_AGCPola agc_polarity = AVL_AGC_NORMAL; if (chip->chip_pub->cur_demod_mode == AVL_DVBSX) @@ -134,7 +133,7 @@ avl_error_code_t avl68x2_demod_get_ssi(uint16_t *pusSSI, avl68x2_chip *chip) if (agc_polarity == AVL_AGC_INVERTED) { - pusSSI = ~(*pusSSI); + *pusSSI = ~(*pusSSI); } return (r); diff --git a/availink/avl68x2/sdk_src/avl68x2_internal.h b/availink/avl68x2/sdk_src/avl68x2_internal.h index bf6f345..6d21f7a 100644 --- a/availink/avl68x2/sdk_src/avl68x2_internal.h +++ b/availink/avl68x2/sdk_src/avl68x2_internal.h @@ -17,7 +17,7 @@ //build number = increment on every change to implementation #define AVL68X2_VER_MAJOR 2 #define AVL68X2_VER_MINOR 19 -#define AVL68X2_VER_BUILD 4 +#define AVL68X2_VER_BUILD 5 #define AVL68XX 0x68624955 diff --git a/availink/common/avl_bsp.h b/availink/common/avl_bsp.h index b4fb457..c528aef 100644 --- a/availink/common/avl_bsp.h +++ b/availink/common/avl_bsp.h @@ -18,7 +18,7 @@ #include #include #endif -#include +#include typedef struct mutex avl_sem_t; /********************************/ diff --git a/firmware b/firmware index f7246b1..678929e 160000 --- a/firmware +++ b/firmware @@ -1 +1 @@ -Subproject commit f7246b13649ca76e6a25784aa793acbfaf5f563a +Subproject commit 678929e241ad6563c66af032f40fd0ca4f2ee640