1 #include <lib/dvb/volume.h>
7 #if HAVE_DVB_API_VERSION < 3
8 #define VIDEO_DEV "/dev/dvb/card0/video0"
9 #define AUDIO_DEV "/dev/dvb/card0/audio0"
10 #include <ost/audio.h>
11 #include <ost/video.h>
13 #define VIDEO_DEV "/dev/dvb/adapter0/video0"
14 #define AUDIO_DEV "/dev/dvb/adapter0/audio0"
15 #include <linux/dvb/audio.h>
16 #include <linux/dvb/video.h>
19 eDVBVolumecontrol* eDVBVolumecontrol::instance = NULL;
21 eDVBVolumecontrol* eDVBVolumecontrol::getInstance()
24 instance = new eDVBVolumecontrol;
28 eDVBVolumecontrol::eDVBVolumecontrol()
34 int eDVBVolumecontrol::openMixer()
36 return open( AUDIO_DEV, O_RDWR );
39 void eDVBVolumecontrol::closeMixer(int fd)
44 void eDVBVolumecontrol::volumeUp(int left, int right)
46 printf("[volume.cpp] Volume up\n");
47 setVolume(leftVol + left, rightVol + right);
50 void eDVBVolumecontrol::volumeDown(int left, int right)
52 printf("[volume.cpp] Volume down\n");
53 setVolume(leftVol - left, rightVol - right);
56 int eDVBVolumecontrol::checkVolume(int vol)
65 void eDVBVolumecontrol::setVolume(int left, int right)
67 /* left, right is 0..100 */
68 leftVol = checkVolume(left);
69 rightVol = checkVolume(right);
71 /* convert to -1dB steps */
72 left = 63 - leftVol * 63 / 100;
73 right = 63 - rightVol * 63 / 100;
74 /* now range is 63..0, where 0 is loudest */
76 #if HAVE_DVB_API_VERSION < 3
82 #if HAVE_DVB_API_VERSION < 3
83 /* convert to linear scale. 0 = loudest, ..63 */
84 mixer.volume_left = 63.0-pow(1.068241, 63-left);
85 mixer.volume_right = 63.0-pow(1.068241, 63-right);
87 mixer.volume_left = left;
88 mixer.volume_right = right;
91 printf("Setvolume: %d %d (raw)\n", leftVol, rightVol);
92 printf("Setvolume: %d %d (-1db)\n", left, right);
93 #if HAVE_DVB_API_VERSION < 3
94 printf("Setvolume: %d %d (lin)\n", mixer.volume_left, mixer.volume_right);
100 #ifdef HAVE_DVB_API_VERSION
101 ioctl(fd, AUDIO_SET_MIXER, &mixer);
109 if((f = fopen("/proc/stb/avs/0/volume", "wb")) == NULL) {
110 printf("cannot open /proc/stb/avs/0/volume\n");
114 fprintf(f, "%d", left); /* in -1dB */
119 int eDVBVolumecontrol::getVolume()
126 bool eDVBVolumecontrol::isMuted()
132 void eDVBVolumecontrol::volumeMute()
134 int fd = openMixer();
135 #ifdef HAVE_DVB_API_VERSION
136 ioctl(fd, AUDIO_SET_MUTE, true);
143 if((f = fopen("/proc/stb/audio/j1_mute", "wb")) == NULL) {
144 printf("cannot open /proc/stb/audio/j1_mute\n");
153 void eDVBVolumecontrol::volumeUnMute()
155 int fd = openMixer();
156 #ifdef HAVE_DVB_API_VERSION
157 ioctl(fd, AUDIO_SET_MUTE, false);
164 if((f = fopen("/proc/stb/audio/j1_mute", "wb")) == NULL) {
165 printf("cannot open /proc/stb/audio/j1_mute\n");
174 void eDVBVolumecontrol::volumeToggleMute()