1 #include <lib/dvb/volume.h>
8 #if HAVE_DVB_API_VERSION < 3
9 #define VIDEO_DEV "/dev/dvb/card0/video0"
10 #define AUDIO_DEV "/dev/dvb/card0/audio0"
11 #include <ost/audio.h>
12 #include <ost/video.h>
14 #define VIDEO_DEV "/dev/dvb/adapter0/video0"
15 #define AUDIO_DEV "/dev/dvb/adapter0/audio0"
16 #include <linux/dvb/audio.h>
17 #include <linux/dvb/video.h>
20 eDVBVolumecontrol* eDVBVolumecontrol::instance = NULL;
22 eDVBVolumecontrol* eDVBVolumecontrol::getInstance()
25 instance = new eDVBVolumecontrol;
29 eDVBVolumecontrol::eDVBVolumecontrol()
35 int eDVBVolumecontrol::openMixer()
37 return open( AUDIO_DEV, O_RDWR );
40 void eDVBVolumecontrol::closeMixer(int fd)
45 void eDVBVolumecontrol::volumeUp(int left, int right)
47 printf("[volume.cpp] Volume up\n");
48 setVolume(leftVol + left, rightVol + right);
51 void eDVBVolumecontrol::volumeDown(int left, int right)
53 printf("[volume.cpp] Volume down\n");
54 setVolume(leftVol - left, rightVol - right);
57 int eDVBVolumecontrol::checkVolume(int vol)
66 void eDVBVolumecontrol::setVolume(int left, int right)
68 leftVol = checkVolume(left);
69 rightVol = checkVolume(right);
71 left = 63 - leftVol * 63 / 100;
72 right = 63 - rightVol * 63 / 100;
74 #if HAVE_DVB_API_VERSION < 3
80 #ifdef HAVE_DVB_API_VERSION
81 mixer.volume_left = (left * left) / 64;
82 mixer.volume_right = (right * right) / 64;
86 #ifdef HAVE_DVB_API_VERSION
87 ioctl(fd, AUDIO_SET_MIXER, &mixer);
91 printf("Setvolume: %d %d\n", leftVol, rightVol);
92 printf("Setvolume: %d %d\n", left, right);
96 if((f = fopen("/proc/stb/avs/0/volume", "wb")) == NULL) {
97 printf("cannot open /proc/stb/avs/0/volume\n");
101 fprintf(f, "%d", left);
106 int eDVBVolumecontrol::getVolume()
113 bool eDVBVolumecontrol::isMuted()
119 void eDVBVolumecontrol::volumeMute()
121 int fd = openMixer();
122 #ifdef HAVE_DVB_API_VERSION
123 ioctl(fd, AUDIO_SET_MUTE, true);
130 if((f = fopen("/proc/stb/adc/j1_mute", "wb")) == NULL) {
131 printf("cannot open /proc/stb/adc/j1_mute\n");
140 void eDVBVolumecontrol::volumeUnMute()
142 int fd = openMixer();
143 #ifdef HAVE_DVB_API_VERSION
144 ioctl(fd, AUDIO_SET_MUTE, false);
151 if((f = fopen("/proc/stb/adc/j1_mute", "wb")) == NULL) {
152 printf("cannot open /proc/stb/adc/j1_mute\n");
161 void eDVBVolumecontrol::volumeToggleMute()