You are not logged in.

#1 2009-04-22 16:14:16

Farstar
Member
Registered: 2009-04-22
Posts: 7

Trouble with Microdia Sonix USB 2.0 Camera

I have MSI PR210 notebook with built-in webcam based on Microdia chipset. I installed Arch 2009.2 x86_64 and got pacman -Syu.

# uname -a
Linux msi-book 2.6.29-ARCH #1 SMP PREEMPT Wed Apr 8 12:39:28 CEST 2009 x86_64 AMD Turion(tm) 64 X2 Mobile Technology TL-56 AuthenticAMD GNU/Linux
# lsusb
Bus 001 Device 006: ID 0c45:62c0 Microdia Sonix USB 2.0 Camera
# dmesg | tail
usb 1-3: new high speed USB device using ehci_hcd and address 8
usb 1-3: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device USB 2.0 Camera (0c45:62c0)
uvcvideo: No valid video chain found.
# lsusb
Bus 001 Device 006: ID 0c45:62c0 Microdia Sonix USB 2.0 Camera
# lsmod
Module                  Size  Used by
radeon                152384  2 
drm                   168800  3 radeon
ext2                   72544  1 
btusb                  14180  0 
bluetooth              58788  1 btusb
sr_mod                 16804  0 
cdrom                  37832  1 sr_mod
uvcvideo               63644  0 
ata_generic             5908  0 
ide_pci_generic         4660  0 
joydev                 12160  0 
videodev               43360  1 uvcvideo
v4l1_compat            15348  2 uvcvideo,videodev
v4l2_compat_ioctl32    10896  1 videodev
pata_acpi               5168  0 
atiixp                  4308  0 
snd_seq_oss            33696  0 
snd_seq_midi_event      7248  1 snd_seq_oss
snd_seq                56672  4 snd_seq_oss,snd_seq_midi_event
snd_seq_device          7236  2 snd_seq_oss,snd_seq
ide_core              112036  2 ide_pci_generic,atiixp
snd_hda_codec_atihdmi     3984  1 
arc4                    1968  2 
ohci_hcd               25836  0 
snd_hda_codec_realtek   255828  1 
ecb                     3088  2 
i2c_piix4              10528  0 
snd_hda_intel          29352  3 
sdhci_pci               8368  0 
sdhci                  18132  1 sdhci_pci
snd_pcm_oss            43424  0 
snd_mixer_oss          16880  1 snd_pcm_oss
ehci_hcd               39612  0 
ath5k                 117428  0 
snd_hda_codec          67696  3 snd_hda_codec_atihdmi,snd_hda_codec_realtek,snd_hda_intel
psmouse                54764  0 
pcspkr                  2800  0 
snd_hwdep               8568  1 snd_hda_codec
i2c_core               24032  2 drm,i2c_piix4
mmc_core               52384  1 sdhci
snd_pcm                81176  3 snd_hda_intel,snd_pcm_oss,snd_hda_codec
serio_raw               6132  0 
usbcore               161488  5 btusb,uvcvideo,ohci_hcd,ehci_hcd
k8temp                  5328  0 
pata_atiixp             5808  0 
snd_timer              22688  2 snd_seq,snd_pcm
mac80211              177608  1 ath5k
snd                    66504  17 snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_pcm_oss,snd_mixer_oss,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
soundcore               7584  1 snd
snd_page_alloc          9728  2 snd_hda_intel,snd_pcm
led_class               4344  2 sdhci,ath5k
video                  20132  0 
cfg80211               41184  2 ath5k,mac80211
output                  3120  1 video
sg                     29664  0 
r8169                  37748  0 
mii                     5200  1 r8169
shpchp                 36204  0 
pci_hotplug            31040  1 shpchp
evdev                  11616  10 
thermal                18896  0 
fan                     5240  0 
button                  7312  0 
battery                12504  0 
ac                      4984  0 
cpufreq_ondemand        8352  1 
cpufreq_conservative     7736  0 
cpufreq_userspace       3732  0 
cpufreq_powersave       1712  0 
powernow_k8            14484  1 
freq_table              4144  2 cpufreq_ondemand,powernow_k8
processor              44712  2 thermal,powernow_k8
rtc_cmos               12056  0 
rtc_core               20100  1 rtc_cmos
rtc_lib                 2864  1 rtc_core
ext3                  140800  2 
jbd                    54104  1 ext3
mbcache                 8148  2 ext2,ext3
sd_mod                 27528  5 
ahci                   36128  4 
libata                175468  4 ata_generic,pata_acpi,pata_atiixp,ahci
scsi_mod              117784  4 sr_mod,sg,sd_mod,libata

