Skip to content

Commit 9f4a0b5

Browse files
author
Sebastien Bourdeauducq
committedNov 25, 2011
videoin: format selection
1 parent b4193b5 commit 9f4a0b5

File tree

2 files changed

+81
-16
lines changed

2 files changed

+81
-16
lines changed
 

‎src/gui/videoin.c

+74-16
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static int appid;
3737

3838
static int video_fd;
3939

40+
static int format;
4041
static int brightness;
4142
static int contrast;
4243
static int hue;
@@ -49,6 +50,17 @@ enum {
4950
CONTROL_HUE
5051
};
5152

53+
static void set_format(int f)
54+
{
55+
ioctl(video_fd, VIDEO_SET_FORMAT, f);
56+
mtk_cmdf(appid, "b_cvbsg.set(-state %s)", f == VIDEO_FORMAT_CVBS6 ? "on" : "off");
57+
mtk_cmdf(appid, "b_cvbsb.set(-state %s)", f == VIDEO_FORMAT_CVBS5 ? "on" : "off");
58+
mtk_cmdf(appid, "b_cvbsr.set(-state %s)", f == VIDEO_FORMAT_CVBS4 ? "on" : "off");
59+
mtk_cmdf(appid, "b_svideo.set(-state %s)", f == VIDEO_FORMAT_SVIDEO ? "on" : "off");
60+
mtk_cmdf(appid, "b_component.set(-state %s)", f == VIDEO_FORMAT_COMPONENT ? "on" : "off");
61+
format = f;
62+
}
63+
5264
static void set_value(int channel, unsigned int val)
5365
{
5466
int cmd;
@@ -97,8 +109,15 @@ static void slide_callback(mtk_event *e, void *arg)
97109
set_value(control, val);
98110
}
99111

