-
Notifications
You must be signed in to change notification settings - Fork 1
/
vp6500mixer.c
89 lines (75 loc) · 2.29 KB
/
vp6500mixer.c
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
/*
* vp6500mixer - sound mixer utility für Philips VP6500 VoIP phone
*
* Copyright (C) 2010 Christian Garbs <[email protected]>
* licensed under GNU GPL v2 or later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "aic14_ioctl.h"
#define MAXLEVEL 255
#define AIC14_DEV "/dev/aic14"
static u_int8_t bytereg[4];
int main(int argc, char *argv[])
{
int aic14_fd = -1;
int vol = -1;
bytereg[0] = 0;
bytereg[1] = 0;
bytereg[2] = 0;
bytereg[3] = 0;
if (argc == 2) {
if (sscanf(argv[1], "%d", &vol) == 1) {
if (vol < 0) {
vol = 0;
}
if (vol > MAXLEVEL) {
vol = MAXLEVEL;
}
if (! ((aic14_fd = open(AIC14_DEV, O_WRONLY)) < 0)) {
#ifdef DEBUG
if (ioctl(aic14_fd, AIC14_GET_DAC_GAIN, bytereg) == -1) {
fprintf(stderr, "err: AIC14_GET_DAC_GAIN ioctl failed\n");
} else {
printf("DAC Gain before: %8X (%5i dB)\n", bytereg[0], -42 + bytereg[0]);
}
#endif
bytereg[0] = vol;
if (ioctl(aic14_fd, AIC14_SET_DAC_GAIN, bytereg) == -1) {
fprintf(stderr, "err: AIC14_SET_DAC_GAIN ioctl failed\n");
}
#ifdef DEBUG
if (ioctl(aic14_fd, AIC14_GET_DAC_GAIN, bytereg) == -1) {
fprintf(stderr, "err: AIC14_GET_DAC_GAIN ioctl failed\n");
} else {
printf("DAC Gain after: %8X (%5i dB)\n", bytereg[0], -42 + bytereg[0]);
}
#endif
close(aic14_fd);
} else {
perror("err: " AIC14_DEV " not opened");
}
} else {
fprintf(stderr, "err: could not parse volume: <%s>\n", argv[1]);
}
} else {
fprintf(stderr, "err: enter volume as first argument (range 0-255)\n");
}
return 0;
}