@@ -37,6 +37,7 @@ static int appid;
37
37
38
38
static int video_fd ;
39
39
40
+ static int format ;
40
41
static int brightness ;
41
42
static int contrast ;
42
43
static int hue ;
@@ -49,6 +50,17 @@ enum {
49
50
CONTROL_HUE
50
51
};
51
52
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
+
52
64
static void set_value (int channel , unsigned int val )
53
65
{
54
66
int cmd ;
@@ -97,8 +109,15 @@ static void slide_callback(mtk_event *e, void *arg)
97
109
set_value (control , val );
98
110
}
99
111
112
+ static void format_callback (mtk_event * e , void * arg )
113
+ {
114
+ set_format ((int )arg );
115
+ }
116
+
100
117
static void load_config ()
101
118
{
119
+ set_format (config_read_int ("vin_format" , VIDEO_FORMAT_CVBS6 ));
120
+
102
121
set_value (CONTROL_BRIGHTNESS , config_read_int ("vin_brightness" , 0 ));
103
122
set_value (CONTROL_CONTRAST , config_read_int ("vin_contrast" , 0x80 ));
104
123
set_value (CONTROL_HUE , config_read_int ("vin_hue" , 0 ));
@@ -110,6 +129,7 @@ static void load_config()
110
129
111
130
static void set_config ()
112
131
{
132
+ config_write_int ("vin_format" , format );
113
133
config_write_int ("vin_brightness" , brightness );
114
134
config_write_int ("vin_contrast" , contrast );
115
135
config_write_int ("vin_hue" , hue );
@@ -165,17 +185,18 @@ static void preview_update(mtk_event *e, int count)
165
185
166
186
static void close_videoin_window ()
167
187
{
188
+ input_delete_callback (preview_update );
168
189
mtk_cmd (appid , "w.close()" );
190
+ load_config ();
169
191
close (video_fd );
170
192
w_open = 0 ;
171
193
resmgr_release (RESOURCE_VIDEOIN );
172
- input_delete_callback (preview_update );
173
194
}
174
195
175
196
static void ok_callback (mtk_event * e , void * arg )
176
197
{
177
- close_videoin_window ();
178
198
set_config ();
199
+ close_videoin_window ();
179
200
}
180
201
181
202
static void close_callback (mtk_event * e , void * arg )
@@ -189,28 +210,60 @@ void init_videoin()
189
210
190
211
mtk_cmd_seq (appid ,
191
212
"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
+
193
252
"gc = new Grid()" ,
194
253
"l_brightness = new Label(-text \"Brightness:\")" ,
195
254
"s_brightness = new Scale(-from -128 -to 127 -value 0 -orient horizontal)" ,
196
255
"l_contrast = new Label(-text \"Contrast:\")" ,
197
256
"s_contrast = new Scale(-from 0 -to 255 -value 128 -orient horizontal)" ,
198
257
"l_hue = new Label(-text \"Hue:\")" ,
199
258
"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
-
203
259
"gc.place(l_brightness, -column 1 -row 1)" ,
204
260
"gc.place(s_brightness, -column 2 -row 1)" ,
205
261
"gc.place(l_contrast, -column 1 -row 2)" ,
206
262
"gc.place(s_contrast, -column 2 -row 2)" ,
207
263
"gc.place(l_hue, -column 1 -row 3)" ,
208
264
"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)" ,
211
265
"gc.columnconfig(2, -size 150)" ,
212
-
213
- "g.place(gc, -column 1 -row 1)" ,
266
+ "g.place(gc, -column 1 -row 7)" ,
214
267
215
268
"g_preview = new Grid()" ,
216
269
"l_preview = new Label(-text \"Preview\" -font \"title\")" ,
@@ -219,27 +272,32 @@ void init_videoin()
219
272
"g_preview.place(s_preview1, -column 1 -row 1)" ,
220
273
"g_preview.place(l_preview, -column 2 -row 1)" ,
221
274
"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)" ,
224
276
225
277
"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 )" ,
227
279
228
- "g.rowconfig(4 , -size 10)" ,
280
+ "g.rowconfig(10 , -size 10)" ,
229
281
230
282
"g_btn = new Grid()" ,
231
283
"b_ok = new Button(-text \"OK\")" ,
232
284
"b_cancel = new Button(-text \"Cancel\")" ,
233
285
"g_btn.columnconfig(1, -size 190)" ,
234
286
"g_btn.place(b_ok, -column 2 -row 1)" ,
235
287
"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 )" ,
237
289
238
- "w = new Window(-content g -title \"Video input settings\")" ,
290
+ "w = new Window(-content g -title \"Video input settings\" -worky 30 )" ,
239
291
0 );
240
292
241
293
mtk_cmdf (appid , "p_preview.set(-fb %d)" , preview_fb );
242
294
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
+
243
301
mtk_bind (appid , "s_brightness" , "change" , slide_callback , (void * )CONTROL_BRIGHTNESS );
244
302
mtk_bind (appid , "s_contrast" , "change" , slide_callback , (void * )CONTROL_CONTRAST );
245
303
mtk_bind (appid , "s_hue" , "change" , slide_callback , (void * )CONTROL_HUE );
0 commit comments