Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,782,686 Members 37,266 Now Online
XDA Developers Android and Mobile Development Forum

Dock resistors (Dock, Car, Headset)

Tip us?
 
CyberPK
Old
(Last edited by CyberPK; 10th March 2014 at 08:11 PM.)
#1  
Member - OP
Thanks Meter 2
Posts: 31
Join Date: Apr 2009
Default Dock resistors (Dock, Car, Headset)

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
 
jthatch12
Old
#2  
jthatch12's Avatar
Senior Member
Thanks Meter 1,376
Posts: 2,005
Join Date: Mar 2012
Location: Philly

 
DONATE TO ME
Quote:
Originally Posted by CyberPK View Post
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.


Running Beanstalk w/ STi Kernel



Find me on Nasioc, jthatch12
 
CyberPK
Old
(Last edited by CyberPK; 15th March 2014 at 06:47 PM.)
#3  
Member - OP
Thanks Meter 2
Posts: 31
Join Date: Apr 2009
Calculator Resistor values between pin4/5 for HTC ONE explained

Quote:
Originally Posted by jthatch12 View Post
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
 
alray
Old
#4  
alray's Avatar
Senior Member
Thanks Meter 1,053
Posts: 2,716
Join Date: May 2012
Location: Montreal

 
DONATE TO ME
Quote:
Originally Posted by CyberPK View Post
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
If I've helped you, please hit the ''tanks'' button
If you want a reply, quote or mention me using @alray

Useful links for the HTC One:
nkk71's SuperGUIDE to returning 100% back to stock
Flashing requirements chart by nkk71
HTC1Guru.com by crushalot
 
CyberPK
Old
#5  
Member - OP
Thanks Meter 2
Posts: 31
Join Date: Apr 2009
Quote:
Originally Posted by alray View Post
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: [ Click to Expand ]
 
jthatch12
Old
#6  
jthatch12's Avatar
Senior Member
Thanks Meter 1,376
Posts: 2,005
Join Date: Mar 2012
Location: Philly

 
DONATE TO ME
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.


Running Beanstalk w/ STi Kernel



Find me on Nasioc, jthatch12
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Moto G 4G Receives Official CyanogenMod 11 Love

When theMoto Gwas initially released to the world in November of last year,very few actually … more

Get Your Tasks Organized on Android Wear with Agenda Wear

Having a checklist of things you need to do is something we all can find useful at … more

Top 5 LG G3 MODs – XDA Developer TV

The LG G3 has been LG’s breakout hit of the summer. Using their knowledge frombuilding some … more

Make Your Calendar Widget Beautiful with Month

For some of us, summer vacation is alreadyover. For those getting ready to school, work, or … more