/* vi: set sw=4 ts=4: */
/*
 * Mini fbset implementation for busybox
 *
 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
 *
 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
 *
 * This is a from-scratch implementation of fbset; but the de facto fbset
 * implementation was a good reference. fbset (original) is released under
 * the GPL, and is (c) 1995-1999 by:
 *     Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
 */

#include "libbb.h"

#define DEFAULTFBDEV  FB_0
#define DEFAULTFBMODE "/etc/fb.modes"

enum {
	CMD_FB = 1,
	CMD_DB = 2,
	CMD_GEOMETRY = 3,
	CMD_TIMING = 4,
	CMD_ACCEL = 5,
	CMD_HSYNC = 6,
	CMD_VSYNC = 7,
	CMD_LACED = 8,
	CMD_DOUBLE = 9,
/*	CMD_XCOMPAT =     10, */
	CMD_ALL = 11,
	CMD_INFO = 12,
	CMD_SHOW = 13,
	CMD_CHANGE = 14,

#if ENABLE_FEATURE_FBSET_FANCY
	CMD_XRES = 100,
	CMD_YRES = 101,
	CMD_VXRES = 102,
	CMD_VYRES = 103,
	CMD_DEPTH = 104,
	CMD_MATCH = 105,
	CMD_PIXCLOCK = 106,
	CMD_LEFT = 107,
	CMD_RIGHT = 108,
	CMD_UPPER = 109,
	CMD_LOWER = 110,
	CMD_HSLEN = 111,
	CMD_VSLEN = 112,
	CMD_CSYNC = 113,
	CMD_GSYNC = 114,
	CMD_EXTSYNC = 115,
	CMD_BCAST = 116,
	CMD_RGBA = 117,
	CMD_STEP = 118,
	CMD_MOVE = 119,
#endif
};

/* Stuff stolen from the kernel's fb.h */
#define FB_ACTIVATE_ALL 64
enum {
	FBIOGET_VSCREENINFO = 0x4600,
	FBIOPUT_VSCREENINFO = 0x4601
};
struct fb_bitfield {
	uint32_t offset;                /* beginning of bitfield */
	uint32_t length;		/* length of bitfield */
	uint32_t msb_right;             /* !=0: Most significant bit is right */
};
struct fb_var_screeninfo {
	uint32_t xres;                  /* visible resolution */
	uint32_t yres;
	uint32_t xres_virtual;          /* virtual resolution */
	uint32_t yres_virtual;
	uint32_t xoffset;               /* offset from virtual to visible */
	uint32_t yoffset;               /* resolution */

	uint32_t bits_per_pixel;
	uint32_t grayscale;             /* !=0 Graylevels instead of colors */

	struct fb_bitfield red;         /* bitfield in fb mem if true color, */
	struct fb_bitfield green;       /* else only length is significant */
	struct fb_bitfield blue;
	struct fb_bitfield transp;      /* transparency */

	uint32_t nonstd;                /* !=0 Non standard pixel format */

	uint32_t activate;              /* see FB_ACTIVATE_x */

	uint32_t height;                /* height of picture in mm */
	uint32_t width;                 /* width of picture in mm */

	uint32_t accel_flags;		/* acceleration flags (hints) */

	/* Timing: All values in pixclocks, except pixclock (of course) */
	uint32_t pixclock;              /* pixel clock in ps (pico seconds) */
	uint32_t left_margin;           /* time from sync to picture */
	uint32_t right_margin;          /* time from picture to sync */
	uint32_t upper_margin;          /* time from sync to picture */
	uint32_t lower_margin;
	uint32_t hsync_len;             /* length of horizontal sync */
	uint32_t vsync_len;             /* length of vertical sync */
	uint32_t sync;                  /* see FB_SYNC_x */
	uint32_t vmode;                 /* see FB_VMODE_x */
	uint32_t reserved[6];           /* Reserved for future compatibility */
};


