Linux Audio

Check our new training course

Loading...
  1/* SPDX-License-Identifier: BSD-3-Clause */
  2/*
  3 * Copyright (c) 2015-2016 Google Inc.
  4 */
  5/*
  6 * This is a special protocol for configuring communication over the
  7 * I2S bus between the DSP on the MSM8994 and APBridgeA.  Therefore,
  8 * we can predefine several low-level attributes of the communication
  9 * because we know that they are supported.  In particular, the following
 10 * assumptions are made:
 11 *	- there are two channels (i.e., stereo)
 12 *	- the low-level protocol is I2S as defined by Philips/NXP
 13 *	- the DSP on the MSM8994 is the clock master for MCLK, BCLK, and WCLK
 14 *	- WCLK changes on the falling edge of BCLK
 15 *	- WCLK low for left channel; high for right channel
 16 *	- TX data is sent on the falling edge of BCLK
 17 *	- RX data is received/latched on the rising edge of BCLK
 18 */
 19
 20#ifndef __AUDIO_APBRIDGEA_H
 21#define __AUDIO_APBRIDGEA_H
 22
 23#define AUDIO_APBRIDGEA_TYPE_SET_CONFIG			0x01
 24#define AUDIO_APBRIDGEA_TYPE_REGISTER_CPORT		0x02
 25#define AUDIO_APBRIDGEA_TYPE_UNREGISTER_CPORT		0x03
 26#define AUDIO_APBRIDGEA_TYPE_SET_TX_DATA_SIZE		0x04
 27							/* 0x05 unused */
 28#define AUDIO_APBRIDGEA_TYPE_PREPARE_TX			0x06
 29#define AUDIO_APBRIDGEA_TYPE_START_TX			0x07
 30#define AUDIO_APBRIDGEA_TYPE_STOP_TX			0x08
 31#define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_TX		0x09
 32#define AUDIO_APBRIDGEA_TYPE_SET_RX_DATA_SIZE		0x0a
 33							/* 0x0b unused */
 34#define AUDIO_APBRIDGEA_TYPE_PREPARE_RX			0x0c
 35#define AUDIO_APBRIDGEA_TYPE_START_RX			0x0d
 36#define AUDIO_APBRIDGEA_TYPE_STOP_RX			0x0e
 37#define AUDIO_APBRIDGEA_TYPE_SHUTDOWN_RX		0x0f
 38
 39#define AUDIO_APBRIDGEA_PCM_FMT_8			BIT(0)
 40#define AUDIO_APBRIDGEA_PCM_FMT_16			BIT(1)
 41#define AUDIO_APBRIDGEA_PCM_FMT_24			BIT(2)
 42#define AUDIO_APBRIDGEA_PCM_FMT_32			BIT(3)
 43#define AUDIO_APBRIDGEA_PCM_FMT_64			BIT(4)
 44
 45#define AUDIO_APBRIDGEA_PCM_RATE_5512			BIT(0)
 46#define AUDIO_APBRIDGEA_PCM_RATE_8000			BIT(1)
 47#define AUDIO_APBRIDGEA_PCM_RATE_11025			BIT(2)
 48#define AUDIO_APBRIDGEA_PCM_RATE_16000			BIT(3)
 49#define AUDIO_APBRIDGEA_PCM_RATE_22050			BIT(4)
 50#define AUDIO_APBRIDGEA_PCM_RATE_32000			BIT(5)
 51#define AUDIO_APBRIDGEA_PCM_RATE_44100			BIT(6)
 52#define AUDIO_APBRIDGEA_PCM_RATE_48000			BIT(7)
 53#define AUDIO_APBRIDGEA_PCM_RATE_64000			BIT(8)
 54#define AUDIO_APBRIDGEA_PCM_RATE_88200			BIT(9)
 55#define AUDIO_APBRIDGEA_PCM_RATE_96000			BIT(10)
 56#define AUDIO_APBRIDGEA_PCM_RATE_176400			BIT(11)
 57#define AUDIO_APBRIDGEA_PCM_RATE_192000			BIT(12)
 58
 59#define AUDIO_APBRIDGEA_DIRECTION_TX			BIT(0)
 60#define AUDIO_APBRIDGEA_DIRECTION_RX			BIT(1)
 61
 62/* The I2S port is passed in the 'index' parameter of the USB request */
 63/* The CPort is passed in the 'value' parameter of the USB request */
 64
 65struct audio_apbridgea_hdr {
 66	__u8	type;
 67	__le16	i2s_port;
 68	__u8	data[];
 69} __packed;
 70
 71struct audio_apbridgea_set_config_request {
 72	struct audio_apbridgea_hdr	hdr;
 73	__le32				format;	/* AUDIO_APBRIDGEA_PCM_FMT_* */
 74	__le32				rate;	/* AUDIO_APBRIDGEA_PCM_RATE_* */
 75	__le32				mclk_freq; /* XXX Remove? */
 76} __packed;
 77
 78struct audio_apbridgea_register_cport_request {
 79	struct audio_apbridgea_hdr	hdr;
 80	__le16				cport;
 81	__u8				direction;
 82} __packed;
 83
 84struct audio_apbridgea_unregister_cport_request {
 85	struct audio_apbridgea_hdr	hdr;
 86	__le16				cport;
 87	__u8				direction;
 88} __packed;
 89
 90struct audio_apbridgea_set_tx_data_size_request {
 91	struct audio_apbridgea_hdr	hdr;
 92	__le16				size;
 93} __packed;
 94
 95struct audio_apbridgea_prepare_tx_request {
 96	struct audio_apbridgea_hdr	hdr;
 97} __packed;
 98
 99struct audio_apbridgea_start_tx_request {
100	struct audio_apbridgea_hdr	hdr;
101	__le64				timestamp;
102} __packed;
103
104struct audio_apbridgea_stop_tx_request {
105	struct audio_apbridgea_hdr	hdr;
106} __packed;
107
108struct audio_apbridgea_shutdown_tx_request {
109	struct audio_apbridgea_hdr	hdr;
110} __packed;
111
112struct audio_apbridgea_set_rx_data_size_request {
113	struct audio_apbridgea_hdr	hdr;
114	__le16				size;
115} __packed;
116
117struct audio_apbridgea_prepare_rx_request {
118	struct audio_apbridgea_hdr	hdr;
119} __packed;
120
121struct audio_apbridgea_start_rx_request {
122	struct audio_apbridgea_hdr	hdr;
123} __packed;
124
125struct audio_apbridgea_stop_rx_request {
126	struct audio_apbridgea_hdr	hdr;
127} __packed;
128
129struct audio_apbridgea_shutdown_rx_request {
130	struct audio_apbridgea_hdr	hdr;
131} __packed;
132
133#endif /*__AUDIO_APBRIDGEA_H */