public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: video4linux-list@redhat.com
Subject: Re: What todo with cams which have 2 drivers?
Date: Tue, 26 Aug 2008 23:26:41 +0200	[thread overview]
Message-ID: <48B47511.4010008@hhs.nl> (raw)
In-Reply-To: <200808262235.12292.hverkuil@xs4all.nl>

Hans Verkuil wrote:
> 
> In general I am getting worried by the lack of a common standard to
> interface to sensor and controller drivers. I'm no expert on webcams, so
> correct me if I'm wrong, but it seems to me that the correct design would
> be to have a generic API to these devices that can be used by the various
> USB or platform drivers.
> 
> But for e.g. the mt9* sensors we have three that use the soc_camera
> interface, one using the sn9c102 interface and I know of two more that
> are not yet in v4l-dvb but that will use the v4l2-int-device.h interface.
> It's a mess in my opinion.
> 

It is indeed, in my experience so far the easiest solution is to see the bridge 
and sensor (and this the whole cam) as one device. 80% of the per sensor code 
in a bridge driver is setting up the bridge to talk to the cam (there are 
various connections between the 2 possible and most bridges support multiple 
connection types) and 80% of the sensor code is configuring the sensor for a 
specific bridge (same story). The remaining 20% of sensor code is rather boring 
  (poking registers to set things like conteast and brightness) and since the 
sensor needs to be programmed to talk to the bridge in a bridge specific way 
there is little to gain from having seperate sensor drivers as those still need 
to be patched for a new bridge type before the sensor will work with a certain 
bridge.

If you for example look at the attempting to be generic ovchipcam drivers in 
the current kernel tree, which contain code for the ov6xxx and ov7xxx sensors, 
then the attach routine contains the following:

         switch (adap->id) {
         case I2C_HW_SMBUS_OV511:
         case I2C_HW_SMBUS_OV518:
         case I2C_HW_SMBUS_W9968CF:
                 PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id);
                 break;
         default:
                 PDEBUG(1, "Adapter ID 0x%06x rejected", adap->id);
                 return -ENODEV;
         }

IOW this generic sensor code will only work with 3 know bridges and some of the 
code itself is bridge specific too, for example in ov6x30.c :

         if (win->format == VIDEO_PALETTE_GREY) {
                 if (c->adapter->id == I2C_HW_SMBUS_OV518) {
                         /* Do nothing - we're already in 8-bit mode */
                 } else {
                         ov_write_mask(c, 0x13, 0x20, 0x20);
                 }
         } else {
                 /* The OV518 needs special treatment. Although both the OV518
                  * and the OV6630 support a 16-bit video bus, only the 8 bit Y
                  * bus is actually used. The UV bus is tied to ground.
                  * Therefore, the OV6630 needs to be in 8-bit multiplexed
                  * output mode */

                 if (c->adapter->id == I2C_HW_SMBUS_OV518) {
                         /* Do nothing - we want to stay in 8-bit mode */
                         /* Warning: Messing with reg 0x13 breaks OV518 color */
                 } else {
                         ov_write_mask(c, 0x13, 0x00, 0x20);
                 }
         }

I've done a comparison of code size between trying to use generic sensor code 
(which isn't that generic at all see above) and just putting sensor specific 
code into each bridge driver separately, see:
http://marc.info/?l=linux-video&m=121645882518114&w=2

So my conclusion (for now) is that trying to separate the sensor code out of 
the bridge drivers is not worth it. I plan to rewrite the ov511/ov518 driver 
for v4l2 using gspca (so that libv4l can be used to decode the special JPEG-ish 
format making these cams actually work). For this rewrite I will probably 
remove the ovcamchip stuff and just put sensor init and ctrl code in the bridge 
driver, probably resulting in a smaller driver.

> I think it would be interesting to discuss this further with you in Portland.

Yes it would, I think we need to make an agenda what we want to discuss (both 
in the miniconf and outside of that).

Regards,

Hans

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  reply	other threads:[~2008-08-26 21:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26  8:03 What todo with cams which have 2 drivers? Hans de Goede
2008-08-26 20:35 ` Hans Verkuil
2008-08-26 21:26   ` Hans de Goede [this message]
2008-08-26 21:57     ` Hans Verkuil
2008-08-28 17:07     ` Thierry Merle

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=48B47511.4010008@hhs.nl \
    --to=j.w.r.degoede@hhs.nl \
    --cc=hverkuil@xs4all.nl \
    --cc=video4linux-list@redhat.com \
    /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