I have no any /dev/video* and webcam doesn't work. Where to dig?

Offline

#2 2009-04-23 11:29:52

pendor
Member
From: Tucumán - Argentina
Registered: 2008-09-24
Posts: 127

Re: Trouble with Microdia Sonix USB 2.0 Camera

IIRC, that camera worked almost (almost!) out-of-the-box on my MSI VR430, supported (as expected) by the uvcvideo module.
I think I installed v4l (#pacman -S libv4l) and xawtv and that was all. Mplayer is slightly better, tho.

Offline

#3 2009-04-24 15:04:46

Farstar
Member
Registered: 2009-04-22
Posts: 7

Re: Trouble with Microdia Sonix USB 2.0 Camera

I've just reinstalled my arch system. It seems, than webcam doesn't work with kernel26-2.6.29. Now I use 2.6.28-ARCH from arch 2009.2 x86_64, no problems. There is /dev/video* and xawtv works. Fantastic...

Offline

#4 2009-04-24 20:06:04

pendor
Member
From: Tucumán - Argentina
Registered: 2008-09-24
Posts: 127

Re: Trouble with Microdia Sonix USB 2.0 Camera

That´s weird, I´m with the latest kernel (2.6.29.1-4 I think) on Arch64 and the webcam (that seems to be the same model of the one in your laptop) is working as usual on my MSI VR340.
With xawtv and mplayer (xawtv has issues with fullscreen mode).

Offline

#5 2009-04-27 18:25:01

petr.gansel
Member
From: Czech
Registered: 2008-08-17
Posts: 13

Re: Trouble with Microdia Sonix USB 2.0 Camera

I have discovered the same problem with webcam...
I don't use webcam frequently but it used to work properly

Linux ghost 2.6.29-ARCH #1 SMP PREEMPT Fri Apr 17 12:46:01 UTC 2009 i686 Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz GenuineIntel GNU/Linux

Bus 002 Device 007: ID 0c45:62c0 Microdia

usb 2-1: new high speed USB device using ehci_hcd and address 7
usb 2-1: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device USB 2.0 Camera (0c45:62c0)
uvcvideo: No valid video chain found.

Offline

#6 2009-04-28 00:38:42

pendor
Member
From: Tucumán - Argentina
Registered: 2008-09-24
Posts: 127

Re: Trouble with Microdia Sonix USB 2.0 Camera

I use Arch64, but that shouldn't be a difference (or it does?).
The kernel version is the same, hardware (besides camera) looks very similar.
From "lsusb -v":

Bus 002 Device 003: ID 0c45:62c0 Microdia Sonix USB 2.0 Camera

And it's working.
No idea what to say...

Offline

#7 2009-05-08 05:10:23

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

I'm on x86_64 with Arch64 too. Since 2.6.29 it doesn't work with the same symptoms... no ideas how to solve this too...

Offline

#8 2009-05-08 12:13:44

Farstar
Member
Registered: 2009-04-22
Posts: 7

Re: Trouble with Microdia Sonix USB 2.0 Camera

I've just saw package "gui-microdia-git" in AUR, it depends on kernel26-2.6.29.2-1. Is it our answer? Can anybody check this out?

Offline

#9 2009-05-09 05:32:11

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

For me not. This is a gui for configuring microdia-git driver options I think. With this driver my cam doesn't work too... It isn't even recognized (it's not in the supported cams list).

Offline

#10 2009-05-19 18:35:38

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

There is some hope:
http://developer.berlios.de/support/?fu … up_id=5681

Let's hope it does get to us soon...

Offline

#11 2009-05-20 07:17:41

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

I've adapted the patch to kernel 2.6.29.3 and compiled the module (on a customized vanilla 2.6.29.3 kernel). Now it loads fine, creates /dev/video0 and works. If anyone is able to make a PKGBUILD to build only the uvcvideo module, please do so, I just don't have enough time right now. Let's hope the developers of uvc include this soon.

My adapted microdia.patch:

 linux/drivers/media/video/uvc/uvc_driver.c |   24 ++++++++++++++++++++----
 linux/drivers/media/video/uvc/uvcvideo.h   |    1 +
 2 files changed, 21 insertions(+), 4 deletions(-)

Index: linux/drivers/media/video/uvc/uvc_driver.c
===================================================================
--- linux.orig/drivers/media/video/uvc/uvc_driver.c 2009-05-16 14:05:25.000000000 +0200
+++ linux/drivers/media/video/uvc/uvc_driver.c 2009-05-16 14:27:39.000000000 +0200
@@ -292,6 +292,7 @@
     unsigned char *_buffer;
     unsigned int interval;
     unsigned int i, n;
+    unsigned int format_frame;
     int _buflen;
     __u8 ftype;
 
@@ -416,8 +417,9 @@
     /* Count the number of frame descriptors to test the bFrameIndex
      * field when parsing the descriptors. We can't rely on the
      * bNumFrameDescriptors field as some cameras don't initialize it
-     * properly.
+     * properly, but save previous value for quirks case.
      */
+    format_frame = format->nframes;
     for (_buflen = buflen, _buffer = buffer;
          _buflen > 2 && _buffer[2] == ftype;
          _buflen -= _buffer[0], _buffer += _buffer[0])
@@ -446,11 +448,15 @@
                    "interface %d frame index %u out of range\n",
                    dev->udev->devnum, alts->desc.bInterfaceNumber,
                    buffer[3]);
-            return -EINVAL;
+            if(!dev->quirks & UVC_QUIRK_IGNORE_VSI_IDX_OOR)
+                return -EINVAL;
+            uvc_trace(UVC_TRACE_DESCR, "UVC_QUIRK_IGNORE_VSI_IDX_OOR supplying %d\n",
+                format_frame);
+            frame = &format->frame[format_frame];
+        } else {
+            frame = &format->frame[buffer[3] - 1];
         }
 