static const struct cmdoptions_t {
	const char name[9];
	const unsigned char param_count;
	const unsigned char code;
} g_cmdoptions[] = {
	/*"12345678" + NUL */
	{ "fb"      , 1, CMD_FB       },
	{ "db"      , 1, CMD_DB       },
	{ "a"       , 0, CMD_ALL      },
	{ "i"       , 0, CMD_INFO     },
	{ "g"       , 5, CMD_GEOMETRY },
	{ "t"       , 7, CMD_TIMING   },
	{ "accel"   , 1, CMD_ACCEL    },
	{ "hsync"   , 1, CMD_HSYNC    },
	{ "vsync"   , 1, CMD_VSYNC    },
	{ "laced"   , 1, CMD_LACED    },
	{ "double"  , 1, CMD_DOUBLE   },
	{ "show"    , 0, CMD_SHOW     },
	{ "s"       , 0, CMD_SHOW     },
#if ENABLE_FEATURE_FBSET_FANCY
	{ "all"     , 0, CMD_ALL      },
	{ "xres"    , 1, CMD_XRES     },
	{ "yres"    , 1, CMD_YRES     },
	{ "vxres"   , 1, CMD_VXRES    },
	{ "vyres"   , 1, CMD_VYRES    },
	{ "depth"   , 1, CMD_DEPTH    },
	{ "match"   , 0, CMD_MATCH    },
	{ "geometry", 5, CMD_GEOMETRY },
	{ "pixclock", 1, CMD_PIXCLOCK },
	{ "left"    , 1, CMD_LEFT     },
	{ "right"   , 1, CMD_RIGHT    },
	{ "upper"   , 1, CMD_UPPER    },
	{ "lower"   , 1, CMD_LOWER    },
	{ "hslen"   , 1, CMD_HSLEN    },
	{ "vslen"   , 1, CMD_VSLEN    },
	{ "timings" , 7, CMD_TIMING   },
	{ "csync"   , 1, CMD_CSYNC    },
	{ "gsync"   , 1, CMD_GSYNC    },
	{ "extsync" , 1, CMD_EXTSYNC  },
	{ "bcast"   , 1, CMD_BCAST    },
	{ "rgba"    , 1, CMD_RGBA     },
	{ "step"    , 1, CMD_STEP     },
	{ "move"    , 1, CMD_MOVE     },
#endif
};

#if ENABLE_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
enum {
	FB_VMODE_INTERLACED = 1,        /* interlaced */
	FB_VMODE_DOUBLE = 2,            /* double scan */
	FB_SYNC_HOR_HIGH_ACT = 1,       /* horizontal sync high active */
	FB_SYNC_VERT_HIGH_ACT = 2,      /* vertical sync high active */
	FB_SYNC_EXT = 4,                /* external sync */
	FB_SYNC_COMP_HIGH_ACT = 8,      /* composite sync high active */
};
#endif

#if ENABLE_FEATURE_FBSET_READMODE
static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what)
{
	if (strcmp(buf, what) == 0)
		*x &= ~flag;
	else
		*x |= flag;
}

