Ejemplo n.º 1
0
static int		dump_rom_2	(CalcHandle* handle, CalcDumpSize size, const char *filename)
{
	int ret = 0;
	unsigned int i;

	if (handle->model == CALC_TI83)
	{
		static const uint16_t keys[] = {
			0x40, 0x09, 0x09,       /* Quit, Clear, Clear, */
			0xFE63, 0x97, 0xDA,     /* Send(, 9, prgm */
			0xAB, 0xA8, 0xA6, 0x9D, /* R, O, M, D */
			0xAE, 0xA6, 0xA9, 0x05  /* U, M, P, Enter */
		};

		// Launch program by remote control
		for (i = 0; !ret && i < sizeof(keys) / sizeof(keys[0]); i++)
		{
			ret = send_key(handle, (uint32_t)(keys[i]));
			PAUSE(100);
		}
	}
	else if (handle->model == CALC_TI86)
	{
		static const uint16_t keys[] = {
			0x76, 0x08, 0x08,       /* Quit, Clear, Clear, */
			0x28, 0x3A, 0x34, 0x11, /* A, S, M, (, */
			0x39, 0x36, 0x34, 0x2B, /* R, O, M, D, */
			0x56, 0x4E, 0x51, 0x12, /* u, m, p, ), */
			0x06                    /* Enter */
		};
		uint16_t dummy;

		// Launch program by remote control
		for (i = 0; !ret && i < (sizeof(keys) / sizeof(keys[0])) - 1; i++)
		{
			ret = send_key(handle, (uint32_t)(keys[i]));
		}

		if (!ret)
		{
			ret = SEND_KEY(handle, keys[i]);
			if (!ret)
			{
				ret = RECV_ACK(handle, &dummy);
			}
			PAUSE(200);
		}
	}

	if (!ret)
	{
		// Get dump
		ret = rd_dump(handle, filename);

		// TI-86: normally there would be another ACK after the program exits, but the ROM dumper disables that behaviour.
	}

	return ret;
}
Ejemplo n.º 2
0
static int		dump_rom_2	(CalcHandle* handle, CalcDumpSize size, const char *filename)
{
	static const uint16_t keys_83p[] = {
		0x40, 0x09, 0x09, 0xFC9C, /* Quit, Clear, Clear, Asm( */
		0xDA, 0xAB, 0xA8, 0xA6,   /* prgm, R, O, M */
		0x9D, 0xAE, 0xA6, 0xA9,   /* D, U, M, P */
		0x86, 0x05 };             /* ), Enter */

	static const uint16_t keys_73[] = {
		0x40, 0x09, 0x09, 0xDA,   /* Quit, Clear, Clear, prgm */
		0xAB, 0xA8, 0xA6, 0x9D,   /* R, O, M, D, */
		0xAE, 0xA6, 0xA9, 0x05 }; /* U, M, P, Enter */

	int ret = 0;
	const uint16_t *keys;
	unsigned int i, nkeys;

	if (handle->model == CALC_TI73)
	{
		keys = keys_73;
		nkeys = sizeof(keys_73) / sizeof(keys_73[0]);
	}
	else
	{
		keys = keys_83p;
		nkeys = sizeof(keys_83p) / sizeof(keys_83p[0]);
	}

	// Launch program by remote control
	PAUSE(200);
	for (i = 0; !ret && i < nkeys - 1; i++)
	{
		ret = send_key(handle, (uint32_t)(keys[i]));
		PAUSE(100);
	}

	if (!ret)
	{
		// This fixes a 100% reproducible timeout: send_key normally requests an ACK,
		// but when the program is running, no ACK is sent. Therefore, hit the Enter key
		// without requesting an ACK.
		ret = SEND_KEY(handle, keys[i]);
		if (!ret)
		{
			ret = RECV_ACK(handle, NULL); // when the key is received
			if (!ret)
			{
				PAUSE(1000);

				// Get dump
				// (Normally there would be another ACK after the program exits,
				// but the ROM dumper disables that behavior)
				ret = rd_dump(handle, filename);
			}
		}
	}

	return ret;
}
Ejemplo n.º 3
0
static void auto_repeat_func(unsigned long scancode)
{
    if (g_timer_id==TIMER_KEY_PUSH) {
        debug("send key push key\n");
        g_enable_key_push_no_need_keyup=1;
//printk("====210\n");
        SEND_KEY((unsigned char) scancode);
//printk("====212\n");
        if (g_key_push_period[g_auto_repeat_index]!=0) {
            mod_timer(&auto_repeat_timer, jiffies + g_key_push_period[g_auto_repeat_index]);
        }
    } else if (g_timer_id==TIMER_AUTO_REPEAT) {
        debug("send TIMER_AUTO_REPEAT key\n");
        SEND_KEY((unsigned char) scancode);
        mod_timer(&auto_repeat_timer, jiffies + auto_repeat_period[g_auto_repeat_index]);
        // jiffies is around 10ms on x86
    }
}
Ejemplo n.º 4
0
/*
 * KEYPAD interrupt handler
 */
