LG G3 Receives Oversharpening Fix via Modified Kernel

Nothing is perfect, as they say. No matter how alluring or seemingly perfect, … more

APKTool Updated with Android Lollipop Support

One of the beauties of Android is the level of flexibility we have over our devices. Whether … more

Lollipop Leak for Sprint Galaxy S5, TWRP for Micromax Canvas Magnus – XDA TV

Android 5.0 Lollipop has been leaked for the Sprint … more

Velocity is Like OpenTable on Steroids

We all enjoy a night out with friends or our significant other from time to time. However, there is … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Dock resistors (Dock, Car, Headset)

OP CyberPK

10th March 2014, 08:39 PM   |  #1  
OP Member
Thanks Meter: 2
 
32 posts
Join Date:Joined: Apr 2009
I was searching for the correct resistor value to enable the advanced function on my generic compatible dock.
Looked at the kernel and found on drivers/misc/cable_detect_8xxx.c the function cable_detect_get_type
...
if (adc > 150 && adc < 220)
type = DOCK_STATE_CAR;
else if (adc > 370 && adc < 440)
type = DOCK_STATE_USB_HEADSET;
else if (adc > 440 && adc < 550)
type = DOCK_STATE_DMB;
else if (adc > 550 && adc < 900)
type = DOCK_STATE_DESK;
else
type = DOCK_STATE_UNDEFINED;
...

and second_detect
...
if ((pInfo->mhl_version_ctrl_flag) || (adc_value >= 776 && adc_value <= 1020))
#ifdef CONFIG_FB_MSM_HDMI_MHL_SII9234
type = DOCK_STATE_MHL;
#else
type = DOCK_STATE_UNDEFINED;
#endif
else if(adc_value >= 1021 && adc_value <= 1224)
#ifdef CONFIG_USB_OTG_HOST_CHG
type = DOCK_STATE_HOST_CHG_DOCK;
#else
type = DOCK_STATE_AUDIO_DOCK;
#endif
else
#if (defined(CONFIG_USB_OTG) && defined(CONFIG_USB_OTG_HOST))
type = DOCK_STATE_USB_HOST;
#else
type = DOCK_STATE_UNDEFINED;
#endif
...

Need help to find how to convert these values to resistor values.
Thank you
Last edited by CyberPK; 10th March 2014 at 09:11 PM.
10th March 2014, 11:13 PM   |  #2  
jthatch12's Avatar
Senior Member
Flag Philly
Thanks Meter: 1,431
 
2,046 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Quote:
Originally Posted by CyberPK

I was searching for the correct resistor value to enable the advanced function on my generic compatible dock.
Looked at the kernel and found on drivers/misc/cable_detect_8xxx.c the function cable_detect_get_type
...
if (adc > 150 && adc < 220)
type = DOCK_STATE_CAR;
else if (adc > 370 && adc < 440)
type = DOCK_STATE_USB_HEADSET;
else if (adc > 440 && adc < 550)
type = DOCK_STATE_DMB;
else if (adc > 550 && adc < 900)
type = DOCK_STATE_DESK;
else
type = DOCK_STATE_UNDEFINED;
...

and second_detect
...
if ((pInfo->mhl_version_ctrl_flag) || (adc_value >= 776 && adc_value <= 1020))
#ifdef CONFIG_FB_MSM_HDMI_MHL_SII9234
type = DOCK_STATE_MHL;
#else
type = DOCK_STATE_UNDEFINED;
#endif
else if(adc_value >= 1021 && adc_value <= 1224)
#ifdef CONFIG_USB_OTG_HOST_CHG
type = DOCK_STATE_HOST_CHG_DOCK;
#else
type = DOCK_STATE_AUDIO_DOCK;
#endif
else
#if (defined(CONFIG_USB_OTG) && defined(CONFIG_USB_OTG_HOST))
type = DOCK_STATE_USB_HOST;
#else
type = DOCK_STATE_UNDEFINED;
#endif
...

Need help to find how to convert these values to resistor values.
Thank you


Learn how analog to digital conversion works. If you cannot figure that out, you're in over your head.
15th March 2014, 07:43 PM   |  #3  
OP Member
Thanks Meter: 2
 
32 posts
Join Date:Joined: Apr 2009
Calculator Resistor values between pin4/5 for HTC ONE explained
Quote:
Originally Posted by jthatch12

Learn how analog to digital conversion works. If you cannot figure that out, you're in over your head.

Thank you for your USELESS comment.
I've figured out that the values are the mV read on the pin4 after the application of a resistor between pin4 and pin5.

It is a simple Voltage divider (http://en.wikipedia.org/wiki/Voltage_divider)
Misured Voltage between pin4 and pin5 (Vin) = 1,8V = 1800 mV
Misured shortcut current between pin4 and pin5 = 0,18uA
Calculated pullup resistor (Z1): 100000 ohm

So tha math in simple:
Z2 = (Z1*adc)/(Vin-adc)
or
Z2 = Z1 / ((Vin/adc)-1)

DOCK_STATE_CAR -> 150mV < adc < 220mV -> 9091Ω < Z2 < 13924Ω | use 10000Ω
DOCK_STATE_USB_HEADSET -> 370mV < adc < 440mV -> 25874Ω < Z2 < 32353Ω | use 27000Ω
DOCK_STATE_DMB -> 440mV < adc < 550mV -> 32353Ω < Z2 < 44000Ω | use 39000Ω
DOCK_STATE_DESK -> 550mV < adc < 900mV -> 44000Ω < Z2 < 100000Ω | use 56000Ω or 68000Ω or 82000Ω

IF
-100mV < adc < 100mV -> -5263Ω < Z2 < 5882Ω ----> 0Ω < Z2 < 5882Ω | simply shortcut
ENABLE pin1 output of 5v and read again pin4 and pin5

MHL -> 776mV < adc < 1020mV
HOST_CHG_DOCK/DOCK_STATE_AUDIO_DOCK -> 1021mV < adc < 1224mV
USB HOST any other value

Regards
Last edited by CyberPK; 15th March 2014 at 07:47 PM.
15th March 2014, 08:20 PM   |  #4  
alray's Avatar
Senior Member
Flag Montreal, Quebec
Thanks Meter: 1,295
 
3,347 posts
Join Date:Joined: May 2012
Donate to Me
More
Quote:
Originally Posted by CyberPK

Thank you for your USELESS comment.

Quote:

2.3 Flaming / Lack of respect: XDA is about sharing and this does not involve virtual yelling (flaming) or rudeness.


If you found his comment useless then just don't reply to it, no needs to start a fight here.
Please stay polite and respectful
thanks
15th March 2014, 09:18 PM   |  #5  
OP Member
Thanks Meter: 2
 
32 posts
Join Date:Joined: Apr 2009
Quote:
Originally Posted by alray

If you found his comment useless then just don't reply to it, no needs to start a fight here.
Please stay polite and respectful
thanks

ok... thank you...
The Following User Says Thank You to CyberPK For This Useful Post: [ View ]
21st March 2014, 07:40 PM   |  #6  
jthatch12's Avatar
Senior Member
Flag Philly
Thanks Meter: 1,431
 
2,046 posts
Join Date:Joined: Mar 2012
Donate to Me
More
FYI I was not " 2.3 Flaming / Lack of respect: XDA is about sharing and this does not involve virtual yelling (flaming) or rudeness." I was simply stating a fact. ADC stands for ANALOG TO DIGITAL CONVERSION.... shocker, I know. I am an electrical engineer and I see all too often people screwing stuff up.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes