本文整理汇总了C++中pwm_config函数的典型用法代码示例。如果您正苦于以下问题:C++ pwm_config函数的具体用法?C++ pwm_config怎么用?C++ pwm_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwm_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: haptic_work
static void haptic_work(struct work_struct *work)
{
struct max77843_haptic_data *hap_data
= container_of(work, struct max77843_haptic_data, work);
pr_info("[VIB] %s\n", __func__);
if (hap_data->timeout > 0) {
if (hap_data->running)
return;
max77843_haptic_i2c(hap_data, true);
pwm_config(hap_data->pwm, hap_data->pdata->duty,
hap_data->pdata->period);
pwm_enable(hap_data->pwm);
if (hap_data->pdata->motor_en)
hap_data->pdata->motor_en(true);
else {
int ret;
ret = regulator_enable(hap_data->regulator);
pr_info("regulator_enable returns %d\n", ret);
}
hap_data->running = true;
} else {
if (!hap_data->running)
return;
if (hap_data->pdata->motor_en)
hap_data->pdata->motor_en(false);
else
regulator_disable(hap_data->regulator);
pwm_disable(hap_data->pwm);
max77843_haptic_i2c(hap_data, false);
hap_data->running = false;
}
return;
}
示例2: mipi_lg_lcd_off
static int mipi_lg_lcd_off(struct platform_device *pdev)
{
struct msm_fb_data_type *mfd;
int ret;
printk("%s+\n", __func__);
mfd = platform_get_drvdata(pdev);
if (!mfd)
return -ENODEV;
if (mfd->key != MFD_KEY)
return -EINVAL;
if (bl_lpm) {
ret = pwm_config(bl_lpm, 0, PWM_PERIOD_USEC);
if (ret) {
pr_err("pwm_config on lpm failed %d\n", ret);
}
pwm_disable(bl_lpm);
}
mdelay(210);
printk("%s, lg display off command+\n", __func__);
cmdreq_lg.cmds = lg_display_off_cmds;
cmdreq_lg.cmds_cnt = ARRAY_SIZE(lg_display_off_cmds);
cmdreq_lg.flags = CMD_REQ_COMMIT;
cmdreq_lg.rlen = 0;
cmdreq_lg.cb = NULL;
mipi_dsi_cmdlist_put(&cmdreq_lg);
printk("%s, lg display off command-\n", __func__);
mdelay(20);
printk("%s-\n", __func__);
return 0;
}
示例3: pwm_beeper_event
static int pwm_beeper_event(struct input_dev *input,
unsigned int type, unsigned int code, int value)
{
int ret = 0;
struct pwm_beeper *beeper = input_get_drvdata(input);
unsigned long period;
if (type != EV_SND || value < 0)
return -EINVAL;
switch (code) {
case SND_BELL:
value = value ? 1000 : 0;
break;
case SND_TONE:
break;
default:
return -EINVAL;
}
if (value == 0) {
//pwm_config(beeper->pwm, 0, 0);
pwm_disable(beeper->pwm);
xc2440_beeper_disable();
} else {
xc2440_beeper_enable();
period = HZ_TO_NANOSECONDS(value);
ret = pwm_config(beeper->pwm, period / 2, period);
if (ret)
return ret;
ret = pwm_enable(beeper->pwm);
if (ret)
return ret;
beeper->period = period;
}
return 0;
}
示例4: enable_lvds
static void enable_lvds(struct display_info_t const *dev)
{
imx_iomux_v3_setup_multiple_pads(
display_pads,
ARRAY_SIZE(display_pads));
imx_iomux_v3_setup_multiple_pads(
backlight_pads,
ARRAY_SIZE(backlight_pads));
/* enable backlight PWM 3 */
if (pwm_init(2, 0, 0))
goto error;
/* duty cycle 500ns, period: 3000ns */
if (pwm_config(2, 500, 3000))
goto error;
if (pwm_enable(2))
goto error;
return;
error:
puts("error init pwm for backlight\n");
return;
}
示例5: lcdc_chimei_set_backlight
static void lcdc_chimei_set_backlight(int level)
{
int ret;
if (bl_pwm) {
ret = pwm_config(bl_pwm, PWM_DUTY_LEVEL * level,
PWM_PERIOD_USEC);
if (ret) {
pr_err("%s: pwm_config on pwm failed %d\n",
__func__, ret);
return;
}
ret = pwm_enable(bl_pwm);
if (ret) {
pr_err("%s: pwm_enable on pwm failed %d\n",
__func__, ret);
return;
}
}
chimei_bl_level = level;
}
示例6: lvds_chimei_set_backlight
static void lvds_chimei_set_backlight(struct msm_fb_data_type *mfd)
{
int ret;
pr_debug("%s: back light level %d\n", __func__, mfd->bl_level);
if (bl_lpm) {
ret = pwm_config(bl_lpm, LVDS_CHIMEI_PWM_DUTY_LEVEL *
mfd->bl_level, LVDS_CHIMEI_PWM_PERIOD_USEC);
if (ret) {
pr_err("pwm_config on lpm failed %d\n", ret);
return;
}
if (mfd->bl_level) {
ret = pwm_enable(bl_lpm);
if (ret)
pr_err("pwm enable/disable on lpm failed"
"for bl %d\n", mfd->bl_level);
} else {
pwm_disable(bl_lpm);
}
}
}
示例7: vibtonz_pwm
void vibtonz_pwm(int nForce)
{
int pwm_period = 0, pwm_duty = 0;
if (g_hap_data == NULL) {
printk(KERN_ERR "[VIB] the motor is not ready!!!");
return ;
}
pwm_period = g_hap_data->pdata->period;
pwm_duty = pwm_period / 2 + ((pwm_period / 2 - 2) * nForce) / 127;
if (pwm_duty > g_hap_data->pdata->duty)
pwm_duty = g_hap_data->pdata->duty;
else if (pwm_period - pwm_duty > g_hap_data->pdata->duty)
pwm_duty = pwm_period - g_hap_data->pdata->duty;
/* add to avoid the glitch issue */
if (prev_duty != pwm_duty) {
prev_duty = pwm_duty;
pwm_config(g_hap_data->pwm, pwm_duty, pwm_period);
}
}
示例8: pwm_regulator_set_voltage_sel
static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{
struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev);
unsigned int pwm_reg_period;
int dutycycle;
int ret;
pwm_reg_period = pwm_get_period(drvdata->pwm);
dutycycle = (pwm_reg_period *
drvdata->duty_cycle_table[selector].dutycycle) / 100;
ret = pwm_config(drvdata->pwm, dutycycle, pwm_reg_period);
if (ret) {
dev_err(&rdev->dev, "Failed to configure PWM\n");
return ret;
}
drvdata->state = selector;
return 0;
}
示例9: bd_display_run
void bd_display_run(char *cmd, int bl_duty, int bl_on)
{
static int display_init = 0;
if (cmd) {
run_command(cmd, 0);
lcd_draw_boot_logo(CONFIG_FB_ADDR, CFG_DISP_PRI_RESOL_WIDTH,
CFG_DISP_PRI_RESOL_HEIGHT, CFG_DISP_PRI_SCREEN_PIXEL_BYTE);
}
if (!display_init) {
bd_display();
pwm_init(CFG_LCD_PRI_PWM_CH, 0, 0);
display_init = 1;
}
pwm_config(CFG_LCD_PRI_PWM_CH,
TO_DUTY_NS(bl_duty, CFG_LCD_PRI_PWM_FREQ),
TO_PERIOD_NS(CFG_LCD_PRI_PWM_FREQ));
if (bl_on)
pwm_enable(CFG_LCD_PRI_PWM_CH);
}
示例10: enable_display_power
static void enable_display_power(void)
{
imx_iomux_v3_setup_multiple_pads(backlight_pads,
ARRAY_SIZE(backlight_pads));
/* backlight enable */
gpio_direction_output(IMX_GPIO_NR(6, 31), 1);
/* LCD power enable */
gpio_direction_output(IMX_GPIO_NR(6, 15), 1);
/* enable backlight PWM 1 */
if (pwm_init(0, 0, 0))
goto error;
/* duty cycle 500ns, period: 3000ns */
if (pwm_config(0, 50000, 300000))
goto error;
if (pwm_enable(0))
goto error;
return;
error:
puts("error init pwm for backlight\n");
return;
}
示例11: mipi_d2l_set_backlight_level
/**
* Set Backlight level.
*
* @param pwm
* @param level
*
* @return int
*/
static int mipi_d2l_set_backlight_level(struct pwm_device *pwm, int level)
{
int ret = 0;
pr_debug("%s: level=%d.\n", __func__, level);
#if defined(CONFIG_FB_MSM_MIPI_BOEOT_TFT_VIDEO_WSVGA_PT_PANEL) \
|| defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WXGA_PT_PANEL)
if ((pwm == NULL) || (level > BRIGHTNESS_MAX) || (level < 0)) {
pr_err("%s.pwm=NULL.\n", __func__);
return -EINVAL;
}
level = scale_pwm_dutycycle(level);
#else
if ((pwm == NULL) || (level > PWM_LEVEL) || (level < 0)) {
pr_err("%s.pwm=NULL.\n", __func__);
return -EINVAL;
}
#endif
ret = pwm_config(pwm, PWM_DUTY_LEVEL * level, PWM_PERIOD_USEC);
if (ret) {
pr_err("%s: pwm_config() failed err=%d.\n", __func__, ret);
return ret;
}
ret = pwm_enable(pwm);
if (ret) {
pr_err("%s: pwm_enable() failed err=%d\n",
__func__, ret);
return ret;
}
return 0;
}
示例12: pwm_test_store_duty
static ssize_t pwm_test_store_duty(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int rc;
struct pwm_test *pwm_test = dev_get_drvdata(dev);
int duty;
rc = kstrtoint(buf, 0, &duty);
if (rc)
return rc;
if (duty < 0)
return -EINVAL;
rc = pwm_config(pwm_test->pwm, duty, pwm_test->period);
if (rc) {
dev_err(dev, "pwm_config() failed\n");
return rc;
}
pwm_test->duty = duty;
return count;
}
示例13: isa1000_vib_set
static int isa1000_vib_set(struct isa1000_vib *vib, int on)
{
int rc;
if (on) {
rc = pwm_config(pwm,
(pwm_period_ns * pwm_duty) / 100,
pwm_period_ns);
if (rc < 0){
printk( "Unable to config pwm%d\n",rc);
}
rc = pwm_enable(pwm);
if (rc < 0){
printk("Unable to enable pwm\n");
}
gpio_set_value_cansleep(GPIO_ISA1000_EN, 1);
} else {
gpio_set_value_cansleep(GPIO_ISA1000_EN, 0);
pwm_disable(pwm);
}
return rc;
}
示例14: vibtonz_en
void vibtonz_en(bool en)
{
int ret;
if (g_hap_data == NULL) {
printk(KERN_ERR "[VIB] the motor is not ready!!!");
return ;
}
if (en) {
if (g_hap_data->running)
return;
max77888_haptic_i2c(g_hap_data, true);
pwm_config(g_hap_data->pwm, prev_duty, g_hap_data->pdata->period);
pwm_enable(g_hap_data->pwm);
if (g_hap_data->pdata->motor_en)
g_hap_data->pdata->motor_en(true);
else
ret = regulator_enable(g_hap_data->regulator);
g_hap_data->running = true;
} else {
if (!g_hap_data->running)
return;
if (g_hap_data->pdata->motor_en)
g_hap_data->pdata->motor_en(false);
else
regulator_disable(g_hap_data->regulator);
pwm_disable(g_hap_data->pwm);
max77888_haptic_i2c(g_hap_data, false);
g_hap_data->running = false;
}
}
示例15: set_pwm
static void set_pwm(unsigned int percent)
{
unsigned long duty;
if(percent > 100)
{
duty = PERIOD;
gDuty = 100;
}
else if(percent < 0)
{
duty = 0;
gDuty = 0;
}
else
{
duty = (PERIOD * percent)/100;
gDuty = percent;
}
pr_info("Duty set to : %ld\n", duty);
if(duty != gDuty)
{
pwm_config(pwm_dev, duty, PERIOD);
}
}