Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3129520pxk; Tue, 15 Sep 2020 10:45:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzHbdlCRC5bLMOAMhAafNR1wZfU6DS7AnlfvrSW7V1cka9f0QQt3wTvXHVfcdnNpRd0Hpv X-Received: by 2002:aa7:d585:: with SMTP id r5mr23754602edq.278.1600191926208; Tue, 15 Sep 2020 10:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600191926; cv=none; d=google.com; s=arc-20160816; b=TSbU8kJ2lAICXRyy3oy3qQIc/x5QG+vNhtL93/sptZTg4pt5uYtQnnq8WA7il9mj6J Oyn9lAdSY4pGfFmpXl48lBGG2YFEpMlNUCTAsg+7PjTq+Dh5yRQEHCB0laH6alM8nU/X S3/JgB9N8tF4LX/B53vsdLav+2ezYN8sNgDk8Xs4Sv9sNSJbBIL58z/l4Tf4O23tTIHX F9v9WbHGQHDCkJvzfFp2l1fY79JhgUdPLFPhdmBLZPNFBky+9L5bQveOYDxT0XhnJp7j A0Tqt8Qo7YOi2Fo4kUwD2HhSib05Em9vB2Yj1UnoflFTeL99HddxKLaEC3n5Nz3LkyVF qVAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mSVukHJaf23dU18xrmYveJEVtHAOgsrL/FM6fto8MZ0=; b=KzFapc6DHw+Hv/lco2d4VCOo9PGS4nZ+TfqLsabUgQTfVbzhtGvGsT51KDE5M29M6e 0vM2SpR4ND6+2S10G/OQArCfGNmkzlwFekCj0wyDwsH7X3032xLbbfKJ6nO49x02dYTv XB43DEsiF3Vjux1idHHBOD8BsKw1cWmJYyJTeB8FbWJ89CKFba17an55DNck0iB4fuU9 JTdDk0EGeJj17wX05BLeLihb6PsTMaDqHO4KJ2U5GaNEMQPLZ8qyZYFsqI7MBh0AlQ52 80adFSXc2hyjV+Wpo53qAsFGOcdHkCC9Z4zWuJAtEF2FFjTqc3IYFI2q5kXroiI+E1e0 mPjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iL0KxC3J; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si10883584edl.504.2020.09.15.10.45.01; Tue, 15 Sep 2020 10:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iL0KxC3J; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbgIORmT (ORCPT + 99 others); Tue, 15 Sep 2020 13:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgIORl5 (ORCPT ); Tue, 15 Sep 2020 13:41:57 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3109C06174A for ; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id bd2so1724050plb.7 for ; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mSVukHJaf23dU18xrmYveJEVtHAOgsrL/FM6fto8MZ0=; b=iL0KxC3JRJNuDjTFZsEYYrqoKEgxAtpjRiXqy436MhG07ru7gDqa1a7R3MsDjmDSY8 Z6g7JzpYn0N11Lsbz2mjNuYm4QtAT5fH4MuxjHDPYow0U/QeLI765Jox8ermxjrEre1R wuvmzubPUJAi++Wd7AUVbfw0qZSYQSAWblpp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mSVukHJaf23dU18xrmYveJEVtHAOgsrL/FM6fto8MZ0=; b=c1PkMZS2p820SQcVY8yUh3N7lwUKuyfNeNlpOXu3frJFOUin3+O7WHBQb6bC168OOb qAAKMjq8A7o9PFHbaYpstC1U2c5T0Hr/5/9Yx3DgKH4J/yTb5PDdyCI3Aj+XKeNCD31k B/fkj8MsRQoBZbJxVnVCUbG4k5R9Xh/pKdIiucZzgCV9dXPDM2Wi4+IkWGnO5ng5fV2N rOXNxbyiyTd/KkcryBFrSgnZsqKwssVV8j4GO7Ei5Rsdl9C4ewQvGUWd/cULREliFHv6 613nXLKUqe0IqxXA862gwugB8LsmeJbbFQgeaP97OSLzIUp1+L9vbFtGqaCON/XVJrEI gn4w== X-Gm-Message-State: AOAM533l7sB3xZOFrQruIPKuKerZ4ipv+0jjAIUV523DsNWkQRvE0m6c W75xiuPb9iqlbHEi2jraZhiFMg== X-Received: by 2002:a17:90a:cb0f:: with SMTP id z15mr446612pjt.76.1600191716217; Tue, 15 Sep 2020 10:41:56 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id y29sm15490232pfq.207.2020.09.15.10.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:55 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi Subject: [Bluez PATCH v5 0/4] adapter: Reconnect audio when resuming from suspend Date: Tue, 15 Sep 2020 10:41:42 -0700 Message-Id: <20200915174146.1693687-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz and Marcel, This is a quality of life improvement for the behavior of audio devices during system suspend. This depends on a kernel change that emits suspend/resume events: https://patchwork.kernel.org/project/bluetooth/list/?series=325771 Right now, audio devices will be disconnected as part of suspend but won't be reconnected when the system resumes without user interaction. This is annoying to some users as it causes an interruption to their normal work flow. This change reconnects audio devices that were disconnected for suspend using the following logic: * In the device disconnect callback, mark any devices with the A2DP service uuid for reconnect. The reconnect will not be queued until resume. * In the controller resume callback, queue any policy items that are marked to reconnect on resume for connection with the ResumeDelay value (default = 2s). A reconnect is queued after the controller resumes and the delay between resume and reconnect is configurable via the ResumeDelay key in the Policy settings. The 2s delay was chosen arbitrarily and I think anywhere up to 10s is probably ok. A longer delay is better to account for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex issues) at the downside of reconnection speed. Here are the tests I have done with this: - Single suspend and verified the headphones reconnect - Suspend stress test for 25 iterations and verify both Wi-Fi and Bluetooth audio reconnect on resume. (Ran with wake minimum time of 10s) - Suspend test with wake time = 1s to verify that BT reconnect isn't attempted. Ran 5 iterations with low wake time and then let it stay awake to confirm reconnect finally completed on last resume. - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and verified it connected several times in the middle and finally at the end. I've tested this on a Pixelbook Go (AC-9260 controller) and HP Chromebook 14a (RTL8822CE controller) with GID6B headset. I've also tested this with the Pixel Buds 2. These earbuds actually reconnect automatically to the Chromebook (even without this policy change) and I verified that the new changes don't break the reconnection mechanism. Thanks Abhishek Changes in v5: - Remove use of !! in has_kernel_features Changes in v4: - Set reconnect timer in disconnect if resume events aren't supported - Only set reconnect timer if adapter matches current notification - Refactor changes in src/adapter to its own commit - Refactor enabling A2DP_SINK_UUID into its own commit Changes in v3: - Refactored resume notification to use btd_adapter_driver - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 - Added A2DP_SINK_UUID to default reconnect list Changes in v2: - Refactored to use policy instead of connecting directly in adapter Abhishek Pandit-Subedi (4): adapter: Refactor kernel feature globals adapter: Handle controller resume and notify drivers policy: Enable reconnect for a2dp-sink in defaults policy: Reconnect audio on controller resume plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- src/adapter.h | 11 +++++ src/main.c | 1 + src/main.conf | 11 ++++- 5 files changed, 168 insertions(+), 44 deletions(-) -- 2.28.0.618.gf4bc123cb7-goog