fix vga setting on freq change

This commit is contained in:
Carl 2024-03-28 14:04:06 +08:00
parent 4765898783
commit 065e3d1a11
2 changed files with 26 additions and 18 deletions

View File

@ -118,5 +118,6 @@ int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq);
int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain);
int r82xx_set_bandwidth(struct r82xx_priv *priv, int bandwidth, uint32_t rate);
int r82xx_toggle_test(struct r82xx_priv *priv, int toggle);
int r82xx_set_vga_gain(struct r82xx_priv *priv);
#endif

View File

@ -986,16 +986,7 @@ int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain)
if (rc < 0)
return rc;
/* set fixed VGA gain based on frequency */
if (priv->rf_freq > MHZ(1500)) {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0f, 0x9f); // Max 40.5 dB
}
else if (priv->rf_freq > MHZ(1000)) {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0b, 0x9f);
}
else {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x08, 0x9f); // 16.3 dB
}
rc = r82xx_set_vga_gain(priv);
if (rc < 0)
return rc;
@ -1031,14 +1022,8 @@ int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain)
if (rc < 0)
return rc;
/* set fixed VGA gain based on frequency */
if (priv->rf_freq > MHZ(1500)) {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0f, 0x9f);
}
else {
/* set fixed VGA gain for now (26.5 dB) */
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0b, 0x9f);
}
/* set fixed VGA gain for now (26.5 dB) */
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0b, 0x9f);
if (rc < 0)
return rc;
@ -1047,6 +1032,24 @@ int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain)
return 0;
}
int r82xx_set_vga_gain(struct r82xx_priv *priv) {
int rc;
/* set fixed VGA gain based on frequency */
if (priv->rf_freq > MHZ(1350)) {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0f, 0x9f); // Max 40.5 dB
}
else if (priv->rf_freq > MHZ(1000)) {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x0b, 0x9f);
}
else {
rc = r82xx_write_reg_mask(priv, 0x0c, 0x08, 0x9f); // 16.3 dB
}
return rc;
}
/* Bandwidth contribution by low-pass filter. */
static const int r82xx_if_low_pass_bw_table[] = {
1700000, 1600000, 1550000, 1450000, 1200000, 900000, 700000, 550000, 450000, 350000
@ -1168,6 +1171,10 @@ int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq)
if (rc < 0)
goto err;
rc = r82xx_set_vga_gain(priv);
if (rc < 0)
goto err;
rc = r82xx_set_pll(priv, lo_freq);
if (rc < 0 || !priv->has_lock)
goto err;