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