Example #1
0
/*
 * lkkbd_reinit() sets leds and beeps to a state the computer remembers they
 * were in.
 */
static void
lkkbd_reinit (struct work_struct *work)
{
	struct lkkbd *lk = container_of(work, struct lkkbd, tq);
	int division;
	unsigned char leds_on = 0;
	unsigned char leds_off = 0;

	/* Ask for ID */
	lk->serio->write (lk->serio, LK_CMD_REQUEST_ID);

	/* Reset parameters */
	lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);

	/* Set LEDs */
	CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
	CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
	CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
	CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
	if (leds_on != 0) {
		lk->serio->write (lk->serio, LK_CMD_LED_ON);
		lk->serio->write (lk->serio, leds_on);
	}
	if (leds_off != 0) {
		lk->serio->write (lk->serio, LK_CMD_LED_OFF);
		lk->serio->write (lk->serio, leds_off);
	}

	/*
	 * Try to activate extended LK401 mode. This command will
	 * only work with a LK401 keyboard and grants access to
	 * LAlt, RAlt, RCompose and RShift.
	 */
	lk->serio->write (lk->serio, LK_CMD_ENABLE_LK401);

	/* Set all keys to UPDOWN mode */
	for (division = 1; division <= 14; division++)
		lk->serio->write (lk->serio, LK_CMD_SET_MODE (LK_MODE_UPDOWN,
					division));

	/* Enable bell and set volume */
	lk->serio->write (lk->serio, LK_CMD_ENABLE_BELL);
	lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume));

	/* Enable/disable keyclick (and possibly set volume) */
	if (test_bit (SND_CLICK, lk->dev->snd)) {
		lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK);
		lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume));
		lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK);
		lk->serio->write (lk->serio, volume_to_hw (lk->ctrlclick_volume));
	} else {
		lk->serio->write (lk->serio, LK_CMD_DISABLE_KEYCLICK);
		lk->serio->write (lk->serio, LK_CMD_DISABLE_CTRCLICK);
	}

	/* Sound the bell if needed */
	if (test_bit (SND_BELL, lk->dev->snd))
		lk->serio->write (lk->serio, LK_CMD_SOUND_BELL);
}
Example #2
0
/*
 * lkkbd_reinit() sets leds and beeps to a state the computer remembers they
 * were in.
 */
static void lkkbd_reinit(struct work_struct *work)
{
	struct lkkbd *lk = container_of(work, struct lkkbd, tq);
	int division;

	/* Ask for ID */
	serio_write(lk->serio, LK_CMD_REQUEST_ID);

	/* Reset parameters */
	serio_write(lk->serio, LK_CMD_SET_DEFAULTS);

	/* Set LEDs */
	lkkbd_toggle_leds(lk);

	/*
	 * Try to activate extended LK401 mode. This command will
	 * only work with a LK401 keyboard and grants access to
	 * LAlt, RAlt, RCompose and RShift.
	 */
	serio_write(lk->serio, LK_CMD_ENABLE_LK401);

	/* Set all keys to UPDOWN mode */
	for (division = 1; division <= 14; division++)
		serio_write(lk->serio,
			    LK_CMD_SET_MODE(LK_MODE_UPDOWN, division));

	/* Enable bell and set volume */
	serio_write(lk->serio, LK_CMD_ENABLE_BELL);
	serio_write(lk->serio, volume_to_hw(lk->bell_volume));

	/* Enable/disable keyclick (and possibly set volume) */
	lkkbd_toggle_keyclick(lk, test_bit(SND_CLICK, lk->dev->snd));

	/* Sound the bell if needed */
	if (test_bit(SND_BELL, lk->dev->snd))
		serio_write(lk->serio, LK_CMD_SOUND_BELL);
}