-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdvddev.c
123 lines (103 loc) · 2.46 KB
/
dvddev.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* DVD Player plugin for VDR
*
* Copyright (C) 2001.2002 Andreas Schultz <[email protected]>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
*/
//#define DVDDEBUG
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "dvddev.h"
#ifndef __QNXNTO__
#include <linux/cdrom.h>
#endif
#ifdef DEBUG
#define DVDDEBUG
#undef DEBUG
#else
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#ifdef DVDDEBUG
#define DEBUG(format, args...) fprintf (stderr, format, ## args)
#else
#define DEBUG(format, args...)
#endif
// --- cDVD ------------------------------------------------------------------
const char *cDVD::deviceName = "/dev/dvd";
cDVD *cDVD::dvdInstance = NULL;
cDVD *cDVD::getDVD(void)
{
if (!dvdInstance)
new cDVD;
return dvdInstance;
}
cDVD::cDVD(void)
{
dvdInstance = this;
}
int cDVD::Command(int Cmd)
{
int result = -1;
int f;
if ((f = open(deviceName, O_RDONLY | O_NONBLOCK)) > 0) {
result = ioctl(f, Cmd, 0);
close(f);
}
return result;
}
void cDVD::SetDeviceName(const char *DeviceName)
{
deviceName = strdup(DeviceName);
}
const char *cDVD::DeviceName(void)
{
return deviceName;
}
bool cDVD::DriveExists(void)
{
return access(deviceName, F_OK) == 0;
}
bool cDVD::DiscOk(void)
{
#ifndef __QNXNTO__
return Command(CDROM_DRIVE_STATUS) == CDS_DISC_OK;
#else
return 1; // fake ok for QNX
#endif
}
void cDVD::Eject(void)
{
// vm_destroy();
#ifndef __QNXNTO__
Command(CDROMEJECT);
#endif
}
#if 0
#define _lang2int( x ) ((x[0] << 8) | x[1]);
int cDVD::vm_reset(void)
{
int ret = ::vm_init(const_cast<char *>(deviceName));
if (ret ==0) {
::vm_reset();
state.registers.SPRM[14] &= ~(0x0f << 8);
state.registers.SPRM[14] |= (Setup.VideoFormat ? 0x03 : 0) << 10;
state.registers.SPRM[14] |= 0x02 << 8; // letterbox is default for dvb/vdr
state.registers.SPRM[0] = _lang2int( LangCodes()[Setup.DVDMenuLanguage] ); // Player Menu Languange code
state.registers.SPRM[16] = _lang2int( LangCodes()[Setup.DVDAudioLanguage] ); // Initial Language Code for Audio
state.registers.SPRM[18] = _lang2int( LangCodes()[Setup.DVDSpuLanguage] ); // Initial Language Code for Spu
state.registers.SPRM[20] = _lang2int( LangCodes()[Setup.DVDPlayerRCE] ); // Player Regional Code (bit mask?)
}
return ret;
}
#endif