예제 #1
0
/**
 * Print status of a PWM channel.
 *
 * @param ch		Channel to print.
 */
static void print_channel(enum pwm_channel ch)
{
	if (pwm_get_enabled(ch))
		ccprintf("  %d: %d%%\n", ch, pwm_get_duty(ch));
	else
		ccprintf("  %d: disabled\n", ch);
}
예제 #2
0
파일: pwm.c 프로젝트: thehobn/ec
/**
 * Get PWM duty cycle.
 *
 * @param   ch  operation channel
 * @return  duty cycle percent
 */
int pwm_get_duty(enum pwm_channel ch)
{
	/* Return percent */
	if (0 == pwm_get_enabled(ch))
		return 0;
	else
		return (((NPCX_DCR(pwm_channels[ch].channel) + 1) * 100)
				/ (NPCX_CTR(pwm_channels[ch].channel) + 1));
}
예제 #3
0
/**
 * Get PWM duty cycle.
 *
 * @param   ch  operation channel
 * @return  duty cycle percent
 */
int pwm_get_duty(enum pwm_channel ch)
{
	int mdl = pwm_channels[ch].channel;
	/* Return percent */
	if ((!pwm_get_enabled(ch)) || (NPCX_DCR(mdl) > NPCX_CTR(mdl)))
		return 0;
	else
		return ((NPCX_DCR(mdl) + 1) * 100) / (NPCX_CTR(mdl) + 1);
}
예제 #4
0
파일: pwm_kblight.c 프로젝트: thehobn/ec
int pwm_command_get_keyboard_backlight(struct host_cmd_handler_args *args)
{
	struct ec_response_pwm_get_keyboard_backlight *r = args->response;

	r->percent = pwm_get_duty(PWM_CH_KBLIGHT);
	r->enabled = pwm_get_enabled(PWM_CH_KBLIGHT);
	args->response_size = sizeof(*r);

	return EC_RES_SUCCESS;
}
예제 #5
0
파일: pwm_kblight.c 프로젝트: thehobn/ec
static void pwm_kblight_preserve_state(void)
{
	struct pwm_kbd_state state;

	state.kblight_en = pwm_get_enabled(PWM_CH_KBLIGHT);
	state.kblight_percent = pwm_get_duty(PWM_CH_KBLIGHT);

	system_add_jump_tag(PWMKBD_SYSJUMP_TAG, PWM_HOOK_VERSION,
			    sizeof(state), &state);
}