Example #1
0
void dbox2_fp_restart (char * cmd)
{
	volatile u32 *flash;
	u32 *addr;
	local_irq_disable();
	
	switch (mid) {
	case TUXBOX_DBOX2_MID_NOKIA:
		/* 
			We have a problem here if the flash
		  	is not in read-array mode. In theory
			the reset circuit should take care
			of this but somehow that doesn't
			happen for some Nokias, so we simply 
			force the chip into the read array 
			mode, no matter what state it was in.
		 */
		flash = addr = ioremap(0x10000000,4);
		if (flash) {
			*flash = 0x00ff00ff; /* Intel */
			*flash = 0x00f000f0; /* AMD */
			iounmap(addr);
		}
		fp_sendcmd(fp_i2c_client, 0x00, 0x14);
		break;
	case TUXBOX_DBOX2_MID_PHILIPS:
	case TUXBOX_DBOX2_MID_SAGEM:
		fp_sendcmd(fp_i2c_client, 0x00, 0x09);
		break;
	}

	for (;;);
}
Example #2
0
void dbox2_fp_power_off (void)
{
	switch (mid) {
	case TUXBOX_DBOX2_MID_NOKIA:
		fp_sendcmd(fp_i2c_client, 0x00, 0x03);
		break;
	case TUXBOX_DBOX2_MID_PHILIPS:
	case TUXBOX_DBOX2_MID_SAGEM:
		fp_sendcmd(fp_i2c_client, 0x00, 0x00);
		break;
	}

	for (;;);
}
Example #3
0
/*
 * Callback function for asynchronous Redis. Receive a block of data,
 * and if it looks like a message, process it and assemble a libfonz
 * packet for transmission serially.
 */
void
pkt_recv(redisAsyncContext *ctxt, void *reply, void *privdata)
{
	int n, cmd, opt1, opt2;
	char *cp, *json;
	unsigned char wrbuffer[32];
	redisReply *rp = reply;

	if (reply == NULL)
		return;

	if (rp->type != REDIS_REPLY_ARRAY || rp->elements != 3 || strcmp(rp->element[0]->str, "message") != 0)
		return;

	cmd = opt1 = opt2 = 0;
	json = rp->element[2]->str;
	if (rxlfp != NULL)
		fprintf(rxlfp, "> [%s]\n", json);
	if (*json == '[') {
		/*
		 * We have an array. If the array has a single element,
		 * treat it as a REQUEST command. If it has a comma,
		 * it's a RESPONSE command and the second (and possibly
		 * the third) arguments are the command options.
		 */
		if ((cp = strchr(++json, ']')) != NULL)
			*cp = '\0';
		if ((cp = strchr(json, ',')) != NULL) {
			*cp++ = '\0';
			cmd = atoi(json) | FONZ_RESPONSE;
			if ((cp = strchr(json = cp, ',')) != NULL) {
				*cp++ = '\0';
				opt1 = atoi(json);
				opt2 = atoi(cp);
			} else
				opt1 = atoi(json);
		} else
			cmd = atoi(json) & ~FONZ_RESPONSE;
	} else {
		/*
		 * A single integer argument. This is a REQUEST command.
		 */
		cmd = atoi(json) & ~FONZ_RESPONSE;
	}
	if (rxlfp != NULL) {
		if (cmd & FONZ_RESPONSE)
			fprintf(rxlfp, "CMD: 0x%02x, Opts=(%d/%d)\n", cmd, opt1, opt2);
		else
			fprintf(rxlfp, "CMD: 0x%02x\n", cmd);
	}
	fp_sendcmd(cmd, opt1, opt2, 0);
	while ((n = fp_outbuffer(wrbuffer, sizeof(wrbuffer))) > 0) {
		if (write(filedes, wrbuffer, n) != n) {
			perror("redis_rx: write");
			exit(1);
		}
	}
}