电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>类型>参考设计>ADP8870背光LED Linux驱动器

ADP8870背光LED Linux驱动器

2021-04-20 | pdf | 208.71KB | 次下载 | 2积分

资料介绍

This version (11 Feb 2016 21:14) was approved by Lars-Peter Clausen.The Previously approved version (08 Nov 2011 17:34) is available.Diff

ADP8870 Back-light LED Linux Driver

Supported Devices

Evaluation Boards

Description

Configuration

Software configurable features

Backlight:

  • Ambient Light Sensor Support (ALS)
  • Five programmable ambient light sensing zones for optimal backlight power savings
  • PWM input can be used for Content Adaptive Brightness Control (CABC) of any, or all, of the LEDs (PWM input scales the LED output current)
  • Configurable Fade On/Off times
  • Configurable Fade Law functions
  • Configurable ALS filter settings
  • Configurable Brightness/Intensity in 128 steps

LED:

  • Up to 7 LEDs configurable
  • Configurable Fade On/Off times
  • LED Blink On/Off times
  • Configurable Fade Law functions
  • Configurable Brightness/Intensity in 128 steps from [0..255]

Source Code

Status

Source Mainlined?
git Yes

Files

Instructions / Theory of operation

Backlight control

With the ADP8870 driver installed, you will find sysfs files in the
/sys/class/backlight/adp8870_bl/
directory. You will be able to query and set the current screen
brightness:

brightness
get/set screen brightness (an integer between 0 and 126)
writing 127 will enable the Ambient Light Sensor.
actual_brightness
reading from this file will query the HW to get real brightness value.
max_brightness
the maximum brightness value.
bl_power
Current FB Power mode (0: full on, 1..3: power saving modes; 4: full off).

ADP8870 Specific Backlight controls

The ADP8870 features 5 individually programmable Ambient Light Sensing Zones:

l1_daylight_dim
Ambient Light Zone Daylight: Backlight DIM Intensity (an integer between 0 and 127, typically set to 0).
l1_daylight_max
Ambient Light Zone Daylight: Backlight Intensity (an integer between 0 and 127).
l2_bright_dim
Ambient Light Zone Bright: Backlight DIM Intensity (an integer between 0 and 127, typically set to 0)
l2_bright_max
Ambient Light Zone Bright: Backlight Intensity (an integer between 0 and 127)
l3_office_dim
Ambient Light Zone Office: Backlight DIM Intensity (an integer between 0 and 127, typically set to 0)
l3_office_max
Ambient Light Zone Office: Backlight Intensity (an integer between 0 and 127)
l4_indoor_dim
Ambient Light Zone Indoor: Backlight DIM Intensity (an integer between 0 and 127, typically set to 0)
l4_indoor_max
Ambient Light Zone Indoor: Backlight Intensity (an integer between 0 and 127)
l5_dark_dim
Ambient Light Zone Dark: Backlight DIM Intensity (an integer between 0 and 127, typically set to 0)
l5_dark_max
Ambient Light Zone Dark: Backlight Intensity (an integer between 0 and 127)
ambient_light_level
Get conversion value of the first light sensor. This value is updated every 80 ms
(when the light sensor is enabled). Returns integer between 0 (dark) and 8000 (max ambient brightness)
ambient_light_zone
Get/Set current Ambient Light Zone. Reading returns integer between 1..5
(1 = Daylight, 2 = bright, …, 5 = dark). Writing a value between 1..5 forces the Backlight controller
to enter the corresponding Ambient Light Zone. Writing 0 returns to normal operation.

LED handling under Linux

LEDs not assigned to the Backlight are optionally exposed to the Linux LEDs Class.

The LED class allows control of LEDs from userspace. LEDs appear in /sys/class/leds/. The brightness file will set the brightness of the LED (taking a value 0-255). The LEDS class also introduces the optional concept of an LED trigger. A trigger is a kernel based source of led events, such as ide-disk or backlight control.
For more information read linux/Documentaion/leds-class.txt

brightness
get/set LED brightness (an integer between 0 and 255)
max_brightness
the maximum brightness value.

Example platform device initialization

For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.

For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.

