Adapted VDR to the NEWSTRUCT driver

This commit is contained in:
Klaus Schmidinger 2002-08-10 14:58:25 +02:00
parent 506c772bd7
commit fd1f60e0e0
9 changed files with 171 additions and 38 deletions

View File

@ -374,3 +374,6 @@ Christian Rienecker <C.Rienecker@deutschepost.de>
Joerg Riechardt <J.Riechardt@gmx.de>
for filling in some missing teletext PIDs
Holger Wächtler <holger@convergence.de>
for some valuable advice during adapting to the NEWSTRUCT driver

View File

@ -1392,3 +1392,9 @@ Video Disk Recorder Revision History
- Now using CC, CFLAGS, CXX and CXXFLAGS in Makefile.
- Changed the cDevice class to allow plugins to implement their own devices (see
PLUGINS.html for details).
2002-08-10: Version 1.1.7
- Adapted VDR to the NEWSTRUCT driver. To use the new driver, compile VDR with
'make NEWSTRUCT=1' (thanks to Holger Wächtler for some valuable advice).
By default it currently still uses the old driver.

View File

@ -4,7 +4,7 @@
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
# $Id: Makefile 1.44 2002/07/28 15:20:47 kls Exp $
# $Id: Makefile 1.45 2002/08/09 16:02:02 kls Exp $
.DELETE_ON_ERROR:
@ -23,7 +23,12 @@ PLUGINDIR= ./PLUGINS
VIDEODIR = /video
ifdef NEWSTRUCT
INCLUDES = -I$(DVBDIR)/include
DEFINES += -DNEWSTRUCT
else
INCLUDES = -I$(DVBDIR)/ost/include
endif
DTVLIB = $(DTVDIR)/libdtv.a

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.h 1.121 2002/07/27 12:00:30 kls Exp $
* $Id: config.h 1.122 2002/08/09 14:53:21 kls Exp $
*/
#ifndef __CONFIG_H
@ -19,7 +19,7 @@
#include "eit.h"
#include "tools.h"
#define VDRVERSION "1.1.6"
#define VDRVERSION "1.1.7"
#define MAXPRIORITY 99
#define MAXLIFETIME 99

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbdevice.c 1.1 2002/08/04 12:24:25 kls Exp $
* $Id: dvbdevice.c 1.2 2002/08/10 14:57:33 kls Exp $
*/
#include "dvbdevice.h"
@ -18,9 +18,15 @@ extern "C" {
}
#include <limits.h>
#include <linux/videodev.h>
#ifdef NEWSTRUCT
#include <linux/dvb/audio.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/video.h>
#else
#include <ost/audio.h>
#include <ost/sec.h>
#include <ost/video.h>
#endif
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@ -33,24 +39,38 @@ extern "C" {
#define MAXDVBDEVICES 4
#define DEV_VIDEO "/dev/video"
#define DEV_OST_OSD "/dev/ost/osd"
#define DEV_OST_FRONTEND "/dev/ost/frontend"
#define DEV_OST_SEC "/dev/ost/sec"
#define DEV_OST_DVR "/dev/ost/dvr"
#define DEV_OST_DEMUX "/dev/ost/demux"
#define DEV_OST_VIDEO "/dev/ost/video"
#define DEV_OST_AUDIO "/dev/ost/audio"
#ifdef NEWSTRUCT
#define DEV_DVB_ADAPTER "/dev/dvb/adapter"
#define DEV_DVB_OSD "osd"
#define DEV_DVB_FRONTEND "frontend"
#define DEV_DVB_DVR "dvr"
#define DEV_DVB_DEMUX "demux"
#define DEV_DVB_VIDEO "video"
#define DEV_DVB_AUDIO "audio"
#else
#define DEV_DVB_OSD "/dev/ost/osd"
#define DEV_DVB_FRONTEND "/dev/ost/frontend"
#define DEV_DVB_SEC "/dev/ost/sec"
#define DEV_DVB_DVR "/dev/ost/dvr"
#define DEV_DVB_DEMUX "/dev/ost/demux"
#define DEV_DVB_VIDEO "/dev/ost/video"
#define DEV_DVB_AUDIO "/dev/ost/audio"
#endif
static const char *OstName(const char *Name, int n)
static const char *DvbName(const char *Name, int n)
{
static char buffer[PATH_MAX];
#ifdef NEWSTRUCT
snprintf(buffer, sizeof(buffer), "%s%d/%s%d", DEV_DVB_ADAPTER, n, Name, 0);
#else
snprintf(buffer, sizeof(buffer), "%s%d", Name, n);
#endif
return buffer;
}
static int OstOpen(const char *Name, int n, int Mode, bool ReportError = false)
static int DvbOpen(const char *Name, int n, int Mode, bool ReportError = false)
{
const char *FileName = OstName(Name, n);
const char *FileName = DvbName(Name, n);
int fd = open(FileName, Mode);
if (fd < 0 && ReportError)
LOG_ERROR_STR(FileName);
@ -64,17 +84,19 @@ cDvbDevice::cDvbDevice(int n)
// Devices that are present on all card types:
fd_frontend = OstOpen(DEV_OST_FRONTEND, n, O_RDWR);
// Devices that are only present on DVB-S cards:
fd_sec = OstOpen(DEV_OST_SEC, n, O_RDWR);
fd_frontend = DvbOpen(DEV_DVB_FRONTEND, n, O_RDWR | O_NONBLOCK);
// Devices that are only present on cards with decoders:
fd_osd = OstOpen(DEV_OST_OSD, n, O_RDWR);
fd_video = OstOpen(DEV_OST_VIDEO, n, O_RDWR | O_NONBLOCK);
fd_audio = OstOpen(DEV_OST_AUDIO, n, O_RDWR | O_NONBLOCK);
fd_osd = DvbOpen(DEV_DVB_OSD, n, O_RDWR);
fd_video = DvbOpen(DEV_DVB_VIDEO, n, O_RDWR | O_NONBLOCK);
fd_audio = DvbOpen(DEV_DVB_AUDIO, n, O_RDWR | O_NONBLOCK);
#ifndef NEWSTRUCT
// Devices that are only present on DVB-S cards:
fd_sec = DvbOpen(DEV_DVB_SEC, n, O_RDWR);
#endif
// The DVR device (will be opened and closed as needed):
@ -87,8 +109,12 @@ cDvbDevice::cDvbDevice(int n)
// We only check the devices that must be present - the others will be checked before accessing them://XXX
if (fd_frontend >= 0) {
siProcessor = new cSIProcessor(OstName(DEV_OST_DEMUX, n));
#ifdef NEWSTRUCT
dvb_frontend_info feinfo;
#else
FrontendInfo feinfo;
#endif
siProcessor = new cSIProcessor(DvbName(DEV_DVB_DEMUX, n));
if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0)
frontendType = feinfo.type;
else
@ -130,7 +156,7 @@ bool cDvbDevice::Initialize(void)
int i;
for (i = 0; i < MAXDVBDEVICES; i++) {
if (UseDevice(NextCardIndex())) {
if (Probe(OstName(DEV_OST_FRONTEND, i))) {
if (Probe(DvbName(DEV_DVB_FRONTEND, i))) {
new cDvbDevice(i);
found++;
}
@ -169,7 +195,7 @@ bool cDvbDevice::HasDecoder(void) const
bool cDvbDevice::GrabImage(const char *FileName, bool Jpeg, int Quality, int SizeX, int SizeY)
{
int videoDev = OstOpen(DEV_VIDEO, CardIndex(), O_RDWR, true);
int videoDev = DvbOpen(DEV_VIDEO, CardIndex(), O_RDWR, true);
if (videoDev >= 0) {
int result = 0;
struct video_mbuf mbuf;
@ -274,7 +300,7 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
if (Handle->pid) {
if (On) {
if (Handle->handle < 0) {
Handle->handle = OstOpen(DEV_OST_DEMUX, CardIndex(), O_RDWR | O_NONBLOCK, true);
Handle->handle = DvbOpen(DEV_DVB_DEMUX, CardIndex(), O_RDWR | O_NONBLOCK, true);
if (Handle->handle < 0)
return false;
}
@ -332,7 +358,11 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
DelPid(pidHandles[ptDolby].pid);
}
#ifdef NEWSTRUCT
dvb_frontend_parameters Frontend;
#else
FrontendParameters Frontend;
#endif
switch (frontendType) {
case FE_QPSK: { // DVB-S
@ -351,15 +381,38 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
tone = SEC_TONE_ON;
}
#ifdef NEWSTRUCT
Frontend.frequency = freq * 1000UL;
Frontend.inversion = INVERSION_AUTO;
Frontend.u.qpsk.symbol_rate = Channel->srate * 1000UL;
Frontend.u.qpsk.fec_inner = FEC_AUTO;
#else
Frontend.Frequency = freq * 1000UL;
Frontend.Inversion = INVERSION_AUTO;
Frontend.u.qpsk.SymbolRate = Channel->srate * 1000UL;
Frontend.u.qpsk.FEC_inner = FEC_AUTO;
#endif
int volt = (Channel->polarization == 'v' || Channel->polarization == 'V') ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
// DiseqC:
// DiSEqC:
#ifdef NEWSTRUCT
struct dvb_diseqc_master_cmd cmd = { {0xE0, 0x10, 0x38, 0xF0, 0x00, 0x00}, 4};
cmd.msg[3] = 0xF0 | (((Channel->diseqc * 4) & 0x0F) | (tone == SEC_TONE_ON ? 1 : 0) | (volt == SEC_VOLTAGE_18 ? 2 : 0));
if (Setup.DiSEqC)
CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF));
CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, volt));
if (Setup.DiSEqC) {
usleep(15 * 1000);
CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
usleep(15 * 1000);
CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, (Channel->diseqc / 4) % 2 ? SEC_MINI_B : SEC_MINI_A));
usleep(15 * 1000);
}
CHECK(ioctl(fd_frontend, FE_SET_TONE, tone));
#else
secCommand scmd;
scmd.type = 0;
scmd.u.diseqc.addr = 0x10;
@ -375,23 +428,43 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
scmds.commands = &scmd;
CHECK(ioctl(fd_sec, SEC_SEND_SEQUENCE, &scmds));
#endif
}
break;
case FE_QAM: { // DVB-C
// Frequency and symbol rate:
#ifdef NEWSTRUCT
Frontend.frequency = Channel->frequency * 1000000UL;
Frontend.inversion = INVERSION_AUTO;
Frontend.u.qam.symbol_rate = Channel->srate * 1000UL;
Frontend.u.qam.fec_inner = FEC_AUTO;
Frontend.u.qam.modulation = QAM_64;
#else
Frontend.Frequency = Channel->frequency * 1000000UL;
Frontend.Inversion = INVERSION_AUTO;
Frontend.u.qam.SymbolRate = Channel->srate * 1000UL;
Frontend.u.qam.FEC_inner = FEC_AUTO;
Frontend.u.qam.QAM = QAM_64;
#endif
}
break;
case FE_OFDM: { // DVB-T
// Frequency and OFDM paramaters:
#ifdef NEWSTRUCT
Frontend.frequency = Channel->frequency * 1000UL;
Frontend.inversion = INVERSION_AUTO;
Frontend.u.ofdm.bandwidth=BANDWIDTH_8_MHZ;
Frontend.u.ofdm.code_rate_HP = FEC_2_3;
Frontend.u.ofdm.code_rate_LP = FEC_1_2;
Frontend.u.ofdm.constellation = QAM_64;
Frontend.u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
Frontend.u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
Frontend.u.ofdm.hierarchy_information = HIERARCHY_NONE;
#else
Frontend.Frequency = Channel->frequency * 1000UL;
Frontend.Inversion = INVERSION_AUTO;
Frontend.u.ofdm.bandWidth=BANDWIDTH_8_MHZ;
@ -401,6 +474,7 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
Frontend.u.ofdm.TransmissionMode=TRANSMISSION_MODE_2K;
Frontend.u.ofdm.guardInterval=GUARD_INTERVAL_1_32;
Frontend.u.ofdm.HierarchyInformation=HIERARCHY_NONE;
#endif
}
break;
default:
@ -408,16 +482,40 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
return false;
}
#ifdef NEWSTRUCT
// Discard stale events:
for (;;) {
dvb_frontend_event event;
if (ioctl(fd_frontend, FE_GET_EVENT, &event) < 0)
break;
}
#endif
// Tuning:
CHECK(ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend));
// Wait for channel sync:
// Wait for channel lock:
#ifdef NEWSTRUCT
FrontendStatus status = FrontendStatus(0);
for (int i = 0; i < 100; i++) {
CHECK(ioctl(fd_frontend, FE_READ_STATUS, &status));
if (status & FE_HAS_LOCK)
break;
usleep(10 * 1000);
}
if (!(status & FE_HAS_LOCK)) {
esyslog("ERROR: channel %d not locked on DVB card %d!", Channel->number, CardIndex() + 1);
if (IsPrimaryDevice())
cThread::RaisePanic();
return false;
}
#else
if (cFile::FileReady(fd_frontend, 5000)) {
FrontendEvent event;
int res = ioctl(fd_frontend, FE_GET_EVENT, &event);
if (res >= 0) {
if (ioctl(fd_frontend, FE_GET_EVENT, &event) >= 0) {
if (event.type != FE_COMPLETION_EV) {
esyslog("ERROR: channel %d not sync'ed on DVB card %d!", Channel->number, CardIndex() + 1);
if (IsPrimaryDevice())
@ -426,10 +524,11 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel)
}
}
else
esyslog("ERROR %d in frontend get event (channel %d, card %d)", res, Channel->number, CardIndex() + 1);
esyslog("ERROR in frontend get event (channel %d, card %d): %m", Channel->number, CardIndex() + 1);
}
else
esyslog("ERROR: timeout while tuning");
esyslog("ERROR: timeout while tuning on DVB card %d", CardIndex() + 1);
#endif
frequency = Channel->frequency;
@ -574,7 +673,7 @@ int cDvbDevice::PlayAudio(const uchar *Data, int Length)
bool cDvbDevice::OpenDvr(void)
{
CloseDvr();
fd_dvr = OstOpen(DEV_OST_DVR, CardIndex(), O_RDONLY | O_NONBLOCK, true);
fd_dvr = DvbOpen(DEV_DVB_DVR, CardIndex(), O_RDONLY | O_NONBLOCK, true);
return fd_dvr >= 0;
}

