public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Abylay Ospan <aospan@netup.ru>
To: mchehab@infradead.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/5 v2] Fix CI code for NetUP Dual DVB-T/C CI RF card
Date: Sun, 02 Jan 2011 16:48:09 +0000	[thread overview]
Message-ID: <4D20AC49.3030905@netup.ru> (raw)

CI reset takes several seconds on some CAM,
so there is no need to lock mutex all that time.
Also we need not to preserve CI's reset bits in
CIBUSCTRL register, they are handled automatically by FPGA.
Set it to 0 explicitly in order to not reset wrong CAM.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
---
  drivers/media/video/cx23885/altera-ci.c |   14 ++++++++++----
  1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/cx23885/altera-ci.c 
b/drivers/media/video/cx23885/altera-ci.c
index e2c9fee..aa67a33 100644
--- a/drivers/media/video/cx23885/altera-ci.c
+++ b/drivers/media/video/cx23885/altera-ci.c
@@ -283,7 +283,7 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, 
int slot,
  	netup_fpga_op_rw(inter, NETUP_CI_ADDR1, ((addr >> 7) & 0x7f), 0);
  	store = netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL, 0, NETUP_CI_FLG_RD);
  -	store &= 0x3f;
+	store &= 0x0f;
  	store |= ((state->nr << 7) | (flag << 6));
   	netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL, store, 0);
@@ -340,19 +340,25 @@ int netup_ci_slot_reset(struct dvb_ca_en50221 
*en50221, int slot)
   	ret = netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL, 0, NETUP_CI_FLG_RD);
  	netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL,
-				ret | (1 << (5 - state->nr)), 0);
+				(ret & 0xcf) | (1 << (5 - state->nr)), 0);
+
+	mutex_unlock(&inter->fpga_mutex);
   	for (;;) {
  		mdelay(50);
+
+		mutex_lock(&inter->fpga_mutex);
+
  		ret = netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL,
  						0, NETUP_CI_FLG_RD);
+		mutex_unlock(&inter->fpga_mutex);
+
  		if ((ret & (1 << (5 - state->nr))) == 0)
  			break;
  		if (time_after(jiffies, t_out))
  			break;
  	}
  -	mutex_unlock(&inter->fpga_mutex);
   	printk("%s: %d msecs\n", __func__,
  		jiffies_to_msecs(jiffies + msecs_to_jiffies(9999) - t_out));
@@ -381,7 +387,7 @@ int netup_ci_slot_ts_ctl(struct dvb_ca_en50221 
*en50221, int slot)
   	ret = netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL, 0, NETUP_CI_FLG_RD);
  	netup_fpga_op_rw(inter, NETUP_CI_BUSCTRL,
-				ret | (1 << (3 - state->nr)), 0);
+				(ret & 0x0f) | (1 << (3 - state->nr)), 0);
   	mutex_unlock(&inter->fpga_mutex);
  -- 1.7.1


                 reply	other threads:[~2011-01-02 16:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D20AC49.3030905@netup.ru \
    --to=aospan@netup.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox