Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3081917rdg; Tue, 17 Oct 2023 04:15:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/C75vCJTqZWfCj9yV2EMiqCDrbxBM+YgT73N5xfUbwD7rFVjGbP3KwPXX5OxzNsXXiELl X-Received: by 2002:a17:90a:2ca1:b0:27d:61:cd21 with SMTP id n30-20020a17090a2ca100b0027d0061cd21mr1739017pjd.29.1697541355129; Tue, 17 Oct 2023 04:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697541355; cv=none; d=google.com; s=arc-20160816; b=jD95RmhuDMYEGfpHgOz1xZnOSN7A48vL6xjCk2Jy3aVjAsGOKqptxwCBFs4ectMQ2V aoTyHsQMMEIoyjobG4bEclWDuW4oP3NQvbsWPwPV4xR3bRNgkoH0Cqq/PliT8vjb6xfI C8xgc6THcAQLFQF+5Cntqc6nuH2mO5brG+u8tp8dDe57Uj9wyRbvzDpeE7x64+9YcnpK ODCfFg3vZv+0rfQd5OwV/Hvxy+R6RiTRePH8n3TN9V+swnwUpVkXVvnsNn9oISXp0XZl J0pKbE+kZSUqMHngAzgdh+XQQo1jtRRrFJrJaZ69LJafg4MaNtfSGMEL5WV7j85xnRx0 Nd/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+44+Hzb0z6pVz0b4amjrQwdXkC/qEJs/4XOggo1kQEk=; fh=PoEAJneU5suXcy0ZTfaz8YVVhxLuGIrK0U0fJT7bTlI=; b=CDWGyLR38rLYsp3sqhMwUW7ilEaLncELQdk7wV4qkYPQJiUi2sXD0NSFEY4XcnIRtH u7N7LmAqMofHSaIu3+ti4V9pBkgBR7WIqhVEfBgZuHRlONOw1qoaPIhnl/3PZ6ofWMGf fZGR199V2hIYwKEwGpNW6xrxfhSfE/SJACBUNekmoVvB4YCToozDusLWlLLHpBzBZoUu IRcRX2YHLPKwnpIT/1OQ8tr/moGpjJtRPfFVG5mTwOLFd8CHb6mIbp3wHBlSq7LjSNLN cYmqgpKMN31aWyDfMQoPiaH9wyubKnlHuaLApqamLlTyntKM0GSjgzspmTE86KHmzjNf 673A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DTm13Y5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n15-20020a6546cf000000b005859c255ce8si1578767pgr.819.2023.10.17.04.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 04:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DTm13Y5x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C787580B6325; Tue, 17 Oct 2023 04:15:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234686AbjJQLPp (ORCPT + 99 others); Tue, 17 Oct 2023 07:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233570AbjJQLPo (ORCPT ); Tue, 17 Oct 2023 07:15:44 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 739BEB6; Tue, 17 Oct 2023 04:15:42 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-565334377d0so4139799a12.2; Tue, 17 Oct 2023 04:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697541342; x=1698146142; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+44+Hzb0z6pVz0b4amjrQwdXkC/qEJs/4XOggo1kQEk=; b=DTm13Y5x2Jsu5A/yuWaEyhTYOXCOyqGWoiZT9PijxcKWSYUiXugtiZvQU51yfeNAiJ QgzG05rWkHwfWh5n8pt0OsXfPHxsiHDx7oBGfcsezUoiuVq24CF4C6cuo7JMYs1pP1CQ +n0kXy57f9I8Z0uS1Pjt/cCWGEUZ3lBVFPdaHNBQ1L9sv/L81Fj9C83z9B+qo7dSMeLS snNI+n3ljjnAkBaV99fUjdgmtVkNxNeQEjtePckhtR82qqZfBKGGQ4catYx1yMT9kEa0 ZerLwVDmLIPXtX4MC/8p+UIddxcVCuKrqWRFXgqvlqWMWzbtzOriLpVXwQDzBAhD4coM v6rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697541342; x=1698146142; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+44+Hzb0z6pVz0b4amjrQwdXkC/qEJs/4XOggo1kQEk=; b=FRbTPK7yy5XGLFbs//MG6baBlf6Nb/wLb5NpyIO73OkFm6Sz3xHHdQUpj4g+S1ZbjD 8PiwM+8LiTkyyOcKFa3UJpyKmHeh3H18iCZVMJswU/c/j7/BAMq/NiKM4PpdNWasFfpv ToxE4KwcgaTDDPDW+CJVnFenOtNne+P/izUSikM1vnGdw875rBRrFbQL5/hyN+03yS2z UHnm/YK7uujM9AcwVj9rKIZSVlfsubtrcisyrlfavD5PrcPgrYoxCVlCOoQiZpTAC7HQ 9i7Yi8dz7iz2UFe7JVmotfJNMEQYp7BKGV9x70WTNpieuDLsQ6WpkkG4l7P9DDKONLWR SDxA== X-Gm-Message-State: AOJu0YyGrPHlr6Ju3OLHkiOGMFxsax+zatHPbHgJBYTCB56NOmyiQR5A QAMRyacbKoTcpXng1KE4kVM= X-Received: by 2002:a05:6a21:47c1:b0:179:fbd6:95f1 with SMTP id as1-20020a056a2147c100b00179fbd695f1mr1573236pzc.26.1697541341850; Tue, 17 Oct 2023 04:15:41 -0700 (PDT) Received: from localhost.localdomain (59-102-24-27.tpgi.com.au. [59.102.24.27]) by smtp.gmail.com with ESMTPSA id jj15-20020a170903048f00b001c60635c13esm1269794plb.115.2023.10.17.04.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 04:15:41 -0700 (PDT) From: Orlando Chamberlain To: Hans de Goede Cc: Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Aditya Garg , Aun-Ali Zaidi , Kerem Karabay , Orlando Chamberlain , Karsten Leipold Subject: [PATCH 1/1] apple-gmux: Hard Code max brightness for MMIO gmux Date: Tue, 17 Oct 2023 22:14:45 +1100 Message-ID: <20231017111444.19304-2-orlandoch.dev@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 04:15:53 -0700 (PDT) The data in the max brightness port for iMacs with MMIO gmux incorrectly reports 0x03ff, but it should be 0xffff. As all other MMIO gmux models have 0xffff, hard code this for all MMIO gmux's so they all have the proper brightness range accessible. Reported-by: Karsten Leipold Signed-off-by: Orlando Chamberlain --- drivers/platform/x86/apple-gmux.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c index cadbb557a108..1417e230edbd 100644 --- a/drivers/platform/x86/apple-gmux.c +++ b/drivers/platform/x86/apple-gmux.c @@ -105,6 +105,8 @@ struct apple_gmux_config { #define GMUX_BRIGHTNESS_MASK 0x00ffffff #define GMUX_MAX_BRIGHTNESS GMUX_BRIGHTNESS_MASK +# define MMIO_GMUX_MAX_BRIGHTNESS 0xffff + static u8 gmux_pio_read8(struct apple_gmux_data *gmux_data, int port) { return inb(gmux_data->iostart + port); @@ -857,7 +859,17 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_PLATFORM; - props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS); + + /* + * All MMIO gmux's have 0xffff as max brightness, but some iMacs incorrectly + * report 0x03ff, despite the firmware being happy to set 0xffff as the brightness + * at boot. Force 0xffff for all MMIO gmux's so they all have the correct brightness + * range. + */ + if (type == APPLE_GMUX_TYPE_MMIO) + props.max_brightness = MMIO_GMUX_MAX_BRIGHTNESS; + else + props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS); #if IS_REACHABLE(CONFIG_ACPI_VIDEO) register_bdev = acpi_video_get_backlight_type() == acpi_backlight_apple_gmux; -- 2.42.0