1 // SPDX-License-Identifier: BSD-3-Clause 2 /** 3 * Copyright (c) 2015-2016 Google Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holder nor the names of its 14 * contributors may be used to endorse or promote products derived from this 15 * software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 /* 30 * This is a special protocol for configuring communication over the 31 * I2S bus between the DSP on the MSM8994 and APBridgeA. Therefore, 32 * we can predefine several low-level attributes of the communication 33 * because we know that they are supported. In particular, the following 34 * assumptions are made: 35 * - there are two channels (i.e., stereo) 36 * - the low-level protocol is I2S as defined by Philips/NXP 37 * - the DSP on the MSM8994 is the clock master for MCLK, BCLK, and WCLK 38 * - WCLK changes on the falling edge of BCLK 39 * - WCLK low for left channel; high for right channel 40 * - TX data is sent on the falling edge of BCLK 41 * - RX data is received/latched on the rising edge of BCLK 42 */ 43 44 #ifndef __AUDIO_APBRIDGEA_H 45 #define __AUDIO_APBRIDGEA_H 46 47 #define AUDIO_APBRIDGEA_TYPE_SET_CONFIG 0x01 48 #define AUDIO_APBRIDGEA_TYPE_REGISTER_CPORT 0x02 49 #define AUDIO_APBRIDGEA_TYPE_UNREGISTER_CPORT 0x03 50 #define AUDIO_APBRIDGEA_TYPE_SET_TX_DATA_SIZE 0x04 51 /* 0x05 unused */ 52 #define AUDIO_APBRIDGEA_TYPE_PREPARE_TX 0x06 53 #define AUDIO_APBRIDGEA_TYPE_START_TX 0x07 54 #define AUDIO_APBRIDGEA_TYPE_STOP_TX 0x08 55 #define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_TX 0x09 56 #define AUDIO_APBRIDGEA_TYPE_SET_RX_DATA_SIZE 0x0a 57 /* 0x0b unused */ 58 #define AUDIO_APBRIDGEA_TYPE_PREPARE_RX 0x0c 59 #define AUDIO_APBRIDGEA_TYPE_START_RX 0x0d 60 #define AUDIO_APBRIDGEA_TYPE_STOP_RX 0x0e 61 #define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_RX 0x0f 62 63 #define AUDIO_APBRIDGEA_PCM_FMT_8 BIT(0) 64 #define AUDIO_APBRIDGEA_PCM_FMT_16 BIT(1) 65 #define AUDIO_APBRIDGEA_PCM_FMT_24 BIT(2) 66 #define AUDIO_APBRIDGEA_PCM_FMT_32 BIT(3) 67 #define AUDIO_APBRIDGEA_PCM_FMT_64 BIT(4) 68 69 #define AUDIO_APBRIDGEA_PCM_RATE_5512 BIT(0) 70 #define AUDIO_APBRIDGEA_PCM_RATE_8000 BIT(1) 71 #define AUDIO_APBRIDGEA_PCM_RATE_11025 BIT(2) 72 #define AUDIO_APBRIDGEA_PCM_RATE_16000 BIT(3) 73 #define AUDIO_APBRIDGEA_PCM_RATE_22050 BIT(4) 74 #define AUDIO_APBRIDGEA_PCM_RATE_32000 BIT(5) 75 #define AUDIO_APBRIDGEA_PCM_RATE_44100 BIT(6) 76 #define AUDIO_APBRIDGEA_PCM_RATE_48000 BIT(7) 77 #define AUDIO_APBRIDGEA_PCM_RATE_64000 BIT(8) 78 #define AUDIO_APBRIDGEA_PCM_RATE_88200 BIT(9) 79 #define AUDIO_APBRIDGEA_PCM_RATE_96000 BIT(10) 80 #define AUDIO_APBRIDGEA_PCM_RATE_176400 BIT(11) 81 #define AUDIO_APBRIDGEA_PCM_RATE_192000 BIT(12) 82 83 #define AUDIO_APBRIDGEA_DIRECTION_TX BIT(0) 84 #define AUDIO_APBRIDGEA_DIRECTION_RX BIT(1) 85 86 /* The I2S port is passed in the 'index' parameter of the USB request */ 87 /* The CPort is passed in the 'value' parameter of the USB request */ 88 89 struct audio_apbridgea_hdr { 90 __u8 type; 91 __le16 i2s_port; 92 __u8 data[0]; 93 } __packed; 94 95 struct audio_apbridgea_set_config_request { 96 struct audio_apbridgea_hdr hdr; 97 __le32 format; /* AUDIO_APBRIDGEA_PCM_FMT_* */ 98 __le32 rate; /* AUDIO_APBRIDGEA_PCM_RATE_* */ 99 __le32 mclk_freq; /* XXX Remove? */ 100 } __packed; 101 102 struct audio_apbridgea_register_cport_request { 103 struct audio_apbridgea_hdr hdr; 104 __le16 cport; 105 __u8 direction; 106 } __packed; 107 108 struct audio_apbridgea_unregister_cport_request { 109 struct audio_apbridgea_hdr hdr; 110 __le16 cport; 111 __u8 direction; 112 } __packed; 113 114 struct audio_apbridgea_set_tx_data_size_request { 115 struct audio_apbridgea_hdr hdr; 116 __le16 size; 117 } __packed; 118 119 struct audio_apbridgea_prepare_tx_request { 120 struct audio_apbridgea_hdr hdr; 121 } __packed; 122 123 struct audio_apbridgea_start_tx_request { 124 struct audio_apbridgea_hdr hdr; 125 __le64 timestamp; 126 } __packed; 127 128 struct audio_apbridgea_stop_tx_request { 129 struct audio_apbridgea_hdr hdr; 130 } __packed; 131 132 struct audio_apbridgea_shutdown_tx_request { 133 struct audio_apbridgea_hdr hdr; 134 } __packed; 135 136 struct audio_apbridgea_set_rx_data_size_request { 137 struct audio_apbridgea_hdr hdr; 138 __le16 size; 139 } __packed; 140 141 struct audio_apbridgea_prepare_rx_request { 142 struct audio_apbridgea_hdr hdr; 143 } __packed; 144 145 struct audio_apbridgea_start_rx_request { 146 struct audio_apbridgea_hdr hdr; 147 } __packed; 148 149 struct audio_apbridgea_stop_rx_request { 150 struct audio_apbridgea_hdr hdr; 151 } __packed; 152 153 struct audio_apbridgea_shutdown_rx_request { 154 struct audio_apbridgea_hdr hdr; 155 } __packed; 156 157 #endif /*__AUDIO_APBRIDGEA_H */ 158