yashsingh1/xdaforums huggingface dataset:
[XPERIA X1 Android Development] drlucky:
First approach of battery driver committed

Hi all,

I have just committed thr first approach for the new battery driver, which is based on the kaiser ds2746 implementation.

The battery level now seems more exact and doesn't "jump nervously" around any more. And the phone is running until the battery is really empty.

Current drawbacks:

1) I think the percentage is not quite right by now, so expect some different percentages than in WinMo.

2) Charging doesn't seem to work at all. The battery symbol shows the charging animation, but the driver doesn't show any growing battery level.

If anyone is interested and may have a suggestion about (2), just let me know.

BTW: I'm using a local branch "develop" on my machine and it seems that all merges and pushes between my local branches are shown in the commit log of our repo - don't be confused, the result should be OK at all ...

I have compiled a kernel with vdelfs fantastic background led changes, but it seems that the kernel nevertheless uses a lot of energy even with background disabled. I suppose we need to get our hands on the power-save functions of some of the hardware in more detail, or we will never get a x1 running at least a single day on android ... seems like still a long way to go ...
[XPERIA X1 Android Development] X1iser:
For save power, Is it possible to "downclock" the CPU and turn off Wifi when screen is OFF?
[XPERIA X1 Android Development] hotlein:
Kovsky Speaker

Hi @all

I have seen at startup the following lines in log

[ 26.899383] DBG: snd_ioctl set_device: device 1
[ 26.908294] DBG: setting GPIO for kovsky headphone...
[ 26.920288] DBG: power down headphone amp...
[ 26.930145] DBG: enabling kovsky speaker...

it seems, that the kovsky speaker always on.

@X1iser

the downclock should work (see bold line in log)

[ 522.004364] microp-klt: Setting lcd-backlight brightness to: 0x5f
[ 522.024169] microp-klt: Setting lcd-backlight brightness to: 0x58
[ 522.044006] microp-klt: Setting lcd-backlight brightness to: 0x51
[ 522.064147] microp-klt: Setting lcd-backlight brightness to: 0x4a
[ 522.084289] microp-klt: Setting lcd-backlight brightness to: 0x43
[ 522.104492] microp-klt: Setting lcd-backlight brightness to: 0x3d
[ 522.124267] microp-klt: Setting lcd-backlight brightness to: 0x36
[ 522.144317] microp-klt: Setting lcd-backlight brightness to: 0x2f
[ 522.164794] microp-klt: Setting lcd-backlight brightness to: 0x28
[ 522.184783] microp-klt: Setting lcd-backlight brightness to: 0x21
[ 522.204864] microp-klt: Setting lcd-backlight brightness to: 0x1b
[ 522.224945] microp-klt: Setting lcd-backlight brightness to: 0x14
[ 522.245025] microp-klt: Setting lcd-backlight brightness to: 0x0d
[ 522.265106] microp-klt: Setting lcd-backlight brightness to: 0x06
[ 522.285430] microp-klt: brightness==0, turn lcd-backlight OFF
[ 522.305847] request_suspend_state: sleep (0->3) at 516390000000 (2010-05-09 20:06:52.850000000 UTC)
[ 522.305938] [B]Sending arm9_low_speed 2[/B]
[ 522.306030] msmfb: panel sleeping
[ 522.326385] epson_blank
[ 522.326416] init epson blank
[ 522.683654] blackstone panel deinit
[ 522.740478] epson_suspend
[ 522.740600] htc_pwrsink: ID 0, Util 7%, Total 7000 uA
[ 522.812469] active wake lock PowerManagerService
[ 522.812591] active wake lock vbus_present
[ 522.812652] wake lock mmc_delayed_work, expired
[ 522.812713] wake lock SMD_DATA1, expired
[ 522.812774] active wake lock SMD_DS, time left 28
[XPERIA X1 Android Development] _Sensible:
@hotlein

Regarding: downclock - There doesnt seem much difference between '2' and '7' as was with kaiser:

