Re: [PATCH] bw-qcam: adds parameter aggressive to skip passive detection and directly attempt initialization

2007-12-05 Thread Brett Warden
On Dec 5, 2007 9:37 AM, Alan Cox <[EMAIL PROTECTED]> wrote:

> Although I would suggest that "aggressive" may not be the best term - I'm
> not such of a good one however - skip_passive ?

How about force_init?

-- 
Brett Warden
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: Adds module parameter 'aggressive' to skip polite auto-detection prior to direct initialization.

2007-12-05 Thread Brett Warden
Sorry, forgot to copy back to the lists.

On Dec 5, 2007 8:49 AM, Brett Warden <[EMAIL PROTECTED]> wrote:
> On Dec 4, 2007 4:46 PM, Alan Cox <[EMAIL PROTECTED]> wrote:
> >
> > Someone still has a bw-qcam device ?
>
> Yes. I haven't found a better option for very-low-light, although I
> admit I haven't looked in a long while. The last one I tried was an
> OV518+, but of course that driver seems to have been abandoned.
>
> > The status polling ought to be rock solid - what values do you see ?
>
> It has been as high as 94-96, but after being connected, powered, and
> used for a while, it drops sometimes into the 40s, but has even been
> as low as 8-14. When it's that low, it never comes back up until
> either I disconnect/reconnect the power, or I force the driver to
> initialize it through this hack. Even after trying that again just
> now, it's ranging from 24-33.
>
> --
> Brett Warden
>



-- 
Brett Warden
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: adds parameter aggressive to skip passive detection and directly attempt initialization

2007-12-05 Thread Brett Warden
On Dec 5, 2007 9:37 AM, Alan Cox [EMAIL PROTECTED] wrote:

 Although I would suggest that aggressive may not be the best term - I'm
 not such of a good one however - skip_passive ?

How about force_init?

-- 
Brett Warden
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: Adds module parameter 'aggressive' to skip polite auto-detection prior to direct initialization.

2007-12-05 Thread Brett Warden
Sorry, forgot to copy back to the lists.

On Dec 5, 2007 8:49 AM, Brett Warden [EMAIL PROTECTED] wrote:
 On Dec 4, 2007 4:46 PM, Alan Cox [EMAIL PROTECTED] wrote:
 
  Someone still has a bw-qcam device ?

 Yes. I haven't found a better option for very-low-light, although I
 admit I haven't looked in a long while. The last one I tried was an
 OV518+, but of course that driver seems to have been abandoned.

  The status polling ought to be rock solid - what values do you see ?

 It has been as high as 94-96, but after being connected, powered, and
 used for a while, it drops sometimes into the 40s, but has even been
 as low as 8-14. When it's that low, it never comes back up until
 either I disconnect/reconnect the power, or I force the driver to
 initialize it through this hack. Even after trying that again just
 now, it's ranging from 24-33.

 --
 Brett Warden




-- 
Brett Warden
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-27 Thread Brett Warden
Fixes use of parport_write_control() to match the newer interface that
requires explicit parport_data_reverse() and parport_data_forward()
calls. This eliminates the following error message and restores the
original intended behavior:

parport0 (bw-qcam): use data_reverse for this!

Also increases threshold in qc_detect() from 300 to 400, as my camera
often results in a count of approx 330. Added a kernel error message
to indicate detection failure.

Signed-off-by: Brett T. Warden <[EMAIL PROTECTED]>

---

Thanks Ray and Randy for your comments, and for pointing out that I
needed to reset the port to forward mode!

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..961e377 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -104,6 +104,17 @@ static inline void write_lpdata(struct
qcam_device *q, int d)

 static inline void write_lpcontrol(struct qcam_device *q, int d)
 {
+   if(0x20 & d) {
+   /* Set bidirectional mode to reverse (data in) */
+   parport_data_reverse(q->pport);
+   } else {
+   /* Set bidirectional mode to forward (data out) */
+   parport_data_forward(q->pport);
+   }
+
+   /* Now issue the regular port command, but strip out the
+* direction flag */
+   d &= ~0x20;
parport_write_control(q->pport, d);
 }

