Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5160357rwb; Tue, 17 Jan 2023 09:55:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUbWKuSKbVErKP2IUZ8KjFFlwRXcgOG4tdAtVeoVbMB6VLsd71C9JSsUlV/ipWNElhxxcR X-Received: by 2002:a05:6402:5110:b0:499:bec8:4f with SMTP id m16-20020a056402511000b00499bec8004fmr5096923edd.20.1673978151173; Tue, 17 Jan 2023 09:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673978151; cv=none; d=google.com; s=arc-20160816; b=JlJRa8f2G4oLVcw9mW4EZqWSipUeETZI5p+KMRdBP+K9Eo7KMS5tDU+gQCBeWVDJTt cI7uCd4mnJFZ/FAmcmh8zpKwsTor2ctGaWbGAPz1H3T1PWA2HO/4cPibvjLgiKjghtm7 U0wjoCBm9JlYVBAmlu2pYolF2oe7njHJsojxD/MWb8cHUyLKFDokoLEnb9dXSEGvb/eu +HYZBoMmeks6pZB4NqYTUs7kZ3Qq0mcewhnt7Th9GH9hjXMdKuIeFvGvSidjAu+PdsYF dDQ1NQvx5YgQUdrf6S0JjOTqv05U5V4G1T7cKpVokk5oLI+2pFXNLRcZtNGWHwD8Rj5L IlFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=wjl53sXj7KPkYekofVBjYGzpf9ivflrw/Qsfu5IY5S0=; b=b3WNaKtY+W+3j17tBkXWXDU+VtrGTG268fYK9++Vf4OWS2/P7Sun2rXjediBuZ64Wd FnWT/q12b4UC4WjVFLnRIRnJHIe6Qy2fbq7JrKqLA0w6lvfCHmafbsm0+gRlgEAbz7du jcKV0ZR1NoyxC9ICdy0SPimbmAPEPJ2syynG3P3ma7zoeCXGOFyG89RMBJKtvVzqs4b3 GF2EWGbgpbCErKhr7YMKDecqK/f04Zn5VnsSk0T0uwUaOdd+ieFyqytCRMBPXreqx/Pc 2fz7pgXn91oeMOPyDNg5nXN2qNiiFJntVbtzjod9vHKA8W4G/2VEq8Kme6cdxrdTCM3L iriA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz35-20020a1709077da300b0086c92fed1edsi13501585ejc.949.2023.01.17.09.55.39; Tue, 17 Jan 2023 09:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232824AbjAQQgo convert rfc822-to-8bit (ORCPT + 48 others); Tue, 17 Jan 2023 11:36:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbjAQQgO (ORCPT ); Tue, 17 Jan 2023 11:36:14 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94603303CD; Tue, 17 Jan 2023 08:36:02 -0800 (PST) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 1570D24000B; Tue, 17 Jan 2023 16:35:58 +0000 (UTC) Message-ID: <83d8a06403d098f90760c199674ed585ca725b13.camel@hadess.net> Subject: Re: [RFC] USB: core: Add wireless_status sysfs attribute From: Bastien Nocera To: Alan Stern Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Date: Tue, 17 Jan 2023 17:35:58 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-01-17 at 11:01 -0500, Alan Stern wrote: > On Tue, Jan 17, 2023 at 04:17:23PM +0100, Bastien Nocera wrote: > > Hey, > > > > TLDR: new sysfs attribute that makes it possible to leave receivers > > for > > wireless headsets plugged in. At the USB level, or at the base > > driver > > level? > > > > Longer version: > > I started working on implementing support for some wireless > > headsets > > that use USB receivers to communicate to the headset itself. > > > > The USB receivers have multiple interfaces, and independent drivers > > for > > each, as is wont to do for USB devices. There's usually a HID > > interface > > to do the custom stuff (LEDs, battery status, connection status, > > etc.) > > and a standard audio class interface. > > > > Those drivers don't know anything about each other, and getting > > them to > > talk to each other would be rather complicated. Additionally the > > audio > > interface is still somewhat functional when the headset is > > disconnected. > > > > In the end, I came up with this new sysfs attribute that would make > > it > > possible for user-space (PulseAudio or Pipewire) to know whether > > the > > receiver is plugged in or not. > > > > That allows user-space to not show the battery information for the > > device (rather than 0 percent), not offer the headset as an output, > > and > > potentially automatically switch to it when the headset is powered > > on. > > > > The question is whether this should be a USB sysfs attribute, or > > one at > > the base driver level. Example implementation of the USB sysfs > > attribute itself below. > > Do you know of any non-USB devices using the receiver/emitter > approach? I don't know of any. > > > I have a patch for a USB API as well, but I'm having some problems > > creating deferred work on a soft irq. > > > > Cheers > > > > ---- > > Add a wireless_status sysfs attribute to USB devices to keep track > > of > > whether a USB device that uses a receiver/emitter combo has its > > emitter connected or disconnected. > > > > By default, the USB device will declare not to use a > > receiver/emitter. > > How do you plan to tell which devices do use a receiver/emitter?  Is > this something the drivers already knowo about? This is something that will need to be done on a device-by-device basis. For example, I have some patches to the hid-logitech-hidpp driver to set the wireless status when the headset is turned on. This would allow leaving the receiver plugged in, and user-space would know when the headset was actually available. > > Is it conceivable that a single device might have more than one > receiver?  If so, should the attribute belong to an interface rather > than to the USB device? The USB device is usually (always?) the receiver, so this kind of setup wouldn't make much sense to me. We could have it at the interface level, certainly, as Greg mentioned. That's probably the path I will take.