-        frame = &format->frame[buffer[3] - 1];
-
         frame->bFrameIndex = buffer[3];
         frame->bmCapabilities = buffer[4];
         frame->wWidth = get_unaligned_le16(&buffer[5]);
@@ -507,6 +513,7 @@
             10000000/frame->dwDefaultFrameInterval,
             (100000000/frame->dwDefaultFrameInterval)%10);
 
+        format_frame++;
         buflen -= buffer[0];
         buffer += buffer[0];
     }
@@ -1966,6 +1973,15 @@
       .driver_info        = UVC_QUIRK_PROBE_MINMAX
                 | UVC_QUIRK_IGNORE_SELECTOR_UNIT
                 | UVC_QUIRK_PRUNE_CONTROLS },
+    /* Microdia Pavilion Webcam */
+    { .match_flags        = USB_DEVICE_ID_MATCH_DEVICE
+                | USB_DEVICE_ID_MATCH_INT_INFO,
+      .idVendor        = 0x0c45,
+      .idProduct        = 0x62c0,
+      .bInterfaceClass    = USB_CLASS_VIDEO,
+      .bInterfaceSubClass    = 1,
+      .bInterfaceProtocol    = 0,
+      .driver_info        = UVC_QUIRK_IGNORE_VSI_IDX_OOR},
     /* Generic USB Video Class */
     { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) },
     {}
Index: linux/drivers/media/video/uvc/uvcvideo.h
===================================================================
--- linux.orig/drivers/media/video/uvc/uvcvideo.h    2009-05-16 14:05:25.000000000 +0200
+++ linux/drivers/media/video/uvc/uvcvideo.h 2009-05-16 14:06:52.000000000 +0200
@@ -317,6 +317,7 @@
 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT    0x00000020
 #define UVC_QUIRK_PRUNE_CONTROLS    0x00000040
