From patchwork Mon Feb 22 01:55:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 8370201 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 446E69F314 for ; Mon, 22 Feb 2016 01:56:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 443692035D for ; Mon, 22 Feb 2016 01:56:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A18D20357 for ; Mon, 22 Feb 2016 01:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752909AbcBVBz0 (ORCPT ); Sun, 21 Feb 2016 20:55:26 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:54110 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752906AbcBVBzW (ORCPT ); Sun, 21 Feb 2016 20:55:22 -0500 Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S27012239AbcBVBzV4U4Nq (ORCPT + 1 other); Mon, 22 Feb 2016 02:55:21 +0100 Date: Mon, 22 Feb 2016 01:55:21 +0000 (GMT) From: "Maciej W. Rozycki" To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Geert Uytterhoeven cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Bt455 is a greyscale RAMDAC, using the green color palette entries only while still providing registers for the red and blue components, all the three of which have to be loaded on palette updates. Chip documentation [1] mandates that the unused red and blue registers are written with 0. Therefore update code to follow this requirement and given that it makes the red and blue components unusable remove them from internal API calls altogether. References: [1] "Bt454 Bt455 170 MHz Monolithic CMOS 16 Color Palette RAMDAC", Brooktree Corporation, Document Number: L454001, Rev. I Signed-off-by: Maciej W. Rozycki --- linux-bt455-cmap-grey.diff -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-20160211-4maxp64/drivers/video/fbdev/bt455.h =================================================================== --- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt455.h +++ linux-20160211-4maxp64/drivers/video/fbdev/bt455.h @@ -2,6 +2,7 @@ * linux/drivers/video/bt455.h * * Copyright 2003 Thiemo Seufer + * Copyright 2016 Maciej W. Rozycki * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this @@ -32,38 +33,38 @@ static inline void bt455_select_reg(stru /* * Read/write to a Bt455 color map register. */ -static inline void bt455_read_cmap_entry(struct bt455_regs *regs, int cr, - u8* red, u8* green, u8* blue) +static inline void bt455_read_cmap_entry(struct bt455_regs *regs, + int cr, u8 *grey) { bt455_select_reg(regs, cr); mb(); - *red = regs->addr_cmap_data & 0x0f; + regs->addr_cmap_data; rmb(); - *green = regs->addr_cmap_data & 0x0f; + *grey = regs->addr_cmap_data & 0xf; rmb(); - *blue = regs->addr_cmap_data & 0x0f; + regs->addr_cmap_data; } -static inline void bt455_write_cmap_entry(struct bt455_regs *regs, int cr, - u8 red, u8 green, u8 blue) +static inline void bt455_write_cmap_entry(struct bt455_regs *regs, + int cr, u8 grey) { bt455_select_reg(regs, cr); wmb(); - regs->addr_cmap_data = red & 0x0f; + regs->addr_cmap_data = 0x0; wmb(); - regs->addr_cmap_data = green & 0x0f; + regs->addr_cmap_data = grey & 0xf; wmb(); - regs->addr_cmap_data = blue & 0x0f; + regs->addr_cmap_data = 0x0; } -static inline void bt455_write_ovly_entry(struct bt455_regs *regs, int cr, - u8 red, u8 green, u8 blue) +static inline void bt455_write_ovly_entry(struct bt455_regs *regs, + int cr, u8 grey) { bt455_select_reg(regs, cr); wmb(); - regs->addr_ovly = red & 0x0f; + regs->addr_ovly = 0x0; wmb(); - regs->addr_ovly = green & 0x0f; + regs->addr_ovly = grey & 0xf; wmb(); - regs->addr_ovly = blue & 0x0f; + regs->addr_ovly = 0x0; } Index: linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c =================================================================== --- linux-20160211-4maxp64.orig/drivers/video/fbdev/pmag-aa-fb.c +++ linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c @@ -121,9 +121,9 @@ static int aafb_cursor(struct fb_info *i u8 fg = cursor->image.fg_color ? 0xf : 0x0; u8 bg = cursor->image.bg_color ? 0xf : 0x0; - bt455_write_cmap_entry(par->bt455, 8, 0, bg, 0); - bt455_write_cmap_entry(par->bt455, 9, 0, bg, 0); - bt455_write_ovly_entry(par->bt455, 0, 0, fg, 0); + bt455_write_cmap_entry(par->bt455, 8, bg); + bt455_write_cmap_entry(par->bt455, 9, bg); + bt455_write_ovly_entry(par->bt455, 0, fg); } if (cursor->set & (FB_CUR_SETSIZE | FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) bt431_set_cursor(par->bt431, @@ -143,7 +143,7 @@ static int aafb_blank(int blank, struct struct aafb_par *par = info->par; u8 val = blank ? 0x00 : 0x0f; - bt455_write_cmap_entry(par->bt455, 1, val, val, val); + bt455_write_cmap_entry(par->bt455, 1, val); return 0; } @@ -211,8 +211,8 @@ static int pmagaafb_probe(struct device info->screen_size = info->fix.smem_len; /* Init colormap. */ - bt455_write_cmap_entry(par->bt455, 0, 0x00, 0x00, 0x00); - bt455_write_cmap_entry(par->bt455, 1, 0x0f, 0x0f, 0x0f); + bt455_write_cmap_entry(par->bt455, 0, 0x0); + bt455_write_cmap_entry(par->bt455, 1, 0xf); /* Init hardware cursor. */ bt431_erase_cursor(par->bt431);