@@ -344,10 +355,13 @@ static int qc_detect(struct qcam_device *q)
/* Be (even more) liberal in what you accept...  */

 /* if (count > 30 && count < 200) */
-   if (count > 20 && count < 300)
+   if (count > 20 && count < 400)
+   {
return 1;   /* found */
-   else
+   } else {
+   printk(KERN_ERR "No Quickcam found on port %s\n",
q->pport->name);
    return 0;   /* not found */
+   }
 }





-- 
Brett Warden
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-27 Thread Brett Warden
Fixes use of parport_write_control() to match the newer interface that
requires explicit parport_data_reverse() and parport_data_forward()
calls. This eliminates the following error message and restores the
original intended behavior:

parport0 (bw-qcam): use data_reverse for this!

Also increases threshold in qc_detect() from 300 to 400, as my camera
often results in a count of approx 330. Added a kernel error message
to indicate detection failure.

Signed-off-by: Brett T. Warden [EMAIL PROTECTED]

---

Thanks Ray and Randy for your comments, and for pointing out that I
needed to reset the port to forward mode!

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..961e377 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -104,6 +104,17 @@ static inline void write_lpdata(struct
qcam_device *q, int d)

 static inline void write_lpcontrol(struct qcam_device *q, int d)
 {
+   if(0x20  d) {
+   /* Set bidirectional mode to reverse (data in) */
+   parport_data_reverse(q-pport);
+   } else {
+   /* Set bidirectional mode to forward (data out) */
+   parport_data_forward(q-pport);
+   }
+
+   /* Now issue the regular port command, but strip out the
+* direction flag */
+   d = ~0x20;
parport_write_control(q-pport, d);
 }

@@ -344,10 +355,13 @@ static int qc_detect(struct qcam_device *q)
/* Be (even more) liberal in what you accept...  */

 /* if (count  30  count  200) */
-   if (count  20  count  300)
+   if (count  20  count  400)
+   {
return 1;   /* found */
-   else
+   } else {
+   printk(KERN_ERR No Quickcam found on port %s\n,
q-pport-name);
return 0;   /* not found */
+   }
 }