21 Oct 2010 16:10

platform_data: Platform data specific to the ADP8870 device.
Includes what LEDs are available, feature selections and default initialization.

#include 

Declaring I2C devices

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each I2C bus segment, and what address these devices are using. For this reason, the kernel code must instantiate I2C devices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare the I2C devices by bus number.

This method is appropriate when the I2C bus is a system bus, as in many embedded systems, wherein each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices that inhabit this bus. This is done with an array of struct i2c_board_info, which is registered by calling i2c_register_board_info().

So, to enable such a driver one need only edit the board support file by adding an appropriate entry to i2c_board_info.

For more information see: Documentation/i2c/instantiating-devices

21 Oct 2010 16:10
static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE)
	{
		I2C_BOARD_INFO("adp8870", 0x2B),
		.platform_data = (void *)&adp8870_pdata,
	},
#endif
}

Adding Linux driver support

Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)

The ADP8870 Backlight driver depends on I2C. It therefore requires selected I2C support to show up during kernel configuration.

Device Drivers  --->
	Graphics support  --->
		[*] Backlight & LCD device support  --->
			<*>   Lowlevel Backlight controls
			   Backlight Driver for ADP8870 using WLED

Hardware configuration

There is no dedicated Blackfin STAMP evaluation board for the ADP8870. During test and driver development we used the ADP8870 Evaluation Mother/Daughter Board.

It can be easily wired to the Blackfin STAMP TWI/I2C header.

BF537-STAMP (P10) TWI/I2C header ADP886x Adaptor Board (J30)
PIN Function PIN/Function
5 SCL SCL
6 SDA SDA
20 GND GND

Leave J31 and J32 open (these jumpers connect the SCL and SDA to the cypress chip used as USB bridge). Then apply your own SCL, SDA, and GND to the big J30 connector on the left edge of the board.

The ADP8870 chip still needs Vin (to power the chip), Vddio (to pull nRST and nINT high), and Vboard (to power the ALS sensor on the daughter card). These are provided through the USB port and then get regulated down (Vin becomes 3.6V, Vddio is 2.7V, and Vboard is around 4 V). So even though you won't be using the USB to program the part, it would still be easiest to plug the board into a USB port just to power Vin, Vddio, and Vboard. Of course, if you want, you can power these supplies from a lab bench power supply. In that case, move LK1, 2, and 3 to the “EXT” position and apply the signals to J29.

Driver testing

Driver compiled as a module

ADP8870 driver is build as a module

root:/> modprobe adp8870_bl
adp8870_bl 0-002b: Rev.0 Backlight
Registered led device: adp8870-led7
root:/>

Example Backlight usage

root:/> cd sys/class/backlight/adp8870_bl/
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> ls -l
-r--r--r--    1 root     root         4096 Jan  1 03:29 actual_brightness
-r--r--r--    1 root     root         4096 Jan  1 03:29 ambient_light_level
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 ambient_light_zone
-rw-r--r--    1 root     root         4096 Jan  1 03:31 bl_power
-rw-r--r--    1 root     root         4096 Jan  1 04:55 brightness
lrwxrwxrwx    1 root     root            0 Jan  1 03:29 device -> ../../../0-002b
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l1_daylight_dim
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l1_daylight_max
-rw-rw-r--    1 root     root         4096 Jan  1 03:30 l2_bright_dim
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l2_bright_max
-rw-rw-r--    1 root     root         4096 Jan  1 03:30 l3_office_dim
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l3_office_max
-rw-rw-r--    1 root     root         4096 Jan  1 03:31 l4_indoor_dim
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l4_indoor_max
-rw-rw-r--    1 root     root         4096 Jan  1 03:31 l5_dark_dim
-rw-rw-r--    1 root     root         4096 Jan  1 03:29 l5_dark_max
-r--r--r--    1 root     root         4096 Jan  1 03:29 max_brightness
drwxr-xr-x    2 root     root            0 Jan  1 03:29 power
lrwxrwxrwx    1 root     root            0 Jan  1 03:29 subsystem -> ../../../../../../../../class/backlight
-rw-r--r--    1 root     root         4096 Jan  1 03:29 uevent
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl>

