-
Notifications
You must be signed in to change notification settings - Fork 12
/
custom_video.cpp
178 lines (147 loc) · 4.31 KB
/
custom_video.cpp
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**************************************************************
custom_video.cpp - Custom video library
---------------------------------------------------------
Switchres Modeline generation engine for emulation
License GPL-2.0+
Copyright 2010-2021 Chris Kennedy, Antonio Giner,
Alexandre Wodarczyk, Gil Delescluse
**************************************************************/
#include <stdio.h>
#include "custom_video.h"
#include "log.h"
#if defined(_WIN32)
#include "custom_video_ati.h"
#include "custom_video_adl.h"
#include "custom_video_pstrip.h"
#elif defined(__linux__)
#ifdef SR_WITH_XRANDR
#include "custom_video_xrandr.h"
#endif
#ifdef SR_WITH_KMSDRM
#include "custom_video_drmkms.h"
#endif
#endif
extern bool ati_is_legacy(int vendor, int device);
//============================================================
// custom_video::make
//============================================================
custom_video *custom_video::make(char *device_name, char *device_id, int method, custom_video_settings *vs)
{
#if defined(_WIN32)
if (method == CUSTOM_VIDEO_TIMING_POWERSTRIP)
{
m_custom_video = new pstrip_timing(device_name, vs);
if (m_custom_video)
{
m_custom_method = CUSTOM_VIDEO_TIMING_POWERSTRIP;
return m_custom_video;
}
}
else
{
int vendor, device;
sscanf(device_id, "PCI\\VEN_%x&DEV_%x", &vendor, &device);
if (vendor == 0x1002) // ATI/AMD
{
if (ati_is_legacy(vendor, device))
{
m_custom_video = new ati_timing(device_name, vs);
if (m_custom_video)
{
m_custom_method = CUSTOM_VIDEO_TIMING_ATI_LEGACY;
return m_custom_video;
}
}
else
{
m_custom_video = new adl_timing(device_name, vs);
if (m_custom_video)
{
m_custom_method = CUSTOM_VIDEO_TIMING_ATI_ADL;
return m_custom_video;
}
}
}
else
log_info("Video chipset is not compatible.\n");
}
#elif defined(__linux__)
if (device_id != NULL)
log_info("Device value is %s.\n", device_id);
#ifdef SR_WITH_XRANDR
if (method == CUSTOM_VIDEO_TIMING_XRANDR || method == 0)
{
try
{
m_custom_video = new xrandr_timing(device_name, vs);
}
catch (...) {};
if (m_custom_video)
{
m_custom_method = CUSTOM_VIDEO_TIMING_XRANDR;
return m_custom_video;
}
}
#endif /* SR_WITH_XRANDR */
#ifdef SR_WITH_KMSDRM
if (method == CUSTOM_VIDEO_TIMING_DRMKMS || method == 0)
{
m_custom_video = new drmkms_timing(device_name, vs);
if (m_custom_video)
{
m_custom_method = CUSTOM_VIDEO_TIMING_DRMKMS;
return m_custom_video;
}
}
#endif /* SR_WITH_KMSDRM */
#endif
return this;
}
//============================================================
// custom_video::init
//============================================================
bool custom_video::init() { return false; }
//============================================================
// custom_video::get_timing
//============================================================
bool custom_video::get_timing(modeline *mode)
{
log_verbose("system mode\n");
mode->type |= CUSTOM_VIDEO_TIMING_SYSTEM;
return false;
}
//============================================================
// custom_video::set_timing
//============================================================
bool custom_video::set_timing(modeline *)
{
return false;
}
//============================================================
// custom_video::add_mode
//============================================================
bool custom_video::add_mode(modeline *)
{
return false;
}
//============================================================
// custom_video::delete_mode
//============================================================
bool custom_video::delete_mode(modeline *)
{
return false;
}
//============================================================
// custom_video::update_mode
//============================================================
bool custom_video::update_mode(modeline *)
{
return false;
}
//============================================================
// custom_video::process_modelist
//============================================================
bool custom_video::process_modelist(std::vector<modeline *>)
{
return false;
}