[ 314.477752] Sending arm9_low_speed 7
[ 314.477905] PLL0 @ f8005300: MODE=00000007 L=0000000c M=00000004 N=00000005 freq=245760000 Hz (245 MHz)
[ 314.478057] PLL1 @ f800531c: MODE=00000007 L=00000028 M=00000000 N=00000001 freq=768000000 Hz (768 MHz)
[ 314.478210] PLL2 @ f8005338: MODE=00000007 L=00000037 M=00000000 N=00000001 freq=1056000000 Hz (1056 MHz)
[ 314.478363] PLL3 @ f8005354: MODE=00000000 L=0000002d M=00000000 N=00000001 freq=864000000 Hz (864 MHz)
[ 239.183319] Sending arm9_low_speed 2
[ 239.183563] PLL0 @ f8005300: MODE=00000007 L=0000000c M=00000004 N=00000005 freq=245760000 Hz (245 MHz)
[ 239.183715] PLL1 @ f800531c: MODE=00000007 L=00000028 M=00000000 N=00000001 freq=768000000 Hz (768 MHz)
[ 239.183837] PLL2 @ f8005338: MODE=00000007 L=00000037 M=00000000 N=00000001 freq=1056000000 Hz (1056 MHz)
[ 239.184051] PLL3 @ f8005354: MODE=00000000 L=0000002d M=00000000 N=00000001 freq=864000000 Hz (864 MHz)

@drlucky

Re battery charging - have you looked into uevents and not polling the values?
[XPERIA X1 Android Development] drlucky:
Not quite sure what you mean - normally the ds2746 internally accumulates the capacity of the battery by measuring the drain and charge all the time.

What's uevents (I'm not a linux kernel specialist at all) and what kind of information can I get there? Sounds interesting and very internal ... :)

I wanted to test the following procedure:

1) start android

2) let battery drop to a few percent

3) attach charger

4) android shoud shut-down on 0% (or at least <= 2%)

5) if winmo shows much more that 2%, charging is happening but just not recognized by battery driver - otherwise charging isn't working any more
[XPERIA X1 Android Development] _Sensible:
@drlucky

I mean making use of:

power_supply_changed()

Unfortunately I havent got much free time at the moment, hopefully i will soon :). I'm sure you have already but if not, take a look at how kaiser deals with ds2746 chip here

:)
[XPERIA X1 Android Development] _Sensible:
Ah, I see the driver I posted above is now outdated :(

Forget the above post :)
[XPERIA X1 Android Development] Mic159:
There must be a switch on the chip because in WinMo you can choose if you want the charger to work or not. Its for if you wanted it to just initiate the USB data connection but not charge I guess.
[XPERIA X1 Android Development] Reversedhex:
but the switch is always on, unless you turn it of in winmo
[XPERIA X1 Android Development] _Sensible:
@drlucky,

Just out of interest, how are you checking battery capacity?

I only ask beacuse I have compiled your latest changes and charging appears to work...

In the space of 40mins my battery was charged from 26% to 34% according to android...perhaps I missed something?

:)
[XPERIA X1 Android Development] drlucky:
Approved - charging works, but is really slow and maybe even might not charge at all when connected by USB. I think the android currently eats more or less the same amount of battery the usb charger can provide.

Should get better as soon as we can reduce the battery consumption of the system. :D
[XPERIA X1 Android Development] _Sensible:
@drlucky,

Yep. In which case, thanks to your excellent work we have a working battery driver...

Onto the next issue!?
[XPERIA X1 Android Development] nemasu:
Button Lights

Any progress on button lights always staying on?

Just looking at previous posts,

-writing 0x00 0xff to 0x14 deactivates keypad backlight

might do it?

In microp-klt.c,

idx of 6 (later added to 14) being "button-backlight" or "klt::keypad-bkl"

doesn't seem to be handled.....then again im not even sure if thats what is used to set button lights......anyone know?
[XPERIA X1 Android Development] drlucky:
You're welcome. I just used the kaiser code and tweaked a little bit. And currently the battery capacity is hard-coded and most likely not 100% correct. So still a bit of work there.

