xref: /freebsd/sys/arm/broadcom/bcm2835/vc_vchi_audioserv_defs.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
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  * $FreeBSD$
28  */
29 
30 #ifndef _VC_AUDIO_DEFS_H_
31 #define _VC_AUDIO_DEFS_H_
32 
33 #define VC_AUDIOSERV_MIN_VER 1
34 #define VC_AUDIOSERV_VER 2
35 
36 /* FourCC code used for VCHI connection */
37 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
38 
39 /* Maximum message length */
40 #define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
41 
42 /*
43  * List of screens that are currently supported
44  * All message types supported for HOST->VC direction
45  */
46 typedef enum
47 {
48 	VC_AUDIO_MSG_TYPE_RESULT,	/* Generic result */
49 	VC_AUDIO_MSG_TYPE_COMPLETE,	/* playback of samples complete */
50 	VC_AUDIO_MSG_TYPE_CONFIG,	/* Configure */
51 	VC_AUDIO_MSG_TYPE_CONTROL,	/* control  */
52 	VC_AUDIO_MSG_TYPE_OPEN,		/*  open */
53 	VC_AUDIO_MSG_TYPE_CLOSE,	/* close/shutdown */
54 	VC_AUDIO_MSG_TYPE_START,	/* start output (i.e. resume) */
55 	VC_AUDIO_MSG_TYPE_STOP,		/* stop output (i.e. pause) */
56 	VC_AUDIO_MSG_TYPE_WRITE,	/* write samples */
57 	VC_AUDIO_MSG_TYPE_MAX
58 
59 } VC_AUDIO_MSG_TYPE;
60 
61 static const char *vc_audio_msg_type_names[] = {
62 	"VC_AUDIO_MSG_TYPE_RESULT",
63 	"VC_AUDIO_MSG_TYPE_COMPLETE",
64 	"VC_AUDIO_MSG_TYPE_CONFIG",
65 	"VC_AUDIO_MSG_TYPE_CONTROL",
66 	"VC_AUDIO_MSG_TYPE_OPEN",
67 	"VC_AUDIO_MSG_TYPE_CLOSE",
68 	"VC_AUDIO_MSG_TYPE_START",
69 	"VC_AUDIO_MSG_TYPE_STOP",
70 	"VC_AUDIO_MSG_TYPE_WRITE",
71 	"VC_AUDIO_MSG_TYPE_MAX"
72 };
73 
74 /* configure the audio */
75 typedef struct
76 {
77 	uint32_t channels;
78 	uint32_t samplerate;
79 	uint32_t bps;
80 
81 } VC_AUDIO_CONFIG_T;
82 
83 typedef struct
84 {
85 	uint32_t volume;
86 	uint32_t dest;
87 
88 } VC_AUDIO_CONTROL_T;
89 
90 typedef struct
91 {
92 	uint32_t dummy;
93 
94 } VC_AUDIO_OPEN_T;
95 
96 typedef struct
97 {
98 	uint32_t dummy;
99 
100 } VC_AUDIO_CLOSE_T;
101 
102 typedef struct
103 {
104 	uint32_t dummy;
105 
106 } VC_AUDIO_START_T;
107 
108 typedef struct
109 {
110 	uint32_t draining;
111 
112 } VC_AUDIO_STOP_T;
113 
114 typedef struct
115 {
116 	uint32_t count; /* in bytes */
117 	void *callback;
118 	void *cookie;
119 	uint16_t silence;
120 	uint16_t max_packet;
121 } VC_AUDIO_WRITE_T;
122 
123 /* Generic result for a request (VC->HOST) */
124 typedef struct
125 {
126 	int32_t success;  /* Success value */
127 
128 } VC_AUDIO_RESULT_T;
129 
130 /* Generic result for a request (VC->HOST) */
131 typedef struct
132 {
133 	int32_t count;  /* Success value */
134 	void *callback;
135 	void *cookie;
136 } VC_AUDIO_COMPLETE_T;
137 
138 /* Message header for all messages in HOST->VC direction */
139 typedef struct
140 {
141 	int32_t type;     /* Message type (VC_AUDIO_MSG_TYPE) */
142 	union
143 	{
144 		VC_AUDIO_CONFIG_T	config;
145 		VC_AUDIO_CONTROL_T	control;
146 		VC_AUDIO_OPEN_T		open;
147 		VC_AUDIO_CLOSE_T	close;
148 		VC_AUDIO_START_T	start;
149 		VC_AUDIO_STOP_T		stop;
150 		VC_AUDIO_WRITE_T	write;
151 		VC_AUDIO_RESULT_T	result;
152 		VC_AUDIO_COMPLETE_T	complete;
153 	} u;
154 } VC_AUDIO_MSG_T;
155 
156 #endif /* _VC_AUDIO_DEFS_H_ */
157