Commit c8e93401 authored by Kalle Kietäväinen's avatar Kalle Kietäväinen Committed by Benjamin Cabé
Browse files

drivers: bluetooth: silabs: Set maximum TX power

Honor Kconfig option `BT_CTLR_TX_PWR_ANTENNA` for limiting the maximum TX
power. The default value for this option is 0 dBm, which means that after
this change the actual TX power is likely lower than before, unless
increased by this option.

Signed-off-by: default avatarKalle Kietäväinen <kalle.kietavainen@silabs.com>
parent 13ac8fe1
Loading
Loading
Loading
Loading
+15 −0
Changes for drivers/bluetooth/hci/hci_silabs_efr32.c: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ static struct k_fifo slz_rx_fifo;
/* FIXME: these functions should come from the SiSDK headers! */
void BTLE_LL_EventRaise(uint32_t events);
void BTLE_LL_Process(uint32_t events);
int16_t BTLE_LL_SetMaxPower(int16_t power);
bool sli_pending_btctrl_events(void);
RAIL_Handle_t BTLE_LL_GetRadioHandle(void);

@@ -256,6 +257,18 @@ static void slz_rx_thread_func(void *p1, void *p2, void *p3)
	}
}

static void slz_set_tx_power(int16_t max_power_dbm)
{
	const int16_t max_power_cbm = max_power_dbm * 10;
	const int16_t actual_max_power_cbm = BTLE_LL_SetMaxPower(max_power_cbm);
	const int16_t actual_max_power_dbm = DIV_ROUND_CLOSEST(actual_max_power_cbm, 10);

	if (actual_max_power_dbm != max_power_dbm) {
		LOG_WRN("Unable to set max TX power to %d dBm, actual max is %d dBm", max_power_dbm,
			actual_max_power_dbm);
	}
}

static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv)
{
	struct hci_data *hci = dev->data;
@@ -303,6 +316,8 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv)
		goto deinit;
	}

	slz_set_tx_power(CONFIG_BT_CTLR_TX_PWR_ANTENNA);

	sl_btctrl_init_adv();
	sl_btctrl_init_scan();
	sl_btctrl_init_conn();
+5 −0
Changes for modules/hal_silabs/simplicity_sdk/src/blob_stubs.c: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ void BTLE_LL_Process(uint32_t events)
{
}

int16_t BTLE_LL_SetMaxPower(int16_t power)
{
	return 0;
}

void sl_btctrl_disable_2m_phy(void)
{
}