Next item maybe: disable speaker if not used anymore? Maybe I need to get a little more into the android part of this issue, since technically the kernal is able to disable the speaker.
[XPERIA X1 Android Development] Tremere:
I built a kernel with that patch last night and left it to charge all night with Android running, this morning the charge meter was still at 60%.

While I was playing around last night getting the kernel on there, when I rebooted into WinMo it reported around 80% rather than 50-60% on Android. Calibration issue?
[XPERIA X1 Android Development] angusmcb:
If you left it on all night, it should definitely have been 100% in both :-)

Was the phone warm when you picked it up in the morning?
[XPERIA X1 Android Development] Tremere:
No, wasn't warm, WinMo reported Full when I rebooted into it.

Now 35 (WinMo) translates to 22 in Android, reported battery voltage 3823mV
[XPERIA X1 Android Development] _Sensible:
@Tremere

drlucky has said the percentages will be a little out. I dont think this is a major issue.

With regards to charging, it appears that although charging is working fine, android is VERY power hungry at the moment.

Hope that helps
[XPERIA X1 Android Development] ilgreco112:
keep on working guys !!! I know you can fast find a good and complete issue for android working at 100%, even Camera and GPS dont even matter for me as I nearly never use it! I cant even help you As I dont know.... so please let's do it!!! I'll really really love it !!!! thank you very very very very very much!!!
[XPERIA X1 Android Development] vdelf:
After looking through drluckys excellent driver conversion and reading the ds2746-datasheet, i am quite sure, that the value for KOVSKY_RSNS is not 10 but 15 mOhm. Booting up android with the new driver compiled and battery charged up to around 90% i got a value of 3056 from the CURRENT_ACCUM-register. The resolution is 6.25mVh per Bit so

3056 * 6.25 = 19100 mVh

This is divided by the Rsns to get the capacity. Using 10 would mean that there are 1910mAh charged into the 1500mAh-battery ;)

Using 15mOhm gives 19100/15 = 1273mAh, and that is 85% of 1500mAh, and that makes sense.

Please give it a try (also KOVSKY_BATTERY_RATING = 3600, that is 1500mAh * 15mOhm / 6.25mVh), it should give a more accurate capacity reading. I will try it myself as soon as i can :o
[XPERIA X1 Android Development] drlucky:
Sorry, doesn't work for me. In WinMo 49%, booted Android: 22%, booted WinMo: 44%

Maybe android saved my too large values last time, so I need to dig a little bit deeper into this.

But your calculations seem to make sense. Maybe I can get my hands on it on Sunday.
[XPERIA X1 Android Development] vdelf:
well, that is because level calculation is wrong.

The variable battery_capacity contains the max capacity value converted to the same type that is stored in the current accumulation register. Variable s contains the actual readout of the current accumulation register. That variable should always be between zero and battery_capacity. So the correct formula to calculate the level is

b->level = (s * 100) / battery_capacity;

I just tried it and it gives nearly the same level as WiMo: 90% Wimo (only 10%-steps) - 98%Android.

I noticed a division by zero error in the htc_battery_smem module. Maybe thats why charging is not working propery. At least on my phone it only lessens the drain, but does not charge. According to dmesg the phone uses around 200mA, sucking the battery dry in around 8 hours :(

edit:

The division by zero is in get_battery_id_detection, commenting out

if ( get_battery_id_detection( buffer ) < 0 ) {
mutex_unlock(&htc_batt_info.lock);
return -EINVAL;
}

in htc_battery_smem "fixed" this, and now my phone charges with 250mA :D
[XPERIA X1 Android Development] angusmcb:
in init_battery_settings() the reading of the smem addresses returns 0,

which is used as a divisor and causing the error, as far as I an see.

Edit:

sorry, could be in get_battery_id_detection() alright:

batt_id=( batt_id * 0xA28 ) / htc_adc_range;
[XPERIA X1 Android Development] jkoljo:
Your process is really good. Too bad I cannot help you in any good way, but I can at least tell my experiences. In the current not battery fixed Android my battery lasts about 7 hours in standby, battery level does not go below 70%.

Keep up your work, many people appreciate it even though they do not come here to say it :)
[XPERIA X1 Android Development] pirlano:
very good work! a full android porting would make X1 immortal! :D