-- 
Brett Warden
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
On 9/26/07, Ray Lee <[EMAIL PROTECTED]> wrote:
> On 9/26/07, Brett Warden <[EMAIL PROTECTED]> wrote:
> > On 9/26/07, Ray Lee <[EMAIL PROTECTED]> wrote:
> >
> > > Just as an aside, if you've tested this and it works, then there's no
> > > point to keep the write_lpcontrol even as a comment. Kill those four
> > > lines, and if someone's interested in what happened they'll just look
> > > at the file history.
> >
> > Point taken, thanks for the feedback.
> >
> > ---
> >
> > diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
> > index 7d47cbe..0ba92e3 100644
> > --- a/drivers/media/video/bw-qcam.c
> > +++ b/drivers/media/video/bw-qcam.c
> > @@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
> > qcam_device *q, int d)
> > parport_write_control(q->pport, d);
> >  }
> >
> > +static inline void reverse_port(struct qcam_device *q)
> > +{
> > +   parport_data_reverse(q->pport);
> > +}
> > +
> >  static int qc_waithand(struct qcam_device *q, int val);
> >  static int qc_command(struct qcam_device *q, int command);
> >  static int qc_readparam(struct qcam_device *q);
> > @@ -369,7 +374,7 @@ static void qc_reset(struct qcam_device *q)
> > break;
> >
> > case QC_ANY:
> > -   write_lpcontrol(q, 0x20);
> > +   reverse_port(q);
> > write_lpdata(q, 0x75);
> >
> > if (read_lpdata(q) != 0x75) {
> > @@ -512,10 +517,12 @@ static inline int qc_readbytes(struct
> > qcam_device *q, char buffer[])
> > switch (q->port_mode & QC_MODE_MASK)
> > {
> > case QC_BIDIR:  /* Bi-directional Port */
> > -   write_lpcontrol(q, 0x26);
> > +   reverse_port(q);
> > +   write_lpcontrol(q, 0x6);
> > lo = (qc_waithand2(q, 1) >> 1);
> > hi = (read_lpstatus(q) >> 3) & 0x1f;
> > -   write_lpcontrol(q, 0x2e);
> > +   reverse_port(q);
> > +   write_lpcontrol(q, 0xe);
> > lo2 = (qc_waithand2(q, 0) >> 1);
> > hi2 = (read_lpstatus(q) >> 3) & 0x1f;
> > switch (q->bpp)
> > @@ -613,10 +620,13 @@ static long qc_capture(struct qcam_device * q,
> > char __user *buf, unsigned long l
> >
> > if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
> > {
> > -   write_lpcontrol(q, 0x2e);   /* turn port around */
> > -   write_lpcontrol(q, 0x26);
> > +   reverse_port(q);/* turn port around 
> > */
> > +   write_lpcontrol(q, 0xe);
> > +   reverse_port(q);
> > +   write_lpcontrol(q, 0x6);
> > (void) qc_waithand(q, 1);
> > -   write_lpcontrol(q, 0x2e);
> > +   reverse_port(q);
> > +   write_lpcontrol(q, 0xe);
> > (void) qc_waithand(q, 0);
> > }
>
> Better, and do you have time for two (possibly stupid) questions? In
> each of the last cases it looks like the transformation is from a
> write_lpcontrol -> reverse_port and a write_lpcontrol (old address -
> 0x20). Except the first one, which merely has the reverse_port. One
> would think that there should be a write_lpcontrol(q, 0x0); after that
> one.
>
> Also, is the reverse port sticky, or does it only apply to the next
> write? If it's only the next, then maybe a different name would be
> better. If it's sticky, then I think the code is wrong...

In response to Randy's and your questions, here's what I understand:

The error message comes from parport_pc_write_control in
include/linux/parport_pc.h, which is called by bw-qcam's
write_lpcontrol():

static __inline__ void parport_pc_write_control (struct parport *p,
 unsigned char d)
{
const unsigned char wm = (PARPORT_CONTROL_STROBE |
  PARPORT_CONTROL_AUTOFD |
  PARPORT_CONTROL_INIT |
  PARPORT_CONTROL_SELECT);

/* Take this out when drivers have adapted to newer interface. */
if (d & 0x20) {
printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
    p->name, p->cad->name);
parport_pc_data_reverse (p);
}

__parport_pc_frob_control (p, wm, d & wm);
}


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
On 9/26/07, Ray Lee <[EMAIL PROTECTED]> wrote:

> Just as an aside, if you've tested this and it works, then there's no
> point to keep the write_lpcontrol even as a comment. Kill those four
> lines, and if someone's interested in what happened they'll just look
> at the file history.

Point taken, thanks for the feedback.

---

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..0ba92e3 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
qcam_device *q, int d)
parport_write_control(q->pport, d);
 }

+static inline void reverse_port(struct qcam_device *q)
+{
+   parport_data_reverse(q->pport);
+}
+
 static int qc_waithand(struct qcam_device *q, int val);
 static int qc_command(struct qcam_device *q, int command);
 static int qc_readparam(struct qcam_device *q);
@@ -369,7 +374,7 @@ static void qc_reset(struct qcam_device *q)
break;

case QC_ANY:
-   write_lpcontrol(q, 0x20);
+   reverse_port(q);
write_lpdata(q, 0x75);

