xref: /freebsd/sys/arm/broadcom/bcm2835/vc_vchi_audioserv_defs.h (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
1 /*
2  * Copyright (c) 2012, Broadcom Europe Ltd
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *    1. Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *    2. Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *    3. Neither the name of the copyright holder nor the
13  *       names of its contributors may be used to endorse or promote products
14  *       derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef _VC_AUDIO_DEFS_H_
29 #define _VC_AUDIO_DEFS_H_
30 
31 #define VC_AUDIOSERV_MIN_VER 1
32 #define VC_AUDIOSERV_VER 2
33 
34 /* FourCC code used for VCHI connection */
35 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
36 
37 /* Maximum message length */
38 #define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
39 
40 /*
41  * List of screens that are currently supported
42  * All message types supported for HOST->VC direction
43  */
44 typedef enum
45 {
46 	VC_AUDIO_MSG_TYPE_RESULT,	/* Generic result */
47 	VC_AUDIO_MSG_TYPE_COMPLETE,	/* playback of samples complete */
48 	VC_AUDIO_MSG_TYPE_CONFIG,	/* Configure */
49 	VC_AUDIO_MSG_TYPE_CONTROL,	/* control  */
50 	VC_AUDIO_MSG_TYPE_OPEN,		/*  open */
51 	VC_AUDIO_MSG_TYPE_CLOSE,	/* close/shutdown */
52 	VC_AUDIO_MSG_TYPE_START,	/* start output (i.e. resume) */
53 	VC_AUDIO_MSG_TYPE_STOP,		/* stop output (i.e. pause) */
54 	VC_AUDIO_MSG_TYPE_WRITE,	/* write samples */
55 	VC_AUDIO_MSG_TYPE_MAX
56 
57 } VC_AUDIO_MSG_TYPE;
58 
59 static const char *vc_audio_msg_type_names[] = {
60 	"VC_AUDIO_MSG_TYPE_RESULT",
61 	"VC_AUDIO_MSG_TYPE_COMPLETE",
62 	"VC_AUDIO_MSG_TYPE_CONFIG",
63 	"VC_AUDIO_MSG_TYPE_CONTROL",
64 	"VC_AUDIO_MSG_TYPE_OPEN",
65 	"VC_AUDIO_MSG_TYPE_CLOSE",
66 	"VC_AUDIO_MSG_TYPE_START",
67 	"VC_AUDIO_MSG_TYPE_STOP",
68 	"VC_AUDIO_MSG_TYPE_WRITE",
69 	"VC_AUDIO_MSG_TYPE_MAX"
70 };
71 
72 /* configure the audio */
73 typedef struct
74 {
75 	uint32_t channels;
76 	uint32_t samplerate;
77 	uint32_t bps;
78 
79 } VC_AUDIO_CONFIG_T;
80 
81 typedef struct
82 {
83 	uint32_t volume;
84 	uint32_t dest;
85 
86 } VC_AUDIO_CONTROL_T;
87 
88 typedef struct
89 {
90 	uint32_t dummy;
91 
92 } VC_AUDIO_OPEN_T;
93 
94 typedef struct
95 {
96 	uint32_t dummy;
97 
98 } VC_AUDIO_CLOSE_T;
99 
100 typedef struct
101 {
102 	uint32_t dummy;
103 
104 } VC_AUDIO_START_T;
105 
106 typedef struct
107 {
108 	uint32_t draining;
109 
110 } VC_AUDIO_STOP_T;
111 
112 typedef struct
113 {
114 	uint32_t count; /* in bytes */
115 	void *callback;
116 	void *cookie;
117 	uint16_t silence;
118 	uint16_t max_packet;
119 } VC_AUDIO_WRITE_T;
120 
121 /* Generic result for a request (VC->HOST) */
122 typedef struct
123 {
124 	int32_t success;  /* Success value */
125 
126 } VC_AUDIO_RESULT_T;
127 
128 /* Generic result for a request (VC->HOST) */
129 typedef struct
130 {
131 	int32_t count;  /* Success value */
132 	void *callback;
133 	void *cookie;
134 } VC_AUDIO_COMPLETE_T;
135 
136 /* Message header for all messages in HOST->VC direction */
137 typedef struct
138 {
139 	int32_t type;     /* Message type (VC_AUDIO_MSG_TYPE) */
140 	union
141 	{
142 		VC_AUDIO_CONFIG_T	config;
143 		VC_AUDIO_CONTROL_T	control;
144 		VC_AUDIO_OPEN_T		open;
145 		VC_AUDIO_CLOSE_T	close;
146 		VC_AUDIO_START_T	start;
147 		VC_AUDIO_STOP_T		stop;
148 		VC_AUDIO_WRITE_T	write;
149 		VC_AUDIO_RESULT_T	result;
150 		VC_AUDIO_COMPLETE_T	complete;
151 	} u;
152 } VC_AUDIO_MSG_T;
153 
154 #endif /* _VC_AUDIO_DEFS_H_ */
155