Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1596908rdb; Wed, 31 Jan 2024 03:42:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpQdDAZGvD2S5vOAbyzlnEIj+CsYfAPKcAiaBEY1qQ8FBLd7RhumBQeSveMOKevlYCTnO+ X-Received: by 2002:a05:620a:4d02:b0:783:daad:3a6e with SMTP id wa2-20020a05620a4d0200b00783daad3a6emr1151484qkn.56.1706701339829; Wed, 31 Jan 2024 03:42:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701339; cv=pass; d=google.com; s=arc-20160816; b=ce61DRTqovRT/qWLAOIS3AjHl4N9bLpwEuVSIzrjxad1lJzTfQhbJTZZHKJ64iv8Ks DoU5gQt+6cKCofeq8oTxwExbGiSQbVLzrjowR6CZ6Bdactqv8q1xjz3AbLwtenWL2Kte +NwwupYSh/OmHgtyeVW6VntvsKBJb4cnlKdAhITiaV7AR0HL93+swX4d0ErYPNX2eFim MMWW7H0g5pPC9DdUqz9rWBv8jFCnKo3Hf6C4YSRLSY49u/5n7o6vfgiEIDIVbt9i8RQP JkoZSiCIgKow+9GXQqIwd1J/rTT50MUzPEf1EDQyw79yrC0YL8vPUX5g+k1AFAbrJq7P h4rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=2SsJehYO30sr02LgW1i3XyRegpdTntKLXnN2eAseYrk=; fh=4o6bMHAkZ3b3uJFWdGjlv8J03gSzH1DZIU4MGJMiDXk=; b=v8DfJ31vKkHm6zZFwkjQX7jllABktSnIZBV81eoBgP7HVPMmz+DLLXraQMYWKg6yia Kv0Tt1bqFnQlynPnQG00r9CCVK4kSv4MaPrHb0K81SPUX6MlwD/CmZBDDZ3xdIDf4Vqy d6nw+mNONP1CMWJpBBuDy/8buT8MOi8PZi2gfi28hLgF7LDh71X21Vr9dwgEWzCFaIBY tHx1Yd8evDNfWbU1isU5SeqdQX8kZoXZ2ptocpBZGjoE/KD7bH69C8JIhqvvAe1UYEJW JizMadkEAzMgLVni6u1Vh/60imIHCKaSzV0nQgiYMJEf372RUro1+6E2KTqLK/Zzytqi EmVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=ZxYtFrTD; arc=pass (i=1 spf=pass spfdomain=tuxedocomputers.com dkim=pass dkdomain=tuxedocomputers.com dmarc=pass fromdomain=tuxedocomputers.com); spf=pass (google.com: domain of linux-kernel+bounces-46375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46375-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com X-Forwarded-Encrypted: i=1; AJvYcCVUJ+niQbbOIsFFK1JsECUY/xpw6TDq5t+fPmZ4sf0gE/B8IdgM6C72Gf54DLu3rSbFbjTEexFat0/LJVF3jrWwHjl4GbFiMmo57oPM+g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y3-20020a05620a09c300b00783f9bb4c80si7051412qky.727.2024.01.31.03.42.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:42:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=ZxYtFrTD; arc=pass (i=1 spf=pass spfdomain=tuxedocomputers.com dkim=pass dkdomain=tuxedocomputers.com dmarc=pass fromdomain=tuxedocomputers.com); spf=pass (google.com: domain of linux-kernel+bounces-46375-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46375-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B19B71C25916 for ; Wed, 31 Jan 2024 11:41:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76767762DC; Wed, 31 Jan 2024 11:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b="ZxYtFrTD" Received: from mail.tuxedocomputers.com (mail.tuxedocomputers.com [157.90.84.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CF0B762C3; Wed, 31 Jan 2024 11:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=157.90.84.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701274; cv=none; b=Tmpknyo890UFmI/XGUZ3mpKmbD1uKuSReuHodz/yoNzHVbvE/1Vj+qLbuWtmHHmF9PKWkswvMEXZnc4SB1vPV7HgOi/35sY0Y3rxqilyBIBSIGQMdX59JjHqqFkHnTDsoKiX+iK+0PksPA2x/pJrm5r3ZvQxYhTSF2CLAnVt7rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701274; c=relaxed/simple; bh=Ysk1DXQQH8iuG3T6SLSADhPrd8JuNH55pHiq/6Vyz18=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XqCQfzVHcOHwaf9/kYM6ZOftnT9Dfh/evLSuoHD9JgjI7BNx8STCh7FR5GPoQ0sDl3w5ULCnodXZZn2cmmfJF1HNYCgIrfUj8FwwoegsIkK+8gFio0Q5YRRLATp9kKhR80nCk59J0sCw9H9lJ1u35frMTZRuTzsmaQEQqtovpd4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com; spf=pass smtp.mailfrom=tuxedocomputers.com; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b=ZxYtFrTD; arc=none smtp.client-ip=157.90.84.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxedocomputers.com Received: from [192.168.42.20] (p5de453e7.dip0.t-ipconnect.de [93.228.83.231]) (Authenticated sender: wse@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPSA id A32332FC004A; Wed, 31 Jan 2024 12:41:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1706701263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2SsJehYO30sr02LgW1i3XyRegpdTntKLXnN2eAseYrk=; b=ZxYtFrTDL35wTkktQPwdhDVYEOf8pW9ybpn7/klnIOy0ABz9s2wkDHJ500ZGK/X9L/hUNQ 12LVdbNj7C9QpSeFB0m7MXclVlvHmle5/ZCdjQe56Bjoq9VS8viJv6tDuZnGG9dDYJebuD k0LFC/WFVpfDcbwzUp9vYywXrLB8dUM= Authentication-Results: mail.tuxedocomputers.com; auth=pass smtp.auth=wse@tuxedocomputers.com smtp.mailfrom=wse@tuxedocomputers.com Message-ID: Date: Wed, 31 Jan 2024 12:41:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Future handling of complex RGB devices on Linux To: Hans de Goede , Pavel Machek Cc: Lee Jones , jikos@kernel.org, linux-kernel@vger.kernel.org, Jelle van der Waa , Miguel Ojeda , "dri-devel@lists.freedesktop.org" , linux-input@vger.kernel.org, ojeda@kernel.org, linux-leds@vger.kernel.org References: <87sf61bm8t.fsf@intel.com> <8096a042-83bd-4b9f-b633-79e86995c9b8@redhat.com> <4222268b-ff44-4b7d-bf11-e350594bbe24@redhat.com> <6bbfdd62-e663-4a45-82f4-445069a8d690@redhat.com> <0cdb78b1-7763-4bb6-9582-d70577781e61@tuxedocomputers.com> <7228f2c6-fbdd-4e19-b703-103b8535d77d@redhat.com> <730bead8-6e1d-4d21-90d2-4ee73155887a@tuxedocomputers.com> <952409e1-2f0e-4d7a-a7a9-3b78f2eafec7@redhat.com> <9851a06d-956e-4b57-be63-e10ff1fce8b4@tuxedocomputers.com> <1bc6d6f0-a13d-4148-80cb-9c13dec7ed32@redhat.com> <477d30ee-247e-47e6-bc74-515fd87fdc13@redhat.com> Content-Language: en-US From: Werner Sembach In-Reply-To: <477d30ee-247e-47e6-bc74-515fd87fdc13@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, so I combined Hans last draft, with the discussion since then and the comments from the OpenRGB maintainers from here https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/3916 and my own experience and came up witrh this rough updated draft for the new uapi: Future handling of complex RGB devices on Linux: Optional: Provide a basic leds-subsystem driver:     - The whole device is treated as a singular RGB led in the current leds uapi         - Backwards compatibility         - Have something work out-of-the-box and during boot time     - The driver also registers a misc device with a singluar sysfs attribute select_uapi         - reading this gives back "[leds] none"         - the current active uapi can be selected by writing it to that attribute         - switching the uapi means deregistering the device from that entirely and registering and initializing it with the new one froms scratch         - selecting none only does the deregistering If the device is already reachable by userspace directly, e.g. via hidraw, the kernel will only offer this basic implementation and a more complex driver has to be implemented in userspace.     - This driver has to use the select_uapi attribute first and select "none" to avoid undefined behaviour caused by accessing the leds upai and hidraw to control the lighting at the same time     - Question: How to best associate the select_uapi attribute to the corresponding hidraw (or other) direct access channel? So that a userspace driver can reliable check whether or not this has to be set. Devices not reachable by userspace directly, e.g. because they are controled via a wmi interface, can also be implemented in the new rgbledstring-subsystem (working title) for more complex control     - a rgbledstring device provides an ioctl interface (ioctl only no r/w) using /dev/rgbledstring0, /dev/rgbledstring1, etc. registered as a misc chardev.         - get-device-info ioctl which returns in a single struct:             - char name[64]                     /* Device model name / identifier, preferable human readable. For keyboards, if known to the driver, physical layout (or even printed layout) should be separated here */             - enum device_type                  /* e.g. keyboard, mouse, lightbar, etc. */             - char firmware_version_string[64]  /* if known to the driver, empty otherwise */             - char serial_number[64]            /* if known to the driver, empty otherwise */             - enum supported_modes[64]          /* modes supported by the firmware e.g. static/direct, breathing, scan, raindrops, etc. */         - get-mode-info icotl, RFC here: Hans thinks it is better to have the modes and their inputs staticly defined and have, if required, something like breathing_clevo_1, breathing_clevo_2, breathing_tongfang_1 if the inputs vary between vendors. I think a dynamic approach could be useful where userspace just queries the struct required for each individual mode.             - input: a mode from the supported_modes extracted from get-device-info             - output: static information about the mode, e.g. max_animation_speed, max_brightness, etc.             - output: the struct/a list of attributes and their types required to configure the mode         - set-mode ioctl takes a single struct:             - enum mode                         /* from supported_modes */             - union data                 - char raw[3072]                 -         - The driver also registers a singluar sysfs attribute select_uapi             - reading this gives back "[leds] rgbledstring none" or "[rgbledstring] none" respectifly             - Discussion question: should select_uapi instead be use_leds_uapi                 - if 1: use basic leds driver                 - if 0: if device is userspace accessible no kernel driver is active, if device ist not userspace accessible register rgbledstring (aka implicit separation between rgbledstring and none instead of explicit one) Zone configuration would be seen as a subset of mode configuration, as I suspect not every mode needs the zone configuration even on devices that offer it? The most simple mode would be static/direct and the set-mode struct would look like this: {     enum mode, /* = static */     {         uint8 brightness, /* global brightness, some keyboards offer this */         uint8 color[*3]     } } Question: Are there modes that have a separate setup command that is only required once and then a continuous stream of update information? If yes, should we reflect that by splitting set-mode into set-mode-setup and set-mode-update (with get-mode-info returning one struct for each)? Or should userspace just always send setup and update information and it's up to the kernel driver to only resend the setup command when something has changed? In the former case set-mode-update might be a noop in most cases. Discussion on this might also happen here: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/3916#note_1751170108 Regards, Werner