From patchwork Wed Jul 18 03:03:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 10531283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 721C760547 for ; Wed, 18 Jul 2018 03:04:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59C5F290C0 for ; Wed, 18 Jul 2018 03:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DF6A290E5; Wed, 18 Jul 2018 03:04:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E60C329424 for ; Wed, 18 Jul 2018 03:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731369AbeGRDj0 (ORCPT ); Tue, 17 Jul 2018 23:39:26 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:37784 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731295AbeGRDjZ (ORCPT ); Tue, 17 Jul 2018 23:39:25 -0400 Received: from 89-71-158-145.dynamic.chello.pl ([89.71.158.145] helo=umbar.angband.pl) by tartarus.angband.pl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffckZ-0007zO-4n; Wed, 18 Jul 2018 05:03:39 +0200 Received: from kilobyte by umbar.angband.pl with local (Exim 4.91) (envelope-from ) id 1ffckY-0000AT-Pj; Wed, 18 Jul 2018 05:03:34 +0200 From: Adam Borowski To: Greg Kroah-Hartman , Jiri Slaby , linux-console@vger.kernel.org, Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adam Borowski Date: Wed, 18 Jul 2018 05:03:26 +0200 Message-Id: <20180718030327.579-5-kilobyte@angband.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180718030327.579-1-kilobyte@angband.pl> References: <20180718030152.kdq53mwpdfusvwl5@angband.pl> <20180718030327.579-1-kilobyte@angband.pl> X-SA-Exim-Connect-IP: 89.71.158.145 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH 5/6] vt: compensate for brightening the 256-color palette X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The algorithm for 256-to-16 conversion was designed with wrong input palette but actually tuned on mainstream GUI terminals. This resulted in something that works well only for data we convert ourselves (ie, 256 not 24-bit). As the change is non-linear, I did not bother replicating it exactly, thus there are some differences, among others: * values very close to black go to 0 (black) rather than 8 (dark grey) * grayscale ramp is more even A comparison of the old vs new vs FreeBSD's teken is at: https://github.com/kilobyte/colorkernel Signed-off-by: Adam Borowski --- drivers/tty/vt/vt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 8c61caafdf3c..c777f4c91df0 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1559,17 +1559,17 @@ static void rgb_foreground(struct vc_data *vc, const struct rgb *c) { u8 hue = 0, max = max3(c->r, c->g, c->b); - if (c->r > max / 2) + if (c->r > max / 2 + 32) hue |= 4; - if (c->g > max / 2) + if (c->g > max / 2 + 32) hue |= 2; - if (c->b > max / 2) + if (c->b > max / 2 + 32) hue |= 1; - if (hue == 7 && max <= 0x55) { + if (hue == 7 && max <= 0x70) { hue = 0; vc->vc_intensity = 2; - } else if (max > 0xaa) + } else if (max > 0xc0) vc->vc_intensity = 2; else vc->vc_intensity = 1;