usb: remove msos-descriptor feature.
This commit is contained in:
@ -13,7 +13,6 @@ target = "thumbv7em-none-eabi"
|
||||
[features]
|
||||
defmt = ["dep:defmt", "embassy-usb-driver/defmt"]
|
||||
usbd-hid = ["dep:usbd-hid", "dep:ssmarshal"]
|
||||
msos-descriptor = []
|
||||
default = ["usbd-hid"]
|
||||
|
||||
# BEGIN AUTOGENERATED CONFIG FEATURES
|
||||
|
@ -3,7 +3,6 @@ use heapless::Vec;
|
||||
use crate::config::MAX_HANDLER_COUNT;
|
||||
use crate::descriptor::{BosWriter, DescriptorWriter};
|
||||
use crate::driver::{Driver, Endpoint, EndpointType};
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
use crate::msos::{DeviceLevelDescriptor, FunctionLevelDescriptor, MsOsDescriptorWriter};
|
||||
use crate::types::{InterfaceNumber, StringIndex};
|
||||
use crate::{Handler, Interface, UsbDevice, MAX_INTERFACE_COUNT, STRING_INDEX_CUSTOM_START};
|
||||
@ -133,7 +132,6 @@ pub struct Builder<'d, D: Driver<'d>> {
|
||||
config_descriptor: DescriptorWriter<'d>,
|
||||
bos_descriptor: BosWriter<'d>,
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
msos_descriptor: MsOsDescriptorWriter<'d>,
|
||||
}
|
||||
|
||||
@ -149,7 +147,7 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
device_descriptor_buf: &'d mut [u8],
|
||||
config_descriptor_buf: &'d mut [u8],
|
||||
bos_descriptor_buf: &'d mut [u8],
|
||||
#[cfg(feature = "msos-descriptor")] msos_descriptor_buf: &'d mut [u8],
|
||||
msos_descriptor_buf: &'d mut [u8],
|
||||
control_buf: &'d mut [u8],
|
||||
) -> Self {
|
||||
// Magic values specified in USB-IF ECN on IADs.
|
||||
@ -189,14 +187,12 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
config_descriptor,
|
||||
bos_descriptor,
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
msos_descriptor: MsOsDescriptorWriter::new(msos_descriptor_buf),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates the [`UsbDevice`] instance with the configuration in this builder.
|
||||
pub fn build(mut self) -> UsbDevice<'d, D> {
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
let msos_descriptor = self.msos_descriptor.build(&mut self.bos_descriptor);
|
||||
|
||||
self.config_descriptor.end_configuration();
|
||||
@ -206,7 +202,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
info!("USB: device_descriptor used: {}", self.device_descriptor.position());
|
||||
info!("USB: config_descriptor used: {}", self.config_descriptor.position());
|
||||
info!("USB: bos_descriptor used: {}", self.bos_descriptor.writer.position());
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
info!("USB: msos_descriptor used: {}", msos_descriptor.len());
|
||||
info!("USB: control_buf size: {}", self.control_buf.len());
|
||||
|
||||
@ -217,10 +212,9 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
self.device_descriptor.into_buf(),
|
||||
self.config_descriptor.into_buf(),
|
||||
self.bos_descriptor.writer.into_buf(),
|
||||
msos_descriptor,
|
||||
self.interfaces,
|
||||
self.control_buf,
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
msos_descriptor,
|
||||
)
|
||||
}
|
||||
|
||||
@ -251,7 +245,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
builder: self,
|
||||
iface_count_index,
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
first_interface,
|
||||
}
|
||||
}
|
||||
@ -275,7 +268,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
StringIndex::new(index)
|
||||
}
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
/// Add an MS OS 2.0 Descriptor Set.
|
||||
///
|
||||
/// Panics if called more than once.
|
||||
@ -283,13 +275,11 @@ impl<'d, D: Driver<'d>> Builder<'d, D> {
|
||||
self.msos_descriptor.header(windows_version, vendor_code);
|
||||
}
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
/// Add an MS OS 2.0 Device Level Feature Descriptor.
|
||||
pub fn msos_feature<T: DeviceLevelDescriptor>(&mut self, desc: T) {
|
||||
self.msos_descriptor.device_feature(desc);
|
||||
}
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
/// Gets the underlying [`MsOsDescriptorWriter`] to allow adding subsets and features for classes that
|
||||
/// do not add their own.
|
||||
pub fn msos_writer(&mut self) -> &mut MsOsDescriptorWriter<'d> {
|
||||
@ -306,13 +296,11 @@ pub struct FunctionBuilder<'a, 'd, D: Driver<'d>> {
|
||||
builder: &'a mut Builder<'d, D>,
|
||||
iface_count_index: Option<usize>,
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
first_interface: InterfaceNumber,
|
||||
}
|
||||
|
||||
impl<'a, 'd, D: Driver<'d>> Drop for FunctionBuilder<'a, 'd, D> {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
self.builder.msos_descriptor.end_function();
|
||||
}
|
||||
}
|
||||
@ -344,7 +332,6 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
/// Add an MS OS 2.0 Function Level Feature Descriptor.
|
||||
pub fn msos_feature<T: FunctionLevelDescriptor>(&mut self, desc: T) {
|
||||
if !self.builder.msos_descriptor.is_in_config_subset() {
|
||||
@ -355,7 +342,6 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> {
|
||||
self.builder.msos_descriptor.function(self.first_interface);
|
||||
}
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
self.builder.msos_descriptor.function_feature(desc);
|
||||
}
|
||||
}
|
||||
|
@ -175,10 +175,7 @@ pub struct UsbBufferReport {
|
||||
/// Number of bos descriptor bytes used
|
||||
pub bos_descriptor_used: usize,
|
||||
/// Number of msos descriptor bytes used
|
||||
///
|
||||
/// Will be `None` if the "msos-descriptor" feature is not active.
|
||||
/// Otherwise will return Some(bytes).
|
||||
pub msos_descriptor_used: Option<usize>,
|
||||
pub msos_descriptor_used: usize,
|
||||
/// Size of the control buffer
|
||||
pub control_buffer_size: usize,
|
||||
}
|
||||
@ -197,6 +194,7 @@ struct Inner<'d, D: Driver<'d>> {
|
||||
device_descriptor: &'d [u8],
|
||||
config_descriptor: &'d [u8],
|
||||
bos_descriptor: &'d [u8],
|
||||
msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
|
||||
|
||||
device_state: UsbDeviceState,
|
||||
suspended: bool,
|
||||
@ -212,9 +210,6 @@ struct Inner<'d, D: Driver<'d>> {
|
||||
|
||||
interfaces: Vec<Interface, MAX_INTERFACE_COUNT>,
|
||||
handlers: Vec<&'d mut dyn Handler, MAX_HANDLER_COUNT>,
|
||||
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
|
||||
}
|
||||
|
||||
impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
||||
@ -225,9 +220,9 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
||||
device_descriptor: &'d [u8],
|
||||
config_descriptor: &'d [u8],
|
||||
bos_descriptor: &'d [u8],
|
||||
msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
|
||||
interfaces: Vec<Interface, MAX_INTERFACE_COUNT>,
|
||||
control_buf: &'d mut [u8],
|
||||
#[cfg(feature = "msos-descriptor")] msos_descriptor: crate::msos::MsOsDescriptorSet<'d>,
|
||||
) -> UsbDevice<'d, D> {
|
||||
// Start the USB bus.
|
||||
// This prevent further allocation by consuming the driver.
|
||||
@ -242,6 +237,7 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
||||
device_descriptor,
|
||||
config_descriptor,
|
||||
bos_descriptor,
|
||||
msos_descriptor,
|
||||
|
||||
device_state: UsbDeviceState::Unpowered,
|
||||
suspended: false,
|
||||
@ -251,8 +247,6 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
||||
set_address_pending: false,
|
||||
interfaces,
|
||||
handlers,
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
msos_descriptor,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -261,16 +255,11 @@ impl<'d, D: Driver<'d>> UsbDevice<'d, D> {
|
||||
///
|
||||
/// Useful for tuning buffer sizes for actual usage
|
||||
pub fn buffer_usage(&self) -> UsbBufferReport {
|
||||
#[cfg(not(feature = "msos-descriptor"))]
|
||||
let mdu = None;
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
let mdu = Some(self.inner.msos_descriptor.len());
|
||||
|
||||
UsbBufferReport {
|
||||
device_descriptor_used: self.inner.device_descriptor.len(),
|
||||
config_descriptor_used: self.inner.config_descriptor.len(),
|
||||
bos_descriptor_used: self.inner.bos_descriptor.len(),
|
||||
msos_descriptor_used: mdu,
|
||||
msos_descriptor_used: self.inner.msos_descriptor.len(),
|
||||
control_buffer_size: self.control_buf.len(),
|
||||
}
|
||||
}
|
||||
@ -684,7 +673,7 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
|
||||
}
|
||||
_ => InResponse::Rejected,
|
||||
},
|
||||
#[cfg(feature = "msos-descriptor")]
|
||||
|
||||
(RequestType::Vendor, Recipient::Device) => {
|
||||
if !self.msos_descriptor.is_empty()
|
||||
&& req.request == self.msos_descriptor.vendor_code()
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![cfg(feature = "msos-descriptor")]
|
||||
|
||||
//! Microsoft OS Descriptors
|
||||
//!
|
||||
//! <https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-os-2-0-descriptors-specification>
|
||||
|
Reference in New Issue
Block a user