Author: janderwald
Date: Wed Oct 26 18:09:19 2016
New Revision: 73042
URL:
http://svn.reactos.org/svn/reactos?rev=73042&view=rev
Log:
[USBAUDIO]
- implement audio volume property handler
Modified:
trunk/reactos/drivers/usb/usbaudio/filter.c
trunk/reactos/drivers/usb/usbaudio/pin.c
trunk/reactos/drivers/usb/usbaudio/usbaudio.h
Modified: trunk/reactos/drivers/usb/usbaudio/filter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/filte…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/filter.c [iso-8859-1] Wed Oct 26 18:09:19 2016
@@ -157,7 +157,6 @@
/* submit urb */
Status = SubmitUrbSync(DeviceObject, Urb);
- DPRINT1("UsbAudioGetSetProperty Status %x\n", Status);
FreeFunction(Urb);
return Status;
}
@@ -215,12 +214,12 @@
FeatureUnitDescriptor =
(PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR)NodeContext->Descriptor;
if (Property->NodeProperty.Property.Flags & KSPROPERTY_TYPE_GET)
{
- Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x100,
FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_IN);
+ Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x1
<< 8, FeatureUnitDescriptor->bUnitID << 8, Data, 1,
USBD_TRANSFER_DIRECTION_IN);
Irp->IoStatus.Information = sizeof(BOOL);
}
else
{
- Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x100,
FeatureUnitDescriptor->bUnitID << 8, Data, 1, USBD_TRANSFER_DIRECTION_OUT);
+ Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x1
<< 8, FeatureUnitDescriptor->bUnitID << 8, Data, 1,
USBD_TRANSFER_DIRECTION_OUT);
}
}
}
@@ -234,8 +233,85 @@
IN PKSIDENTIFIER Request,
IN OUT PVOID Data)
{
- UNIMPLEMENTED
- return STATUS_SUCCESS;
+ PKSNODEPROPERTY_AUDIO_CHANNEL Property;
+ PKSFILTER Filter;
+ PFILTER_CONTEXT FilterContext;
+ PNODE_CONTEXT NodeContext;
+ PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR FeatureUnitDescriptor;
+ PSHORT TransferBuffer;
+ LONG Value;
+ NTSTATUS Status = STATUS_INVALID_PARAMETER;
+
+
+ /* get filter from irp */
+ Filter = KsGetFilterFromIrp(Irp);
+
+ if (Filter)
+ {
+ /* get property */
+ Property = (PKSNODEPROPERTY_AUDIO_CHANNEL)Request;
+
+ /* get filter context */
+ FilterContext = (PFILTER_CONTEXT)Filter->Context;
+
+ TransferBuffer = AllocFunction(sizeof(USHORT) * 3);
+ ASSERT(TransferBuffer);
+
+ Value = *(PLONG)Data;
+
+ /* search for node context */
+ NodeContext =
FindNodeContextWithNode(FilterContext->DeviceExtension->NodeContext,
FilterContext->DeviceExtension->NodeContextCount,
Property->NodeProperty.NodeId);
+ if (NodeContext)
+ {
+ FeatureUnitDescriptor =
(PUSB_AUDIO_CONTROL_FEATURE_UNIT_DESCRIPTOR)NodeContext->Descriptor;
+ if (Property->NodeProperty.Property.Flags & KSPROPERTY_TYPE_GET)
+ {
+ Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x81, 0x2
<< 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[0],
sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
+ Value = (LONG)TransferBuffer[0] * 256;
+
+ *(PLONG)Data = Value;
+ Irp->IoStatus.Information = sizeof(BOOL);
+ }
+ else
+ {
+ /* downscale value */
+ Value /= 256;
+
+ /* get minimum value */
+ UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice,
0x82, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8,
&TransferBuffer[0], sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
+
+ /* get maximum value */
+ UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice,
0x83, 0x2 << 8, FeatureUnitDescriptor->bUnitID << 8,
&TransferBuffer[1], sizeof(USHORT), USBD_TRANSFER_DIRECTION_IN);
+
+ if (TransferBuffer[0] > Value)
+ {
+ /* use minimum value */
+ Value = TransferBuffer[0];
+ }
+
+ if (TransferBuffer[1] < Value)
+ {
+ /* use maximum value */
+ Value = TransferBuffer[1];
+ }
+
+ /* store value */
+ TransferBuffer[2] = Value;
+
+ /* set volume request */
+ Status =
UsbAudioGetSetProperty(FilterContext->DeviceExtension->LowerDevice, 0x01, 0x2
<< 8, FeatureUnitDescriptor->bUnitID << 8, &TransferBuffer[2],
sizeof(USHORT), USBD_TRANSFER_DIRECTION_OUT);
+ if (NT_SUCCESS(Status))
+ {
+ /* store number of bytes transferred*/
+ Irp->IoStatus.Information = sizeof(LONG);
+ }
+ }
+ }
+
+ /* free transfer buffer */
+ FreeFunction(TransferBuffer);
+ }
+ return Status;
}
Modified: trunk/reactos/drivers/usb/usbaudio/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/pin.c…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/pin.c [iso-8859-1] Wed Oct 26 18:09:19 2016
@@ -88,61 +88,6 @@
*OutUrb = Urb;
return STATUS_SUCCESS;
-}
-
-NTSTATUS
-UsbAudioSetVolume(
- IN PKSPIN Pin)
-{
- PURB Urb;
- PUCHAR SampleRateBuffer;
- PPIN_CONTEXT PinContext;
- NTSTATUS Status;
-
- /* allocate sample rate buffer */
- SampleRateBuffer = AllocFunction(sizeof(ULONG));
- if (!SampleRateBuffer)
- {
- /* no memory */
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- /* allocate urb */
- Urb = AllocFunction(sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
- if (!Urb)
- {
- /* no memory */
- FreeFunction(SampleRateBuffer);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- /* FIXME: determine controls and format urb */
- UsbBuildVendorRequest(Urb,
- URB_FUNCTION_CLASS_INTERFACE,
- sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
- USBD_TRANSFER_DIRECTION_OUT,
- 0,
- 0x01,
- 0x200,
- 0x300,
- SampleRateBuffer,
- NULL,
- 2,
- NULL);
-
- /* get pin context */
- PinContext = Pin->Context;
-
- SampleRateBuffer[0] = 0xC2;
- SampleRateBuffer[1] = 0xFE;
-
- /* submit urb */
- Status = SubmitUrbSync(PinContext->LowerDevice, Urb);
-
- DPRINT1("UsbAudioSetVolume Pin %p Status %x\n", Pin, Status);
- FreeFunction(Urb);
- FreeFunction(SampleRateBuffer);
- return Status;
}
NTSTATUS
@@ -642,9 +587,6 @@
Status = _KsEdit(Pin->Bag,
(PVOID*)&Pin->Descriptor->AllocatorFraming, sizeof(KSALLOCATOR_FRAMING_EX),
sizeof(KSALLOCATOR_FRAMING_EX), USBAUDIO_TAG);
ASSERT(Status == STATUS_SUCCESS);
}
-
- /* FIXME move to build filter topology*/
- UsbAudioSetVolume(Pin);
/* select streaming interface */
Status = USBAudioSelectAudioStreamingInterface(PinContext,
PinContext->DeviceExtension,
PinContext->DeviceExtension->ConfigurationDescriptor);
Modified: trunk/reactos/drivers/usb/usbaudio/usbaudio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbaudio/usbau…
==============================================================================
--- trunk/reactos/drivers/usb/usbaudio/usbaudio.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbaudio/usbaudio.h [iso-8859-1] Wed Oct 26 18:09:19 2016
@@ -61,8 +61,6 @@
DEFINE_KSPROPERTY_TABLE(TopologySet) {\
DEFINE_KSPROPERTY_ITEM_AUDIO_MUTE(Handler)\
}
-
-
#include <pshpack1.h>