本文整理汇总了C++中pwm_enable函数的典型用法代码示例。如果您正苦于以下问题:C++ pwm_enable函数的具体用法?C++ pwm_enable怎么用?C++ pwm_enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwm_enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pm8xxx_led_current_set
static void pm8xxx_led_current_set(struct led_classdev *led_cdev, enum led_brightness brightness)
{
struct pm8xxx_led_data *led = container_of(led_cdev, struct pm8xxx_led_data, cdev);
int rc, offset;
u8 level;
int *pduties;
LED_INFO("%s, bank:%d, brightness:%d\n", __func__, led->bank, brightness);
cancel_delayed_work_sync(&led->fade_delayed_work);
virtual_key_state = brightness;
if (flag_hold_virtual_key == 1) {
LED_INFO("%s, key control \n", __func__);
return;
}
if(brightness) {
level = (led->out_current << PM8XXX_DRV_LED_CTRL_SHIFT) & PM8XXX_DRV_LED_CTRL_MASK;
offset = PM8XXX_LED_OFFSET(led->id);
led->reg &= ~PM8XXX_DRV_LED_CTRL_MASK;
led->reg |= level;
rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), led->reg);
if (rc)
LED_ERR("%s can't set (%d) led value rc=%d\n", __func__, led->id, rc);
if (led->function_flags & LED_BRETH_FUNCTION) {
pduties = led->duties;
pm8xxx_pwm_lut_config(led->pwm_led,
led->period_us,
pduties,
led->duty_time_ms,
led->start_index,
led->duites_size,
0, 0,
led->lut_flag);
pm8xxx_pwm_lut_enable(led->pwm_led, 0);
pm8xxx_pwm_lut_enable(led->pwm_led, 1);
} else {
pwm_config(led->pwm_led, 64000, 64000);
pwm_enable(led->pwm_led);
}
} else {
if (led->function_flags & LED_BRETH_FUNCTION) {
pduties = led->duties + led->duites_size;
pm8xxx_pwm_lut_config(led->pwm_led,
led->period_us,
pduties,
led->duty_time_ms,
led->start_index,
led->duites_size,
0, 0,
led->lut_flag);
pm8xxx_pwm_lut_enable(led->pwm_led, 0);
pm8xxx_pwm_lut_enable(led->pwm_led, 1);
queue_delayed_work(g_led_work_queue,
&led->fade_delayed_work,
msecs_to_jiffies(led->duty_time_ms*led->duites_size));
} else {
pwm_disable(led->pwm_led);
level = (0 << PM8XXX_DRV_LED_CTRL_SHIFT) & PM8XXX_DRV_LED_CTRL_MASK;
offset = PM8XXX_LED_OFFSET(led->id);
led->reg &= ~PM8XXX_DRV_LED_CTRL_MASK;
led->reg |= level;
rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), led->reg);
if (rc)
LED_ERR("%s can't set (%d) led value rc=%d\n", __func__, led->id, rc);
}
}
}
示例2: pm8058_led_blink_store
static ssize_t pm8058_led_blink_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct led_classdev *led_cdev;
struct pm8058_led_data *ldata;
int id, mode;
int val;
/*struct timespec ts1, ts2;*/
val = -1;
sscanf(buf, "%u", &val);
if (val < 0 || val > 255)
return -EINVAL;
led_cdev = (struct led_classdev *) dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct pm8058_led_data, ldev);
id = bank_to_id(ldata->bank);
mode = (id == PM_PWM_LED_KPD) ? PM_PWM_CONF_PWM1 :
PM_PWM_CONF_PWM1 + (ldata->bank - 4);
if (ldata->flags & PM8058_LED_BLINK_EN)
pm8058_pwm_config_led(ldata->pwm_led, id, mode,
ldata->out_current);
printk(KERN_INFO "%s: bank %d blink %d +\n", __func__, ldata->bank, val);
switch (val) {
case -1: /* stop flashing */
pwm_disable(ldata->pwm_led);
if (ldata->flags & PM8058_LED_BLINK_EN)
pm8058_pwm_config_led(ldata->pwm_led, id, mode, 0);
break;
case 0:
pwm_disable(ldata->pwm_led);
if (led_cdev->brightness) {
pwm_config(ldata->pwm_led, 64000, 64000);
pwm_enable(ldata->pwm_led);
} else {
if (ldata->flags & PM8058_LED_BLINK_EN)
pm8058_pwm_config_led(ldata->pwm_led, id,
mode, 0);
}
break;
case 1:
pwm_disable(ldata->pwm_led);
pwm_config(ldata->pwm_led, 64000, 2000000);
pwm_enable(ldata->pwm_led);
break;
case 2:
cancel_delayed_work_sync(&ldata->led_delayed_work);
pwm_disable(ldata->pwm_led);
ldata->duty_time_ms = 64;
ldata->period_us = 2000000;
queue_delayed_work(g_led_work_queue, &ldata->led_delayed_work,
msecs_to_jiffies(310));
break;
case 3:
cancel_delayed_work_sync(&ldata->led_delayed_work);
pwm_disable(ldata->pwm_led);
ldata->duty_time_ms = 64;
ldata->period_us = 2000000;
queue_delayed_work(g_led_work_queue, &ldata->led_delayed_work,
msecs_to_jiffies(1000));
break;
case 4:
pwm_disable(ldata->pwm_led);
pwm_config(ldata->pwm_led, 1000000, 2000000);
#if 0
pwm_conf.pwm_size = 9;
pwm_conf.clk = PM_PWM_CLK_1KHZ;
pwm_conf.pre_div = PM_PWM_PREDIVIDE_2;
pwm_conf.pre_div_exp = 1;
pwm_conf.pwm_value = 512/2;
pwm_conf.bypass_lut = 1;
pwm_configure(ldata->pwm_led, &pwm_conf);
#endif
pwm_enable(ldata->pwm_led);
break;
default:
printk(KERN_INFO "%s: bank %d blink %d -\n", __func__, ldata->bank, val);
return -EINVAL;
}
printk(KERN_INFO "%s: bank %d blink %d -\n", __func__, ldata->bank, val);
return count;
}
示例3: handle_twi_command
static void handle_twi_command(void)
{
uint8_t command;
// Get the command from the receive buffer.
command = twi_receive_byte();
switch (command)
{
case TWI_CMD_RESET:
// Reset the servo.
watchdog_hard_reset();
break;
case TWI_CMD_PWM_ENABLE:
// Enable PWM to the servo motor.
pwm_enable();
break;
case TWI_CMD_PWM_DISABLE:
// Disable PWM to the servo motor.
pwm_disable();
break;
case TWI_CMD_WRITE_ENABLE:
// Enable write to read/write protected registers.
registers_write_enable();
break;
case TWI_CMD_WRITE_DISABLE:
// Disable write to read/write protected registers.
registers_write_disable();
break;
case TWI_CMD_REGISTERS_SAVE:
// Save register values into EEPROM.
eeprom_save_registers();
break;
case TWI_CMD_REGISTERS_RESTORE:
// Restore register values into EEPROM.
eeprom_restore_registers();
break;
case TWI_CMD_REGISTERS_DEFAULT:
// Restore register values to factory defaults.
registers_defaults();
break;
case TWI_CMD_EEPROM_ERASE:
// Erase the EEPROM.
eeprom_erase();
break;
case TWI_CMD_VOLTAGE_READ:
// Request a voltage reading.
adc_read_voltage();
break;
#if CURVE_MOTION_ENABLED
case TWI_CMD_CURVE_MOTION_ENABLE:
// Enable curve motion handling.
motion_enable();
break;
case TWI_CMD_CURVE_MOTION_DISABLE:
// Disable curve motion handling.
motion_disable();
break;
case TWI_CMD_CURVE_MOTION_RESET:
// Reset the motion to the current position.
#if ENCODER_ENABLED
motion_reset(enc_get_position_value());
#else
motion_reset(adc_get_position_value());
//.........这里部分代码省略.........
示例4: max77833_vibtonz_en
void max77833_vibtonz_en(bool en)
{
int error = 0, temperature_level;
if (g_hap_data == NULL) {
pr_err("[VIB] the motor is not ready!!!");
return ;
}
if (en) {
if (g_hap_data->running)
return;
max77833_haptic_i2c(g_hap_data, true);
temperature_level = temperature_check();
if (temperature_level != prev_temperature_level) {
switch(temperature_level)
{
case 0:
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MIN_FREQ_LOW, g_hap_data->pdata->auto_res_min_low_low_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MIN_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MAX_FREQ_LOW, g_hap_data->pdata->auto_res_max_low_low_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MAX_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_INIT_GUESS_LOW, g_hap_data->pdata->auto_res_init_low_low_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_INIT_GUESS_LOW, error);
}
break;
case 1:
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MIN_FREQ_LOW, g_hap_data->pdata->auto_res_min_low);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MIN_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MAX_FREQ_LOW, g_hap_data->pdata->auto_res_max_low);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MAX_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_INIT_GUESS_LOW, g_hap_data->pdata->auto_res_init_low);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_INIT_GUESS_LOW, error);
}
break;
case 2:
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MIN_FREQ_LOW, g_hap_data->pdata->auto_res_min_low_high_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MIN_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_MAX_FREQ_LOW, g_hap_data->pdata->auto_res_max_low_high_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_MAX_FREQ_LOW, error);
}
error = max77833_write_reg(g_hap_data->i2c,
MAX77833_AUTORES_INIT_GUESS_LOW, g_hap_data->pdata->auto_res_init_low_high_temp);
if (error < 0) {
pr_err("[VIB] %s Failed to write REG(0x%02x) [%d]\n",
__func__, MAX77833_AUTORES_INIT_GUESS_LOW, error);
}
break;
default:
pr_err("[VIB] %s Failed to read temperature [%d]\n",
__func__, temperature_level);
break;
}
}
prev_temperature_level = temperature_level;
pwm_config(g_hap_data->pwm, prev_duty, g_hap_data->pdata->period);
pwm_enable(g_hap_data->pwm);
g_hap_data->running = true;
} else {
if (!g_hap_data->running)
return;
pwm_disable(g_hap_data->pwm);
max77833_haptic_i2c(g_hap_data, false);
g_hap_data->running = false;
}
}
示例5: pm8xxx_led_current_set_flagged
static void pm8xxx_led_current_set_flagged(struct led_classdev *led_cdev, enum led_brightness brightness, int blink)
{
struct pm8xxx_led_data *led = container_of(led_cdev, struct pm8xxx_led_data, cdev);
int rc, offset;
u8 level;
int *pduties;
LED_INFO("%s, bank:%d, brightness:%d\n", __func__, led->bank, brightness);
cancel_delayed_work_sync(&led->fade_delayed_work);
virtual_key_state = brightness;
if (flag_hold_virtual_key == 1) {
LED_INFO("%s, key control \n", __func__);
return;
}
if(brightness) {
level = (led->out_current << PM8XXX_DRV_LED_CTRL_SHIFT) & PM8XXX_DRV_LED_CTRL_MASK;
offset = PM8XXX_LED_OFFSET(led->id);
led->reg &= ~PM8XXX_DRV_LED_CTRL_MASK;
led->reg |= level;
rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), led->reg);
if (rc)
LED_ERR("%s can't set (%d) led value rc=%d\n", __func__, led->id, rc);
if (led->function_flags & LED_BRETH_FUNCTION) {
if (blink == 0) {
buttons_led_is_on = 1;
// no blink needed
pduties = &dutys_array[0];
pm8xxx_pwm_lut_config(led->pwm_led,
led->period_us,
pduties,
led->duty_time_ms,
led->start_index,
led->duites_size,
0, 0,
led->lut_flag);
} else {
pduties = &dutys_array[0];
// LUT_LOOP for blinking
pm8xxx_pwm_lut_config(led->pwm_led,
led->period_us,
pduties,
led->duty_time_ms, // slower, 2x
led->start_index,
led->duites_size * 8, // 16 duty entries -> original size * 2, + 6 * 8 zeroes for pause
0, 0,
PM_PWM_LUT_LOOP | PM_PWM_LUT_PAUSE_HI_EN);
}
pm8xxx_pwm_lut_enable(led->pwm_led, 0);
pm8xxx_pwm_lut_enable(led->pwm_led, 1);
} else {
pwm_config(led->pwm_led, 6400 * led->pwm_coefficient / 100, 6400);
pwm_enable(led->pwm_led);
}
} else {
if (led->function_flags & LED_BRETH_FUNCTION) {
buttons_led_is_on = 0;
wake_lock_timeout(&pmic_led_wake_lock, HZ*2);
pduties = &dutys_array[8];
pm8xxx_pwm_lut_config(led->pwm_led,
led->period_us,
pduties,
led->duty_time_ms,
led->start_index,
led->duites_size,
0, 0,
led->lut_flag);
pm8xxx_pwm_lut_enable(led->pwm_led, 0);
pm8xxx_pwm_lut_enable(led->pwm_led, 1);
queue_delayed_work(g_led_work_queue,
&led->fade_delayed_work,
msecs_to_jiffies(led->duty_time_ms*led->duites_size));
} else {
pwm_disable(led->pwm_led);
level = (0 << PM8XXX_DRV_LED_CTRL_SHIFT) & PM8XXX_DRV_LED_CTRL_MASK;
offset = PM8XXX_LED_OFFSET(led->id);
led->reg &= ~PM8XXX_DRV_LED_CTRL_MASK;
led->reg |= level;
rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), led->reg);
if (rc)
LED_ERR("%s can't set (%d) led value rc=%d\n", __func__, led->id, rc);
}
}
}
示例6: pm8xxx_led_blink_store
static ssize_t pm8xxx_led_blink_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct led_classdev *led_cdev;
struct pm8xxx_led_data *ldata;
int val;
int level, offset;
int led_is_green;
val = -1;
sscanf(buf, "%u", &val);
if (val < 0 || val > 255)
return -EINVAL;
current_blink= val;
led_cdev = (struct led_classdev *) dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct pm8xxx_led_data, cdev);
LED_INFO("%s: bank %d blink %d sync %d\n", __func__, ldata->bank, val, ldata->led_sync);
printk("%s: [BB] bank %d blink %d sync %d\n", __func__, ldata->bank, val, ldata->led_sync);
if (!strcmp(ldata->cdev.name, "green")) {
led_is_green = 1;
}
if (!strcmp(ldata->cdev.name, "amber")) {
led_is_green = 0;
}
switch (val) {
case BLINK_STOP:
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(0);
pwm_disable(ldata->pwm_led);
if(ldata->led_sync) {
if (!strcmp(ldata->cdev.name, "green")) {
if (green_back_led_data->gpio_status_switch != NULL)
green_back_led_data->gpio_status_switch(0);
pwm_disable(green_back_led_data->pwm_led);
}
if (!strcmp(ldata->cdev.name, "amber")) {
if (amber_back_led_data->gpio_status_switch != NULL)
amber_back_led_data->gpio_status_switch(0);
pwm_disable(amber_back_led_data->pwm_led);
}
}
if (blink_buttons > 0) {
if (led_is_green == 1) {
green_blink_value = 0;
} else {
amber_blink_value = 0;
}
pm8xxx_buttons_blink(0);
}
break;
case BLINK_UNCHANGE:
pwm_disable(ldata->pwm_led);
if (led_cdev->brightness) {
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(1);
pwm_config(ldata->pwm_led, 6400 * ldata->pwm_coefficient / 100, 6400);
pwm_enable(ldata->pwm_led);
if(ldata->led_sync) {
if (!strcmp(ldata->cdev.name, "green")) {
if (green_back_led_data->gpio_status_switch != NULL)
green_back_led_data->gpio_status_switch(1);
pwm_config(green_back_led_data->pwm_led, 64000, 64000);
pwm_enable(green_back_led_data->pwm_led);
}
if (!strcmp(ldata->cdev.name, "amber")) {
if (amber_back_led_data->gpio_status_switch != NULL)
amber_back_led_data->gpio_status_switch(1);
pwm_config(amber_back_led_data->pwm_led, 64000, 64000);
pwm_enable(amber_back_led_data->pwm_led);
}
}
if (blink_buttons > 0 && val > 0) {
if (led_is_green == 1) {
green_blink_value = 1;
} else {
amber_blink_value = 1;
}
pm8xxx_buttons_blink(1);
}
} else {
pwm_disable(ldata->pwm_led);
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(0);
if(ldata->led_sync) {
if (!strcmp(ldata->cdev.name, "green")){
if (green_back_led_data->gpio_status_switch != NULL)
green_back_led_data->gpio_status_switch(0);
pwm_disable(green_back_led_data->pwm_led);
level = ( 0 << PM8XXX_DRV_LED_CTRL_SHIFT) & PM8XXX_DRV_LED_CTRL_MASK;
offset = PM8XXX_LED_OFFSET(green_back_led_data->id);
green_back_led_data->reg &= ~PM8XXX_DRV_LED_CTRL_MASK;
green_back_led_data->reg |= level;
pm8xxx_writeb(green_back_led_data->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), green_back_led_data->reg);
}
//.........这里部分代码省略.........
示例7: pwm_test_probe
static int pwm_test_probe(struct platform_device *pdev)
{
struct pwm_test *pwm_test;
struct pinctrl *pinctrl;
struct device_node *node = (&pdev->dev)->of_node;
int rc;
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
if (IS_ERR(pinctrl))
dev_warn(&pdev->dev, "unable to select pin group. PWM not muxed right\n");
pwm_test = devm_kzalloc(&pdev->dev, sizeof(*pwm_test), GFP_KERNEL);
if (!pwm_test) {
dev_err(&pdev->dev, "memory error\n");
return -ENOMEM;
}
if (pwm_test_class_init(&pdev->dev)) {
dev_err(&pdev->dev, "sysfs creation failed\n");
return -EINVAL;
}
pwm_test->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pwm_test->pwm)) {
dev_err(&pdev->dev, "unable to request PWM\n");
return -EINVAL;
}
pwm_test->requested = 1;
pr_debug("pwm_test got PWM\n");
/* Get the properties of the pwm. This is set in the device driver (tiehrpwm) */
pwm_test->period = pwm_get_period(pwm_test->pwm);
/* Determine running or not from the device tree */
rc = of_property_read_u32(node, "enabled", (u32*) &(pwm_test->run));
if (rc < 0)
return rc;
if(pwm_test->run){
rc = pwm_enable(pwm_test->pwm);
if (rc < 0)
return rc;
}
/* Determine the duty from the device tree */
rc = of_property_read_u32(node, "duty", (u32*) &(pwm_test->duty_s));
if (rc < 0)
return rc;
rc = pwm_config(pwm_test->pwm, pwm_test->duty_s, pwm_test->period);
if (rc) {
pr_err("Unable to set pwm duty %d\n", rc);
return rc;
}
platform_set_drvdata(pdev, pwm_test);
return 0;
}
示例8: backlight_pwm_gpio_config
//.........这里部分代码省略.........
|| machine_is_msm7x30_u8800_51()
|| machine_is_msm8255_u8800_pro()
|| machine_is_msm8255_u8860()
|| machine_is_msm8255_c8860()
|| machine_is_msm8255_u8860lp()
|| machine_is_msm8255_u8860_r()
|| machine_is_msm8255_u8860_92()
|| machine_is_msm8255_u8680()
|| machine_is_msm8255_u8667()
|| machine_is_msm8255_u8860_51()
|| machine_is_msm8255_u8730())
{
bl_pwm = pwm_request(PM_GPIO25_PWM_ID, "backlight");
}
else if(machine_is_msm7x30_u8820())
{
bl_pwm = pwm_request(PM_GPIO26_PWM_ID, "backlight");
}
else
{
bl_pwm = NULL;
}
if (NULL == bl_pwm || IS_ERR(bl_pwm))
{
pr_err("%s: pwm_request() failed\n", __func__);
bl_pwm = NULL;
}
first_set_bl = FALSE;
}
if (bl_pwm)
{
if(level)
{
level = ((level * PWM_LEVEL_ADJUST) / PWM_LEVEL + ADD_VALUE);
if (level < BL_MIN_LEVEL)
{
level = BL_MIN_LEVEL;
}
}
if (last_level == level)
{
return ;
}
last_level = level;
pwm_config(bl_pwm, PWM_DUTY_LEVEL*level/NSEC_PER_USEC, PWM_PERIOD/NSEC_PER_USEC);
pwm_enable(bl_pwm);
}
#endif
}
void cabc_backlight_set(struct msm_fb_data_type * mfd)
{
struct msm_fb_panel_data *pdata = NULL;
uint32 bl_level = mfd->bl_level;
/* keep duty 10% < level < 100% */
if (bl_level)
{
/****delete one line codes for backlight*****/
if (bl_level < BL_MIN_LEVEL)
{
bl_level = BL_MIN_LEVEL;
}
}
/* backlight ctrl by LCD-self, like as CABC */
pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
if ((pdata) && (pdata->set_cabc_brightness))
{
pdata->set_cabc_brightness(mfd,bl_level);
}
}
void pwm_set_backlight(struct msm_fb_data_type *mfd)
{
/*< Delete unused variable */
/*When all the device are resume that can turn the light*/
if(atomic_read(&suspend_flag))
{
mfd_local = mfd;
backlight_set = TRUE;
return;
}
/*< Delete some lines,control backlight in hardware lights.c by property */
if (get_hw_lcd_ctrl_bl_type() == CTRL_BL_BY_MSM)
{
msm_backlight_set(mfd->bl_level);
}
else
{
cabc_backlight_set(mfd);
}
return;
}
#ifdef CONFIG_HAS_EARLYSUSPEND
static void pwm_backlight_suspend( struct early_suspend *h)
{
atomic_set(&suspend_flag,1);
}
示例9: buzzer_off
/**
****************************************************************************************
* @brief Switch buzzer off
****************************************************************************************
*/
void buzzer_off(void)
{
pwm_enable(PWM_CH1, MASK_DISABLE);
}
示例10: backlight_pwm_gpio_config
//.........这里部分代码省略.........
}
else if(machine_is_msm7x30_u8820())
{
bl_pwm = pwm_request(PM_GPIO26_PWM_ID, "backlight");
}
else
{
bl_pwm = NULL;
}
if (NULL == bl_pwm || IS_ERR(bl_pwm))
{
pr_err("%s: pwm_request() failed\n", __func__);
bl_pwm = NULL;
}
first_set_bl = FALSE;
}
if (bl_pwm)
{
if(level)
{
level = ((level * PWM_LEVEL_ADJUST) / PWM_LEVEL + ADD_VALUE);
if (level < BL_MIN_LEVEL)
{
level = BL_MIN_LEVEL;
}
}
if (last_level == level)
{
return ;
}
last_level = level;
pwm_config(bl_pwm, PWM_DUTY_LEVEL*level/NSEC_PER_USEC, PWM_PERIOD/NSEC_PER_USEC);
pwm_enable(bl_pwm);
}
#endif
}
/* DTS2012012101194 lijianzhao 20120121 end >*/
void cabc_backlight_set(struct msm_fb_data_type * mfd)
{
struct msm_fb_panel_data *pdata = NULL;
uint32 bl_level = mfd->bl_level;
/*< DTS2012042605475 zhongjinrong 20120426 begin */
/*< DTS2012032101654 liweiwu 20120321 begin */
/* keep duty 10% < level < 100% */
/* DTS2012032101654 liweiwu 20120321 end >*/
if (bl_level)
{
/*< DTS2012032101654 liweiwu 20120321 begin */
/****delete one line codes for backlight*****/
/* DTS2012032101654 liweiwu 20120321 end >*/
/* DTS2012042605475 zhongjinrong 20120426 end >*/
if (bl_level < BL_MIN_LEVEL)
{
bl_level = BL_MIN_LEVEL;
}
}
/* backlight ctrl by LCD-self, like as CABC */
/*< DTS2012012101194 lijianzhao 20120121 begin */
pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
if ((pdata) && (pdata->set_cabc_brightness))
{
pdata->set_cabc_brightness(mfd,bl_level);
}
/* DTS2012012101194 lijianzhao 20120121 end >*/
示例11: buzzer_on
/**
****************************************************************************************
* @brief Switch buzzer on
* @param[in] volume buzzer's volume
****************************************************************************************
*/
void buzzer_on(enum buzz_vol volume)
{
pwm_init(PWM_CH1);
pwm_config(PWM_CH1, PWM_PSCAL_DIV, PWM_COUNT_US(BUZZ_PWM_PERIOD, PWM_PSCAL_DIV), PWM_COUNT_US(volume, PWM_PSCAL_DIV));
pwm_enable(PWM_CH1, MASK_ENABLE);
}
示例12: pm8xxx_led_blink_store
static ssize_t pm8xxx_led_blink_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct led_classdev *led_cdev;
struct pm8xxx_led_data *ldata;
int val;
val = -1;
sscanf(buf, "%u", &val);
if (val < 0 || val > 255)
return -EINVAL;
led_cdev = (struct led_classdev *) dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct pm8xxx_led_data, cdev);
LED_INFO("%s: bank %d blink %d\n", __func__, ldata->bank, val);
switch (val) {
case BLINK_STOP:
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(0);
pwm_disable(ldata->pwm_led);
break;
case BLINK_UNCHANGE:
pwm_disable(ldata->pwm_led);
if (led_cdev->brightness) {
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(1);
pwm_config(ldata->pwm_led, 64000, 64000);
pwm_enable(ldata->pwm_led);
} else {
pwm_disable(ldata->pwm_led);
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(0);
}
break;
case BLINK_64MS_PER_2SEC:
if (ldata->gpio_status_switch != NULL)
ldata->gpio_status_switch(1);
pwm_disable(ldata->pwm_led);
pwm_config(ldata->pwm_led, 64000, 2000000);
pwm_enable(ldata->pwm_led);
break;
case BLINK_64MS_ON_310MS_PER_2SEC:
cancel_delayed_work_sync(&ldata->blink_delayed_work);
pwm_disable(ldata->pwm_led);
ldata->duty_time_ms = 64;
ldata->period_us = 2000000;
queue_delayed_work(g_led_work_queue, &ldata->blink_delayed_work,
msecs_to_jiffies(310));
break;
case BLINK_64MS_ON_2SEC_PER_2SEC:
cancel_delayed_work_sync(&ldata->blink_delayed_work);
pwm_disable(ldata->pwm_led);
ldata->duty_time_ms = 64;
ldata->period_us = 2000000;
queue_delayed_work(g_led_work_queue, &ldata->blink_delayed_work,
msecs_to_jiffies(1000));
break;
case BLINK_1SEC_PER_2SEC:
pwm_disable(ldata->pwm_led);
pwm_config(ldata->pwm_led, 1000000, 2000000);
pwm_enable(ldata->pwm_led);
break;
default:
LED_ERR("%s: bank %d did not support blink type %d\n", __func__, ldata->bank, val);
return -EINVAL;
}
return count;
}
示例13: mcu_main
void mcu_main()
{
// by default, the edison has ID 0
int edisonID = 0;
// if we pass in an argument, use it for the edisonID
// please pass in an integer
//if (argc == 2) {
//edisonID = atoi(argv[1]);
//}
int temp;
while (1)
{
//int host_receive(unsigned char *buf, int length)
temp = host_receive((unsigned char *)host_message, BUFFER_LENGTH);
if (temp > 0)
{
debug_print(DBG_INFO, "Received a Message!\n");
host_send((unsigned char*)"hello mcu\n", 10);
preamble_length = host_message[0];
}
// Preamble - Signals the Receiver Message Incoming
send_preamble_sequence(preamble_length);
// Sending Edison Board ID # - 2 bits, MSB then LSB
switch (edisonID) {
case 0:
send_low_bit(); // Send lsb bit 0 = LOW
send_low_bit(); // Send msb bit 1 = LOW
break;
case 1:
send_high_bit(); // Send lsb bit 0 = HIGH
send_low_bit(); // Send msb bit 1 = LOW
break;
case 2:
send_low_bit(); // Send lsb bit 0 = LOW
send_high_bit(); // Send msb bit 1 =
break;
case 3:
send_high_bit(); // Send lsb bit 0 = HIGH
send_high_bit(); // Send msb bit 1 = HIGH
break;
default:
send_low_bit(); // Send lsb bit 0 = LOW
send_low_bit(); // Send msb bit 1 = LOW
}
// Sending Edison IR Emitter ID # - 2 bits, MSB then LSB
// pwm1 = 00 = short-long/short-long = 5-20/5-20
// pwm2 = 01 = short-long/long-short = 5-20/20-5
// pwm3 = 10 = long-short/short-long = 20-5/5-20
// pwm4 = 11 = long-short/long-short = 20-5/20-5
// First Bit
pwm_configure(pwm1, MESSAGE_DUTY_LOW, MESSAGE_PERIOD); // 0
pwm_configure(pwm2, MESSAGE_DUTY_LOW, MESSAGE_PERIOD); // 0
pwm_configure(pwm3, MESSAGE_DUTY_HIGH, MESSAGE_PERIOD); // 1
pwm_configure(pwm4, MESSAGE_DUTY_HIGH, MESSAGE_PERIOD); // 1
pwm_enable(pwm1);
pwm_enable(pwm2);
pwm_enable(pwm3);
pwm_enable(pwm4);
mcu_delay(MESSAGE_SLEEP);
// Second Bit
pwm_configure(pwm1, MESSAGE_DUTY_LOW, MESSAGE_PERIOD); // 0
pwm_configure(pwm2, MESSAGE_DUTY_HIGH, MESSAGE_PERIOD); // 1
pwm_configure(pwm3, MESSAGE_DUTY_LOW, MESSAGE_PERIOD); // 0
pwm_configure(pwm4, MESSAGE_DUTY_HIGH, MESSAGE_PERIOD); // 1
pwm_enable(pwm1);
pwm_enable(pwm2);
pwm_enable(pwm3);
pwm_enable(pwm4);
mcu_delay(MESSAGE_SLEEP);
}
}
示例14: display_init
int display_init(void *lcdbase, int fb_bits_per_pixel,
struct display_timing *timing)
{
struct dc_ctlr *dc_ctlr;
const void *blob = gd->fdt_blob;
struct udevice *dp_dev;
const int href_to_sync = 1, vref_to_sync = 1;
int panel_bpp = 18; /* default 18 bits per pixel */
u32 plld_rate;
struct gpio_desc vdd_gpio, enable_gpio;
int pwm;
int node;
int ret;
ret = uclass_get_device(UCLASS_DISPLAY, 0, &dp_dev);
if (ret)
return ret;
node = fdtdec_next_compatible(blob, 0, COMPAT_NVIDIA_TEGRA124_DC);
if (node < 0)
return -ENOENT;
dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
if (fdtdec_decode_display_timing(blob, node, 0, timing))
return -EINVAL;
ret = display_update_config_from_edid(dp_dev, &panel_bpp, timing);
if (ret) {
debug("%s: Failed to decode EDID, using defaults\n", __func__);
dump_config(panel_bpp, timing);
}
if (!get_backlight_info(blob, &vdd_gpio, &enable_gpio, &pwm)) {
dm_gpio_set_value(&vdd_gpio, 1);
debug("%s: backlight vdd setting gpio %08x to %d\n",
__func__, gpio_get_number(&vdd_gpio), 1);
}
/*
* The plld is programmed with the assumption of the SHIFT_CLK_DIVIDER
* and PIXEL_CLK_DIVIDER are zero (divide by 1). See the
* update_display_mode() for detail.
*/
plld_rate = clock_set_display_rate(timing->pixelclock.typ * 2);
if (plld_rate == 0) {
printf("dc: clock init failed\n");
return -EIO;
} else if (plld_rate != timing->pixelclock.typ * 2) {
debug("dc: plld rounded to %u\n", plld_rate);
timing->pixelclock.typ = plld_rate / 2;
}
/* Init dc */
ret = tegra_dc_init(dc_ctlr);
if (ret) {
debug("dc: init failed\n");
return ret;
}
/* Configure dc mode */
ret = update_display_mode(dc_ctlr, timing, href_to_sync, vref_to_sync);
if (ret) {
debug("dc: failed to configure display mode\n");
return ret;
}
/* Enable dp */
ret = display_enable(dp_dev, panel_bpp, timing);
if (ret)
return ret;
ret = update_window(dc_ctlr, (ulong)lcdbase, fb_bits_per_pixel, timing);
if (ret)
return ret;
/* Set up Tegra PWM to drive the panel backlight */
pwm_enable(pwm, 0, 220, 0x2e);
udelay(10 * 1000);
if (dm_gpio_is_valid(&enable_gpio)) {
dm_gpio_set_value(&enable_gpio, 1);
debug("%s: backlight enable setting gpio %08x to %d\n",
__func__, gpio_get_number(&enable_gpio), 1);
}
return 0;
}
示例15: handle_stage
/**
* Handle the next stage of device init
*/
static int handle_stage(const void *blob)
{
debug("%s: stage %d\n", __func__, stage);
/* do the things for this stage */
switch (stage) {
case STAGE_START:
/* Initialize the Tegra display controller */
if (tegra_display_probe(gd->fdt_blob, (void *)gd->fb_base)) {
printf("%s: Failed to probe display driver\n",
__func__);
return -1;
}
/* get panel details */
if (fdt_decode_lcd(blob, &config)) {
printf("No valid LCD information in device tree\n");
return -1;
}
/*
* It is possible that the FDT has requested that the LCD be
* disabled. We currently don't support this. It would require
* changes to U-Boot LCD subsystem to have LCD support
* compiled in but not used. An easier option might be to
* still have a frame buffer, but leave the backlight off and
* remove all mention of lcd in the stdout environment
* variable.
*/
funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
break;
case STAGE_PANEL_VDD:
if (dm_gpio_is_valid(&config.panel_vdd))
dm_gpio_set_value(&config.panel_vdd, 1);
break;
case STAGE_LVDS:
if (dm_gpio_is_valid(&config.lvds_shutdown))
dm_gpio_set_value(&config.lvds_shutdown, 1);
break;
case STAGE_BACKLIGHT_VDD:
if (dm_gpio_is_valid(&config.backlight_vdd))
dm_gpio_set_value(&config.backlight_vdd, 1);
break;
case STAGE_PWM:
/* Enable PWM at 15/16 high, 32768 Hz with divider 1 */
pinmux_set_func(PMUX_PINGRP_GPU, PMUX_FUNC_PWM);
pinmux_tristate_disable(PMUX_PINGRP_GPU);
pwm_enable(config.pwm_channel, 32768, 0xdf, 1);
break;
case STAGE_BACKLIGHT_EN:
if (dm_gpio_is_valid(&config.backlight_en))
dm_gpio_set_value(&config.backlight_en, 1);
break;
case STAGE_DONE:
break;
}
/* set up timer for next stage */
timer_next = timer_get_us();
if (stage < FDT_LCD_TIMINGS)
timer_next += config.panel_timings[stage] * 1000;
/* move to next stage */
stage++;
return 0;
}