1# Copyright 2015 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""This module provides the USB Controller interface.""" 6 7 8class USBController(object): 9 """An abstraction of USB audio gadget driver controller on Chameleon. 10 11 It provides methods to control the USB gadget driver on Chameleon. 12 13 A ChameleonConnection object is passed to the construction. 14 15 """ 16 def __init__(self, chameleon_connection): 17 """Constructs an USBController. 18 19 @param chameleon_connection: A ChameleonConnection object. 20 21 """ 22 self._chameleond_proxy = chameleon_connection.chameleond_proxy 23 24 25 def set_playback_configs(self, playback_data_format): 26 """Sets the playback configurations for the USB gadget driver. 27 28 @param playback_data_format: A 4-entry dictionary with following fields: 29 'file_type', 'sample_format', 'channel' and 30 'rate'. For e.g., 31 format = { 32 'file_type': 'raw', 33 'sample_format': 'S16_LE', 34 'channel': 2, 35 'rate': 48000 36 } 37 38 """ 39 self._chameleond_proxy.SetUSBDriverPlaybackConfigs(playback_data_format) 40 41 42 def set_capture_configs(self, port_id, capture_data_foramt): 43 """Sets the capture configurations for the USB gadget driver. 44 45 @param capture_data_format: A 4-entry dictionary with following fields: 46 'file_type', 'sample_format', 'channel' and 47 'rate'. For e.g., 48 format = { 49 'file_type': 'raw', 50 'sample_format': 'S16_LE', 51 'channel': 2, 52 'rate': 48000 53 } 54 55 """ 56 self._chameleond_proxy.SetUSBDriverCaptureConfigs(capture_data_foramt) 57