Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3128894pxk; Tue, 15 Sep 2020 10:44:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdWipjLuwChv6iTAUBC7nEZgdUrqf/ptGbT4kklqYBCyR2NbPQcVPMAKDlnd1gU0iG8gik X-Received: by 2002:a17:906:4dc7:: with SMTP id f7mr21697238ejw.261.1600191861630; Tue, 15 Sep 2020 10:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600191861; cv=none; d=google.com; s=arc-20160816; b=isEAfsThO91by3U2+xFPfuOAmcRuw7dLRouplIeKC/tqfX+LJidvzdOGcAWr3ZAEYX kx4aKSSTE2OkhW/zLdrup4+H8/0SX3lB3OBulSFIBPcuaEPA1WjU+ZLWZQri8u+e5vcK NcON4yUA490OOD8gptdjMjlAsc04fS8sZ22tF+EGPrg26mx17Pxcpu4PdCskm4Cjqjni Rlsm3Nt4ARVPkG+tD3QdWGsjQ9mzh50qgB5hJr2PE/5ArJxgcaKzSgZA8goX3CRiwiwU QuQa/IOPXMIs7R3NdnrmiOyEs0HhGMTFaFnU4cHlyUpWXSJaVab/crhK2/TUMAGlwTg5 rHMA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vd5r3TeLsaCA/FonKoaEEnRN1IsGwZeTfuAzbxCS9yE=; b=O1AQgG5KexYrcvOhSWcq3YUVEx+RHLrz3YG58TmL7G++Y50Y2V9OwRmA1VniYEzt/g FoNgPR7Vgac1+BW99wqBBG9fQmp/M50xd3RBcbxv/NxYuH+ZSbAWHGIRpJEkT3tE65w0 W7IJuOT8AA8hx5uQvQIGf4kSzWFtQrJyxZL3om+J55zEt3tkRypRQdxkNOR9ze8lrFc/ 6kiPkjNCaKUhadgJVIOCxxl8dPtn1omZex4tx6VjAwD2R6aI/L8+4LZLO63yg8qCWYDJ ancdgO+mi53C2LzKjFadA/0bIGimc1Aw4GPzjB/3KqP2fVh1CCglp6wE1kuv6HJ07SOP 9ZOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Hf+jhrcN; 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 nu23si9522700ejb.577.2020.09.15.10.43.41; Tue, 15 Sep 2020 10:44:21 -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=Hf+jhrcN; 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 S1727908AbgIORn0 (ORCPT + 99 others); Tue, 15 Sep 2020 13:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbgIORl7 (ORCPT ); Tue, 15 Sep 2020 13:41:59 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9403C06178A for ; Tue, 15 Sep 2020 10:41:58 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 7so2339128pgm.11 for ; Tue, 15 Sep 2020 10:41:58 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vd5r3TeLsaCA/FonKoaEEnRN1IsGwZeTfuAzbxCS9yE=; b=Hf+jhrcNZa13owORLbemg2thCh3yoSHlopNqRTy3NhCi64Q5cxIY9uh3MlBm9VYqqD oZ8QezExrZQcda/PDQ+rS3YMxsNmumyGImBpM4BNdQI5l1rzlYxn8TcVpE+smxeowz/L 1TJ1A1fAMx7HVRa1C/Qi/gQ01fWcmRtLgGfvI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vd5r3TeLsaCA/FonKoaEEnRN1IsGwZeTfuAzbxCS9yE=; b=LwCmN/K8a2LI3dvKZGDTC7v2hyzJED2ldvkJzC3BcA9veKR64+zRsumYAv02vhwQqb RzkMznAfxXdQWAozlYiJKlh/orpo/R41y2XEfaZLxDH0ZpjUxKxKTaXwBoxrX6GCJWzI v9yBccv1hw6UVgsgcDvsLHDoxKjwkFDIoPvfNeyA8LdLWbmwa+3CiXt1mBohKkpZ/tB3 o6bh7tATGKUkXKmYV1DBSLmCZsCsI2XenwwMLnpDVOwwjKwDwhS1tRxOFRGaCJu3XN6k p92bux6lOYBz4BbtCpYolqB/7q+8VxoLdqJ9uBdRhwByM38OyuYY78Pjw6sYC5kkdmOe QERA== X-Gm-Message-State: AOAM530bPXS4TgE5lx9TM2i9TFF40Rg2cwI6wSr63HczmlvrPsKwGo5R 1ZVfhgdudfixT9e7yoQfbRXSQQ== X-Received: by 2002:a63:d648:: with SMTP id d8mr15441341pgj.4.1600191718408; Tue, 15 Sep 2020 10:41:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 10:41:57 -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 2/4] adapter: Handle controller resume and notify drivers Date: Tue, 15 Sep 2020 10:41:44 -0700 Message-Id: <20200915104127.Bluez.v5.2.Ic6aa9c03323b5ef0265e5b5b36986af05d9ecd26@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> References: <20200915174146.1693687-1-abhishekpandit@chromium.org> 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 Register for controller resume notification and notify the adapter drivers when it occurs. Also adds the resume event kernel feature to make sure the kernel supports this event. --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/adapter.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 88b5202d9..b431097f2 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -8771,6 +8771,33 @@ static void connected_callback(uint16_t index, uint16_t length, eir_data_free(&eir_data); } +static void controller_resume_notify(struct btd_adapter *adapter) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + if (driver->resume) + driver->resume(adapter); + } +} + +static void controller_resume_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_controller_resume *ev = param; + struct btd_adapter *adapter = user_data; + + if (length < sizeof(*ev)) { + btd_error(adapter->dev_id, "Too small device resume event"); + return; + } + + info("Controller resume with wake event 0x%x", ev->wake_reason); + + controller_resume_notify(adapter); +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9394,6 +9421,11 @@ static void read_info_complete(uint8_t status, uint16_t length, user_passkey_notify_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_CONTROLLER_RESUME, + adapter->dev_id, + controller_resume_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); @@ -9604,6 +9636,17 @@ static void read_commands_complete(uint8_t status, uint16_t length, break; } } + + for (i = 0; i < num_events; i++) { + uint16_t ev = get_le16(rp->opcodes + num_commands + i); + + switch(ev) { + case MGMT_EV_CONTROLLER_RESUME: + DBG("kernel supports suspend/resume events"); + kernel_features |= KERNEL_HAS_RESUME_EVT; + break; + } + } } static void read_version_complete(uint8_t status, uint16_t length, diff --git a/src/adapter.h b/src/adapter.h index b0ed4915f..fae2e9d3d 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -113,6 +113,7 @@ struct btd_adapter_driver { const char *name; int (*probe) (struct btd_adapter *adapter); void (*remove) (struct btd_adapter *adapter); + void (*resume) (struct btd_adapter *adapter); }; typedef void (*service_auth_cb) (DBusError *derr, void *user_data); @@ -239,6 +240,7 @@ enum kernel_features { KERNEL_BLOCKED_KEYS_SUPPORTED = 1 << 1, KERNEL_SET_SYSTEM_CONFIG = 1 << 2, KERNEL_EXP_FEATURES = 1 << 3, + KERNEL_HAS_RESUME_EVT = 1 << 4, }; bool has_kernel_features(uint32_t feature); -- 2.28.0.618.gf4bc123cb7-goog