From patchwork Thu Nov 7 06:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1190937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IWB9FR7l"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477tww5B0jzB3tT; Thu, 7 Nov 2019 17:37:04 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iSbPh-0002pO-37; Thu, 07 Nov 2019 06:37:01 +0000 Received: from mail-pl1-f193.google.com ([209.85.214.193]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSbPe-0002nF-2g for kernel-team@lists.ubuntu.com; Thu, 07 Nov 2019 06:36:58 +0000 Received: by mail-pl1-f193.google.com with SMTP id s10so752757plp.2 for ; Wed, 06 Nov 2019 22:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=VTjdnsbVpfcNzdFaxrrVapCMsVCy5hJrW9wR0cRiGRk=; b=IWB9FR7lKp9zcRmIeToluF3iC87iHZiM+po1oPs4oJZvDvH+cQq0bV7gm3jUeQDK5b BpIjnWzRiYdMxRe3mlUdoNh3d5yQPwbgOXgBY3nqusJc3AQHBVbZcbuNtk4za7YABlh1 mLy60VKcZb2VlRUdVH9TKEJZ7sns1yxlWLc7iLXAaTd1amtfRo2q9eLgXlQnsIHQwem9 8FkeOThirw8IYuo8njLRaVHmtI30cbOSdR9rjt4JiCc4kgAy8X6vqqfat1Odnd6Ri2Zm hd5xGdn8M3I8HHKVUnteTSrurXfK1FSJTgx6sui2vY2rMkueZJ+i5w+2Xe65DG37FE+3 yu5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=VTjdnsbVpfcNzdFaxrrVapCMsVCy5hJrW9wR0cRiGRk=; b=eiHnH1kqEr4I/GJ4ua/UfeotZMXEZKHWhklcRPE5/ZyKjPLm+NEvF1RTadu2iCJD2a OAuwC8CaEw8KL3NTrZGnulHqvDgMs7NNsdMAbMQy1E+Ol/KGZ0jRhgYjbSd03wmv+nHv b8SW88HJ/qSg+2ohAE9YVIIByOgM/xIZY5s/8AQMtrmvijzHu6rpHzFFweWOtOZiObTF 2XViCa11MJZdougYY5T8Igf/9tSDwkRzUXFZjnwupSy8l8z1DElOHn7uGg8iFZorvk0h qm3sbuD7BDUx0Y3jw7JaH/KERme1+xWcs2gStepC2B2XnegXu/YBU7SGBn7Z5/hnytRq xLLg== X-Gm-Message-State: APjAAAV8yoIdAsSy3j8LSqwIlK46cx2A3zFuGd+3zZ3LOCeISh8ipNUQ yjoUN9fQwe655QLX5gJ0Em8URdwM1Jk= X-Google-Smtp-Source: APXvYqyvoFbkULgTkwxL3V4pUPuc2aap+pXD7so7iQXDdin2/t/EgN9TsdUtaoWWV9LFnQZYIGxXQA== X-Received: by 2002:a17:902:261:: with SMTP id 88mr306138plc.322.1573108616128; Wed, 06 Nov 2019 22:36:56 -0800 (PST) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id o125sm993834pfg.118.2019.11.06.22.36.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Nov 2019 22:36:55 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4] UBUNTU: SAUCE: platform/x86: dell-uart-backlight: add quirk for old platforms Date: Thu, 7 Nov 2019 14:36:44 +0800 Message-Id: <20191107063644.31145-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107063644.31145-1-acelan.kao@canonical.com> References: <20191107063644.31145-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1813877 Old platforms do not support DELL_UART_GET_SCALAR command and the behavior of DELL_UART_GET_FIRMWARE_VER command is different as the new firmware, so the new way to check if the backlight is controlled by scalar IC doesn't work on old platforms. We now add them into a list and use the old way to do the check. Signed-off-by: AceLan Kao --- drivers/platform/x86/dell-uart-backlight.c | 58 +++++++++++++++++++--- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/dell-uart-backlight.c b/drivers/platform/x86/dell-uart-backlight.c index f81fc01606d0..90b28865896a 100644 --- a/drivers/platform/x86/dell-uart-backlight.c +++ b/drivers/platform/x86/dell-uart-backlight.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "dell-uart-backlight.h" @@ -116,6 +117,38 @@ static struct dell_uart_bl_cmd uart_cmd[] = { }, }; +static const struct dmi_system_id dell_uart_backlight_alpha_platform[] __initconst = { + { + .ident = "Dell Inspiron 7777 AIO", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7777 AIO"), + }, + }, + { + .ident = "Dell Inspiron 5477 AIO", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5477 AIO"), + }, + }, + { + .ident = "Dell OptiPlex 7769 AIO", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 7769 AIO"), + }, + }, + { + .ident = "Dell OptiPlex 5260 AIO", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 5260 AIO"), + }, + }, + { } +}; + static int dell_uart_write(struct uart_8250_port *up, __u8 *buf, int len) { int actual = 0; @@ -285,8 +318,7 @@ static int dell_uart_get_scalar_status(struct dell_uart_backlight *dell_pdata) struct dell_uart_bl_cmd *bl_cmd = &uart_cmd[DELL_UART_GET_SCALAR]; struct uart_8250_port *uart = serial8250_get_port(dell_pdata->line); int rx_len; - /* assume the scalar IC controls backlight if the command failed */ - int status = 1; + int status = 0; dell_uart_dump_cmd(__func__, "tx: ", bl_cmd->cmd, bl_cmd->tx_len); @@ -377,7 +409,7 @@ static int dell_uart_bl_add(struct acpi_device *dev) dell_pdata = kzalloc(sizeof(struct dell_uart_backlight), GFP_KERNEL); if (!dell_pdata) { pr_debug("Failed to allocate memory for dell_uart_backlight\n"); - return -1; + return -ENOMEM; } dell_pdata->dev = &dev->dev; dell_uart_startup(dell_pdata); @@ -385,10 +417,20 @@ static int dell_uart_bl_add(struct acpi_device *dev) mutex_init(&dell_pdata->brightness_mutex); - if (!force && !dell_uart_get_scalar_status(dell_pdata)) { - pr_debug("Scalar is not in charge of brightness adjustment.\n"); - kzfree(dell_pdata); - return -1; + if (!force) { + if (dmi_check_system(dell_uart_backlight_alpha_platform)) { + /* try another command to make sure there is no scalar IC */ + if (dell_uart_show_firmware_ver(dell_pdata) <= 4) { + pr_debug("Scalar is not in charge of brightness adjustment.\n"); + kzfree(dell_pdata); + return -ENODEV; + } + } + else if (!dell_uart_get_scalar_status(dell_pdata)) { + pr_debug("Scalar is not in charge of brightness adjustment.\n"); + kzfree(dell_pdata); + return -ENODEV; + } } dell_uart_show_firmware_ver(dell_pdata); @@ -404,7 +446,7 @@ static int dell_uart_bl_add(struct acpi_device *dev) if (IS_ERR(dell_uart_bd)) { kzfree(dell_pdata); pr_debug("Backlight registration failed\n"); - return -1; + return PTR_ERR(dell_uart_bd); } dell_pdata->dell_uart_bd = dell_uart_bd;