Snap for 9899401 from cfaaafcf40
to udc-release
Change-Id: I705a4959d8237e471a0be78c0616400cc4d47ef6
This commit is contained in:
commit
e8c5619038
5 changed files with 93 additions and 116 deletions
|
@ -41,3 +41,8 @@ on property:ro.revision=PROTO1.1
|
|||
setprop debug.hypervisor.metrics_tag "hwrev_a0"
|
||||
on property:ro.revision=EVT1.0
|
||||
setprop debug.hypervisor.metrics_tag "hwrev_a0"
|
||||
|
||||
# Enable etm/etm2dram when ramdump is enabled.
|
||||
on property:ro.boot.ramdump=enabled
|
||||
write /sys/devices/platform/exynos-etm/etm_on 1
|
||||
write /sys/devices/platform/etm2dram/arm 1
|
||||
|
|
|
@ -68,29 +68,12 @@ void endSection(int fd, const std::string §ionName, timepoint_t startTime) {
|
|||
"\n", fd);
|
||||
}
|
||||
|
||||
Dumpstate::Dumpstate()
|
||||
: mTextSections{
|
||||
{ "wlan", [this](int fd) { dumpWlanSection(fd); } },
|
||||
} {}
|
||||
|
||||
// Dump data requested by an argument to the "dump" interface, or help info
|
||||
// if the specified section is not supported.
|
||||
void Dumpstate::dumpTextSection(int fd, const std::string §ionName) {
|
||||
bool dumpAll = (sectionName == kAllSections);
|
||||
std::string dumpFiles;
|
||||
|
||||
for (const auto §ion : mTextSections) {
|
||||
if (dumpAll || sectionName == section.first) {
|
||||
auto startTime = startSection(fd, section.first);
|
||||
section.second(fd);
|
||||
endSection(fd, section.first, startTime);
|
||||
|
||||
if (!dumpAll) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute all or designated programs under vendor/bin/dump/
|
||||
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir);
|
||||
if (!dir) {
|
||||
|
@ -124,22 +107,11 @@ void Dumpstate::dumpTextSection(int fd, const std::string §ionName) {
|
|||
// An unsupported section was requested on the command line
|
||||
::android::base::WriteStringToFd("Unrecognized text section: " + sectionName + "\n", fd);
|
||||
::android::base::WriteStringToFd("Try \"" + kAllSections + "\" or one of the following:", fd);
|
||||
for (const auto §ion : mTextSections) {
|
||||
::android::base::WriteStringToFd(" " + section.first, fd);
|
||||
}
|
||||
::android::base::WriteStringToFd(dumpFiles, fd);
|
||||
::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are"
|
||||
"not avalable from the command line.\n", fd);
|
||||
}
|
||||
|
||||
// Dump items related to wlan
|
||||
void Dumpstate::dumpWlanSection(int fd) {
|
||||
// Dump firmware symbol table for firmware log decryption
|
||||
DumpFileToFd(fd, "WLAN FW Log Symbol Table", "/vendor/firmware/Data.msc");
|
||||
RunCommandToFd(fd, "WLAN TWT Dump", {"/vendor/bin/sh", "-c",
|
||||
"cat /sys/wlan_ptracker/twt/*"});
|
||||
}
|
||||
|
||||
void Dumpstate::dumpLogSection(int fd, int fd_bin)
|
||||
{
|
||||
std::string logDir = MODEM_LOG_DIRECTORY;
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace dumpstate {
|
|||
|
||||
class Dumpstate : public BnDumpstateDevice {
|
||||
public:
|
||||
Dumpstate();
|
||||
|
||||
::ndk::ScopedAStatus dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds,
|
||||
IDumpstateDevice::DumpstateMode in_mode,
|
||||
int64_t in_timeoutMillis) override;
|
||||
|
@ -42,14 +40,8 @@ class Dumpstate : public BnDumpstateDevice {
|
|||
private:
|
||||
const std::string kAllSections = "all";
|
||||
|
||||
std::vector<std::pair<std::string, std::function<void(int)>>> mTextSections;
|
||||
|
||||
void dumpTextSection(int fd, std::string const& sectionName);
|
||||
|
||||
// Text sections that can be dumped individually on the command line in
|
||||
// addition to being included in full dumps
|
||||
void dumpWlanSection(int fd);
|
||||
|
||||
void dumpLogSection(int fd, int fdModem);
|
||||
|
||||
//bool getVerboseLoggingEnabledImpl();
|
||||
|
|
164
usb/usb/Usb.cpp
164
usb/usb/Usb.cpp
|
@ -17,6 +17,7 @@
|
|||
#define LOG_TAG "android.hardware.usb.aidl-service"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/parseint.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <assert.h>
|
||||
|
@ -95,6 +96,9 @@ void queryVersionHelper(android::hardware::usb::Usb *usb,
|
|||
#define GL852G_PRODUCT_ID1 0x0608
|
||||
#define GL852G_PRODUCT_ID2 0x0610
|
||||
#define GL852G_VENDOR_CMD_REQ 0xe3
|
||||
// GL852G port 1 and port 2 JK level default settings
|
||||
#define GL852G_VENDOR_CMD_VALUE_DEFAULT 0x0008
|
||||
#define GL852G_VENDOR_CMD_INDEX_DEFAULT 0x0404
|
||||
|
||||
ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
|
||||
int64_t in_transactionId) {
|
||||
|
@ -452,6 +456,61 @@ bool switchMode(const string &portName, const PortRole &in_role, struct Usb *usb
|
|||
return roleSwitch;
|
||||
}
|
||||
|
||||
static int usbDeviceRemoved(const char *devname, void* client_data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbDeviceAdded(const char *devname, void* client_data) {
|
||||
uint16_t vendorId, productId;
|
||||
struct usb_device *device;
|
||||
::aidl::android::hardware::usb::Usb *usb;
|
||||
int value, index;
|
||||
|
||||
device = usb_device_open(devname);
|
||||
if (!device) {
|
||||
ALOGE("usb_device_open failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
usb = (::aidl::android::hardware::usb::Usb *)client_data;
|
||||
value = usb->mUsbHubVendorCmdValue;
|
||||
index = usb->mUsbHubVendorCmdIndex;
|
||||
|
||||
// The vendor cmd only applies to USB Hubs of Genesys Logic, Inc.
|
||||
// The request field of vendor cmd is fixed to 0xe3.
|
||||
vendorId = usb_device_get_vendor_id(device);
|
||||
productId = usb_device_get_product_id(device);
|
||||
if (vendorId == GL852G_VENDOR_ID &&
|
||||
(productId == GL852G_PRODUCT_ID1 || productId == GL852G_PRODUCT_ID2)) {
|
||||
int ret = usb_device_control_transfer(device,
|
||||
USB_DIR_OUT | USB_TYPE_VENDOR, GL852G_VENDOR_CMD_REQ, value, index,
|
||||
NULL, 0, CTRL_TRANSFER_TIMEOUT_MSEC);
|
||||
ALOGI("USB hub vendor cmd %s (wValue 0x%x, wIndex 0x%x, return %d)\n",
|
||||
ret? "failed" : "succeeded", value, index, ret);
|
||||
}
|
||||
|
||||
usb_device_close(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *usbHostWork(void *param) {
|
||||
struct usb_host_context *ctx;
|
||||
|
||||
ALOGI("creating USB host thread\n");
|
||||
|
||||
ctx = usb_host_init();
|
||||
if (!ctx) {
|
||||
ALOGE("usb_host_init failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This will never return, it will keep monitoring USB sysfs inotify events
|
||||
usb_host_run(ctx, usbDeviceAdded, usbDeviceRemoved, NULL, param);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Usb::Usb()
|
||||
: mLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER),
|
||||
|
@ -465,7 +524,9 @@ Usb::Usb()
|
|||
ThrottlingSeverity::NONE),
|
||||
ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary2,
|
||||
ThrottlingSeverity::NONE)}, kSamplingIntervalSec),
|
||||
mUsbDataEnabled(true) {
|
||||
mUsbDataEnabled(true),
|
||||
mUsbHubVendorCmdValue(GL852G_VENDOR_CMD_VALUE_DEFAULT),
|
||||
mUsbHubVendorCmdIndex(GL852G_VENDOR_CMD_INDEX_DEFAULT) {
|
||||
pthread_condattr_t attr;
|
||||
if (pthread_condattr_init(&attr)) {
|
||||
ALOGE("pthread_condattr_init failed: %s", strerror(errno));
|
||||
|
@ -483,6 +544,10 @@ Usb::Usb()
|
|||
ALOGE("pthread_condattr_destroy failed: %s", strerror(errno));
|
||||
abort();
|
||||
}
|
||||
if (pthread_create(&mUsbHost, NULL, usbHostWork, this)) {
|
||||
ALOGE("pthread creation failed %d\n", errno);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role,
|
||||
|
@ -1095,82 +1160,6 @@ ScopedAStatus Usb::setCallback(const shared_ptr<IUsbCallback>& in_callback) {
|
|||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
struct hub_vendor_cmd {
|
||||
// wValue filed of standard device request
|
||||
int value;
|
||||
// wIndex field of standard device request
|
||||
int index;
|
||||
// Output pipe to shell command
|
||||
int out;
|
||||
// Whether the hub is found
|
||||
bool found;
|
||||
};
|
||||
|
||||
static int usbDeviceAdded(const char *devname, void* client_data) {
|
||||
struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data;
|
||||
uint16_t vendorId, productId;
|
||||
struct usb_device *device = usb_device_open(devname);
|
||||
|
||||
if (!device) {
|
||||
dprintf(cmd->out, "usb_device_open failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The vendor cmd only applies to USB Hubs of Genesys Logic, Inc.
|
||||
// The request field of vendor cmd is fixed to 0xe3.
|
||||
vendorId = usb_device_get_vendor_id(device);
|
||||
productId = usb_device_get_product_id(device);
|
||||
if (vendorId == GL852G_VENDOR_ID &&
|
||||
(productId == GL852G_PRODUCT_ID1 || productId == GL852G_PRODUCT_ID2)) {
|
||||
int ret = usb_device_control_transfer(
|
||||
device, USB_DIR_OUT | USB_TYPE_VENDOR,
|
||||
GL852G_VENDOR_CMD_REQ, cmd->value, cmd->index, NULL, 0,
|
||||
CTRL_TRANSFER_TIMEOUT_MSEC);
|
||||
dprintf(cmd->out, "Vendor cmd %s (wValue %x, wIndex %x, return %d)\n",
|
||||
ret? "failed" : "succeeded", cmd->value, cmd->index, ret);
|
||||
// Stop iterating through usb devices once the hub is found.
|
||||
cmd->found = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbDiscoveryDone(void *client_data)
|
||||
{
|
||||
struct hub_vendor_cmd *cmd = (struct hub_vendor_cmd *)client_data;
|
||||
|
||||
dprintf(cmd->out, "Done USB discovery, hub %s found\n",
|
||||
cmd->found ? "is" : "not");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static status_t sendHubVendorCmd(int out, Vector<String8>& args) {
|
||||
if (args.size() < 3) {
|
||||
dprintf(out, "Incorrect number of argument supplied\n");
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
struct hub_vendor_cmd cmd = {
|
||||
.value = std::stoi(args[1].c_str(), NULL, 16),
|
||||
.index = std::stoi(args[2].c_str(), NULL, 16),
|
||||
.out = out,
|
||||
.found = false
|
||||
};
|
||||
|
||||
struct usb_host_context *ctx;
|
||||
ctx = usb_host_init();
|
||||
if (!ctx) {
|
||||
dprintf(out, "usb_host_init failed\n");
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
usb_host_run(ctx, usbDeviceAdded, NULL, usbDiscoveryDone, &cmd);
|
||||
usb_host_cleanup(ctx);
|
||||
|
||||
return ::android::NO_ERROR;
|
||||
}
|
||||
|
||||
status_t Usb::handleShellCommand(int in, int out, int err, const char** argv,
|
||||
uint32_t argc) {
|
||||
uid_t uid = AIBinder_getCallingUid();
|
||||
|
@ -1186,13 +1175,28 @@ status_t Usb::handleShellCommand(int in, int out, int err, const char** argv,
|
|||
|
||||
if (argc >= 1) {
|
||||
if (!utf8Args[0].compare(String8("hub-vendor-cmd"))) {
|
||||
return sendHubVendorCmd(out, utf8Args);
|
||||
if (utf8Args.size() < 3) {
|
||||
dprintf(out, "Incorrect number of argument supplied\n");
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
int value, index;
|
||||
if (!::android::base::ParseInt(utf8Args[1].c_str(), &value) ||
|
||||
!::android::base::ParseInt(utf8Args[2].c_str(), &index)) {
|
||||
dprintf(out, "Fail to parse arguments\n");
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
mUsbHubVendorCmdValue = value;
|
||||
mUsbHubVendorCmdIndex = index;
|
||||
ALOGI("USB hub vendor cmd update (wValue 0x%x, wIndex 0x%x)\n",
|
||||
mUsbHubVendorCmdValue, mUsbHubVendorCmdIndex);
|
||||
return ::android::NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
dprintf(out, "usage: adb shell cmd hub-vendor-cmd VALUE INDEX\n"
|
||||
" VALUE wValue field in hex format, e.g. f321\n"
|
||||
" INDEX wIndex field in hex format, e.g. f321\n");
|
||||
" VALUE wValue field in hex format, e.g. 0xf321\n"
|
||||
" INDEX wIndex field in hex format, e.g. 0xf321\n"
|
||||
" The settings take effect next time the hub is enabled\n");
|
||||
|
||||
return ::android::NO_ERROR;
|
||||
}
|
||||
|
|
|
@ -93,8 +93,12 @@ struct Usb : public BnUsb {
|
|||
float mPluggedTemperatureCelsius;
|
||||
// Usb Data status
|
||||
bool mUsbDataEnabled;
|
||||
// Usb hub vendor command settings for JK level tuning
|
||||
int mUsbHubVendorCmdValue;
|
||||
int mUsbHubVendorCmdIndex;
|
||||
private:
|
||||
pthread_t mPoll;
|
||||
pthread_t mUsbHost;
|
||||
};
|
||||
|
||||
} // namespace usb
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue