Skip to content

Commit 466271d

Browse files
committed
feat: add usb gadget audio config
1 parent 2aa7b85 commit 466271d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ var defaultConfig = &Config{
125125
RelativeMouse: true,
126126
Keyboard: true,
127127
MassStorage: true,
128+
Audio: true,
128129
},
129130
NetworkConfig: &network.NetworkConfig{},
130131
DefaultLogLevel: "INFO",

internal/usbgadget/config.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ var defaultGadgetConfig = map[string]gadgetConfigItem{
6363
// mass storage
6464
"mass_storage_base": massStorageBaseConfig,
6565
"mass_storage_lun0": massStorageLun0Config,
66+
// audio
67+
"audio": {
68+
order: 4000,
69+
device: "uac1.usb0",
70+
path: []string{"functions", "uac1.usb0"},
71+
configPath: []string{"uac1.usb0"},
72+
attrs: gadgetAttributes{
73+
"p_chmask": "3",
74+
"p_srate": "48000",
75+
"p_ssize": "2",
76+
"p_volume_present": "0",
77+
"c_chmask": "3",
78+
"c_srate": "48000",
79+
"c_ssize": "2",
80+
"c_volume_present": "0",
81+
},
82+
},
6683
}
6784

6885
func (u *UsbGadget) isGadgetConfigItemEnabled(itemKey string) bool {
@@ -77,6 +94,8 @@ func (u *UsbGadget) isGadgetConfigItemEnabled(itemKey string) bool {
7794
return u.enabledDevices.MassStorage
7895
case "mass_storage_lun0":
7996
return u.enabledDevices.MassStorage
97+
case "audio":
98+
return u.enabledDevices.Audio
8099
default:
81100
return true
82101
}

internal/usbgadget/usbgadget.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Devices struct {
1717
RelativeMouse bool `json:"relative_mouse"`
1818
Keyboard bool `json:"keyboard"`
1919
MassStorage bool `json:"mass_storage"`
20+
Audio bool `json:"audio"`
2021
}
2122

2223
// Config is a struct that represents the customizations for a USB gadget.

0 commit comments

Comments
 (0)