USB audio: cleanup and codestyle fixes.
* cleanup and codestyle fixes; * AudioFunction module contents purged out as unused.
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <[email protected]>
|
* Copyright (c) 2009-13 S.Zharski <[email protected]>
|
||||||
* Distributed under the tems of the MIT license.
|
* Distributed under the tems of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AudioControlInterface.h"
|
#include "AudioControlInterface.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "Device.h"
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
#include "Device.h"
|
||||||
|
#include "Driver.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
enum TerminalTypes {
|
enum TerminalTypes {
|
||||||
@@ -205,14 +207,12 @@ _AudioControl::~_AudioControl()
|
|||||||
AudioChannelCluster*
|
AudioChannelCluster*
|
||||||
_AudioControl::OutCluster()
|
_AudioControl::OutCluster()
|
||||||
{
|
{
|
||||||
if (SourceID() == 0 || fInterface == NULL) {
|
if (SourceID() == 0 || fInterface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
_AudioControl* control = fInterface->Find(SourceID());
|
_AudioControl* control = fInterface->Find(SourceID());
|
||||||
if (control == NULL) {
|
if (control == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return control->OutCluster();
|
return control->OutCluster();
|
||||||
}
|
}
|
||||||
@@ -224,13 +224,11 @@ AudioChannelCluster::AudioChannelCluster()
|
|||||||
fChannelsConfig(0),
|
fChannelsConfig(0),
|
||||||
fChannelNames(0)
|
fChannelNames(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioChannelCluster::~AudioChannelCluster()
|
AudioChannelCluster::~AudioChannelCluster()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -243,13 +241,11 @@ _Terminal::_Terminal(AudioControlInterface* interface,
|
|||||||
fClockSourceId(0),
|
fClockSourceId(0),
|
||||||
fControlsBitmap(0)
|
fControlsBitmap(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_Terminal::~_Terminal()
|
_Terminal::~_Terminal()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -450,10 +446,8 @@ SelectorUnit::SelectorUnit(AudioControlInterface* interface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fInterface->SpecReleaseNumber() < 0x200) {
|
if (fInterface->SpecReleaseNumber() < 0x200) {
|
||||||
|
|
||||||
fStringIndex = Selector->input_pins[Selector->num_input_pins];
|
fStringIndex = Selector->input_pins[Selector->num_input_pins];
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
fControlsBitmap = Selector->input_pins[Selector->num_input_pins];
|
fControlsBitmap = Selector->input_pins[Selector->num_input_pins];
|
||||||
fStringIndex = Selector->input_pins[Selector->num_input_pins + 1];
|
fStringIndex = Selector->input_pins[Selector->num_input_pins + 1];
|
||||||
|
|
||||||
@@ -474,20 +468,17 @@ SelectorUnit::~SelectorUnit()
|
|||||||
AudioChannelCluster*
|
AudioChannelCluster*
|
||||||
SelectorUnit::OutCluster()
|
SelectorUnit::OutCluster()
|
||||||
{
|
{
|
||||||
if (fInterface == NULL) {
|
if (fInterface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < fInputPins.Count(); i++) {
|
for (int i = 0; i < fInputPins.Count(); i++) {
|
||||||
_AudioControl* control = fInterface->Find(fInputPins[i]);
|
_AudioControl* control = fInterface->Find(fInputPins[i]);
|
||||||
if (control == NULL) {
|
if (control == NULL)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (control->OutCluster() != NULL) {
|
if (control->OutCluster() != NULL)
|
||||||
return control->OutCluster();
|
return control->OutCluster();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -555,7 +546,6 @@ FeatureUnit::Name()
|
|||||||
// first check if source of this FU is an input terminal
|
// first check if source of this FU is an input terminal
|
||||||
_AudioControl* control = fInterface->Find(fSourceID);
|
_AudioControl* control = fInterface->Find(fSourceID);
|
||||||
while (control != 0) {
|
while (control != 0) {
|
||||||
|
|
||||||
if (control->SubType() != IDSInputTerminal)
|
if (control->SubType() != IDSInputTerminal)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -570,7 +560,6 @@ FeatureUnit::Name()
|
|||||||
// check if output of this FU is connected to output terminal
|
// check if output of this FU is connected to output terminal
|
||||||
control = fInterface->FindOutputTerminal(fID);
|
control = fInterface->FindOutputTerminal(fID);
|
||||||
while (control != 0) {
|
while (control != 0) {
|
||||||
|
|
||||||
if (control->SubType() != IDSOutputTerminal)
|
if (control->SubType() != IDSOutputTerminal)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -640,9 +629,8 @@ FeatureUnit::NormalizeAndTraceChannel(int32 Channel)
|
|||||||
for (size_t i = 0; i < _countof(remapInfos); i++) {
|
for (size_t i = 0; i < _countof(remapInfos); i++) {
|
||||||
uint32 bits = isRev1 ? remapInfos[i].rev1Bits : remapInfos[i].rev2Bits;
|
uint32 bits = isRev1 ? remapInfos[i].rev1Bits : remapInfos[i].rev2Bits;
|
||||||
if ((fControlBitmaps[Channel] & bits) > 0) {
|
if ((fControlBitmaps[Channel] & bits) > 0) {
|
||||||
if (isRev1) {
|
if (isRev1)
|
||||||
remappedBitmap |= remapInfos[i].rev2Bits;
|
remappedBitmap |= remapInfos[i].rev2Bits;
|
||||||
}
|
|
||||||
TRACE("\t%s\n", remapInfos[i].name);
|
TRACE("\t%s\n", remapInfos[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,9 +871,8 @@ AudioControlInterface::AudioControlInterface(Device* device)
|
|||||||
AudioControlInterface::~AudioControlInterface()
|
AudioControlInterface::~AudioControlInterface()
|
||||||
{
|
{
|
||||||
for (AudioControlsIterator I = fAudioControls.Begin();
|
for (AudioControlsIterator I = fAudioControls.Begin();
|
||||||
I != fAudioControls.End(); I++) {
|
I != fAudioControls.End(); I++)
|
||||||
delete I->Value();
|
delete I->Value();
|
||||||
}
|
|
||||||
|
|
||||||
fAudioControls.MakeEmpty();
|
fAudioControls.MakeEmpty();
|
||||||
|
|
||||||
@@ -978,10 +965,9 @@ AudioControlInterface::Init(size_t interface, usb_interface_info *Interface)
|
|||||||
}
|
}
|
||||||
fAudioControls.Put(control->ID(), control);
|
fAudioControls.Put(control->ID(), control);
|
||||||
|
|
||||||
} else {
|
} else
|
||||||
delete control;
|
delete control;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return fStatus = B_OK;
|
return fStatus = B_OK;
|
||||||
}
|
}
|
||||||
@@ -1005,9 +991,8 @@ status_t
|
|||||||
AudioControlInterface::InitACHeader(size_t interface,
|
AudioControlInterface::InitACHeader(size_t interface,
|
||||||
usb_audiocontrol_header_descriptor* Header)
|
usb_audiocontrol_header_descriptor* Header)
|
||||||
{
|
{
|
||||||
if (Header == NULL) {
|
if (Header == NULL)
|
||||||
return fStatus = B_NO_INIT;
|
return fStatus = B_NO_INIT;
|
||||||
}
|
|
||||||
|
|
||||||
fInterface = interface;
|
fInterface = interface;
|
||||||
|
|
||||||
@@ -1036,9 +1021,8 @@ AudioControlInterface::InitACHeader(size_t interface,
|
|||||||
|
|
||||||
uint32
|
uint32
|
||||||
AudioControlInterface::GetChannelsDescription(
|
AudioControlInterface::GetChannelsDescription(
|
||||||
Vector<multi_channel_info>& Channels,
|
Vector<multi_channel_info>& Channels, multi_description* Description,
|
||||||
multi_description *Description,
|
Vector<_AudioControl*>&Terminals)
|
||||||
AudioControlsVector &Terminals)
|
|
||||||
{
|
{
|
||||||
uint32 addedChannels = 0;
|
uint32 addedChannels = 0;
|
||||||
// multi_channel_info* Channels = Description->channels;
|
// multi_channel_info* Channels = Description->channels;
|
||||||
@@ -1070,8 +1054,7 @@ AudioControlInterface::GetChannelsDescription(
|
|||||||
|
|
||||||
uint32
|
uint32
|
||||||
AudioControlInterface::GetTerminalChannels(Vector<multi_channel_info>& Channels,
|
AudioControlInterface::GetTerminalChannels(Vector<multi_channel_info>& Channels,
|
||||||
AudioChannelCluster* cluster, channel_kind kind,
|
AudioChannelCluster* cluster, channel_kind kind, uint32 connectors)
|
||||||
uint32 connectors)
|
|
||||||
{
|
{
|
||||||
if (cluster->ChannelsCount() < 2) { // mono channel
|
if (cluster->ChannelsCount() < 2) { // mono channel
|
||||||
multi_channel_info info;
|
multi_channel_info info;
|
||||||
@@ -1132,8 +1115,7 @@ AudioControlInterface::GetTerminalChannels(Vector<multi_channel_info>& Channels,
|
|||||||
|
|
||||||
uint32
|
uint32
|
||||||
AudioControlInterface::GetBusChannelsDescription(
|
AudioControlInterface::GetBusChannelsDescription(
|
||||||
Vector<multi_channel_info>& Channels,
|
Vector<multi_channel_info>& Channels, multi_description* Description)
|
||||||
multi_description *Description)
|
|
||||||
{
|
{
|
||||||
uint32 addedChannels = 0;
|
uint32 addedChannels = 0;
|
||||||
// multi_channel_info* Channels = Description->channels;
|
// multi_channel_info* Channels = Description->channels;
|
||||||
@@ -1141,7 +1123,6 @@ AudioControlInterface::GetBusChannelsDescription(
|
|||||||
// first iterate output channels
|
// first iterate output channels
|
||||||
for (AudioControlsIterator I = fOutputTerminals.Begin();
|
for (AudioControlsIterator I = fOutputTerminals.Begin();
|
||||||
I != fOutputTerminals.End(); I++) {
|
I != fOutputTerminals.End(); I++) {
|
||||||
|
|
||||||
_AudioControl* control = I->Value();
|
_AudioControl* control = I->Value();
|
||||||
if (static_cast<_Terminal*>(control)->IsUSBIO())
|
if (static_cast<_Terminal*>(control)->IsUSBIO())
|
||||||
continue;
|
continue;
|
||||||
@@ -1163,7 +1144,6 @@ AudioControlInterface::GetBusChannelsDescription(
|
|||||||
// output channels should follow too
|
// output channels should follow too
|
||||||
for (AudioControlsIterator I = fInputTerminals.Begin();
|
for (AudioControlsIterator I = fInputTerminals.Begin();
|
||||||
I != fInputTerminals.End(); I++) {
|
I != fInputTerminals.End(); I++) {
|
||||||
|
|
||||||
_AudioControl* control = I->Value();
|
_AudioControl* control = I->Value();
|
||||||
if (static_cast<_Terminal*>(control)->IsUSBIO())
|
if (static_cast<_Terminal*>(control)->IsUSBIO())
|
||||||
continue;
|
continue;
|
||||||
@@ -1203,9 +1183,8 @@ AudioControlInterface::_HarvestRecordFeatureUnits(_AudioControl* rootControl,
|
|||||||
case IDSSelectorUnit:
|
case IDSSelectorUnit:
|
||||||
{
|
{
|
||||||
SelectorUnit* unit = static_cast<SelectorUnit*>(rootControl);
|
SelectorUnit* unit = static_cast<SelectorUnit*>(rootControl);
|
||||||
for (int i = 0; i < unit->fInputPins.Count(); i++) {
|
for (int i = 0; i < unit->fInputPins.Count(); i++)
|
||||||
_HarvestRecordFeatureUnits(Find(unit->fInputPins[i]), Map);
|
_HarvestRecordFeatureUnits(Find(unit->fInputPins[i]), Map);
|
||||||
}
|
|
||||||
|
|
||||||
Map.Put(rootControl->ID(), rootControl);
|
Map.Put(rootControl->ID(), rootControl);
|
||||||
}
|
}
|
||||||
@@ -1253,16 +1232,14 @@ AudioControlInterface::_InitGainLimits(multi_mix_control& Control)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TRACE_ALWAYS("Control %s: from %f to %f dB, step %f dB.\n", Control.name,
|
TRACE_ALWAYS("Control %s: from %f to %f dB, step %f dB.\n", Control.name,
|
||||||
Control.gain.min_gain, Control.gain.max_gain,
|
Control.gain.min_gain, Control.gain.max_gain, Control.gain.granularity);
|
||||||
Control.gain.granularity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
||||||
int32& index, int32 parentIndex,
|
int32& index, int32 parentIndex, multi_mix_control_info* Info,
|
||||||
multi_mix_control_info* Info, FeatureUnit* unit,
|
FeatureUnit* unit, uint32 channel, uint32 channels)
|
||||||
uint32 channel, uint32 channels)
|
|
||||||
{
|
{
|
||||||
int32 startIndex = index;
|
int32 startIndex = index;
|
||||||
uint32 id = 0;
|
uint32 id = 0;
|
||||||
@@ -1296,8 +1273,8 @@ AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
|||||||
multi_mix_control* Controls = Info->controls;
|
multi_mix_control* Controls = Info->controls;
|
||||||
|
|
||||||
if (unit->HasControl(channel, controlType)) {
|
if (unit->HasControl(channel, controlType)) {
|
||||||
uint32 masterIndex
|
uint32 masterIndex = CTL_ID(id, channel, unit->ID(), fInterface);
|
||||||
= Controls[index].id = CTL_ID(id, channel, unit->ID(), fInterface);
|
Controls[index].id = masterIndex;
|
||||||
Controls[index].flags = flags;
|
Controls[index].flags = flags;
|
||||||
Controls[index].parent = parentIndex;
|
Controls[index].parent = parentIndex;
|
||||||
Controls[index].string = string;
|
Controls[index].string = string;
|
||||||
@@ -1309,15 +1286,13 @@ AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
|||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (channels == 2) {
|
if (channels == 2) {
|
||||||
Controls[index].id = CTL_ID(id, channel + 1,
|
Controls[index].id = CTL_ID(id, channel + 1, unit->ID(), fInterface);
|
||||||
unit->ID(), fInterface);
|
|
||||||
Controls[index].flags = flags;
|
Controls[index].flags = flags;
|
||||||
Controls[index].parent = parentIndex;
|
Controls[index].parent = parentIndex;
|
||||||
Controls[index].master = masterIndex;
|
Controls[index].master = masterIndex;
|
||||||
Controls[index].string = string;
|
Controls[index].string = string;
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
strlcpy(Controls[index].name, name,
|
strlcpy(Controls[index].name, name, sizeof(Controls[index].name));
|
||||||
sizeof(Controls[index].name));
|
|
||||||
if (initGainLimits)
|
if (initGainLimits)
|
||||||
_InitGainLimits(Controls[index]);
|
_InitGainLimits(Controls[index]);
|
||||||
index++;
|
index++;
|
||||||
@@ -1391,8 +1366,8 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (masterIndex == 0) {
|
if (masterIndex == 0) {
|
||||||
groupIndex
|
groupIndex = index;
|
||||||
= Controls[index].id = index;
|
Controls[index].id = groupIndex;
|
||||||
Controls[index].flags = B_MULTI_MIX_GROUP;
|
Controls[index].flags = B_MULTI_MIX_GROUP;
|
||||||
Controls[index].parent = parentIndex;
|
Controls[index].parent = parentIndex;
|
||||||
snprintf(Controls[index].name, sizeof(Controls[index].name),
|
snprintf(Controls[index].name, sizeof(Controls[index].name),
|
||||||
@@ -1409,8 +1384,7 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
|
|||||||
|
|
||||||
// Gain controls may be usefull too
|
// Gain controls may be usefull too
|
||||||
if (_ListFeatureUnitOption(VolumeControl, index, groupIndex, Info,
|
if (_ListFeatureUnitOption(VolumeControl, index, groupIndex, Info,
|
||||||
unit, channel, channelInfos[i].channels) == 0)
|
unit, channel, channelInfos[i].channels) == 0) {
|
||||||
{
|
|
||||||
masterIndex = (i == 0) ? groupIndex : 0 ;
|
masterIndex = (i == 0) ? groupIndex : 0 ;
|
||||||
TRACE("channel:%d set master index to %d\n", channel, masterIndex);
|
TRACE("channel:%d set master index to %d\n", channel, masterIndex);
|
||||||
}
|
}
|
||||||
@@ -1439,10 +1413,9 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelsConfig > 0) {
|
if (channelsConfig > 0)
|
||||||
TRACE_ALWAYS("Following channels were "
|
TRACE_ALWAYS("Following channels were not processed: %#08x.\n",
|
||||||
"not processed: %#08x.\n", channelsConfig);
|
channelsConfig);
|
||||||
}
|
|
||||||
|
|
||||||
// return last group index to stick possible selector unit to it. ;-)
|
// return last group index to stick possible selector unit to it. ;-)
|
||||||
return groupIndex;
|
return groupIndex;
|
||||||
@@ -1454,14 +1427,13 @@ AudioControlInterface::_ListSelectorUnitControl(int32& index, int32 parentGroup,
|
|||||||
multi_mix_control_info* Info, _AudioControl* control)
|
multi_mix_control_info* Info, _AudioControl* control)
|
||||||
{
|
{
|
||||||
SelectorUnit* selector = static_cast<SelectorUnit*>(control);
|
SelectorUnit* selector = static_cast<SelectorUnit*>(control);
|
||||||
if (selector == 0 || selector->SubType() != IDSSelectorUnit) {
|
if (selector == 0 || selector->SubType() != IDSSelectorUnit)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
multi_mix_control* Controls = Info->controls;
|
multi_mix_control* Controls = Info->controls;
|
||||||
|
|
||||||
int32 recordMUX
|
int32 recordMUX = CTL_ID(0, 0, selector->ID(), fInterface);
|
||||||
= Controls[index].id = CTL_ID(0, 0, selector->ID(), fInterface);
|
Controls[index].id = recordMUX;
|
||||||
Controls[index].flags = B_MULTI_MIX_MUX;
|
Controls[index].flags = B_MULTI_MIX_MUX;
|
||||||
Controls[index].parent = parentGroup;
|
Controls[index].parent = parentGroup;
|
||||||
Controls[index].string = S_null;
|
Controls[index].string = S_null;
|
||||||
@@ -1475,27 +1447,24 @@ AudioControlInterface::_ListSelectorUnitControl(int32& index, int32 parentGroup,
|
|||||||
Controls[index].string = S_null;
|
Controls[index].string = S_null;
|
||||||
Controls[index].parent = recordMUX;
|
Controls[index].parent = recordMUX;
|
||||||
_AudioControl* control = Find(selector->fInputPins[i]);
|
_AudioControl* control = Find(selector->fInputPins[i]);
|
||||||
if (control != NULL) {
|
if (control != NULL)
|
||||||
strlcpy(Controls[index].name,
|
strlcpy(Controls[index].name,
|
||||||
control->Name(), sizeof(Controls[index].name));
|
control->Name(), sizeof(Controls[index].name));
|
||||||
} else {
|
else
|
||||||
snprintf(Controls[index].name,
|
snprintf(Controls[index].name,
|
||||||
sizeof(Controls[index].name), "Input #%d", i + 1);
|
sizeof(Controls[index].name), "Input #%d", i + 1);
|
||||||
}
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioControlInterface::_ListMixControlsPage(int32& index,
|
AudioControlInterface::_ListMixControlsPage(int32& index,
|
||||||
multi_mix_control_info* Info,
|
multi_mix_control_info* Info, AudioControlsMap& Map, const char* Name)
|
||||||
AudioControlsMap& Map, const char* Name)
|
|
||||||
{
|
{
|
||||||
multi_mix_control* Controls = Info->controls;
|
multi_mix_control* Controls = Info->controls;
|
||||||
int32 groupIndex
|
int32 groupIndex = index | 0x10000;
|
||||||
= Controls[index].id = index | 0x10000;
|
Controls[index].id = groupIndex;
|
||||||
Controls[index].flags = B_MULTI_MIX_GROUP;
|
Controls[index].flags = B_MULTI_MIX_GROUP;
|
||||||
Controls[index].parent = 0;
|
Controls[index].parent = 0;
|
||||||
strlcpy(Controls[index].name, Name, sizeof(Controls[index].name));
|
strlcpy(Controls[index].name, Name, sizeof(Controls[index].name));
|
||||||
@@ -1524,51 +1493,42 @@ AudioControlInterface::ListMixControls(multi_mix_control_info* Info)
|
|||||||
AudioControlsMap RecordControlsMap;
|
AudioControlsMap RecordControlsMap;
|
||||||
|
|
||||||
for (AudioControlsIterator I = fOutputTerminals.Begin();
|
for (AudioControlsIterator I = fOutputTerminals.Begin();
|
||||||
I != fOutputTerminals.End(); I++)
|
I != fOutputTerminals.End(); I++) {
|
||||||
{
|
|
||||||
_Terminal* terminal = static_cast<_Terminal*>(I->Value());
|
_Terminal* terminal = static_cast<_Terminal*>(I->Value());
|
||||||
if (terminal->IsUSBIO()) {
|
if (terminal->IsUSBIO())
|
||||||
_HarvestRecordFeatureUnits(terminal, RecordControlsMap);
|
_HarvestRecordFeatureUnits(terminal, RecordControlsMap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
AudioControlsMap InputControlsMap;
|
AudioControlsMap InputControlsMap;
|
||||||
AudioControlsMap OutputControlsMap;
|
AudioControlsMap OutputControlsMap;
|
||||||
|
|
||||||
for (AudioControlsIterator I = fAudioControls.Begin();
|
for (AudioControlsIterator I = fAudioControls.Begin();
|
||||||
I != fAudioControls.End(); I++)
|
I != fAudioControls.End(); I++) {
|
||||||
{
|
|
||||||
_AudioControl* control = I->Value();
|
_AudioControl* control = I->Value();
|
||||||
// filter out feature units
|
// filter out feature units
|
||||||
if (control->SubType() != IDSFeatureUnit) {
|
if (control->SubType() != IDSFeatureUnit)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
// ignore controls that are already in the record controls map
|
// ignore controls that are already in the record controls map
|
||||||
if (RecordControlsMap.Find(control->ID()) != RecordControlsMap.End()) {
|
if (RecordControlsMap.Find(control->ID()) != RecordControlsMap.End())
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
_AudioControl* sourceControl = Find(control->SourceID());
|
_AudioControl* sourceControl = Find(control->SourceID());
|
||||||
if (sourceControl != 0 && sourceControl->SubType() == IDSInputTerminal) {
|
if (sourceControl != 0 && sourceControl->SubType() == IDSInputTerminal)
|
||||||
InputControlsMap.Put(control->ID(), control);
|
InputControlsMap.Put(control->ID(), control);
|
||||||
} else {
|
else
|
||||||
OutputControlsMap.Put(control->ID(), control);
|
OutputControlsMap.Put(control->ID(), control);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
if (InputControlsMap.Count() > 0) {
|
if (InputControlsMap.Count() > 0)
|
||||||
_ListMixControlsPage(index, Info, InputControlsMap, "Input");
|
_ListMixControlsPage(index, Info, InputControlsMap, "Input");
|
||||||
}
|
|
||||||
|
|
||||||
if (OutputControlsMap.Count() > 0) {
|
if (OutputControlsMap.Count() > 0)
|
||||||
_ListMixControlsPage(index, Info, OutputControlsMap, "Output");
|
_ListMixControlsPage(index, Info, OutputControlsMap, "Output");
|
||||||
}
|
|
||||||
|
|
||||||
if (RecordControlsMap.Count() > 0) {
|
if (RecordControlsMap.Count() > 0)
|
||||||
_ListMixControlsPage(index, Info, RecordControlsMap, "Record");
|
_ListMixControlsPage(index, Info, RecordControlsMap, "Record");
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -1578,7 +1538,6 @@ status_t
|
|||||||
AudioControlInterface::GetMix(multi_mix_value_info* Info)
|
AudioControlInterface::GetMix(multi_mix_value_info* Info)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < Info->item_count; i++) {
|
for (int32 i = 0; i < Info->item_count; i++) {
|
||||||
|
|
||||||
uint16 length = 0;
|
uint16 length = 0;
|
||||||
int16 data = 0;
|
int16 data = 0;
|
||||||
switch(CS_FROM_CTLID(Info->values[i].id)) {
|
switch(CS_FROM_CTLID(Info->values[i].id)) {
|
||||||
@@ -1649,7 +1608,6 @@ status_t
|
|||||||
AudioControlInterface::SetMix(multi_mix_value_info* Info)
|
AudioControlInterface::SetMix(multi_mix_value_info* Info)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < Info->item_count; i++) {
|
for (int32 i = 0; i < Info->item_count; i++) {
|
||||||
|
|
||||||
uint16 length = 0;
|
uint16 length = 0;
|
||||||
int16 data = 0;
|
int16 data = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8,14 +8,20 @@
|
|||||||
#define _AUDIO_CONTROL_INTERFACE_H_
|
#define _AUDIO_CONTROL_INTERFACE_H_
|
||||||
|
|
||||||
|
|
||||||
#include <util/VectorMap.h>
|
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
#include "USB_audio_spec.h"
|
#include "USB_audio_spec.h"
|
||||||
|
#include <hmulti_audio.h>
|
||||||
|
|
||||||
|
#include <util/VectorMap.h>
|
||||||
|
#include <USB3.h>
|
||||||
|
|
||||||
|
|
||||||
|
class Device;
|
||||||
class AudioControlInterface;
|
class AudioControlInterface;
|
||||||
|
|
||||||
|
class _AudioControl;
|
||||||
|
typedef VectorMap<uint32, _AudioControl*> AudioControlsMap;
|
||||||
|
typedef VectorMap<uint32, _AudioControl*>::Iterator AudioControlsIterator;
|
||||||
|
|
||||||
|
|
||||||
class AudioChannelCluster {
|
class AudioChannelCluster {
|
||||||
public:
|
public:
|
||||||
@@ -33,8 +39,8 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
template<class __base_class_name>
|
template<class __base_class_name>
|
||||||
class _AudioChannelCluster
|
class _AudioChannelCluster : public __base_class_name,
|
||||||
: public __base_class_name, public AudioChannelCluster {
|
public AudioChannelCluster {
|
||||||
public:
|
public:
|
||||||
_AudioChannelCluster(AudioControlInterface* interface,
|
_AudioChannelCluster(AudioControlInterface* interface,
|
||||||
usb_audiocontrol_header_descriptor* Header)
|
usb_audiocontrol_header_descriptor* Header)
|
||||||
@@ -44,14 +50,9 @@ public:
|
|||||||
|
|
||||||
virtual AudioChannelCluster*
|
virtual AudioChannelCluster*
|
||||||
OutCluster() { return this; }
|
OutCluster() { return this; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// base class for Audio Controls (Units and Terminals)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
class _AudioControl {
|
class _AudioControl {
|
||||||
public:
|
public:
|
||||||
_AudioControl(AudioControlInterface* interface,
|
_AudioControl(AudioControlInterface* interface,
|
||||||
@@ -62,11 +63,13 @@ public:
|
|||||||
uint8 SourceID() { return fSourceID; }
|
uint8 SourceID() { return fSourceID; }
|
||||||
uint8 SubType() { return fSubType; }
|
uint8 SubType() { return fSubType; }
|
||||||
status_t InitCheck() { return fStatus; };
|
status_t InitCheck() { return fStatus; };
|
||||||
|
|
||||||
virtual const char* Name() { return ""; }
|
virtual const char* Name() { return ""; }
|
||||||
virtual AudioChannelCluster* OutCluster();
|
|
||||||
|
virtual AudioChannelCluster*
|
||||||
|
OutCluster();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// state tracking
|
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
AudioControlInterface* fInterface;
|
AudioControlInterface* fInterface;
|
||||||
uint8 fSubType;
|
uint8 fSubType;
|
||||||
@@ -76,7 +79,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _Terminal : public _AudioControl {
|
class _Terminal : public _AudioControl {
|
||||||
public:
|
public:
|
||||||
_Terminal(AudioControlInterface* interface,
|
_Terminal(AudioControlInterface* interface,
|
||||||
@@ -94,6 +96,7 @@ protected:
|
|||||||
uint16 fControlsBitmap;
|
uint16 fControlsBitmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class InputTerminal : public _AudioChannelCluster<_Terminal> {
|
class InputTerminal : public _AudioChannelCluster<_Terminal> {
|
||||||
public:
|
public:
|
||||||
InputTerminal(AudioControlInterface* interface,
|
InputTerminal(AudioControlInterface* interface,
|
||||||
@@ -133,7 +136,9 @@ public:
|
|||||||
usb_audiocontrol_header_descriptor* Header);
|
usb_audiocontrol_header_descriptor* Header);
|
||||||
virtual ~SelectorUnit();
|
virtual ~SelectorUnit();
|
||||||
|
|
||||||
virtual AudioChannelCluster* OutCluster();
|
virtual AudioChannelCluster*
|
||||||
|
OutCluster();
|
||||||
|
|
||||||
// protected:
|
// protected:
|
||||||
Vector<uint8> fInputPins;
|
Vector<uint8> fInputPins;
|
||||||
uint8 fControlsBitmap;
|
uint8 fControlsBitmap;
|
||||||
@@ -156,7 +161,7 @@ virtual const char* Name();
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class EffectUnit : public _AudioControl/*, public _AudioChannelsCluster*/ {
|
class EffectUnit : public _AudioControl {
|
||||||
public:
|
public:
|
||||||
EffectUnit(AudioControlInterface* interface,
|
EffectUnit(AudioControlInterface* interface,
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
usb_audiocontrol_header_descriptor* Header);
|
||||||
@@ -238,14 +243,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef VectorMap<uint32, _AudioControl*> AudioControlsMap;
|
|
||||||
typedef VectorMap<uint32, _AudioControl*>::Iterator AudioControlsIterator;
|
|
||||||
|
|
||||||
typedef Vector<_AudioControl*> AudioControlsVector;
|
|
||||||
// typedef Vector<_AudioControl*>::Iterator AudioControlsIterator;
|
|
||||||
|
|
||||||
class Device;
|
|
||||||
|
|
||||||
class AudioControlInterface {
|
class AudioControlInterface {
|
||||||
public:
|
public:
|
||||||
AudioControlInterface(Device* device);
|
AudioControlInterface(Device* device);
|
||||||
@@ -258,12 +255,13 @@ public:
|
|||||||
_AudioControl* FindOutputTerminal(uint8 id);
|
_AudioControl* FindOutputTerminal(uint8 id);
|
||||||
uint16 SpecReleaseNumber() { return fADCSpecification; }
|
uint16 SpecReleaseNumber() { return fADCSpecification; }
|
||||||
|
|
||||||
AudioControlsMap& Controls() { return fAudioControls; }
|
AudioControlsMap&
|
||||||
|
Controls() { return fAudioControls; }
|
||||||
|
|
||||||
uint32 GetChannelsDescription(
|
uint32 GetChannelsDescription(
|
||||||
Vector<multi_channel_info>& Channels,
|
Vector<multi_channel_info>& Channels,
|
||||||
multi_description* Description,
|
multi_description* Description,
|
||||||
AudioControlsVector &USBTerminals);
|
Vector<_AudioControl*>& USBTerminals);
|
||||||
uint32 GetBusChannelsDescription(
|
uint32 GetBusChannelsDescription(
|
||||||
Vector<multi_channel_info>& Channels,
|
Vector<multi_channel_info>& Channels,
|
||||||
multi_description* Description);
|
multi_description* Description);
|
||||||
@@ -293,8 +291,8 @@ protected:
|
|||||||
int32& index, int32 parentIndex,
|
int32& index, int32 parentIndex,
|
||||||
multi_mix_control_info* Info, FeatureUnit* unit,
|
multi_mix_control_info* Info, FeatureUnit* unit,
|
||||||
uint32 channel, uint32 channels);
|
uint32 channel, uint32 channels);
|
||||||
void _ListSelectorUnitControl(int32& index, int32 parentGroup,
|
void _ListSelectorUnitControl(int32& index,
|
||||||
multi_mix_control_info* Info,
|
int32 parentGroup, multi_mix_control_info* Info,
|
||||||
_AudioControl* control);
|
_AudioControl* control);
|
||||||
void _InitGainLimits(multi_mix_control& Control);
|
void _InitGainLimits(multi_mix_control& Control);
|
||||||
|
|
||||||
@@ -315,5 +313,6 @@ protected:
|
|||||||
AudioControlsMap fInputTerminals;
|
AudioControlsMap fInputTerminals;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // _AUDIO_CONTROL_INTERFACE_H_
|
#endif // _AUDIO_CONTROL_INTERFACE_H_
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,349 +0,0 @@
|
|||||||
/*
|
|
||||||
* Driver for USB Audio Device Class devices.
|
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef _AUDIO_FUNCTION_H_
|
|
||||||
#define _AUDIO_FUNCTION_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <VectorMap.h>
|
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
#include "USB_audio_spec.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Device;
|
|
||||||
|
|
||||||
//
|
|
||||||
// base class for all entities in Audio Function
|
|
||||||
//
|
|
||||||
//
|
|
||||||
class _AudioFunctionEntity {
|
|
||||||
public:
|
|
||||||
_AudioFunctionEntity(Device* device, size_t interface);
|
|
||||||
~_AudioFunctionEntity();
|
|
||||||
|
|
||||||
status_t InitCheck() { return fStatus; };
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// state tracking
|
|
||||||
status_t fStatus;
|
|
||||||
Device* fDevice;
|
|
||||||
size_t fInterface;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class _AudioChannelsCluster {
|
|
||||||
public:
|
|
||||||
_AudioChannelsCluster();
|
|
||||||
virtual ~_AudioChannelsCluster();
|
|
||||||
|
|
||||||
virtual _AudioChannelsCluster* OutputCluster();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint8 fOutChannelsNumber;
|
|
||||||
uint32 fChannelsConfig;
|
|
||||||
uint8 fChannelNames;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// base class for Audio Controls (Units and Terminals)
|
|
||||||
//
|
|
||||||
//
|
|
||||||
class _AudioControl : public _AudioFunctionEntity {
|
|
||||||
public:
|
|
||||||
_AudioControl(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~_AudioControl();
|
|
||||||
|
|
||||||
uint8 ID() { return fID; }
|
|
||||||
uint8 SourceID() { return fSourceID; }
|
|
||||||
uint8 SubType() { return fSubType; }
|
|
||||||
virtual const char* Name() { return ""; }
|
|
||||||
virtual _AudioChannelsCluster* OutputCluster();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// state tracking
|
|
||||||
uint8 fSubType;
|
|
||||||
uint8 fID;
|
|
||||||
uint8 fSourceID;
|
|
||||||
uint8 fStringIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AudioControlHeader : public _AudioControl {
|
|
||||||
public:
|
|
||||||
AudioControlHeader(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~AudioControlHeader();
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
uint16 fADCSpecification;
|
|
||||||
Vector<uint8> fStreams;
|
|
||||||
uint8 fFunctionCategory;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class _Terminal : public _AudioControl {
|
|
||||||
public:
|
|
||||||
_Terminal(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~_Terminal();
|
|
||||||
|
|
||||||
uint16 TerminalType() { return fTerminalType; }
|
|
||||||
bool IsUSBIO();
|
|
||||||
virtual const char* Name();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint16 fTerminalType;
|
|
||||||
uint8 fAssociatedTerminal;
|
|
||||||
uint8 fClockSourceId;
|
|
||||||
uint16 fControlsBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class InputTerminal : public _Terminal, public _AudioChannelsCluster {
|
|
||||||
public:
|
|
||||||
InputTerminal(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~InputTerminal();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OutputTerminal : public _Terminal {
|
|
||||||
public:
|
|
||||||
OutputTerminal(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~OutputTerminal();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class MixerUnit : public _AudioControl, public _AudioChannelsCluster {
|
|
||||||
public:
|
|
||||||
MixerUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~MixerUnit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Vector<uint8> fInputPins;
|
|
||||||
Vector<uint8> fProgrammableControls;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class SelectorUnit : public _AudioControl {
|
|
||||||
public:
|
|
||||||
SelectorUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~SelectorUnit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Vector<uint8> fInputPins;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class FeatureUnit : public _AudioControl {
|
|
||||||
public:
|
|
||||||
FeatureUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~FeatureUnit();
|
|
||||||
|
|
||||||
virtual const char* Name();
|
|
||||||
bool HasControl(int32 Channel, uint32 Control);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void TraceChannel(Device* device, int32 Channel);
|
|
||||||
|
|
||||||
Vector<uint32> fControlBitmaps;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class EffectUnit : public _AudioControl/*, public _AudioChannelsCluster*/ {
|
|
||||||
public:
|
|
||||||
EffectUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~EffectUnit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/* uint16 fProcessType;
|
|
||||||
Vector<uint8> fInputPins;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
Vector<uint16> fModes;
|
|
||||||
*/};
|
|
||||||
|
|
||||||
|
|
||||||
class ProcessingUnit : public _AudioControl, public _AudioChannelsCluster {
|
|
||||||
public:
|
|
||||||
ProcessingUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~ProcessingUnit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint16 fProcessType;
|
|
||||||
Vector<uint8> fInputPins;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
Vector<uint16> fModes;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ExtensionUnit : public _AudioControl, public _AudioChannelsCluster {
|
|
||||||
public:
|
|
||||||
ExtensionUnit(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~ExtensionUnit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint16 fExtensionCode;
|
|
||||||
Vector<uint8> fInputPins;
|
|
||||||
uint8 fControlsBitmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ClockSource : public _AudioControl {
|
|
||||||
public:
|
|
||||||
ClockSource(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~ClockSource();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ClockSelector : public _AudioControl {
|
|
||||||
public:
|
|
||||||
ClockSelector(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~ClockSelector();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ClockMultiplier : public _AudioControl {
|
|
||||||
public:
|
|
||||||
ClockMultiplier(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~ClockMultiplier();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class SampleRateConverter : public _AudioControl {
|
|
||||||
public:
|
|
||||||
SampleRateConverter(Device* device, size_t interface,
|
|
||||||
usb_audiocontrol_header_descriptor* Header);
|
|
||||||
virtual ~SampleRateConverter();
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Audio Streaming Interface information entities
|
|
||||||
//
|
|
||||||
//
|
|
||||||
class ASInterfaceDescriptor : public _AudioFunctionEntity {
|
|
||||||
public:
|
|
||||||
ASInterfaceDescriptor(Device* device, size_t interface,
|
|
||||||
usb_as_interface_descriptor_r1* Descriptor);
|
|
||||||
~ASInterfaceDescriptor();
|
|
||||||
// protected:
|
|
||||||
uint8 fTerminalLink;
|
|
||||||
uint8 fDelay;
|
|
||||||
uint16 fFormatTag;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ASEndpointDescriptor : public _AudioFunctionEntity {
|
|
||||||
public:
|
|
||||||
ASEndpointDescriptor(Device* device, size_t interface,
|
|
||||||
usb_as_cs_endpoint_descriptor* Descriptor);
|
|
||||||
~ASEndpointDescriptor();
|
|
||||||
// protected:
|
|
||||||
uint8 fAttributes;
|
|
||||||
uint8 fLockDelayUnits;
|
|
||||||
uint16 fLockDelay;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class _ASFormatDescriptor : public _AudioFunctionEntity {
|
|
||||||
public:
|
|
||||||
_ASFormatDescriptor(Device* device, size_t interface);
|
|
||||||
virtual ~_ASFormatDescriptor();
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
uint32 GetSamFreq(uint8* freq);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TypeIFormatDescriptor : public _ASFormatDescriptor {
|
|
||||||
public:
|
|
||||||
TypeIFormatDescriptor(Device* device, size_t interface,
|
|
||||||
usb_type_I_format_descriptor* Descriptor);
|
|
||||||
virtual ~TypeIFormatDescriptor();
|
|
||||||
|
|
||||||
status_t Init(usb_type_I_format_descriptor* Descriptor);
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
uint8 fNumChannels;
|
|
||||||
uint8 fSubframeSize;
|
|
||||||
uint8 fBitResolution;
|
|
||||||
uint8 fSampleFrequencyType;
|
|
||||||
Vector<uint32> fSampleFrequencies;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TypeIIFormatDescriptor : public _ASFormatDescriptor {
|
|
||||||
public:
|
|
||||||
TypeIIFormatDescriptor(Device* device, size_t interface,
|
|
||||||
usb_type_II_format_descriptor* Descriptor);
|
|
||||||
virtual ~TypeIIFormatDescriptor();
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
uint16 fMaxBitRate;
|
|
||||||
uint16 fSamplesPerFrame;
|
|
||||||
uint8 fSampleFrequencyType;
|
|
||||||
Vector<uint32> fSampleFrequencies;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TypeIIIFormatDescriptor : public TypeIFormatDescriptor {
|
|
||||||
public:
|
|
||||||
TypeIIIFormatDescriptor(Device* device, size_t interface,
|
|
||||||
usb_type_III_format_descriptor* Descriptor);
|
|
||||||
virtual ~TypeIIIFormatDescriptor();
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AudioStreamAlternate {
|
|
||||||
public:
|
|
||||||
AudioStreamAlternate(size_t alternate,
|
|
||||||
ASInterfaceDescriptor* interface,
|
|
||||||
ASEndpointDescriptor* endpoint,
|
|
||||||
_ASFormatDescriptor* format);
|
|
||||||
~AudioStreamAlternate();
|
|
||||||
|
|
||||||
ASInterfaceDescriptor* Interface() { return fInterface; }
|
|
||||||
ASEndpointDescriptor* Endpoint() { return fEndpoint; }
|
|
||||||
_ASFormatDescriptor* Format() { return fFormat; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
size_t fAlternate;
|
|
||||||
ASInterfaceDescriptor* fInterface;
|
|
||||||
ASEndpointDescriptor* fEndpoint;
|
|
||||||
_ASFormatDescriptor* fFormat;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _AUDIO_FUNCTION_H_
|
|
||||||
|
|
||||||
@@ -5,10 +5,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "AudioStreamingInterface.h"
|
#include "AudioStreamingInterface.h"
|
||||||
#include "Settings.h"
|
|
||||||
#include "Device.h"
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
#include "Driver.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
static struct RatePair {
|
static struct RatePair {
|
||||||
@@ -38,10 +41,9 @@ static struct RatePair {
|
|||||||
// Audio Stream information entities
|
// Audio Stream information entities
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
ASInterfaceDescriptor::ASInterfaceDescriptor(/*Device* device, size_t interface,*/
|
ASInterfaceDescriptor::ASInterfaceDescriptor(
|
||||||
usb_as_interface_descriptor_r1* Descriptor)
|
usb_as_interface_descriptor_r1* Descriptor)
|
||||||
:
|
:
|
||||||
// _AudioFunctionEntity(device, interface),
|
|
||||||
fTerminalLink(0),
|
fTerminalLink(0),
|
||||||
fDelay(0),
|
fDelay(0),
|
||||||
fFormatTag(0)
|
fFormatTag(0)
|
||||||
@@ -60,7 +62,6 @@ ASInterfaceDescriptor::ASInterfaceDescriptor(/*Device* device, size_t interface,
|
|||||||
|
|
||||||
ASInterfaceDescriptor::~ASInterfaceDescriptor()
|
ASInterfaceDescriptor::~ASInterfaceDescriptor()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,9 +101,9 @@ ASEndpointDescriptor::~ASEndpointDescriptor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_ASFormatDescriptor::_ASFormatDescriptor(usb_type_I_format_descriptor* Descriptor)
|
_ASFormatDescriptor::_ASFormatDescriptor(
|
||||||
|
usb_type_I_format_descriptor* Descriptor)
|
||||||
:
|
:
|
||||||
/*_AudioFunctionEntity(device, interface)*/
|
|
||||||
fFormatType(UAF_FORMAT_TYPE_UNDEFINED)
|
fFormatType(UAF_FORMAT_TYPE_UNDEFINED)
|
||||||
{
|
{
|
||||||
fFormatType = Descriptor->format_type;
|
fFormatType = Descriptor->format_type;
|
||||||
@@ -121,7 +122,7 @@ _ASFormatDescriptor::GetSamFreq(uint8* freq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TypeIFormatDescriptor::TypeIFormatDescriptor(/*Device* device, size_t interface,*/
|
TypeIFormatDescriptor::TypeIFormatDescriptor(
|
||||||
usb_type_I_format_descriptor* Descriptor)
|
usb_type_I_format_descriptor* Descriptor)
|
||||||
:
|
:
|
||||||
_ASFormatDescriptor(Descriptor),
|
_ASFormatDescriptor(Descriptor),
|
||||||
@@ -152,27 +153,24 @@ TypeIFormatDescriptor::Init(usb_type_I_format_descriptor* Descriptor)
|
|||||||
GetSamFreq(Descriptor->sf.cont.lower_sam_freq));
|
GetSamFreq(Descriptor->sf.cont.lower_sam_freq));
|
||||||
fSampleFrequencies.PushBack(
|
fSampleFrequencies.PushBack(
|
||||||
GetSamFreq(Descriptor->sf.cont.upper_sam_freq));
|
GetSamFreq(Descriptor->sf.cont.upper_sam_freq));
|
||||||
} else {
|
} else
|
||||||
for (size_t i = 0; i < fSampleFrequencyType; i++) {
|
for (size_t i = 0; i < fSampleFrequencyType; i++)
|
||||||
fSampleFrequencies.PushBack(
|
fSampleFrequencies.PushBack(
|
||||||
GetSamFreq(Descriptor->sf.discr.sam_freq[i]));
|
GetSamFreq(Descriptor->sf.discr.sam_freq[i]));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("fNumChannels:%d\n", fNumChannels);
|
TRACE("fNumChannels:%d\n", fNumChannels);
|
||||||
TRACE("fSubframeSize:%d\n", fSubframeSize);
|
TRACE("fSubframeSize:%d\n", fSubframeSize);
|
||||||
TRACE("fBitResolution:%d\n", fBitResolution);
|
TRACE("fBitResolution:%d\n", fBitResolution);
|
||||||
TRACE("fSampleFrequencyType:%d\n", fSampleFrequencyType);
|
TRACE("fSampleFrequencyType:%d\n", fSampleFrequencyType);
|
||||||
|
|
||||||
for (int32 i = 0; i < fSampleFrequencies.Count(); i++) {
|
for (int32 i = 0; i < fSampleFrequencies.Count(); i++)
|
||||||
TRACE("Frequency #%d: %d\n", i, fSampleFrequencies[i]);
|
TRACE("Frequency #%d: %d\n", i, fSampleFrequencies[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TypeIIFormatDescriptor::TypeIIFormatDescriptor(/*Device* device, size_t interface,*/
|
TypeIIFormatDescriptor::TypeIIFormatDescriptor(
|
||||||
usb_type_II_format_descriptor* Descriptor)
|
usb_type_II_format_descriptor* Descriptor)
|
||||||
:
|
:
|
||||||
_ASFormatDescriptor((usb_type_I_format_descriptor*)Descriptor),
|
_ASFormatDescriptor((usb_type_I_format_descriptor*)Descriptor),
|
||||||
@@ -189,13 +187,11 @@ TypeIIFormatDescriptor::~TypeIIFormatDescriptor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TypeIIIFormatDescriptor::TypeIIIFormatDescriptor(/*Device* device, size_t interface,*/
|
TypeIIIFormatDescriptor::TypeIIIFormatDescriptor(
|
||||||
usb_type_III_format_descriptor* Descriptor)
|
usb_type_III_format_descriptor* Descriptor)
|
||||||
:
|
:
|
||||||
TypeIFormatDescriptor(/*device, interface, */
|
TypeIFormatDescriptor((usb_type_I_format_descriptor*)Descriptor)
|
||||||
(usb_type_I_format_descriptor*) Descriptor)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -205,8 +201,7 @@ TypeIIIFormatDescriptor::~TypeIIIFormatDescriptor()
|
|||||||
|
|
||||||
|
|
||||||
AudioStreamAlternate::AudioStreamAlternate(size_t alternate,
|
AudioStreamAlternate::AudioStreamAlternate(size_t alternate,
|
||||||
ASInterfaceDescriptor* interface,
|
ASInterfaceDescriptor* interface, ASEndpointDescriptor* endpoint,
|
||||||
ASEndpointDescriptor* endpoint,
|
|
||||||
_ASFormatDescriptor* format)
|
_ASFormatDescriptor* format)
|
||||||
:
|
:
|
||||||
fAlternate(alternate),
|
fAlternate(alternate),
|
||||||
@@ -215,7 +210,6 @@ AudioStreamAlternate::AudioStreamAlternate(size_t alternate,
|
|||||||
fFormat(format),
|
fFormat(format),
|
||||||
fSamplingRate(0)
|
fSamplingRate(0)
|
||||||
{
|
{
|
||||||
// SetSamplingRate(0); // init to default (max) sampling rate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,7 +263,6 @@ AudioStreamAlternate::SetSamplingRate(uint32 newRate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newRate = fSamplingRate;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,18 +407,17 @@ AudioStreamingInterface::AudioStreamingInterface(
|
|||||||
if (Header->descriptor_type == AC_CS_INTERFACE) {
|
if (Header->descriptor_type == AC_CS_INTERFACE) {
|
||||||
switch(Header->descriptor_subtype) {
|
switch(Header->descriptor_subtype) {
|
||||||
case UAS_AS_GENERAL:
|
case UAS_AS_GENERAL:
|
||||||
if (ASInterface == 0) {
|
if (ASInterface == 0)
|
||||||
ASInterface = new ASInterfaceDescriptor(
|
ASInterface = new ASInterfaceDescriptor(
|
||||||
/*this, interface, */
|
|
||||||
(usb_as_interface_descriptor_r1*) Header);
|
(usb_as_interface_descriptor_r1*) Header);
|
||||||
} else
|
else
|
||||||
TRACE_ALWAYS("Duplicate AStream interface ignored.\n");
|
TRACE_ALWAYS("Duplicate AStream interface ignored.\n");
|
||||||
break;
|
break;
|
||||||
case UAS_FORMAT_TYPE:
|
case UAS_FORMAT_TYPE:
|
||||||
if (ASFormat == 0) {
|
if (ASFormat == 0)
|
||||||
ASFormat = new TypeIFormatDescriptor(
|
ASFormat = new TypeIFormatDescriptor(
|
||||||
(usb_type_I_format_descriptor*) Header);
|
(usb_type_I_format_descriptor*) Header);
|
||||||
} else
|
else
|
||||||
TRACE_ALWAYS("Duplicate AStream format ignored.\n");
|
TRACE_ALWAYS("Duplicate AStream format ignored.\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -459,14 +451,11 @@ AudioStreamingInterface::AudioStreamingInterface(
|
|||||||
|
|
||||||
AudioStreamingInterface::~AudioStreamingInterface()
|
AudioStreamingInterface::~AudioStreamingInterface()
|
||||||
{
|
{
|
||||||
// alternates of the streams
|
|
||||||
// StreamAlternatesVector fAlternates;
|
|
||||||
// size_t fActiveAlternate;
|
|
||||||
// we own stream header objects too, so free them
|
// we own stream header objects too, so free them
|
||||||
for (StreamAlternatesIterator I = fAlternates.Begin();
|
for (Vector<AudioStreamAlternate*>::Iterator I = fAlternates.Begin();
|
||||||
I != fAlternates.End(); I++) {
|
I != fAlternates.End(); I++)
|
||||||
delete *I;
|
delete *I;
|
||||||
}
|
|
||||||
fAlternates.MakeEmpty();
|
fAlternates.MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,10 +463,8 @@ AudioStreamingInterface::~AudioStreamingInterface()
|
|||||||
uint8
|
uint8
|
||||||
AudioStreamingInterface::TerminalLink()
|
AudioStreamingInterface::TerminalLink()
|
||||||
{
|
{
|
||||||
if (fAlternates[fActiveAlternate]->Interface() != 0) {
|
if (fAlternates[fActiveAlternate]->Interface() != 0)
|
||||||
return fAlternates[fActiveAlternate]->Interface()->fTerminalLink;
|
return fAlternates[fActiveAlternate]->Interface()->fTerminalLink;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,71 +483,12 @@ AudioStreamingInterface::ChannelCluster()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ASInterfaceDescriptor*
|
|
||||||
Stream::ASInterface()
|
|
||||||
{
|
|
||||||
return fAlternates[fActiveAlternate]->Interface();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_ASFormatDescriptor*
|
|
||||||
Stream::ASFormat()
|
|
||||||
{
|
|
||||||
return fAlternates[fActiveAlternate]->Format();
|
|
||||||
} */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioStreamingInterface::GetFormatsAndRates(multi_description* Description)
|
AudioStreamingInterface::GetFormatsAndRates(multi_description* Description)
|
||||||
{
|
{
|
||||||
// TODO: fIsInput ??????
|
|
||||||
Description->interface_flags
|
Description->interface_flags
|
||||||
|= fIsInput ? B_MULTI_INTERFACE_RECORD : B_MULTI_INTERFACE_PLAYBACK;
|
|= fIsInput ? B_MULTI_INTERFACE_RECORD : B_MULTI_INTERFACE_PLAYBACK;
|
||||||
|
|
||||||
// uint32 rates = 0;
|
|
||||||
/*
|
|
||||||
TypeIFormatDescriptor* format
|
|
||||||
= static_cast<TypeIFormatDescriptor*>(
|
|
||||||
fAlternates[fActiveAlternate]->Format());
|
|
||||||
|
|
||||||
if (format == NULL || fAlternates[fActiveAlternate]->Interface() == NULL) {
|
|
||||||
TRACE_ALWAYS("Ignore alternate %d due format "
|
|
||||||
"%#08x or interface %#08x null.\n", fActiveAlternate, format,
|
|
||||||
fAlternates[fActiveAlternate]->Interface());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (format->fSampleFrequencyType == 0) { // continuous frequencies
|
|
||||||
rates = B_SR_CVSR;
|
|
||||||
Description->min_cvsr_rate = float(format->fSampleFrequencies[0]);
|
|
||||||
Description->max_cvsr_rate = float(format->fSampleFrequencies[1]);
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < format->fSampleFrequencies.Count(); i++) {
|
|
||||||
switch(format->fSampleFrequencies[i]) {
|
|
||||||
case 8000: rates |= B_SR_8000; break;
|
|
||||||
case 11025: rates |= B_SR_11025; break;
|
|
||||||
case 12000: rates |= B_SR_12000; break;
|
|
||||||
case 16000: rates |= B_SR_16000; break;
|
|
||||||
case 22050: rates |= B_SR_22050; break;
|
|
||||||
case 24000: rates |= B_SR_24000; break;
|
|
||||||
case 32000: rates |= B_SR_32000; break;
|
|
||||||
case 44100: rates |= B_SR_44100; break;
|
|
||||||
case 48000: rates |= B_SR_48000; break;
|
|
||||||
case 64000: rates |= B_SR_64000; break;
|
|
||||||
case 88200: rates |= B_SR_88200; break;
|
|
||||||
case 96000: rates |= B_SR_96000; break;
|
|
||||||
case 176400: rates |= B_SR_176400; break;
|
|
||||||
case 192000: rates |= B_SR_192000; break;
|
|
||||||
case 384000: rates |= B_SR_384000; break;
|
|
||||||
case 1536000: rates |= B_SR_1536000; break;
|
|
||||||
default:
|
|
||||||
TRACE_ALWAYS("Ignore unsupported "
|
|
||||||
"sample rate %d for alternate %d.\n",
|
|
||||||
format->fSampleFrequencies[i], fActiveAlternate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
uint32 rates = fAlternates[fActiveAlternate]->GetSamplingRateIds();
|
uint32 rates = fAlternates[fActiveAlternate]->GetSamplingRateIds();
|
||||||
uint32 formats = fAlternates[fActiveAlternate]->GetFormatId();
|
uint32 formats = fAlternates[fActiveAlternate]->GetFormatId();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8,20 +8,16 @@
|
|||||||
#define _AUDIO_STREAMING_INTERFACE_H_
|
#define _AUDIO_STREAMING_INTERFACE_H_
|
||||||
|
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
#include "AudioControlInterface.h"
|
|
||||||
|
|
||||||
#include <util/VectorMap.h>
|
#include <util/VectorMap.h>
|
||||||
|
#include <USB3.h>
|
||||||
|
|
||||||
|
#include "AudioControlInterface.h"
|
||||||
#include "USB_audio_spec.h"
|
#include "USB_audio_spec.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
class ASInterfaceDescriptor {
|
||||||
// Audio Streaming Interface information entities
|
|
||||||
//
|
|
||||||
//
|
|
||||||
class ASInterfaceDescriptor /*: public _AudioFunctionEntity*/ {
|
|
||||||
public:
|
public:
|
||||||
ASInterfaceDescriptor(/*Device* device, size_t interface,*/
|
ASInterfaceDescriptor(
|
||||||
usb_as_interface_descriptor_r1* Descriptor);
|
usb_as_interface_descriptor_r1* Descriptor);
|
||||||
~ASInterfaceDescriptor();
|
~ASInterfaceDescriptor();
|
||||||
|
|
||||||
@@ -32,7 +28,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ASEndpointDescriptor /*: public _AudioFunctionEntity*/ {
|
class ASEndpointDescriptor {
|
||||||
public:
|
public:
|
||||||
ASEndpointDescriptor(
|
ASEndpointDescriptor(
|
||||||
usb_endpoint_descriptor* Endpoint,
|
usb_endpoint_descriptor* Endpoint,
|
||||||
@@ -49,7 +45,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class _ASFormatDescriptor /*: public _AudioFunctionEntity*/ {
|
class _ASFormatDescriptor {
|
||||||
public:
|
public:
|
||||||
_ASFormatDescriptor(
|
_ASFormatDescriptor(
|
||||||
usb_type_I_format_descriptor* Descriptor);
|
usb_type_I_format_descriptor* Descriptor);
|
||||||
@@ -63,7 +59,7 @@ public:
|
|||||||
|
|
||||||
class TypeIFormatDescriptor : public _ASFormatDescriptor {
|
class TypeIFormatDescriptor : public _ASFormatDescriptor {
|
||||||
public:
|
public:
|
||||||
TypeIFormatDescriptor(/*Device* device, size_t interface,*/
|
TypeIFormatDescriptor(
|
||||||
usb_type_I_format_descriptor* Descriptor);
|
usb_type_I_format_descriptor* Descriptor);
|
||||||
virtual ~TypeIFormatDescriptor();
|
virtual ~TypeIFormatDescriptor();
|
||||||
|
|
||||||
@@ -80,7 +76,7 @@ public:
|
|||||||
|
|
||||||
class TypeIIFormatDescriptor : public _ASFormatDescriptor {
|
class TypeIIFormatDescriptor : public _ASFormatDescriptor {
|
||||||
public:
|
public:
|
||||||
TypeIIFormatDescriptor(/*Device* device, size_t interface,*/
|
TypeIIFormatDescriptor(
|
||||||
usb_type_II_format_descriptor* Descriptor);
|
usb_type_II_format_descriptor* Descriptor);
|
||||||
virtual ~TypeIIFormatDescriptor();
|
virtual ~TypeIIFormatDescriptor();
|
||||||
|
|
||||||
@@ -94,7 +90,7 @@ public:
|
|||||||
|
|
||||||
class TypeIIIFormatDescriptor : public TypeIFormatDescriptor {
|
class TypeIIIFormatDescriptor : public TypeIFormatDescriptor {
|
||||||
public:
|
public:
|
||||||
TypeIIIFormatDescriptor(/*Device* device, size_t interface, */
|
TypeIIIFormatDescriptor(
|
||||||
usb_type_III_format_descriptor* Descriptor);
|
usb_type_III_format_descriptor* Descriptor);
|
||||||
virtual ~TypeIIIFormatDescriptor();
|
virtual ~TypeIIIFormatDescriptor();
|
||||||
|
|
||||||
@@ -133,10 +129,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef Vector<AudioStreamAlternate*> StreamAlternatesVector;
|
|
||||||
typedef Vector<AudioStreamAlternate*>::Iterator StreamAlternatesIterator;
|
|
||||||
|
|
||||||
|
|
||||||
class AudioStreamingInterface {
|
class AudioStreamingInterface {
|
||||||
public:
|
public:
|
||||||
AudioStreamingInterface(
|
AudioStreamingInterface(
|
||||||
@@ -150,8 +142,8 @@ public:
|
|||||||
|
|
||||||
AudioChannelCluster* ChannelCluster();
|
AudioChannelCluster* ChannelCluster();
|
||||||
|
|
||||||
void GetFormatsAndRates(multi_description *Description);
|
void GetFormatsAndRates(
|
||||||
|
multi_description* Description);
|
||||||
protected:
|
protected:
|
||||||
size_t fInterface;
|
size_t fInterface;
|
||||||
AudioControlInterface* fControlInterface;
|
AudioControlInterface* fControlInterface;
|
||||||
@@ -159,7 +151,7 @@ protected:
|
|||||||
// status_t fStatus;
|
// status_t fStatus;
|
||||||
bool fIsInput;
|
bool fIsInput;
|
||||||
// alternates of the streams
|
// alternates of the streams
|
||||||
StreamAlternatesVector fAlternates;
|
Vector<AudioStreamAlternate*> fAlternates;
|
||||||
size_t fActiveAlternate;
|
size_t fActiveAlternate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
#include "Device.h"
|
|
||||||
#include "Settings.h"
|
|
||||||
//#include "audio.h"
|
|
||||||
#include "AudioStreamingInterface.h"
|
|
||||||
// #include "StreamFormats.h"
|
|
||||||
|
|
||||||
#include <malloc.h>
|
#include "Device.h"
|
||||||
|
|
||||||
|
#include "Driver.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
Device::Device(usb_device device)
|
Device::Device(usb_device device)
|
||||||
:
|
:
|
||||||
fStatus(B_ERROR),
|
fStatus(B_ERROR),
|
||||||
fOpen(false),
|
fOpen(false),
|
||||||
fRemoved(false),
|
fRemoved(false),
|
||||||
fInsideNotify(0),
|
// fInsideNotify(0),
|
||||||
fDevice(device),
|
fDevice(device),
|
||||||
fNonBlocking(false),
|
fNonBlocking(false),
|
||||||
fAudioControl(this),
|
fAudioControl(this),
|
||||||
// fControlEndpoint(0),
|
|
||||||
// fInStreamEndpoint(0),
|
|
||||||
// fOutStreamEndpoint(0),
|
|
||||||
fNotifyReadSem(-1),
|
|
||||||
fNotifyWriteSem(-1),
|
|
||||||
fNotifyBuffer(NULL),
|
|
||||||
fNotifyBufferLength(0),
|
|
||||||
fBuffersReadySem(-1)
|
fBuffersReadySem(-1)
|
||||||
{
|
{
|
||||||
const usb_device_descriptor* deviceDescriptor
|
const usb_device_descriptor* deviceDescriptor
|
||||||
@@ -44,30 +35,15 @@ Device::Device(usb_device device)
|
|||||||
fProductID = deviceDescriptor->product_id;
|
fProductID = deviceDescriptor->product_id;
|
||||||
fUSBVersion = deviceDescriptor->usb_version;
|
fUSBVersion = deviceDescriptor->usb_version;
|
||||||
|
|
||||||
fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read");
|
|
||||||
if (fNotifyReadSem < B_OK) {
|
|
||||||
TRACE_ALWAYS("Error of creating read notify semaphore:%#010x\n",
|
|
||||||
fNotifyReadSem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fNotifyWriteSem = create_sem(0, DRIVER_NAME"_notify_write");
|
|
||||||
if (fNotifyWriteSem < B_OK) {
|
|
||||||
TRACE_ALWAYS("Error of creating write notify semaphore:%#010x\n",
|
|
||||||
fNotifyWriteSem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fBuffersReadySem = create_sem(0, DRIVER_NAME "_buffers_ready");
|
fBuffersReadySem = create_sem(0, DRIVER_NAME "_buffers_ready");
|
||||||
if (fBuffersReadySem < B_OK) {
|
if (fBuffersReadySem < B_OK) {
|
||||||
TRACE_ALWAYS("Error of creating ready buffers semaphore:%#010x\n",
|
TRACE_ALWAYS("Error of creating ready "
|
||||||
fBuffersReadySem);
|
"buffers semaphore:%#010x\n", fBuffersReadySem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_SetupEndpoints() != B_OK) {
|
if (_SetupEndpoints() != B_OK)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// must be set in derived class constructor
|
// must be set in derived class constructor
|
||||||
fStatus = B_OK;
|
fStatus = B_OK;
|
||||||
@@ -76,40 +52,14 @@ Device::Device(usb_device device)
|
|||||||
|
|
||||||
Device::~Device()
|
Device::~Device()
|
||||||
{
|
{
|
||||||
// we have to clear because we own those objects here
|
for (Vector<Stream*>::Iterator I = fStreams.Begin();
|
||||||
/*
|
I != fStreams.End(); I++)
|
||||||
for (AudioControlsIterator I = fAudioControls.Begin();
|
|
||||||
I != fAudioControls.End(); I++) {
|
|
||||||
delete I->Value();
|
|
||||||
}
|
|
||||||
fAudioControls.MakeEmpty();
|
|
||||||
|
|
||||||
// object already freed. just purge the map
|
|
||||||
fOutputTerminals.MakeEmpty();
|
|
||||||
|
|
||||||
// object already freed. just purge the map
|
|
||||||
fInputTerminals.MakeEmpty();
|
|
||||||
*/
|
|
||||||
// free stream objects too.
|
|
||||||
for (AudioStreamsIterator I = fStreams.Begin();
|
|
||||||
I != fStreams.End(); I++) {
|
|
||||||
delete *I;
|
delete *I;
|
||||||
}
|
|
||||||
fStreams.MakeEmpty();
|
|
||||||
|
|
||||||
if (fNotifyReadSem >= B_OK)
|
fStreams.MakeEmpty();
|
||||||
delete_sem(fNotifyReadSem);
|
|
||||||
if (fNotifyWriteSem >= B_OK)
|
|
||||||
delete_sem(fNotifyWriteSem);
|
|
||||||
|
|
||||||
if (fBuffersReadySem > B_OK)
|
if (fBuffersReadySem > B_OK)
|
||||||
delete_sem(fBuffersReadySem);
|
delete_sem(fBuffersReadySem);
|
||||||
|
|
||||||
// if (!fRemoved) // ???
|
|
||||||
// gUSBModule->cancel_queued_transfers(fNotifyEndpoint);
|
|
||||||
|
|
||||||
if (fNotifyBuffer)
|
|
||||||
free(fNotifyBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,19 +72,10 @@ Device::Open(uint32 flags)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
status_t result = StartDevice();
|
status_t result = StartDevice();
|
||||||
if (result != B_OK) {
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
// setup state notifications
|
|
||||||
/* result = gUSBModule->queue_interrupt(fNotifyEndpoint, fNotifyBuffer,
|
|
||||||
fNotifyBufferLength, _NotifyCallback, this);
|
|
||||||
if (result != B_OK) {
|
|
||||||
TRACE_ALWAYS("Error of requesting notify interrupt:%#010x\n", result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// TODO: are we need this???
|
||||||
fNonBlocking = (flags & O_NONBLOCK) == O_NONBLOCK;
|
fNonBlocking = (flags & O_NONBLOCK) == O_NONBLOCK;
|
||||||
fOpen = true;
|
fOpen = true;
|
||||||
return result;
|
return result;
|
||||||
@@ -149,13 +90,12 @@ Device::Close()
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fStreams.Count(); i++) {
|
for (int i = 0; i < fStreams.Count(); i++)
|
||||||
fStreams[i]->Stop();
|
fStreams[i]->Stop();
|
||||||
}
|
|
||||||
|
|
||||||
// wait until possible notification handling finished...
|
// wait until possible notification handling finished...
|
||||||
while (atomic_add(&fInsideNotify, 0) != 0)
|
// while (atomic_add(&fInsideNotify, 0) != 0)
|
||||||
snooze(100);
|
// snooze(100);
|
||||||
// gUSBModule->cancel_queued_transfers(fControlEndpoint);
|
// gUSBModule->cancel_queued_transfers(fControlEndpoint);
|
||||||
// gUSBModule->cancel_queued_transfers(fInStreamEndpoint);
|
// gUSBModule->cancel_queued_transfers(fInStreamEndpoint);
|
||||||
// gUSBModule->cancel_queued_transfers(fOutStreamEndpoint);
|
// gUSBModule->cancel_queued_transfers(fOutStreamEndpoint);
|
||||||
@@ -224,7 +164,7 @@ Device::Control(uint32 op, void *buffer, size_t length)
|
|||||||
TRACE(("B_MULTI_GET_CHANNEL_FORMATS\n"));
|
TRACE(("B_MULTI_GET_CHANNEL_FORMATS\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
case B_MULTI_SET_CHANNEL_FORMATS: /* only implemented if possible */
|
case B_MULTI_SET_CHANNEL_FORMATS:
|
||||||
TRACE(("B_MULTI_SET_CHANNEL_FORMATS\n"));
|
TRACE(("B_MULTI_SET_CHANNEL_FORMATS\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
@@ -279,7 +219,6 @@ void
|
|||||||
Device::Removed()
|
Device::Removed()
|
||||||
{
|
{
|
||||||
fRemoved = true;
|
fRemoved = true;
|
||||||
// fHasConnection = false;
|
|
||||||
|
|
||||||
// the notify hook is different from the read and write hooks as it does
|
// the notify hook is different from the read and write hooks as it does
|
||||||
// itself schedule traffic (while the other hooks only release a semaphore
|
// itself schedule traffic (while the other hooks only release a semaphore
|
||||||
@@ -287,16 +226,13 @@ Device::Removed()
|
|||||||
// case) - so we must ensure that we are not inside the notify hook anymore
|
// case) - so we must ensure that we are not inside the notify hook anymore
|
||||||
// before returning, as we would otherwise violate the promise not to use
|
// before returning, as we would otherwise violate the promise not to use
|
||||||
// any of the pipes after returning from the removed hook
|
// any of the pipes after returning from the removed hook
|
||||||
while (atomic_add(&fInsideNotify, 0) != 0)
|
// TODO??????
|
||||||
snooze(100);
|
// while (atomic_add(&fInsideNotify, 0) != 0)
|
||||||
|
// snooze(100);
|
||||||
|
|
||||||
// gUSBModule->cancel_queued_transfers(fControlEndpoint);
|
// gUSBModule->cancel_queued_transfers(fControlEndpoint);
|
||||||
// gUSBModule->cancel_queued_transfers(fInStreamEndpoint);
|
// gUSBModule->cancel_queued_transfers(fInStreamEndpoint);
|
||||||
// gUSBModule->cancel_queued_transfers(fOutStreamEndpoint);
|
// gUSBModule->cancel_queued_transfers(fOutStreamEndpoint);
|
||||||
/*
|
|
||||||
if (fLinkStateChangeSem >= B_OK)
|
|
||||||
release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -319,10 +255,9 @@ Device::CompareAndReattach(usb_device device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deviceDescriptor->vendor_id != fVendorID
|
if (deviceDescriptor->vendor_id != fVendorID
|
||||||
&& deviceDescriptor->product_id != fProductID) {
|
&& deviceDescriptor->product_id != fProductID)
|
||||||
// this certainly isn't the same device
|
// this certainly isn't the same device
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
|
||||||
|
|
||||||
// this is the same device that was replugged - clear the removed state,
|
// this is the same device that was replugged - clear the removed state,
|
||||||
// re- setup the endpoints and transfers and open the device if it was
|
// re- setup the endpoints and transfers and open the device if it was
|
||||||
@@ -337,9 +272,8 @@ Device::CompareAndReattach(usb_device device)
|
|||||||
|
|
||||||
// we need to setup hardware on device replug
|
// we need to setup hardware on device replug
|
||||||
result = SetupDevice(true);
|
result = SetupDevice(true);
|
||||||
if (result != B_OK) {
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
if (fOpen) {
|
if (fOpen) {
|
||||||
fOpen = false;
|
fOpen = false;
|
||||||
@@ -355,14 +289,13 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
|||||||
{
|
{
|
||||||
multi_description Description;
|
multi_description Description;
|
||||||
if (user_memcpy(&Description, multiDescription,
|
if (user_memcpy(&Description, multiDescription,
|
||||||
sizeof(multi_description)) != B_OK) {
|
sizeof(multi_description)) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
}
|
|
||||||
|
|
||||||
Description.interface_version = B_CURRENT_INTERFACE_VERSION;
|
Description.interface_version = B_CURRENT_INTERFACE_VERSION;
|
||||||
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
||||||
|
|
||||||
strlcpy(Description.friendly_name, "USB Audio", // TODO: ????
|
strlcpy(Description.friendly_name, "USB Audio",
|
||||||
sizeof(Description.friendly_name));
|
sizeof(Description.friendly_name));
|
||||||
|
|
||||||
strlcpy(Description.vendor_info, "S.Zharski",
|
strlcpy(Description.vendor_info, "S.Zharski",
|
||||||
@@ -389,7 +322,7 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
|||||||
|
|
||||||
Description.control_panel[0] = '\0';
|
Description.control_panel[0] = '\0';
|
||||||
|
|
||||||
AudioControlsVector USBTerminals;
|
Vector<_AudioControl*> USBTerminals;
|
||||||
|
|
||||||
// channels (USB I/O terminals) are already in fStreams
|
// channels (USB I/O terminals) are already in fStreams
|
||||||
// in outputs->inputs order, use them.
|
// in outputs->inputs order, use them.
|
||||||
@@ -406,28 +339,22 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// int32 index = 0;
|
|
||||||
Vector<multi_channel_info> Channels;
|
Vector<multi_channel_info> Channels;
|
||||||
/*uint32 channels =*/ fAudioControl.GetChannelsDescription(Channels, &Description, USBTerminals);
|
fAudioControl.GetChannelsDescription(Channels, &Description, USBTerminals);
|
||||||
/*uint32 bus_channels =*/ fAudioControl.GetBusChannelsDescription(Channels, &Description );
|
fAudioControl.GetBusChannelsDescription(Channels, &Description );
|
||||||
|
|
||||||
// Description.request_channel_count = channels + bus_channels;
|
// Description.request_channel_count = channels + bus_channels;
|
||||||
|
|
||||||
TraceMultiDescription(&Description, Channels);
|
TraceMultiDescription(&Description, Channels);
|
||||||
|
|
||||||
if (user_memcpy(multiDescription, &Description,
|
if (user_memcpy(multiDescription, &Description,
|
||||||
sizeof(multi_description)) != B_OK) {
|
sizeof(multi_description)) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
}
|
|
||||||
|
|
||||||
// if (Description.request_channel_count >=
|
|
||||||
// (int)(sizeof(channel_descriptions) / sizeof(channel_descriptions[0])))
|
|
||||||
// {
|
|
||||||
if (user_memcpy(multiDescription->channels,
|
if (user_memcpy(multiDescription->channels,
|
||||||
&Channels[0], min_c(Channels.Count(),
|
&Channels[0], min_c(Channels.Count(),
|
||||||
Description.request_channel_count)) != B_OK)
|
Description.request_channel_count)) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
// }
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -479,9 +406,8 @@ Device::_MultiGetEnabledChannels(multi_channel_enable *Enable)
|
|||||||
Enable->lock_source = B_MULTI_LOCK_INTERNAL;
|
Enable->lock_source = B_MULTI_LOCK_INTERNAL;
|
||||||
|
|
||||||
uint32 offset = 0;
|
uint32 offset = 0;
|
||||||
for (int i = 0; i < fStreams.Count() && status == B_OK; i++) {
|
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
|
||||||
status = fStreams[i]->GetEnabledChannels(offset, Enable);
|
status = fStreams[i]->GetEnabledChannels(offset, Enable);
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -492,9 +418,8 @@ Device::_MultiSetEnabledChannels(multi_channel_enable *Enable)
|
|||||||
{
|
{
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
uint32 offset = 0;
|
uint32 offset = 0;
|
||||||
for (int i = 0; i < fStreams.Count() && status == B_OK; i++) {
|
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
|
||||||
status = fStreams[i]->SetEnabledChannels(offset, Enable);
|
status = fStreams[i]->SetEnabledChannels(offset, Enable);
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -510,9 +435,8 @@ Device::_MultiGetGlobalFormat(multi_format_info *Format)
|
|||||||
Format->timecode_kind = 0;
|
Format->timecode_kind = 0;
|
||||||
|
|
||||||
// uint32 offset = 0;
|
// uint32 offset = 0;
|
||||||
for (int i = 0; i < fStreams.Count() && status == B_OK; i++) {
|
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
|
||||||
status = fStreams[i]->GetGlobalFormat(Format);
|
status = fStreams[i]->GetGlobalFormat(Format);
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -528,9 +452,8 @@ Device::_MultiSetGlobalFormat(multi_format_info *Format)
|
|||||||
TRACE("timecode_kind:%#08x\n", Format->timecode_kind);
|
TRACE("timecode_kind:%#08x\n", Format->timecode_kind);
|
||||||
|
|
||||||
// uint32 offset = 0;
|
// uint32 offset = 0;
|
||||||
for (int i = 0; i < fStreams.Count() && status == B_OK; i++) {
|
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
|
||||||
status = fStreams[i]->SetGlobalFormat(Format);
|
status = fStreams[i]->SetGlobalFormat(Format);
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -560,9 +483,8 @@ Device::_MultiGetBuffers(multi_buffer_list* List)
|
|||||||
List->return_playback_channels = 0;
|
List->return_playback_channels = 0;
|
||||||
List->return_record_channels = 0;
|
List->return_record_channels = 0;
|
||||||
|
|
||||||
for (int i = 0; i < fStreams.Count() && status == B_OK; i++) {
|
for (int i = 0; i < fStreams.Count() && status == B_OK; i++)
|
||||||
status = fStreams[i]->GetBuffers(List);
|
status = fStreams[i]->GetBuffers(List);
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -575,17 +497,10 @@ Device::_MultiBufferExchange(multi_buffer_info* multiInfo)
|
|||||||
if (user_memcpy(&Info, multiInfo, sizeof(multi_buffer_info)) != B_OK)
|
if (user_memcpy(&Info, multiInfo, sizeof(multi_buffer_info)) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
for (int i = 0; i < fStreams.Count(); i++) {
|
for (int i = 0; i < fStreams.Count(); i++)
|
||||||
if (!fStreams[i]->IsRunning()) {
|
if (!fStreams[i]->IsRunning())
|
||||||
fStreams[i]->Start();
|
fStreams[i]->Start();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TRACE_ALWAYS("Exchange!\n");
|
|
||||||
/*
|
|
||||||
snooze(1000000);
|
|
||||||
return B_OK;
|
|
||||||
*/
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
bool anyBufferProcessed = false;
|
bool anyBufferProcessed = false;
|
||||||
for (int i = 0; i < fStreams.Count() && !anyBufferProcessed; i++) {
|
for (int i = 0; i < fStreams.Count() && !anyBufferProcessed; i++) {
|
||||||
@@ -610,9 +525,8 @@ Device::_MultiBufferExchange(multi_buffer_info* multiInfo)
|
|||||||
status_t
|
status_t
|
||||||
Device::_MultiBufferForceStop()
|
Device::_MultiBufferForceStop()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fStreams.Count(); i++) {
|
for (int i = 0; i < fStreams.Count(); i++)
|
||||||
fStreams[i]->Stop();
|
fStreams[i]->Stop();
|
||||||
}
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,9 +591,8 @@ Device::_SetupEndpoints()
|
|||||||
|
|
||||||
for (size_t i = 0; i < config->interface_count; i++) {
|
for (size_t i = 0; i < config->interface_count; i++) {
|
||||||
usb_interface_info* Interface = config->interface[i].active;
|
usb_interface_info* Interface = config->interface[i].active;
|
||||||
if (Interface->descr->interface_class != UAS_AUDIO) {
|
if (Interface->descr->interface_class != UAS_AUDIO)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
switch (Interface->descr->interface_subclass) {
|
switch (Interface->descr->interface_subclass) {
|
||||||
case UAS_AUDIOCONTROL:
|
case UAS_AUDIOCONTROL:
|
||||||
@@ -691,15 +604,13 @@ Device::_SetupEndpoints()
|
|||||||
if (B_OK == stream->Init()) {
|
if (B_OK == stream->Init()) {
|
||||||
// put the stream in the correct order:
|
// put the stream in the correct order:
|
||||||
// first output that input ones.
|
// first output that input ones.
|
||||||
if (stream->IsInput()) {
|
if (stream->IsInput())
|
||||||
fStreams.PushBack(stream);
|
fStreams.PushBack(stream);
|
||||||
} else {
|
else
|
||||||
fStreams.PushFront(stream);
|
fStreams.PushFront(stream);
|
||||||
}
|
} else
|
||||||
} else {
|
|
||||||
delete stream;
|
delete stream;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TRACE_ALWAYS("Ignore interface of unsupported subclass %#x.\n",
|
TRACE_ALWAYS("Ignore interface of unsupported subclass %#x.\n",
|
||||||
@@ -712,9 +623,8 @@ Device::_SetupEndpoints()
|
|||||||
TRACE("Found device %#06x:%#06x\n", fVendorID, fProductID);
|
TRACE("Found device %#06x:%#06x\n", fVendorID, fProductID);
|
||||||
gUSBModule->set_configuration(fDevice, config);
|
gUSBModule->set_configuration(fDevice, config);
|
||||||
|
|
||||||
for (int i = 0; i < fStreams.Count(); i++) {
|
for (int i = 0; i < fStreams.Count(); i++)
|
||||||
fStreams[i]->OnSetConfiguration(fDevice, config);
|
fStreams[i]->OnSetConfiguration(fDevice, config);
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -728,40 +638,15 @@ Device::StopDevice()
|
|||||||
{
|
{
|
||||||
status_t result = B_OK;
|
status_t result = B_OK;
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK)
|
||||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
|
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_RET(result);
|
TRACE_RET(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/*void
|
||||||
Device::_ReadCallback(void *cookie, int32 status, void *data,
|
|
||||||
uint32 actualLength)
|
|
||||||
{
|
|
||||||
TRACE_FLOW("ReadCB: %d bytes; status:%#010x\n", actualLength, status);
|
|
||||||
Device *device = (Device *)cookie;
|
|
||||||
device->fActualLengthRead = actualLength;
|
|
||||||
device->fStatusRead = status;
|
|
||||||
release_sem_etc(device->fNotifyReadSem, 1, B_DO_NOT_RESCHEDULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Device::_WriteCallback(void *cookie, int32 status, void *data,
|
|
||||||
uint32 actualLength)
|
|
||||||
{
|
|
||||||
TRACE_FLOW("WriteCB: %d bytes; status:%#010x\n", actualLength, status);
|
|
||||||
Device *device = (Device *)cookie;
|
|
||||||
device->fActualLengthWrite = actualLength;
|
|
||||||
device->fStatusWrite = status;
|
|
||||||
release_sem_etc(device->fNotifyWriteSem, 1, B_DO_NOT_RESCHEDULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Device::_NotifyCallback(void* cookie, int32 status, void* data,
|
Device::_NotifyCallback(void* cookie, int32 status, void* data,
|
||||||
uint32 actualLength)
|
uint32 actualLength)
|
||||||
{
|
{
|
||||||
@@ -788,4 +673,5 @@ Device::_NotifyCallback(void *cookie, int32 status, void *data,
|
|||||||
// device->fNotifyBufferLength, _NotifyCallback, device);
|
// device->fNotifyBufferLength, _NotifyCallback, device);
|
||||||
atomic_add(&device->fInsideNotify, -1);
|
atomic_add(&device->fInsideNotify, -1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8,24 +8,13 @@
|
|||||||
#define _USB_AUDIO_DEVICE_H_
|
#define _USB_AUDIO_DEVICE_H_
|
||||||
|
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
#include "USB_audio_spec.h"
|
|
||||||
#include "AudioControlInterface.h"
|
#include "AudioControlInterface.h"
|
||||||
#include "AudioStreamingInterface.h"
|
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
|
|
||||||
// typedef VectorMap<uint32, _AudioControl*> AudioControlsMap;
|
|
||||||
// typedef VectorMap<uint32, _AudioControl*>::Iterator AudioControlsIterator;
|
|
||||||
|
|
||||||
typedef Vector<Stream*> AudioStreamsVector;
|
|
||||||
typedef Vector<Stream*>::Iterator AudioStreamsIterator;
|
|
||||||
|
|
||||||
|
|
||||||
class FeatureUnit;
|
|
||||||
|
|
||||||
class Device {
|
class Device {
|
||||||
friend class FeatureUnit;
|
|
||||||
friend class Stream;
|
friend class Stream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Device(usb_device device);
|
Device(usb_device device);
|
||||||
virtual ~Device();
|
virtual ~Device();
|
||||||
@@ -47,39 +36,28 @@ public:
|
|||||||
|
|
||||||
status_t CompareAndReattach(usb_device device);
|
status_t CompareAndReattach(usb_device device);
|
||||||
virtual status_t SetupDevice(bool deviceReplugged);
|
virtual status_t SetupDevice(bool deviceReplugged);
|
||||||
// uint16 SpecReleaseNumber();
|
|
||||||
|
|
||||||
// _AudioControl* FindAudioControl(uint8 ID);
|
|
||||||
usb_device USBDevice() { return fDevice; }
|
usb_device USBDevice() { return fDevice; }
|
||||||
|
|
||||||
AudioControlInterface& AudioControl() { return fAudioControl; }
|
AudioControlInterface&
|
||||||
|
AudioControl() { return fAudioControl; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void _ReadCallback(void *cookie, int32 status,
|
|
||||||
void *data, uint32 actualLength);
|
|
||||||
static void _WriteCallback(void *cookie, int32 status,
|
|
||||||
void *data, uint32 actualLength);
|
|
||||||
static void _NotifyCallback(void *cookie, int32 status,
|
|
||||||
void *data, uint32 actualLength);
|
|
||||||
|
|
||||||
status_t _SetupEndpoints();
|
status_t _SetupEndpoints();
|
||||||
// void ParseAudioControlInterface(usb_device device,
|
|
||||||
// size_t interface, usb_interface_info *Interface);
|
|
||||||
// void ParseAudioStreamingInterface(usb_device device,
|
|
||||||
// size_t interface, usb_interface_list *List);
|
|
||||||
|
|
||||||
protected:
|
// protected:
|
||||||
virtual status_t StartDevice() { return B_OK; }
|
virtual status_t StartDevice() { return B_OK; }
|
||||||
virtual status_t StopDevice();
|
virtual status_t StopDevice();
|
||||||
|
|
||||||
void TraceMultiDescription(multi_description* Description,
|
void TraceMultiDescription(multi_description* Description,
|
||||||
Vector<multi_channel_info>& Channels);
|
Vector<multi_channel_info>& Channels);
|
||||||
void TraceListMixControls(multi_mix_control_info* Info);
|
void TraceListMixControls(multi_mix_control_info* Info);
|
||||||
|
|
||||||
// state tracking
|
// state tracking
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
bool fOpen;
|
bool fOpen;
|
||||||
bool fRemoved;
|
bool fRemoved;
|
||||||
vint32 fInsideNotify;
|
// int32 fInsideNotify; // TODO: move to Stream!
|
||||||
usb_device fDevice;
|
usb_device fDevice;
|
||||||
uint16 fUSBVersion;
|
uint16 fUSBVersion;
|
||||||
uint16 fVendorID;
|
uint16 fVendorID;
|
||||||
@@ -88,19 +66,9 @@ const char * fDescription;
|
|||||||
bool fNonBlocking;
|
bool fNonBlocking;
|
||||||
|
|
||||||
AudioControlInterface fAudioControl;
|
AudioControlInterface fAudioControl;
|
||||||
/*
|
Vector<Stream*> fStreams;
|
||||||
AudioControlHeader* fAudioControlHeader;
|
|
||||||
// map to store all controls and lookup by control ID
|
|
||||||
AudioControlsMap fAudioControls;
|
|
||||||
// map to store output terminal and lookup them by source ID
|
|
||||||
AudioControlsMap fOutputTerminals;
|
|
||||||
// map to store output terminal and lookup them by control ID
|
|
||||||
AudioControlsMap fInputTerminals;
|
|
||||||
*/
|
|
||||||
// vector of audio streams
|
|
||||||
AudioStreamsVector fStreams;
|
|
||||||
|
|
||||||
protected:
|
// protected:
|
||||||
status_t _MultiGetDescription(multi_description* Description);
|
status_t _MultiGetDescription(multi_description* Description);
|
||||||
status_t _MultiGetEnabledChannels(multi_channel_enable* Enable);
|
status_t _MultiGetEnabledChannels(multi_channel_enable* Enable);
|
||||||
status_t _MultiSetEnabledChannels(multi_channel_enable* Enable);
|
status_t _MultiSetEnabledChannels(multi_channel_enable* Enable);
|
||||||
@@ -113,25 +81,6 @@ protected:
|
|||||||
status_t _MultiBufferExchange(multi_buffer_info* Info);
|
status_t _MultiBufferExchange(multi_buffer_info* Info);
|
||||||
status_t _MultiBufferForceStop();
|
status_t _MultiBufferForceStop();
|
||||||
|
|
||||||
// interface and device infos
|
|
||||||
// uint16 fFrameSize;
|
|
||||||
|
|
||||||
// pipes for notifications and data io
|
|
||||||
// usb_pipe fControlEndpoint;
|
|
||||||
// usb_pipe fInStreamEndpoint;
|
|
||||||
// usb_pipe fOutStreamEndpoint;
|
|
||||||
|
|
||||||
// data stores for async usb transfers
|
|
||||||
uint32 fActualLengthRead;
|
|
||||||
uint32 fActualLengthWrite;
|
|
||||||
int32 fStatusRead;
|
|
||||||
int32 fStatusWrite;
|
|
||||||
sem_id fNotifyReadSem;
|
|
||||||
sem_id fNotifyWriteSem;
|
|
||||||
|
|
||||||
uint8 * fNotifyBuffer;
|
|
||||||
uint32 fNotifyBufferLength;
|
|
||||||
|
|
||||||
sem_id fBuffersReadySem;
|
sem_id fBuffersReadySem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <lock.h> // for mutex
|
|
||||||
|
|
||||||
#include "Driver.h"
|
#include "Driver.h"
|
||||||
#include "Settings.h"
|
|
||||||
|
#include <AutoLock.h>
|
||||||
|
|
||||||
#include "Device.h"
|
#include "Device.h"
|
||||||
#include "USB_audio_spec.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
|
||||||
|
|
||||||
|
|
||||||
static const char* sDeviceBaseName = "audio/hmulti/USB Audio/";
|
static const char* sDeviceBaseName = "audio/hmulti/USB Audio/";
|
||||||
Device *gDevices[MAX_DEVICES];
|
|
||||||
char *gDeviceNames[MAX_DEVICES + 1];
|
|
||||||
|
|
||||||
usb_module_info* gUSBModule = NULL;
|
usb_module_info* gUSBModule = NULL;
|
||||||
|
|
||||||
|
Device* gDevices[MAX_DEVICES];
|
||||||
|
char* gDeviceNames[MAX_DEVICES + 1];
|
||||||
|
|
||||||
mutex gDriverLock;
|
mutex gDriverLock;
|
||||||
// auto - release helper class
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
class DriverSmartLock {
|
|
||||||
public:
|
|
||||||
DriverSmartLock() { mutex_lock(&gDriverLock); }
|
|
||||||
~DriverSmartLock() { mutex_unlock(&gDriverLock); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@@ -41,7 +29,7 @@ usb_audio_device_added(usb_device device, void **cookie)
|
|||||||
{
|
{
|
||||||
*cookie = NULL;
|
*cookie = NULL;
|
||||||
|
|
||||||
DriverSmartLock driverLock; // released on exit
|
MutexLocker driverLock;
|
||||||
|
|
||||||
// check if this is a replug of an existing device first
|
// check if this is a replug of an existing device first
|
||||||
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
||||||
@@ -58,9 +46,8 @@ usb_audio_device_added(usb_device device, void **cookie)
|
|||||||
|
|
||||||
// no such device yet, create a new one
|
// no such device yet, create a new one
|
||||||
Device* audioDevice = new Device(device);
|
Device* audioDevice = new Device(device);
|
||||||
if (audioDevice == 0) {
|
if (audioDevice == 0)
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
|
||||||
|
|
||||||
status_t status = audioDevice->InitCheck();
|
status_t status = audioDevice->InitCheck();
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
@@ -96,7 +83,7 @@ usb_audio_device_added(usb_device device, void **cookie)
|
|||||||
status_t
|
status_t
|
||||||
usb_audio_device_removed(void* cookie)
|
usb_audio_device_removed(void* cookie)
|
||||||
{
|
{
|
||||||
DriverSmartLock driverLock; // released on exit
|
MutexLocker driverLock;
|
||||||
|
|
||||||
Device* device = (Device*)cookie;
|
Device* device = (Device*)cookie;
|
||||||
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
||||||
@@ -185,7 +172,7 @@ uninit_driver()
|
|||||||
static status_t
|
static status_t
|
||||||
usb_audio_open(const char* name, uint32 flags, void** cookie)
|
usb_audio_open(const char* name, uint32 flags, void** cookie)
|
||||||
{
|
{
|
||||||
DriverSmartLock driverLock; // released on exit
|
MutexLocker driverLock;
|
||||||
|
|
||||||
*cookie = NULL;
|
*cookie = NULL;
|
||||||
status_t status = ENODEV;
|
status_t status = ENODEV;
|
||||||
@@ -237,7 +224,7 @@ usb_audio_free(void *cookie)
|
|||||||
{
|
{
|
||||||
Device* device = (Device*)cookie;
|
Device* device = (Device*)cookie;
|
||||||
|
|
||||||
DriverSmartLock driverLock; // released on exit
|
MutexLocker driverLock;
|
||||||
|
|
||||||
status_t status = device->Free();
|
status_t status = device->Free();
|
||||||
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
||||||
@@ -263,7 +250,7 @@ publish_devices()
|
|||||||
gDeviceNames[i] = NULL;
|
gDeviceNames[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DriverSmartLock driverLock; // released on exit
|
MutexLocker driverLock;
|
||||||
|
|
||||||
int32 deviceCount = 0;
|
int32 deviceCount = 0;
|
||||||
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
for (int32 i = 0; i < MAX_DEVICES; i++) {
|
||||||
@@ -294,8 +281,8 @@ find_device(const char *name)
|
|||||||
usb_audio_control,
|
usb_audio_control,
|
||||||
usb_audio_read,
|
usb_audio_read,
|
||||||
usb_audio_write,
|
usb_audio_write,
|
||||||
NULL, /* select */
|
NULL, // select
|
||||||
NULL /* deselect */
|
NULL // deselect
|
||||||
};
|
};
|
||||||
|
|
||||||
return &deviceHooks;
|
return &deviceHooks;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8,22 +8,20 @@
|
|||||||
#define _USB_AUDIO_DRIVER_H_
|
#define _USB_AUDIO_DRIVER_H_
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
#include <KernelExport.h>
|
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <USB3.h>
|
#include <USB3.h>
|
||||||
#include <hmulti_audio.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define DRIVER_NAME "usb_audio"
|
#define DRIVER_NAME "usb_audio"
|
||||||
#define MAX_DEVICES 8
|
#define MAX_DEVICES 8
|
||||||
|
|
||||||
const char* const kVersion = "ver.0.0.4";
|
const char* const kVersion = "ver.0.0.5";
|
||||||
|
|
||||||
|
// initial buffer size in samples
|
||||||
const uint32 kSamplesBufferSize = 1024;
|
const uint32 kSamplesBufferSize = 1024;
|
||||||
|
// [sub]buffers count
|
||||||
const uint32 kSamplesBufferCount = 2;
|
const uint32 kSamplesBufferCount = 2;
|
||||||
|
|
||||||
|
|
||||||
// calculate count of array members
|
// calculate count of array members
|
||||||
#ifdef _countof
|
#ifdef _countof
|
||||||
#warning "countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
|
#warning "countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
|
||||||
@@ -34,19 +32,14 @@ const uint32 kSamplesBufferCount = 2;
|
|||||||
|
|
||||||
extern usb_module_info* gUSBModule;
|
extern usb_module_info* gUSBModule;
|
||||||
|
|
||||||
|
extern "C" status_t usb_audio_device_added(usb_device device, void** cookie);
|
||||||
|
extern "C" status_t usb_audio_device_removed(void* cookie);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" status_t init_hardware();
|
||||||
|
extern "C" void uninit_driver();
|
||||||
|
|
||||||
status_t usb_audio_device_added(usb_device device, void **cookie);
|
extern "C" const char** publish_devices();
|
||||||
status_t usb_audio_device_removed(void *cookie);
|
extern "C" device_hooks *find_device(const char* name);
|
||||||
|
|
||||||
status_t init_hardware();
|
|
||||||
void uninit_driver();
|
|
||||||
|
|
||||||
const char **publish_devices();
|
|
||||||
device_hooks *find_device(const char *name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _USB_AUDIO_DRIVER_H_
|
#endif // _USB_AUDIO_DRIVER_H_
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ SubDir HAIKU_TOP src add-ons kernel drivers audio usb_audio ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders kernel media ;
|
|
||||||
|
|
||||||
UsePrivateHeaders kernel net ;
|
UsePrivateHeaders kernel net ;
|
||||||
|
UsePrivateKernelHeaders ;
|
||||||
UsePrivateHeaders [ FDirName kernel util ] ;
|
UsePrivateHeaders [ FDirName kernel util ] ;
|
||||||
|
UsePrivateHeaders kernel media ;
|
||||||
|
|
||||||
KernelAddon usb_audio :
|
KernelAddon usb_audio :
|
||||||
Driver.cpp
|
Driver.cpp
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <lock.h> // for mutex
|
|
||||||
#include <stdlib.h> // for file operation
|
|
||||||
#include <string.h> // for file operation
|
|
||||||
#include <stdio.h> // for file operation
|
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <driver_settings.h>
|
||||||
|
#include <lock.h>
|
||||||
|
|
||||||
|
#include "Driver.h"
|
||||||
|
|
||||||
|
|
||||||
bool gTraceOn = false;
|
bool gTraceOn = false;
|
||||||
bool gTruncateLogFile = false;
|
bool gTruncateLogFile = false;
|
||||||
bool gAddTimeStamp = true;
|
bool gAddTimeStamp = true;
|
||||||
@@ -49,9 +55,8 @@ void load_settings()
|
|||||||
gAddTimeStamp, true);
|
gAddTimeStamp, true);
|
||||||
const char* logFilePath = get_driver_parameter(handle, "logfile",
|
const char* logFilePath = get_driver_parameter(handle, "logfile",
|
||||||
NULL, "/var/log/"DRIVER_NAME".log");
|
NULL, "/var/log/"DRIVER_NAME".log");
|
||||||
if (logFilePath != NULL) {
|
if (logFilePath != NULL)
|
||||||
gLogFilePath = strdup(logFilePath);
|
gLogFilePath = strdup(logFilePath);
|
||||||
}
|
|
||||||
|
|
||||||
unload_driver_settings(handle);
|
unload_driver_settings(handle);
|
||||||
|
|
||||||
@@ -70,9 +75,8 @@ void release_settings()
|
|||||||
|
|
||||||
void usb_audio_trace(bool force, const char* func, const char* fmt, ...)
|
void usb_audio_trace(bool force, const char* func, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
if (!(force || gTraceOn)) {
|
if (!(force || gTraceOn))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
va_list arg_list;
|
va_list arg_list;
|
||||||
static const char* prefix = DRIVER_NAME":";
|
static const char* prefix = DRIVER_NAME":";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -8,10 +8,6 @@
|
|||||||
#define _USB_AUDIO_SETTINGS_H_
|
#define _USB_AUDIO_SETTINGS_H_
|
||||||
|
|
||||||
|
|
||||||
#include <driver_settings.h>
|
|
||||||
|
|
||||||
#include "Driver.h"
|
|
||||||
|
|
||||||
void load_settings();
|
void load_settings();
|
||||||
void release_settings();
|
void release_settings();
|
||||||
|
|
||||||
@@ -30,5 +26,5 @@ extern bool gTraceFlow;
|
|||||||
#define TRACE_RET(result) usb_audio_trace(false, __func__, \
|
#define TRACE_RET(result) usb_audio_trace(false, __func__, \
|
||||||
"Returns:%#010x\n", result);
|
"Returns:%#010x\n", result);
|
||||||
|
|
||||||
#endif /*_USB_AUDIO_SETTINGS_H_*/
|
#endif // _USB_AUDIO_SETTINGS_H_
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Device.h"
|
#include "Device.h"
|
||||||
#include "Driver.h"
|
#include "Driver.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
Stream::Stream(Device *device, size_t interface, usb_interface_list *List
|
Stream::Stream(Device* device, size_t interface, usb_interface_list* List)
|
||||||
/*, bool isInput, uint32 HWChannel*/)
|
|
||||||
:
|
:
|
||||||
AudioStreamingInterface(&device->AudioControl(), interface, List),
|
AudioStreamingInterface(&device->AudioControl(), interface, List),
|
||||||
fDevice(device),
|
fDevice(device),
|
||||||
@@ -30,7 +31,6 @@ Stream::Stream(Device *device, size_t interface, usb_interface_list *List
|
|||||||
fPacketSize(0),
|
fPacketSize(0),
|
||||||
fProcessedBuffers(0)
|
fProcessedBuffers(0)
|
||||||
{
|
{
|
||||||
memset(&fFormat, 0, sizeof(_multi_format));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -107,10 +107,11 @@ Stream::_ChooseAlternate()
|
|||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ASEndpointDescriptor* endpoint = fAlternates[
|
const ASEndpointDescriptor* endpoint
|
||||||
fActiveAlternate]->Endpoint();
|
= fAlternates[fActiveAlternate]->Endpoint();
|
||||||
fIsInput = (endpoint->fEndpointAddress & USB_ENDPOINT_ADDR_DIR_IN)
|
fIsInput = (endpoint->fEndpointAddress & USB_ENDPOINT_ADDR_DIR_IN)
|
||||||
== USB_ENDPOINT_ADDR_DIR_IN;
|
== USB_ENDPOINT_ADDR_DIR_IN;
|
||||||
|
|
||||||
TRACE("Alternate %d EP:%x selected for %s!\n",
|
TRACE("Alternate %d EP:%x selected for %s!\n",
|
||||||
fActiveAlternate, endpoint->fEndpointAddress,
|
fActiveAlternate, endpoint->fEndpointAddress,
|
||||||
fIsInput ? "recording" : "playback");
|
fIsInput ? "recording" : "playback");
|
||||||
@@ -158,8 +159,8 @@ Stream::_SetupBuffers()
|
|||||||
B_READ_AREA | B_WRITE_AREA);
|
B_READ_AREA | B_WRITE_AREA);
|
||||||
|
|
||||||
if (fArea < 0) {
|
if (fArea < 0) {
|
||||||
TRACE_ALWAYS("Error of creating %#x - bytes size buffer area:%#010x\n",
|
TRACE_ALWAYS("Error of creating %#x - "
|
||||||
fAreaSize, fArea);
|
"bytes size buffer area:%#010x\n", fAreaSize, fArea);
|
||||||
fStatus = fArea;
|
fStatus = fArea;
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
@@ -221,22 +222,6 @@ Stream::OnSetConfiguration(usb_device device,
|
|||||||
fStreamEndpoint = interface->endpoint[i].handle;
|
fStreamEndpoint = interface->endpoint[i].handle;
|
||||||
TRACE("%s Stream Endpoint [address %#04x] handle is: %#010x.\n",
|
TRACE("%s Stream Endpoint [address %#04x] handle is: %#010x.\n",
|
||||||
fIsInput ? "Input" : "Output", address, fStreamEndpoint);
|
fIsInput ? "Input" : "Output", address, fStreamEndpoint);
|
||||||
/*
|
|
||||||
size_t actualLength = 0;
|
|
||||||
uint32 speed = 48000;
|
|
||||||
uint8 data[3];
|
|
||||||
data[0] = 0xFF & speed;
|
|
||||||
data[1] = (uint8) 0xFF & speed >> 8;
|
|
||||||
data[2] = (uint8) 0xFF & speed >> 16;
|
|
||||||
|
|
||||||
status_t status = gUSBModule->send_request(device,
|
|
||||||
USB_REQTYPE_CLASS | USB_REQTYPE_ENDPOINT_OUT,
|
|
||||||
UAS_SET_CUR, UAS_SAMPLING_FREQ_CONTROL << 8,
|
|
||||||
address, 3, data, &actualLength);
|
|
||||||
|
|
||||||
TRACE_ALWAYS("set_speed for ep %#x %d: %x\n",
|
|
||||||
address, actualLength, status);
|
|
||||||
*/
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,9 +263,8 @@ Stream::Stop()
|
|||||||
status_t
|
status_t
|
||||||
Stream::_QueueNextTransfer(size_t queuedBuffer, bool start)
|
Stream::_QueueNextTransfer(size_t queuedBuffer, bool start)
|
||||||
{
|
{
|
||||||
TypeIFormatDescriptor* format
|
TypeIFormatDescriptor* format = static_cast<TypeIFormatDescriptor*>(
|
||||||
= static_cast<TypeIFormatDescriptor*>(fAlternates[
|
fAlternates[fActiveAlternate]->Format());
|
||||||
fActiveAlternate]->Format());
|
|
||||||
|
|
||||||
size_t bufferSize = format->fNumChannels * format->fSubframeSize;
|
size_t bufferSize = format->fNumChannels * format->fSubframeSize;
|
||||||
bufferSize *= fSamplesCount / kSamplesBufferCount;
|
bufferSize *= fSamplesCount / kSamplesBufferCount;
|
||||||
@@ -292,26 +276,6 @@ Stream::_QueueNextTransfer(size_t queuedBuffer, bool start)
|
|||||||
TRACE("buffers:%#010x[%#x]\ndescrs:%#010x[%#x]\n",
|
TRACE("buffers:%#010x[%#x]\ndescrs:%#010x[%#x]\n",
|
||||||
buffers + bufferSize * queuedBuffer, bufferSize,
|
buffers + bufferSize * queuedBuffer, bufferSize,
|
||||||
fDescriptors + queuedBuffer * packetsCount, packetsCount);
|
fDescriptors + queuedBuffer * packetsCount, packetsCount);
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
static int16 sin[24] = { 0, 4277, 8481, 12540, 16384, 19948, 23170, 25996,
|
|
||||||
28378, 30273, 31651, 32487, 32767, 32487, 31651, 30273, 28378, 25996,
|
|
||||||
23170, 19948, 16384, 12540, 8481, 4277 };
|
|
||||||
static uint16 sample = 0;
|
|
||||||
static bool sign = true;
|
|
||||||
|
|
||||||
uint16* b = (uint16*)(buffers + bufferSize * queuedBuffer);
|
|
||||||
size_t length = bufferSize;
|
|
||||||
for (size_t u = 0; u < length / 2; u += 2) {
|
|
||||||
b[u] = b[u + 1] = sign ? sin[sample] : -sin[sample];
|
|
||||||
sample ++;
|
|
||||||
if (sample == 24) {
|
|
||||||
sample = 0;
|
|
||||||
sign = !sign;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
status_t status = gUSBModule->queue_isochronous(fStreamEndpoint,
|
status_t status = gUSBModule->queue_isochronous(fStreamEndpoint,
|
||||||
buffers + bufferSize * queuedBuffer, bufferSize,
|
buffers + bufferSize * queuedBuffer, bufferSize,
|
||||||
@@ -342,9 +306,8 @@ Stream::_TransferCallback(void *cookie, int32 status, void *data,
|
|||||||
|
|
||||||
/*status_t result =*/ stream->_QueueNextTransfer(stream->fCurrentBuffer, false);
|
/*status_t result =*/ stream->_QueueNextTransfer(stream->fCurrentBuffer, false);
|
||||||
|
|
||||||
if (atomic_add(&stream->fProcessedBuffers, 1) > (int32)kSamplesBufferCount) {
|
if (atomic_add(&stream->fProcessedBuffers, 1) > (int32)kSamplesBufferCount)
|
||||||
TRACE_ALWAYS("Processed buffers overflow:%d\n", stream->fProcessedBuffers);
|
TRACE_ALWAYS("Processed buffers overflow:%d\n", stream->fProcessedBuffers);
|
||||||
}
|
|
||||||
|
|
||||||
release_sem_etc(stream->fDevice->fBuffersReadySem, 1, B_DO_NOT_RESCHEDULE);
|
release_sem_etc(stream->fDevice->fBuffersReadySem, 1, B_DO_NOT_RESCHEDULE);
|
||||||
|
|
||||||
@@ -359,21 +322,19 @@ Stream::_DumpDescriptors()
|
|||||||
//size_t packetsCount = fDescriptorsCount / kSamplesBufferCount;
|
//size_t packetsCount = fDescriptorsCount / kSamplesBufferCount;
|
||||||
size_t from = /*fCurrentBuffer > 0 ? packetsCount :*/ 0 ;
|
size_t from = /*fCurrentBuffer > 0 ? packetsCount :*/ 0 ;
|
||||||
size_t to = /*fCurrentBuffer > 0 ?*/ fDescriptorsCount /*: packetsCount*/ ;
|
size_t to = /*fCurrentBuffer > 0 ?*/ fDescriptorsCount /*: packetsCount*/ ;
|
||||||
for (size_t i = from; i < to; i++) {
|
for (size_t i = from; i < to; i++)
|
||||||
TRACE("%d:req_len:%d; act_len:%d; stat:%#010x\n", i,
|
TRACE("%d:req_len:%d; act_len:%d; stat:%#010x\n", i,
|
||||||
fDescriptors[i].request_length, fDescriptors[i].actual_length,
|
fDescriptors[i].request_length, fDescriptors[i].actual_length,
|
||||||
fDescriptors[i].status);
|
fDescriptors[i].status);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Stream::GetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
|
Stream::GetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
|
||||||
{
|
{
|
||||||
AudioChannelCluster* cluster = ChannelCluster();
|
AudioChannelCluster* cluster = ChannelCluster();
|
||||||
if (cluster == 0) {
|
if (cluster == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < cluster->ChannelsCount(); i++) {
|
for (size_t i = 0; i < cluster->ChannelsCount(); i++) {
|
||||||
B_SET_CHANNEL(Enable->enable_bits, offset++, true);
|
B_SET_CHANNEL(Enable->enable_bits, offset++, true);
|
||||||
@@ -388,14 +349,12 @@ status_t
|
|||||||
Stream::SetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
|
Stream::SetEnabledChannels(uint32& offset, multi_channel_enable* Enable)
|
||||||
{
|
{
|
||||||
AudioChannelCluster* cluster = ChannelCluster();
|
AudioChannelCluster* cluster = ChannelCluster();
|
||||||
if (cluster == 0) {
|
if (cluster == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < cluster->ChannelsCount(); i++) {
|
for (size_t i = 0; i < cluster->ChannelsCount(); i++)
|
||||||
TRACE("%s channel %d.\n", (B_TEST_CHANNEL(Enable->enable_bits, offset++)
|
TRACE("%s channel %d.\n", (B_TEST_CHANNEL(Enable->enable_bits, offset++)
|
||||||
? "Enable" : "Disable"), offset + 1);
|
? "Enable" : "Disable"), offset + 1);
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -494,8 +453,7 @@ Stream::GetBuffers(multi_buffer_list* List)
|
|||||||
List->return_playback_buffer_size, List->return_playback_buffers);
|
List->return_playback_buffer_size, List->return_playback_buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeIFormatDescriptor* format
|
TypeIFormatDescriptor* format = static_cast<TypeIFormatDescriptor*>(
|
||||||
= static_cast<TypeIFormatDescriptor*>(
|
|
||||||
fAlternates[fActiveAlternate]->Format());
|
fAlternates[fActiveAlternate]->Format());
|
||||||
// const ASEndpointDescriptor* endpoint
|
// const ASEndpointDescriptor* endpoint
|
||||||
// = fAlternates[fActiveAlternate]->Endpoint();
|
// = fAlternates[fActiveAlternate]->Endpoint();
|
||||||
@@ -505,8 +463,7 @@ Stream::GetBuffers(multi_buffer_list* List)
|
|||||||
TRACE("%s buffer #%d:\n", fIsInput ? "input" : "output", buffer + 1);
|
TRACE("%s buffer #%d:\n", fIsInput ? "input" : "output", buffer + 1);
|
||||||
|
|
||||||
for (size_t channel = startChannel;
|
for (size_t channel = startChannel;
|
||||||
channel < format->fNumChannels; channel++)
|
channel < format->fNumChannels; channel++) {
|
||||||
{
|
|
||||||
// init stride to the same for all buffers
|
// init stride to the same for all buffers
|
||||||
uint32 stride = format->fSubframeSize * format->fNumChannels;
|
uint32 stride = format->fSubframeSize * format->fNumChannels;
|
||||||
Buffers[buffer][channel].stride = stride;
|
Buffers[buffer][channel].stride = stride;
|
||||||
@@ -528,7 +485,8 @@ Stream::GetBuffers(multi_buffer_list* List)
|
|||||||
|
|
||||||
if (fIsInput) {
|
if (fIsInput) {
|
||||||
List->return_record_channels += format->fNumChannels;
|
List->return_record_channels += format->fNumChannels;
|
||||||
TRACE("return_record_channels:%#010x\n", List->return_record_channels);
|
TRACE("return_record_channels:%#010x\n",
|
||||||
|
List->return_record_channels);
|
||||||
} else {
|
} else {
|
||||||
List->return_playback_channels += format->fNumChannels;
|
List->return_playback_channels += format->fNumChannels;
|
||||||
TRACE("return_playback_channels:%#010x\n",
|
TRACE("return_playback_channels:%#010x\n",
|
||||||
@@ -563,18 +521,3 @@ Stream::ExchangeBuffer(multi_buffer_info* Info)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ASInterfaceDescriptor*
|
|
||||||
Stream::ASInterface()
|
|
||||||
{
|
|
||||||
return fAlternates[fActiveAlternate]->Interface();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_ASFormatDescriptor*
|
|
||||||
Stream::ASFormat()
|
|
||||||
{
|
|
||||||
return fAlternates[fActiveAlternate]->Format();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Driver for USB Audio Device Class devices.
|
* Driver for USB Audio Device Class devices.
|
||||||
* Copyright (c) 2009,10,12 S.Zharski <imker@gmx.li>
|
* Copyright (c) 2009-13 S.Zharski <imker@gmx.li>
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef _STREAM_H_
|
#ifndef _USB_AUDIO_STREAM_H_
|
||||||
#define _STREAM_H_
|
#define _USB_AUDIO_STREAM_H_
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
|
|
||||||
#include "AudioStreamingInterface.h"
|
#include "AudioStreamingInterface.h"
|
||||||
|
|
||||||
class Device;
|
|
||||||
|
|
||||||
// typedef Vector<AudioStreamAlternate*> StreamAlternatesVector;
|
class Device;
|
||||||
// typedef Vector<AudioStreamAlternate*>::Iterator StreamAlternatesIterator;
|
|
||||||
|
|
||||||
class Stream : public AudioStreamingInterface {
|
class Stream : public AudioStreamingInterface {
|
||||||
friend class Device;
|
friend class Device;
|
||||||
public:
|
public:
|
||||||
Stream(Device* device, size_t interface,
|
Stream(Device* device, size_t interface,
|
||||||
usb_interface_list *List
|
usb_interface_list* List);
|
||||||
/*, bool isInput, uint32 HWChannel*/);
|
|
||||||
~Stream();
|
~Stream();
|
||||||
|
|
||||||
status_t Init();
|
status_t Init();
|
||||||
status_t InitCheck() { return fStatus; }
|
status_t InitCheck() { return fStatus; }
|
||||||
|
|
||||||
@@ -37,11 +33,6 @@ public:
|
|||||||
const usb_configuration_info* config);
|
const usb_configuration_info* config);
|
||||||
|
|
||||||
bool ExchangeBuffer(multi_buffer_info* Info);
|
bool ExchangeBuffer(multi_buffer_info* Info);
|
||||||
/*
|
|
||||||
int32 InterruptHandler(uint32 SignaledChannelsMask);
|
|
||||||
*/
|
|
||||||
// ASInterfaceDescriptor* ASInterface();
|
|
||||||
// _ASFormatDescriptor* ASFormat();
|
|
||||||
status_t GetEnabledChannels(uint32& offset,
|
status_t GetEnabledChannels(uint32& offset,
|
||||||
multi_channel_enable* Enable);
|
multi_channel_enable* Enable);
|
||||||
status_t SetEnabledChannels(uint32& offset,
|
status_t SetEnabledChannels(uint32& offset,
|
||||||
@@ -49,16 +40,11 @@ public:
|
|||||||
status_t GetGlobalFormat(multi_format_info* Format);
|
status_t GetGlobalFormat(multi_format_info* Format);
|
||||||
status_t SetGlobalFormat(multi_format_info* Format);
|
status_t SetGlobalFormat(multi_format_info* Format);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Device* fDevice;
|
Device* fDevice;
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
|
|
||||||
// alternates of the streams
|
|
||||||
// StreamAlternatesVector fAlternates;
|
|
||||||
// size_t fActiveAlternate;
|
|
||||||
|
|
||||||
uint8 fTerminalID;
|
uint8 fTerminalID;
|
||||||
usb_pipe fStreamEndpoint;
|
usb_pipe fStreamEndpoint;
|
||||||
bool fIsRunning;
|
bool fIsRunning;
|
||||||
@@ -71,7 +57,6 @@ protected:
|
|||||||
size_t fSamplesCount;
|
size_t fSamplesCount;
|
||||||
size_t fPacketSize;
|
size_t fPacketSize;
|
||||||
int32 fProcessedBuffers;
|
int32 fProcessedBuffers;
|
||||||
_multi_format fFormat;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _ChooseAlternate();
|
status_t _ChooseAlternate();
|
||||||
@@ -82,14 +67,6 @@ static void _TransferCallback(void *cookie, int32 status,
|
|||||||
void _DumpDescriptors();
|
void _DumpDescriptors();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
class RecordStream : public Stream {
|
|
||||||
public:
|
|
||||||
RecordStream(Device* device, uint32 HWChannel);
|
|
||||||
~RecordStream();
|
|
||||||
status_t Start();
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif // _STREAM_H_
|
#endif // _USB_AUDIO_STREAM_H_
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,11 @@
|
|||||||
* And the USB Device Class Definition for Audio Formats Release 1.0
|
* And the USB Device Class Definition for Audio Formats Release 1.0
|
||||||
* (March 18, 1998)
|
* (March 18, 1998)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __USB_AUDIO_SPEC_H__
|
#ifndef __USB_AUDIO_SPEC_H__
|
||||||
#define __USB_AUDIO_SPEC_H__
|
#define __USB_AUDIO_SPEC_H__
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
## BeOS Generic Makefile v2.2 ##
|
|
||||||
|
|
||||||
## Fill in this file to specify the project being created, and the referenced
|
|
||||||
## makefile-engine will do all of the hard work for you. This handles both
|
|
||||||
## Intel and PowerPC builds of the BeOS.
|
|
||||||
|
|
||||||
## Application Specific Settings ---------------------------------------------
|
|
||||||
|
|
||||||
# specify the name of the binary
|
|
||||||
NAME=usb_audio
|
|
||||||
|
|
||||||
# specify the type of binary
|
|
||||||
# APP: Application
|
|
||||||
# SHARED: Shared library or add-on
|
|
||||||
# STATIC: Static library archive
|
|
||||||
# DRIVER: Kernel Driver
|
|
||||||
TYPE=DRIVER
|
|
||||||
|
|
||||||
# add support for new Pe and Eddie features
|
|
||||||
# to fill in generic makefile
|
|
||||||
|
|
||||||
#%{
|
|
||||||
# @src->@
|
|
||||||
|
|
||||||
# specify the source files to use
|
|
||||||
# full paths or paths relative to the makefile can be included
|
|
||||||
# all files, regardless of directory, will have their object
|
|
||||||
# files created in the common object directory.
|
|
||||||
# Note that this means this makefile will not work correctly
|
|
||||||
# if two source files with the same name (source.c or source.cpp)
|
|
||||||
# are included from different directories. Also note that spaces
|
|
||||||
# in folder names do not work well with this makefile.
|
|
||||||
SRCS=Driver.cpp\
|
|
||||||
Device.cpp\
|
|
||||||
AudioControlInterface.cpp\
|
|
||||||
AudioStreamingInterface.cpp\
|
|
||||||
Stream.cpp\
|
|
||||||
Settings.cpp
|
|
||||||
|
|
||||||
# specify the resource files to use
|
|
||||||
# full path or a relative path to the resource file can be used.
|
|
||||||
RSRCS=
|
|
||||||
|
|
||||||
# @<-src@
|
|
||||||
#%}
|
|
||||||
|
|
||||||
# end support for Pe and Eddie
|
|
||||||
|
|
||||||
# specify additional libraries to link against
|
|
||||||
# there are two acceptable forms of library specifications
|
|
||||||
# - if your library follows the naming pattern of:
|
|
||||||
# libXXX.so or libXXX.a you can simply specify XXX
|
|
||||||
# library: libbe.so entry: be
|
|
||||||
#
|
|
||||||
# - if your library does not follow the standard library
|
|
||||||
# naming scheme you need to specify the path to the library
|
|
||||||
# and it's name
|
|
||||||
# library: my_lib.a entry: my_lib.a or path/my_lib.a
|
|
||||||
LIBS=
|
|
||||||
|
|
||||||
# specify additional paths to directories following the standard
|
|
||||||
# libXXX.so or libXXX.a naming scheme. You can specify full paths
|
|
||||||
# or paths relative to the makefile. The paths included may not
|
|
||||||
# be recursive, so include all of the paths where libraries can
|
|
||||||
# be found. Directories where source files are found are
|
|
||||||
# automatically included.
|
|
||||||
LIBPATHS=
|
|
||||||
|
|
||||||
# additional paths to look for system headers
|
|
||||||
# thes use the form: #include <header>
|
|
||||||
# source file directories are NOT auto-included here
|
|
||||||
SYSTEM_INCLUDE_PATHS=../../../../../../headers/private/kernel \
|
|
||||||
../../../../../../headers/private/kernel/util \
|
|
||||||
../../../../../../headers/private/media
|
|
||||||
|
|
||||||
# additional paths to look for local headers
|
|
||||||
# thes use the form: #include "header"
|
|
||||||
# source file directories are automatically included
|
|
||||||
LOCAL_INCLUDE_PATHS=../../../../../../build/config_headers
|
|
||||||
|
|
||||||
# specify the level of optimization that you desire
|
|
||||||
# NONE, SOME, FULL
|
|
||||||
OPTIMIZE=
|
|
||||||
|
|
||||||
# specify any preprocessor symbols to be defined. The symbols will not
|
|
||||||
# have their values set automatically; you must supply the value (if any)
|
|
||||||
# to use. For example, setting DEFINES to "DEBUG=1" will cause the
|
|
||||||
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG"
|
|
||||||
# would pass "-DDEBUG" on the compiler's command line.
|
|
||||||
DEFINES=
|
|
||||||
|
|
||||||
# specify special warning levels
|
|
||||||
# if unspecified default warnings will be used
|
|
||||||
# NONE = supress all warnings
|
|
||||||
# ALL = enable all warnings
|
|
||||||
WARNINGS=ALL
|
|
||||||
|
|
||||||
# specify whether image symbols will be created
|
|
||||||
# so that stack crawls in the debugger are meaningful
|
|
||||||
# if TRUE symbols will be created
|
|
||||||
SYMBOLS=
|
|
||||||
|
|
||||||
# specify debug settings
|
|
||||||
# if TRUE will allow application to be run from a source-level
|
|
||||||
# debugger. Note that this will disable all optimzation.
|
|
||||||
DEBUGGER=
|
|
||||||
|
|
||||||
# specify additional compiler flags for all files
|
|
||||||
COMPILER_FLAGS=
|
|
||||||
|
|
||||||
# specify additional linker flags
|
|
||||||
LINKER_FLAGS=
|
|
||||||
|
|
||||||
# specify the version of this particular item
|
|
||||||
# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL")
|
|
||||||
# This may also be specified in a resource.
|
|
||||||
APP_VERSION=
|
|
||||||
|
|
||||||
# (for TYPE == DRIVER only) Specify desired location of driver in the /dev
|
|
||||||
# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will
|
|
||||||
# instruct the driverinstall rule to place a symlink to your driver's binary in
|
|
||||||
# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at
|
|
||||||
# /dev/video/usb when loaded. Default is "misc".
|
|
||||||
DRIVER_PATH=audio/hmulti
|
|
||||||
|
|
||||||
## include the makefile-engine
|
|
||||||
include $(BUILDHOME)/etc/makefile-engine
|
|
||||||
Reference in New Issue
Block a user