1 /*************************************************************************************
2  *  Copyright 2018   Daniel Vrátil <dvratil@kde.org>                                 *
3  *                                                                                   *
4  *  This library is free software; you can redistribute it and/or                    *
5  *  modify it under the terms of the GNU Lesser General Public                       *
6  *  License as published by the Free Software Foundation; either                     *
7  *  version 2.1 of the License, or (at your option) any later version.               *
8  *                                                                                   *
9  *  This library is distributed in the hope that it will be useful,                  *
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                *
12  *  Lesser General Public License for more details.                                  *
13  *                                                                                   *
14  *  You should have received a copy of the GNU Lesser General Public                 *
15  *  License along with this library; if not, write to the Free Software              *
16  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA       *
17  *************************************************************************************/
18 
19 #include "utils.h"
20 
21 #include <QVector>
22 
guessOutputType(const QString & type,const QString & name)23 Disman::Output::Type Utils::guessOutputType(const QString& type, const QString& name)
24 {
25     static const auto embedded = {QLatin1String("LVDS"),
26                                   QLatin1String("IDP"),
27                                   QLatin1String("EDP"),
28                                   QLatin1String("LCD"),
29                                   QLatin1String("DSI")};
30 
31     for (const QLatin1String& pre : embedded) {
32         if (name.startsWith(pre, Qt::CaseInsensitive)) {
33             return Disman::Output::Panel;
34         }
35     }
36 
37     if (type.contains(QLatin1String("VGA"))) {
38         return Disman::Output::VGA;
39     } else if (type.contains(QLatin1String("DVI"))) {
40         return Disman::Output::DVI;
41     } else if (type.contains(QLatin1String("DVI-I"))) {
42         return Disman::Output::DVII;
43     } else if (type.contains(QLatin1String("DVI-A"))) {
44         return Disman::Output::DVIA;
45     } else if (type.contains(QLatin1String("DVI-D"))) {
46         return Disman::Output::DVID;
47     } else if (type.contains(QLatin1String("HDMI"))) {
48         return Disman::Output::HDMI;
49     } else if (type.contains(QLatin1String("Panel"))) {
50         return Disman::Output::Panel;
51     } else if (type.contains(QLatin1String("TV-Composite"))) {
52         return Disman::Output::TVComposite;
53     } else if (type.contains(QLatin1String("TV-SVideo"))) {
54         return Disman::Output::TVSVideo;
55     } else if (type.contains(QLatin1String("TV-Component"))) {
56         return Disman::Output::TVComponent;
57     } else if (type.contains(QLatin1String("TV-SCART"))) {
58         return Disman::Output::TVSCART;
59     } else if (type.contains(QLatin1String("TV-C4"))) {
60         return Disman::Output::TVC4;
61     } else if (type.contains(QLatin1String("TV"))) {
62         return Disman::Output::TV;
63     } else if (type.contains(QLatin1String("DisplayPort"))
64                || type.startsWith(QLatin1String("DP"))) {
65         return Disman::Output::DisplayPort;
66     } else if (type.contains(QLatin1String("unknown"))) {
67         return Disman::Output::Unknown;
68     } else {
69         return Disman::Output::Unknown;
70     }
71 }
72