Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Compile on linux kenel 2.6.24 & 2.6.26

2008-10-13
2013-06-03
  • Hello,

    I have found that qc-usb-0.6.6 wil not compile on linux kernels 2.6.24 and 2.6.26.  Using google I found the two needed patched in the Debian package qc-usb 0.6.6-6.

    The package contained two patches one fixes compile problems for the
    2.6.24 kernel.  The other fixes compile problems for the 2.6.26.

    Both were developed by Debian developers.  To use copy paste into a blank file and save at a patch file.  Use the follwing command to patch:

    #patch -Np1 -i name/of/file.patch

    To compile qc-usb-0.6.6 on a 2.6.24 kernel the 2.6.24 patch must be
    installed.

    To compile qc-usb-0.6.6 on a 2.6.26 kernel both patches must be installed.

    Cheers,
    Joe

    Patch One (patch for 2.6.24): Start copy below this line.

    diff -urNad qc-usb-0.6.6~/qc-driver.c qc-usb-0.6.6/qc-driver.c
    --- qc-usb-0.6.6~/qc-driver.c    2006-10-24 04:06:19.000000000 +0200
    +++ qc-usb-0.6.6/qc-driver.c    2007-12-09 17:20:30.000000000 +0100
    @@ -821,7 +821,9 @@
         if (!cr) goto fail2;
         urb->transfer_buffer = kmalloc(qc_i2c_maxbufsize*sizeof(u8), GFP_KERNEL);    /* Allocate maximum ever needed */
         if (!urb->transfer_buffer) goto fail3;
    +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
         spin_lock_init(&urb->lock);
    +#endif
         urb->complete = qc_i2c_handler;
         urb->context  = qc;
    #if (LINUX_VERSION_CODE<KERNEL_VERSION(2,6,9) && !defined(CONFIG_SUSE_KERNEL)) || LINUX_VERSION_CODE<KERNEL_VERSION(2,6,8)
    @@ -3006,7 +3008,9 @@
    static struct video_device qc_v4l_template = {
         name:        "QuickCam USB",
         type:        VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE,
    +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
         hardware:    VID_HARDWARE_QCAM_USB,
    +#endif
         minor:        -1,
    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
         release:    qc_v4l_release,
    diff -urNad qc-usb-0.6.6~/quickcam.h qc-usb-0.6.6/quickcam.h
    --- qc-usb-0.6.6~/quickcam.h    2006-11-04 14:38:27.000000000 +0100
    +++ qc-usb-0.6.6/quickcam.h    2007-12-09 17:17:01.000000000 +0100
    @@ -126,7 +126,9 @@
    #define FALSE            0
    #define TRUE            (!FALSE)
    typedef unsigned char Bool;
    +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
    #define BIT(x)        (1<<(x))
    +#endif
    #define SIZE(a)        (sizeof(a)/sizeof((a)[0]))
    #define MAX(a,b)    ((a)>(b)?(a):(b))
    #define MIN(a,b)    ((a)<(b)?(a):(b))

    End of Patch one:  Stop copy above this line

    Start of Patch two (patch for 2.6.26):  Start copy below this line

    From kernel 2.6.26rc2, SetPageReserved and ClearPageReserved changed from
    macros to inline functions, that are generated using macros (among which
    SETPAGEFLAG).

    The functions were redefined because they don't exist as macros, and then
    preventing compilation.

    This patch allows to compile the quickcam/qce-ga/qc-usb module on kernels
    2.6.26rc2 and later.

    An other fix could use #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26).

    Signed-off-by: Guillaume Bedot <littletux@mandriva.org>
    --- qc-usb-0.6.6.orig/qc-memory.c    2008-05-27 16:41:19.000000000 +0200
    +++ qc-usb-0.6.6/qc-memory.c    2008-05-27 16:41:35.000000000 +0200
    @@ -81,12 +81,14 @@
    #define pte_offset(pmd,adr)    pte_offset_map(pmd,adr)    /* Emulation for a kernel using the new rmap-vm */
    #endif                            /* Fix by Michele Balistreri <brain87@gmx.net> */

    +#ifndef SETPAGEFLAG
    #ifndef SetPageReserved
    #define SetPageReserved(p)    mem_map_reserve(p)
    #endif
    #ifndef ClearPageReserved
    #define ClearPageReserved(p)    mem_map_unreserve(p)
    #endif
    +#endif
    /* }}} */

    /* {{{ [fold] kvirt_to_pa(): obtain physical address from virtual address obtained by vmalloc() */

    End copy two:  End copy on line above.