|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. ! 24: * ! 25: * HISTORY ! 26: * ! 27: */ ! 28: ! 29: #include <libkern/OSByteOrder.h> ! 30: #include "AppleComposite.h" ! 31: #include <IOKit/usb/IOUSBInterface.h> ! 32: ! 33: #include <IOKit/assert.h> ! 34: ! 35: #define super IOService ! 36: #define DEBUGGING_LEVEL 0 ! 37: ! 38: OSDefineMetaClassAndStructors(AppleComposite, IOService) ! 39: ! 40: bool AppleComposite::start(IOService * provider) ! 41: { ! 42: IOReturn err = 0; ! 43: UInt8 configNum; ! 44: IOUSBDevice::FindInterfaceRequest req; ! 45: IOUSBInterface * interface; ! 46: IOUSBDevice * device; ! 47: ! 48: if( !super::start(provider)) ! 49: return (false); ! 50: ! 51: // get my device ! 52: device = OSDynamicCast(IOUSBDevice, provider); ! 53: if(!device) ! 54: return false; ! 55: ! 56: do { ! 57: #if (DEBUGGING_LEVEL > 0) ! 58: IOLog("%s: USB Generic Composite @ %d\n", getName(), _device->address()); ! 59: #endif ! 60: // Find the first config/interface ! 61: if (device->deviceDescriptor()->numConf < 1) ! 62: { ! 63: IOLog("%s: no composite configurations\n", getName()); ! 64: continue; ! 65: } ! 66: ! 67: req.theClass = req.subClass = req.protocol = 0; ! 68: req.maxPower = 0; ! 69: if ((interface = device->findNextInterface(NULL, &req)) == 0) ! 70: { ! 71: IOLog("%s: no interface found\n", getName()); ! 72: continue; ! 73: } ! 74: ! 75: configNum = interface->getConfigValue(); ! 76: ! 77: // set my configuration ! 78: if ((err = device->SetConfiguration(configNum))) ! 79: continue; ! 80: ! 81: #if (DEBUGGING_LEVEL > 0) ! 82: printInterfaceDescriptor(interface->descriptor); ! 83: #endif ! 84: // Set up interface for matching, and release it. ! 85: // it's also held by the device (which it is attached to) ! 86: interface->registerService(); ! 87: interface->release(); ! 88: ! 89: // create a new IOUSBInterface nub for each interface ! 90: // with the same configuration. ! 91: do { ! 92: req.theClass = req.subClass = req.protocol = 0; ! 93: req.maxPower = 0; ! 94: interface = device->findNextInterface(interface, &req); ! 95: if (interface == 0) ! 96: { ! 97: break; ! 98: } ! 99: if(interface->getConfigValue() == configNum) ! 100: interface->registerService(); ! 101: interface->release(); ! 102: } while (true); ! 103: ! 104: return(true); ! 105: ! 106: } while (false); ! 107: ! 108: IOLog("%s: aborting startup. err = %d\n", getName(), err); ! 109: ! 110: return(false); ! 111: } ! 112: ! 113:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.