My Linux Stuff

Welcome

Here you can find my Linux Stuff which is maybe helpful to others.

Gnome Screensaver Command Fake

The support for gnome-screensaver-command --poke was deactivated and mostly every video player has problems with it. I wrote a little workaround to get ride of this.
Go to the workaround ...

New version of CyberLink Remote Control

Newer kernels do not report all buttons, so a change to libusb was necessary.
Go to cyberlinkusb ...

Samsung Unified Linux Driver on Fedora, Gentoo

Fri, 09. September 2011 12:23

Sadly, but the Samsung Unified Linux Driver does not work out of the box.

First, be sure the QT4 installer is used, you will get a nicer GUI. The installer does not give any information, when and why qt3 is used. Mostly missing dependences are the reason. Simply run guiinstall in the qt4/install folder to see which ones and install them.

 

The installer uses /usr/lib/cups/filter as default location for some files. But depending on your version of cups, cups is looking at /usr/libexec/cups/filter.  The cups error log at http://localhost:631/admin/log/error_log can give you additional information.

 

On Fedora you have to restore the SELinux context on the following files:

restorecon /etc/cups/smfp.*
restorecon /etc/cups/pstosecps.*
restorecon /usr/lib/cups/backend/mfp
restorecon /usr/lib/libmfp.so.*
restorecon -R /usr/share/cups/model/samsung/cms/
restorecon  /usr/lib/cups/filter/rastertosamsungspl*
restorecon  /usr/lib/cups/filter/smfpautoconf
restorecon  /usr/lib/cups/filter/pstosecps

 

If everything is fixed, pinter and scanner can be used without problems.

It would be nice, if the installer gives more information what it is doing.

cyberlinkdrv

Fri, 15. July 2011 15:47

I'm still not able to get a working CyberLink remote control out of the box. There has been added a USB HID driver to the kernel source, but still not all buttons are working for me.

Introduction

lsusb says:

0766:0204 Jess-Link Products Co., Ltd

 

/var/log/messages tells me:

kernel: input: TopSeed Tech Corp. USB IR Combo Device  as /devices/pci0000:00/0000:00:04.0/usb3/3-1/3-1:1.0/input/input4
kernel: topseed 0003:0766:0204.0001: input,hidraw0: USB HID v1.00 Keyboard [TopSeed Tech Corp. USB IR Combo Device ] on usb-0000:00:04.0-1/input0
kernel: input: TopSeed Tech Corp. USB IR Combo Device  as /devices/pci0000:00/0000:00:04.0/usb3/3-1/3-1:1.1/input/input5
kernel: topseed 0003:0766:0204.0002: input,hiddev96,hidraw1: USB HID v1.00 Mouse [TopSeed Tech Corp. USB IR Combo Device ] on usb-0000:00:04.0-1/input1

 

Driver cyberlinkdrv

So I thought to myself: Why not write a driver for it? So I did it.

For my workaround cyberlinkusb I haven't read the USB documentation. Now I'm a step further, I have read the documentation but not the HID.

 

The driver works very well except one really big problem:

The remote control is a HID device and so the usbhid driver is loaded instead of my own written driver.

You can tell the usbhid driver with

usbhid.quirks=0x0766:0x0204:0x0004

to ignore the device but not to give the control over to the next machting driver.

 

Workaround

A workaround is to plug in the remote control, unload the usbhid driver (e.g. with cyberlinkusb) and then to insert the cyberlinkdrv driver with insmod.

 

Conclusion

The driver would be a nice solution because it handles the auto repeat key better than the user space program cyberlinkusb.

But how useful is the driver if it will not get loaded? Not very.

So for the most users cyberlinkusb is still the best solution to get a working remote control.

If someone knows how to load a specific driver or is interessted in the source code of the driver can send me a message (thaj at users dot sf.net).

Install Fedora with external HDD

Tue, 12. July 2011 12:17

In the times where HDD are cheaper than ever, there is not need to burn a DVD just do install your distro.

Just put the necesary files on the external disk, install grub and boot from it.

 

