Maciej W. Rozycki 01ac59c344 video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling
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 <macro@linux-mips.org>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-02-26 13:06:11 +02:00

71 lines
1.4 KiB
C

/*
* linux/drivers/video/bt455.h
*
* Copyright 2003 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
* Copyright 2016 Maciej W. Rozycki <macro@linux-mips.org>
*
* 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
* archive for more details.
*/
#include <linux/types.h>
/*
* Bt455 byte-wide registers, 32-bit aligned.
*/
struct bt455_regs {
volatile u8 addr_cmap;
u8 pad0[3];
volatile u8 addr_cmap_data;
u8 pad1[3];
volatile u8 addr_clr;
u8 pad2[3];
volatile u8 addr_ovly;
u8 pad3[3];
};
static inline void bt455_select_reg(struct bt455_regs *regs, int ir)
{
mb();
regs->addr_cmap = ir & 0x0f;
}
/*
* Read/write to a Bt455 color map register.
*/
static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
int cr, u8 *grey)
{
bt455_select_reg(regs, cr);
mb();
regs->addr_cmap_data;
rmb();
*grey = regs->addr_cmap_data & 0xf;
rmb();
regs->addr_cmap_data;
}
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 = 0x0;
wmb();
regs->addr_cmap_data = grey & 0xf;
wmb();
regs->addr_cmap_data = 0x0;
}
static inline void bt455_write_ovly_entry(struct bt455_regs *regs,
int cr, u8 grey)
{
bt455_select_reg(regs, cr);
wmb();
regs->addr_ovly = 0x0;
wmb();
regs->addr_ovly = grey & 0xf;
wmb();
regs->addr_ovly = 0x0;
}