This patch prevents a Null Pointer Exception in
queryMoistureDetectionStatus() when getPortStatusHelper() fails to open
the /sys/class/typec file. The failure results in an empty
currentPortStatus vector, causing the NPE when accessing its first
element.
Bug: 361097811
Flag: EXEMPT bugfix
Test: NPE does not occur when getPortStatusHelper() fails
Change-Id: I4657ab8dbc9bb7e5d2dc46c1a20b66477604ec36
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
kernel dev attribute has now been renamed from enable_usb
to move_data_to_usb. Update the same.
Bug: 251381400
Bug: 357028350
Flag: EXEMPT bugfix
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I8e4aa0b2e09bfef807f0169eabb79e2fa2e4d2c7
(ported from ag/20309232)
Signed-off-by: Kyle Tso <kyletso@google.com>
Indicate to the kernel that the usb gadget is pulled up
by writing to `update_sdp_enum_timeout` sysfs node. Write
to this node will inform the kernel that it can lower the SDP
timeout alarm value which is used to detect an SDP port
vs a DCP.
Bug:356685367
Test: Check `update_sdp_enum_timeout` is written into after usb
gadget is pulled up. Verify that the alarm timeout lowers.
Flag: EXEMPT bugfix
Change-Id: Id3ae7e7a20b236cec6604414a7f81860e868bdd0
(ported from commit d8e2a02998fc1db9be00dab69a213378fb3caede)
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Some external hubs have the same VID and PID as the internal hub,
causing unintended hub tuning and compatibility issues.
This patch restricts hub tuning to only the internal hub located on
bus 1, port 1 when enable_hub is set to 1.
Bug: 353650207
Test: Verified an external GL852G speakerphone dock works when docked.
Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd <hex wValue> <hex wIndex>
Flag: EXEMPT bugfix
Change-Id: I381f3883c90628753f0e5e9c11eb546fb15ce679
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Add a log for the retry. Also define the sleep time in the header file.
Bug: 341996696
Change-Id: Ib3cc0c6ad576e7cda26b7f50cdc61d52e6349c78
Signed-off-by: Kyle Tso <kyletso@google.com>
(cherry picked from commit d17fdff5f81cff76adaa75d50f26318be8048123)
server_configurable_flags, this new read api lib will be needed for new
codegened aconfig flag lib.
Bug: 321077378
Test m and avd
Change-Id: Ib25c24bf437f2de5a557653ef6ed42f8fbac65e1
The JK level setting is configured to the hub via a vendor USB
command whenever the hub is enabled.
The shell command can be used to change the JK setting for testing
purpose, but the values take effect next time the hub is enumerated.
Bug: 261923350
Bug: 340665903
Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd
<hex wValue> <hex wIndex>
Test: verify on user/userdebug builds the vendor command is triggered
in the following scenarios.
1. boot with Kolan docked
2. undock and dock Kolan
3. kill android.hardware.usb.IUsb/default
Change-Id: I8873695c42f362138d99b45ffa2ef637c357202b
Change the big core number from 8 to 7 for change platform.
Bug: 316995755
Change-Id: Iec0fe10621296d557ae66da76318a6339ea16d44
Signed-off-by: Chien Kun Niu <rickyniu@google.com>
If the device is unplugged then plugged before
mDisplayPortDebounceTimer triggers, then the new
displayPortPollWork could process the trigger
in the intial epoll handling loop. Because the
timer can be rearmed, the timerfd read results
in -EAGAIN because no data is ready, but stale
data was ready to begin with.
Disarm the debounce timer when displayPortPollWork
closes to prevent new work threads from reading
timer when not ready. Also log debounce read
errors as a warning and not an error.
Test: manual test on device
Bug: 328553922
Change-Id: Icf3dbe929eb9f0520941a4efe3dcea79a71d46c3
Signed-off-by: RD Babiera <rdbabiera@google.com>
DisplayPort kernel driver passes error code/status to hardware composer
via the dp_hotplug_error_code sysfs file. When HWC receives/consumes
the error, it will write "0" into that file to reset the error code. So
this file must be readable and writable by the HWC code running with
"system" user/group permissions.
Bug: 324953626
Test: checked that SYSFS dp_hotplug_error_code has correct permissions
Change-Id: Idb7d44f8e9f22fc61e8df432aa72281daddb15ef
i2c paths for 5.15 and 6.1 kernels are statically assigned,
so delete variations that do not exist from init rc file.
Depending on the device either i2c bus 6 or 11 are used, so
create permissions for both in separate init rc files.
Put the correct rc file to the vendor partition based on
target product.
Test: Manual test on device. Confirm that file reads related to
file path error do not trigger error.
Bug: 318820040
Change-Id: I4cb67bcbba99ef32a5ddfb2487b92ee196563b90
Signed-off-by: RD Babiera <rdbabiera@google.com>
The paths of sysfs nodes are different across kernel versions
and i2c bus assignement. Runtime search the correct ones.
Test: Manual test on device. Confirm that file reads related to
file path error do not trigger error.
Bug: 318820040
Change-Id: I1217fcea012865cebe12c935917f12903003fd5b
(ported from commit 0b768c8fbe1e59a4b9efa7b5f7b6a017a81d46fb)
Signed-off-by: RD Babiera <rdbabiera@google.com>
Dump flag value in the construtor for easier debugging. Feature flags
are not expected to change in runtime, dumping the value once should
be enough.
Bug: 296119135
Test: manual test
Change-Id: Ie5aca2dff23e59704fb306833cde0e592b9f430d
(cherry picked from commit 9164eae7cdee032381d8bf045fbbed33f62b00bf)
The state count requirement is very specific to the case where the
signal integrity is the culprit of flaky connection. However,
there could be other cases such as bad receptacles causing data pins
to disconnect randomly.
Remove the state count requirement to cover more cases.
Bug: 296119135
Test: manually trigger the warnings
Change-Id: Ic2ae376ad6062d9930614381503f44e4a5ac760f
(cherry picked from commit 5e14ba01be9acc31d3df0f506b4287eea0bf9583)
Support flagging enum failure and flaky connection in device mode,
flagging enum failure and missing data lines in host mode.
No warning would be flagged until 5 secs after the data session
starts to give ample time for the connection to stabilize, a timer
is added to support it.
Bug: 296119135
Test: manually trigger the warnings
Change-Id: I25f08657e328913946add192b5ecb9ee50c3a1a8
(cherry picked from commit 42020dc4585442bd7ca88f183ba29a18834af197)
On port-partner remove, write to drm's usbc_cable_disconnect
node if setupDisplayPortPoll() had run previously in the
connection, flagged by mPartnerSupportsDisplayPort.
Test: manual test on device
Bug: 303820069
Change-Id: I3478f2f027540972647044716a1a3e832ae1b152
Signed-off-by: RD Babiera <rdbabiera@google.com>
(cherry picked from commit 3082aa7f4877e737f06f2fb170778dac56fb7d0a)
Migrate the usb data session event functions to the class with the
following additional functionalities;
- Support detecting gadget soft pulldown (usually done during configfs
function switch) and report usb data session correctly.
- Support reporting usb data compliance warnings to the class USB
by providing getDataComplianceWarnings call.
- Use boot_clock instead of steady_clock to measure time correctly in
the case of system suspend.
UsbDataSessionMonitor is self-contained and can be migrated to pixel usb
library after feature maturation.
Bug: 297224564
Bug: 296119135
Test: usb data session upload in device and host mode
Change-Id: Iba001933e193935d64cf5fd0a1257d02a4274fb1
(cherry picked from commit ea65ca11f6fbb6f13b89ef9ed03015f47ec1cedb)
In the kernel, it is possible for the DisplayPort Alt Mode
driver to queue an Enter Mode message to the tcpm and have
that message be interupted by a Power Role or Vconn swap,
which results in the Port Partner never entering Alt Mode.
Add a debounce that checks to make sure that the port partner
enters Alt Mode when DisplayPort Alt Mode is active on the
port. On trigger, reattempt to send Enter Mode through the
tcpm up to 2 times.
Test: Manual test on device - put device into Preferred
Source role, test to see if Alt Mode reentry triggers
when original entry is interrupted by PR Swap from
monitor.
Bug: 308383356
(cherry picked from commit 04d1e94d10515f03e66cdfe16a23924e561cb3f3)
Change-Id: I96563c9900a01e428850e4873371bcdb0225aa07
Signed-off-by: RD Babiera <rdbabiera@google.com>
Report COMPLIANCE_WARNING_INPUT_POWER_LIMITED instead of
COMPLIANCE_WARNING_OTHER to flag incompatible chargers. The underlying
logic that generates the warning remains the same, what's changed is
the enum that's being used.
The purpose of the change is to have a warning type that better
represents what actually happens and free up COMPLIANCE_WARNING_OTHER
that was intended to act as a fallback reason code.
The flag enable_input_power_limited_warning controls whether to switch
to the new enum, while the flag enable_usb_data_compliance_warning
controls the new enums that are added as FlaggedApi in the framework.
Both flags need to be on to enable the change.
Bug: 308700954
Bug: 301380358
Test: manual tests with local flag override
Change-Id: I6595706d1b83d533fc2d3e29086773270e045ede
Set mode, power role and data role on non compliant port partners
only if the portStatus is not already populated. Compliance warnings
such as missing rp do not populate these fields during
getPortStatusHelper
Test: manual test on device
Bug: 279251052
Bug: 301380358
Change-Id: Ibe71bdd5c521ba90c124d89bd56af90087c0df18
Set mode, power role and data role when connected to non compliant
port partners.
Test: manual test on device
Bug: 268584498
Bug: 301380358
Change-Id: I6c3e7df09a61e26f3b976a86bd65cb646edd653d
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
(cherry picked from commit 7c2d62aafc219af11252dabf49d84d84b7ccfa57)
Adds vendor code for non-compliant charger feature.
Minor port of commit 96ccf93453583642a15dd96b1e4d6bf0645fc10b
Test: atest VtsAidlUsbTargetTest
Test: manual test on device
Bug: 301380358
Change-Id: Ie1a48b1acaaae9a53f3b9bfebcfee7a2f4814810
(cherry picked from commit 96ccf93453583642a15dd96b1e4d6bf0645fc10b)
Query the port partner's SVIDs when the DisplayPort driver sysfs
is not recognized so that the USB HAL can identify whether or not
the port partner supports Thunderbolt.
Test: manual verification on device - test to see that cableStatus
is set to NOT_CAPABLE on hub that supports Thunderbolt but not
DisplayPort Alt Mode. Then verify that device not capable of being
a DisplayPort sink but does support Thunderbolt does not trigger
this status.
Bug: 288150501
Change-Id: Iaba60ecc5510acecee1e1d3241611906c738a263
Signed-off-by: RD Babiera <rdbabiera@google.com>
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:873766c6f0c668ba526eaefe18ecc5e51ce87d67)
Adds functionality for enabling and disabling DisplayPort Alt Mode
on the port through enableUsbData in the USB HAL to comply with USB
restrictions for heightened security mode.
Test: manual test on device - use enableUsbData dumpsys command to
turn off DisplayPort and then turn it back on while connected to a
partner sink.
Bug: 297208252
Change-Id: I9f071bce802b728f2229abc08efb2204e4c2505a
Signed-off-by: RD Babiera <rdbabiera@google.com>
If Usb.cpp cannot write a zero value to the USB_DATA_PATH file, display
the message of "Not able to turn off usb connection notification".
Test: refactoring CL. Existing tests still pass.
Bug: 301016122
Change-Id: I4e2a920a67b022496c5332d260ff53cd6400a9f9
Populates AltModeData within PortStatus with DisplayPort
Alt Mode statuses for pin assignment, hpd, link training
status, and port partner capability.
Test: manual test on device
Bug: 297286558
Change-Id: I52a56f7090ed6dbef6211f19d6350cecac58e4fa
(cherry picked from commit c2c37bf3a81e4138bd2c0e82275d363dce2220ec)
Signed-off-by: RD Babiera <rdbabiera@google.com>
Better enforces that only one DisplayPort poll thread should be
active at once. If a new call to setup is made from additional
bind uevents before a disconnect occurs, tells the old thread
to shutdown and awaits signaling before a new worker thread spins
up.
Test: manual testing on device
Bug: 286593610
Change-Id: I1707970c500915fd4abb161d0b3a424bbb2bddca
(cherrypicked from commit 78f6294e381ca4df70b28d1d0f07aff77b73574c)
Signed-off-by: RD Babiera <rdbabiera@google.com>
When booting check whether displayport driver has been probed and
signal hpd events as needed. Pin config and orientation needs to
be queried before signalling hpd.
Test: Manual verification on device
Bug: 297286558
Change-Id: Iddb0921b363e49c41c0f6f635887b4daf4d19561
(cherry picked from commit 574d046bd7c3a2d81f48caf3881a61ad0d283e9a)
Signed-off-by: RD Babiera <rdbabiera@google.com>
Monitor typec stack for irq_hpd events and signal irq_hpd when the
irq_hpd counter value read is not the same as the previously cached
value.
Test: Manual verification on device
Bug: 297286558
Change-Id: Id4a72afcf85550cabbc2f9469bb0ccb92cd02ad2
(cherry picked from commit 412f31194c8b169806a2c0df85ef6bf69cf7af0b)
Signed-off-by: RD Babiera <rdbabiera@google.com>
Passes usb object reference to thread creation of
mDisplayPortShutdownHelper so that it can properly call DisplayPort
shutdown method instead of calling on NULL reference.
Test: manual test on device
Bug: 297286558
Change-Id: Ie4dabb5e3ae9065f57cc0fbf2593fbe399097472
(cherry picked from commit cc50d9950807280653973a0dd9cd3b22e323bcd5)
Signed-off-by: RD Babiera <rdbabiera@google.com>
Write pin assignment, hpd, and orientation from type-c class to
drmdp platform device attributes using epoll when displayport
driver binds to device, and determine whether or not to shut down
epoll on displayport driver change uevents.
Test: manual testing with form factor device
Bug: 297286558
(cherry picked from commit de0fc9d2201685b5eb4c3905e652911b192a542f)
Change-Id: Iec9fc76166481a4611bb2fc023aea044b497f2c0
Signed-off-by: RD Babiera <rdbabiera@google.com>