static int read_mode_db(struct fb_var_screeninfo *base, const char *fn,
					const char *mode)
{
	char *token[2], *p, *s;
	parser_t *parser = config_open(fn);

	while (config_read(parser, token, 2, 1, "# \t\r", PARSE_NORMAL)) {
		if (strcmp(token[0], "mode") != 0 || !token[1])
			continue;
		p = strstr(token[1], mode);
		if (!p)
			continue;
		s = p + strlen(mode);
		//bb_info_msg("CHECK[%s][%s][%d]", mode, p-1, *s);
		/* exact match? */
		if (((!*s || isspace(*s)) && '"' != s[-1]) /* end-of-token */
		 || ('"' == *s && '"' == p[-1]) /* ends with " but starts with " too! */
		) {
			//bb_info_msg("FOUND[%s][%s][%s][%d]", token[1], p, mode, isspace(*s));
			break;
		}
	}

	if (!token[0])
		return 0;

	while (config_read(parser, token, 2, 1, "# \t", PARSE_NORMAL)) {
		int i;

//bb_info_msg("???[%s][%s]", token[0], token[1]);
		if (strcmp(token[0], "endmode") == 0) {
//bb_info_msg("OK[%s]", mode);
			return 1;
		}
		p = token[1];
		i = index_in_strings(
			"geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0",
			token[0]);
		switch (i) {
		case 0:
			/* FIXME: catastrophic on arches with 64bit ints */
			sscanf(p, "%d %d %d %d %d",
				&(base->xres), &(base->yres),
				&(base->xres_virtual), &(base->yres_virtual),
				&(base->bits_per_pixel));
//bb_info_msg("GEO[%s]", p);
			break;
		case 1:
			sscanf(p, "%d %d %d %d %d %d %d",
				&(base->pixclock),
				&(base->left_margin), &(base->right_margin),
				&(base->upper_margin), &(base->lower_margin),
				&(base->hsync_len), &(base->vsync_len));
//bb_info_msg("TIM[%s]", p);
			break;
		case 2:
		case 3: {
			static const uint32_t syncs[] = {FB_VMODE_INTERLACED, FB_VMODE_DOUBLE};
			ss(&base->vmode, syncs[i-2], p, "false");
//bb_info_msg("VMODE[%s]", p);
			break;
		}
		case 4:
		case 5:
		case 6:	{
			static const uint32_t syncs[] = {FB_SYNC_VERT_HIGH_ACT, FB_SYNC_HOR_HIGH_ACT, FB_SYNC_COMP_HIGH_ACT};
			ss(&base->sync, syncs[i-4], p, "low");
//bb_info_msg("SYNC[%s]", p);
			break;
		}
		case 7:
			ss(&base->sync, FB_SYNC_EXT, p, "false");
//bb_info_msg("EXTSYNC[%s]", p);
			break;
		}
	}
	return 0;
}
#endif

static void setfbmode(struct fb_var_screeninfo *base,
					struct fb_var_screeninfo *set)
{
	if ((int32_t) set->xres > 0)
		base->xres = set->xres;
	if ((int32_t) set->yres > 0)
		base->yres = set->yres;
	if ((int32_t) set->xres_virtual > 0)
		base->xres_virtual = set->xres_virtual;
	if ((int32_t) set->yres_virtual > 0)
		base->yres_virtual = set->yres_virtual;
	if ((int32_t) set->bits_per_pixel > 0)
		base->bits_per_pixel = set->bits_per_pixel;
}

static NOINLINE void showmode(struct fb_var_screeninfo *v)
{
	double drate = 0, hrate = 0, vrate = 0;

	if (v->pixclock) {
		drate = 1e12 / v->pixclock;
		hrate = drate / (v->left_margin + v->xres + v->right_margin + v->hsync_len);
		vrate = hrate / (v->upper_margin + v->yres + v->lower_margin + v->vsync_len);
	}
	printf("\nmode \"%ux%u-%u\"\n"
#if ENABLE_FEATURE_FBSET_FANCY
	"\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n"
#endif
	"\tgeometry %u %u %u %u %u\n"
	"\ttimings %u %u %u %u %u %u %u\n"
	"\taccel %s\n"
	"\trgba %u/%u,%u/%u,%u/%u,%u/%u\n"
	"endmode\n\n",
		v->xres, v->yres, (int) (vrate + 0.5),
#if ENABLE_FEATURE_FBSET_FANCY
		drate / 1e6, hrate / 1e3, vrate,
#endif
		v->xres, v->yres, v->xres_virtual, v->yres_virtual, v->bits_per_pixel,
		v->pixclock, v->left_margin, v->right_margin, v->upper_margin, v->lower_margin,
			v->hsync_len, v->vsync_len,
		(v->accel_flags > 0 ? "true" : "false"),
		v->red.length, v->red.offset, v->green.length, v->green.offset,
			v->blue.length, v->blue.offset, v->transp.length, v->transp.offset);
}

