rem: status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row)
add: status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row, bool *acc_mode)
context: status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row){	/* Note:	 * This routine assumes that the CRTC memory pitch granularity is 'smaller than',	 * or 'equals' the acceleration engine memory pitch granularity! */	uint32 video_pitch;	uint32 acc_mask, crtc_mask;	uint8 depth = 8;	/* determine pixel multiple based on 2D/3D engine constraints */	switch (si->ps.card_arch)	{	default:		/* confirmed for:		 * TNT1, TNT2, TNT2-M64, GeForce2 MX400, GeForce4 MX440, GeForceFX 5200 */		switch (target->space)		{			case B_CMAP8: acc_mask = 0x0f; depth =  8; break;			case B_RGB15: acc_mask = 0x07; depth = 16; break;			case B_RGB16: acc_mask = 0x07; depth = 16; break;			case B_RGB24: acc_mask = 0x0f; depth = 24; break;			case B_RGB32: acc_mask = 0x03; depth = 32; break;			default:				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));				return B_ERROR;		}		/* NV31 (confirmed GeForceFX 5600) has NV20A granularity!		 * So let it fall through... */		if (si->ps.card_type != NV31) break;	case NV20A:		/* confirmed for:		 * GeForce4 Ti4200 */		switch (target->space)		{			case B_CMAP8: acc_mask = 0x3f; depth =  8; break;			case B_RGB15: acc_mask = 0x1f; depth = 16; break;			case B_RGB16: acc_mask = 0x1f; depth = 16; break;			case B_RGB24: acc_mask = 0x3f; depth = 24; break;			case B_RGB32: acc_mask = 0x0f; depth = 32; break;			default:				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));				return B_ERROR;		}		break;	}	/* determine pixel multiple based on CRTC memory pitch constraints.	 * (Note: Don't mix this up with CRTC timing contraints! Those are	 *        multiples of 8 for horizontal, 1 for vertical timing.) */	switch (si->ps.card_arch)	{	default:		/* all NV cards */		switch (target->space)		{			case B_CMAP8: crtc_mask = 0x07; break;			case B_RGB15: crtc_mask = 0x03; break;			case B_RGB16: crtc_mask = 0x03; break;			case B_RGB24: crtc_mask = 0x07; break;			case B_RGB32: crtc_mask = 0x01; break;			default:				LOG(8,("INIT: unknown color space: 0x%08x\n", target->space));				return B_ERROR;		}//fixme for NV..		/* see G400 specs: CRTC2 has different constraints */		/* Note:		 * set for RGB and B_YCbCr422 modes. Other modes need larger multiples! */		if (target->flags & DUALHEAD_BITS)		{			switch (target->space)			{				case B_RGB16: crtc_mask = 0x1f; break;				case B_RGB32: crtc_mask = 0x0f; break;				default:					LOG(8,("INIT: illegal DH color space: 0x%08x\n", target->space));					return B_ERROR;			}		}//end fixme.		break;	}	/* check if we can setup this mode with acceleration:	 * Max sizes need to adhere to both the acceleration engine _and_ the CRTC constraints! */	si->acc_mode = true;	/* check virtual_width */	switch (si->ps.card_arch)	{	case NV04A:		/* confirmed for:		 * TNT1, TNT2, TNT2-M64 */		switch(target->space)		{		case B_CMAP8:			if (target->virtual_width > 8176) si->acc_mode = false;			break;		case B_RGB15_LITTLE:		case B_RGB16_LITTLE:			if (target->virtual_width > 4088) si->acc_mode = false;			break;		case B_RGB24_LITTLE:			if (target->virtual_width > 2720) si->acc_mode = false;			break;		case B_RGB32_LITTLE:			if (target->virtual_width > 2044) si->acc_mode = false;			break;		}		break;	default:		/* confirmed for:		 * GeForce2 MX400, GeForce4 MX440, GeForceFX 5200 */		switch(target->space)		{		case B_CMAP8:			if (target->virtual_width > 16368) si->acc_mode = false;			break;		case B_RGB15_LITTLE:		case B_RGB16_LITTLE:			if (target->virtual_width > 8184) si->acc_mode = false;			break;		case B_RGB24_LITTLE:			if (target->virtual_width > 5456) si->acc_mode = false;			break;		case B_RGB32_LITTLE:			if (target->virtual_width > 4092) si->acc_mode = false;			break;		}		/* NV31 (confirmed GeForceFX 5600) has NV20A granularity!		 * So let it fall through... */		if (si->ps.card_type != NV31) break;	case NV20A:		/* confirmed for:		 * GeForce4 Ti4200 */		switch(target->space)		{		case B_CMAP8:			if (target->virtual_width > 16320) si->acc_mode = false;			break;		case B_RGB15_LITTLE:		case B_RGB16_LITTLE:			if (target->virtual_width > 8160) si->acc_mode = false;			break;		case B_RGB24_LITTLE:			if (target->virtual_width > 5440) si->acc_mode = false;			break;		case B_RGB32_LITTLE:			if (target->virtual_width > 4080) si->acc_mode = false;			break;		}		break;	}	/* virtual_height */	/* (NV cards can even do more than this(?)...	 *  but 4096 is confirmed on all cards at max. accelerated width.) */	if (target->virtual_height > 4096) si->acc_mode = false;	/* now check NV virtual_size based on CRTC constraints */	{		/* virtual_width */		//fixme for NV CRTC2?...:		switch(target->space)		{		case B_CMAP8:			if (target->virtual_width > 16376)				target->virtual_width = 16376;			break;		case B_RGB15_LITTLE:		case B_RGB16_LITTLE:			if (target->virtual_width > 8188)				target->virtual_width = 8188;			break;		case B_RGB24_LITTLE:			if (target->virtual_width > 5456)				target->virtual_width = 5456;			break;		case B_RGB32_LITTLE:			if (target->virtual_width > 4094)				target->virtual_width = 4094;			break;		}		/* virtual_height: The only constraint here is the cards memory size which is		 * checked later on in ProposeMode: virtual_height is adjusted then if needed.		 * 'Limiting here' to the variable size that's at least available (uint16). */		if (target->virtual_height > 65535) target->virtual_height = 65535;	}	/* OK, now we know that virtual_width is valid, and it's needing no slopspace if	 * it was confined above, so we can finally calculate safely if we need slopspace	 * for this mode... */	if (si->acc_mode)		video_pitch = ((target->virtual_width + acc_mask) & ~acc_mask);	else		video_pitch = ((target->virtual_width + crtc_mask) & ~crtc_mask);	LOG(2,("INIT: memory pitch will be set to %d pixels for colorspace 0x%08x\n",														video_pitch, target->space)); 	if (target->virtual_width != video_pitch)		LOG(2,("INIT: effective mode slopspace is %d pixels\n", 											(video_pitch - target->virtual_width)));	/* now calculate bytes_per_row for this mode */	*bytes_per_row = video_pitch * (depth >> 3);	return B_OK;}