if (read_lpdata(q) != 0x75) {
@@ -512,10 +517,12 @@ static inline int qc_readbytes(struct
qcam_device *q, char buffer[])
switch (q->port_mode & QC_MODE_MASK)
{
case QC_BIDIR:  /* Bi-directional Port */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
lo = (qc_waithand2(q, 1) >> 1);
hi = (read_lpstatus(q) >> 3) & 0x1f;
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
lo2 = (qc_waithand2(q, 0) >> 1);
hi2 = (read_lpstatus(q) >> 3) & 0x1f;
switch (q->bpp)
@@ -613,10 +620,13 @@ static long qc_capture(struct qcam_device * q,
char __user *buf, unsigned long l

if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
{
-   write_lpcontrol(q, 0x2e);   /* turn port around */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);/* turn port around */
+   write_lpcontrol(q, 0xe);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
(void) qc_waithand(q, 1);
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
(void) qc_waithand(q, 0);
}




-- 
Brett Warden
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
Appeases the warning "parport0 (bw-qcam): use data_reverse for this!"

Signed-off-by: Brett T. Warden <[EMAIL PROTECTED]>

---

It seems to work fine with my Quickcam under 2.6.22.

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..01e47ed 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
qcam_device *q, int d)
parport_write_control(q->pport, d);
 }

+static inline void reverse_port(struct qcam_device *q)
+{
+   parport_data_reverse(q->pport);
+}
+
 static int qc_waithand(struct qcam_device *q, int val);
 static int qc_command(struct qcam_device *q, int command);
 static int qc_readparam(struct qcam_device *q);
@@ -369,7 +374,11 @@ static void qc_reset(struct qcam_device *q)
break;

case QC_ANY:
-   write_lpcontrol(q, 0x20);
+   /*
+* Replaced with reverse_port
+* write_lpcontrol(q, 0x20);
+*/
+   reverse_port(q);
write_lpdata(q, 0x75);

if (read_lpdata(q) != 0x75) {
@@ -512,10 +521,12 @@ static inline int qc_readbytes(struct
qcam_device *q, char buffer[])
switch (q->port_mode & QC_MODE_MASK)
{
case QC_BIDIR:  /* Bi-directional Port */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
lo = (qc_waithand2(q, 1) >> 1);
hi = (read_lpstatus(q) >> 3) & 0x1f;
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
lo2 = (qc_waithand2(q, 0) >> 1);
hi2 = (read_lpstatus(q) >> 3) & 0x1f;
switch (q->bpp)
@@ -613,10 +624,13 @@ static long qc_capture(struct qcam_device * q,
char __user *buf, unsigned long l

if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
{
-   write_lpcontrol(q, 0x2e);   /* turn port around */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);/* turn port around */
+   write_lpcontrol(q, 0xe);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
(void) qc_waithand(q, 1);
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
(void) qc_waithand(q, 0);
}



-- 
Brett Warden
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
Appeases the warning parport0 (bw-qcam): use data_reverse for this!

Signed-off-by: Brett T. Warden [EMAIL PROTECTED]

---

It seems to work fine with my Quickcam under 2.6.22.

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..01e47ed 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
qcam_device *q, int d)
parport_write_control(q-pport, d);
 }

+static inline void reverse_port(struct qcam_device *q)
+{
+   parport_data_reverse(q-pport);
+}
+
 static int qc_waithand(struct qcam_device *q, int val);
 static int qc_command(struct qcam_device *q, int command);
 static int qc_readparam(struct qcam_device *q);
@@ -369,7 +374,11 @@ static void qc_reset(struct qcam_device *q)
break;

case QC_ANY:
-   write_lpcontrol(q, 0x20);
+   /*
+* Replaced with reverse_port
+* write_lpcontrol(q, 0x20);
+*/
+   reverse_port(q);
write_lpdata(q, 0x75);

