From 8ed6f42772f3002bfa1b8ef8772b138e8cddd443 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 4 Dec 2017 23:49:29 +0700 Subject: host/trxcon: forward Timing Advance value to transceiver The time at which the phone is allowed to transmit a burst of traffic within a timeslot must be adjusted accordingly to prevent collisions with adjacent users. Timing Advance (TA) is the variable controlling this adjustment. The TA value is normally between 0 and 63, with each step representing an advance of one bit period (approximately 3.69 microseconds). As trxcon doesn't perform actual burst transmission, this value needs to be forwarded to the transceiver, which will take care about the timings. Change-Id: Ia8c0848827ab2b4cd7cf1efe128b28d5c06ec84e --- src/host/trxcon/l1ctl.c | 5 ++++- src/host/trxcon/trx_if.c | 26 ++++++++++++++++++++++++++ src/host/trxcon/trx_if.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c index 6a9cdb3c..aeb6c07e 100644 --- a/src/host/trxcon/l1ctl.c +++ b/src/host/trxcon/l1ctl.c @@ -643,6 +643,7 @@ static int l1ctl_rx_param_req(struct l1ctl_link *l1l, struct msgb *msg) { struct l1ctl_par_req *par_req; struct l1ctl_info_ul *ul; + int rc = 0; ul = (struct l1ctl_info_ul *) msg->l1h; par_req = (struct l1ctl_par_req *) ul->payload; @@ -650,11 +651,13 @@ static int l1ctl_rx_param_req(struct l1ctl_link *l1l, struct msgb *msg) LOGP(DL1C, LOGL_NOTICE, "Received L1CTL_PARAM_REQ " "(ta=%d, tx_power=%u)\n", par_req->ta, par_req->tx_power); + rc |= trx_if_cmd_setta(l1l->trx, par_req->ta); + l1l->trx->ta = par_req->ta; l1l->trx->tx_power = par_req->tx_power; msgb_free(msg); - return 0; + return rc; } static int l1ctl_rx_tch_mode_req(struct l1ctl_link *l1l, struct msgb *msg) diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c index c9bf6c87..6ee75d3e 100644 --- a/src/host/trxcon/trx_if.c +++ b/src/host/trxcon/trx_if.c @@ -415,6 +415,32 @@ static void trx_if_measure_rsp_cb(struct trx_instance *trx, char *resp) trx_if_cmd_measure(trx, ++arfcn, trx->pm_arfcn_stop); } +/* + * Timing Advance control + * + * SETTA instructs the transceiver to transmit bursts in + * advance calculated from requested TA value. This value is + * normally between 0 and 63, with each step representing + * an advance of one bit period (about 3.69 microseconds). + * CMD SETTA <0-63> + * RSP SETTA + */ + +int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta) +{ + /* Do nothing, if requested TA value matches the current */ + if (trx->ta == ta) + return 0; + + /* Make sure that TA value is in valid range */ + if (ta < 0 || ta > 63) { + LOGP(DTRX, LOGL_ERROR, "TA value %d is out of allowed range\n", ta); + return -ENOTSUP; + } + + return trx_ctrl_cmd(trx, 0, "SETTA", "%d", ta); +} + /* Get response from CTRL socket */ static int trx_ctrl_read_cb(struct osmo_fd *ofd, unsigned int what) { diff --git a/src/host/trxcon/trx_if.h b/src/host/trxcon/trx_if.h index 02c9ff78..dd84315e 100644 --- a/src/host/trxcon/trx_if.h +++ b/src/host/trxcon/trx_if.h @@ -63,6 +63,8 @@ int trx_if_cmd_echo(struct trx_instance *trx); int trx_if_cmd_setpower(struct trx_instance *trx, int db); int trx_if_cmd_adjpower(struct trx_instance *trx, int db); +int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta); + int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t arfcn); int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t arfcn); -- cgit v1.2.3