int fbset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int fbset_main(int argc, char **argv)
{
	enum {
		OPT_CHANGE   = (1 << 0),
		OPT_SHOW     = (1 << 1),
		OPT_READMODE = (1 << 2),
		OPT_ALL      = (1 << 9),
	};
	struct fb_var_screeninfo var, varset;
	int fh, i;
	unsigned options = 0;

	const char *fbdev = DEFAULTFBDEV;
	const char *modefile = DEFAULTFBMODE;
	char *thisarg, *mode = NULL;

	memset(&varset, 0xff, sizeof(varset));

	/* parse cmd args.... why do they have to make things so difficult? */
	argv++;
	argc--;
	for (; argc > 0 && (thisarg = *argv) != NULL; argc--, argv++) {
		if (thisarg[0] == '-') for (i = 0; i < ARRAY_SIZE(g_cmdoptions); i++) {
			if (strcmp(thisarg + 1, g_cmdoptions[i].name) != 0)
				continue;
			if (argc <= g_cmdoptions[i].param_count)
				bb_show_usage();

			switch (g_cmdoptions[i].code) {
			case CMD_FB:
				fbdev = argv[1];
				break;
			case CMD_DB:
				modefile = argv[1];
				break;
			case CMD_ALL:
				options |= OPT_ALL;
				break;
			case CMD_SHOW:
				options |= OPT_SHOW;
				break;
			case CMD_GEOMETRY:
				varset.xres = xatou32(argv[1]);
				varset.yres = xatou32(argv[2]);
				varset.xres_virtual = xatou32(argv[3]);
				varset.yres_virtual = xatou32(argv[4]);
				varset.bits_per_pixel = xatou32(argv[5]);
				break;
			case CMD_TIMING:
				varset.pixclock = xatou32(argv[1]);
				varset.left_margin = xatou32(argv[2]);
				varset.right_margin = xatou32(argv[3]);
				varset.upper_margin = xatou32(argv[4]);
				varset.lower_margin = xatou32(argv[5]);
				varset.hsync_len = xatou32(argv[6]);
				varset.vsync_len = xatou32(argv[7]);
				break;
#if ENABLE_FEATURE_FBSET_FANCY
			case CMD_XRES:
				varset.xres = xatou32(argv[1]);
				break;
			case CMD_YRES:
				varset.yres = xatou32(argv[1]);
				break;
			case CMD_DEPTH:
				varset.bits_per_pixel = xatou32(argv[1]);
				break;
#endif
			}
			switch (g_cmdoptions[i].code) {
			case CMD_FB:
			case CMD_DB:
			case CMD_ALL:
			case CMD_SHOW:
				break;
			default:
				options |= OPT_CHANGE; /* the other commands imply changes */
			}
			argc -= g_cmdoptions[i].param_count;
			argv += g_cmdoptions[i].param_count;
			goto contin;
		}
		if (argc != 1)
			bb_show_usage();
		mode = *argv;
		options |= OPT_READMODE;
 contin: ;
	}

	fh = xopen(fbdev, O_RDONLY);
	xioctl(fh, FBIOGET_VSCREENINFO, &var);
	if (options & OPT_READMODE) {
#if !ENABLE_FEATURE_FBSET_READMODE
		bb_show_usage();
#else
		if (!read_mode_db(&var, modefile, mode)) {
			bb_error_msg_and_die("unknown video mode '%s'", mode);
		}
#endif
	}

	if (options & OPT_CHANGE) {
		setfbmode(&var, &varset);
		if (options & OPT_ALL)
			var.activate = FB_ACTIVATE_ALL;
		xioctl(fh, FBIOPUT_VSCREENINFO, &var);
	}
	if (options == 0 || options & OPT_SHOW)
		showmode(&var);
	/* Don't close the file, as exiting will take care of that */
	/* close(fh); */

	return EXIT_SUCCESS;
}
