diff options
author | Maxim Levitsky <maximlevitsky@gmail.com> | 2007-10-13 04:35:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-22 10:01:41 -0400 |
commit | ea63d0b11ebb296b3daca4fcb74931604ee3ce78 (patch) | |
tree | 7f0cddc91eabbc4b24869cfb3b5e184e80fd2275 /drivers/media | |
parent | c458473ebf31755373ca2f8063c9ec9744205924 (diff) |
V4L/DVB (6330): V4L: saa7134: Fix interaction between tvaudio thread and the freezer
make tvaudio thread freezeable, and add proper support for that
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 30 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 1 |
2 files changed, 24 insertions, 7 deletions
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 976318d50828..f8e304c76232 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/kthread.h> | 27 | #include <linux/kthread.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/freezer.h> | ||
30 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
31 | 32 | ||
32 | #include "saa7134-reg.h" | 33 | #include "saa7134-reg.h" |
@@ -502,13 +503,17 @@ static int tvaudio_thread(void *data) | |||
502 | unsigned int i, audio, nscan; | 503 | unsigned int i, audio, nscan; |
503 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; | 504 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; |
504 | 505 | ||
505 | allow_signal(SIGTERM); | 506 | |
507 | set_freezable(); | ||
508 | |||
506 | for (;;) { | 509 | for (;;) { |
507 | tvaudio_sleep(dev,-1); | 510 | tvaudio_sleep(dev,-1); |
508 | if (kthread_should_stop() || signal_pending(current)) | 511 | if (kthread_should_stop()) |
509 | goto done; | 512 | goto done; |
510 | 513 | ||
511 | restart: | 514 | restart: |
515 | try_to_freeze(); | ||
516 | |||
512 | dev->thread.scan1 = dev->thread.scan2; | 517 | dev->thread.scan1 = dev->thread.scan2; |
513 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); | 518 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); |
514 | dev->tvaudio = NULL; | 519 | dev->tvaudio = NULL; |
@@ -612,9 +617,12 @@ static int tvaudio_thread(void *data) | |||
612 | 617 | ||
613 | lastmode = 42; | 618 | lastmode = 42; |
614 | for (;;) { | 619 | for (;;) { |
620 | |||
621 | try_to_freeze(); | ||
622 | |||
615 | if (tvaudio_sleep(dev,5000)) | 623 | if (tvaudio_sleep(dev,5000)) |
616 | goto restart; | 624 | goto restart; |
617 | if (kthread_should_stop() || signal_pending(current)) | 625 | if (kthread_should_stop()) |
618 | break; | 626 | break; |
619 | if (UNSET == dev->thread.mode) { | 627 | if (UNSET == dev->thread.mode) { |
620 | rx = tvaudio_getstereo(dev,&tvaudio[i]); | 628 | rx = tvaudio_getstereo(dev,&tvaudio[i]); |
@@ -630,6 +638,7 @@ static int tvaudio_thread(void *data) | |||
630 | } | 638 | } |
631 | 639 | ||
632 | done: | 640 | done: |
641 | dev->thread.stopped = 1; | ||
633 | return 0; | 642 | return 0; |
634 | } | 643 | } |
635 | 644 | ||
@@ -777,7 +786,8 @@ static int tvaudio_thread_ddep(void *data) | |||
777 | struct saa7134_dev *dev = data; | 786 | struct saa7134_dev *dev = data; |
778 | u32 value, norms, clock; | 787 | u32 value, norms, clock; |
779 | 788 | ||
780 | allow_signal(SIGTERM); | 789 | |
790 | set_freezable(); | ||
781 | 791 | ||
782 | clock = saa7134_boards[dev->board].audio_clock; | 792 | clock = saa7134_boards[dev->board].audio_clock; |
783 | if (UNSET != audio_clock_override) | 793 | if (UNSET != audio_clock_override) |
@@ -790,10 +800,13 @@ static int tvaudio_thread_ddep(void *data) | |||
790 | 800 | ||
791 | for (;;) { | 801 | for (;;) { |
792 | tvaudio_sleep(dev,-1); | 802 | tvaudio_sleep(dev,-1); |
793 | if (kthread_should_stop() || signal_pending(current)) | 803 | if (kthread_should_stop()) |
794 | goto done; | 804 | goto done; |
795 | 805 | ||
796 | restart: | 806 | restart: |
807 | |||
808 | try_to_freeze(); | ||
809 | |||
797 | dev->thread.scan1 = dev->thread.scan2; | 810 | dev->thread.scan1 = dev->thread.scan2; |
798 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); | 811 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); |
799 | 812 | ||
@@ -870,6 +883,7 @@ static int tvaudio_thread_ddep(void *data) | |||
870 | } | 883 | } |
871 | 884 | ||
872 | done: | 885 | done: |
886 | dev->thread.stopped = 1; | ||
873 | return 0; | 887 | return 0; |
874 | } | 888 | } |
875 | 889 | ||
@@ -997,7 +1011,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
997 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) | 1011 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) |
998 | { | 1012 | { |
999 | /* shutdown tvaudio thread */ | 1013 | /* shutdown tvaudio thread */ |
1000 | if (dev->thread.thread) | 1014 | if (dev->thread.thread && !dev->thread.stopped) |
1001 | kthread_stop(dev->thread.thread); | 1015 | kthread_stop(dev->thread.thread); |
1002 | 1016 | ||
1003 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ | 1017 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ |
@@ -1013,7 +1027,9 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) | |||
1013 | } else if (dev->thread.thread) { | 1027 | } else if (dev->thread.thread) { |
1014 | dev->thread.mode = UNSET; | 1028 | dev->thread.mode = UNSET; |
1015 | dev->thread.scan2++; | 1029 | dev->thread.scan2++; |
1016 | wake_up_process(dev->thread.thread); | 1030 | |
1031 | if (!dev->insuspend && !dev->thread.stopped) | ||
1032 | wake_up_process(dev->thread.thread); | ||
1017 | } else { | 1033 | } else { |
1018 | dev->automute = 0; | 1034 | dev->automute = 0; |
1019 | saa7134_tvaudio_setmute(dev); | 1035 | saa7134_tvaudio_setmute(dev); |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index fe0a8439b878..66a390c321a7 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -333,6 +333,7 @@ struct saa7134_thread { | |||
333 | unsigned int scan1; | 333 | unsigned int scan1; |
334 | unsigned int scan2; | 334 | unsigned int scan2; |
335 | unsigned int mode; | 335 | unsigned int mode; |
336 | unsigned int stopped; | ||
336 | }; | 337 | }; |
337 | 338 | ||
338 | /* buffer for one video/vbi/ts frame */ | 339 | /* buffer for one video/vbi/ts frame */ |