USB port 若何识别分歧的Charger类型?USB接口识别充

2020-03-29 时尚品牌资讯 阅读

  基于Qualcom 8960/8921平台

  一,软件剖析

  1. USB charger types & Power supply types

  USB_INVALID_CHARGER Invalid USB charger.

  USB_SDP_CHARGER Standard downstream port. Refers to a downstream port on USB2.0 compliant host/hub.

  USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).

  USB_CDP_CHARGER Charging downstream port. Enumeration can happen and IDEV_CHG_MAX can be drawn irrespective of USB state.

  USB_ACA_A_CHARGER B-device is connected on accessory port with charger connected on charging port. This configuration allows charging in host mode.

  USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on accessory port with charger connected on charging port.

  USB_ACA_C_CHARGER A-device (with VBUS) is connected on accessory port with charger connected on charging port.

  USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one or more downstream ports. Capable of supplying IDEV_CHG_MAX irrespective of devices connected on accessory ports.

  USB_PROPRIETARY_CHARGER A proprietary charger pull DP and DM to specific voltages between 2.0-3.3v for identification.

  POWER_SUPPLY_TYPE_USB,

  POWER_SUPPLY_TYPE_USB_DCP,

  POWER_SUPPLY_TYPE_USB_CDP,

  POWER_SUPPLY_TYPE_USB_ACA,

  POWER_SUPPLY_TYPE_BMS,

  2. How to classify or identify charger?

  USB_SDP_CHARGER

  POWER_SUPPLY_TYPE_USB

  USB Charger

  USB_CDP_CHARGER

  POWER_SUPPLY_TYPE_USB_CDP

  USB_ACA_DOCK_CHARGER

  POWER_SUPPLY_TYPE_USB_ACA

  USB_ACA_A_CHARGER

  USB_ACA_B_CHARGER

  USB_ACA_C_CHARGER

  USB_DCP_CHARGER

  POWER_SUPPLY_TYPE_USB_DCP

  AC Charger

  USB_PROPRIETARY_CHARGER

  As for the DMS, refer to bold font items, so it is USB charger.

  3. Analysis about source codes

  *******************************************************************

  ###用户空间的剖析以下:

  1. 检查 /sys/class/power_supply/pm8921-dc/online和 /sys/class/power_supply/usb/online 的值,可以知道是何充电器类型

  @frameworks/base/services/jni/com_android_server_batteryservice.cpp中有

  int register_android_server_BatteryService(JNIEnv* env)

  {

  if (strcmp(buf, "Mains")==0) { ///sys/class/power_supply/pm8921-dc/type==Mains

  snprintf(path, sizeof(path), "%s/%s/online", POWER_SUPPLY_PATH, name);

  if (access(path, R_OK)==0)

  gPaths.acOnlinePath=strdup(path);

  }

  }

  假设/sys/class/power_supply/pm8921-dc/online==1,则拔出的充电器是wall charger

  /sys/class/power_supply/usb/online==1, 则拔出的充电器是usb charger

标签: