kernels/linux-2.4.0/drivers/video/cyber2000fb.c
/*
 *    Set a single color register. Return != 0 for invalid regno.
 */
Set a single color register. Return != 0 for invalid regno.
Set a single color register . Return ! = 0 for invalid regno .
static int
cyber2000_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
		    u_int transp, struct fb_info *info)
{
	struct cfb_info *cfb = (struct cfb_info *)info;
	if (regno >= NR_PALETTE)
		return 1;
	red   >>= 8;
	green >>= 8;
	blue  >>= 8;
	cfb->palette[regno].red   = red;
	cfb->palette[regno].green = green;
	cfb->palette[regno].blue  = blue;
	switch (cfb->fb.var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB8
	case 8:
		cyber2000_outb(regno, 0x3c8);
		cyber2000_outb(red,   0x3c9);
		cyber2000_outb(green, 0x3c9);
		cyber2000_outb(blue,  0x3c9);
		break;
#endif
#ifdef FBCON_HAS_CFB16
	case 16:
#ifndef CFB16_IS_CFB15
		if (regno < 64) {
			cyber2000_outb(regno << 2, 0x3c8);
			cyber2000_outb(cfb->palette[regno >> 1].red, 0x3c9);
			cyber2000_outb(green, 0x3c9);
			cyber2000_outb(cfb->palette[regno >> 1].blue, 0x3c9);
		}
		if (regno < 32) {
			cyber2000_outb(regno << 3, 0x3c8);
			cyber2000_outb(red, 0x3c9);
			cyber2000_outb(cfb->palette[regno << 1].green, 0x3c9);
			cyber2000_outb(blue, 0x3c9);
		}
		if (regno < 16)
			((u16 *)cfb->fb.pseudo_palette)[regno] =
				regno | regno << 5 | regno << 11;
		break;
#endif
	case 15:
		if (regno < 32) {
			cyber2000_outb(regno << 3, 0x3c8);
			cyber2000_outb(red, 0x3c9);
			cyber2000_outb(green, 0x3c9);
			cyber2000_outb(blue, 0x3c9);
		}
		if (regno < 16)
			((u16 *)cfb->fb.pseudo_palette)[regno] =
				regno | regno << 5 | regno << 10;
		break;
#endif
#ifdef FBCON_HAS_CFB24
	case 24:
		cyber2000_outb(regno, 0x3c8);
		cyber2000_outb(red,   0x3c9);
		cyber2000_outb(green, 0x3c9);
		cyber2000_outb(blue,  0x3c9);
		if (regno < 16)
			((u32 *)cfb->fb.pseudo_palette)[regno] =
				regno | regno << 8 | regno << 16;
		break;
#endif
	default:
		return 1;
	}
	return 0;
}
static int cyber2000_setcolreg ( u_int regno , u_int red , u_int green , u_int blue , u_int transp , struct fb_info * info ) { struct cfb_info * cfb = ( struct cfb_info * ) info ; if ( regno >= NR_PALETTE ) return 1 ; red >>= 8 ; green >>= 8 ; blue >>= 8 ; cfb -> palette [ regno ] . red = red ; cfb -> palette [ regno ] . green = green ; cfb -> palette [ regno ] . blue = blue ; switch ( cfb -> fb . var . bits_per_pixel ) { #ifdef FBCON_HAS_CFB8 case 8 : cyber2000_outb ( regno , 0x3c8 ) ; cyber2000_outb ( red , 0x3c9 ) ; cyber2000_outb ( green , 0x3c9 ) ; cyber2000_outb ( blue , 0x3c9 ) ; break ; #endif #ifdef FBCON_HAS_CFB16 case 16 : #ifndef CFB16_IS_CFB15 if ( regno < 64 ) { cyber2000_outb ( regno << 2 , 0x3c8 ) ; cyber2000_outb ( cfb -> palette [ regno >> 1 ] . red , 0x3c9 ) ; cyber2000_outb ( green , 0x3c9 ) ; cyber2000_outb ( cfb -> palette [ regno >> 1 ] . blue , 0x3c9 ) ; } if ( regno < 32 ) { cyber2000_outb ( regno << 3 , 0x3c8 ) ; cyber2000_outb ( red , 0x3c9 ) ; cyber2000_outb ( cfb -> palette [ regno << 1 ] . green , 0x3c9 ) ; cyber2000_outb ( blue , 0x3c9 ) ; } if ( regno < 16 ) ( ( u16 * ) cfb -> fb . pseudo_palette ) [ regno ] = regno | regno << 5 | regno << 11 ; break ; #endif case 15 : if ( regno < 32 ) { cyber2000_outb ( regno << 3 , 0x3c8 ) ; cyber2000_outb ( red , 0x3c9 ) ; cyber2000_outb ( green , 0x3c9 ) ; cyber2000_outb ( blue , 0x3c9 ) ; } if ( regno < 16 ) ( ( u16 * ) cfb -> fb . pseudo_palette ) [ regno ] = regno | regno << 5 | regno << 10 ; break ; #endif #ifdef FBCON_HAS_CFB24 case 24 : cyber2000_outb ( regno , 0x3c8 ) ; cyber2000_outb ( red , 0x3c9 ) ; cyber2000_outb ( green , 0x3c9 ) ; cyber2000_outb ( blue , 0x3c9 ) ; if ( regno < 16 ) ( ( u32 * ) cfb -> fb . pseudo_palette ) [ regno ] = regno | regno << 8 | regno << 16 ; break ; #endif default : return 1 ; } return 0 ; }
Set a single color register.
Set a single color register .
/* write green */ /* write red,blue */