How to patch the latest Dektec Linux SDK for Linux KERNEL 2.6.38+

If you get the latest Dektec SDK for Linux that was released in May 2011,
you will get compilation problems under Ubuntu 11.04 which is now using
the latest Linux kernel 2.6.38

I spent some time trying to understand what was the problems.
The main two problems are refactored methods under the kernel:
- MUTEX methods renamed to stick to semaphore stuff
- IOCTL redefinitions (ioctl -> compat_ioctl -> unlocked_ioctl)

Therefore for example in the directory Dta1xx (for cards 1xx but
this is exactly the same patch for Dtu2xx and Dta1xxNw), you just have to patch
those 3 files in order to compile the kernel module:

Dta1xx.c:
---------
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
ioctl: Dta1xxIoCtl,
#else
unlocked_ioctl: Dta1xxNewIoCtl,
#endif #ifdef CONFIG_COMPAT
compat_ioctl: Dta1xxCompatIoCtl,
#endif Dta1xx.h: --------- // PATCH for new kernel 2.6.38+ to avoid: error: implicit declaration of function ‘init_MUTEX’ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
#ifndef init_MUTEX
#define init_MUTEX(_m) sema_init(_m,1);
#endif // #ifndef init_MUTEX
#endif ... Int Dta1xxIoCtl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); Int Dta1xxNewIoCtl(struct file *file, unsigned int cmd, unsigned long arg); #ifdef CONFIG_COMPAT long Dta1xxCompatIoCtl(struct file *filp, unsigned int cmd, unsigned long arg); #endif IoCtl.c: -------- ... int Dta1xxNewIoCtl(
struct file *file, // Represents file object
unsigned int cmd, // Command
unsigned long arg) // Pointer to the IoCtl parameter
{ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
struct inode *inode = file->f_dentry->d_inode;
#else
struct inode *inode = file->f_path.dentry->d_inode;
#endif
// Just call the regular IOCTL handler
return Dta1xxIoCtl(inode, file, cmd, arg);
}

I hope it will help you.

As it seems far better to provide the full source code than patches
so here are the file links on the Dta1xx files to replace in the Dektec SDK:
IoCtl.c
Dta1xx.c
Dta1xx.h
You will see that a "make" and "make install" will work and then you will be able to call the driver launch command "sh ./Dta1xxInit start" as explained in their ReadMe file.
To see if the driver is fully loaded you can check the linux log using "dmesg" command.

I also tried on Linux MINT distro too.
Those patches have also been sent to Dektec that they will integrate in their next release.

6 comments:

amertum said...

T'es vraiment trop balaise ! ;-)

Conan_Fr said...

This guy did have the same problem:
http://timpson.ru/tag/dektec/

I contacted him and he will try ...

timgabets said...

Hm. I still have compile-time errors after patching:
http://timpson.ru/2011/06/my-second-dektec-and-linux-expirience/

timgabets said...

Does this patch works for you? And what is your kernel version - mine is 2.6.38-r7 (Gentoo).

Conan_Fr said...

Hi Tim. I've seen your comments and I suppose that my patch explanation was not so easy. Here are the files that will help and avoid those copy and paste errors.
I will burn the Gentoo LiveDVD and check ...

Right here under Mint distro, my kernel is 2.6.38-8-generic (same one as the Ubuntu 11.04)

Ricardo Martinez said...

In case anybody run into the same problem with newer kernels.
For kernel 3.11 I had to do the following additional changes:

DtPlay/Makefile:
$(CXX) $(CPPFLAGS) $^ $(LDLIBS) $(LDFLAGS) -o $@

Dta1xx/Source/Interrupt.c:
Dta1xx/Source/Dta1xx.c:
#define KERNELVERSION 26
#else
#define KERNELVERSION 27
#endif

Dta1xx/Source/Init.c
#define DMA_32BIT_MASK DMA_BIT_MASK(32)

Post a Comment

Copyright © IT pages