10a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean/* 20a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * Copyright (C) 2014 The Android Open Source Project 30a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * 40a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * Licensed under the Apache License, Version 2.0 (the "License"); 50a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * you may not use this file except in compliance with the License. 60a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * You may obtain a copy of the License at 70a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * 80a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * http://www.apache.org/licenses/LICENSE-2.0 90a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * 100a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * Unless required by applicable law or agreed to in writing, software 110a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * distributed under the License is distributed on an "AS IS" BASIS, 120a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * See the License for the specific language governing permissions an 140a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean * limitations under the License. 150a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean */ 160a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 170a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLeanpackage com.android.server.usb; 180a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 190a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLeanpublic final class UsbAudioDevice { 200a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean private static final String TAG = "UsbAudioDevice"; 210a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean protected static final boolean DEBUG = false; 220a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 230a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public int mCard; 240a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public int mDevice; 250a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public boolean mHasPlayback; 260a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public boolean mHasCapture; 270a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 280a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean // Device "class" flags 290a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceClassMask = 0x00FFFFFF; 300a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceClass_Undefined = 0x00000000; 310a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceClass_Internal = 0x00000001; 320a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceClass_External = 0x00000002; 330a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean // Device meta-data flags 340a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceMetaMask = 0xFF000000; 350a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public static final int kAudioDeviceMeta_Alsa = 0x80000000; 360a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean // This member is a combination of the above bit-flags 370a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public int mDeviceClass; 380a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 390a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public String mDeviceName = ""; 400a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public String mDeviceDescription = ""; 410a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 420a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public UsbAudioDevice(int card, int device, 4310024b3dc12a8552c1547b67810c77b865045cc8Mike Lockwood boolean hasPlayback, boolean hasCapture, int deviceClass) { 440a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean mCard = card; 450a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean mDevice = device; 460a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean mHasPlayback = hasPlayback; 470a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean mHasCapture = hasCapture; 480a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean mDeviceClass = deviceClass; 490a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean } 500a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 510a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public String toString() { 520a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean StringBuilder sb = new StringBuilder(); 530a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append("UsbAudioDevice: [card: " + mCard); 540a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append(", device: " + mDevice); 550a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append(", name: " + mDeviceName); 560a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append(", hasPlayback: " + mHasPlayback); 570a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append(", hasCapture: " + mHasCapture); 580a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean sb.append(", class: 0x" + Integer.toHexString(mDeviceClass) + "]"); 590a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean return sb.toString(); 600a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean } 610a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 620a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean public String toShortString() { 630a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean return "[card:" + mCard + " device:" + mDevice + " " + mDeviceName + "]"; 640a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean } 650a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean} 660a8f06922f288bfa4a22a7cd45dd5b89a9563e54Paul McLean 67