diff options
author | Andy Walls <awalls@radix.net> | 2008-08-23 15:42:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:53 -0400 |
commit | d3c5e7075508a6874d1a53d0a409b0bbbe3a9fbe (patch) | |
tree | a9e6884ac71641938abc1866e5d81f607bd5f907 /drivers/media/video/cx18/cx18-fileops.c | |
parent | b04bce476c57ac844962462ee4c813c44fa942cf (diff) |
V4L/DVB (8773): cx18: Fix cx18_find_handle() and add error checking
cx18: Fix cx18_find_handle() and add error checking. cx18_find_handle() did
not find a good task handle and would use the invalid task handle under common
conditions. Added a define for the invalid task handle and added error checking
as well.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-fileops.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-fileops.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index eb0144f95562..5f9089907544 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
@@ -132,6 +132,7 @@ static void cx18_dualwatch(struct cx18 *cx) | |||
132 | u16 new_stereo_mode; | 132 | u16 new_stereo_mode; |
133 | const u16 stereo_mask = 0x0300; | 133 | const u16 stereo_mask = 0x0300; |
134 | const u16 dual = 0x0200; | 134 | const u16 dual = 0x0200; |
135 | u32 h; | ||
135 | 136 | ||
136 | new_stereo_mode = cx->params.audio_properties & stereo_mask; | 137 | new_stereo_mode = cx->params.audio_properties & stereo_mask; |
137 | memset(&vt, 0, sizeof(vt)); | 138 | memset(&vt, 0, sizeof(vt)); |
@@ -143,13 +144,21 @@ static void cx18_dualwatch(struct cx18 *cx) | |||
143 | if (new_stereo_mode == cx->dualwatch_stereo_mode) | 144 | if (new_stereo_mode == cx->dualwatch_stereo_mode) |
144 | return; | 145 | return; |
145 | 146 | ||
146 | new_bitmap = new_stereo_mode | (cx->params.audio_properties & ~stereo_mask); | 147 | new_bitmap = new_stereo_mode |
148 | | (cx->params.audio_properties & ~stereo_mask); | ||
147 | 149 | ||
148 | CX18_DEBUG_INFO("dualwatch: change stereo flag from 0x%x to 0x%x. new audio_bitmask=0x%ux\n", | 150 | CX18_DEBUG_INFO("dualwatch: change stereo flag from 0x%x to 0x%x. " |
149 | cx->dualwatch_stereo_mode, new_stereo_mode, new_bitmap); | 151 | "new audio_bitmask=0x%ux\n", |
152 | cx->dualwatch_stereo_mode, new_stereo_mode, new_bitmap); | ||
150 | 153 | ||
151 | if (cx18_vapi(cx, CX18_CPU_SET_AUDIO_PARAMETERS, 2, | 154 | h = cx18_find_handle(cx); |
152 | cx18_find_handle(cx), new_bitmap) == 0) { | 155 | if (h == CX18_INVALID_TASK_HANDLE) { |
156 | CX18_DEBUG_INFO("dualwatch: can't find valid task handle\n"); | ||
157 | return; | ||
158 | } | ||
159 | |||
160 | if (cx18_vapi(cx, | ||
161 | CX18_CPU_SET_AUDIO_PARAMETERS, 2, h, new_bitmap) == 0) { | ||
153 | cx->dualwatch_stereo_mode = new_stereo_mode; | 162 | cx->dualwatch_stereo_mode = new_stereo_mode; |
154 | return; | 163 | return; |
155 | } | 164 | } |
@@ -695,20 +704,28 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp) | |||
695 | 704 | ||
696 | void cx18_mute(struct cx18 *cx) | 705 | void cx18_mute(struct cx18 *cx) |
697 | { | 706 | { |
698 | if (atomic_read(&cx->ana_capturing)) | 707 | u32 h; |
699 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, | 708 | if (atomic_read(&cx->ana_capturing)) { |
700 | cx18_find_handle(cx), 1); | 709 | h = cx18_find_handle(cx); |
710 | if (h != CX18_INVALID_TASK_HANDLE) | ||
711 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, h, 1); | ||
712 | else | ||
713 | CX18_ERR("Can't find valid task handle for mute\n"); | ||
714 | } | ||
701 | CX18_DEBUG_INFO("Mute\n"); | 715 | CX18_DEBUG_INFO("Mute\n"); |
702 | } | 716 | } |
703 | 717 | ||
704 | void cx18_unmute(struct cx18 *cx) | 718 | void cx18_unmute(struct cx18 *cx) |
705 | { | 719 | { |
720 | u32 h; | ||
706 | if (atomic_read(&cx->ana_capturing)) { | 721 | if (atomic_read(&cx->ana_capturing)) { |
707 | cx18_msleep_timeout(100, 0); | 722 | h = cx18_find_handle(cx); |
708 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, | 723 | if (h != CX18_INVALID_TASK_HANDLE) { |
709 | cx18_find_handle(cx), 12); | 724 | cx18_msleep_timeout(100, 0); |
710 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, | 725 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, h, 12); |
711 | cx18_find_handle(cx), 0); | 726 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, h, 0); |
727 | } else | ||
728 | CX18_ERR("Can't find valid task handle for unmute\n"); | ||
712 | } | 729 | } |
713 | CX18_DEBUG_INFO("Unmute\n"); | 730 | CX18_DEBUG_INFO("Unmute\n"); |
714 | } | 731 | } |