happy to test newer kernels :)
[XPERIA X1 Android Development] vdelf:
I am done tuning the capacity-values in our new battery-driver. The changes are now in the repository, feel free to play with it. :)
[XPERIA X1 Android Development] hotlein:
@vdelf

how can I get only the changes from repo to my local with git? Can You put an example here?

thanks

btw. in wich files can I find the code for the speaker?

if I play a sound i.e. I press the volume+ Button, then I see the following lines in log. I hear "GPRS Traffic" at the Speaker

[82792.757690] snd already opened.
[82792.757781] DBG: snd_ioctl set_device: device 1
[82792.757812] DBG: setting GPIO for kovsky headphone...
[82792.757842] DBG: power down headphone amp...
[82792.757903] DBG: enabling kovsky speaker...

now i plug in the Headphone,i hear the Speaker to

[83922.578613] DBG: h2w_config_cpld 0<6>DBG: h2w_config_cpld GPIO
[83922.638793] [H2W] is_accessary_pluged_in (0,0) (0,0) (0,0)

now i play a sound i.e. I press the volume+ Button, the Speaker is off

[83979.346557] snd already opened.
[83979.346679] DBG: snd_ioctl set_device: device 10
[83979.346740] DBG: setting GPIO for kovsky headphone...
[83979.346771] DBG: power down headphone amp...
[83979.346832] DBG: disabling kovsky speaker...

now I plug out the Headphone, the Speaker is always off til I play a new Sound.

Sorry for my bad english.

regards
[XPERIA X1 Android Development] n00b3r:
Just wondering; is there a guide in to compiling the kernel from gitorious? I want to try out the new changes, but I'm clueless when it comes to git.
[XPERIA X1 Android Development] sp3dev:
You can download the tree snapshot via the site or clone the tree (which is a bit harder). Then, compile as usual. Here is how I do

export kvers=xperia
export PATH=/home/alexander/handhelds/armv6/codesourcery/bin:$PATH
export ARCH=arm
export CROSS_COMPILE=/home/alexander/handhelds/armv6/codesourcery/bin/arm-none-linux-gnueabi-
cd /home/alexander/handhelds/linux-$kvers
#make htckovsky_defconfig
make htc_msm_android_defconfig
make -j4 ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE zImage modules
rm -r /home/alexander/handhelds/modules/
make modules_install INSTALL_MOD_PATH=/home/alexander/handhelds/modules/
[XPERIA X1 Android Development] Musse_1:
a question, when changes are pushed in the repository, will they be part of Glemsom kernel autobuild ?

http://glemsom.anapnea.net/android2/htc-msm-linux/

thanks:)
[XPERIA X1 Android Development] Tremere:
There are also instructions on the wiki:

http://wiki.xda-developers.com/inde...ngx20.thex20.Kernelx20.fromx20.thex20.Sources

Question: I added the instructions on compiling the WiFi driver a few days ago, is using the TI driver still the preferred method? As compat-wireless didn't get me anywhere (missing symbols in module)
[XPERIA X1 Android Development] knownie:
You guys are fabulous. Thanks for you effort.
[XPERIA X1 Android Development] angusmcb:
To get rid of missing symbol errors & various other warnings when compiling compat-wireless,

adjust your kernel config to enable: CRC7 in library routines, SPI in device drivers

and QOS in networking options.

To get your hands on a known working config, boot up a working kernel,

shell to the phone and do: zcat /proc/config.gz >myconfig

then you can load this config as a starting point for building your kernel.

It is best to use a kernel built from the same git revision for this.
[XPERIA X1 Android Development] drlucky:
Hi,

From my point of view this is true for all changes that are merged into the "main" repository used by the autobuild.

Changes that are currently only in our forked repo are not included in the autobuild
[XPERIA X1 Android Development] Musse_1:
would it be possible for you to share a copy of your kernel build & wifi modules that using the TI driver? for us to test it with sense build.