+#define UVC_QUIRK_IGNORE_VSI_IDX_OOR    0x00000100

 /* Format flags */
 #define UVC_FMT_FLAG_COMPRESSED    0x00000001
 #define UVC_FMT_FLAG_STREAM        0x00000002

Have fun

P.s. Works on 2.6.29.4 too (maybe on all 2.6.29's).

Last edited by slimmer (2009-05-20 08:14:27)

Offline

#12 2009-05-20 12:53:12

Farstar
Member
Registered: 2009-04-22
Posts: 7

Re: Trouble with Microdia Sonix USB 2.0 Camera

slimmer, great respect!

Offline

#13 2009-05-20 16:17:19

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

Respect to the man that has found out what's the problem, I've just made it compatible with kernel 2.6.29. I still hope that someone will make a PKGBUILD for uvcvideo module only to make it easier for distribution until the changes become reality in the official source.

Offline

#14 2009-05-28 18:55:41

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

This one is for kernel 2.6.30. I've tested it with the kernel26-git from the AUR. Here's how:

1. "yaourt -Rd kernel26-firmware"
2. "yaourt -S kernel26-firmware-git"
3. Extract the tar to a newly created dir (e.g. /home/user/kernel26-git).
4. Create a directory named patches in the same directory and make a text file named microdia.patch. Copy in it the source from below.
5. Download the dependencies (git gcc make...).
6. Optional: Copy the config file as config.saved.<arch> (e.g. config.saved.x86_64) if you have a customised kernel.
7. Run "makepkg" and do not make any changes to the configuration of the kernel if you don't know what you are doing (just press exit smile ).
8. Install the resulting package.
9. Edit /boot/grub/menu.lst - copy the section for Arch's kernel and just add:

title  Arch Linux GIT Kernel
root   (hd0,0)
kernel /boot/vmlinuz26-git root=/dev/disk/by-uuid/9ec9cf83-81d0-4b45-9b88-ecaf9eaa04ff ro vga=0x323 quiet
initrd /boot/kernel26-git.img

WARNING - I recommend to copy your own section, cause it's system-specific. Just add -git to vmlinuz26 and kernel26!!!
10. Reboot and pray smile.

microdia-2.6.30.patch:

diff -crB linux-2.6.git-build/drivers/media/video/uvc/uvc_driver.c linux-2.6.git-build/drivers/media/video/uvco/uvc_driver.c
*** linux-2.6.git-build/drivers/media/video/uvc/uvc_driver.c    2009-05-28 09:18:44.000000000 +0300
--- linux-2.6.git-build/drivers/media/video/uvco/uvc_driver.c    2009-05-28 09:16:50.000000000 +0300
***************
*** 292,297 ****
--- 292,298 ----
      unsigned char *_buffer;
      unsigned int interval;
      unsigned int i, n;
+     unsigned int format_frame;
      int _buflen;
      __u8 ftype;
  
***************
*** 416,423 ****
      /* Count the number of frame descriptors to test the bFrameIndex
       * field when parsing the descriptors. We can't rely on the
       * bNumFrameDescriptors field as some cameras don't initialize it
!      * properly.
       */
      for (_buflen = buflen, _buffer = buffer;
           _buflen > 2 && _buffer[2] == ftype;
           _buflen -= _buffer[0], _buffer += _buffer[0])
--- 417,425 ----
      /* Count the number of frame descriptors to test the bFrameIndex
       * field when parsing the descriptors. We can't rely on the
       * bNumFrameDescriptors field as some cameras don't initialize it
!      * properly, but save previous value for quirks case.
       */
+         format_frame = format->nframes;
      for (_buflen = buflen, _buffer = buffer;
           _buflen > 2 && _buffer[2] == ftype;
           _buflen -= _buffer[0], _buffer += _buffer[0])
***************
*** 446,456 ****
                     "interface %d frame index %u out of range\n",
                     dev->udev->devnum, alts->desc.bInterfaceNumber,
                     buffer[3]);
!             return -EINVAL;
          }
  
