vdr  1.7.31
setup.c
Go to the documentation of this file.
1 /*
2  * setup.c: Setup for the DVB HD Full Featured On Screen Display
3  *
4  * See the README file for copyright information and how to reach the author.
5  *
6  * $Id: setup.c 1.17 2012/02/08 15:14:01 kls Exp $
7  */
8 
9 #include "setup.h"
10 #include "hdffcmd.h"
11 
12 const int kResolution1080i = 0;
13 const int kResolution720p = 1;
14 const int kResolution576p = 2;
15 const int kResolution576i = 3;
16 
17 
19 
21 {
27  AudioDelay = 0;
29  OsdSize = 0;
30  CecEnabled = 1;
31  CecTvOn = 1;
32  CecTvOff = 0;
33  RemoteProtocol = 1;
34  RemoteAddress = -1;
35  HighLevelOsd = 1;
36  TrueColorOsd = 1;
37  HideMainMenu = 0;
38 }
39 
40 bool cHdffSetup::SetupParse(const char *Name, const char *Value)
41 {
42  if (strcmp(Name, "Resolution") == 0) Resolution = atoi(Value);
43  else if (strcmp(Name, "VideoModeAdaption") == 0) VideoModeAdaption = atoi(Value);
44  else if (strcmp(Name, "TvFormat") == 0) TvFormat = atoi(Value);
45  else if (strcmp(Name, "VideoConversion") == 0) VideoConversion = atoi(Value);
46  else if (strcmp(Name, "AnalogueVideo") == 0) AnalogueVideo = atoi(Value);
47  else if (strcmp(Name, "AudioDelay") == 0) AudioDelay = atoi(Value);
48  else if (strcmp(Name, "AudioDownmix") == 0) AudioDownmix = atoi(Value);
49  else if (strcmp(Name, "OsdSize") == 0) OsdSize = atoi(Value);
50  else if (strcmp(Name, "CecEnabled") == 0) CecEnabled = atoi(Value);
51  else if (strcmp(Name, "CecTvOn") == 0) CecTvOn = atoi(Value);
52  else if (strcmp(Name, "CecTvOff") == 0) CecTvOff = atoi(Value);
53  else if (strcmp(Name, "RemoteProtocol") == 0) RemoteProtocol = atoi(Value);
54  else if (strcmp(Name, "RemoteAddress") == 0) RemoteAddress = atoi(Value);
55  else if (strcmp(Name, "HighLevelOsd") == 0) HighLevelOsd = atoi(Value);
56  else if (strcmp(Name, "TrueColorOsd") == 0) TrueColorOsd = atoi(Value);
57  else if (strcmp(Name, "HideMainMenu") == 0) HideMainMenu = atoi(Value);
58  else return false;
59  return true;
60 }
61 
62 void cHdffSetup::GetOsdSize(int &Width, int &Height, double &PixelAspect)
63 {
64  if (OsdSize == 0) {
66  Width = 1920;
67  Height = 1080;
68  }
69  else if (Resolution == kResolution720p) {
70  Width = 1280;
71  Height = 720;
72  }
73  else {
74  Width = 720;
75  Height = 576;
76  }
78  PixelAspect = 16.0 / 9.0;
79  else
80  PixelAspect = 4.0 / 3.0;
81  }
82  else if (OsdSize == 1) {
83  Width = 1920;
84  Height = 1080;
85  PixelAspect = 16.0 / 9.0;
86  }
87  else if (OsdSize == 2) {
88  Width = 1280;
89  Height = 720;
90  PixelAspect = 16.0 / 9.0;
91  }
92  else if (OsdSize == 3) {
93  Width = 1024;
94  Height = 576;
95  PixelAspect = 16.0 / 9.0;
96  }
97  else {
98  Width = 720;
99  Height = 576;
100  PixelAspect = 4.0 / 3.0;
101  }
102  PixelAspect /= double(Width) / Height;
103 }
104 
106 {
107  switch (Resolution)
108  {
109  case kResolution1080i:
110  default:
112  case kResolution720p:
113  return HDFF_VIDEO_MODE_720P50;
114  case kResolution576p:
115  return HDFF_VIDEO_MODE_576P50;
116  case kResolution576i:
117  return HDFF_VIDEO_MODE_576I50;
118  }
119 }
120 
122 {
123  int nextVideoConversion = HDFF_VIDEO_CONVERSION_AUTOMATIC;
124 
126  {
127  switch (VideoConversion)
128  {
130  nextVideoConversion = HDFF_VIDEO_CONVERSION_CENTRE_CUT_OUT;
131  break;
133  nextVideoConversion = HDFF_VIDEO_CONVERSION_ALWAYS_16_BY_9;
134  break;
136  nextVideoConversion = HDFF_VIDEO_CONVERSION_ZOOM_16_BY_9;
137  break;
139  nextVideoConversion = HDFF_VIDEO_CONVERSION_PILLARBOX;
140  break;
141  }
142  }
143  else
144  {
145  switch (VideoConversion)
146  {
148  nextVideoConversion = HDFF_VIDEO_CONVERSION_LETTERBOX_14_BY_9;
149  break;
151  nextVideoConversion = HDFF_VIDEO_CONVERSION_CENTRE_CUT_OUT;
152  break;
154  nextVideoConversion = HDFF_VIDEO_CONVERSION_LETTERBOX_16_BY_9;
155  break;
156  }
157  }
158  VideoConversion = nextVideoConversion;
159 }
160 
162 {
163  switch (VideoConversion)
164  {
166  default:
167  return tr("Automatic");
169  return tr("Letterbox 16/9");
171  return tr("Letterbox 14/9");
173  return tr("Pillarbox");
175  return tr("CentreCutOut");
177  return tr("Always 16/9");
179  return tr("Zoom 16/9");
180  }
181 }
182 
183 
185 {
186  const int kResolutions = 4;
187  const int kVideoModeAdaptions = 4;
188  const int kTvFormats = 2;
189  const int kAnalogueVideos = 4;
190  const int kAudioDownmixes = 5;
191  const int kOsdSizes = 5;
192  const int kRemoteProtocols = 3;
193 
194  static const char * ResolutionItems[kResolutions] =
195  {
196  "1080i",
197  "720p",
198  "576p",
199  "576i",
200  };
201 
202  static const char * VideoModeAdaptionItems[kVideoModeAdaptions] =
203  {
204  tr("Off"),
205  tr("Frame rate"),
206  tr("HD Only"),
207  tr("Always")
208  };
209 
210  static const char * TvFormatItems[kTvFormats] =
211  {
212  "4/3",
213  "16/9",
214  };
215 
216  static const char * AnalogueVideoItems[kAnalogueVideos] =
217  {
218  tr("Disabled"),
219  "RGB",
220  "CVBS + YUV",
221  "YC (S-Video)",
222  };
223 
224  static const char * AudioDownmixItems[kAudioDownmixes] =
225  {
226  tr("Disabled"),
227  tr("Analogue only"),
228  tr("Always"),
229  tr("Automatic"),
230  tr("HDMI only"),
231  };
232 
233  static const char * OsdSizeItems[kOsdSizes] =
234  {
235  tr("Follow resolution"),
236  "1920x1080",
237  "1280x720",
238  "1024x576",
239  "720x576",
240  };
241 
242  static const char * RemoteProtocolItems[] =
243  {
244  tr("none"),
245  "RC5",
246  "RC6",
247  };
248 
249  mHdffCmdIf = pHdffCmdIf;
251 
252  Add(new cMenuEditStraItem(tr("Resolution"), &mNewHdffSetup.Resolution, kResolutions, ResolutionItems));
253  Add(new cMenuEditStraItem(tr("Video Mode Adaption"), &mNewHdffSetup.VideoModeAdaption, kVideoModeAdaptions, VideoModeAdaptionItems));
254  mTvFormatItem = new cMenuEditStraItem(tr("TV format"), &mNewHdffSetup.TvFormat, kTvFormats, TvFormatItems);
256  Add(new cMenuEditStraItem(tr("Analogue Video"), &mNewHdffSetup.AnalogueVideo, kAnalogueVideos, AnalogueVideoItems));
257  Add(new cMenuEditIntItem(tr("Audio Delay (ms)"), &mNewHdffSetup.AudioDelay, 0, 500));
258  Add(new cMenuEditStraItem(tr("Audio Downmix"), &mNewHdffSetup.AudioDownmix, kAudioDownmixes, AudioDownmixItems));
259  Add(new cMenuEditStraItem(tr("OSD Size"), &mNewHdffSetup.OsdSize, kOsdSizes, OsdSizeItems));
260  Add(new cMenuEditBoolItem(tr("HDMI CEC"), &mNewHdffSetup.CecEnabled));
261  Add(new cMenuEditBoolItem(tr("CEC: Switch TV on"), &mNewHdffSetup.CecTvOn));
262  Add(new cMenuEditBoolItem(tr("CEC: Switch TV off"), &mNewHdffSetup.CecTvOff));
263  Add(new cMenuEditStraItem(tr("Remote Control Protocol"), &mNewHdffSetup.RemoteProtocol, kRemoteProtocols, RemoteProtocolItems));
264  Add(new cMenuEditIntItem(tr("Remote Control Address"), &mNewHdffSetup.RemoteAddress, -1, 31));
265  Add(new cMenuEditBoolItem(tr("High Level OSD"), &mNewHdffSetup.HighLevelOsd));
266  Add(new cMenuEditBoolItem(tr("Allow True Color OSD"), &mNewHdffSetup.TrueColorOsd));
267  Add(new cMenuEditBoolItem(tr("Hide mainmenu entry"), &mNewHdffSetup.HideMainMenu));
268 
269  mVideoConversion = 0;
271  {
273  {
275  mVideoConversion = 0;
276  break;
278  mVideoConversion = 1;
279  break;
281  mVideoConversion = 2;
282  break;
284  mVideoConversion = 3;
285  break;
286  }
287  }
288  else
289  {
291  {
293  mVideoConversion = 0;
294  break;
296  mVideoConversion = 1;
297  break;
299  mVideoConversion = 2;
300  break;
301  }
302  }
304 }
305 
307 {
308 }
309 
311 {
312  const int kVideoConversions4by3 = 3;
313  const int kVideoConversions16by9 = 4;
314 
315  static const char * VideoConversionItems4by3[kVideoConversions4by3] =
316  {
317  tr("Letterbox 16/9"),
318  tr("Letterbox 14/9"),
319  tr("CentreCutOut")
320  };
321 
322  static const char * VideoConversionItems16by9[kVideoConversions16by9] =
323  {
324  tr("Pillarbox"),
325  tr("CentreCutOut"),
326  tr("Always 16/9"),
327  tr("Zoom 16/9")
328  };
329 
330  cOsdItem * item;
331 
334  {
335  item = new cMenuEditStraItem(tr("Video Conversion"), &mVideoConversion,
336  kVideoConversions16by9, VideoConversionItems16by9);
337  }
338  else
339  {
340  item = new cMenuEditStraItem(tr("Video Conversion"), &mVideoConversion,
341  kVideoConversions4by3, VideoConversionItems4by3);
342  }
343  Add(item, false, mTvFormatItem);
344 }
345 
347 {
349  {
350  switch (mVideoConversion)
351  {
352  case 0:
354  break;
355  case 1:
357  break;
358  case 2:
360  break;
361  case 3:
363  break;
364  }
365  }
366  else
367  {
368  switch (mVideoConversion)
369  {
370  case 0:
372  break;
373  case 1:
375  break;
376  case 2:
378  break;
379  }
380  }
381  SetupStore("Resolution", mNewHdffSetup.Resolution);
382  SetupStore("VideoModeAdaption", mNewHdffSetup.VideoModeAdaption);
383  SetupStore("TvFormat", mNewHdffSetup.TvFormat);
384  SetupStore("VideoConversion", mNewHdffSetup.VideoConversion);
385  SetupStore("AnalogueVideo", mNewHdffSetup.AnalogueVideo);
386  SetupStore("AudioDelay", mNewHdffSetup.AudioDelay);
387  SetupStore("AudioDownmix", mNewHdffSetup.AudioDownmix);
388  SetupStore("OsdSize", mNewHdffSetup.OsdSize);
389  SetupStore("CecEnabled", mNewHdffSetup.CecEnabled);
390  SetupStore("CecTvOn", mNewHdffSetup.CecTvOn);
391  SetupStore("CecTvOff", mNewHdffSetup.CecTvOff);
392  SetupStore("RemoteProtocol", mNewHdffSetup.RemoteProtocol);
393  SetupStore("RemoteAddress", mNewHdffSetup.RemoteAddress);
394  SetupStore("HighLevelOsd", mNewHdffSetup.HighLevelOsd);
395  SetupStore("TrueColorOsd", mNewHdffSetup.TrueColorOsd);
396  SetupStore("HideMainMenu", mNewHdffSetup.HideMainMenu);
397 
398  if (mHdffCmdIf)
399  {
400  if (mNewHdffSetup.Resolution != gHdffSetup.Resolution)
401  {
403  }
404  HdffVideoFormat_t videoFormat;
405  HdffHdmiConfig_t hdmiConfig;
406 
407  videoFormat.AutomaticEnabled = true;
408  videoFormat.AfdEnabled = false;
411  mHdffCmdIf->CmdAvSetVideoFormat(0, &videoFormat);
412 
415 
417 
418  memset(&hdmiConfig, 0, sizeof(hdmiConfig));
419  hdmiConfig.TransmitAudio = true;
420  hdmiConfig.ForceDviMode = false;
421  hdmiConfig.CecEnabled = mNewHdffSetup.CecEnabled;
423  mHdffCmdIf->CmdHdmiConfigure(&hdmiConfig);
424 
427  }
428 
429  gHdffSetup = mNewHdffSetup;
430 }
431 
433 {
435 
436  if (state == osContinue)
437  {
438  cOsdItem * item;
439  switch (key)
440  {
441  case kLeft:
442  case kRight:
443  item = Get(Current());
444  if (item == mTvFormatItem)
445  {
446  mVideoConversion = 0;
448  Display();
449  }
450  break;
451  default:
452  break;
453  }
454  }
455  return state;
456 }