# # Patch managed by http://www.holgerschurig.de/patcher.html # --- linux/drivers/char/tosa_ts.c~tosa_ts.patch +++ linux/drivers/char/tosa_ts.c @@ -102,6 +102,8 @@ static int head = 0, tail = 0; #ifdef CONFIG_PM +#include +static struct pm_dev* tosa_ts_pm_dev; static int tp_suspend = 0; #endif /* CONFIG_PM */ @@ -495,25 +497,6 @@ ioctl: ts_ioctl, }; -static void ts_exit(void) -{ - ts_timer_clear(); - ts_clear(); - free_irq(IRQ_GPIO_TP_INT, NULL); - wm9712_power_mode_ts(WM9712_PWR_OFF); - - pxa_ac97_put(&ac97_on); -} - -#ifdef MODULE -static void __exit ac97_ts_cleanup(void) -{ - ts_exit(); - unregister_chrdev(TS_MAJOR, "ts"); -} -module_exit(ac97_ts_cleanup); -#endif /* MODULE */ - extern int tc6393fb_lcdMode; int ac97_ad_input(int ch, unsigned short *dat) @@ -608,7 +591,7 @@ #endif } -static int ts_init(void) +static int tosa_ts_hardware_start(void) { pxa_ac97_get(&codec, &ac97_on); @@ -625,7 +608,6 @@ /* GPIO3/PENDOWN wakeup */ ac97_bit_set(AC97_GPIO_WAKE_UP, CODEC_PENDOWN); - ts_clear(); /* Init queue */ //X kernel_thread(ts_pendown, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD); @@ -639,12 +621,39 @@ return -EBUSY; } - // printk(KERN_INFO "Tosa Touch Screen driver initialized\n"); - return 0; } -static int __init ac97_ts_init(void) +static void tosa_ts_hardware_stop(void) +{ + ts_timer_clear(); + ts_clear(); + free_irq(IRQ_GPIO_TP_INT, NULL); + wm9712_power_mode_ts(WM9712_PWR_OFF); + + pxa_ac97_put(&ac97_on); +} + +#ifdef CONFIG_PM +static int tosa_ts_pm_callback(struct pm_dev *pm_dev, + pm_request_t req, void *data) +{ + switch (req) { + case PM_SUSPEND: + tp_suspend = 1; + tosa_ts_hardware_stop(); + break; + case PM_RESUME: + tp_suspend = 0; + tosa_ts_hardware_start(); + break; + } + return 0; +} +#endif + + +static int __init tosa_ts_init(void) { ac97_on = 0; @@ -663,28 +672,37 @@ if( register_chrdev(TS_MAJOR,DEV_NAME, &ts_fops) ) { printk("unable to get major %d for touch screen\n", TS_MAJOR); - ts_exit(); } init_procinfo(); + tosa_ts_hardware_start(); + +#ifdef CONFIG_PM + tosa_ts_pm_dev = pm_register(PM_SYS_DEV, 0, tosa_ts_pm_callback); +#endif + kernel_thread(ts_pendown, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD); return 0; } -module_init(ac97_ts_init); +static int __exit tosa_ts_cleanup() +{ + tosa_hardware_stop(); + pm_unregister(tosa_ts_pm_dev); + unregister_chrdev(TS_MAJOR, "ts"); +} + +module_init(tosa_ts_init); +module_exit(tosa_ts_cleanup); /* * Driver functions */ static int ts_open(struct inode *inode, struct file *file) { - if( ts_init() < 0 ) { - ts_exit(); - return -EINVAL; - } - + ts_clear(); MOD_INC_USE_COUNT; return 0; } @@ -692,7 +710,6 @@ static int ts_release(struct inode *inode, struct file *file) { - ts_exit(); MOD_DEC_USE_COUNT; return 0; @@ -788,20 +805,3 @@ return 0; } -#ifdef CONFIG_PM -void tosa_ts_suspend(void) -{ - DEBUG(DBG_L1, "in\n"); - tp_suspend = 1; - ts_exit(); - DEBUG(DBG_L1, "out\n"); -} - -void tosa_ts_resume(void) -{ - DEBUG(DBG_L1, "in\n"); - tp_suspend = 0; - ts_init(); - DEBUG(DBG_L1, "out\n"); -} -#endif /* CONFIG_PM */ --- linux/drivers/sound/pxa-ac97_tosa.c~tosa_ts.patch +++ linux/drivers/sound/pxa-ac97_tosa.c @@ -90,8 +90,6 @@ #include static struct pm_dev* pxa_sound_pm_dev; static int tosa_pm_callback(struct pm_dev *,pm_request_t, void *); -extern void tosa_ts_suspend(void); -extern void tosa_ts_resume(void); #endif /* CONFIG_PM */ /************************************************************ @@ -2195,9 +2193,6 @@ case PM_SUSPEND: DEBUG(DBG_L1, "PM_SUSPEND: start\n"); wm9712_suspend(); -#ifdef CONFIG_TOSA_TS - tosa_ts_suspend(); -#endif /* CONFIG_TOSA_TS */ if ( ac97_audio_state.rd_ref != 0 ) { audio_clear_buf(ac97_audio_state.input_stream); *ac97_audio_state.input_stream->drcmr = 0; @@ -2239,9 +2234,6 @@ ac97_audio_state.input_stream->dma_ch = err; } wm9712_resume(); -#ifdef CONFIG_TOSA_TS - tosa_ts_resume(); -#endif /* CONFIG_TOSA_TS */ DEBUG(DBG_L1, "PM_RESUME: done\n"); break; }