From: Johannes Stezenbach <js@linuxtv.org>

Fix for CAMs on Typhoon DVB-S, where it would constantly reset itself.
(Kenneth Aafloy)

Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/media/dvb/dvb-core/dvb_ca_en50221.c |    2 +-
 25-akpm/drivers/media/dvb/ttpci/budget-av.c         |   13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff -puN drivers/media/dvb/dvb-core/dvb_ca_en50221.c~dvb-fix-cams-on-typhoon-dvb-s drivers/media/dvb/dvb-core/dvb_ca_en50221.c
--- 25/drivers/media/dvb/dvb-core/dvb_ca_en50221.c~dvb-fix-cams-on-typhoon-dvb-s	2005-03-21 20:58:22.000000000 -0800
+++ 25-akpm/drivers/media/dvb/dvb-core/dvb_ca_en50221.c	2005-03-21 20:58:22.000000000 -0800
@@ -974,7 +974,7 @@ static void dvb_ca_en50221_thread_update
 			if (ca->open) {
 				if ((!ca->slot_info[slot].da_irq_supported) ||
 				    (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) {
-					delay = HZ / 100;
+					delay = HZ / 10;
 				}
 			}
 			break;
diff -puN drivers/media/dvb/ttpci/budget-av.c~dvb-fix-cams-on-typhoon-dvb-s drivers/media/dvb/ttpci/budget-av.c
--- 25/drivers/media/dvb/ttpci/budget-av.c~dvb-fix-cams-on-typhoon-dvb-s	2005-03-21 20:58:22.000000000 -0800
+++ 25-akpm/drivers/media/dvb/ttpci/budget-av.c	2005-03-21 20:58:22.000000000 -0800
@@ -121,6 +121,8 @@ static int ciintf_read_attribute_mem(str
 		return -EINVAL;
 
 	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
+	udelay(1);
+
 	result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 0);
 
 	if (result == -ETIMEDOUT)
@@ -137,6 +139,8 @@ static int ciintf_write_attribute_mem(st
 		return -EINVAL;
 
 	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
+	udelay(1);
+
 	result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 0);
 
 	if (result == -ETIMEDOUT)
@@ -153,6 +157,8 @@ static int ciintf_read_cam_control(struc
 		return -EINVAL;
 
 	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+	udelay(1);
+
 	result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
 
 	if (result == -ETIMEDOUT)
@@ -169,6 +175,8 @@ static int ciintf_write_cam_control(stru
 		return -EINVAL;
 
 	saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+	udelay(1);
+
 	result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
 
 	if (result == -ETIMEDOUT)
@@ -190,7 +198,10 @@ static int ciintf_slot_reset(struct dvb_
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
 	msleep(100);
 	saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
-	msleep(2000);		/* horrendous I know, but its the only way to be absolutely sure without an IRQ line! */
+
+	int max = 20;
+	while (--max > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d)
+		msleep(100);
 
 	ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
 	return 0;
_