From ff984192b4529d6684173fb098e8bd1901932ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Thu, 9 Oct 2025 21:58:39 +0200 Subject: [PATCH] shared/hfp: Add in-band ring tone setting support --- src/shared/hfp.c | 16 ++++++++++++++++ src/shared/hfp.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/shared/hfp.c b/src/shared/hfp.c index a6f9645d8..bc81a07ee 100644 --- a/src/shared/hfp.c +++ b/src/shared/hfp.c @@ -1752,6 +1752,20 @@ static bool call_active_match(const void *data, const void *match_data) return (call->status == CALL_STATUS_ACTIVE); } +static void bsir_cb(struct hfp_context *context, void *user_data) +{ + struct hfp_hf *hfp = user_data; + unsigned int val; + + DBG(hfp, ""); + + if (!hfp_context_get_number(context, &val)) + return; + + if (hfp->callbacks && hfp->callbacks->update_inband_ring) + hfp->callbacks->update_inband_ring(!!val, hfp->callbacks_data); +} + static void ciev_callsetup_cb(uint8_t val, void *user_data) { struct hfp_hf *hfp = user_data; @@ -2083,6 +2097,8 @@ static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err, } /* Register unsolicited results handlers */ + if (hfp->features & HFP_AG_FEAT_IN_BAND_RING_TONE) + hfp_hf_register(hfp, bsir_cb, "+BSIR", hfp, NULL); hfp_hf_register(hfp, ciev_cb, "+CIEV", hfp, NULL); hfp_hf_register(hfp, clip_cb, "+CLIP", hfp, NULL); hfp_hf_register(hfp, cops_cb, "+COPS", hfp, NULL); diff --git a/src/shared/hfp.h b/src/shared/hfp.h index 21214eee4..27315bfa0 100644 --- a/src/shared/hfp.h +++ b/src/shared/hfp.h @@ -201,6 +201,7 @@ struct hfp_hf_callbacks { void (*update_indicator)(enum hfp_indicator indicator, uint32_t val, void *user_data); void (*update_operator)(const char *operator_name, void *user_data); + void (*update_inband_ring)(bool enabled, void *user_data); void (*call_added)(uint id, enum hfp_call_status status, void *user_data); -- 2.47.3