[XPERIA X1 Android Development] ultrashot:
Examples for backlight hackers. For WM. I really don't have enough time to integrate it to kernel :)

base wrappers for i2c:

int devcontrol(int devicecode, int channel, unsigned char *buf, int buf_size)
{
HANDLE device=CreateFileW(L"I2C1:",0xC0000000,0,0,3,0,0);

#pragma pack(1)
typedef struct
{
unsigned char devcode;
unsigned char smth1;
unsigned char channel;
unsigned char dummy;
unsigned int length;
unsigned char *massive;
}I2C;
#pragma pack()

I2C i2c;
i2c.devcode=devicecode;
i2c.channel=channel;
i2c.smth1=1;
i2c.length=buf_size;
i2c.massive=buf;
for (int x=0;x<3;x++)
{
if (DeviceIoControl(device,0x80100024,&i2c,sizeof(I2C),NULL,NULL,NULL,NULL))
goto away;
DeviceIoControl(device,0x80100014,&i2c,sizeof(I2C),NULL,NULL,NULL,NULL);
Sleep(0xA);
}
CloseHandle(device);
return -1;
away:
CloseHandle(device);
return S_OK;
};

// i2c control for simple i2c requests
int devcontrol2(int devicecode, int channel)
{
HANDLE device=CreateFileW(L"I2C1:",0xC0000000,0,0,3,0,0);

#pragma pack(1)
typedef struct
{
unsigned char devcode;
unsigned char channel;
unsigned char smth1;
unsigned char dummy;
}I2C2;
#pragma pack()

I2C2 i2c;
i2c.devcode=devicecode;
i2c.channel=channel;
i2c.smth1=1;
for (int x=0;x<3;x++)
{
if (DeviceIoControl(device,0x8010000C,&i2c,sizeof(I2C2),NULL,NULL,NULL,NULL))
goto away;
DeviceIoControl(device,0x80100014,&i2c,sizeof(I2C2),NULL,NULL,NULL,NULL);
Sleep(0xA);
}
CloseHandle(device);
return -1;
away:
CloseHandle(device);
return S_OK;
};

These wrappers are equal to ones from n5ledmgr.dll.

And real examples:

int keypad_control(int mode, int brightness)
{
unsigned char buf[2]={0x94,mode ? 0xff : 0};
return devcontrol(0xCC /*microp_klt*/, 0x14 /*let's call it MICROP_KLT_ID_KEYPAD_BRIGTNESS_KOVS*/, buf, 2);
};

can be easily translated to linux code as I showed before:

micropklt_write(client, <<0x14, 0x94, brightness>>, 3);

int qwerty_control(int mode, int brightness)
{
unsigned char buf[9]={mode ? 0 : brightness, mode ? 0x40 : 0xFF, mode ? brightness : 0, 0, 0, 0, 0, 0, 0};
int ret=devcontrol(0xCE /*microp_ksc*/, 0x32, buf,9);
if (ret!=S_OK)
return -1;

ret=devcontrol2(0xCE,0x30);
if (ret!=S_OK)
return -2;
return S_OK;
};

I am not sure how to translate devcontrol2 to linux code. Probably it is gpio request?

But don't use such a great brightness, it is a lot more than enough.

Also I have i2c pattern activating code (interesting for charging):

int color_control(int mode)
{
int retval;
if (mode) //activating
{
unsigned char buf1[0x5C]={0x00,0x00,0x02,0x30,0x1A,0x00,0x1B,0x00,0x1C,0x00,0x1D,0x00,0x1E,0x00,0x1F,0x00,0x20,0x00,0x64,0x00,0x00,0x00,0x02,0x00,0x1A,0x00,0x1B,0x00,0x1C,0x00,0x1D,0x00,0x1E,0x00,0x1F,0x00,0x20,0x00,0x64,0x00,0x00,0x00,0x02,0x00,0x1A,0x00,0x1B,0x00,0x1C,0x00,0x1D,0x00,0x1E,0x00,0x1F,0x00,0x20,0x00,0x64,0x00,0x0A,0x0F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x32,0x00,0x4B,0x00,0x64,0x00,0x7D,0x00,0x7E,0x00,0x7F,0x00,0x80,0x00,0xE1,0x00,0xFC,0x04}; //it is array with pattern
retval=devcontrol(0xCC /*microp_klt*/,0x41,buf1,0x46);
if (retval!=S_OK)
return -1;

unsigned char buf2[0x5C]={0x00,0x00};
retval=devcontrol(0xCC /*microp_klt*/,0x11,buf2, 0x2);

if (retval!=S_OK)
return -2;

int mystic_integer=*((int*)(0xBA081C2C));

if (mystic_integer>=0x400)
mystic_integer=1;
else
mystic_integer=0x1E;

unsigned char buf3[2]={buf1[0x5A], mystic_integer};
retval=devcontrol(0xCC /*microp_klt*/,0x11,buf3, 0x2);
if (retval!=S_OK)
return -3;
}
else //disactivating
{
int mystic_integer=*((int*)(0xBA081C2C));

if (mystic_integer<=0x400)
mystic_integer=0x10;
else
mystic_integer=0;

unsigned char buf3[2]={0, mystic_integer};
retval=devcontrol(0xCC /*microp_klt*/,0x11, buf3, 0x2);
if (retval!=S_OK)
return -4;
}
return S_OK;
}