summaryrefslogtreecommitdiff
path: root/dxr3interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'dxr3interface.c')
-rw-r--r--dxr3interface.c1203
1 files changed, 615 insertions, 588 deletions
diff --git a/dxr3interface.c b/dxr3interface.c
index 3eea756..c3f5150 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -38,91 +38,98 @@ const uint32_t UNKNOWN_AUDIO_MODE = 9; // default, unused value
//! helper function to generate name
static const char *Dxr3Name(const char *Name, int n)
{
- static char buffer[PATH_MAX];
- snprintf(buffer, sizeof(buffer), "/dev/em8300%s-%d", Name, n);
- return buffer;
+ static char buffer[PATH_MAX];
+ snprintf(buffer, sizeof(buffer), "/dev/em8300%s-%d", Name, n);
+ return buffer;
}
// ==================================
//! helper function to open the card #n
static int Dxr3Open(const char *Name, int n, int Mode)
{
- const char *FileName = Dxr3Name(Name, n);
- int fd = open(FileName, Mode);
-
- if (fd < 0)
- {
- cLog::Instance() << "Unable to open " << FileName << "\n";
- }
- return fd;
+ const char *FileName = Dxr3Name(Name, n);
+ int fd = open(FileName, Mode);
+
+ if (fd < 0)
+ {
+ cLog::Instance() << "Unable to open " << FileName << "\n";
+ }
+ return fd;
}
// ==================================
//! constructor
cDxr3Interface::cDxr3Interface() :
-m_fdControl(-1), m_fdVideo(-1), m_fdAudio(-1), m_fdSpu(-1)
+ m_fdControl(-1), m_fdVideo(-1), m_fdAudio(-1), m_fdSpu(-1)
{
- // open control stream
- m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
- if (m_fdControl < 0)
- {
- cLog::Instance() << "Please check if the dxr3 modules are loaded!\n";
- exit(1);
- }
-
- // upload microcode to dxr3
- UploadMicroCode();
+ // open control stream
+ m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+ if (m_fdControl < 0)
+ {
+ cLog::Instance() << "Please check if the dxr3 modules are loaded!\n";
+ exit(1);
+ }
- ///< open 'multimedia' streams
- m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
- m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
- m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
+ // upload microcode to dxr3
+ UploadMicroCode();
- // everything ok?
- if (m_fdVideo < 0 || m_fdAudio < 0 || m_fdSpu < 0)
- {
- cLog::Instance() << "Unable to open one of the 'multimedia' streams!\n";
- exit(1);
- }
+ ///< open multimedia streams
+ m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+ m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+ m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+
+ // everything ok?
+ if (m_fdVideo < 0 || m_fdAudio < 0 || m_fdSpu < 0)
+ {
+ cLog::Instance() << "Unable to open one of the 'multimedia' streams!\n";
+ exit(1);
+ }
- // create clock
- m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
+ // create clock
+ m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
- // everything ok?
- if (!m_pClock)
- {
- cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
- exit(1);
- }
+ // everything ok?
+ if (!m_pClock)
+ {
+ cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
+ exit(1);
+ }
- // set default values
+ // set default values
m_AudioActive = false;
- m_VideoActive = false;
- m_OverlayActive = false;
+ m_VideoActive = false;
+ m_OverlayActive = false;
m_ExternalReleased = false;
m_volume = 255;
- m_horizontal = 720;
- m_vertical = 576;
+ m_horizontal = 720;
+ m_vertical = 576;
m_audioChannelCount = UNKNOWN_CHANNEL_COUNT;
m_audioDataRate = 0;
m_audioSampleSize = 0;
m_audioMode = UNKNOWN_AUDIO_MODE;
- m_aspectRatio = UNKNOWN_ASPECT_RATIO;
- m_spuMode = EM8300_SPUMODE_OFF;
+ m_aspectRatio = UNKNOWN_ASPECT_RATIO;
+ m_spuMode = EM8300_SPUMODE_OFF;
- // configure device based on settings
- ConfigureDevice();
-
- // get bcs values from driver
- ioctl(m_fdControl, EM8300_IOCTL_GETBCS, &m_bcs);
+ // configure device based on settings
+ ConfigureDevice();
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "DXR3: brightness: " << m_bcs.brightness << "\n";
- cLog::Instance() << "DXR3: contrast: " << m_bcs.contrast << "\n";
- cLog::Instance() << "DXR3: saturation: " << m_bcs.saturation << "\n";
- }
+ // get bcs values from driver
+ ioctl(m_fdControl, EM8300_IOCTL_GETBCS, &m_bcs);
+
+ if (cDxr3ConfigData::Instance().GetDebug())
+ {
+ cLog::Instance() << "DXR3: brightness: "
+ << m_bcs.brightness << "\n";
+ cLog::Instance() << "DXR3: contrast: "
+ << m_bcs.contrast << "\n";
+ cLog::Instance() << "DXR3: saturation: "
+ << m_bcs.saturation << "\n";
+ }
PlayBlackFrame();
SetChannelCount(1);
@@ -132,29 +139,29 @@ m_fdControl(-1), m_fdVideo(-1), m_fdAudio(-1), m_fdSpu(-1)
//! destructor
cDxr3Interface::~cDxr3Interface()
{
- // close filehandles
- if (m_fdControl > -1)
- {
- close(m_fdControl);
- }
- if (m_fdVideo > -1)
- {
- close(m_fdVideo);
- }
- if (m_fdSpu > -1)
- {
- close(m_fdSpu);
- }
- if (m_fdAudio > -1)
- {
- close(m_fdAudio);
- }
+ // close filehandles
+ if (m_fdControl > -1)
+ {
+ close(m_fdControl);
+ }
+ if (m_fdVideo > -1)
+ {
+ close(m_fdVideo);
+ }
+ if (m_fdSpu > -1)
+ {
+ close(m_fdSpu);
+ }
+ if (m_fdAudio > -1)
+ {
+ close(m_fdAudio);
+ }
- // free some memory
- if (m_pClock)
- {
- delete m_pClock;
- }
+ // free some memory
+ if (m_pClock)
+ {
+ delete m_pClock;
+ }
}
// main
@@ -176,18 +183,18 @@ void cDxr3Interface::SetAudioAnalog()
int ioval = 0;
Lock();
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_ANALOG)
+ if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_ANALOG)
+ {
+ int prevMode = m_audioMode;
+ m_audioMode = ioval = EM8300_AUDIOMODE_ANALOG;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
{
- int prevMode = m_audioMode;
- m_audioMode = ioval = EM8300_AUDIOMODE_ANALOG;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
- }
- if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
- {
- ReOpenAudio();
- }
+ cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
+ }
+ if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
+ {
+ ReOpenAudio();
+ }
}
Unlock();
@@ -200,19 +207,19 @@ void cDxr3Interface::SetAudioDigitalPCM()
int ioval = 0;
Lock();
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALPCM)
+ if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALPCM)
+ {
+ int prevMode = m_audioMode;
+ m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALPCM;
+
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
{
- int prevMode = m_audioMode;
- m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALPCM;
-
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
- }
- if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
- {
- ReOpenAudio();
- }
+ cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
+ }
+ if (prevMode == EM8300_AUDIOMODE_DIGITALAC3)
+ {
+ ReOpenAudio();
+ }
}
Unlock();
@@ -222,22 +229,22 @@ void cDxr3Interface::SetAudioDigitalPCM()
//! set audio-output to digital ac3
void cDxr3Interface::SetAudioDigitalAC3()
{
- if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
+ if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
+ {
+ int ioval = 0;
+ Lock();
+
+ if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
{
- int ioval = 0;
- Lock();
+ m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALAC3;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
+ }
+ ReOpenAudio();
+ }
- if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
- {
- m_audioMode = ioval = EM8300_AUDIOMODE_DIGITALAC3;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_AUDIOMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetAudioAnalog Unable to set audiomode!\n";
- }
- ReOpenAudio();
- }
-
- Unlock();
+ Unlock();
}
}
@@ -245,19 +252,19 @@ void cDxr3Interface::SetAudioDigitalAC3()
//! set audiosepeed
void cDxr3Interface::SetAudioSpeed(uint32_t speed)
{
- if (m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
+ if (m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
+ {
+ if (!m_ExternalReleased)
{
- if (!m_ExternalReleased)
+ if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
+ {
+ if (ioctl(m_fdAudio, SNDCTL_DSP_SPEED, &speed) < 0)
{
- if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
- {
- if (ioctl(m_fdAudio, SNDCTL_DSP_SPEED, &speed) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetAudioSpeed Unable to set dsp speed\n";
- }
- }
- }
- m_audioDataRate = speed;
+ cLog::Instance() << "cDxr3Interface::SetAudioSpeed Unable to set dsp speed\n";
+ }
+ }
+ }
+ m_audioDataRate = speed;
}
}
@@ -265,53 +272,53 @@ void cDxr3Interface::SetAudioSpeed(uint32_t speed)
//! set nummber of channels
void cDxr3Interface::SetChannelCount(uint32_t count)
{
- if (m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
+ if (m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
+ {
+ if (!m_ExternalReleased)
{
- if (!m_ExternalReleased)
+ if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
+ {
+ if (ioctl(m_fdAudio, SNDCTL_DSP_STEREO, &count) < 0)
{
- if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
- {
- if (ioctl(m_fdAudio, SNDCTL_DSP_STEREO, &count) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetChannelCount Unable to set channel count\n";
- }
- }
- }
- m_audioChannelCount = count;
+ cLog::Instance() << "cDxr3AbsDevice::SetChannelCount Unable to set channel count\n";
+ }
+ }
+ }
+ m_audioChannelCount = count;
}
}
// ==================================
//! set audio sample size
-void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
+void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
{
- if (!m_ExternalReleased)
+ if (!m_ExternalReleased)
+ {
+ if (ioctl(m_fdAudio, SNDCTL_DSP_SAMPLESIZE, sampleSize))
{
- if (ioctl(m_fdAudio, SNDCTL_DSP_SAMPLESIZE, sampleSize))
- {
- cLog::Instance() <<"cDxr3AbsDevice::SetAudioSampleSize Unable to set audio sample size\n";
- }
+ cLog::Instance() <<"cDxr3AbsDevice::SetAudioSampleSize Unable to set audio sample size\n";
+ }
}
- m_audioSampleSize = sampleSize;
+ m_audioSampleSize = sampleSize;
}
// clock
// ==================================
-void cDxr3Interface::SetSysClock(uint32_t scr)
+void cDxr3Interface::SetSysClock(uint32_t scr)
{
- if (!m_ExternalReleased)
- {
- m_pClock->SetSysClock(scr);
+ if (!m_ExternalReleased)
+ {
+ m_pClock->SetSysClock(scr);
}
}
// ==================================
-uint32_t cDxr3Interface::GetSysClock() const
+uint32_t cDxr3Interface::GetSysClock() const
{
uint32_t ret = 0;
- if (!m_ExternalReleased)
- {
- ret = m_pClock->GetSysClock();
+ if (!m_ExternalReleased)
+ {
+ ret = m_pClock->GetSysClock();
}
return ret;
}
@@ -323,24 +330,25 @@ int64_t cDxr3Interface::GetPts()
}
// ==================================
-void cDxr3Interface::SetPts(uint32_t pts)
+void cDxr3Interface::SetPts(uint32_t pts)
{
- if (!m_ExternalReleased)
- {
- m_pClock->SetPts(pts);
+ if (!m_ExternalReleased)
+ {
+ m_pClock->SetPts(pts);
}
}
// ==================================
-void cDxr3Interface::SetSpuPts(uint32_t pts)
+void cDxr3Interface::SetSpuPts(uint32_t pts)
{
- pts = pts >> 1;
- if (!m_ExternalReleased)
+ pts = pts >> 1;
+ if (!m_ExternalReleased)
+ {
+ if (pts > m_pClock->GetSysClock() &&
+ pts - m_pClock->GetSysClock() < 100000)
{
- if (pts > m_pClock->GetSysClock() && pts - m_pClock->GetSysClock() < 100000)
- {
- m_pClock->SetSpuPts(pts);
- }
+ m_pClock->SetSpuPts(pts);
+ }
}
}
@@ -352,13 +360,13 @@ void cDxr3Interface::EnableSPU()
int ioval = 0;
Lock();
- if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_ON)
- {
- m_spuMode = ioval = EM8300_SPUMODE_ON;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::EnableSpu Unable to set subpicture mode!\n";
- }
+ if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_ON)
+ {
+ m_spuMode = ioval = EM8300_SPUMODE_ON;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3AbsDevice::EnableSpu Unable to set subpicture mode!\n";
+ }
}
Unlock();
@@ -371,13 +379,13 @@ void cDxr3Interface::DisableSPU()
int ioval = 0;
Lock();
- if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_OFF)
- {
- m_spuMode = ioval = EM8300_SPUMODE_OFF;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::EnableSpu Unable to set subpicture mode!\n";
- }
+ if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_OFF)
+ {
+ m_spuMode = ioval = EM8300_SPUMODE_OFF;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3AbsDevice::EnableSpu Unable to set subpicture mode!\n";
+ }
}
Unlock();
@@ -386,16 +394,16 @@ void cDxr3Interface::DisableSPU()
// ==================================
//! disable audio output of dxr3
void cDxr3Interface::DisableAudio()
-{
- m_AudioActive = false;
-
- // we write zero buffers to dxr3
- if (!m_ExternalReleased)
- {
- if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
- if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
- if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
- if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
+{
+ m_AudioActive = false;
+
+ // we write zero buffers to dxr3
+ if (!m_ExternalReleased)
+ {
+ if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
+ if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
+ if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
+ if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
}
}
@@ -403,65 +411,65 @@ void cDxr3Interface::DisableAudio()
//! enable overlay mode of the dxr3
void cDxr3Interface::EnableOverlay()
{
- // first we check, if it is enabled yet
- if (m_OverlayActive)
- {
- return;
- }
-
- /*
- #define EM8300_OVERLAY_SIGNAL_ONLY 1
- #define EM8300_OVERLAY_SIGNAL_WITH_VGA 2
- #define EM8300_OVERLAY_VGA_ONLY 3
- */
-
- int ioval = EM8300_OVERLAY_SIGNAL_WITH_VGA;
- // set overlay signal mode
- if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SIGNALMODE, &ioval) < 0)
- {
- //######
- cLog::Instance() << "Singnalmode failed\n";
- return;
- }
+ // first we check, if it is enabled yet
+ if (m_OverlayActive)
+ {
+ return;
+ }
- // setup overlay screen
- em8300_overlay_screen_t scr;
- scr.xsize = 1024;
- scr.ysize = 768;
+ /*
+#define EM8300_OVERLAY_SIGNAL_ONLY 1
+#define EM8300_OVERLAY_SIGNAL_WITH_VGA 2
+#define EM8300_OVERLAY_VGA_ONLY 3
+ */
+
+ int ioval = EM8300_OVERLAY_SIGNAL_WITH_VGA;
+ // set overlay signal mode
+ if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SIGNALMODE, &ioval) < 0)
+ {
+ //######
+ cLog::Instance() << "Singnalmode failed\n";
+ return;
+ }
- if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SETSCREEN, &scr) < 0)
- {
- //######
- cLog::Instance() << "seting up screen failed\n";
- return;
- }
+ // setup overlay screen
+ em8300_overlay_screen_t scr;
+ scr.xsize = 1024;
+ scr.ysize = 768;
- // setup overlay window
- em8300_overlay_window_t win;
- win.xpos = 0;
- win.ypos = 0;
- win.width = 1024;
- win.height = 768;
+ if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SETSCREEN, &scr) < 0)
+ {
+ //######
+ cLog::Instance() << "seting up screen failed\n";
+ return;
+ }
- if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SETWINDOW, &win) < 0)
- {
- //######
- cLog::Instance() << "seting up window failed\n";
- return;
- }
+ // setup overlay window
+ em8300_overlay_window_t win;
+ win.xpos = 0;
+ win.ypos = 0;
+ win.width = 1024;
+ win.height = 768;
+
+ if (ioctl(m_fdControl, EM8300_IOCTL_OVERLAY_SETWINDOW, &win) < 0)
+ {
+ //######
+ cLog::Instance() << "seting up window failed\n";
+ return;
+ }
- m_OverlayActive = true;
+ m_OverlayActive = true;
}
// ==================================
//! disable overlay mode of the dxr3
void cDxr3Interface::DisanleOverlay()
{
- // is it allready disabled
- if (!m_OverlayActive)
- {
- return;
- }
+ // is it allready disabled
+ if (!m_OverlayActive)
+ {
+ return;
+ }
}
// set/get functions
@@ -471,57 +479,59 @@ uint32_t cDxr3Interface::GetAspectRatio() const
{
int ioval = 0;
Lock();
-
- if (!m_ExternalReleased)
+
+ if (!m_ExternalReleased)
+ {
+ if (ioctl(m_fdControl, EM8300_IOCTL_GET_ASPECTRATIO, &ioval) < 0)
{
- if (ioctl(m_fdControl, EM8300_IOCTL_GET_ASPECTRATIO, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::GetAspectRatio Unable to get aspect ratio\n";
- }
+ cLog::Instance() << "cDxr3AbsDevice::GetAspectRatio Unable to get aspect ratio\n";
+ }
}
-
+
Unlock();
return ioval;
}
// ==================================
//! set aspectratio
-void cDxr3Interface::SetAspectRatio(uint32_t ratio)
+void cDxr3Interface::SetAspectRatio(uint32_t ratio)
{
static int requestCounter = 0;
-
+
Lock();
- if (cDxr3ConfigData::Instance().GetForceLetterBox()) ratio = EM8300_ASPECTRATIO_16_9;
- if (Setup.VideoFormat) ratio = EM8300_ASPECTRATIO_4_3;
+ if (cDxr3ConfigData::Instance().GetForceLetterBox())
+ ratio = EM8300_ASPECTRATIO_16_9;
+ if (Setup.VideoFormat)
+ ratio = EM8300_ASPECTRATIO_4_3;
- if (!m_ExternalReleased && ratio != UNKNOWN_ASPECT_RATIO)
- {
- if (ratio != m_aspectRatio && requestCounter > 50)
- {
- requestCounter = 0;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_ASPECTRATIO, &ratio) < 0)
- {
- cLog::Instance() << "cDxr3AbsDevice::SetAspectRatio Unable to set aspect ratio\n";
- }
- else
- {
- m_aspectRatio = ratio;
- }
- }
- else
- {
- if (ratio != m_aspectRatio)
- {
- ++requestCounter;
- }
- else
- {
- requestCounter = 0;
- }
- }
+ if (!m_ExternalReleased && ratio != UNKNOWN_ASPECT_RATIO)
+ {
+ if (ratio != m_aspectRatio && requestCounter > 50)
+ {
+ requestCounter = 0;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_ASPECTRATIO, &ratio) < 0)
+ {
+ cLog::Instance() << "cDxr3AbsDevice::SetAspectRatio Unable to set aspect ratio\n";
+ }
+ else
+ {
+ m_aspectRatio = ratio;
+ }
+ }
+ else
+ {
+ if (ratio != m_aspectRatio)
+ {
+ ++requestCounter;
+ }
+ else
+ {
+ requestCounter = 0;
+ }
+ }
}
-
+
Unlock();
}
@@ -535,26 +545,26 @@ void cDxr3Interface::SetPlayMode()
Lock();
- if (!m_ExternalReleased)
- {
- ioval = EM8300_SUBDEVICE_AUDIO;
- ioctl(m_fdControl, EM8300_IOCTL_FLUSH, &ioval);
- fsync(m_fdVideo);
+ if (!m_ExternalReleased)
+ {
+ ioval = EM8300_SUBDEVICE_AUDIO;
+ ioctl(m_fdControl, EM8300_IOCTL_FLUSH, &ioval);
+ fsync(m_fdVideo);
- ioval = EM8300_PLAYMODE_PLAY;
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3Device::SetPlayMode Unable to set playmode!\n";
- }
- reg.microcode_register = 1;
- reg.reg = 0;
- reg.val = MVCOMMAND_SYNC;
+ ioval = EM8300_PLAYMODE_PLAY;
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3Device::SetPlayMode Unable to set playmode!\n";
+ }
+ reg.microcode_register = 1;
+ reg.reg = 0;
+ reg.val = MVCOMMAND_SYNC;
- if (ioctl(m_fdControl, EM8300_IOCTL_WRITEREG, &reg) < 0)
- {
- cLog::Instance() << "cDxr3Device::SetPlayMode Unable to start em8300 sync engine\n";
- }
+ if (ioctl(m_fdControl, EM8300_IOCTL_WRITEREG, &reg) < 0)
+ {
+ cLog::Instance() << "cDxr3Device::SetPlayMode Unable to start em8300 sync engine\n";
+ }
}
Unlock();
@@ -566,12 +576,12 @@ void cDxr3Interface::Pause()
int ioval = EM8300_PLAYMODE_PAUSED;
Lock();
- if (!m_ExternalReleased)
- {
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0)
- {
- cLog::Instance() << "cDxr3Device::Pause Unable to set playmode!\n";
- }
+ if (!m_ExternalReleased)
+ {
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3Device::Pause Unable to set playmode!\n";
+ }
}
Unlock();
@@ -582,11 +592,12 @@ void cDxr3Interface::SingleStep()
int ioval = EM8300_PLAYMODE_SINGLESTEP;
Lock();
- if (!m_ExternalReleased)
- {
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
- cLog::Instance() << "cDxr3Device::Pause Unable to set playmode!\n";
- }
+ if (!m_ExternalReleased)
+ {
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0)
+ {
+ cLog::Instance() << "cDxr3Device::Pause Unable to set playmode!\n";
+ }
}
Unlock();
@@ -598,39 +609,39 @@ void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
int written = 0;
int count = 0;
- if (m_VideoActive)
+ if (m_VideoActive)
+ {
+ Lock();
+
+ if (!m_ExternalReleased)
{
- Lock();
+ for (int i = 0; i < times; i++)
+ {
+ if (times > 1)
+ {
+ cLog::Instance() << "times: " << times << "\n";
+ }
- if (!m_ExternalReleased)
+ while (written < pFrame->GetCount() && count >= 0)
{
- for (int i = 0; i < times; i++)
- {
- if (times > 1)
- {
- cLog::Instance() << "times: " << times << "\n";
- }
-
- while (written < pFrame->GetCount() && count >= 0)
- {
- if ((count = write(m_fdVideo, pFrame->GetData() + written, pFrame->GetCount() - written)) < 0)
- {
- // an error occured
- Resuscitation();
- }
- written += count;
- }
-
- // reset
- written = 0;
- }
- }
-
- Unlock();
-
- SetAspectRatio(pFrame->GetAspectRatio());
- uint32_t pts = pFrame->GetPts();
- if (pts > 0) m_lastSeenPts = pts;
+ if ((count = write(m_fdVideo, pFrame->GetData() + written, pFrame->GetCount() - written)) < 0)
+ {
+ // an error occured
+ Resuscitation();
+ }
+ written += count;
+ }
+
+ // reset
+ written = 0;
+ }
+ }
+
+ Unlock();
+
+ SetAspectRatio(pFrame->GetAspectRatio());
+ uint32_t pts = pFrame->GetPts();
+ if (pts > 0) m_lastSeenPts = pts;
}
}
@@ -638,15 +649,15 @@ void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
{
Lock();
-
- if (!m_ExternalReleased)
+
+ if (!m_ExternalReleased)
+ {
+ for (int i = 0; i < times; i++)
{
- for (int i = 0; i < times; i++)
- {
- if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
- }
+ if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
+ }
}
-
+
Unlock();
}
@@ -654,22 +665,23 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
void cDxr3Interface::PlayAudioFrame(cFixedLengthFrame* pFrame)
{
- // XXX: Call this only with we are not in external mode?
+ // XXX: Call this only with we are not in external mode?
- if (m_AudioActive)
- {
- Lock();
+ if (m_AudioActive)
+ {
+ Lock();
- SetAudioSpeed(pFrame->GetDataRate());
- SetChannelCount(pFrame->GetChannelCount());
+ SetAudioSpeed(pFrame->GetDataRate());
+ SetChannelCount(pFrame->GetChannelCount());
- if (!m_ExternalReleased)
- {
- if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pFrame->GetData(), pFrame->GetCount());
- write(m_fdAudio, pFrame->GetData(), pFrame->GetCount());
- }
+ if (!m_ExternalReleased)
+ {
+ if (!cDxr3ConfigData::Instance().GetAc3OutPut())
+ ResampleVolume((short*)pFrame->GetData(), pFrame->GetCount());
+ write(m_fdAudio, pFrame->GetData(), pFrame->GetCount());
+ }
- Unlock();
+ Unlock();
}
}
@@ -679,15 +691,16 @@ void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
int written = 0;
Lock();
- if (!m_ExternalReleased)
- {
- if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pBuf, length);
+ if (!m_ExternalReleased)
+ {
+ if (!cDxr3ConfigData::Instance().GetAc3OutPut())
+ ResampleVolume((short*)pBuf, length);
- if ((written = write(m_fdAudio, pBuf, length) < 0)) Resuscitation();
- if (written != length)
- {
- cLog::Instance() << "cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
- }
+ if ((written = write(m_fdAudio, pBuf, length) < 0)) Resuscitation();
+ if (written != length)
+ {
+ cLog::Instance() << "cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
+ }
}
Unlock();
@@ -696,42 +709,43 @@ void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
// ==================================
void cDxr3Interface::PlayAudioLpcmFrame(uint8_t* pBuf, int length)
{
- if (length > (LPCM_HEADER_LENGTH + 2))
+ if (length > (LPCM_HEADER_LENGTH + 2))
+ {
+ uint8_t* pFrame = new uint8_t[length - LPCM_HEADER_LENGTH];
+ // only even number of bytes are allowed
+ assert(!((length - LPCM_HEADER_LENGTH) % 2));
+
+ for (int i = LPCM_HEADER_LENGTH; i < length; i += 2)
{
- uint8_t* pFrame = new uint8_t[length - LPCM_HEADER_LENGTH];
- assert(!((length - LPCM_HEADER_LENGTH) % 2)); // only even number of bytes are allowed
-
- for (int i = LPCM_HEADER_LENGTH; i < length; i += 2)
- {
- pFrame[i - LPCM_HEADER_LENGTH] = pBuf[i + 1];
- pFrame[i - LPCM_HEADER_LENGTH + 1] = pBuf[i];
- }
+ pFrame[i - LPCM_HEADER_LENGTH] = pBuf[i + 1];
+ pFrame[i - LPCM_HEADER_LENGTH + 1] = pBuf[i];
+ }
- int codedSpeed = (pBuf[5] >> 4) & 0x03;
- int speed = 0;
+ int codedSpeed = (pBuf[5] >> 4) & 0x03;
+ int speed = 0;
- switch (codedSpeed)
- {
- case 1:
- speed = 96000;
- break;
-
- case 2:
- speed = 44100;
- break;
-
- case 3:
- speed = 32000;
- break;
-
- default:
- speed = 48000;
- break;
- }
-
- SetAudioSpeed(speed);
- PlayAudioFrame(pFrame, length - LPCM_HEADER_LENGTH);
- delete[] pFrame;
+ switch (codedSpeed)
+ {
+ case 1:
+ speed = 96000;
+ break;
+
+ case 2:
+ speed = 44100;
+ break;
+
+ case 3:
+ speed = 32000;
+ break;
+
+ default:
+ speed = 48000;
+ break;
+ }
+
+ SetAudioSpeed(speed);
+ PlayAudioFrame(pFrame, length - LPCM_HEADER_LENGTH);
+ delete[] pFrame;
}
}
@@ -743,22 +757,22 @@ void cDxr3Interface::ExternalReleaseDevices()
{
Lock();
- if (!m_ExternalReleased)
- {
- if (m_fdControl > -1) close(m_fdControl);
- if (m_fdVideo > -1) close(m_fdVideo);
- if (m_fdSpu > -1) close(m_fdSpu);
- if (m_fdAudio > -1) close(m_fdAudio);
- m_fdControl = m_fdVideo = m_fdSpu = m_fdAudio = -1;
- m_aspectRatio = UNKNOWN_ASPECT_RATIO;
- m_audioMode = UNKNOWN_AUDIO_MODE;
-
- m_ExternalReleased = true;
-
- delete m_pClock;
- m_pClock = 0;
+ if (!m_ExternalReleased)
+ {
+ if (m_fdControl > -1) close(m_fdControl);
+ if (m_fdVideo > -1) close(m_fdVideo);
+ if (m_fdSpu > -1) close(m_fdSpu);
+ if (m_fdAudio > -1) close(m_fdAudio);
+ m_fdControl = m_fdVideo = m_fdSpu = m_fdAudio = -1;
+ m_aspectRatio = UNKNOWN_ASPECT_RATIO;
+ m_audioMode = UNKNOWN_AUDIO_MODE;
+
+ m_ExternalReleased = true;
+
+ delete m_pClock;
+ m_pClock = 0;
}
-
+
Unlock();
}
@@ -768,36 +782,40 @@ void cDxr3Interface::ExternalReopenDevices()
{
Lock();
- if (m_ExternalReleased)
+ if (m_ExternalReleased)
+ {
+ // open control stream
+ m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+
+ // open 'multimedia' streams
+ m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+ m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+ m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+
+ if (m_fdControl < 0 || m_fdVideo < 0 || m_fdAudio < 0 || m_fdSpu <0)
{
- // open control stream
- m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
+ ExternalReleaseDevices();
+ }
+ else
+ {
+ m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
+ if (!m_pClock)
+ {
+ cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
+ exit(1);
+ }
- // open 'multimedia' streams
- m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
- m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
- m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
+ SetChannelCount(1);
+ m_ExternalReleased = false;
+ }
- if (m_fdControl < 0 || m_fdVideo < 0 || m_fdAudio < 0 || m_fdSpu <0)
- {
- ExternalReleaseDevices();
- }
- else
- {
- m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
- if (!m_pClock)
- {
- cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
- exit(1);
- }
-
- SetChannelCount(1);
- m_ExternalReleased = false;
- }
-
- Resuscitation();
+ Resuscitation();
}
-
+
Unlock();
}
@@ -809,18 +827,21 @@ void cDxr3Interface::PlayBlackFrame()
{
extern char blackframe[];
extern int blackframeLength;
-
+
Lock();
-
- if (!m_ExternalReleased)
- {
- if (write(m_fdVideo, blackframe, blackframeLength) < 0) Resuscitation();
- if (write(m_fdVideo, blackframe, blackframeLength) < 0) Resuscitation();
- if (write(m_fdVideo, blackframe, blackframeLength) < 0) Resuscitation();
+
+ if (!m_ExternalReleased)
+ {
+ if (write(m_fdVideo, blackframe, blackframeLength) < 0)
+ Resuscitation();
+ if (write(m_fdVideo, blackframe, blackframeLength) < 0)
+ Resuscitation();
+ if (write(m_fdVideo, blackframe, blackframeLength) < 0)
+ Resuscitation();
}
m_horizontal = 720;
m_vertical = 576;
-
+
Unlock();
}
@@ -828,28 +849,30 @@ void cDxr3Interface::PlayBlackFrame()
void cDxr3Interface::ReOpenAudio()
{
Lock();
-
- if (!m_ExternalReleased)
+
+ if (!m_ExternalReleased)
+ {
+ if (m_fdAudio > -1)
{
- if (m_fdAudio > -1)
- {
- int bufsize = 0;
- ioctl(m_fdAudio, SNDCTL_DSP_GETODELAY, &bufsize);
- usleep(bufsize / 192 * 1000);
-
- delete m_pClock;
- close(m_fdAudio);
-
- m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
-
- uint32_t tmpAudioDataRate = m_audioDataRate;
- uint32_t tmpAudioChannelCount = m_audioChannelCount;
- m_audioDataRate = m_audioChannelCount = 0;
- m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
- SetAudioSpeed(tmpAudioDataRate);
- SetChannelCount(tmpAudioChannelCount);
- }
+ int bufsize = 0;
+ ioctl(m_fdAudio, SNDCTL_DSP_GETODELAY, &bufsize);
+ usleep(bufsize / 192 * 1000);
+
+ delete m_pClock;
+ close(m_fdAudio);
+
+ m_fdAudio = Dxr3Open("_ma",
+ cDxr3ConfigData::Instance().GetDxr3Card(),
+ O_WRONLY | O_SYNC);
+
+ uint32_t tmpAudioDataRate = m_audioDataRate;
+ uint32_t tmpAudioChannelCount = m_audioChannelCount;
+ m_audioDataRate = m_audioChannelCount = 0;
+ m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
+ SetAudioSpeed(tmpAudioDataRate);
+ SetChannelCount(tmpAudioChannelCount);
}
+ }
Unlock();
}
@@ -858,7 +881,7 @@ void cDxr3Interface::ReOpenAudio()
// ==================================
cOsdBase* cDxr3Interface::NewOsd(int x, int y)
{
- return new cDxr3Osd(x, y);
+ return new cDxr3Osd(x, y);
}
#endif
@@ -866,140 +889,143 @@ cOsdBase* cDxr3Interface::NewOsd(int x, int y)
//! uploadroutine for microcode
void cDxr3Interface::UploadMicroCode()
{
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading from " << MICROCODE << "...";
- }
+ if (cDxr3ConfigData::Instance().GetDebug())
+ {
+ cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading from "
+ << MICROCODE << "...";
+ }
- em8300_microcode_t em8300_microcode;
+ em8300_microcode_t em8300_microcode;
struct stat s;
- // try to open it
- // MICROCODE comes from makefile
+ // try to open it
+ // MICROCODE comes from makefile
int UCODE = open(MICROCODE, O_RDONLY);
-
- if (UCODE <0)
- {
- cLog::Instance() << "Unable to open microcode file " << MICROCODE << " for reading\n";
- exit(1);
+
+ if (UCODE <0)
+ {
+ cLog::Instance() << "Unable to open microcode file "
+ << MICROCODE << " for reading\n";
+ exit(1);
}
- if (fstat(UCODE, &s ) <0)
- {
- cLog::Instance() << "Unable to fstat ucode file\n";
- exit(1);
+ if (fstat(UCODE, &s ) <0)
+ {
+ cLog::Instance() << "Unable to fstat ucode file\n";
+ exit(1);
}
- // read microcode
+ // read microcode
em8300_microcode.ucode = new char[s.st_size];
- if (em8300_microcode.ucode == NULL)
- {
- cLog::Instance() << "Unable to malloc() space for ucode\n";
- exit(1);
+ if (em8300_microcode.ucode == NULL)
+ {
+ cLog::Instance() << "Unable to malloc() space for ucode\n";
+ exit(1);
}
-
- if (read(UCODE,em8300_microcode.ucode,s.st_size) < 1)
- {
- cLog::Instance() << "Unable to read data from microcode file\n";
- // free memory to avoid memory leak
- delete [] (char*) em8300_microcode.ucode;
- exit(1);
+
+ if (read(UCODE,em8300_microcode.ucode,s.st_size) < 1)
+ {
+ cLog::Instance() << "Unable to read data from microcode file\n";
+ // free memory to avoid memory leak
+ delete [] (char*) em8300_microcode.ucode;
+ exit(1);
}
close(UCODE);
em8300_microcode.ucode_size = s.st_size;
- // upload it
- if( ioctl(m_fdControl, EM8300_IOCTL_INIT, &em8300_microcode) == -1)
- {
- cLog::Instance() << "Microcode upload to failed!! \n";
- // free memory to avoid memory leak
- delete [] (char*) em8300_microcode.ucode;
- exit(1);
+ // upload it
+ if( ioctl(m_fdControl, EM8300_IOCTL_INIT, &em8300_microcode) == -1)
+ {
+ cLog::Instance() << "Microcode upload to failed!! \n";
+ // free memory to avoid memory leak
+ delete [] (char*) em8300_microcode.ucode;
+ exit(1);
}
- // free memory to avoid memory leak
+ // free memory to avoid memory leak
delete [] (char*) em8300_microcode.ucode;
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "...done\n";
- }
+ if (cDxr3ConfigData::Instance().GetDebug())
+ {
+ cLog::Instance() << "...done\n";
+ }
}
// ==================================
//! config and setup device via ioctl calls
void cDxr3Interface::ConfigureDevice()
{
- uint32_t videomode = 0;
+ uint32_t videomode = 0;
- // set video mode
- if (cDxr3ConfigData::Instance().GetVideoMode() == PAL)
+ // set video mode
+ if (cDxr3ConfigData::Instance().GetVideoMode() == PAL)
+ {
+ videomode = EM8300_VIDEOMODE_PAL;
+ if (cDxr3ConfigData::Instance().GetDebug())
{
- videomode = EM8300_VIDEOMODE_PAL;
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = PAL\n";
- }
+ cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = PAL\n";
}
- else if (cDxr3ConfigData::Instance().GetVideoMode() == PAL60)
+ }
+ else if (cDxr3ConfigData::Instance().GetVideoMode() == PAL60)
+ {
+ videomode = EM8300_VIDEOMODE_PAL60;
+ if (cDxr3ConfigData::Instance().GetDebug())
{
- videomode = EM8300_VIDEOMODE_PAL60;
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = PAL60\n";
- }
+ cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = PAL60\n";
}
- else
+ }
+ else
+ {
+ videomode = EM8300_VIDEOMODE_NTSC;
+ if (cDxr3ConfigData::Instance().GetDebug())
{
- videomode = EM8300_VIDEOMODE_NTSC;
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = NTSC\n";
- }
+ cLog::Instance() << "cDxr3Interface::ConfigureDevice: Videomode = NTSC\n";
}
+ }
- // make ioctl
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
- {
- cLog::Instance() << "Unable to set videomode\n";
- exit(1);
+ // make ioctl
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
+ {
+ cLog::Instance() << "Unable to set videomode\n";
+ exit(1);
}
- // set audio mode
- if (!cDxr3ConfigData::Instance().GetUseDigitalOut())
+ // set audio mode
+ if (!cDxr3ConfigData::Instance().GetUseDigitalOut())
+ {
+ SetAudioAnalog();
+ if (cDxr3ConfigData::Instance().GetDebug())
{
- SetAudioAnalog();
- if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "cDxr3Interface::ConfigureDevice: Audiomode = Analog\n";
- }
+ cLog::Instance() << "cDxr3Interface::ConfigureDevice: Audiomode = Analog\n";
}
+ }
}
// ==================================
//! reset whole hardware
-void cDxr3Interface::Resuscitation()
+void cDxr3Interface::Resuscitation()
{
time_t startt = time(&startt);
time_t endt = 0;
m_ExternalReleased = true;
dsyslog("cDxr3Interface::Resuscitation Device failure detected");
-
+
UploadMicroCode();
dsyslog("cDxr3Interface::Resuscitation Micro code upload successfully");
-
-// NonBlockingCloseOpen();
+
+ //NonBlockingCloseOpen();
m_ExternalReleased = false;
-
+
endt = time(&endt);
-
- dsyslog("cDxr3Interface::Resuscitation Reopening devices took %d", (int)(endt - startt));
-
- if (endt - startt > 4)
- {
- exit(1);
+
+ dsyslog("cDxr3Interface::Resuscitation Reopening devices took %d",
+ (int)(endt - startt));
+
+ if (endt - startt > 4)
+ {
+ exit(1);
}
ConfigureDevice();
@@ -1009,18 +1035,18 @@ void cDxr3Interface::Resuscitation()
//! pcm resampling funtcion
void cDxr3Interface::ResampleVolume(short* pcmbuf, int size)
{
- if (m_volume == 0)
- {
- memset(pcmbuf, 0, size);
+ if (m_volume == 0)
+ {
+ memset(pcmbuf, 0, size);
}
- else if (m_volume != 255)
+ else if (m_volume != 255)
+ {
+ int factor = (int)pow (2.0, (double)m_volume/32 + 8.0) - 1;
+ //int factor = (int)pow (2.0, (double)m_volume/16) - 1;
+ for (int i = 0; i < size / (int)sizeof(short); i++)
{
- int factor = (int)pow (2.0, (double)m_volume/32 + 8.0) - 1;
- //int factor = (int)pow (2.0, (double)m_volume/16) - 1;
- for (int i = 0; i < size / (int)sizeof(short); i++)
- {
- pcmbuf[i] = (((int)pcmbuf[i]) * factor) / 65536;
- }
+ pcmbuf[i] = (((int)pcmbuf[i]) * factor) / 65536;
+ }
}
}
@@ -1032,10 +1058,10 @@ void cDxr3Interface::ClearOsd()
int x1 = 0;
int& i = ed.count = 0;
- // display duration...
+ // display duration...
ed.data[i++]= 0x00;
ed.data[i++]= 0x00; //durration before turn on command occurs
- //in 90000/1024 units
+ //in 90000/1024 units
// x1
ed.data[i++]= x1 >> 8; //since this is the last command block, this
ed.data[i++]= x1 & 0xff; //points back to itself
@@ -1046,9 +1072,9 @@ void cDxr3Interface::ClearOsd()
// 0xFF: end sequence
ed.data[i++]= 0xFF;
- if (!i&1)
- {
- ed.data[i++]= 0xff;
+ if (!i&1)
+ {
+ ed.data[i++]= 0xff;
}
// x0
@@ -1059,10 +1085,10 @@ void cDxr3Interface::ClearOsd()
ed.data[0]= i >> 8;
ed.data[1]= i & 0xff;
- if (!m_ExternalReleased)
- {
- WriteSpu((const uint8_t*) &ed, (int) ed.count);
- ClearButton();
+ if (!m_ExternalReleased)
+ {
+ WriteSpu((const uint8_t*) &ed, (int) ed.count);
+ ClearButton();
}
}
@@ -1070,17 +1096,18 @@ void cDxr3Interface::ClearOsd()
void cDxr3Interface::WriteSpu(const uint8_t* pBuf, int length)
{
Lock();
-
- if (!m_ExternalReleased)
- {
- if (write(m_fdSpu, pBuf, length) < 0) Resuscitation();
+
+ if (!m_ExternalReleased)
+ {
+ if (write(m_fdSpu, pBuf, length) < 0) Resuscitation();
}
-
+
Unlock();
}
// ==================================
-void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette)
+void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex,
+ uint16_t ey, uint32_t palette)
{
em8300_button_t button;
@@ -1112,7 +1139,7 @@ void cDxr3Interface::ClearButton()
// ==================================
void cDxr3Interface::SetPalette(unsigned int *pal)
{
- ioctl(m_fdSpu, EM8300_IOCTL_SPU_SETPALETTE, (uint8_t*)pal);
+ ioctl(m_fdSpu, EM8300_IOCTL_SPU_SETPALETTE, (uint8_t*)pal);
}
// helper functions for dxr3 main osd screen
@@ -1120,9 +1147,9 @@ void cDxr3Interface::SetPalette(unsigned int *pal)
//! reset dxr3 card
void cDxr3Interface::ResetHardware()
{
- Lock();
+ Lock();
- cLog::Instance() << "cDxr3Interface: Resetting DXR3 hardware\n";
+ cLog::Instance() << "cDxr3Interface: Resetting DXR3 hardware\n";
Resuscitation();
Unlock();
@@ -1133,36 +1160,36 @@ void cDxr3Interface::ResetHardware()
//! set brightness
void cDxr3Interface::SetBrightness(int value)
{
- m_bcs.brightness = value;
+ m_bcs.brightness = value;
- if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
- {
- cLog::Instance() << "cDxr3Interface::SetBrightness: Unable to set brightness to " << value << "\n";
- }
+ if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
+ {
+ cLog::Instance() << "cDxr3Interface::SetBrightness: Unable to set brightness to " << value << "\n";
+ }
}
// ==================================
//! set contrast
void cDxr3Interface::SetContrast(int value)
{
- m_bcs.contrast = value;
+ m_bcs.contrast = value;
- if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
- {
- cLog::Instance() << "cDxr3Interface::SetContrast: Unable to set contrast to " << value << "\n";
- }
+ if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
+ {
+ cLog::Instance() << "cDxr3Interface::SetContrast: Unable to set contrast to " << value << "\n";
+ }
}
// ==================================
//! set saturation
void cDxr3Interface::SetSaturation(int value)
{
- m_bcs.saturation = value;
+ m_bcs.saturation = value;
- if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
- {
- cLog::Instance() << "cDxr3Interface::SetSaturation: Unable to set saturation to " << value << "\n";
- }
+ if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
+ {
+ cLog::Instance() << "cDxr3Interface::SetSaturation: Unable to set saturation to " << value << "\n";
+ }
}
// ==================================