当前位置:网站首页>Imx6q PWM drive
Imx6q PWM drive
2022-06-12 07:03:00 【Handsome without friends~】
One : Device tree

kernel_imx/arch/arm/boot/dts/imx6q-c-sabresd.dts

kernel_imx/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
pwms = <&pwm3 0 50000>;
pwm3: Indicates that the backlight is connected to pwm3 On
0: Express index by 0,pwm3 There is only 1 individual pwm, So fill in 0
50000: Indicates that the period is 50000ns, The frequency is 20k
default-brightness-level = <60>;
Default backlight brightness ,60Two :pwm drive
pwm Driving dependency backlight Subsystem .
drive :kernel/drivers/video/backlight/pwm_bl.c kernel_imx/drivers/video/backlight/backlight.c
pwm_backlight_probe
pwm_backlight_parse_dt // analysis dts Medium brightness-levels、default-brightness-level
//RK3288 It will also be parsed here enable-gpios , however 3399 No, ,3399 Is in probe with devm_gpiod_get_optional // obtain enable-gpio State of
devm_gpiod_get_optional // It's actually encapsulation gpio_request_one
devm_gpio_request_one // Apply for backlight enable gpio
devm_pwm_get -> /drivers/pwm/core.c // To obtain a pwm
pwm_get ->
of_pwm_get ->
of_parse_phandle_with_args Parse the above dts Medium pwms attribute .
of_node_to_pwmchip
pwm = pc->of_xlate // The resulting struct pwm_device type .
pwm_request // apply pwm, Prevent other drivers from using .
pwm_set_period //pb->pwm->period = data->pwm_period_ns
pwm_get_period // obtain period.
dev_set_name(&pdev->dev, "rk28_bl"); //name Can't change , User space will be used :/sys/class/backlight/rk28_bl
backlight_device_register -> /drivers/video/baklight/backlight.c // Register standard backlight devices
device_register
backlight_register_fb ->
fb_register_client //callback yes fb_notifier_callback
fb_register_client // Register the kernel notification chain
backlight_update_status -> // Update... With default values .
bd->ops->update_status ->
pwm_backlight_update_status ->
compute_duty_cycle // Calculate the duty cycle
pwm_config // To configure pwm
pwm_backlight_power_on //enable Backlight
platform_set_drvdata // Can be pdev Private data saved as platform bus device , When you want to use it later, you just call platform_get_drvdatacompute_duty_cycle Calculate the duty cycle :
static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
{
/* Generally, this value is 0*/
unsigned int lth = pb->lth_brightness;
/* Duty cycle */
int duty_cycle;
/*pb->levels This form is from dts node brightness-levels From ,
Suppose that the incoming parameters brightness yes 254, So what you get duty_cycle Namely 1,
Without this form , Then it is directly the incoming brightness value .*/
if (pb->levels)
duty_cycle = pb->levels[brightness];
else
duty_cycle = brightness;
/* Suppose here lth yes 0, So the formula is duty_cycle * pb->period / pb->scale
pb->period That is to say dts node pwms The third parameter period value of is 25000
pb->scale by pb->levels The maximum value in the array
So this formula is based on the following formula Android The pure value of is converted into the duty cycle corresponding to the event cycle value .*/
return (duty_cycle * (pb->period - lth) / pb->scale) + lth;
}Either way, it calls backlight_update_status To change the backlight ,syfs It's also . look down backlight.c,
backlight_class_init -> backlight.c
class_create // establish class, The name is backlight.
among backlight_store_brightness() The final call backlight_update_status().
There is also a case where the screen is on / Call when the screen is off , Remember to register one in front fb notify callback.
static int fb_notifier_callback(struct notifier_block *self,
unsigned long event, void *data)
{
...
/* Only screen on and screen off events are handled .*/
/* If we aren't interested in this event, skip it immediately ... */
if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
return 0;
...
if (bd->ops)
if (!bd->ops->check_fb ||
bd->ops->check_fb(bd, evdata->info)) {
bd->props.fb_blank = *(int *)evdata->data;
// On screen condition
if (bd->props.fb_blank == FB_BLANK_UNBLANK)
bd->props.state &= ~BL_CORE_FBBLANK;
// When the screen is off
else
bd->props.state |= BL_CORE_FBBLANK;
backlight_update_status(bd);
}
...
}backlight_update_status Function implementation :

kernel_imx/include/linux/backlight.h
The final call bd->ops->update_status(bd);bd->ops The assignment of is in pwm_bl.c In the document backlight_device_register Function assignment .


Android6.0 Backlight Drive analysis
边栏推荐
- Scons编译IMGUI
- Troubleshooting of cl210openstack operation -- Chapter experiment
- 六月集训 第七日 ——哈希表
- [Li Kou] curriculum series
- Lambda function perfect use guide
- Database syntax related problems, solve a correct syntax
- Scons compiling imgui
- Junior high school education, less than 3k, to 30k+ monthly salary, how wonderful life is without restrictions
- SQL language
- Vscode Common plug - in
猜你喜欢

Descscheduler secondary scheduling makes kubernetes load more balanced

(14) The software version number is displayed in the flash window of blender source code analysis

【图像去噪】基于偏微分方程(PDE)实现图像去噪附matlab代码

I met 15 people recently and found that I couldn't answer the basic question of this test

Freshmen are worried about whether to get a low salary of more than 10000 yuan from Huawei or a high salary of more than 20000 yuan from the Internet

sql server 2019安装出现错误,如何解决

leetcode:剑指 Offer 60. n个骰子的点数【数学 + 层次dp + 累计贡献】

(14)Blender源码分析之闪屏窗口显示软件版本号

Kotlin插件 kotlin-android-extensions

lambda 函数完美使用指南
随机推荐
最近面了15个人,发现这个测试基础题都答不上来...
3 strings, containers, and arrays
网络丢包问题排查
What is the difference between < t > and object?
五、EL 表达式& JSTL 标签库
d的扩大@nogc
JDE 对象管理工作平台介绍及 From 的使用
MySQL multiple SQL batch operations (crud) in JDBC
Recommend 17 "wheels" to improve development efficiency
Idea common shortcut keys
The seventh day of June training - hash table
postman拼接替换参数循环调用接口
d不能用非常ctfe指针
Torch models trained in higher versions report errors in lower versions
An error occurred while downloading the remote file The errormessage
Scons compiling imgui
Set judge the existence of intersection
CL210OpenStack操作的故障排除--章节实验
美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
[easyexcel] easyexcel checks whether the header matches the tool class encapsulated in easyexcel, including the field verification function. You can use validate to verify