From patchwork Mon Jan 15 14:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1749720dyc; Mon, 15 Jan 2024 06:51:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBQMkt7zv7ZlsQmdMKhU2A2Z7W5pJZCQe3j6yxUkJxUrgDHa19cp2sZsx9XBYRBE2imo8H X-Received: by 2002:a0c:db03:0:b0:680:f84c:f7b0 with SMTP id d3-20020a0cdb03000000b00680f84cf7b0mr6284683qvk.3.1705330310631; Mon, 15 Jan 2024 06:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330310; cv=none; d=google.com; s=arc-20160816; b=n4XQ2RCis8rpc2XvOKadP/y7DrUPhuyzyCVsUGCAbvgdX/pTv9hn8rjWW2f/5X6KIs RVdwJ6/S8+gpWwyV4UtYus3vs9YY+/GQC95RvqDw8wqccH4nCp3SdIoK604Ys/z25cHC aJ6dLayzhsAlpdZN2QGU7nRRupg7YsvHAbBdhWv0E5kg+q+cArByPZe6NAaZI01wT70H JHCEjHRLucOaTveuJrB7k+/yj3P5SNDN39wd7Tiu3uZ3+yYkzvlJJbsq44wSR2rrUEp4 P2IwPqUlRjzV4cbJItQgJcldm0wuZcs7pFnFfVJYt0ZdIYUiT3/ZiO1x4pDjBHXcJ5lD PoOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Q7ky0jJf6VW4JTJaAMl9SwzWpwd6q3Bu4BdjaP0tTqU=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=tF1rQHFLyj7ASueY8KSiZTdWkZntXDXK/9xGAr9l+K8n0lB7oS+mwF0IjL/bpurWc3 snlgo2cBHMmlz5zbz7dK7DAF8BaxDpQbHhoUFCzgJVMY8LnPmqo2uRAZPWqGoPNvMJl2 2E8w8qmjjFfYfZ+YXuldmawnLDkBUamo7eXCd/9xdvju3+/mQf/f7Qeg5XrHvVl8SAiJ ZWPyW98mN+syX8veGvahDeDw/WeFXuHYb4imDzbCQ6RB/wBu0UxrYyIMPbNo4lBKtInB wFHtmYs6jWAYJFHgFEOfPZ8ZIF1b4AJkNJlmtARRiskUqwK5Va8Wqq8foB/3YDFPlkbK ++Dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c2-20020a0ce142000000b006812aec8373si956015qvl.430.2024.01.15.06.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org" 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 6F13B1C21BB8 for ; Mon, 15 Jan 2024 14:51:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E422A17BAC; Mon, 15 Jan 2024 14:48:58 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7FAB175B5; Mon, 15 Jan 2024 14:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 9F44D101601; Mon, 15 Jan 2024 14:48:44 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v1 1/7] HID: playstation: DS4: Fix LED blinking Date: Mon, 15 Jan 2024 23:45:32 +0900 Message-Id: <20240115144538.12018-2-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-1-max@enpas.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788168435385317317 X-GMAIL-MSGID: 1788168435385317317 There was no way to disable blinking once enabled. Disable it on brightness = 0, as per the Linux LED spec. The driver reports back the values it sends to the controller, but they need to be scaled back to milliseconds. Setting the LED blinking via sysfs works as expected now. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 8ac8f7b8e317..7f50e13601f0 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2037,8 +2037,9 @@ static int dualshock4_led_set_blink(struct led_classdev *led, unsigned long *del dualshock4_schedule_work(ds4); - *delay_on = ds4->lightbar_blink_on; - *delay_off = ds4->lightbar_blink_off; + /* Report scaled values back to LED subsystem */ + *delay_on = ds4->lightbar_blink_on * 10; + *delay_off = ds4->lightbar_blink_off * 10; return 0; } @@ -2065,6 +2066,13 @@ static int dualshock4_led_set_brightness(struct led_classdev *led, enum led_brig break; case 3: ds4->lightbar_enabled = !!value; + + /* brightness = 0 also cancels blinking in Linux. */ + if (!ds4->lightbar_enabled) { + ds4->lightbar_blink_off = 0; + ds4->lightbar_blink_on = 0; + ds4->update_lightbar_blink = true; + } } ds4->update_lightbar = true;