Create a boot partition (big enough, about 150MB; should be a pimary one, some BIOS and/or grub have problems accessing it if a extended partition is used) and install grub on the external HDD.

Mount the ISO (e.g. mount -o loop Fedora15-i386-DVD.iso /mnt) and copy isolinux/initrd.img and isolinux/vmlinuz to your previously created boot partition.

Rename the files to the file names used in your grub entry, edit grub.conf and create a new entry:

title Fedora Install
  root (hd0,0)
  kernel /finstall-vmlinuz askmethod
  initrd /finstall-initrd.img

 

askmethod will ask you where the install media can be found (DVD, network, hard disk).

More Fedora install boot options see http://fedoraproject.org/wiki/Anaconda/Options

Replace root (hd0,0) with the correct value. Most BIOS set your external HDD to hd0 if you boot from USB. If your boot partition is the first one, use 0, else use the number of the partition minus one.

Copy the hole ISO file to a partition on the external hard disk. In the installer then select the partition and enter the path to the ISO file.

pCalc

Sat, 09. July 2011 12:13

If you work a lot of with bits and bytes, the calculator which comes with your os will not fit your needs normaly, especially when it comes to signed and unsigned values.

A calculator with some nice features to convert between binary, hexdecimal and decimal values can be found here.

  • 8bit, 16bit, 32bit
  • signed, unsigned
  • bin, hex, dec

Using binary values in C/C++

Mon, 30. May 2011 11:53

In the last time I worked a lot of with binary values in C/C++. Some better compilers support the 0b prefix for binary values like

int b = 0b101; // = 5

 

If the compiler, like my one, does not support the prefix, the hex or decimal value has to be recalculated each time you change a bit, which is not really satisfactory.

 

A little trick will help you:

#include <stdint.h>
#include <limits.h>

/*
turn a numeric literal into a hex constant (avoids problems with leading zeroes)
8-bit constants max value 0x11111111, always fits in unsigned long
*/
#define HEX__(n) 0x##n##LU

/* 8-bit conversion function */
#define B8__(x) \
  ((x&0x0000000FLU)?1:0) \
+((x&0x000000F0LU)?2:0) \
+((x&0x00000F00LU)?4:0) \
+((x&0x0000F000LU)?8:0) \
+((x&0x000F0000LU)?16:0) \
+((x&0x00F00000LU)?32:0) \
+((x&0x0F000000LU)?64:0) \
+((x&0xF0000000LU)?128:0)

#define B8(d)  ((uint8_t)B8__(HEX__(d)))

#if INT_MAX > 32767  /* 32-bit and more */

/* 16-bit conversion function */
#define B16__(x) B8__(x) \
+((x&0x0000000F00000000LU)?256:0) \
+((x&0x000000F000000000LU)?512:0) \
+((x&0x00000F0000000000LU)?1024:0) \
+((x&0x0000F00000000000LU)?2048:0) \
+((x&0x000F000000000000LU)?4096:0) \
+((x&0x00F0000000000000LU)?8192:0) \
+((x&0x0F00000000000000LU)?16384:0) \
+((x&0xF000000000000000LU)?32768:0)

#define B16(d) ((uint16_t)B16__(HEX__(d)))
#define B32(h,l) ((uint32_t)((uint32_t)(B16__(HEX__(h)))<<16)+(uint32_t)(B16__(HEX__(l))))
#define B(uh,ul,h,l) ((uint32_t)((uint32_t)(B8__(HEX__(uh))<<24)+ \
           (uint32_t)(B8__(HEX__(ul))<<16)+(uint32_t)(B8__(HEX__(h))<<8)+\
           (uint32_t)B8__(HEX__(l))))
#else /* 16-bit and less */
#define B16(h,l) ((uint16_t)((uint16_t)(B8__(HEX__(h)))<<8)+(uint16_t)(B8__(HEX__(l))))
#endif

 

And then simply use:

unsigned char b;
b = B8(1010);      // 0xA, dec: 10
b = B8(11111111);  // 0xFF, dec: 255