112+
static void format_callback(mtk_event *e, void *arg)
113+
{
114+
set_format((int)arg);
115+
}
116+
100117
static void load_config()
101118
{
119+
set_format(config_read_int("vin_format", VIDEO_FORMAT_CVBS6));
120+
102121
set_value(CONTROL_BRIGHTNESS, config_read_int("vin_brightness", 0));
103122
set_value(CONTROL_CONTRAST, config_read_int("vin_contrast", 0x80));
104123
set_value(CONTROL_HUE, config_read_int("vin_hue", 0));
@@ -110,6 +129,7 @@ static void load_config()
110129

111130
static void set_config()
112131
{
132+
config_write_int("vin_format", format);
113133
config_write_int("vin_brightness", brightness);
114134
config_write_int("vin_contrast", contrast);
115135
config_write_int("vin_hue", hue);
@@ -165,17 +185,18 @@ static void preview_update(mtk_event *e, int count)
165185

166186
static void close_videoin_window()
167187
{
188+
input_delete_callback(preview_update);
168189
mtk_cmd(appid, "w.close()");
190+
load_config();
169191
close(video_fd);
170192
w_open = 0;
171193
resmgr_release(RESOURCE_VIDEOIN);
172-
input_delete_callback(preview_update);
173194
}
174195

175196
static void ok_callback(mtk_event *e, void *arg)
176197
{
177-
close_videoin_window();
178198
set_config();
199+
close_videoin_window();
179200
}
180201

181202
static void close_callback(mtk_event *e, void *arg)
@@ -189,28 +210,60 @@ void init_videoin()
189210

190211
mtk_cmd_seq(appid,
191212
"g = new Grid()",
192-
213+
214+
"g_format = new Grid()",
215+
"l_format = new Label(-text \"Format\" -font \"title\")",
216+
"s_format1 = new Separator(-vertical no)",
217+
"s_format2 = new Separator(-vertical no)",
218+
"g_format.place(s_format1, -column 1 -row 1)",
219+
"g_format.place(l_format, -column 2 -row 1)",
220+
"g_format.place(s_format2, -column 3 -row 1)",
221+
"g.place(g_format, -column 1 -row 1)",
222+
223+
"g_cvbs = new Grid()",
224+
"b_cvbsg = new Button(-text \"CVBS: Green\")",
225+
"b_cvbsb = new Button(-text \"CVBS: Blue\")",
226+
"b_cvbsr = new Button(-text \"CVBS: Red\")",
227+
"g_cvbs.place(b_cvbsg, -column 1 -row 1)",
228+
"g_cvbs.place(b_cvbsb, -column 2 -row 1)",
229+
"g_cvbs.place(b_cvbsr, -column 3 -row 1)",
230+
"g.place(g_cvbs, -column 1 -row 2)",
231+
"b_svideo = new Button(-text \"S-Video (Y: Green, C: Blue)\")",
232+
"g.place(b_svideo, -column 1 -row 3)",
233+
"b_component = new Button(-text \"Component (YPbPr)\")",
234+
"g.place(b_component, -column 1 -row 4)",
235+
236+
"g_detected = new Grid()",
237+
"l0_detected = new Label(-text \"Detected signal:\")",
238+
"l_detected = new Label(-text \"None\")",
239+
"g_detected.place(l0_detected, -column 1 -row 1)",
240+
"g_detected.place(l_detected, -column 2 -row 1)",
241+
"g.place(g_detected, -column 1 -row 5)",
242+
243+
"g_parameters = new Grid()",
244+
"l_parameters = new Label(-text \"Parameters\" -font \"title\")",
245+
"s_parameters1 = new Separator(-vertical no)",
246+
"s_parameters2 = new Separator(-vertical no)",
247+
"g_parameters.place(s_parameters1, -column 1 -row 1)",
248+
"g_parameters.place(l_parameters, -column 2 -row 1)",
249+
"g_parameters.place(s_parameters2, -column 3 -row 1)",
250+
"g.place(g_parameters, -column 1 -row 6)",
251+
193252
"gc = new Grid()",
194253
"l_brightness = new Label(-text \"Brightness:\")",
195254
"s_brightness = new Scale(-from -128 -to 127 -value 0 -orient horizontal)",
196255
"l_contrast = new Label(-text \"Contrast:\")",
197256
"s_contrast = new Scale(-from 0 -to 255 -value 128 -orient horizontal)",
198257
"l_hue = new Label(-text \"Hue:\")",
199258
"s_hue = new Scale(-from -128 -to 127 -value 0 -orient horizontal)",
200-
"l0_detected = new Label(-text \"Detected signal:\")",
201-
"l_detected = new Label(-text \"None\")",
202-
203259
"gc.place(l_brightness, -column 1 -row 1)",
204260
"gc.place(s_brightness, -column 2 -row 1)",
205261
"gc.place(l_contrast, -column 1 -row 2)",
206262
"gc.place(s_contrast, -column 2 -row 2)",
207263
"gc.place(l_hue, -column 1 -row 3)",
208264
"gc.place(s_hue, -column 2 -row 3)",
209-
"gc.place(l0_detected, -column 1 -row 4)",
210-
"gc.place(l_detected, -column 2 -row 4)",
211265
"gc.columnconfig(2, -size 150)",
212-
213-
"g.place(gc, -column 1 -row 1)",
266+
"g.place(gc, -column 1 -row 7)",
214267

215268
"g_preview = new Grid()",
216269
"l_preview = new Label(-text \"Preview\" -font \"title\")",
@@ -219,27 +272,32 @@ void init_videoin()
219272
"g_preview.place(s_preview1, -column 1 -row 1)",
220273
"g_preview.place(l_preview, -column 2 -row 1)",
221274
"g_preview.place(s_preview2, -column 3 -row 1)",
222-
223-
"g.place(g_preview, -column 1 -row 2)",
275+
"g.place(g_preview, -column 1 -row 8)",
224276

225277
"p_preview = new Pixmap(-w 180 -h 144)",
226-
"g.place(p_preview, -column 1 -row 3)",
278+
"g.place(p_preview, -column 1 -row 9)",
227279

228-
"g.rowconfig(4, -size 10)",
280+
"g.rowconfig(10, -size 10)",
229281

230282
"g_btn = new Grid()",
231283
"b_ok = new Button(-text \"OK\")",
232284
"b_cancel = new Button(-text \"Cancel\")",
233285
"g_btn.columnconfig(1, -size 190)",
234286
"g_btn.place(b_ok, -column 2 -row 1)",
235287
"g_btn.place(b_cancel, -column 3 -row 1)",
236-
"g.place(g_btn, -column 1 -row 5)",
288+
"g.place(g_btn, -column 1 -row 11)",
237289

238-
"w = new Window(-content g -title \"Video input settings\")",
290+
"w = new Window(-content g -title \"Video input settings\" -worky 30)",
239291
0);
240292

241293
mtk_cmdf(appid, "p_preview.set(-fb %d)", preview_fb);
242294

295+
mtk_bind(appid, "b_cvbsg", "press", format_callback, (void *)VIDEO_FORMAT_CVBS6);
296+
mtk_bind(appid, "b_cvbsb", "press", format_callback, (void *)VIDEO_FORMAT_CVBS5);
297+
mtk_bind(appid, "b_cvbsr", "press", format_callback, (void *)VIDEO_FORMAT_CVBS4);
298+
mtk_bind(appid, "b_svideo", "press", format_callback, (void *)VIDEO_FORMAT_SVIDEO);
299+
mtk_bind(appid, "b_component", "press", format_callback, (void *)VIDEO_FORMAT_COMPONENT);
300+
243301
mtk_bind(appid, "s_brightness", "change", slide_callback, (void *)CONTROL_BRIGHTNESS);
244302
mtk_bind(appid, "s_contrast", "change", slide_callback, (void *)CONTROL_CONTRAST);
245303
mtk_bind(appid, "s_hue", "change", slide_callback, (void *)CONTROL_HUE);

‎src/translations/french.c

+7
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ struct mtk_i18n_entry translation_french[] = {
116116

117117
// Video input settings
118118
{ "Video input settings", "Param\xe8""tres d'entr\xe9""e vid\xe9""o" },
119+
{ "Format", "Format" },
120+
{ "CVBS: Green", "CVBS: Vert" },
121+
{ "CVBS: Blue", "CVBS: Bleu" },
122+
{ "CVBS: Red", "CVBS: Rouge" },
123+
{ "S-Video (Y: Green, C: Blue)", "S-Video (Y: Vert, C: Bleu)" },
124+
{ "Component (YPbPr)", "Composantes (YPbPr)" },
125+
{ "Parameters", "Param\xe8""tres" },
119126
{ "Brightness:", "Luminosit\xe9"" :" },
120127
{ "Contrast:", "Contraste :" },
121128
{ "Hue:", "Teinte :" },

0 commit comments

Comments
 (0)