summaryrefslogtreecommitdiff
path: root/include/linux/tegra_avp_audio.h
blob: 2fd15a45eae1ec6f8e09bb11bcaac3868e7e902a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
 * tegra_avp_audio.h - Shared interface between AVP and kernel audio avp driver
 *
 * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#ifndef _TEGRA_AVP_AUDIO_H
#define _TEGRA_AVP_AUDIO_H

#define USE_IRAM_DEVICE_BUFFER  1

/* Runtime profiling options */
#define PROFILE_RENDER_PROCESSING           0x00000001
#define PROFILE_RENDER_OVERALL_PROCESSING  \
	(0x00000002 | PROFILE_RENDER_PROCESSING)
#define PROFILE_RENDER_MEMORY               0x00000004

#define DEVICE_BUFFER_SIZE      (0x1000)

#define RENDERSW_MAX_LOOPBACK_STREAMS        1
#define RENDERSW_MAX_RENDER_STREAMS          4
#define RENDERSW_MAX_STREAMS                 \
	(RENDERSW_MAX_LOOPBACK_STREAMS + RENDERSW_MAX_RENDER_STREAMS)
#define RENDERSW_MAX_CHANNELS                2

#define AAC_PAYLOAD_RAW     0
#define AAC_PAYLOAD_ADTS    1
#define AAC_PAYLOAD_ADIF    2
#define AAC_PAYLOAD_LOAS    3

enum KSSTATE {
	KSSTATE_STOP,
	KSSTATE_ACQUIRE,
	KSSTATE_PAUSE,
	KSSTATE_RUN,

	KSSTATE_Force32 = 0x7fffffff
};

enum audio_format {
	FORMAT_PCM,
	FORMAT_MP3,
	FORMAT_AAC,
	FORMAT_WMA,
	FORMAT_NUM,
};

enum {
	CODEC_PCM = 0,
	CODEC_MP3 = 1,
	CODEC_AAC = 2,
	CODEC_WMA = 3,
	NUM_CODECS,
};

enum avp_audio_stream_id {
	loopback_stream_id = 0,
	pcm_stream_id,
	pcm2_stream_id,
	decode_stream_id,
	decode2_stream_id,
	max_stream_id
};

enum tegra_arch {
	NV_TEGRA_T20 = 0x20,
	NV_TEGRA_T30 = 0x30,
	NV_TEGRA_T114 = 0x35,
	NV_TEGRA_T148 = 0x14,
	NV_TEGRA_T124 = 0x40,
	NV_TEGRA_Force32 = 0x7FFFFFFF
};

enum aac_profile {
	AAC_PROFILE_MAIN,
	AAC_PROFILE_LC,
	AAC_PROFILE_SSR,
};

enum ucode_desc_params {
	UCODE_DESC_OFFSET,
	UCODE_DESC_SIZE,
	UCODE_DESC_NUM,
};

struct audio_params {
	unsigned int                rate;
	unsigned int                channels;
	unsigned int                bits_per_sample;
};

struct stream_data {
	/* Writeable by mixer */
	enum KSSTATE                stream_state_current;
	unsigned int                halted;
	unsigned int                source_buffer_read_position;
	unsigned int                source_buffer_read_position_fraction;
	unsigned int                source_buffer_presentation_position;
	unsigned int                source_buffer_linear_position;
	unsigned int                source_buffer_frames_decoded;
	unsigned int                stream_notification_offset;
	unsigned int                stream_notification_request;

	/* Read-only for mixer */
	unsigned int                stream_allocated;
	enum KSSTATE                stream_state_target;

	unsigned long long          source_buffer_system;
	unsigned int                source_buffer_avp;
	unsigned int                source_buffer_size;
	unsigned int                source_buffer_write_position;
	unsigned int                source_buffer_write_count;

	unsigned int                stream_notification_interval;
	int                         stream_notification_enable;

	struct audio_params         stream_params;
	enum audio_format           stream_format;
	int                         stream_volume[RENDERSW_MAX_CHANNELS];

	union {
		/* AAC Specific Data */
		struct {
			unsigned int            payload_type;
			unsigned int            audio_profile;
			unsigned int            sampling_freq_index;
			unsigned int            sampling_freq;
			unsigned int            channel_configuration;
			unsigned int            extension_sampling_freq_index;
			unsigned int            extension_sampling_freq;
		} aac;
	} u;
};

struct audio_engine_data {
	unsigned int            apb_channel_handle;

	unsigned long long      device_buffer_system;
	unsigned int            device_buffer_avp;

	unsigned int            track_audio_latency;
	unsigned int            hw_write_time;

	unsigned int            codec_ucode_base_address;
	unsigned int            codec_ucode_desc[NUM_CODECS][UCODE_DESC_NUM];
					/* [codec][offset,size] */

	enum KSSTATE            device_state_target;
	unsigned int            profile_state;

	struct audio_params     device_format;

	enum KSSTATE            device_state_current;
	unsigned int            device_buffer_write_position;
	unsigned int            device_buffer_read_position;
	unsigned int            chip_id;
	unsigned int            only_loopback_flag;

	struct stream_data      stream[RENDERSW_MAX_STREAMS];
};

#endif