1 // SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2015-2016 Google Inc.
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.
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.
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
44 #ifndef __AUDIO_APBRIDGEA_H
45 #define __AUDIO_APBRIDGEA_H
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
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
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
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)
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)
83 #define AUDIO_APBRIDGEA_DIRECTION_TX BIT(0)
84 #define AUDIO_APBRIDGEA_DIRECTION_RX BIT(1)
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 */
89 struct audio_apbridgea_hdr {
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? */
102 struct audio_apbridgea_register_cport_request {
103 struct audio_apbridgea_hdr hdr;
108 struct audio_apbridgea_unregister_cport_request {
109 struct audio_apbridgea_hdr hdr;
114 struct audio_apbridgea_set_tx_data_size_request {
115 struct audio_apbridgea_hdr hdr;
119 struct audio_apbridgea_prepare_tx_request {
120 struct audio_apbridgea_hdr hdr;
123 struct audio_apbridgea_start_tx_request {
124 struct audio_apbridgea_hdr hdr;
128 struct audio_apbridgea_stop_tx_request {
129 struct audio_apbridgea_hdr hdr;
132 struct audio_apbridgea_shutdown_tx_request {
133 struct audio_apbridgea_hdr hdr;
136 struct audio_apbridgea_set_rx_data_size_request {
137 struct audio_apbridgea_hdr hdr;
141 struct audio_apbridgea_prepare_rx_request {
142 struct audio_apbridgea_hdr hdr;
145 struct audio_apbridgea_start_rx_request {
146 struct audio_apbridgea_hdr hdr;
149 struct audio_apbridgea_stop_rx_request {
150 struct audio_apbridgea_hdr hdr;
153 struct audio_apbridgea_shutdown_rx_request {
154 struct audio_apbridgea_hdr hdr;
157 #endif /*__AUDIO_APBRIDGEA_H */