summaryrefslogtreecommitdiffstats
path: root/arcam-av/arcam_av.h
blob: 85e921987f70cfa53ee92d02c09bfb022ced0c73 (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
/*
 * ALSA -> Arcam AV control plugin
 *
 * Copyright (c) 2009 by Peter Stokes <linux@dadeos.co.uk>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

#include <pthread.h>

typedef enum {
	ARCAM_AV_ZONE1				= '1',
	ARCAM_AV_ZONE2				= '2'
} arcam_av_zone_t;


typedef enum {
	ARCAM_AV_POWER				= '*',
	ARCAM_AV_VOLUME_CHANGE			= '/',
	ARCAM_AV_VOLUME_SET			= '0',
	ARCAM_AV_MUTE				= '.',
	ARCAM_AV_SOURCE				= '1',
	ARCAM_AV_SOURCE_TYPE			= '7',
	ARCAM_AV_DIRECT				= '3',
	ARCAM_AV_STEREO_DECODE			= '4',
	ARCAM_AV_MULTI_DECODE			= '5',
	ARCAM_AV_STEREO_EFFECT			= '6'
} arcam_av_cc_t;


typedef enum {
	ARCAM_AV_OK				= 'P',
	ARCAM_AV_ERROR				= 'R'
} arcam_av_rc_t;


typedef enum {
	ARCAM_AV_POWER_STAND_BY			= '0',
	ARCAM_AV_POWER_ON			= '1',
	ARCAM_AV_POWER_REQUEST			= '9'
} arcam_av_power_t;


typedef enum {
	ARCAM_AV_VOLUME_MIN			= '0',
	ARCAM_AV_VOLUME_REQUEST			= '9'
} arcam_av_volume_t;


typedef enum {
	ARCAM_AV_MUTE_ON			= '0',
	ARCAM_AV_MUTE_OFF			= '1',
	ARCAM_AV_MUTE_REQUEST			= '9'
} arcam_av_mute_t;


typedef enum {
	ARCAM_AV_DIRECT_DISABLE			= '0',
	ARCAM_AV_DIRECT_ENABLE			= '1',
	ARCAM_AV_DIRECT_REQUEST			= '9'
} arcam_av_direct_t;


typedef enum {
	ARCAM_AV_SOURCE_DVD 			= '0',
	ARCAM_AV_SOURCE_SAT			= '1',
	ARCAM_AV_SOURCE_AV			= '2',
	ARCAM_AV_SOURCE_PVR			= '3',
	ARCAM_AV_SOURCE_VCR			= '4',
	ARCAM_AV_SOURCE_CD			= '5',
	ARCAM_AV_SOURCE_FM			= '6',
	ARCAM_AV_SOURCE_AM			= '7',
	ARCAM_AV_SOURCE_DVDA			= '8',
	ARCAM_AV_SOURCE_REQUEST			= '9'
} arcam_av_source_t;


typedef enum {
	ARCAM_AV_SOURCE_TYPE_ANALOGUE 		= '0',
	ARCAM_AV_SOURCE_TYPE_DIGITAL		= '1',
	ARCAM_AV_SOURCE_TYPE_REQUEST		= '9'
} arcam_av_source_type_t;


typedef enum {
	ARCAM_AV_STEREO_DECODE_MONO		= '.',
	ARCAM_AV_STEREO_DECODE_STEREO		= '/',
	ARCAM_AV_STEREO_DECODE_PLII_MOVIE	= '0',
	ARCAM_AV_STEREO_DECODE_PLII_MUSIC	= '1',
	ARCAM_AV_STEREO_DECODE_PLIIx_MOVIE	= '3',
	ARCAM_AV_STEREO_DECODE_PLIIx_MUSIC	= '4',
	ARCAM_AV_STEREO_DECODE_DOLBY_PL		= '6',
	ARCAM_AV_STEREO_DECODE_NEO6_CINEMA	= '7',
	ARCAM_AV_STEREO_DECODE_NEO6_MUSIC	= '8',
	ARCAM_AV_STEREO_DECODE_REQUEST		= '9'
} arcam_av_stereo_decode_t;


typedef enum {
	ARCAM_AV_MULTI_DECODE_MONO		= '.',
	ARCAM_AV_MULTI_DECODE_STEREO		= '/',
	ARCAM_AV_MULTI_DECODE_MULTI_CHANNEL	= '0',
	ARCAM_AV_MULTI_DECODE_PLIIx		= '2',
	ARCAM_AV_MULTI_DECODE_REQUEST		= '9'
} arcam_av_multi_decode_t;


typedef enum {
	ARCAM_AV_STEREO_EFFECT_NONE		= '0',
	ARCAM_AV_STEREO_EFFECT_MUSIC		= '1',
	ARCAM_AV_STEREO_EFFECT_PARTY		= '2',
	ARCAM_AV_STEREO_EFFECT_CLUB		= '3',
	ARCAM_AV_STEREO_EFFECT_HALL		= '4',
	ARCAM_AV_STEREO_EFFECT_SPORTS		= '5',
	ARCAM_AV_STEREO_EFFECT_CHURCH		= '6',
	ARCAM_AV_STEREO_EFFECT_REQUEST		= '9'
} arcam_av_stereo_effect_t;

int arcam_av_connect(const char* port);
int arcam_av_send(int fd, arcam_av_cc_t command, unsigned char param1, unsigned char param2);


typedef struct arcam_av_state {
	struct {
		arcam_av_power_t		power;
		unsigned char			volume;
		arcam_av_mute_t			mute;
		arcam_av_direct_t		direct;
		arcam_av_source_t		source;
		arcam_av_source_type_t		source_type;
		arcam_av_stereo_decode_t	stereo_decode;
		arcam_av_stereo_effect_t	stereo_effect;
		arcam_av_multi_decode_t		multi_decode;
	} zone1;
	struct {
		arcam_av_power_t		power;
		unsigned char			volume;
		arcam_av_mute_t			mute;
		arcam_av_source_t		source;
	} zone2;
} arcam_av_state_t;

arcam_av_state_t* arcam_av_state_attach(const char* port);
int arcam_av_state_detach(arcam_av_state_t* state);

int arcam_av_server_start(pthread_t* thread, const char* port);
int arcam_av_server_stop(pthread_t thread, const char* port);

int arcam_av_client(const char* port);