I don't have a working build environment and I'm not sure how to do this. I want to edit the file from source. The source code path is:
msm/drivers/power/ds2784_battery.c
Which belongs in the file system:
/sys/devices/platform/ds2784-battery
I specifically want to edit one line of code and change the following line 380:
(di->status.current_uA <= 80000) &&
And change it to
(di->status.current_uA <= 10000) &&
I don't know enough, but is it possible to make a small edit like this and recompile just this individual file, and then for me to push this edited file to my phone(rooted obviously)? Is this feasible or am I just in way over my head? If anyone could guide me, or better yet make this edit for me I would be very greatful and willing to test it out on my phone. Thanks.
Hi,
I build the file for you from synced tree about 20min ago from cyanogen's repository.
Unfortunately, u can't push any files to /sys even when you have root because those files are automaticaly generated by kernel as same as files in /dev.
So i build the whole kernel for nexus one with that modification you want.
single file is there http://www.multiupload.com/WJA1GXEANV
and whole kernel is there http://www.multiupload.com/BS3YR6P2K1
Just to notice you, you wanted to lower the value from 80000 to 10000 but there is just 1024 instead of 80000 in the cyanogen's source so i raised it to 10000 as you want.
Hope this helps. Let me know if this works..
(and sorry for my english )
Thank you. I'm not sure I understand. Are you saying that the cyanogen version of this file ds2784_battery.c was not set to 80000 like the stock source code showed? You say that you had to raise that value from 1024. I don't understand why it would be different than AOSP. Thank you, I'll try it when I get home.
Yes, you understand right, cyanogen's source have that value on 1024 but don't know why.
Yes I am looking at the cyanogen code now, and It is different than AOSP file. However running cyanogen ROM the file still behaves as if 80000 was there. Hope I can find the correct value and I will post back. Thanks
I just looked at the source again and maybe i changed something else because line 380 is not same as you wrote.
Look yourself here http://github.com/CyanogenMod/cm-kernel/blob/android-msm-2.6.34/drivers/power/ds2784_battery.c
Yes the code is different, so I am looking for the Correct line to change. Thank I'll post back when I find it.
I've looked and looked thru as much as i could, and i cannot locate the identified code i found in the earlier version, where it speifies mA < 80000 (80 mA). the strange thing is that my current installation of cyanogen RC3 is still functioning as if 80 mA were set. the charger shuts off still at 80 mA. maybe someone else can guide me to see what i'm missing.
ok i have the new code i'd like to try out if you dont mind. i'm running cm rc3, and wanted to edit the ds2784_battery.c file with the following line 450:
original:
PHP:
if (di->status.status_reg & 0x80) {
di->status.battery_full = 1;
charge_mode = CHARGE_BATT_DISABLE;
} else
di->status.battery_full = 0;
new
PHP:
if ((di->status.status_reg & 0x80) && (di->status.current_uA <=20000)) {
di->status.battery_full = 1;
charge_mode = CHARGE_BATT_DISABLE;
} else
di->status.battery_full = 0;
only one change was made to line 450. could you make a flashable file? thanks so much if you have the time
Rog, just in case you were waiting for a notification here:
http://forum.xda-developers.com/showpost.php?p=7819793&postcount=261
This thread should be used for bugreporting and troubleshooting.
FolioTNTmod 0.4 ONLY.
Please make sure to post a detailed description of the issue, under what curcumstances it occures, and which processes are running.
Use the search function to make sure your issue hasn't already been solved before you post.
I've found a way to access Accounts Sync and Keyboard installation.
first, Accounts Sync :
- you must install LauncherPro even if you do not use it.
- On the desktop, add a new shortcut, select "Activities".
- Under "Account Settings and Sync" select "com.android.settings.ManageAccountsSettings.
Well, now you have a shortcut on the desktop to access the sync settings.
Keyboard installation :
After installing your alternative keyboard, copy the APK from /data/app/ to /system/app/
I create a simple script (in Gscript) that mount the file system as read/write , copy the APK, and enable the "SmartKeyboardPro" keyboard (after reboot).
code :
Code:
su
mount -o remount,rw /dev/block/mmcblk0p1 /system
cp /data/app/net.cdeguet.smartkeyboardpro-1.apk /system/app/
**optional**
reboot
**optional**
I was playing with Angry birds and after a reboot the application was corrupted in some way, the icon dissapeared and I had to reinstall, but the configuration was saved.
In anycase I used Angry Birds backup to backup it and after Andexplorer to copy the backup from the internal SD to the external one, to my surprise, the internal one was not present on Andexplorer (but I was able to go trought /mnt/sdcard).
Now I can see it again but there are a lot of files DiskCacheIndexxxxx.tmp, any clues?
julio77 said:
Keyboard installation :
After installing your alternative keyboard, copy the APK from /data/app/ to /system/app/
I create a simple script (in Gscript) that mount the file system as read/write , copy the APK, and enable the "SmartKeyboardPro" keyboard (after reboot).
Click to expand...
Click to collapse
Yeah, thank you for this tweak
Orientation has some problems..
getWindowManager().getDefaultDisplay().getRotation()
should return 0, when Orientation is setted to Landscape...
but it returns Surface.ROTATION_90.
(I'm using 0.4a version)
Davide
This is intended behaviour. It fixes the sensor issues for many applications, as developers didn't prepare their apps for devices with natural orientation set to landscape.
Is this causing any problems for you?
Thank you for your reply.
I'm developing an android game that uses accelerometer to evaluate gravity force's vector. I would like to write portable code (to work on both phones and tablets), so the right code to evaluate gravity (ignoring other forces) should be:
screenRotation = getWindowManager().getDefaultDisplay().getRotation();
[...]
float x;
float y;
float z;
if (screenRotation == Surface.ROTATION_0) // Default portrait
{
x = event.values[0];
y = event.values[1];
} else if (screenRotation == Surface.ROTATION_90) // Default landscape
{
x = -event.values[1];
y = event.values[0];
} else if (screenRotation == Surface.ROTATION_180)
{
x = -event.values[0];
y = -event.values[1];
} else// (screenRotation == Surface.ROTATION_270)
{
x = event.values[1];
y = -event.values[0];
}
z = event.values[2];
gravity.x = -x;
gravity.y = -y;
gravity.z = -z;
This should be the right way to ensure portability.. (it's similar to the Nvidia 'Android Accelerometer Whitepaper''s way),
but it's not working with this patch on Folio (y results in reverse, and rotation sensibility is weird)..
So, to ensure compatibility to games coded only for portrait-native oriented (and, in the same time, ensure correctness to the right written codes), it is not enough to return Surface.ROTATION_90 on landscape orientation, but it should emulate it reversing the values returned by onSensorChanged(SensorEvent event).
In other words,
(EMULATED)event.values[0] = (ORIGINAL)event.values[1]
(EMULATED)event.values[1] = -(ORIGINAL)event.values[0]
The patch should do that. Could you verify that on FolioMod? Maybe something got broken when this was ported to tnt.
Also the Nvidia whitepaper states the following for rotating the values:
90°
x = -v[1]
y = -v[0]
180°
x = -v[0]
y = v[1]
270°
x = v[1]
y = v[0]
Also, please check if you are using the newer API for listning to events (the one that uses SensorEventListener) The legacy Api handles rotations by itself, so you should not handle this in your code.
Yes, I'm using SensorEventListener.
weeds2000 said:
Also the Nvidia whitepaper states the following for rotating the values:
90°
x = -v[1]
y = -v[0]
180°
x = -v[0]
y = v[1]
270°
x = v[1]
y = v[0]
Click to expand...
Click to collapse
This is the canonicalToScreen transform for rotating values,
for screen coordinates, increasing y is down (so I'm using world transform).
Sure that the returned value are (for every rotation angle) these:
(EMULATED)event.values[0] = (ORIGINAL)event.values[1]
(EMULATED)event.values[1] = -(ORIGINAL)event.values[0]
?
To understand if it's a my mistake, I've downloaded a free app from the market, JumpyBall 3D Lite, and I noticed that also in this game tilt behaviour is reversed in one direction (could someone test it on the FolioMod?)..
I've checked the code, and yes in the last version for the fix the accelerometer values are rotated in the correct way:
Code:
switch ( sensor.getType() ) {
// ...
case Sensor.TYPE_ACCELEROMETER: {
if ( legacy == false ) {
valuesOut[0] = valuesIn[1];
valuesOut[1] = -valuesIn[0];
}
break;
}
}
However there was an issue with the first release of the fix, as my portrait testgame was using legacy API, and therefore values were somewhat broken.
Maybe only the first version of the patch is in TNT?
By the way, the code that was modified for the fix has been posted in the kernel and tweaks thread. You should be able to verify that TNT has the correct version of the fix or be able to create a patch for TNT. (Do not try to flash the update, it will most certainly break your framework.jar)
Edit:
JumpyBall 3D is working as expected on FolioMod, therefore i think TNT only has the first revision of the patch included.
Ok, thank you!!
Problems
Thanks for a great ROM...
I have a few problems.. Hope someone can help:
Some applications like NFS:Shift and Grooveshark can't access the internet..
Contacts gives a FC..
I can't seem to sync contacts and calendar from my exchange sync.. I can choose to do so, by entering the sync & accounts through pro launcher, but I can't enable sync, so only email works..
I think that was it for now...
Hope someone can help
***Update***
I got contact and calendar sync to work by installing the contacts application from FolioMod and the Calendar app from The TnT Lite mod from Viewsonic...
hi all,
first of all, i would like to say that i'm no expert in c, and this post is not intended to blame anyone but want to raise this concern only.
since i started to mod i9000's kernel source code, i found some unneeded conditional statements in the original source and modded OC/UV sections which can be avoided very easily and thus consuming less resources.
let's take a look in this example from the original source:
Code:
for (i = 0; i < LOOP_CNT; i++) {
tmp = __raw_readb(iem_base + S5PV310_APC_DBG_DLYCODE);
sum_result += tmp;
hpm[i] = tmp;
}
for (i = 0; i < LOOP_CNT; i++)
printk(KERN_INFO "ASV : hpm[%d] = %d value\n", i, hpm[i]);
the second for loop is definitely unnecessary, and it should be changed to something like:
Code:
for (i = 0; i < LOOP_CNT; i++) {
tmp = __raw_readb(iem_base + S5PV310_APC_DBG_DLYCODE);
sum_result += tmp;
hpm[i] = tmp;
printk(KERN_INFO "ASV : hpm[%d] = %d value\n", i, hpm[i]);
}
let's take a look at another extreme case, taken from the OC/UV section:
Code:
if (index < L6)
{
if (old_index == L0)
index = L1;
if (old_index == L1)
index = L2;
if (old_index == L2)
index = L3;
if (old_index == L3)
index = L4;
if (old_index == L4)
index = L5;
if (old_index == L5)
index = L6;
}
it is obvious that, if old_index=L0, it has to go thru the remaining 5 if statements which shouldnt be. isnt it be nice and more efficient to chg it to something like below or use switch case instead?
Code:
if (index < L6)
{
if (old_index == L0)
index = L1;
else if (old_index == L1)
index = L2;
else if (old_index == L2)
index = L3;
else if (old_index == L3)
index = L4;
...
...
...
...
}
since we all aim at producing better and faster kernels, i think this is a good practice to clean up the codes while we r modding
thx for your kind attention
and this is the most ridiculous part that i've ever seen in my life, which can be found in I9000 source also. if u have 10 frequencies set, then instead of running the loop 10 times, this will run 50 times in total
arch/arm/mach-s5pv310/cpufreq.c, inside static int s5pv310_update_dvfs_table()
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_freq_table[i-1].index = s5pv310_lookup_freq_table.index - 1;
s5pv310_freq_table[i-1].frequency = s5pv310_lookup_freq_table.frequency;
printk(KERN_INFO "index = %d, frequency = %d\n",
s5pv310_freq_table[i-1].index, s5pv310_freq_table[i-1].frequency);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_volt_table[i-1].index = s5pv310_lookup_volt_table.index - 1;
s5pv310_volt_table[i-1].arm_volt = s5pv310_lookup_volt_table.arm_volt;
printk(KERN_INFO "index = %d, arm_volt = %d\n",
s5pv310_volt_table[i-1].index, s5pv310_volt_table[i-1].arm_volt);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_apll_pms_table[i-1] = s5pv310_lookup_apll_pms_table;
printk(KERN_INFO "apll pms_table = 0x%08x\n", s5pv310_apll_pms_table[i-1]);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
for (j = 0; j < 7; j++) {
clkdiv_cpu0[i-1][j] = clkdiv_cpu0_lookup[j];
printk("%d, ", clkdiv_cpu0[i-1][j]);
}
printk("\n");
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
for (j = 0; j < 2; j++) {
clkdiv_cpu1[i-1][j] = clkdiv_cpu1_lookup[j];
printk("%d, ", clkdiv_cpu1[i-1][j]);
}
printk("\n");
}
Interesting...
Sent from my GT-I9100 using XDA Premium.
This might be right. My C is bad, but some OC/UV patches look really quite 'whatever works' for me. I dont say its bad - having something is better than nothing.
Its always good if some skilled coders do reviews of such patches.
good finding and the samsung programmers are really ............... bad...
joecisd said:
good finding and the samsung programmers are really ............... bad...
Click to expand...
Click to collapse
i think it's not samsung's problem, instead, it should be unsolved/overlooked problems brought forward from linux kernel
yeaaa Hong Kong
Do you want make a kernel for us?
regards
Nice catches
Hope most devs are already taking care of this!
avetny said:
yeaaa Hong Kong
Do you want make a kernel for us?
regards
Click to expand...
Click to collapse
sorry, but maybe u don know me coz i'm a newbie here in the i9100 section
as in the i9000 forum, i usually prefer not to release files, except some quick fixes like sms sent time mod, but i'll tell u guys my findings, dirty tricks, and how to instead
sorry about that
glad to see that some of you guys already fixed, or started to fix those redundant conditional statements
and ultimately, hope that one day these will be collected as a whole and stored somewhere for everyone like our kernel source code repo here
ykk_five said:
glad to see that some of you guys already fixed, or started to fix those redundant conditional statements
and ultimately, hope that one day these will be collected as a whole and stored somewhere for everyone like our kernel source code repo here
Click to expand...
Click to collapse
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
netchip said:
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
Click to expand...
Click to collapse
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
I'm also not an expert in C or kernel development, but i'm quite sure, that gcc is smart enough to check that some code is redundant and do that kind of optimizations in compile time (if you enable the optimize flags).
Feel free to give it a try, i'm also curious, but i think the final assembly code will be pretty much similar.
Sent from my GT-I9100 using xda premium
killerjohn said:
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
Click to expand...
Click to collapse
Okay, I go.do.that
Sent from my GT-I9100
netchip said:
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
Click to expand...
Click to collapse
yeah, i know. i was learning from your source in github last nite
killerjohn said:
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
Click to expand...
Click to collapse
that's great. yes, most of them are structural problems actually
Guiper said:
I'm also not an expert in C or kernel development, but i'm quite sure, that gcc is smart enough to check that some code is redundant and do that kind of optimizations in compile time (if you enable the optimize flags).
Click to expand...
Click to collapse
i know gcc is quite smart but i doubt if it can handle the conditional statements automatically if something like:
if (a is a male) then a is a boy
if (a is a female) then a is a girl
so actually, a should be checked once only coz we all know that in our daily life. but sometimes we need a bit more complicated logics like:
if (a contains red) then color = red
if (a contains green) then color =green
if (a contains blue) then color =blue
if (a contains blue & green & blue) then color = gray/black/white (by assuming the portions of red, green and blue are equal)
perhaps this is not a good example, but i just want to point out that not every set of conditions are redundant sometimes and hence gcc may not be able to handle it, i think (i'm not a gcc expert neither, pls correct me if i'm wrong )
Feel free to give it a try, i'm also curious, but i think the final assembly code will be pretty much similar.
Click to expand...
Click to collapse
but i've modded some smali before and found that even a very simple for loop in java can produce a lot of goto statements in the assembly code which can be clean up also
[From my README]
A mod for the Oneplus One DWC3 otg module. This allows for charging and host mode simultaneously, inspired by Ziddey's msm_otg mod for the Nexus 4/7 (2013). Functionality was ported over from his kernel hack to the DWC3 USB driver which now handles the MSM8974 USB controller.
The hack works through setting a custom module parameter I've added to allow 'ACA' host mode. This flag effectively turns on ID_A host mode while disabling VBUS power going to the hosted device. I've uploaded the modded dwc3_otg.c file that you can replace in your Oneplus One(bacon) kernel source of choice. It'll be located in the drivers/usb/dwc3/ directory. I've also uploaded my personal kernel image with this hack built on top of Franco's kernel. It also has other modules built into it, mainly DRM/Devtmpfs/Cifs/NFS/NTFS/Alsa Sequencer/Usbip/Binfmt/loadable modules/etc... It was compiled with GCC 4.9 NDK version.
Usage: First you'll need either a generic Y split USB OTG cable or a powered USB hub connected to regular OTG(I've only tested the Y cable).
With the modified kernel flashed, open a terminal shell and as root, enter the following command: "echo Y > /sys/module/dwc3/parameters/aca_enable"
This activates the 'ACA' host mode hack.
[UPDATE]
Wiggling the cord is not needed anymore. I've updated the code so that the phone automatically accepts a charge on entering host mode.
The tricky part is now getting your Y-OTG adapter to send power to the phone. First with power cable and USB device(s) connected the adapter, plug the Y cable into the phone. Test that the phone reads the device. Now, unplug the cable from the phone, leaving the USB device and power cord plugged into the OTG adapter. Gently wiggle the cable slightly while slowly pushing it back into the phone's port, wait for the charge indicator to come on. Once the phone detects the charge, you can push the cable in all the way. The phone should be charging at max current rate while retaining host mode.
Please, if you can test the powered hub method or have improvements to this hack, feel free to share! Also, the standard legal disclaimer applies here that by using this mod/code/kernel in anyway is completely your responsibility. I'm not liable for any possible damages to your devices.
Links:
DWC3 OTG Modification For OnePlus One
https://github.com/sollapse/opo_dwc3_otg/
Ziddey's Original ACA hack for Mako
https://github.com/ziddey/mako/commits/nightlies-4.3-JSS
Franco's Oneplus One Kernel Source
https://github.com/franciscofranco/one_plus_one
Hi sollapse, thank you a lot for this patch, i modified it a little for my xperia z2, it seems to be working just fine, it detects when power is disconnected and switches back to OTG_STATE_A_IDLE automatically, anyway, the only thing that i couldnt get to work is once it is on host mode, when i connect the power it doesnt start charging, perhaps you can find a way to get it working, here's my patch:
Code:
--- dwc3_otg.c 2015-09-22 14:44:45.115324661 -0300
+++ dwc3_otg.c.new 2015-09-22 14:47:40.950239287 -0300
@@ -45,6 +45,12 @@ static void dwc3_otg_reset(struct dwc3_o
static void dwc3_otg_notify_host_mode(struct usb_otg *otg, int host_mode);
static void dwc3_otg_reset(struct dwc3_otg *dotg);
+/*OTG charging hack*/
+static bool aca_enable = 0;
+static bool enable_otg_charge = 0;
+module_param(enable_otg_charge, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(enable_otg_charge, "Force ACA host mode to allow charging and host.");
+
/**
* dwc3_otg_set_host_regs - reset dwc3 otg registers to host operation.
*
@@ -204,41 +210,45 @@ static int dwc3_otg_start_host(struct us
if (!dwc->xhci)
return -EINVAL;
-
- if (!dotg->vbus_otg) {
- dotg->vbus_otg = devm_regulator_get(dwc->dev->parent,
- "vbus_dwc3");
- if (IS_ERR(dotg->vbus_otg)) {
- dev_err(dwc->dev, "Failed to get vbus regulator\n");
- ret = PTR_ERR(dotg->vbus_otg);
- dotg->vbus_otg = 0;
- return ret;
- }
- }
-
+
+ if(!aca_enable){
+ if (!dotg->vbus_otg) {
+ dotg->vbus_otg = devm_regulator_get(dwc->dev->parent,
+ "vbus_dwc3");
+ if (IS_ERR(dotg->vbus_otg)) {
+ dev_err(dwc->dev, "Failed to get vbus regulator\n");
+ ret = PTR_ERR(dotg->vbus_otg);
+ dotg->vbus_otg = 0;
+ return ret;
+ }
+ }
+ }
+
if (on) {
dev_dbg(otg->phy->dev, "%s: turn on host\n", __func__);
dwc3_otg_notify_host_mode(otg, on);
-
- /* register ocp notification */
- if (ext_xceiv && ext_xceiv->otg_capability &&
- ext_xceiv->ext_ocp_notification.notify) {
- ret = regulator_register_ocp_notification(
- dotg->vbus_otg,
- &ext_xceiv->ext_ocp_notification);
- if (ret)
- dev_err(otg->phy->dev,
- "unable to register ocp\n");
- }
-
- ret = regulator_enable(dotg->vbus_otg);
- if (ret) {
- dev_err(otg->phy->dev, "unable to enable vbus_otg\n");
- dwc3_otg_notify_host_mode(otg, 0);
- return ret;
- }
-
+
+ if(!aca_enable){
+ /* register ocp notification */
+ if (ext_xceiv && ext_xceiv->otg_capability &&
+ ext_xceiv->ext_ocp_notification.notify) {
+ ret = regulator_register_ocp_notification(
+ dotg->vbus_otg,
+ &ext_xceiv->ext_ocp_notification);
+ if (ret)
+ dev_err(otg->phy->dev,
+ "unable to register ocp\n");
+ }
+
+ ret = regulator_enable(dotg->vbus_otg);
+ if (ret) {
+ dev_err(otg->phy->dev, "unable to enable vbus_otg\n");
+ dwc3_otg_notify_host_mode(otg, 0);
+ return ret;
+ }
+ }
+
/* The delay between enabling regulator and adding the
platform device is needed to succeed in the enumeration
for certain devices. */
@@ -269,7 +279,9 @@ static int dwc3_otg_start_host(struct us
dev_err(otg->phy->dev,
"%s: failed to add XHCI pdev ret=%d\n",
__func__, ret);
- regulator_disable(dotg->vbus_otg);
+ if(!aca_enable)
+ regulator_disable(dotg->vbus_otg);
+
dwc3_otg_notify_host_mode(otg, 0);
return ret;
}
@@ -279,24 +291,27 @@ static int dwc3_otg_start_host(struct us
dwc3_otg_reset(dotg);
} else {
dev_dbg(otg->phy->dev, "%s: turn off host\n", __func__);
-
- ret = regulator_disable(dotg->vbus_otg);
- if (ret) {
- dev_err(otg->phy->dev, "unable to disable vbus_otg\n");
- return ret;
- }
-
- /* unregister ocp notification */
- if (ext_xceiv && ext_xceiv->otg_capability &&
- ext_xceiv->ext_ocp_notification.notify) {
- ret = regulator_register_ocp_notification(
- dotg->vbus_otg, NULL);
- if (ret)
- dev_err(otg->phy->dev,
- "unable to unregister ocp\n");
- }
-
- dwc3_otg_notify_host_mode(otg, on);
+
+ if(!aca_enable){
+ ret = regulator_disable(dotg->vbus_otg);
+ if (ret) {
+ dev_err(otg->phy->dev, "unable to disable vbus_otg\n");
+ return ret;
+ }
+
+ /* unregister ocp notification */
+ if (ext_xceiv && ext_xceiv->otg_capability &&
+ ext_xceiv->ext_ocp_notification.notify) {
+ ret = regulator_register_ocp_notification(
+ dotg->vbus_otg, NULL);
+ if (ret)
+ dev_err(otg->phy->dev,
+ "unable to unregister ocp\n");
+ }
+ }
+
+ if(!aca_enable)
+ dwc3_otg_notify_host_mode(otg, on);
platform_device_del(dwc->xhci);
/*
@@ -341,8 +356,11 @@ static int dwc3_otg_set_host(struct usb_
* required for XHCI controller before setting OTG Port Power
* TODO: Tune this delay
*/
- msleep(300);
- dwc3_otg_set_host_power(dotg);
+
+ msleep(300);
+ if(!aca_enable){
+ dwc3_otg_set_host_power(dotg);
+ }
} else {
otg->host = NULL;
}
@@ -972,7 +990,17 @@ static void dwc3_otg_sm_work(struct work
dev_dbg(phy->dev, "vbus_drop_det\n");
/* staying on here until exit from A-Device */
} else {
- phy->state = OTG_STATE_A_HOST;
+ //if we have power and enable_otg_charge, force charging on
+ if (test_bit(B_SESS_VLD, &dotg->inputs) && enable_otg_charge){
+ if(charger){
+ dev_info(phy->dev, "OTG charging is ON!!!\n");
+ aca_enable = 1;
+ charger->chg_type =DWC3_SDP_CHARGER;
+ dwc3_otg_set_power(phy, DWC3_IDEV_CHG_MAX);
+ }
+ } else
+ aca_enable = 0;
+ phy->state = OTG_STATE_A_HOST;
ret = dwc3_otg_start_host(&dotg->otg, 1);
if ((ret == -EPROBE_DEFER) &&
dotg->vbus_retry_count < 3) {
@@ -1000,7 +1028,15 @@ static void dwc3_otg_sm_work(struct work
break;
case OTG_STATE_A_HOST:
- if (test_bit(ID, &dotg->inputs)) {
+ if (enable_otg_charge){
+ //detect power change and switch back to OTG_STATE_A_IDLE
+ if(!test_bit(B_SESS_VLD, &dotg->inputs)){
+ dev_info(phy->dev, "Power disconnected, charging disabled!!!\n");
+ dwc3_otg_start_host(&dotg->otg, 0);
+ phy->state = OTG_STATE_A_IDLE;
+ work = 1;
+ }
+ } else if (test_bit(ID, &dotg->inputs)) {
dev_dbg(phy->dev, "id\n");
dwc3_otg_start_host(&dotg->otg, 0);
phy->state = OTG_STATE_B_IDLE;
I've updated my code a couple of days ago to automatically apply power during the state change, assuming a charger is connected to the y cable (USB devices would not power otherwise). In your mod, it seems you're attempting to detect a charge using the 'B' mode state, but by that time with the aca flag enabled, the USB controller should be in ID_A host mode instead of B_SESS_VLD. The driver's 'set_power' function already checks the line for current automatically. Please look at the updated code to see what I did during the state change. It should all work utilizing the one parameter flag.
I tested this with a patched sultanXDA CAF kernel (since the .c source file was slightly different, I was careful to only merge the relevant changes), and a powered USB HUB. It works perfectly! Thanks.
Phoenix Wright said:
I tested this with a patched sultanXDA CAF kernel (since the .c source file was slightly different, I was careful to only merge the relevant changes), and a powered USB HUB. It works perfectly! Thanks.
Click to expand...
Click to collapse
That's great! I'm pretty certain with the push to USB Type C and potential USB 3.1 support, that the DWC3 driver will be used across most devices for now on. This code should merge well with them if ACA is absent (Zenphone 2 is the only exception I've found so far since Intel enabled it in the driver).
Can someone post a modded CAF kernel for the opo? I am having issues building a kernel as I currently only have a windows box.
snekiam said:
Can someone post a modded CAF kernel for the opo? I am having issues building a kernel as I currently only have a windows box.
Click to expand...
Click to collapse
Latest Sultanxda kernel (as of 10/4), with the CAF dwc_otg modified with sollapse's patches. His sources are here: https://github.com/sultanxda/android_kernel_oneplus_msm8974
I used Google GCC 4.8, which is the same one he uses, as far as I could tell.
View attachment sultan10-4_otg-y.7z
@sollapse I noticed a bug. I made two widgets with an app on Play Store (to enable and disable this hack). I disabled this by mistake while the OTG device and charge were still inserted, and after I removed them I got a kernel panic, could this be fixed?
I should be able to fix it. I'll look at it again and will try to clean up the state change code.
Kernel
Can someone please upload a kernel .img?
I am not able to compile a kernel on my own....
@sollapse I fixed the kernel panics, and also another bug (when the aca_enable parameter was on, you couldn't charge at full speed with a wall charger - not in host mode, just simple charging). I've done all possible status changes (set aca_enable to on, insert otg-y cable + device, turn aca_enable off, unplug device; aca_enable is off, plug regular otg cable + device, turn aca_enable on, unplug device, set aca_enable to off, re-plug). These two situations respectively gave these results: kernel panic and inability to use regular otg again.
Turns out that the issues were with "regulator_disable", now it's executed when the regulator is enabled, regardless of the aca_enable parameter.
Another fix for incorrect usage: if you connected a regular OTG cable+device while aca_enable was set to Y, it would show the charging icon, and it would even stay there after the device was disconnected! Sadly I can't prevent the charging icon from appearing (as this hack basically forces all the "unknown" chargers to be reported as USB - as opposed to AC - chargers... and the weird part is that the charge coming from OTG-Y is an "unknown charger"... but the charge (?) coming from a regular OTG device is an "unknown charger" too! XD, if there's a way it's out of reach for me), but I managed to make it go away after disconnection. Basically, it doesn't force "unknown" to USB if the function gets called to *disable* charging. I guess this is the best I can do for this kernel mod ^_^
It looks I was wrong, after lots of debugging of dwc3_otg I learned how it works, so I overhauled the patch. It works more cleanly now: it actually properly detects the charger (no more phantom notifications, faster charging rates if it's allowed by the charger), supports unplugging and replugging of the power cord while using OTG-Y, and unplugging of the device after power was unplugged, fixes all sorts of race conditions and wrong usages of the aca_enable parameter (I'm not sure if it's all of them, but I've been testing and fixing things for a while).
I attach a .diff for CAF kernels. Take note that to use the fix for plugging OTG devices in sleep mode you need to patch the charger driver: https://github.com/sultanxda/androi...mmit/7b023b295fdfa4789c93aee8b04f5d2a9b52dbba
Wow, I've completely abandoned this hack since it's worked well enough for me . Also haven't had much time due to work and other necessities. Thanks for the patches @Phoenix Wright for cleaning up this hack! This should be a standard addition to all future Android kernels.
sollapse said:
Wow, I've completely abandoned this hack since it's worked well enough for me . Also haven't had much time due to work and other necessities. Thanks for the patches @Phoenix Wright for cleaning up this hack! This should be a standard addition to all future Android kernels.
Click to expand...
Click to collapse
Yeah, I wonder why they haven't implemented the feature officially, as it can be done just fine
And many thanks for developing this
By the way, I realized the reboots when inserting an OTG-Y device in deep sleep were not actually fixed, as I got a reboot yesterday, my bad (sultanxda fixed the issues with doing it with regular OTG, but it seems the issue with OTG-Y was different). It seems it's fixed properly this time though. Same patch as yesterday, just a two line difference.
Thanks for the original mod, sollapse, and thanks for your patches and all the updates, Phoenix. Just to confirm: this mod requires that on every kernel update via Sultan's OTA, the kernel source be pulled, patched, flashed onto your OPO, and finally activated using the aca command?
I'm off to go learn how to build a kernel from this handy guide, if anyone else is interested in jumping on this exciting bandwagon.
http://forum.xda-developers.com/android/software/ultimate-guide-compile-android-kernel-t2871276
EDIT: Thought I'd keep everyone abrest of my progress as a total newbie trying this out. I've used Ubunutu before, but had a lot of headaches trying to get my network working properly.
5:00pm: started the downloads of Ubuntu and Virtualbox. I have Hyper-V support (which is supposedly faster) on my desktop rig, but it has network issues, so I went with Virtualbox. Apparently, one of the things needed to create a kernel is a "toolchain". The guide uses "arm-eabi-4.33", but Phoenix and apparently sultan use gcc 4.8, so we'll go with that. But, how do I replace them? Can I just switch the git urls with this one I found of Google's toolchain?
5:30pm: got Ubuntu's 15.10 iso downloaded and VirtualBox installed. We'll figure out the toolchains later.
5:45pm: OK, Ubuntu is installing. I did the default on everything (2GB RAM, 8GB virtual hard disk). Booted up, installed it, and rebooted. "SQUASHFS errors" on first Ubuntu boot. The issues begin early, lol.
5:50pm: Checked the iso's MD5, matches up. Google'd around, but only random fixes that don't really fit (updating my BIOS? on a virtualbox?!). OK, let's try again with 3GB of RAM (my rig has 8GB) and 12GB of disk space.
5:55pm: "SquashFS errors" again. Whhhhhhhyyyy, Ubuntu, whyyyyyyyyy.
5:56pm: Hmm, what if I just shut down the virtual box and just try starting Ubuntu again?
5:57pm: HOLYCOWITWORKED. Thank you, Ubuntu--I love you.
5:58pm: Why is the resolution so small even though Ubuntu is installed? Everything is huge and my mouse is a little laggy.
6:05pm: OK, from a StackExchange post: you need "Guest Additions" to change the resolution. In the VirtualBox window (not in Ubuntu), you just click "Install Guest Additions" and it does its thing. It actually inserts the files as a virtual CD, haha. That's neat.
6:15pm: Trying to get the hang of "Right Control" as "host key". But, wait, why can't I copy/paste between my host and guest (copying all the commands from the guide linked above)? I feel like I had that last time I used VirtualBox. The Firefox in Ubunutu is really slow, too, and troubleshooting is mostly through Google right now, lol, and I don't want slow troubleshooting.
6:20pm: Oh, bidirectional copy/paste needs to be enabled. I see....
6:22pm: I FEEL LIKE A GOD NOW. I can copy and paste between TWO operating systems running my PC. WOWZA....I don't know what enromous amount of engineering that required, but it is a killer feature.
6:26pm: I'm trying to learn all the commands that the guide is using, just in case I mess up somewhere. What does the "-y" do in apt-get?
6:26:15pm: Thank you, random internet stranger many years ago, about telling me what a "man page" is. It's a simple website/HTML document that will actually explain all the arguments of a command. Great in interpreting the exotic arguments of cerebral StackExchange users....and what "-y" does in apt-get....
6:26:30pm: "-y" just hits "yes" to any prompts or whatever that apt-get invokes. Nice noob feature for people like me, haha. All right, I'm OK with that argument, let's do it!
6:30pm: Next, "mkdir"....well, that makes sense. But, where is it making this folder? How does it know where to put it????
6:33pm: Ah, so there is a "Home" folder that is the default folder. That's where it puts things. I made like 15 folders using "mkdir" and they all appear there.
6:40pm: Let's start! First, I need to grab sultan's kernel. OK, "git clone", let's do it!
6:41pm: "Git is not installed". These errors freak me out, but at least this one is minor, lol. OK: step zero, install git.
6:42pm: THE COMMAND WORKED! First success. But, wow, the kernel is a huge download (300MB+). Damn, wish I started this earlier in the background.
6:44pm: I wonder if I can start installing the other things, too. But, how? Can I open another terminal window?
6:45pm: Yes, you can open another terminal window and even a tab. But, should I install other things? Might that interfere with "git clone"? Why risk it? I mean, it took two hours to get just here...
6:46pm: Throwing caution to the wind. Opening TWO terminal windows and starting apt-get with the other stuff.
6:50pm: No errors so far...
6:55pm: woot! Everything downloaded, nice, nice. OK, the last thing: those toolchains. What even is a toolchain?
6:56pm: OK, a toolchain is basically like a list of directories and their location? Or something? It's like a default variable location "list" or something. Hmm...OK, Phoenix used gcc 4.8, so that's what we'll do!
6:58pm: But, wait, the instructions at the gcc toolchain page say I need the "Android GCC repository" and even more dependencies. But, the guide doesn't mention any of that. Is this specific to the Google one? Looks like more downloading...
6:59pm: Err, hold on. I don't want to BUILD the toolchain. I just want it cloned to my system....I don't need to build the toolchain, right? OK, let's just get the gcc repo first and then we'll see.
7:05pm: Ugh, another huge download. I'm down to 180MB of free space! What? How did I use 12GB already?
7:06pm: Oh, the HDD is only 9.6GB. I guess formatting takes away some of it and Ubuntu's install, too. OK, we'll resize the partition and call it night. To be continued later...
A brief update, as I'm too tired to annotate everything today, haha. The reason the guide uses Doom's toolchains is because they're prebuilt. So, I guess, we'll use those. I'm creating the updated dwc3_otg.c from all the patches, but the hunks are failing after the first patch. Will troubleshoot today by looking at the reject file and see what's being moved around.
EDIT: OK, I actually just opened the patch files. Looks like I just need the latest one to apply to sollapse's original patch. Patches 1/2 are almost identical (and sans full overhaul). Patch 3 is superseded by patch 4. So, just patch 4 is the one you need. Huh. Let's do it! ;D
This guide is great for understanding patch files.
sollapse said:
Wow, I've completely abandoned this hack since it's worked well enough for me . Also haven't had much time due to work and other necessities. Thanks for the patches @Phoenix Wright for cleaning up this hack! This should be a standard addition to all future Android kernels.
Click to expand...
Click to collapse
thanks for your work, it's awesome feature
is there some solution without a kernel compiling ? some custom rom or kernel image
stadnyuk said:
thanks for your work, it's awesome feature
is there some solution without a kernel compiling ? some custom rom or kernel image
Click to expand...
Click to collapse
Its already there in my kernel called lightning kernel check tht sig for the link and if you are on cm then there is another thread in original android dev section
nikhil18 said:
Its already there in my kernel called lightning kernel check tht sig for the link and if you are on cm then there is another thread in original android dev section
Click to expand...
Click to collapse
Thank you, I'll check it. I've installed sultanxda ROM with hope for future kernel updates, but there is some bugs and I think to return to stock CM
nikhil18 said:
Its already there in my kernel called lightning kernel check tht sig for the link and if you are on cm then there is another thread in original android dev section
Click to expand...
Click to collapse
Hi again, I'm stuck with lightning kernel(((
Can't flash it. I'm starting to think I'm completely noon.
Flashing over night build of CM12 the cm version of kernel(V15)
Wipe, flash, wipe
The result - stuck on one plus logo
Flashing again sultanxda ROM, wipe, kernel, gapps
The result - boot loop
Where is the problem? What I'm doing wrong?
Now I'm on a last night build, am I right that I need V15 cm version?
Thank you for helping
PS: I've realized I was flashing cm13 kernel version with cm12 ROM, so flashed sultanxda 12, v33 kernel version - loop boot