-         frame = &format->frame[buffer[3] - 1];
- 
          frame->bFrameIndex = buffer[3];
          frame->bmCapabilities = buffer[4];
          frame->wWidth = get_unaligned_le16(&buffer[5]);
--- 448,462 ----
                     "interface %d frame index %u out of range\n",
                     dev->udev->devnum, alts->desc.bInterfaceNumber,
                     buffer[3]);
!             if(!dev->quirks & UVC_QUIRK_IGNORE_VSI_IDX_OOR)
!                 return -EINVAL;
!             uvc_trace(UVC_TRACE_DESCR, "UVC_QUIRK_IGNORE_VSI_IDX_OOR supplying %d\n",
!                 format_frame);
!             frame = &format->frame[format_frame];
!         } else {
!             frame = &format->frame[buffer[3] - 1];
          }
  
          frame->bFrameIndex = buffer[3];
          frame->bmCapabilities = buffer[4];
          frame->wWidth = get_unaligned_le16(&buffer[5]);
***************
*** 506,512 ****
              frame->wWidth, frame->wHeight,
              10000000/frame->dwDefaultFrameInterval,
              (100000000/frame->dwDefaultFrameInterval)%10);
! 
          buflen -= buffer[0];
          buffer += buffer[0];
      }
--- 512,519 ----
              frame->wWidth, frame->wHeight,
              10000000/frame->dwDefaultFrameInterval,
              (100000000/frame->dwDefaultFrameInterval)%10);
!                         
!                 format_frame++;
          buflen -= buffer[0];
          buffer += buffer[0];
      }
***************
*** 1967,1972 ****
--- 1974,1988 ----
        .driver_info        = UVC_QUIRK_PROBE_MINMAX
                  | UVC_QUIRK_IGNORE_SELECTOR_UNIT
                  | UVC_QUIRK_PRUNE_CONTROLS },
+     /* Microdia Pavilion Webcam */
+     { .match_flags        = USB_DEVICE_ID_MATCH_DEVICE
+                 | USB_DEVICE_ID_MATCH_INT_INFO,
+       .idVendor        = 0x0c45,
+       .idProduct        = 0x62c0,
+       .bInterfaceClass    = USB_CLASS_VIDEO,
+       .bInterfaceSubClass    = 1,
+       .bInterfaceProtocol    = 0,
+       .driver_info        = UVC_QUIRK_IGNORE_VSI_IDX_OOR},                                
      /* Generic USB Video Class */
      { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) },
      {}
diff -crB linux-2.6.git-build/drivers/media/video/uvc/uvcvideo.h linux-2.6.git-build/drivers/media/video/uvco/uvcvideo.h
*** linux-2.6.git-build/drivers/media/video/uvc/uvcvideo.h    2009-05-28 09:18:44.000000000 +0300
--- linux-2.6.git-build/drivers/media/video/uvco/uvcvideo.h    2009-05-28 08:31:19.000000000 +0300
***************
*** 315,320 ****
--- 315,321 ----
  #define UVC_QUIRK_IGNORE_SELECTOR_UNIT    0x00000020
  #define UVC_QUIRK_PRUNE_CONTROLS    0x00000040
  #define UVC_QUIRK_FIX_BANDWIDTH        0x00000080
+ #define UVC_QUIRK_IGNORE_VSI_IDX_OOR    0x00000100
  
  /* Format flags */
  #define UVC_FMT_FLAG_COMPRESSED        0x00000001

I hope that I haven't missed something. Btw 2.6.30 works better than 2.6.29 for me. Good luck. Feel free to comment if something is not clear or is wrong.

p.s. Of course you can use yaourt for kernel26-git too, just copy the patch to /var/abs/local/yaourtbuild/kernel26-git/patches before compilation.

Last edited by slimmer (2009-05-28 19:06:09)

Offline

#15 2009-06-22 04:58:50

slimmer
Member
From: Bulgaria
Registered: 2008-11-23
Posts: 10

Re: Trouble with Microdia Sonix USB 2.0 Camera

I write just to inform you that the author of the uvc driver has made a correction. He asked me to test it and it worked. It will be present in 2.6.31. Until then you can use this one as a workaround. Below is his patch for 2.6.30 that is going to be in 2.6.31:

