Commit graph

51 commits

Author SHA1 Message Date
Kyle Tso
ea7bd38c52 usb: Remove project-specific file modification
Bug: 365912852
Test: verified the file owner and permission
Flag: EXEMPT bugfix
Change-Id: I41d4a03c1f38ce332887889eda960acc9625aa2d
Signed-off-by: Kyle Tso <kyletso@google.com>
2024-09-24 08:40:00 +00:00
Badhri Jagan Sridharan
f16ad49244 Rename enable_usb dev node to move_data_to_usb
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>
2024-08-29 14:28:52 +00:00
Badhri Jagan Sridharan
7ebbf913ef Usb: Update UsbDataStatus while being docked
Bug: 275150939
Bug: 357028350
Change-Id: I09499642012c7e95bb5a5fef1ac6eb7b8c4e6832
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
(ported from ag/22273065)
Signed-off-by: Kyle Tso <kyletso@google.com>
2024-08-29 14:02:06 +00:00
Amit Sunil Dhamne
7f688ffd28 UsbGadget: Update SDP enum timeout when gadget is pulled up
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>
2024-08-20 18:36:29 -07:00
Kuen-Han Tsai
5cfc68b55b Limit hub tuning when enable_hub is enabled
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>
2024-08-06 09:45:05 +00:00
Roy Luo
9236e194c0 Use absolute path for udc device
Avoid search in /sys/class/udc directory

Bug: 339241080
Test: tested on zumapro
Flag: EXEMPT bugfix
Change-Id: Iad74cae0d6ad6887d79d705dc8478f1b44532503
2024-06-27 00:08:41 +00:00
Kyle Tso
4f43c1cdaf usb: Log for retry on role switch
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)
2024-06-13 17:04:11 +08:00
Kyle Tso
a22b308d42 usb: Add retry on role switch
Bug: 341996696
Change-Id: I8caa65288af1588d24fea4aa6c5768d45d69bbd5
Signed-off-by: Kyle Tso <kyletso@google.com>
(cherry picked from commit ef5856a4474002cc35a51377adffddd4cb239796)
2024-06-13 17:02:08 +08:00
Dennis Shen
8a0c1ccc91 switch over to use new storage read api instead of
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
2024-06-07 13:09:09 +00:00
Roy Luo
a6a17804f7 Update JK level setting
Bug: 340665903
Test: N/A
Change-Id: I5f14383aa2f97352a9a1f98b6f83c7cc975b0c58
2024-05-29 23:47:35 +00:00
Roy Luo
fd704fdcfb Support GL852G USB hub JK level tuning
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
2024-05-22 00:57:45 +00:00
Roy Luo
b058b0088f Add shell command to send vendor command to GL852G
Bug: 261923350
Bug: 340665903
Test: adb shell cmd android.hardware.usb.IUsb/default hub-vendor-cmd
<hex wValue> <hex wIndex>
Change-Id: I83b56d28cfd89dfaf51fce88f97020196402f972
Signed-off-by: Roy Luo <royluo@google.com>
2024-05-22 00:49:45 +00:00
Treehugger Robot
4d5349f64b Merge "usb: handle displayport debounce timer empty reads" into main 2024-03-29 23:57:14 +00:00
Chien Kun Niu
57d671706b usb: change CPU to big core 7
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>
2024-03-27 08:25:24 +00:00
RD Babiera
94c9c1ac86 usb: handle displayport debounce timer empty reads
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>
2024-03-19 18:34:02 +00:00
Sergey Volk
9ede436718 Fix permissions for dp_hotplug_error_code sysfs node
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
2024-02-13 22:56:26 +00:00
RD Babiera
92f2eb594a usb: select usb-service rc files based on device type
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>
2024-01-30 17:59:32 +00:00
RD Babiera
f1140a12b1 usb: Runtime search the i2c path
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>
2024-01-30 17:56:51 +00:00
RD Babiera
7957a85d46 Merge "usb: report displayport capable port partner disconnect to drm" into main 2024-01-23 17:42:50 +00:00
Scott Wiest
b7046b2dce UsbGadget: Add support for webcam on zumapro
Bug: 318801643

Test: Manual

Change-Id: I77a97a13779452f75b5d73300904a1c2825b1ba3
2024-01-19 21:50:01 +00:00
Roy Luo
340d840cfe usb: dump flag value in the constructor
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)
2024-01-10 10:47:32 +00:00
Roy Luo
aa0edc38fb usb: adjust heuristics for flaky connection warning
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)
2023-12-26 23:12:18 +00:00
Roy Luo
ce1aaad6e2 usb: implement heuristics to flag data compliance warnings
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)
2023-12-26 23:12:07 +00:00
RD Babiera
39c864b17b usb: report displayport capable port partner disconnect to drm
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)
2023-12-11 22:35:20 +00:00
Roy Luo
8bd5335437 Revert^2 "usb: introduce UsbDataSessionMonitor class"
e2db6dd90c

