LCD背光是通过 CPU的 LCD_PWR引脚来控制的, 当LCD_PWR输出1, 亮 , 输出0则灭.
以下的代码均参考mini2440的移植手册
(1)新建/drivers/video/mini2440_backlight.c
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #undef DEBUG #ifdef DEBUG #define DPRINTK(x...) {printk(__FUNCTION__"(%d): ",__LINE__);printk(##x);} #else #define DPRINTK(x...) (void)(0) #endif #define DEVICE_NAME "backlight" static unsigned int bl_state; static inline void set_bl(int state) { bl_state = !!state; s3c2410_gpio_setpin(S3C2410_GPG(4), bl_state); } static inline unsigned int get_bl(void) { return bl_state; } static ssize_t dev_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) { unsigned char ch; int ret; if (count == 0) { return count; } ret = copy_from_user(&ch, buffer, sizeof ch)?-EFAULT:0; if (ret) { return ret; } ch &= 0x01; set_bl(ch); return count; } static ssize_t dev_read(struct file *filp, char *buffer, size_t count, loff_t *ppos) { int ret; unsigned char str[] = {'0', '1' }; if (count == 0) { return 0; } ret = copy_to_user(buffer, str + get_bl(), sizeof(unsigned char) ) ? -EFAULT : 0; if (ret) { return ret; } return sizeof(unsigned char); } static struct file_operations dev_fops = { owner: THIS_MODULE, read:dev_read, write: dev_write, }; static struct miscdevice misc = { .minor = MISC_DYNAMIC_MINOR, .name = DEVICE_NAME, .fops = &dev_fops, }; static int __init dev_init(void) { int ret; ret = misc_register(&misc); printk (DEVICE_NAME"/tinitialized/n"); s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT); set_bl(1); return ret; } static void __exit dev_exit(void) { misc_deregister(&misc); } module_init(dev_init); module_exit(dev_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("FriendlyARM Inc."); (2)编辑同级目录(drivers/video/)的Kconfig, 找到config FB_S3C2410_DEBUG ,在下面添加: config BACKLIGHT_MINI2440 tristate "Backlight support for mini2440 from FriendlyARM" depends on FB_S3C2410 #这里注释掉&& FB_S3C2410 help backlight driver for MINI2440 from FriendlyARM (3) 编辑同级目录(drivers/video)的Makefile, 找到obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o, 在下面添加: obj-$(CONFIG_BACKLIGHT_MINI2440) += mini2440_backlight.o (4)然后再初级目录make menuconfig,在 Device Drivers ---> Graphics support ---> <*> Support for frame buffer devices ---> [*]Backlight support for mini2440 from FriendlyARM 然后make zImage, 测试, ok, (5) 使用方式 在命令行种输入:echo 0 > /dev/backlight 可以关闭LCD背光。 在命令行种输入:echo 1 > /dev/backlight 可以打开LCD背光。
上一篇:linux2.6.32移植概要总结
下一篇:linux 2.6.32 在arm9(s3c2440)平台的移植2 -- Kconfig和Makefile(2)
推荐阅读最新更新时间:2024-11-12 20:25
设计资源 培训 开发板 精华推荐
- Cube-101_esp-tool烧录调试工具
- ESP8266开发板
- STEVAL-IME013V1,基于 STHV800 具有成本效益的超声脉冲发生器 IC 的评估板
- 使用 NXP Semiconductors 的 TDA3603P 的参考设计
- 使用 Microchip Technology 的 MHL8701 的参考设计
- LT6656AIS6-3.3、3.3V ADC 电压基准和桥式激励电源的典型应用
- DEV-15866,电源管理 IC 开发套件直流电机驱动器 HAT
- ZR431L 的典型应用,可调精密并联稳压器
- OP284ESZ-REEL 仅 5V、12 位 DAC 摆幅轨到轨运算放大器的典型应用
- CH340N-USB转TTL串口烧录器