--- a/linux/drivers/media/video/uvc/uvc_driver.c    Fri Mar 27 14:46:49 2009 +0100
+++ b/linux/drivers/media/video/uvc/uvc_driver.c    Wed May 06 17:30:30 2009 +0200
@@ -289,10 +289,8 @@ static int uvc_parse_format(struct uvc_d
     struct uvc_format_desc *fmtdesc;
     struct uvc_frame *frame;
     const unsigned char *start = buffer;
-    unsigned char *_buffer;
     unsigned int interval;
     unsigned int i, n;
-    int _buflen;
     __u8 ftype;
 
     format->type = buffer[2];
@@ -413,20 +411,11 @@ static int uvc_parse_format(struct uvc_d
     buflen -= buffer[0];
     buffer += buffer[0];
 
-    /* Count the number of frame descriptors to test the bFrameIndex
-     * field when parsing the descriptors. We can't rely on the
-     * bNumFrameDescriptors field as some cameras don't initialize it
-     * properly.
-     */
-    for (_buflen = buflen, _buffer = buffer;
-         _buflen > 2 && _buffer[2] == ftype;
-         _buflen -= _buffer[0], _buffer += _buffer[0])
-        format->nframes++;
-
     /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
      * based formats have frame descriptors.
      */
     while (buflen > 2 && buffer[2] == ftype) {
+        frame = &format->frame[format->nframes];
         if (ftype != VS_FRAME_FRAME_BASED)
             n = buflen > 25 ? buffer[25] : 0;
         else
@@ -440,16 +429,6 @@ static int uvc_parse_format(struct uvc_d
                    alts->desc.bInterfaceNumber);
             return -EINVAL;
         }
-
-        if (buffer[3] - 1 >= format->nframes) {
-            uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming"
-                   "interface %d frame index %u out of range\n",
-                   dev->udev->devnum, alts->desc.bInterfaceNumber,
-                   buffer[3]);
-            return -EINVAL;
-        }
-
-        frame = &format->frame[buffer[3] - 1];
 
         frame->bFrameIndex = buffer[3];
         frame->bmCapabilities = buffer[4];
@@ -507,6 +486,7 @@ static int uvc_parse_format(struct uvc_d
             10000000/frame->dwDefaultFrameInterval,
             (100000000/frame->dwDefaultFrameInterval)%10);
 
+        format->nframes++;
         buflen -= buffer[0];
         buffer += buffer[0];
     }

Last edited by slimmer (2009-06-22 05:02:56)

Offline

#16 2009-07-28 16:37:19

kandalf
Member
Registered: 2007-06-10
Posts: 31

Re: Trouble with Microdia Sonix USB 2.0 Camera

Hi everybody,
I tried to use the updated patch for 2.6.30 but it failed to apply hunks.
What I did, since it is a small patch, was:
1 - Copy the drivers/media/video/uvc/uvc_driver.c to a temp location
2 - Modify the file with the same modifications that are in the previous patch
3 - Create a new patch with diff -c in a new file (microdia.patch)
4 - Modify the PKGBUILD to include this patch in the sources list
5 - Modify the PKGBUILD to apply the patch after the patch from Arch
6 - Run makepkg
7 - Install the new kernel

As a recommendation, I'd suggest to modify the image name on the PKGBUILD file and add a new entry on the bootloader menu so you don't loose you working kernel if something goes wrong.

Here are my PKGBUILD and patch files

# $Id: PKGBUILD 46779 2009-07-20 06:02:41Z tpowa $
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Maintainer: Thomas Baechler <thomas@archlinux.org>
#pkgname=kernel26                # Build stock -ARCH kernel
 pkgname=kernel26-uvc       # Build kernel with a different name
