summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/mythinstall/xorgsettings.h
blob: 46c4952c2cb5b359fb1250937a234c4317be06c1 (plain)
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
#include <settings.h>
#include "mythdialogs.h"
#include "libmyth/mythdialogs.h"
#include "libmyth/mythwidgets.h"
#include "installsettings.h"

class AdvancedXNvidiaConnections: public TriggeredConfigurationGroup {
Q_OBJECT
public:
    AdvancedXNvidiaConnections();
    HostComboBox *HostXNvidiaConnection;
    HostComboBox *HostXnVidiaTVformat;
    HostComboBox *HostXnVidiaTVstandard;

public slots:
    void AdvancedXNvidiaConnectionsGatherSettings();
signals:
        void nVidia_sig(void);
};


class AdvancedXNvidia_modelines: public TriggeredConfigurationGroup {
    Q_OBJECT
public:
    AdvancedXNvidia_modelines();
    HostComboBox *HostXNvidiaModelineCatagory;
    HostComboBox *HostXNvidiaadvancedresVESA;
    HostComboBox *HostXNvidiaadvancedresATSC;
    HostComboBox *HostXNvidiaadvancedresDVD;
    HostComboBox *HostXNvidiaadvancedresNTSC;
    HostComboBox *HostXNvidiaadvancedresCustom;
    HostCheckBox *HostXnVidia1080p;
    HostCheckBox *HostXnVidia1080i;
    HostCheckBox *HostXnVidia720p;
    HostCheckBox *HostXnVidia480p;
    void Nvidia_fillselection(QString);
public slots:
    void AdvancedXNvidia_modelines_GatherSettings(void);
};


//-------------------------------------------------

class AdvancedXcardtype: public TriggeredConfigurationGroup {
Q_OBJECT
public:
    AdvancedXcardtype();
    HostComboBox *HostXcardtype;

public slots:
    void AdvancedXcardgatherSettings();
signals:
        void go(void );
        void goATI(void);
        void gonVidia(void);
};


class AdvancedXSettings:    public TriggeredConfigurationGroup {
Q_OBJECT
public:
    AdvancedXSettings();
    HostCheckBox *HostXIgnoreConfig;
protected slots:
    void ADJUSTEDID(void);
};


class AdvancedXGeneric_modelines: public TriggeredConfigurationGroup {
    Q_OBJECT
public:
    AdvancedXGeneric_modelines();
    HostComboBox *HostXModelineCatagory;
    HostComboBox *HostXadvancedresVESA;
    HostComboBox *HostXadvancedresATSC;
    HostComboBox *HostXadvancedresDVD;
    HostComboBox *HostXadvancedresNTSC;
    HostComboBox *HostXadvancedresCustom;
    void generic_fillselection(QString);
public slots:
    void AdvancedXGeneric_modelines_GatherSettings(void);
};


class EDIDOptions : public ConfigurationWizard
{
public:
    EDIDOptions();
};








void testXconfiguration();
void ReadDDCvalues();
static HostComboBox *HostXres()
//Used in the simple config
{
    HostComboBox *gc = new HostComboBox("HostXres");
    gc->setLabel(QObject::tr("Initial resolution"));
    const int num_defaults = 2;
    char *defaults[num_defaults]={"800x600","1280x720"};
    int defaults_added[num_defaults]={0,0};
    int found_modes_in_xorg_log = FALSE;

    gc->addSelection("Auto");

    {
      FILE *modelines;
      const char*mode_extract_command =
        "sed -n 's/[[:space:]]\\+/ /g;"             // compress whitespace
                "s/[\\) ]: /#/g;"              // Insert # as a field delimiter
		"/Modes in ModePool/,/ModePool/p'" // get the Modelool lines
		" /var/log/Xorg.0.log |"             // from the Xorg log
	"cut -d# -f2-3 | "            // select the mode and description fields
	"sed '/^\\\"/!d;"             // Only selest modeline lines.
	     "/DoubleScan/d;"         // Remove doublescan modelines.
	     "/nvidia-auto-select/d;" // Remove auto modeline.
             "s/ x /x/g;"
	     "s/ @ /@/g;"
             "s/From: //g;"
             "s/ Format [0-9]*) (/, /g;"
             "s/ Format [0-9]*//g;"
	     "s/ Server//g'"; //reformat. 
      cout << mode_extract_command << endl;
      modelines = popen (mode_extract_command, "r");

      char previous_mode[200]={0};

      if (modelines)
      {
	char line_in[200];
	while (fgets (line_in, sizeof (line_in), modelines))
	{
          char *separator;

	  if (strchr (line_in, '\n'))
	    strchr (line_in, '\n')[0]=0;

	  separator = strchr (line_in, '#');

	  if (separator)
	  {
	    separator[0]=0;
	    separator++;

  	    // Skip this mode if the description is identical to the previous.
	    if (strcmp (previous_mode, separator) == 0)
	      continue;

	    strncpy (previous_mode, separator, sizeof(previous_mode));
  	    gc->addSelection(separator, line_in);
	    found_modes_in_xorg_log = TRUE;

 	    for (int def = 0; def < num_defaults; def++)
	      if (strncmp (&line_in[1], defaults[def], strlen (defaults[def]))==0)
	        defaults_added[def]=1;
	  }
	}
	pclose (modelines);
      }
    }

    for (int def = 0; def < num_defaults; def++)
      if (!defaults_added[def])
	gc->addSelection(defaults[def], defaults[def]);

    if (found_modes_in_xorg_log)
      gc->setHelpText(QObject::tr("Choose a resolution to match your display and a refresh rate to match the content you will be recording - 60 Hz for NTSC (e.g. US) 50 Hz for PAL (e.g. UK, Aust, NZ)."));
    else
      gc->setHelpText(QObject::tr("Choose the resolution to use when the system reboots."));

    return gc;
}