1 #include <lib/base/eerror.h>
2 #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 setVolume(leftVol + left, rightVol + right);
50 void eDVBVolumecontrol::volumeDown(int left, int right)
52 setVolume(leftVol - left, rightVol - right);
55 int eDVBVolumecontrol::checkVolume(int vol)
64 void eDVBVolumecontrol::setVolume(int left, int right)
66 /* left, right is 0..100 */
67 leftVol = checkVolume(left);
68 rightVol = checkVolume(right);
70 /* convert to -1dB steps */
71 left = 63 - leftVol * 63 / 100;
72 right = 63 - rightVol * 63 / 100;
73 /* now range is 63..0, where 0 is loudest */
75 #if HAVE_DVB_API_VERSION < 3
81 #if HAVE_DVB_API_VERSION < 3
82 /* convert to linear scale. 0 = loudest, ..63 */
83 mixer.volume_left = 63.0-pow(1.068241, 63-left);
84 mixer.volume_right = 63.0-pow(1.068241, 63-right);
86 mixer.volume_left = left;
87 mixer.volume_right = right;
90 eDebug("Setvolume: %d %d (raw)", leftVol, rightVol);
91 eDebug("Setvolume: %d %d (-1db)", left, right);
92 #if HAVE_DVB_API_VERSION < 3
93 eDebug("Setvolume: %d %d (lin)", mixer.volume_left, mixer.volume_right);
99 #ifdef HAVE_DVB_API_VERSION
100 ioctl(fd, AUDIO_SET_MIXER, &mixer);
108 if((f = fopen("/proc/stb/avs/0/volume", "wb")) == NULL) {
109 eDebug("cannot open /proc/stb/avs/0/volume(%m)");
113 fprintf(f, "%d", left); /* in -1dB */
118 int eDVBVolumecontrol::getVolume()
123 bool eDVBVolumecontrol::isMuted()
129 void eDVBVolumecontrol::volumeMute()
131 int fd = openMixer();
132 #ifdef HAVE_DVB_API_VERSION
133 ioctl(fd, AUDIO_SET_MUTE, true);
140 if((f = fopen("/proc/stb/audio/j1_mute", "wb")) == NULL) {
141 eDebug("cannot open /proc/stb/audio/j1_mute(%m)");
150 void eDVBVolumecontrol::volumeUnMute()
152 int fd = openMixer();
153 #ifdef HAVE_DVB_API_VERSION
154 ioctl(fd, AUDIO_SET_MUTE, false);
161 if((f = fopen("/proc/stb/audio/j1_mute", "wb")) == NULL) {
162 eDebug("cannot open /proc/stb/audio/j1_mute(%m)");
171 void eDVBVolumecontrol::volumeToggleMute()