大家好,我想请教个问题,关于AM335X的背光控制
在用户层,可以用echo 0> /sys/class/backlight/backlight/brightness的方式来调节开关背光,而这个方式的时候,会通过调用pwm_backlight_update_status函数来更新背光状态。那么在内核中该如何控制呢?
应用场景是AM335X在不使用的情况下休眠(只关闭LCD或则背光,用户程序继续跑,所以应该不能suspend),在点击触摸屏或则按一下其他按钮后可以唤醒设备。因此我想在触摸驱动的中断函数中添加判断背光状态的代码,在背光关闭的时候,点击触摸屏可以重新打开背光。
这个场景除了上面这个做法,可有其他建议?谢谢
Steven Liu1:
因为背光是靠PWM控制的,所以正常情况下,你在休眠的时候,如果使用的是DEEPSLEEP0模式()就是echo mem的方式使其休眠),背光应该会关掉。你用的是这种模式进行休眠吗?休眠态PWM还有输出?
zizhen hu:
回复 Steven Liu1:
不是这种suspend的休眠模式,客户的目的是把屏幕关掉而他们的应用程序继续运行,所以我想就是只把背光关掉,需要点亮的时候,通过点击屏幕,把触摸屏点亮。
我在触摸驱动的中断函数中添加了如下代码,但是调试的时候发现会出现异常,但是不影响继续使用,请问是怎么回事。代码如下,通过读取brightness的值来操作。
if (status & IRQENB_PENUP) { fsm = titsc_readl(ts_dev, REG_ADCFSM); if (((fsm == ADCFSM_STEPID)&&(isReport == true)) || (isReport == true)) { ts_dev->pen_down = false; input_report_key(input_dev, BTN_TOUCH, 0); input_report_abs(input_dev, ABS_PRESSURE, 0); input_sync(input_dev); prex = 0; prey = 0; isReport = false; printk("[huzz]%s:report pen_up\n",__func__); pm_relax(ts_dev->mfd_tscadc->dev); fp = filp_open("/sys/class/backlight/backlight/brightness",O_RDWR,0644); if(IS_ERR(fp)){ printk("open failed\n"); } else{ fs = get_fs(); set_fs(KERNEL_DS); pos = 0; vfs_read(fp,&state,1,&pos); printk("[huzz]%s:brightness=%d\n",__func__,state); filp_close(fp,NULL); set_fs(fs); }
异常信息如下,不清楚上面的代码哪里出现了问题。出现下面的异常之后,继续点击屏幕,则触摸功能依旧可以使用,而且能打印[huzz]titsc_irq:brightness=56
root@am335x-evm:~# [ 50.810663] [huzz]titsc_irq:brightness=56[ 50.814627] ————[ cut here ]————[ 50.819509] WARNING: CPU: 0 PID: 560 at kernel/irq/handle.c:150 handle_irq_event_percpu+0x160/0x16c()[ 50.828818] irq 179 handler titsc_irq+0x0/0x58c [ti_am335x_tsc] enabled interrupts[ 50.836439] Modules linked in: ftdi_sio usbserial usbhid musb_dsps musb_hdrc udc_core usbcore ti_am335x_adc kfifo_buf pru_rproc pruss_intc pm33xx snd_soc_simple_card ti_emif_sram ecb wkup_m3_ipc sha256_generic hmac md5 sha1_generic sha1_arm_neon wkup_m3_rproc sha1_arm pruss remoteproc virtio omap_aes_driver omap_sham virtio_ring omap_rng rng_core ti_am335x_tsc musb_am335x rtc_omap omap_wdt ti_am335x_tscadc sch_fq_codel[ 50.873998] CPU: 0 PID: 560 Comm: QThread Not tainted 4.4.32-gadde2ca9f8 #243[ 50.881161] Hardware name: Generic AM33XX (Flattened Device Tree)[ 50.887295] Backtrace: [ 50.889779] [<c00134e4>] (dump_backtrace) from [<c00136e0>] (show_stack+0x18/0x1c)[ 50.897392] r7:c006b740 r6:00000096 r5:00000009 r4:00000000[ 50.903110] [<c00136c8>] (show_stack) from [<c02a8688>] (dump_stack+0x24/0x28)[ 50.910385] [<c02a8664>] (dump_stack) from [<c0031d0c>] (warn_slowpath_common+0x88/0xb4)[ 50.918547] [<c0031c84>] (warn_slowpath_common) from [<c0031d70>] (warn_slowpath_fmt+0x38/0x40)[ 50.927293] r8:000000b3 r7:00000000 r6:00000000 r5:00000001 r4:c0813aac[ 50.934069] [<c0031d3c>] (warn_slowpath_fmt) from [<c006b740>] (handle_irq_event_percpu+0x160/0x16c)[ 50.943236] r3:000000b3 r2:c0813aac[ 50.946843] r4:dc7896c0[ 50.949398] [<c006b5e0>] (handle_irq_event_percpu) from [<c006b7b0>] (handle_irq_event+0x64/0x90)[ 50.958315] r10:10c53c7d r9:0006d4c5 r8:dc006000 r7:00000000 r6:00000000 r5:dc112910[ 50.966221] r4:dc112900[ 50.968774] [<c006b74c>] (handle_irq_event) from [<c006e58c>] (handle_level_irq+0xb8/0x168)[ 50.977169] r5:dc112910 r4:dc112900[ 50.980770] [<c006e4d4>] (handle_level_irq) from [<c006ad5c>] (generic_handle_irq+0x2c/0x3c)[ 50.989255] r5:000000b3 r4:c093c284[ 50.992856] [<c006ad30>] (generic_handle_irq) from [<c006afc8>] (__handle_domain_irq+0x5c/0xb0)[ 51.001610] [<c006af6c>] (__handle_domain_irq) from [<c0009468>] (omap_intc_handle_irq+0x3c/0x98)[ 51.010539] r9:0006d4c5 r8:80010030 r7:da98bf94 r6:ffffffff r5:00010013 r4:c0995e80[ 51.018363] [<c000942c>] (omap_intc_handle_irq) from [<c0014194>] (__irq_svc+0x54/0x90)[ 51.026411] Exception stack(0xda98bf60 to 0xda98bfa8)[ 51.031489] bf60: 00000011 b2167df0 00000010 0000002c 00af28e4 00af28f0 00af28ec 00000003[ 51.039720] bf80: 80010030 0006d4c5 10c53c7d 00000000 10c5387d da98bfb0 b63a5c90 c000fb20[ 51.047941] bfa0: 00010013 ffffffff[ 51.051445] r5:00010013 r4:c000fb20[ 51.055052] —[ end trace aec24ede5aa820ce ]—