Thursday, February 28, 2008

Loading custom compiled ALSA modules

While trying to debug the soundcard on my Clevo M720R I had the pleasure of trying to find out how to avoid loading the ubuntu supplied kernel modules and instead loading the custom compiled ones.
These instructions have only been verified to work while using Ubuntu Hardy current.

I use the following steps to set up my environment:
1. Enter the module directory of your current kernel ( /lib/modules/2.6.24-...). You can check what kernel you're currently running by issuing the 'uname -a' command on a terminal.
2. Move the 'ubuntu' subdirectory to somewhere safe (your home folder preferably). Do not put it in the /tmp directory, as it gets swiped during each reboot.
3. Build and install the custom ALSA kernel modules.
4. Reboot the system
5. Your system should now have loaded the custom modules. If not, try to do a 'sudo modprobe "sound kernel module"' (snd-hda-intel in my case).
6. To return the system state to normal, enter the kernel module directory as stated in 1. and move the 'ubuntu' directory back from where you put it.

That's it!

Should you screw up, reinstall the ubuntu modules by issuing the following command on the terminal: sudo apt-get --reinstall install linux-ubuntu-modules-`uname -r`

Sunday, February 17, 2008

Clevo backlight

So, it seems I never gave a status update on the reverse engineering of the backlight.
I basically hit a wall. The EC is readable and gives status on the current backlight level.
Unfortunately it seems that writing to the EC accomplish nothing. I currently suspect that the windows backlight driver doesn't write at all but only poll relevant registers in the EC and show some graphics upon detecting a change. If someone has an update or solution to this, contact me ASAP.

Thursday, February 14, 2008

Reverse engineering the Ali M5602 webcam

I've been experimenting with reverse engineering the webcam equipped on my Clevo M720R.

After snooping the windows driver and cross referencing the register writes with the OV9650 (the actual camera sensor) one wonders what kind of crack they smoke in Taiwan. The following code describes the full init sequence for the sensor with comments from me.
Notice the amount of writes that are invalidated later on and writes writing the default value already set in the chip...

{OV9650_COM7, 0x80}, /* Reset chip */
{OV9650_COM7, 0x05},
/* 2, 2 */

{OV9650_BLUE, 0x80}, /* Set blue and red to default values */
{OV9650_RED, 0x80},
/* 2, 4 */

{OV9650_AECH, 0x29}, /* Set exposure */
{OV9650_COM1, 0x03},
{OV9650_GAIN, 0x02}, /* Set gain */
/* 3, 7 */

{OV9650_COM7, 0x80}, /* Reset chip */
{OV9650_COM7, 0x05}, /* Set raw RGB */
/* 2, 9 */

{OV9650_COM7, 0x80}, /* Reset chip */
{OV9650_CLKRC, 0x80}, /* Enable double clock */
{OV9650_RSVD1, 0x91},
{OV9650_ADC, 0x04},
{OV9650_OFON, 0x40}, /* Do something out of spec with the power */
{OV9650_ACOM38, 0x12},
{OV9650_COM1, 0x20}, /* Set QQVGA or QQCIF */
{OV9650_COM8, 0xc0}, /* Set fast AGC/AEC algorithm with unlimited step size */
{OV9650_BLUE, 0x80}, /* Set blue and red to default values again */
{OV9650_RED, 0x80},
{OV9650_GAIN, 0x00}, /* Set gain to zero */
{OV9650_AECH, 0xf0}, /* Set exposure [9:2] */
{OV9650_PSHFT, 0x00}, /* Set pixel delay to zero (default) */
{OV9650_RSVD16, 0x06},
{OV9650_CHLF, 0x10},
{OV9650_ARBLM, 0xbf},
{OV9650_ACOM38, 0x81},
{OV9650_COM16, 0x00}, /* Turn off color matrix coefficient double option */
{OV9650_RSVD96, 0x04},
{OV9650_COM13, 0x19}, /* Enable color matrix for RGB/YUV, Delay Y channel, set output Y/UV delay to 1 */
{OV9650_HV, 0x80},
{OV9650_TSLB, 0x0d}, /* Enable digital BLC, Set output mode to U Y V Y */
{OV9650_COM24, 0x00}, /* Limit the AGC/AEC stable upper region */
{OV9650_COM12, 0x73}, /* Enable HREF and some out of spec things */
{OV9650_DBLC1, 0xdf}, /* Set all DBLC offset signs to positive and do some out of spec stuff */
{OV9650_COM21, 0x06},
{OV9650_RSVD1, 0x91},
{OV9650_RSVD94, 0x99},
{OV9650_RSVD95, 0x99},
{OV9650_COM15, 0xc0}, /* Enable full range output */
{OV9650_COM6, 0x4b}, /* Enable HREF at optical black, enable ADBLC bias, enable ADBLC, reset timings at format change */
{OV9650_BBIAS, 0xa0}, /* Subtract 32 from the B channel bias */
{OV9650_GbBIAS, 0xa0}, /* Subtract 32 from the Gb channel bias */
{OV9650_Gr_COM, 0xa0}, /* Bypass the analog BLC and to some out of spec stuff */
{OV9650_RBIAS, 0xa0}, /* Subtract 32 from the R channel bias */
{OV9650_COM26, 0x80},
{OV9650_MVFP, 0x04},
{OV9650_ACOMA9, 0x98},
{OV9650_AEW, 0x68}, /* Set the AGC/AEC stable region upper limit */
{OV9650_AEB, 0x5c}, /* Set the AGC/AEC stable region lower limit */
{OV9650_VPT, 0xc3}, /* Set the high and low limit nibbles to 3 */
{OV9650_COM9, 0x4e}, /* Set the Automatic Gain Ceiling (AGC) to 32x,
drop VSYNC at frame drop,
limit exposure timing
drop frame when the AEC step is larger than the exposure gap */
{OV9650_MVFP, 0x00}, /* No flip or mirroring */
{OV9650_COM10, 0x42}, /* Set VSYNC negative, Set RESET to SLHS (slave mode horizontal sync) and set PWDN to SLVS (slave mode vertical sync) */
{OV9650_HSTART, 0x1a}, /* Set horizontal column start high to default value */
{OV9650_HSTOP, 0xbf}, /* Set horizontal column end */
{OV9650_HREF, 0xb2}, /* Complementing register to the two writes above */
{OV9650_VSTRT, 0x02}, /* Set vertical row start high bits */
{OV9650_VSTOP, 0x7e}, /* Set vertical row end low bits */
{OV9650_VREF, 0x10}, /* Set complementing vertical frame control */
{OV9650_COM7, 0x45}, /* Set raw RGB output format with VGA resolution */
{OV9650_PSHFT, 0x00}, /* Set pixel delay to zero */
{OV9650_ADC, 0x04},
{OV9650_HV, 0x40},
{OV9650_COM22, 0x23}, /* Enable denoise, and white-pixel erase */
{OV9650_LCC1, 0x00}, /* Set Lens correction option to default values */
{OV9650_LCC2, 0x00},
{OV9650_LCC3, 0x10},
{OV9650_LCC4, 0x80},
{OV9650_LCC5, 0x01}, /* Set correction from 00 to 01 */
{OV9650_LCCFB, 0x00},
{OV9650_LCCFR, 0x00},
/* 64, 73 */

{OV9650_BLUE, 0x80}, /* Set the blue and red gain to default yet again */
{OV9650_RED, 0x80},
/* 2, 75 */

{OV9650_AECH, 0x29}, /* Set the high bits of the exposure value */
{OV9650_COM1, 0x03}, /* Set the low bits of the exposure value */
{OV9650_GAIN, 0x02} /* Set the gain */