Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] [PATCH] dxr3: workaround and possible fix for "incorrect ioctl()"errors



It appears that the "incorrect ioctl()" errors being generated by the current dxr3-0.2.0 driver are caused by a bug uncovered by a subtle change in the recent code. A small change to the dxr3abstractiondevice.c code results in the em8300 audio and video fd's getting swapped (caused by the two fd's being closed and then re-opened in a different order). This can be worked around by swapping the two open lines, but doesn't fix the underlying problem.

The real problem appears to be cDxr3SysClock() code gets passed the video fd, and doesn't updated when the fd is reopened, hence it continues to operate on the old video fd. The patch deletes the cDxr3SysClock object and recreates a new one each time the video device is re-opened. This seems to work for me, but it probably needs to be checked by someone that understands the code a bit better.

As an aside, I really dislike the em8300 driver's use of ioctl() numbers 0,1,2 rather than the usual magic _IO(...) values. strace thought these were for "FIBMAP". This made trying to track down the mysterious ioctl calls quite tricky. Is there a chance these could be fixed up in the em8300 driver?

Jon


--- dxr3abstractiondevice.c	Tue Jun  3 17:09:21 2003
+++ new/dxr3abstractiondevice.c	Mon Jun  9 19:19:24 2003
@@ -626,10 +626,12 @@
             ioctl(m_fdAudio, SNDCTL_DSP_GETODELAY, &bufsize);
             usleep(bufsize / 192 * 1000);
             
+	    delete m_pClock;
             close(m_fdAudio);
             close(m_fdVideo);
-            m_fdAudio = open(dxr3DeviceName( "_ma" ).c_str(), O_WRONLY | O_SYNC); assert(m_fdAudio >= 0);
             m_fdVideo = open(dxr3DeviceName( "_mv" ).c_str(), O_WRONLY | O_SYNC); assert(m_fdVideo >= 0);
+            m_fdAudio = open(dxr3DeviceName( "_ma" ).c_str(), O_WRONLY | O_SYNC); assert(m_fdAudio >= 0);
+	    m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
             uint32_t tmpAudioDataRate = m_audioDataRate;
             uint32_t tmpAudioChannelCount = m_audioChannelCount;
             m_audioDataRate = m_audioChannelCount = 0;
@@ -770,6 +772,10 @@
 
 void cDxr3AbsDevice::NonBlockingCloseOpen(void) {
     int count = 0;
+
+    delete m_pClock;
+    m_pClock = 0;
+
     do {
         cDxr3SafeCloseThread* pControlClose = new cDxr3SafeCloseThread(m_fdControl);
         pControlClose->Start();
@@ -793,6 +799,7 @@
         m_fdSpu = open(dxr3DeviceName( "_sp" ).c_str(), O_WRONLY | O_SYNC);
         count++;
     } while ( (m_fdControl < 0 || m_fdVideo < 0 || m_fdAudio < 0 || m_fdSpu < 0) || (count < 2));    
+    m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
 }
 
 void cDxr3AbsDevice::UploadMicroCode(void) {

Home | Main Index | Thread Index