Bug: 297224564
Bug: 296119135
Change-Id: Ib25bd56744dfb6a8d357f988bda60422f6e3f00f
2023-12-08 20:14:49 +00:00
Qian-Hao Huang
e2db6dd90c Revert "usb: introduce UsbDataSessionMonitor class"
Revert submission 25524752-usbDataSessionMonitor

Reason for revert: Test for gs101/gs201 boot blocking issue (b/314904288)

Reverted changes: /q/submissionid:25524752-usbDataSessionMonitor

Change-Id: Iba9e6a4c1e98db742e3c8691313166c2cd229554
2023-12-05 09:36:22 +00:00
Roy Luo
0c1deb532f usb: introduce UsbDataSessionMonitor class
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)
2023-12-01 01:00:23 +00:00
RD Babiera
637426c6a8 Merge "usb: reattempt to enter displayport alt mode if driver entry process fails" into main 2023-11-17 22:12:05 +00:00
RD Babiera
d7ac262f4a usb: reattempt to enter displayport alt mode if driver entry process fails
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>
2023-11-17 01:20:13 +00:00
Roy Luo
03fbf970bb usb: update usb hal version to v3
Bug: 308700954
Bug: 301380358
Test: atest vts_treble_vintf_vendor_test
Change-Id: I724a170a1403dec7eecbc33d7f532471f09b559f
2023-11-16 00:03:56 +00:00
Roy Luo
acf4e01386 usb: update incompatible charger warning reason
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
2023-11-16 00:03:49 +00:00
Badhri Jagan Sridharan
3c94c8bb80 Usb: Populate connected status of non compliant port partners only when not populated
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
2023-11-16 00:03:24 +00:00
Badhri Jagan Sridharan
0991cd02ca Usb: Set connected status when connected to non compliant port partners
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)
2023-11-15 18:23:56 +00:00
RD Babiera
90ece745e5 Usb: non-compliant port partner implementation
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)
2023-11-15 18:23:48 +00:00
RD Babiera
52d276e80f Merge "usb: enable/disable displayport alt mode through enableUsbData" into main 2023-10-13 21:23:36 +00:00
RD Babiera
435c89be86 Merge "usb: check for port partner Thunderbolt capability" into main 2023-10-05 23:09:55 +00:00
RD Babiera
e1a03c3dd0 usb: check for port partner Thunderbolt capability
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)
2023-10-05 20:01:02 +00:00
Roy Luo
5f6a61e1a4 Merge "usb: upgrade stats AIDL to v2" into main 2023-10-03 20:49:36 +00:00
Treehugger Robot
81b7f5cfc6 Merge "Usb.cpp: Fix typos when unable to disable USB data" into udc-qpr-dev am: 206ecbd71d am: 96d8442f91
Original change: https://googleplex-android-review.googlesource.com/c/device/google/zumapro/+/24800352

Change-Id: I33e7c8ed998a03b4b23047347581b26254fa78e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-21 11:30:59 +00:00
Roy Luo
7d8e108a00 usb: upgrade stats AIDL to v2
Upgrade stats AIDL to v2 following pixelstats lib.

Bug: 297224564
Test: Build
Change-Id: I3ff3a761467651a6550ec0c07419844189216a2e
2023-09-20 23:37:33 +00:00
RD Babiera
7fbcdf0237 usb: enable/disable displayport alt mode through enableUsbData
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>
2023-09-20 19:51:03 +00:00
Kuen-Han Tsai
20d7a3bcc3 Usb.cpp: Fix typos when unable to disable USB data
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
2023-09-19 18:57:13 +08:00
RD Babiera
2323e69cf4 usb: populate USB aidl hal AltModeData
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>
2023-09-11 21:22:05 +00:00
RD Babiera
d14e37d77d Usb: shutdown old displayport poll thread when multiple start up
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>
2023-09-11 21:22:01 +00:00
Badhri Jagan Sridharan
8e5daebb44 Usb: Check for displayport when booting
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>
2023-09-11 21:21:57 +00:00
Badhri Jagan Sridharan
9df9887bd1 Usb: Signal irq_hpd to drm stack
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>
2023-09-11 21:21:53 +00:00
RD Babiera
667ff0cf59 usb: Fix HAL build warnings related to DisplayPort
Adds proper error handling go-to points to remove warnings arising
from uninitialized variables, and removes unused
queryDisplayPortStatus() method.

Test: manual test on device, verify compiler warnings
Bug: 297286558
Change-Id: I54f7b710a0805b32c894d741e473d64814200134
(cherry picked from commit 4e29924d3d5ef1e9e13df46bf249f91593c73946)
Signed-off-by: RD Babiera <rdbabiera@google.com>
2023-09-11 21:21:50 +00:00
RD Babiera
94dac0240c usb: provide usb reference to DisplayPort shutdown thread
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>
2023-09-11 21:21:43 +00:00
RD Babiera
fe0c40802e Port dp changes to drm sysfs
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>
2023-09-08 22:46:43 +00:00
Chien Kun Niu
2d27d7b453 usb: add all i2c number
Add all I2c number to change the permission

Bug: 297109635
Test: limit 1.3A work
Change-Id: I5ca8301da72ea848154f5382265ea06fa432fea2
2023-08-24 15:45:35 +08:00