Exemplo n.º 1
0
void
fb_setsize(struct sunfb *sf, int def_depth, int def_width, int def_height,
    int node, int bustype)
{
	int def_linebytes;

	switch (bustype) {
	case BUS_VME16:
	case BUS_VME32:
	case BUS_OBIO:
#if defined(SUN4M)
		/* 4m may have SBus-like framebuffer on obio */
		if (CPU_ISSUN4M) {
			goto obpsize;
		}
#endif
		/* Set up some defaults. */
		sf->sf_width = def_width;
		sf->sf_height = def_height;
		sf->sf_depth = def_depth;

#if defined(SUN4)
		/*
		 * This is not particularly useful on Sun 4 VME framebuffers.
		 * The EEPROM only contains info about the built-in.
		 */
		if (CPU_ISSUN4 && bustype == BUS_OBIO) {
			struct eeprom *eep = (struct eeprom *)eeprom_va;

			if (ISSET(sf->sf_flags, FB_PFOUR)) {
				volatile u_int32_t pfour;
				u_int size;

				pfour = *sf->sf_pfour;

				/*
				 * Use the pfour register to determine
				 * the size.  Note that the cgsix and
				 * cgeight don't use this size encoding.
				 * In this case, we have to settle
				 * for the defaults we were provided
				 * with.
				 */
				if ((PFOUR_ID(pfour) == PFOUR_ID_COLOR24) ||
				    (PFOUR_ID(pfour) == PFOUR_ID_FASTCOLOR))
					size = 0x00; /* invalid */
				else
					size = PFOUR_SIZE(pfour);

				switch (size) {
				case PFOUR_SIZE_1152X900:
					sf->sf_width = 1152;
					sf->sf_height = 900;
					break;
				case PFOUR_SIZE_1024X1024:
					sf->sf_width = 1024;
					sf->sf_height = 1024;
					break;
				case PFOUR_SIZE_1280X1024:
					sf->sf_width = 1280;
					sf->sf_height = 1024;
					break;
				case PFOUR_SIZE_1600X1280:
					sf->sf_width = 1600;
					sf->sf_height = 1280;
					break;
				case PFOUR_SIZE_1440X1440:
					sf->sf_width = 1440;
					sf->sf_height = 1440;
					break;
				case PFOUR_SIZE_640X480:
					sf->sf_width = 640;
					sf->sf_height = 480;
					break;
				}
			} else if (eep != NULL) {
				switch (eep->eeScreenSize) {
				case EE_SCR_1152X900:
					sf->sf_width = 1152;
					sf->sf_height = 900;
					break;
				case EE_SCR_1024X1024:
					sf->sf_width = 1024;
					sf->sf_height = 1024;
					break;
				case EE_SCR_1600X1280:
					sf->sf_width = 1600;
					sf->sf_height = 1280;
					break;
				case EE_SCR_1440X1440:
					sf->sf_width = 1440;
					sf->sf_height = 1440;
					break;
				}
			}
		}
#endif /* SUN4 */
#if defined(SUN4M)
		if (CPU_ISSUN4M) {
			/* XXX: need code to find 4/600 vme screen size */
		}
#endif /* SUN4M */

		sf->sf_linebytes = (sf->sf_width * sf->sf_depth) / 8;
		break;

	case BUS_SBUS:
#if defined(SUN4M)
obpsize:
#endif
		sf->sf_depth = getpropint(node, "depth", def_depth);
		sf->sf_width = getpropint(node, "width", def_width);
		sf->sf_height = getpropint(node, "height", def_height);

		def_linebytes =
		    roundup(sf->sf_width, sf->sf_depth) * sf->sf_depth / 8;
		sf->sf_linebytes = getpropint(node, "linebytes", def_linebytes);

		/*
		 * XXX If we are configuring a board in a wider depth level
		 * than the mode it is currently operating in, the PROM will
		 * return a linebytes property tied to the current depth value,
		 * which is NOT what we are relying upon!
		 */
		if (sf->sf_linebytes < (sf->sf_width * sf->sf_depth) / 8)
			sf->sf_linebytes = def_linebytes;

		break;
	}

	sf->sf_fbsize = sf->sf_height * sf->sf_linebytes;
}
Exemplo n.º 2
0
void
fb_setsize_pfour(struct fbdevice *fb)
{
#if defined(SUN4)
	volatile u_int32_t pfour;
	int width, height;

	/*
	 * Some pfour framebuffers, e.g. the
	 * cgsix, don't encode resolution the
	 * same, so the driver handles that.
	 * The driver can let us know that it
	 * needs to do this by not mapping in
	 * the pfour register by the time this
	 * routine is called.
	 */
	if (fb->fb_pfour == NULL)
		return;

	pfour = *fb->fb_pfour;

	/*
	 * Use the pfour register to determine
	 * the size.  Note that the cgsix and
	 * cgeight don't use this size encoding.
	 * In this case, we have to settle
	 * for the defaults we were provided
	 * with.
	 */
	if ((PFOUR_ID(pfour) == PFOUR_ID_COLOR24) ||
	    (PFOUR_ID(pfour) == PFOUR_ID_FASTCOLOR))
		return;

	switch (PFOUR_SIZE(pfour)) {
	case PFOUR_SIZE_1152X900:
		width = 1152;
		height = 900;
		break;

	case PFOUR_SIZE_1024X1024:
		width = 1024;
		height = 1024;
		break;

	case PFOUR_SIZE_1280X1024:
		width = 1280;
		height = 1024;
		break;

	case PFOUR_SIZE_1600X1280:
		width = 1600;
		height = 1280;
		break;

	case PFOUR_SIZE_1440X1440:
		width = 1440;
		height = 1440;
		break;

	case PFOUR_SIZE_640X480:
		width = 640;
		height = 480;
		break;

	default:

		/*
		 * Use the defaults already filled in by the generic fb code.
		 */

		return;
	}

	fb->fb_type.fb_width = width;
	fb->fb_type.fb_height = height;
#endif /* SUN4 */
}