Skip to content

Commit

Permalink
AVL62X1: refactor update_fe_props to use new S2X enums when available
Browse files Browse the repository at this point in the history
AVL68X2: fix bug in avl68x2_demod_get_ssi()
Firmware: AVL62X1 FW 1.8.28971
  • Loading branch information
Tom Richardson committed Jan 10, 2023
1 parent 991fdb4 commit 31ad4d8
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions availink/avl62x1/avl62x1.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef _AVL62X1_H_
#define _AVL62X1_H_

#include <linux/version.h>
#include <linux/firmware.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/version.h>
Expand All @@ -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))
Expand All @@ -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:

This comment has been minimized.

Copy link
@athoik

athoik Jan 10, 2023

I notice the update two days ago.

Today a patch was submitted https://patchwork.kernel.org/project/linux-media/patch/[email protected]/

#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)
Expand Down
216 changes: 162 additions & 54 deletions availink/avl62x1/avl62x1_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -749,38 +876,13 @@ 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
: INVERSION_OFF;

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:
Expand All @@ -792,44 +894,50 @@ 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;
}

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
Expand Down
2 changes: 1 addition & 1 deletion availink/avl62x1/sdk_src/avl62x1_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions availink/avl68x2/sdk_src/avl68x2_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion availink/avl68x2/sdk_src/avl68x2_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion availink/common/avl_bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <stdint.h>
#include <linux/types.h>
#endif
#include <stddef.h>
#include <linux/stddef.h>

typedef struct mutex avl_sem_t;
/********************************/
Expand Down
2 changes: 1 addition & 1 deletion firmware

0 comments on commit 31ad4d8

Please sign in to comment.