1#
2# Copyright (C) 2016 The Android Open-Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17on early-boot
18    mount configfs none /config
19    mkdir /config/usb_gadget/g1 0770
20    mkdir /config/usb_gadget/g1/strings/0x409 0770
21    write /config/usb_gadget/g1/bcdUSB 0x0200
22    write /config/usb_gadget/g1/idVendor 0x18d1
23    write /config/usb_gadget/g1/bcdDevice 0x0440
24    write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
25    write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
26    write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
27    mkdir /config/usb_gadget/g1/functions/accessory.gs2
28    mkdir /config/usb_gadget/g1/functions/audio_source.gs3
29    mkdir /config/usb_gadget/g1/functions/midi.gs5
30    mkdir /config/usb_gadget/g1/functions/ffs.adb
31    mkdir /config/usb_gadget/g1/functions/ffs.mtp
32    mkdir /config/usb_gadget/g1/functions/ffs.ptp
33    mkdir /config/usb_gadget/g1/functions/diag.diag
34    mkdir /config/usb_gadget/g1/functions/cser.dun.0
35    mkdir /config/usb_gadget/g1/functions/cser.nmea.1
36    mkdir /config/usb_gadget/g1/functions/gsi.rmnet
37    mkdir /config/usb_gadget/g1/functions/gsi.rndis
38    mkdir /config/usb_gadget/g1/functions/qdss.qdss
39    mkdir /config/usb_gadget/g1/configs/b.1 0770
40    mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770
41    write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
42    write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
43    mkdir /dev/usb-ffs 0775 shell shell
44    mkdir /dev/usb-ffs/adb 0770 shell shell
45    mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1
46    mkdir /dev/usb-ffs/mtp 0770 mtp mtp
47    mkdir /dev/usb-ffs/ptp 0770 mtp mtp
48    mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
49    mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
50    setprop sys.usb.mtp.device_type 3
51    setprop sys.usb.controller "a600000.dwc3"
52    symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
53    write /sys/module/libcomposite/parameters/disable_l1_for_hs "y"
54    write /config/usb_gadget/g1/functions/gsi.rndis/rndis_class_id 1
55
56on boot
57    setprop sys.usb.configfs 2
58
59on charger
60    mkdir /config/usb_gadget/g1 0770
61    mkdir /config/usb_gadget/g1/strings/0x409 0770
62    write /config/usb_gadget/g1/bcdUSB 0x0200
63    write /config/usb_gadget/g1/idVendor 0x18d1
64    write /config/usb_gadget/g1/bcdDevice 0x0440
65    write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
66    write /config/usb_gadget/g1/strings/0x409/manufacturer Google
67    write /config/usb_gadget/g1/strings/0x409/product Pixel
68    mkdir /config/usb_gadget/g1/functions/midi.gs5
69    mkdir /config/usb_gadget/g1/configs/b.1 0770
70    mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770
71    symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
72    write /sys/module/libcomposite/parameters/disable_l1_for_hs "y"
73    setprop sys.usb.controller "a600000.dwc3"
74    setprop sys.usb.configfs 1
75
76on property:ro.bootmode=charger
77    setprop sys.usb.config midi
78
79on property:sys.usb.config=midi && property:sys.usb.configfs=1
80    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "midi"
81    rm /config/usb_gadget/g1/configs/b.1/f1
82    rm /config/usb_gadget/g1/configs/b.1/f2
83    rm /config/usb_gadget/g1/configs/b.1/f3
84    rm /config/usb_gadget/g1/configs/b.1/f4
85    write /config/usb_gadget/g1/idVendor 0x18d1
86    write /config/usb_gadget/g1/idProduct 0x4eea
87    symlink /config/usb_gadget/g1/functions/midi.gs5 /config/usb_gadget/g1/configs/b.1/f1
88    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
89    setprop sys.usb.state ${sys.usb.config}
90