From patchwork Tue Jun 12 16:20:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10460603 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 1366B60348 for ; Tue, 12 Jun 2018 16:21:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0434528A30 for ; Tue, 12 Jun 2018 16:21:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00E2E28A7D; Tue, 12 Jun 2018 16:21:01 +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=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9EE528A4F for ; Tue, 12 Jun 2018 16:20:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 223846E53E; Tue, 12 Jun 2018 16:20:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) by gabe.freedesktop.org (Postfix) with ESMTPS id 625EE6E53E for ; Tue, 12 Jun 2018 16:20:55 +0000 (UTC) Received: by mail-wr0-x235.google.com with SMTP id h10-v6so24717017wrq.8 for ; Tue, 12 Jun 2018 09:20:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0f5TQnl995WO8H9apyuGSpMETFNyu9zLOEhjTwfA6SA=; b=O5gF+MEG5puezCqOcPP4hEYaqAhfURgYjYFJRIE+GHaCNbFLeyGQN5Q7QP/4kYY+2s vFxvX7ZZEZxIYMsSt/v3cgsuW3kg97S1pOLuz8Evgri26Y4tuqZRmQJRW03BRuhQbgD3 YffO+FmNvja5XD6/y5m94m7WDXZp6UiUDshMiVfteOt33gJPNHIeUKku/o25yNmb9la+ QmwSExU/1qr+tr5qcs8PfF8AD+LKMIkNSbaR7wNmtPUH4ToEl5k4Oagte0C2BBtTGNfc lr8rlq1FOPQMHGOdV4P804xNnMKu82mqF+Oa9PrPoAP85MMyT0X8qIN/QZNJnrubUF7J sH9Q== X-Gm-Message-State: APt69E0RDwNybFaIupjXQykH0au1bQdgbjx93QIEAd79FtL81iLDtoXL CfOMlOQHGjjsklO7BGsDIU/q3A== X-Google-Smtp-Source: ADUXVKI6RwNv6hf0WrlfCY7+f5N0nEfyt3wBTY9SEbRMRELvSiyMcCacDT0vupRt1vCgh52yt7yEvw== X-Received: by 2002:adf:8da1:: with SMTP id o30-v6mr819257wrb.81.1528820453877; Tue, 12 Jun 2018 09:20:53 -0700 (PDT) Received: from kleinerm-MaxtorLinux.localdomain ([2a01:c22:d02a:3600:25b4:2f2b:a0ee:f938]) by smtp.gmail.com with ESMTPSA id q17-v6sm769862wrr.7.2018.06.12.09.20.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jun 2018 09:20:53 -0700 (PDT) From: Mario Kleiner To: intel-gfx@lists.freedesktop.org Date: Tue, 12 Jun 2018 18:20:35 +0200 Message-Id: <1528820435-2732-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528820435-2732-1-git-send-email-mario.kleiner.de@gmail.com> References: <1528820435-2732-1-git-send-email-mario.kleiner.de@gmail.com> Subject: [Intel-gfx] [PATCH xf86-video-intel] sna/uxa: Fix colormap handling at screen depth 30. (v2) X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The various clut handling functions like a setup consistent with the x-screen color depth. Otherwise we observe improper sampling in the gamma tables at depth 30. Therefore replace hard-coded bitsPerRGB = 8 by actual bits per channel scrn->rgbBits. Also use this for call to xf86HandleColormaps(). Tested for uxa and sna at depths 8, 16, 24 and 30 on IvyBridge, and tested at depth 24 and 30 that xgamma and gamma table animations work, and with measurement equipment to make sure identity gamma ramps actually are identity mappings at the output. v2: Also deal with X-Server 1.19 and earlier, which as of v1.19.6 lack a fix to color palette handling and can not deal with depths/bpc > 24/8 bpc. On < 1.20 we skip xf86HandleColormaps() setup at > 8 bpc. This disables color palette handling on such servers at > 8 bpc, but still keeps RandR gamma table handling intact. Tested on 1.19.6 and 1.20.0 to do the right thing. Signed-off-by: Mario Kleiner Reviewed-by: Ville Syrjälä Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
--- src/sna/sna_driver.c | 9 ++++++--- src/uxa/intel_driver.c | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 2007e354..8c79d43b 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -1152,7 +1152,7 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL) if (!miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth, &defaultVisual, ((unsigned long)1 << (scrn->bitsPerPixel - 1)), - 8, -1)) + scrn->rgbBits, -1)) return FALSE; if (!miScreenInit(screen, NULL, @@ -1223,8 +1223,11 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL) if (!miCreateDefColormap(screen)) return FALSE; - if (sna->mode.num_real_crtc && - !xf86HandleColormaps(screen, 256, 8, sna_load_palette, NULL, + /* X-Server < 1.20 mishandles > 256 slots / > 8 bpc color maps. */ + if (sna->mode.num_real_crtc && (scrn->rgbBits <= 8 || + XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,20,0,0,0)) && + !xf86HandleColormaps(screen, 1 << scrn->rgbBits, scrn->rgbBits, + sna_load_palette, NULL, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR)) return FALSE; diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c index 3703c412..77c0dc00 100644 --- a/src/uxa/intel_driver.c +++ b/src/uxa/intel_driver.c @@ -991,7 +991,11 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL) if (!miCreateDefColormap(screen)) return FALSE; - if (!xf86HandleColormaps(screen, 256, 8, I830LoadPalette, NULL, + /* X-Server < 1.20 mishandles > 256 slots / > 8 bpc color maps. */ + if ((scrn->rgbBits <= 8 || + XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,20,0,0,0)) && + !xf86HandleColormaps(screen, 1 << scrn->rgbBits, scrn->rgbBits, + I830LoadPalette, NULL, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR)) { return FALSE;