Set Backlight Intensity

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 42 > brightness

Query Backlight Intensity

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat brightness
42

Enable Ambient Light Sensing Feature

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 127 > brightness

Query Ambient Light Level

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat ambient_light_level
1276

Query Ambient Light Zone

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat ambient_light_zone
4

Adjust Intensity for Ambient Light Zone 4 (indoor)

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 22 > l4_indoor_max
22

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat l4_indoor_max
22

Example LED usage

root:/> cd /sys/class/leds/adp8870-led7/
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> ls -l
-rw-r--r--    1 root     root         4096 Jan  1 03:29 brightness
lrwxrwxrwx    1 root     root            0 Jan  1 03:29 device -> ../../../0-002b
-r--r--r--    1 root     root         4096 Jan  1 03:29 max_brightness
drwxr-xr-x    2 root     root            0 Jan  1 03:29 power
lrwxrwxrwx    1 root     root            0 Jan  1 03:29 subsystem -> ../../../../../../../../class/leds

Set Intensity

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7>echo 99 > brightness

Turn LED OFF

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> echo 0 > brightness

Query Max Brightness

root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> cat max_brightness
255
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7>

More Information

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1AN-1267: 使用ADSP-CM408F ADC控制器的电机控制反馈采样时序
  2. 1.41MB   |  3次下载  |  免费
  3. 2AN158 GD32VW553 Wi-Fi开发指南
  4. 1.51MB   |  2次下载  |  免费
  5. 3AN148 GD32VW553射频硬件开发指南
  6. 2.07MB   |  1次下载  |  免费
  7. 4AN-1154: 采用恒定负渗漏电流优化ADF4157和ADF4158 PLL的相位噪声和杂散性能
  8. 199.28KB   |  次下载  |  免费
  9. 5AN-960: RS-485/RS-422电路实施指南
  10. 380.8KB   |  次下载  |  免费
  11. 6EE-249:使用VisualDSP在ADSP-218x DSP上实现软件叠加
  12. 60.02KB   |  次下载  |  免费
  13. 7AN-1111: 使用ADuCM360/ADuCM361时的降低功耗选项
  14. 306.09KB   |  次下载  |  免费
  15. 8AN-904: ADuC7028评估板参考指南
  16. 815.82KB   |  次下载  |  免费

本月

  1. 1ADI高性能电源管理解决方案
  2. 2.43 MB   |  450次下载  |  免费
  3. 2免费开源CC3D飞控资料(电路图&PCB源文件、BOM、
  4. 5.67 MB   |  138次下载  |  1 积分
  5. 3基于STM32单片机智能手环心率计步器体温显示设计
  6. 0.10 MB   |  130次下载  |  免费
  7. 4使用单片机实现七人表决器的程序和仿真资料免费下载
  8. 2.96 MB   |  44次下载  |  免费
  9. 5美的电磁炉维修手册大全
  10. 1.56 MB   |  24次下载  |  5 积分
  11. 6如何正确测试电源的纹波
  12. 0.36 MB   |  18次下载  |  免费
  13. 7感应笔电路图
  14. 0.06 MB   |  10次下载  |  免费
  15. 8万用表UT58A原理图
  16. 0.09 MB   |  9次下载  |  5 积分

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935121次下载  |  10 积分
  3. 2开源硬件-PMP21529.1-4 开关降压/升压双向直流/直流转换器 PCB layout 设计
  4. 1.48MB  |  420062次下载  |  10 积分
  5. 3Altium DXP2002下载入口
  6. 未知  |  233088次下载  |  10 积分
  7. 4电路仿真软件multisim 10.0免费下载
  8. 340992  |  191367次下载  |  10 积分
  9. 5十天学会AVR单片机与C语言视频教程 下载
  10. 158M  |  183335次下载  |  10 积分
  11. 6labview8.5下载
  12. 未知  |  81581次下载  |  10 积分
  13. 7Keil工具MDK-Arm免费下载
  14. 0.02 MB  |  73810次下载  |  10 积分
  15. 8LabVIEW 8.6下载
  16. 未知  |  65988次下载  |  10 积分