thank you :)
[XPERIA X1 Android Development] Tremere:
Sure,

zImage

Modules
[XPERIA X1 Android Development] vdelf:
Go into your working dir and type git pull to get all changes missing in your repo.

On the gitorious-website you can browse through changes and look what files are changed. Look for speaker- or headset-changes and you will find some of the relevant files.

Take a look at the following files to get started:

arch/arm/mach-msm/qdsp5/external.c

arch/arm/mach-msm/qdsp5/snd.c

arch/arm/mach-msm/htc_headset.c

Hope this helps.
[XPERIA X1 Android Development] marijn26:
GPS working on Diamond

see http://xdaforums.com/showthread.php?t=601751

could this be used for Xperia as well?
[XPERIA X1 Android Development] vdelf:
I could not find any details on what/how gps was fixed. It seems, that something was modified in the rootfs.img :confused:

Do you have any more infos on that?
[XPERIA X1 Android Development] demichiel:
@vdelf and other devvers

xdandroid.southcape.org/rootfs

I can't link yet, but you'll get the message no?

Here is the rootfs directory/changelog.

I found the following:

So I guess the major differences should be found here. Afterwards there are a lot of 'libhardware_legacy' tweaks, but they don't seem to have the key to enabling gps.

You can find the changes in the git-repo, but they're jibberish to me. Non-linked link:

gitorious.org/xdandroid-eclair/eclair-rootfs

The Rhodium (whose GPS was enabled first) uses the MSM7201A chipset, where the X1 uses the MSM7200A chipset.

But the Topaz uses the MSM7200A chipset as well, and I think the 'other devices' includes the Topaz.

So let's hope you'll find the made changes in the rootfs file!

Best of luck with it, really curious!

Any luck of authenticating me as a 'real' user?
[XPERIA X1 Android Development] Musse_1:
without knowing all details, yes it looks like changes made in rootfs to "libhardware_legacy_ti.so" and "bcm4325-libhardware_legacy.so" which is wifi???

but I think kernel has also been updated "board-htcraphael-gps.c", "board-htcblackstone.c", "board-htctopaz.c" etc...and maybe similar need to be defined in "board-htckovsky"

could be good to ask phhusson to give some hints:)
[XPERIA X1 Android Development] demichiel:
I asked Phusson for some hints/help.

What do our devs think about this? (Adding the X1 code to the XPEROID repo)
[XPERIA X1 Android Development] raja'i:
@ our Great Dev's

y cant we join the XDAndroid project?

as far as i know, they didn't develop kernels for kovsky cause they lack X1 Developers

i mean, with the experience of our great dev's we can save very long time and effort and make our x1 android better and better in no time

ur work is great, and the all achievements u done alone without any aid proves that

am very happy with the point we have reached

and i hope to c the development gets better and better

thanx aloot for all ur work, and im just glad we have u
[XPERIA X1 Android Development] Reversedhex:
Could someone please test the battery draining by comparing a kernel with and one without speaker.

Because the constant amplifying could be both for the cpu and the speaker a huge energy loss.
[XPERIA X1 Android Development] gamer-Kenny:
What about adding Bluetooth to the todo list? Or is it already working?
[XPERIA X1 Android Development] tosomax:
am i the only one who notice that the speaker is always on?

there is a solution?
[XPERIA X1 Android Development] gamer-Kenny:
Noticed that too, a "workaround" is plugin and plugout the headset, speaker is muted until a sound is played
[XPERIA X1 Android Development] ilgreco112:
hmm I dont think I want to do that everytime I sue my phone ^^
[XPERIA X1 Android Development] scholbert:
Hi!

Nope.... i think we were very close someday, while stepping through the register set of the Epson chip.

At the moment i use my X1 everday and stopped to mess around with ROMs and stuff, because everything does what it should do.

Anyway, maybe i'll start to investigate again.

BTW, great effort on general development... impressive work at the kernel base... very nice stuff :D

Have fun!

scholbert
[XPERIA X1 Android Development] learyt:
developers check this:

Kernel update: Add Kovsky microp ID (seems to be really different from other microps... perhaps would need anoth..... http://bit.ly/9ADHH6

http://gitorious.org/linux-on-qualc...tml?utm_source=twitterfeed&utm_medium=twitter
[XPERIA X1 Android Development] angusmcb:
I've been messing around with this quite a lot, but all I have managed so far is to mirror the display and split it in two simultaneously :D

Maybe some of the memory addresses and start offsets etc need to be set up properly in the Epson in order to use these write-path facilities, but I can't seem to nail them.
[XPERIA X1 Android Development] drlucky:
Offline for a little while

Hi all,

Just wanted to inform you that I will be offline for 2-3 weeks ... so if you want something specifically from me, you need to wait a few more days than usual ... :)
[XPERIA X1 Android Development] ilgreco112:
Noooooooooo we need youuuu :'(, see you soon!
[XPERIA X1 Android Development] ilgreco112:
so where you at with battery ?? is it finely fixed? bc some continue saying that its too hot and short
[XPERIA X1 Android Development] matejdro:
Yeah first post is wrong. It's not yet fixed.

I downloaded may 18 2.0.1 version and battery was still 15% in android compared to the WM 70%. And it was still hot.
[XPERIA X1 Android Development] ilgreco112:
that's bad :(, can you be helped with Other phones to see whats up with the code ?? or with the x10 or something, I dont know anything about this I'm a beginner in programming but I know how it works...

so bad that I dont know more things about this... I would do my best and work on it like no other !!
[XPERIA X1 Android Development] vdelf:
Hmm, strange. The battery level should be fixed. Was your kernel build from the xdadev-repos?

Please try this one (see attachment), it should be much more accurate. It does NOT fix the hot battery. But if it displays the current correct, than we can start to find the culprits for the high energy needs :)

Atm the only way i know of to get the values is to start a terminal and type dmesg or better dmesg | grep ds2 to get the linux kernel output. Android does not display current, only voltage :(

edit:

Output should look like this

[ 296.845916] ds2746: 4040mV 390mA charge: 48/100 (3019 units) aux0: 161 (845) aux1: 169 (893)
[XPERIA X1 Android Development] ilgreco112:
Vdelf I love you! I'm waiting you to fix it all and get a great Rom !!!!
[XPERIA X1 Android Development] sanjayecb:
i compiled the kernel from the latest repos

from the git

and included wifi also

it seems fine to me as of yet
[XPERIA X1 Android Development] ilgreco112:
did u find anythig for froyo? they say is much better and faster so maybe you can go 2.2?
[XPERIA X1 Android Development] Tremere:
Might be better to just wait for the 2.2 source to come out.

BTW I see that one could build Dalvik (the java vm in android) with JIT enabled, this might give us a similar speed boost on 2.1

A friend who has an N1 had a go on my Xperiod today, said is was laggy even by 2.1 standards (accounting for the big CPU diff between Xperia and N1 as well), so there is opportunity to make it better before we go to 2.2

@matejdro Are you definitely sure you downloaded the latest release?
[XPERIA X1 Android Development] ilgreco112:
hey where are y'all ? is anybody working on xperoid ?

we all wait for you!!! we love you!
[XPERIA X1 Android Development] ilgreco112:
I took a look @ XDandroid developement for HTC and I saw that some fixed GPS so maybe it could help?
[XPERIA X1 Android Development] Tremere:
I've got a system running on the Xperia with compat wireless modules and I'm not having any luck getting them working.

I've mounted debugfs and tried prodding it by toggling wifi_cd, wifi_pwr etc, its not associating at all. Yes, wifi was on in WM before booting.

(I'm using iwconfig to set essid, just in case I should be looking elsewhere)

BTW, I have Gentoo running on the Xperia, 1) because I'm familiar with it 2) easier than trying to muck with an Android rom for module testing etc.

http://wiki.xda-developers.com/index.php?pagename=Gentoo_on_HTC

Once I hammer down a method for getting most packages compiling I'll expand that page. I'm learning the hard way a lot of stuff isn't cross compile friendly :mad: