Exemplo n.º 1
0
int
serialVFD_init_parallel (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;
#ifdef HAVE_PCSTYLE_LPT_CONTROL
	debug(RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port);
	if (port_access_multiple(p->port,3)) {
		report(RPT_ERR, "%s: port_access_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror(errno));
		return -1;
	}
	return 0;
#else
	report(RPT_ERR, "%s: LCDproc was compiled without PCstyle LPT support\n", __FUNCTION__);
	return -1;
#endif
}
/**
 * API: Initialize the driver.
 */
MODULE_EXPORT int
sdeclcd_init(Driver *drvthis)
{
	PrivateData *p;
	int i, j;
	/*
	 * Compact version of big num character bitmaps. Stack each line
	 * separately to visualize each char.
	 */
	static char bignum_bitmaps[] = {
		b___XXXX, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___,
		b__XXXX_, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX,
		b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b___XXXX,
		b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b__XXXX_,
		b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX,
		b__XXXXX, b_______, b_______, b_______, b_______, b_______, b_______, b__XXXXX,
		b__XXXX_, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b_____XX, b__XXXX_,
		b___XXXX, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b__XX___, b___XXXX
	};

	/* Allocate and store private data */
	p = (PrivateData *) malloc(sizeof(PrivateData));
	if (p == NULL)
		return -1;
	if (drvthis->store_private_ptr(drvthis, p))
		return -1;

	/* Initialize private data and read config */
	p->ccmode = standard;
	p->bklgt = BACKLIGHT_ON;
	p->bklgt_timer = SDEC_BKLT_DFT;
	p->bklgt_lasttime = time(NULL);
	p->hrbt_lasttime = time(NULL);
	p->hb_stus = HEARTBEAT_OFF;
	p->framebuf = (char *)malloc(SDEC_DISP_W * SDEC_DISP_H);
	p->framelcd = (char *)malloc(SDEC_DISP_W * SDEC_DISP_H);
	p->vbar_cg = (char *)malloc(SDEC_CELL_H * SDEC_NUM_CC);
	p->hbar_cg = (char *)malloc(SDEC_CELL_H * SDEC_NUM_CC);
	p->bignum_cg = (char *)bignum_bitmaps;

	if (NULL == p->framebuf || NULL == p->framelcd ||
	    NULL == p->vbar_cg || NULL == p->hbar_cg) {
		report(RPT_ERR, "%s: unable to allocate framebuffer",
		       drvthis->name);
		return -1;
	}

	memset(p->framebuf, ' ', SDEC_DISP_W * SDEC_DISP_H);
	memset(p->framelcd, ' ', SDEC_DISP_W * SDEC_DISP_H);

	/* Prepare custom character bitmaps:vbar, hbar */
	for (i = 0; i < SDEC_NUM_CC; i++) {
		for (j = 0; j < SDEC_CELL_H; j++) {
			/* Visualize this: */
			p->vbar_cg[i * SDEC_CELL_H + SDEC_CELL_H - j - 1] = (j <= i) ? 0xFF : 0;
			p->hbar_cg[i * SDEC_CELL_H + j] = (~(0x0F >> i)) & 0x1F;
		}
	}

	p->bignum_cg = bignum_bitmaps;

	/* Initializes the scheduler, see timing.h */
	timing_init();

	/* Initialize access to the ports */
	if (port_access_multiple(LPT_DEFAULT, 3)) {
		report(RPT_ERR, "%s: cannot get IO-permission for 0x%03X! Are we root?",
		       drvthis->name, LPT_DEFAULT);
		return -1;
	}
	sdec_init();
	return 0;
}