scrp->offset.red = ffs(mask.red); scrp->offset.green = ffs(mask.green); scrp->offset.blue = ffs(mask.blue);
scrp->offset.red = ffs(mask.red) - 1; scrp->offset.green = ffs(mask.green) - 1; scrp->offset.blue = ffs(mask.blue) - 1;
xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask){    MessageType weightFrom = X_DEFAULT;    scrp->weight.red = 0;    scrp->weight.green = 0;    scrp->weight.blue = 0;    if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) {	scrp->weight = xf86Weight;	weightFrom = X_CMDLINE;    } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0	       && scrp->display->weight.blue > 0) {	scrp->weight = scrp->display->weight;	weightFrom = X_CONFIG;    } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {	scrp->weight = weight;    } else {	switch (scrp->depth) {	case 1:	case 4:	case 8:	    scrp->weight.red = scrp->weight.green =		scrp->weight.blue = scrp->rgbBits;	    break;	case 15:	    scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;	    break;	case 16:	    scrp->weight.red = scrp->weight.blue = 5;	    scrp->weight.green = 6;	    break;	case 24:	    scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;	    break;	case 30:	    scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;	    break;	}    }    if (scrp->weight.red)	xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",		   (int)scrp->weight.red, (int)scrp->weight.green,		   (int)scrp->weight.blue);    if (scrp->depth > MAX_PSEUDO_DEPTH &&	(scrp->depth != scrp->weight.red + scrp->weight.green +			scrp->weight.blue)) {	xf86DrvMsg(scrp->scrnIndex, X_ERROR,		   "Weight given (%d%d%d) is inconsistent with the "		   "depth (%d)\n",		   (int)scrp->weight.red, (int)scrp->weight.green,		   (int)scrp->weight.blue, scrp->depth);	return FALSE;    }    if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) {	/*	 * XXX Does this even mean anything for TrueColor visuals?	 * If not, we shouldn't even be setting it here.  However, this	 * matches the behaviour of 3.x versions of XFree86.	 */	scrp->rgbBits = scrp->weight.red;	if (scrp->weight.green > scrp->rgbBits)	    scrp->rgbBits = scrp->weight.green;	if (scrp->weight.blue > scrp->rgbBits)	    scrp->rgbBits = scrp->weight.blue;    }    /* Set the mask and offsets */    if (mask.red == 0 || mask.green == 0 || mask.blue == 0) {	/* Default to a setting common to PC hardware */	scrp->offset.red = scrp->weight.green + scrp->weight.blue;	scrp->offset.green = scrp->weight.blue;	scrp->offset.blue = 0;	scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;	scrp->mask.green = ((1 << scrp->weight.green) - 1)				<< scrp->offset.green;	scrp->mask.blue = (1 << scrp->weight.blue) - 1;    } else {	/* Initialise to the values passed */	scrp->mask.red = mask.red;	scrp->mask.green = mask.green;	scrp->mask.blue = mask.blue;	scrp->offset.red = ffs(mask.red);	scrp->offset.green = ffs(mask.green);	scrp->offset.blue = ffs(mask.blue);    }    return TRUE;}