if (read_lpdata(q) != 0x75) {
@@ -512,10 +521,12 @@ static inline int qc_readbytes(struct
qcam_device *q, char buffer[])
switch (q-port_mode  QC_MODE_MASK)
{
case QC_BIDIR:  /* Bi-directional Port */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
lo = (qc_waithand2(q, 1)  1);
hi = (read_lpstatus(q)  3)  0x1f;
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
lo2 = (qc_waithand2(q, 0)  1);
hi2 = (read_lpstatus(q)  3)  0x1f;
switch (q-bpp)
@@ -613,10 +624,13 @@ static long qc_capture(struct qcam_device * q,
char __user *buf, unsigned long l

if ((q-port_mode  QC_MODE_MASK) == QC_BIDIR)
{
-   write_lpcontrol(q, 0x2e);   /* turn port around */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);/* turn port around */
+   write_lpcontrol(q, 0xe);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
(void) qc_waithand(q, 1);
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
(void) qc_waithand(q, 0);
}



-- 
Brett Warden
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
On 9/26/07, Ray Lee [EMAIL PROTECTED] wrote:

 Just as an aside, if you've tested this and it works, then there's no
 point to keep the write_lpcontrol even as a comment. Kill those four
 lines, and if someone's interested in what happened they'll just look
 at the file history.

Point taken, thanks for the feedback.

---

diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 7d47cbe..0ba92e3 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
qcam_device *q, int d)
parport_write_control(q-pport, d);
 }

+static inline void reverse_port(struct qcam_device *q)
+{
+   parport_data_reverse(q-pport);
+}
+
 static int qc_waithand(struct qcam_device *q, int val);
 static int qc_command(struct qcam_device *q, int command);
 static int qc_readparam(struct qcam_device *q);
@@ -369,7 +374,7 @@ static void qc_reset(struct qcam_device *q)
break;

case QC_ANY:
-   write_lpcontrol(q, 0x20);
+   reverse_port(q);
write_lpdata(q, 0x75);