View File

@ -4,18 +4,22 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbdevice.h 1.1 2002/08/04 12:19:10 kls Exp $
* $Id: dvbdevice.h 1.2 2002/08/09 16:23:53 kls Exp $
*/
#ifndef __DVBDEVICE_H
#define __DVBDEVICE_H
#ifdef NEWSTRUCT
#include <linux/dvb/frontend.h>
#else
#include <stdlib.h> // FIXME: this is apparently necessary for the ost/... header files
// FIXME: shouldn't every header file include ALL the other header
// FIXME: files it depends on? The sequence in which header files
// FIXME: are included here should not matter - and it should NOT
// FIXME: be necessary to include <stdlib.h> here!
#include <ost/frontend.h>
#endif
#include "device.h"
#include "eit.h"
@ -30,7 +34,11 @@ public:
// Must be called before accessing any DVB functions.
private:
FrontendType frontendType;
#ifdef NEWSTRUCT
int fd_osd, fd_frontend, fd_audio, fd_video, fd_dvr;
#else
int fd_osd, fd_frontend, fd_sec, fd_audio, fd_video, fd_dvr;
#endif
int OsdDeviceHandle(void) const { return fd_osd; }
protected:
virtual void MakePrimaryDevice(bool On);

View File

@ -4,13 +4,17 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbosd.h 1.14 2002/08/04 10:12:14 kls Exp $
* $Id: dvbosd.h 1.15 2002/08/09 16:16:48 kls Exp $
*/
#ifndef __DVBOSD_H
#define __DVBOSD_H
#ifdef NEWSTRUCT
#include <linux/dvb/osd.h>
#else
#include <ost/osd.h>
#endif
#include "dvbdevice.h"
#include "osdbase.h"

6
eit.c
View File

@ -16,7 +16,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* $Id: eit.c 1.46 2002/06/10 16:30:00 kls Exp $
* $Id: eit.c 1.47 2002/08/09 16:17:14 kls Exp $
***************************************************************************/
#include "eit.h"
@ -26,7 +26,11 @@
#include <iomanip.h>
#include <iostream.h>
#include <limits.h>
#ifdef NEWSTRUCT
#include <linux/dvb/dmx.h>
#else
#include <ost/dmx.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -4,14 +4,18 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: remux.h 1.6 2002/08/04 10:27:07 kls Exp $
* $Id: remux.h 1.7 2002/08/09 16:18:02 kls Exp $
*/
#ifndef __REMUX_H
#define __REMUX_H
#include <time.h> //XXX FIXME: DVB/ost/include/ost/dmx.h should include <time.h> itself!!!
#include <time.h> //XXX FIXME: DVB/linux/dvb/dmx.h should include <time.h> itself!!!
#ifdef NEWSTRUCT
#include <linux/dvb/dmx.h>
#else
#include <ost/dmx.h>
#endif
#include "tools.h"
// Picture types: