From: "Ville Syrjälä" <syrjala@sci.fi>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: [PATCH] atyfb (2.6): Add RGB565 support
Date: Wed, 12 May 2004 00:36:07 +0300 [thread overview]
Message-ID: <20040511213607.GB6854@sci.fi> (raw)
[-- Attachment #1: Type: text/plain, Size: 109 bytes --]
This patch adds RGB565 support to atyfb.
--
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/
[-- Attachment #2: atyfb-2.6-rgb565.patch --]
[-- Type: text/plain, Size: 4182 bytes --]
diff -urN linux-orig/drivers/video/aty/atyfb.h linux/drivers/video/aty/atyfb.h
--- linux-orig/drivers/video/aty/atyfb.h 2004-05-11 23:45:00.524832384 +0300
+++ linux/drivers/video/aty/atyfb.h 2004-05-11 23:52:08.142824568 +0300
@@ -116,6 +116,7 @@
struct atyfb_par {
struct aty_cmap_regs *aty_cmap_regs;
+ struct { u8 red, green, blue; } palette[256];
const struct aty_dac_ops *dac_ops;
const struct aty_pll_ops *pll_ops;
unsigned long ati_regbase;
diff -urN linux-orig/drivers/video/aty/atyfb_base.c linux/drivers/video/aty/atyfb_base.c
--- linux-orig/drivers/video/aty/atyfb_base.c 2004-05-11 23:45:00.532831168 +0300
+++ linux/drivers/video/aty/atyfb_base.c 2004-05-12 00:07:24.822468080 +0300
@@ -683,6 +683,8 @@
xoffset = var->xoffset;
yoffset = var->yoffset;
bpp = var->bits_per_pixel;
+ if (bpp == 16)
+ bpp = (var->green.length == 5) ? 15 : 16;
sync = var->sync;
vmode = var->vmode;
@@ -702,12 +704,18 @@
HOST_8BPP | SRC_8BPP | DST_8BPP |
BYTE_ORDER_LSB_TO_MSB;
dp_chain_mask = DP_CHAIN_8BPP;
- } else if (bpp <= 16) {
+ } else if (bpp <= 15) {
bpp = 16;
pix_width = CRTC_PIX_WIDTH_15BPP;
dp_pix_width = HOST_15BPP | SRC_15BPP | DST_15BPP |
BYTE_ORDER_LSB_TO_MSB;
dp_chain_mask = DP_CHAIN_15BPP;
+ } else if (bpp <= 16) {
+ bpp = 16;
+ pix_width = CRTC_PIX_WIDTH_16BPP;
+ dp_pix_width = HOST_16BPP | SRC_16BPP | DST_16BPP |
+ BYTE_ORDER_LSB_TO_MSB;
+ dp_chain_mask = DP_CHAIN_16BPP;
} else if (bpp <= 24 && M64_HAS(INTEGRATED)) {
bpp = 24;
pix_width = CRTC_PIX_WIDTH_24BPP;
@@ -1078,7 +1086,6 @@
var->transp.offset = 0;
var->transp.length = 0;
break;
-#if 0
case CRTC_PIX_WIDTH_16BPP: /* RGB 565 */
bpp = 16;
var->red.offset = 11;
@@ -1090,7 +1097,6 @@
var->transp.offset = 0;
var->transp.length = 0;
break;
-#endif
case CRTC_PIX_WIDTH_24BPP: /* RGB 888 */
bpp = 24;
var->red.offset = 16;
@@ -2521,46 +2527,75 @@
u_int transp, struct fb_info *info)
{
struct atyfb_par *par = (struct atyfb_par *) info->par;
- int i, scale;
+ int i, depth;
u32 *pal = info->pseudo_palette;
+ depth = info->var.bits_per_pixel;
+ if (depth == 16)
+ depth = (info->var.green.length == 5) ? 15 : 16;
+
if (par->asleep)
return 0;
- if (regno > 255)
+
+ if (regno > 255 ||
+ (depth == 16 && regno > 63) ||
+ (depth == 15 && regno > 31))
return 1;
+
red >>= 8;
green >>= 8;
blue >>= 8;
+
+ par->palette[regno].red = red;
+ par->palette[regno].green = green;
+ par->palette[regno].blue = blue;
+
+ if (regno < 16) {
+ switch (depth) {
+ case 15:
+ pal[regno] = (regno << 10) | (regno << 5) | regno;
+ break;
+ case 16:
+ pal[regno] = (regno << 11) | (regno << 5) | regno;
+ break;
+ case 24:
+ pal[regno] = (regno << 16) | (regno << 8) | regno;
+ break;
+ case 32:
+ i = (regno << 8) | regno;
+ pal[regno] = (i << 16) | i;
+ break;
+ }
+ }
+
i = aty_ld_8(DAC_CNTL, par) & 0xfc;
if (M64_HAS(EXTRA_BRIGHT))
i |= 0x2; /* DAC_CNTL | 0x2 turns off the extra brightness for gt */
aty_st_8(DAC_CNTL, i, par);
aty_st_8(DAC_MASK, 0xff, par);
- scale = (M64_HAS(INTEGRATED) && info->var.bits_per_pixel == 16) ? 3 : 0;
+
+ if (M64_HAS(INTEGRATED)) {
+ if (depth == 16) {
+ red = par->palette[regno>>1].red;
+ blue = par->palette[regno>>1].blue;
+ regno <<= 2;
+ } else if (depth == 15) {
+ regno <<= 3;
+ }
+ }
+
#ifdef CONFIG_ATARI
- out_8(&par->aty_cmap_regs->windex, regno << scale);
+ out_8(&par->aty_cmap_regs->windex, regno);
out_8(&par->aty_cmap_regs->lut, red);
out_8(&par->aty_cmap_regs->lut, green);
out_8(&par->aty_cmap_regs->lut, blue);
#else
- writeb(regno << scale, &par->aty_cmap_regs->windex);
+ writeb(regno, &par->aty_cmap_regs->windex);
writeb(red, &par->aty_cmap_regs->lut);
writeb(green, &par->aty_cmap_regs->lut);
writeb(blue, &par->aty_cmap_regs->lut);
#endif
- if (regno < 16)
- switch (info->var.bits_per_pixel) {
- case 16:
- pal[regno] = (regno << 10) | (regno << 5) | regno;
- break;
- case 24:
- pal[regno] = (regno << 16) | (regno << 8) | regno;
- break;
- case 32:
- i = (regno << 8) | regno;
- pal[regno] = (i << 16) | i;
- break;
- }
+
return 0;
}
next reply other threads:[~2004-05-11 21:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-11 21:36 Ville Syrjälä [this message]
2004-05-12 9:11 ` [PATCH] atyfb (2.6): Add RGB565 support Geert Uytterhoeven
2004-05-12 18:57 ` Ville Syrjälä
2004-05-13 9:22 ` Geert Uytterhoeven
2004-05-13 19:19 ` Ville Syrjälä
2004-05-14 1:11 ` John Zielinski
2004-05-14 4:53 ` Ville Syrjälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040511213607.GB6854@sci.fi \
--to=syrjala@sci.fi \
--cc=linux-fbdev-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).