if (read_lpdata(q) != 0x75) {
@@ -512,10 +517,12 @@ static inline int qc_readbytes(struct
qcam_device *q, char buffer[])
switch (q-port_mode  QC_MODE_MASK)
{
case QC_BIDIR:  /* Bi-directional Port */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
lo = (qc_waithand2(q, 1)  1);
hi = (read_lpstatus(q)  3)  0x1f;
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
lo2 = (qc_waithand2(q, 0)  1);
hi2 = (read_lpstatus(q)  3)  0x1f;
switch (q-bpp)
@@ -613,10 +620,13 @@ static long qc_capture(struct qcam_device * q,
char __user *buf, unsigned long l

if ((q-port_mode  QC_MODE_MASK) == QC_BIDIR)
{
-   write_lpcontrol(q, 0x2e);   /* turn port around */
-   write_lpcontrol(q, 0x26);
+   reverse_port(q);/* turn port around */
+   write_lpcontrol(q, 0xe);
+   reverse_port(q);
+   write_lpcontrol(q, 0x6);
(void) qc_waithand(q, 1);
-   write_lpcontrol(q, 0x2e);
+   reverse_port(q);
+   write_lpcontrol(q, 0xe);
(void) qc_waithand(q, 0);
}




-- 
Brett Warden
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] bw-qcam: use data_reverse instead of manually poking the control register

2007-09-26 Thread Brett Warden
On 9/26/07, Ray Lee [EMAIL PROTECTED] wrote:
 On 9/26/07, Brett Warden [EMAIL PROTECTED] wrote:
  On 9/26/07, Ray Lee [EMAIL PROTECTED] wrote:
 
   Just as an aside, if you've tested this and it works, then there's no
   point to keep the write_lpcontrol even as a comment. Kill those four
   lines, and if someone's interested in what happened they'll just look
   at the file history.
 
  Point taken, thanks for the feedback.
 
  ---
 
  diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
  index 7d47cbe..0ba92e3 100644
  --- a/drivers/media/video/bw-qcam.c
  +++ b/drivers/media/video/bw-qcam.c
  @@ -107,6 +107,11 @@ static inline void write_lpcontrol(struct
  qcam_device *q, int d)
  parport_write_control(q-pport, d);
   }
 
  +static inline void reverse_port(struct qcam_device *q)
  +{
  +   parport_data_reverse(q-pport);
  +}
  +
   static int qc_waithand(struct qcam_device *q, int val);
   static int qc_command(struct qcam_device *q, int command);
   static int qc_readparam(struct qcam_device *q);
  @@ -369,7 +374,7 @@ static void qc_reset(struct qcam_device *q)
  break;
 
  case QC_ANY:
  -   write_lpcontrol(q, 0x20);
  +   reverse_port(q);
  write_lpdata(q, 0x75);
 
  if (read_lpdata(q) != 0x75) {
  @@ -512,10 +517,12 @@ static inline int qc_readbytes(struct
  qcam_device *q, char buffer[])
  switch (q-port_mode  QC_MODE_MASK)
  {
  case QC_BIDIR:  /* Bi-directional Port */
  -   write_lpcontrol(q, 0x26);
  +   reverse_port(q);
  +   write_lpcontrol(q, 0x6);
  lo = (qc_waithand2(q, 1)  1);
  hi = (read_lpstatus(q)  3)  0x1f;
  -   write_lpcontrol(q, 0x2e);
  +   reverse_port(q);
  +   write_lpcontrol(q, 0xe);
  lo2 = (qc_waithand2(q, 0)  1);
  hi2 = (read_lpstatus(q)  3)  0x1f;
  switch (q-bpp)
  @@ -613,10 +620,13 @@ static long qc_capture(struct qcam_device * q,
  char __user *buf, unsigned long l
 
  if ((q-port_mode  QC_MODE_MASK) == QC_BIDIR)
  {
  -   write_lpcontrol(q, 0x2e);   /* turn port around */
  -   write_lpcontrol(q, 0x26);
  +   reverse_port(q);/* turn port around 
  */
  +   write_lpcontrol(q, 0xe);
  +   reverse_port(q);
  +   write_lpcontrol(q, 0x6);
  (void) qc_waithand(q, 1);
  -   write_lpcontrol(q, 0x2e);
  +   reverse_port(q);
  +   write_lpcontrol(q, 0xe);
  (void) qc_waithand(q, 0);
  }

 Better, and do you have time for two (possibly stupid) questions? In
 each of the last cases it looks like the transformation is from a
 write_lpcontrol - reverse_port and a write_lpcontrol (old address -
 0x20). Except the first one, which merely has the reverse_port. One
 would think that there should be a write_lpcontrol(q, 0x0); after that
 one.

 Also, is the reverse port sticky, or does it only apply to the next
 write? If it's only the next, then maybe a different name would be
 better. If it's sticky, then I think the code is wrong...

In response to Randy's and your questions, here's what I understand:

The error message comes from parport_pc_write_control in
include/linux/parport_pc.h, which is called by bw-qcam's
write_lpcontrol():

static __inline__ void parport_pc_write_control (struct parport *p,
 unsigned char d)
{
const unsigned char wm = (PARPORT_CONTROL_STROBE |
  PARPORT_CONTROL_AUTOFD |
  PARPORT_CONTROL_INIT |
  PARPORT_CONTROL_SELECT);

/* Take this out when drivers have adapted to newer interface. */
if (d  0x20) {
printk (KERN_DEBUG %s (%s): use data_reverse for this!\n,
p-name, p-cad-name);
parport_pc_data_reverse (p);
}

__parport_pc_frob_control (p, wm, d  wm);
}

The mask wm works out to 0x0f, so first it calls
parport_pc_data_reverse(), then masks off the high nibble with the
reverse flag and makes the regular call.

Looking at that more carefully, I'm not sure whether I need to add the
write_lpcontrol(q, 0) after the first call. Other than that, I believe
I'm following the same procedure.

As for whether data_reverse is sticky, I don't know... I'll see what I
can find out.

-- 
Brett Warden
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/