_kernelname=${pkgname#kernel26}
_basekernel=2.6.30
pkgver=${_basekernel}.2
pkgrel=1
_patchname="patch-${pkgver}-${pkgrel}-ARCH"
pkgdesc="The Linux Kernel and modules"
arch=(i686 x86_64)
license=('GPL2')
groups=('base')
url="http://www.kernel.org"
backup=(etc/mkinitcpio.d/${pkgname}.preset)
depends=('coreutils' 'kernel26-firmware>=2.6.30' 'module-init-tools' 'mkinitcpio>=0.5.20')
# pwc, ieee80211 and hostap-driver26 modules are included in kernel26 now
# nforce package support was abandoned by nvidia, kernel modules should cover everything now.
# kernel24 support is dropped since glibc24
replaces=('kernel24' 'kernel24-scsi' 'kernel26-scsi'
          'alsa-driver' 'ieee80211' 'hostap-driver26'
          'pwc' 'nforce' 'squashfs' 'unionfs' 'ivtv'
          'zd1211' 'kvm-modules' 'iwlwifi' 'rt2x00-cvs'
          'gspcav1' 'atl2' 'wlan-ng26' 'aufs' 'rt2500')
install=kernel26.install
source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2
        ftp://ftp.archlinux.org/other/kernel26/${_patchname}.bz2
    # the main kernel config files
        config config.x86_64 microdia.patch
        # standard config files for mkinitcpio ramdisk
        kernel26.preset)
optdepends=('crda: to set the correct wireless channels of your country')
md5sums=('7a80058a6382e5108cdb5554d1609615'
         '047230e4ebb44bf37e7f5306a9c87697'
         '999272ccb838e6e61d03463cd52d1ad4'
         '8a7e6e4157d33bd34ba31049a55e9777'
         '25584700a0a679542929c4bed31433b6')

build() {
  KARCH=x86

  cd ${srcdir}/linux-$_basekernel
  # Add -ARCH patches
  # See http://projects.archlinux.org/git/?p=linux-2.6-ARCH.git;a=summary
    
  patch -Np1 -i ${srcdir}/${_patchname} || return 1
  patch -Np1 -i ${srcdir}/microdia.patch || return 1

  if [ "$CARCH" = "x86_64" ]; then
    cat ../config.x86_64 >./.config
  else
    cat ../config >./.config
  fi
  if [ "${_kernelname}" != "" ]; then
    sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  fi
  # get kernel version  
  make prepare
  _kernver="$(make kernelrelease)"
  # load configuration
  # Configure the kernel. Replace the line below with one of your choice.
  #make menuconfig # CLI menu for configuration
  #make xconfig # X-based configuration
  #make oldconfig # using old config from previous kernel version
  # ... or manually edit .config
  ####################
  # stop here
  # this is useful to configure the kernel
  #msg "Stopping build"
  #return 1
  ####################
  yes "" | make config
  # build!
  make bzImage modules || return 1
  mkdir -p ${pkgdir}/{lib/modules,boot}
  make INSTALL_MOD_PATH=${pkgdir} modules_install || return 1
  cp System.map ${pkgdir}/boot/System.map26${_kernelname}
  cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26${_kernelname}
  install -D -m644 Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Makefile
  install -D -m644 kernel/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
  install -D -m644 .config \
    ${pkgdir}/usr/src/linux-${_kernver}/.config
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include

  for i in acpi asm-{generic,x86} config linux math-emu media net pcmcia scsi sound trace video; do
    cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
  done

  # copy arch includes for external modules
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
  cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/

  # copy files necessary for later builds, like nvidia and vmware
  cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
  cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
  # fix permissions on scripts dir
  chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
  #mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions

  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel

  cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  if [ "$CARCH" = "i686" ]; then
    cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
  fi
  cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/

  # add headers for lirc package
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
  cp drivers/media/video/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
  for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
   mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
   cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
  done
  # add docbook makefile
  install -D -m644 Documentation/DocBook/Makefile \
    ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
  # add dm headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  cp drivers/md/*.h  ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
  # add inotify.h
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
  cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
  # add wireless headers
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/9912
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
  cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
  # add dvb headers for external modules
  # in reference to:
  # http://bugs.archlinux.org/task/11194
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
  # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
  # in reference to:
  # http://bugs.archlinux.org/task/13146
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
  # add xfs and shmem for aufs building
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
  mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
  cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
  # add headers vor virtualbox
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
  # add headers for broadcom wl
  # in reference to:
  # http://bugs.archlinux.org/task/14568
  cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
  # add vmlinux
  cp vmlinux ${pkgdir}/usr/src/linux-${_kernver}
  # copy in Kconfig files
  for i in `find . -name "Kconfig*"`; do 
    mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
    cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
  done

  cd ${pkgdir}/usr/src/linux-${_kernver}/include && ln -s asm-$KARCH asm

  chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
  find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
  cd ${pkgdir}/lib/modules/${_kernver} && \
    (rm -f source build; ln -sf ../../../usr/src/linux-${_kernver} build)
  # install fallback mkinitcpio.conf file and preset file for kernel
  install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset || return 1
  # set correct depmod command for install
  sed \
    -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
    -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
    -i $startdir/kernel26.install
  sed \
    -e "s|source .*|source /etc/mkinitcpio.d/kernel26${_kernelname}.kver|g" \
    -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
    -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
    -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset

  echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${startdir}/pkg/etc/mkinitcpio.d/${pkgname}.kver
  # remove unneeded architectures
  rm -rf ${pkgdir}/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
  # remove the firmware
  rm -rf ${pkgdir}/lib/firmware
}