static inline int check_combine_key(int key_down) {
    debug("check_combine_key,key_down=%x\n",key_down);
    int i;
    for(i=0; i<g_combine_count; i++) {
        debug("g_combine_pin,g_combine_pin[i]=%x\n",g_combine_pin[i]);
        if (g_combine_pin[i]==key_down) {
            //send virtual combine key
            SEND_KEY(g_combine_keycode[i]);
            return 1;
        }
    }
    return 0;
}
Ejemplo n.º 5
0
static int		send_key	(CalcHandle* handle, uint32_t key)
{
	int ret;
	uint16_t status;

	ret = SEND_KEY(handle, (uint16_t)key);
	if (!ret)
	{
		ret = RECV_ACK(handle, &status);
		if (handle->model != CALC_TI83 && !ret)
		{
			ret = RECV_ACK(handle, &status);
		}
	}

	return ret;
}
Ejemplo n.º 6
0
static int		send_key	(CalcHandle* handle, uint32_t key)
{
	int ret;
	uint16_t status;

	ret = SEND_KEY(handle, (uint16_t)key);
	if (!ret)
	{
		ret = RECV_ACK(handle, &status);	// when the key is received
		if (!ret)
		{
			ret = RECV_ACK(handle, NULL);	// after it completes the resulting action
		}
	}

	return ret;
}
Ejemplo n.º 7
0
static void keypad61_handler(int irq, void *dev_id, struct pt_regs *regs)
{
    int input, in, sel;
    int key_down_mask;
    int i;

    in = input = readw(GPIO_KEY_STATUS);
    debug("Input:0x%04x\n",in);

    key_down_mask = readw(GPIO_KEY_POL);

    if (input_active_low) {
        key_down_mask = ~key_down_mask;
        debug ("320==Keypad Polarity is  %s\n", (input_active_low)? "Active_Low": "Active_High");
    }
    debug("KMask:0x%04x\n",key_down_mask);

    for (sel = 1, i=0; in != 0; i++, in >>= 1, sel <<= 1) {
        if ((in & 1) && (input_pins & sel)) {
            del_timer(&auto_repeat_timer);
            if (key_down_mask & sel) {
                debug("\nGPIO%d up\n", i);
                g_record_key_down&= ~( (unsigned int)(1<<i));
                /* no need to send handle_scancode(x,0) */
                /* replace by send handle_scancode(x,1) */
                /* because we want to send a virtual key when key up */

                /* handle_scancode(keypad_table[i], 0); */
                /* tasklet_schedule(&keyboard_tasklet); */
                if (g_key_up_code[i]!=0 && g_enable_key_push_no_need_keyup==0) {
                    //check up duration
                    if (g_key_up_duration[i]< jiffies-g_key_down_time[i]) {
                        SEND_KEY(g_key_up_code[i]);
                    }
                }
                g_enable_key_push_no_need_keyup=0;
                key_down_mask &= ~sel;
            } else {
                debug("\nGPIO%d down\n", i);
                key_down_mask |= sel;
                g_key_down_time[i]=jiffies;

                g_record_key_down|= 1<<i;
                //check combine key
                int has_combine=check_combine_key(g_record_key_down);
                if (has_combine==1) {
                    debug("\n combine key\n");
                    continue;
                }

                if (keypad_table[i]!=0) {
                    debug("==send normal single key\n");
                    SEND_KEY(keypad_table[i]);
                }

                /* check key push */
                if (g_key_push_code[i]!=0) {
                    debug("\n key_push timer\n");
                    /* check up duration */
                    auto_repeat_timer.data = g_key_push_code[i];
                    g_timer_id=TIMER_KEY_PUSH;
//printk("====358\n");
                    g_auto_repeat_index=i;
//printk("====360\n");
                    mod_timer(&auto_repeat_timer, jiffies + g_key_push_duration[i]);
//printk("====362\n");
                    continue;
                } else if (input & auto_pins) {	//check auto repeat
                    debug("\n auto repeat timer\n");
                    auto_repeat_timer.data = keypad_table[i];
                    g_auto_repeat_index=i;
                    g_timer_id=TIMER_AUTO_REPEAT;
                    mod_timer(&auto_repeat_timer, jiffies + auto_repeat_duration[g_auto_repeat_index]);
                }
            }
        }
    } /* --for loop--- */

    if (input_active_low)
        key_down_mask = ~key_down_mask;

    writew(key_down_mask, GPIO_KEY_POL);
//printk("379---GPIO_KEY_POL = %x \n", readw(GPIO_KEY_POL));
    writew((input & input_pins), GPIO_KEY_STATUS);//Write same value to clear Interrupt
//printk("381---GPIO_KEY_STATUS = %x \n", readw(GPIO_KEY_STATUS));
}