microdia.patch

*** /drivers/media/video/uvc/uvc_driver.c    2009-07-26 00:46:21.000000000 -0300
--- /drivers/media/video/uvc/uvc_driver.c    2009-07-26 00:54:14.000000000 -0300
***************
*** 289,298 ****
      struct uvc_format_desc *fmtdesc;
      struct uvc_frame *frame;
      const unsigned char *start = buffer;
-     unsigned char *_buffer;
      unsigned int interval;
      unsigned int i, n;
-     int _buflen;
      __u8 ftype;
  
      format->type = buffer[2];
--- 289,296 ----
***************
*** 413,432 ****
      buflen -= buffer[0];
      buffer += buffer[0];
  
-     /* Count the number of frame descriptors to test the bFrameIndex
-      * field when parsing the descriptors. We can't rely on the
-      * bNumFrameDescriptors field as some cameras don't initialize it
-      * properly.
-      */
-     for (_buflen = buflen, _buffer = buffer;
-          _buflen > 2 && _buffer[2] == ftype;
-          _buflen -= _buffer[0], _buffer += _buffer[0])
-         format->nframes++;
- 
      /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
       * based formats have frame descriptors.
       */
      while (buflen > 2 && buffer[2] == ftype) {
          if (ftype != VS_FRAME_FRAME_BASED)
              n = buflen > 25 ? buffer[25] : 0;
          else
--- 411,421 ----
      buflen -= buffer[0];
      buffer += buffer[0];
  
      /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
       * based formats have frame descriptors.
       */
      while (buflen > 2 && buffer[2] == ftype) {
+         frame = &format->frame[format->nframes];
          if (ftype != VS_FRAME_FRAME_BASED)
              n = buflen > 25 ? buffer[25] : 0;
          else
***************
*** 441,454 ****
              return -EINVAL;
          }
  
-         if (buffer[3] - 1 >= format->nframes) {
-             uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming"
-                    "interface %d frame index %u out of range\n",
-                    dev->udev->devnum, alts->desc.bInterfaceNumber,
-                    buffer[3]);
-             return -EINVAL;
-         }
- 
          frame = &format->frame[buffer[3] - 1];
  
          frame->bFrameIndex = buffer[3];
--- 430,435 ----
***************
*** 507,512 ****
--- 488,494 ----
              10000000/frame->dwDefaultFrameInterval,
              (100000000/frame->dwDefaultFrameInterval)%10);
  
+         format->nframes++;
          buflen -= buffer[0];
          buffer += buffer[0];
      }

Hope it helps.

Cheers!

Last edited by kandalf (2009-07-29 02:19:17)


There's no place like ~

Offline

#17 2011-01-28 10:29:41

jemadux
Member
From: Thessaloniki City / Greece
Registered: 2010-07-17
Posts: 45

Re: Trouble with Microdia Sonix USB 2.0 Camera

my webcam that is the same model doesnt work w/ .37 kernel

Offline

Board footer

Powered by FluxBB