1 |
lu_zero 11/11/18 11:02:35 |
2 |
|
3 |
Added: guvcview-1.5.1-loops.patch |
4 |
Log: |
5 |
Fix segfault when enumerating controls |
6 |
|
7 |
(Portage version: 2.1.10.35/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 media-video/guvcview/files/guvcview-1.5.1-loops.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-video/guvcview/files/guvcview-1.5.1-loops.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/media-video/guvcview/files/guvcview-1.5.1-loops.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: guvcview-1.5.1-loops.patch |
16 |
=================================================================== |
17 |
--- guvcview-src-1.5.1.orig/src/v4l2_controls.c 2011-11-18 11:42:46.213631997 +0100 |
18 |
+++ guvcview-src-1.5.1/src/v4l2_controls.c 2011-11-18 11:46:06.978623600 +0100 |
19 |
@@ -39,22 +39,22 @@ |
20 |
#include "v4l2_dyna_ctrls.h" |
21 |
#include "callbacks.h" |
22 |
|
23 |
-/* |
24 |
+/* |
25 |
* don't use xioctl for control query when using V4L2_CTRL_FLAG_NEXT_CTRL |
26 |
*/ |
27 |
static int query_ioctl(int hdevice, int current_ctrl, struct v4l2_queryctrl *ctrl) |
28 |
{ |
29 |
int ret = 0; |
30 |
int tries = 4; |
31 |
- do |
32 |
+ do |
33 |
{ |
34 |
- if(ret) |
35 |
+ if(ret) |
36 |
ctrl->id = current_ctrl | V4L2_CTRL_FLAG_NEXT_CTRL; |
37 |
ret = v4l2_ioctl(hdevice, VIDIOC_QUERYCTRL, ctrl); |
38 |
- } |
39 |
+ } |
40 |
while (ret && tries-- && |
41 |
((errno == EIO || errno == EPIPE || errno == ETIMEDOUT))); |
42 |
- |
43 |
+ |
44 |
return(ret); |
45 |
} |
46 |
|
47 |
@@ -88,27 +88,27 @@ |
48 |
Control *first = NULL; |
49 |
Control *current = NULL; |
50 |
Control *control = NULL; |
51 |
- |
52 |
+ |
53 |
int n = 0; |
54 |
struct v4l2_queryctrl queryctrl={0}; |
55 |
struct v4l2_querymenu querymenu={0}; |
56 |
|
57 |
int currentctrl = 0; |
58 |
queryctrl.id = 0 | V4L2_CTRL_FLAG_NEXT_CTRL; |
59 |
- |
60 |
- if ((ret=query_ioctl (hdevice, currentctrl, &queryctrl)) == 0) |
61 |
+ |
62 |
+ if ((ret=query_ioctl (hdevice, currentctrl, &queryctrl)) == 0) |
63 |
{ |
64 |
// The driver supports the V4L2_CTRL_FLAG_NEXT_CTRL flag |
65 |
queryctrl.id = 0; |
66 |
currentctrl= queryctrl.id; |
67 |
queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL; |
68 |
|
69 |
- while((ret = query_ioctl(hdevice, currentctrl, &queryctrl)), ret ? errno != EINVAL : 1) |
70 |
+ while((ret = query_ioctl(hdevice, currentctrl, &queryctrl)), ret ? errno != EINVAL : 1) |
71 |
{ |
72 |
struct v4l2_querymenu *menu = NULL; |
73 |
- |
74 |
+ |
75 |
// Prevent infinite loop for buggy V4L2_CTRL_FLAG_NEXT_CTRL implementations |
76 |
- if(ret && queryctrl.id <= currentctrl) |
77 |
+ if(ret && queryctrl.id <= currentctrl) |
78 |
{ |
79 |
printf("buggy V4L2_CTRL_FLAG_NEXT_CTRL flag implementation (workaround enabled)\n"); |
80 |
// increment the control id manually |
81 |
@@ -118,13 +118,13 @@ |
82 |
} |
83 |
else if ((queryctrl.id == V4L2_CTRL_FLAG_NEXT_CTRL) || (!ret && queryctrl.id == currentctrl)) |
84 |
{ |
85 |
- printf("buggy V4L2_CTRL_FLAG_NEXT_CTRL flag implementation (failed enumeration for id=0x%08x)\n", |
86 |
+ printf("buggy V4L2_CTRL_FLAG_NEXT_CTRL flag implementation (failed enumeration for id=0x%08x)\n", |
87 |
queryctrl.id); |
88 |
// stop control enumeration |
89 |
*num_ctrls = n; |
90 |
return first; |
91 |
} |
92 |
- |
93 |
+ |
94 |
currentctrl = queryctrl.id; |
95 |
// skip if control failed |
96 |
if (ret) |
97 |
@@ -132,14 +132,14 @@ |
98 |
printf("Control 0x%08x failed to query\n", queryctrl.id); |
99 |
goto next_control; |
100 |
} |
101 |
- |
102 |
+ |
103 |
// skip if control is disabled |
104 |
if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) |
105 |
{ |
106 |
printf("Disabling control 0x%08x\n", queryctrl.id); |
107 |
goto next_control; |
108 |
} |
109 |
- |
110 |
+ |
111 |
//check menu items if needed |
112 |
if(queryctrl.type == V4L2_CTRL_TYPE_MENU) |
113 |
{ |
114 |
@@ -147,18 +147,18 @@ |
115 |
int ret = 0; |
116 |
for (querymenu.index = queryctrl.minimum; |
117 |
querymenu.index <= queryctrl.maximum; |
118 |
- querymenu.index++) |
119 |
+ querymenu.index++) |
120 |
{ |
121 |
querymenu.id = queryctrl.id; |
122 |
ret = xioctl (hdevice, VIDIOC_QUERYMENU, &querymenu); |
123 |
if (ret < 0) |
124 |
- continue; |
125 |
- |
126 |
+ continue; |
127 |
+ |
128 |
if(!menu) |
129 |
menu = g_new0(struct v4l2_querymenu, i+1); |
130 |
else |
131 |
- menu = g_renew(struct v4l2_querymenu, menu, i+1); |
132 |
- |
133 |
+ menu = g_renew(struct v4l2_querymenu, menu, i+1); |
134 |
+ |
135 |
memcpy(&(menu[i]), &querymenu, sizeof(struct v4l2_querymenu)); |
136 |
i++; |
137 |
} |
138 |
@@ -166,26 +166,26 @@ |
139 |
menu = g_new0(struct v4l2_querymenu, i+1); |
140 |
else |
141 |
menu = g_renew(struct v4l2_querymenu, menu, i+1); |
142 |
- |
143 |
+ |
144 |
menu[i].id = querymenu.id; |
145 |
menu[i].index = queryctrl.maximum+1; |
146 |
menu[i].name[0] = 0; |
147 |
} |
148 |
- |
149 |
+ |
150 |
// Add the control to the linked list |
151 |
control = calloc (1, sizeof(Control)); |
152 |
memcpy(&(control->control), &queryctrl, sizeof(struct v4l2_queryctrl)); |
153 |
control->class = (control->control.id & 0xFFFF0000); |
154 |
//add the menu adress (NULL if not a menu) |
155 |
control->menu = menu; |
156 |
-#ifndef DISABLE_STRING_CONTROLS |
157 |
+#ifndef DISABLE_STRING_CONTROLS |
158 |
//allocate a string with max size if needed |
159 |
if(control->control.type == V4L2_CTRL_TYPE_STRING) |
160 |
control->string = calloc(control->control.maximum + 1, sizeof(char)); |
161 |
else |
162 |
#endif |
163 |
control->string = NULL; |
164 |
- |
165 |
+ |
166 |
if(first != NULL) |
167 |
{ |
168 |
current->next = control; |
169 |
@@ -196,9 +196,9 @@ |
170 |
first = control; |
171 |
current = first; |
172 |
} |
173 |
- |
174 |
+ |
175 |
n++; |
176 |
- |
177 |
+ |
178 |
next_control: |
179 |
queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL; |
180 |
} |
181 |
@@ -207,15 +207,15 @@ |
182 |
{ |
183 |
printf("NEXT_CTRL flag not supported\n"); |
184 |
int currentctrl; |
185 |
- for(currentctrl = V4L2_CID_BASE; currentctrl < V4L2_CID_LASTP1; currentctrl++) |
186 |
+ for(currentctrl = V4L2_CID_BASE; currentctrl < V4L2_CID_LASTP1; currentctrl++) |
187 |
{ |
188 |
struct v4l2_querymenu *menu = NULL; |
189 |
queryctrl.id = currentctrl; |
190 |
ret = xioctl(hdevice, VIDIOC_QUERYCTRL, &queryctrl); |
191 |
- |
192 |
+ |
193 |
if (ret || (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) ) |
194 |
continue; |
195 |
- |
196 |
+ |
197 |
//check menu items if needed |
198 |
if(queryctrl.type == V4L2_CTRL_TYPE_MENU) |
199 |
{ |
200 |
@@ -223,18 +223,18 @@ |
201 |
int ret = 0; |
202 |
for (querymenu.index = queryctrl.minimum; |
203 |
querymenu.index <= queryctrl.maximum; |
204 |
- querymenu.index++) |
205 |
+ querymenu.index++) |
206 |
{ |
207 |
querymenu.id = queryctrl.id; |
208 |
ret = xioctl (hdevice, VIDIOC_QUERYMENU, &querymenu); |
209 |
if (ret < 0) |
210 |
- break; |
211 |
- |
212 |
+ break; |
213 |
+ |
214 |
if(!menu) |
215 |
menu = g_new0(struct v4l2_querymenu, i+1); |
216 |
else |
217 |
- menu = g_renew(struct v4l2_querymenu, menu, i+1); |
218 |
- |
219 |
+ menu = g_renew(struct v4l2_querymenu, menu, i+1); |
220 |
+ |
221 |
memcpy(&(menu[i]), &querymenu, sizeof(struct v4l2_querymenu)); |
222 |
i++; |
223 |
} |
224 |
@@ -242,21 +242,21 @@ |
225 |
menu = g_new0(struct v4l2_querymenu, i+1); |
226 |
else |
227 |
menu = g_renew(struct v4l2_querymenu, menu, i+1); |
228 |
- |
229 |
+ |
230 |
menu[i].id = querymenu.id; |
231 |
menu[i].index = queryctrl.maximum+1; |
232 |
menu[i].name[0] = 0; |
233 |
- |
234 |
+ |
235 |
} |
236 |
- |
237 |
+ |
238 |
// Add the control to the linked list |
239 |
control = calloc (1, sizeof(Control)); |
240 |
memcpy(&(control->control), &queryctrl, sizeof(struct v4l2_queryctrl)); |
241 |
- |
242 |
+ |
243 |
control->class = 0x00980000; |
244 |
//add the menu adress (NULL if not a menu) |
245 |
control->menu = menu; |
246 |
- |
247 |
+ |
248 |
if(first != NULL) |
249 |
{ |
250 |
current->next = control; |
251 |
@@ -267,11 +267,11 @@ |
252 |
first = control; |
253 |
current = first; |
254 |
} |
255 |
- |
256 |
+ |
257 |
n++; |
258 |
} |
259 |
- |
260 |
- for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;queryctrl.id++) |
261 |
+ |
262 |
+ for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;queryctrl.id++) |
263 |
{ |
264 |
struct v4l2_querymenu *menu = NULL; |
265 |
ret = xioctl(hdevice, VIDIOC_QUERYCTRL, &queryctrl); |
266 |
@@ -279,7 +279,7 @@ |
267 |
break; |
268 |
else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) |
269 |
continue; |
270 |
- |
271 |
+ |
272 |
//check menu items if needed |
273 |
if(queryctrl.type == V4L2_CTRL_TYPE_MENU) |
274 |
{ |
275 |
@@ -287,18 +287,18 @@ |
276 |
int ret = 0; |
277 |
for (querymenu.index = queryctrl.minimum; |
278 |
querymenu.index <= queryctrl.maximum; |
279 |
- querymenu.index++) |
280 |
+ querymenu.index++) |
281 |
{ |
282 |
querymenu.id = queryctrl.id; |
283 |
ret = xioctl (hdevice, VIDIOC_QUERYMENU, &querymenu); |
284 |
if (ret < 0) |
285 |
- break; |
286 |
- |
287 |
+ break; |
288 |
+ |
289 |
if(!menu) |
290 |
menu = g_new0(struct v4l2_querymenu, i+1); |
291 |
else |
292 |
- menu = g_renew(struct v4l2_querymenu, menu, i+1); |
293 |
- |
294 |
+ menu = g_renew(struct v4l2_querymenu, menu, i+1); |
295 |
+ |
296 |
memcpy(&(menu[i]), &querymenu, sizeof(struct v4l2_querymenu)); |
297 |
i++; |
298 |
} |
299 |
@@ -306,19 +306,19 @@ |
300 |
menu = g_new0(struct v4l2_querymenu, i+1); |
301 |
else |
302 |
menu = g_renew(struct v4l2_querymenu, menu, i+1); |
303 |
- |
304 |
+ |
305 |
menu[i].id = querymenu.id; |
306 |
menu[i].index = queryctrl.maximum+1; |
307 |
menu[i].name[0] = 0; |
308 |
} |
309 |
- |
310 |
+ |
311 |
// Add the control to the linked list |
312 |
control = calloc (1, sizeof(Control)); |
313 |
memcpy(&(control->control), &queryctrl, sizeof(struct v4l2_queryctrl)); |
314 |
control->class = 0x00980000; |
315 |
//add the menu adress (NULL if not a menu) |
316 |
control->menu = menu; |
317 |
- |
318 |
+ |
319 |
if(first != NULL) |
320 |
{ |
321 |
current->next = control; |
322 |
@@ -333,7 +333,7 @@ |
323 |
n++; |
324 |
} |
325 |
} |
326 |
- |
327 |
+ |
328 |
*num_ctrls = n; |
329 |
return first; |
330 |
} |
331 |
@@ -342,85 +342,85 @@ |
332 |
* called when setting controls |
333 |
*/ |
334 |
static void update_ctrl_flags(Control *control_list, int id) |
335 |
-{ |
336 |
- switch (id) |
337 |
+{ |
338 |
+ switch (id) |
339 |
{ |
340 |
case V4L2_CID_EXPOSURE_AUTO: |
341 |
{ |
342 |
Control *ctrl_this = get_ctrl_by_id(control_list, id ); |
343 |
if(ctrl_this == NULL) |
344 |
break; |
345 |
- |
346 |
- switch (ctrl_this->value) |
347 |
+ |
348 |
+ switch (ctrl_this->value) |
349 |
{ |
350 |
case V4L2_EXPOSURE_AUTO: |
351 |
{ |
352 |
//printf("auto\n"); |
353 |
- Control *ctrl_that = get_ctrl_by_id(control_list, |
354 |
+ Control *ctrl_that = get_ctrl_by_id(control_list, |
355 |
V4L2_CID_IRIS_ABSOLUTE ); |
356 |
if (ctrl_that) |
357 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
358 |
- |
359 |
- ctrl_that = get_ctrl_by_id(control_list, |
360 |
+ |
361 |
+ ctrl_that = get_ctrl_by_id(control_list, |
362 |
V4L2_CID_IRIS_RELATIVE ); |
363 |
if (ctrl_that) |
364 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
365 |
- ctrl_that = get_ctrl_by_id(control_list, |
366 |
+ ctrl_that = get_ctrl_by_id(control_list, |
367 |
V4L2_CID_EXPOSURE_ABSOLUTE ); |
368 |
if (ctrl_that) |
369 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
370 |
} |
371 |
break; |
372 |
- |
373 |
+ |
374 |
case V4L2_EXPOSURE_APERTURE_PRIORITY: |
375 |
{ |
376 |
//printf("AP\n"); |
377 |
- Control *ctrl_that = get_ctrl_by_id(control_list, |
378 |
+ Control *ctrl_that = get_ctrl_by_id(control_list, |
379 |
V4L2_CID_EXPOSURE_ABSOLUTE ); |
380 |
if (ctrl_that) |
381 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
382 |
- ctrl_that = get_ctrl_by_id(control_list, |
383 |
+ ctrl_that = get_ctrl_by_id(control_list, |
384 |
V4L2_CID_IRIS_ABSOLUTE ); |
385 |
if (ctrl_that) |
386 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
387 |
- ctrl_that = get_ctrl_by_id(control_list, |
388 |
+ ctrl_that = get_ctrl_by_id(control_list, |
389 |
V4L2_CID_IRIS_RELATIVE ); |
390 |
if (ctrl_that) |
391 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
392 |
} |
393 |
break; |
394 |
- |
395 |
+ |
396 |
case V4L2_EXPOSURE_SHUTTER_PRIORITY: |
397 |
{ |
398 |
//printf("SP\n"); |
399 |
- Control *ctrl_that = get_ctrl_by_id(control_list, |
400 |
+ Control *ctrl_that = get_ctrl_by_id(control_list, |
401 |
V4L2_CID_IRIS_ABSOLUTE ); |
402 |
if (ctrl_that) |
403 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
404 |
- |
405 |
- ctrl_that = get_ctrl_by_id(control_list, |
406 |
+ |
407 |
+ ctrl_that = get_ctrl_by_id(control_list, |
408 |
V4L2_CID_IRIS_RELATIVE ); |
409 |
if (ctrl_that) |
410 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
411 |
- ctrl_that = get_ctrl_by_id(control_list, |
412 |
+ ctrl_that = get_ctrl_by_id(control_list, |
413 |
V4L2_CID_EXPOSURE_ABSOLUTE ); |
414 |
if (ctrl_that) |
415 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
416 |
} |
417 |
break; |
418 |
- |
419 |
+ |
420 |
default: |
421 |
{ |
422 |
//printf("manual\n"); |
423 |
- Control *ctrl_that = get_ctrl_by_id(control_list, |
424 |
+ Control *ctrl_that = get_ctrl_by_id(control_list, |
425 |
V4L2_CID_EXPOSURE_ABSOLUTE ); |
426 |
if (ctrl_that) |
427 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
428 |
- ctrl_that = get_ctrl_by_id(control_list, |
429 |
+ ctrl_that = get_ctrl_by_id(control_list, |
430 |
V4L2_CID_IRIS_ABSOLUTE ); |
431 |
if (ctrl_that) |
432 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
433 |
- ctrl_that = get_ctrl_by_id(control_list, |
434 |
+ ctrl_that = get_ctrl_by_id(control_list, |
435 |
V4L2_CID_IRIS_RELATIVE ); |
436 |
if (ctrl_that) |
437 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
438 |
@@ -435,13 +435,13 @@ |
439 |
Control *ctrl_this = get_ctrl_by_id(control_list, id ); |
440 |
if(ctrl_this == NULL) |
441 |
break; |
442 |
- if(ctrl_this->value > 0) |
443 |
+ if(ctrl_this->value > 0) |
444 |
{ |
445 |
Control *ctrl_that = get_ctrl_by_id(control_list, |
446 |
V4L2_CID_FOCUS_ABSOLUTE); |
447 |
if (ctrl_that) |
448 |
ctrl_that->control.flags |= V4L2_CTRL_FLAG_GRABBED; |
449 |
- |
450 |
+ |
451 |
ctrl_that = get_ctrl_by_id(control_list, |
452 |
V4L2_CID_FOCUS_RELATIVE); |
453 |
if (ctrl_that) |
454 |
@@ -453,7 +453,7 @@ |
455 |
V4L2_CID_FOCUS_ABSOLUTE); |
456 |
if (ctrl_that) |
457 |
ctrl_that->control.flags &= !(V4L2_CTRL_FLAG_GRABBED); |
458 |
- |
459 |
+ |
460 |
ctrl_that = get_ctrl_by_id(control_list, |
461 |
V4L2_CID_FOCUS_RELATIVE); |
462 |
if (ctrl_that) |
463 |
@@ -461,13 +461,13 @@ |
464 |
} |
465 |
} |
466 |
break; |
467 |
- |
468 |
+ |
469 |
case V4L2_CID_HUE_AUTO: |
470 |
{ |
471 |
Control *ctrl_this = get_ctrl_by_id(control_list, id ); |
472 |
if(ctrl_this == NULL) |
473 |
break; |
474 |
- if(ctrl_this->value > 0) |
475 |
+ if(ctrl_this->value > 0) |
476 |
{ |
477 |
Control *ctrl_that = get_ctrl_by_id(control_list, |
478 |
V4L2_CID_HUE); |
479 |
@@ -489,7 +489,7 @@ |
480 |
Control *ctrl_this = get_ctrl_by_id(control_list, id ); |
481 |
if(ctrl_this == NULL) |
482 |
break; |
483 |
- |
484 |
+ |
485 |
if(ctrl_this->value > 0) |
486 |
{ |
487 |
Control *ctrl_that = get_ctrl_by_id(control_list, |
488 |
@@ -533,11 +533,11 @@ |
489 |
Control *current = control_list; |
490 |
Control *next = current->next; |
491 |
int done = 0; |
492 |
- |
493 |
+ |
494 |
while(!done) |
495 |
{ |
496 |
update_ctrl_flags(control_list, current->control.id); |
497 |
- |
498 |
+ |
499 |
if(next == NULL) |
500 |
done = 1; |
501 |
else |
502 |
@@ -579,7 +579,7 @@ |
503 |
g_signal_handlers_block_by_func(GTK_TOGGLE_BUTTON(current->widget), |
504 |
G_CALLBACK (check_changed), all_data); |
505 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current->widget), |
506 |
- current->value ? TRUE : FALSE); |
507 |
+ current->value ? TRUE : FALSE); |
508 |
//enable widget signals |
509 |
g_signal_handlers_unblock_by_func(GTK_TOGGLE_BUTTON(current->widget), |
510 |
G_CALLBACK (check_changed), all_data); |
511 |
@@ -588,20 +588,20 @@ |
512 |
if(!(is_special_case_control(current->control.id))) |
513 |
{ |
514 |
//disable widget signals |
515 |
- g_signal_handlers_block_by_func(GTK_SCALE (current->widget), |
516 |
+ g_signal_handlers_block_by_func(GTK_SCALE (current->widget), |
517 |
G_CALLBACK (slider_changed), all_data); |
518 |
gtk_range_set_value (GTK_RANGE (current->widget), current->value); |
519 |
- //enable widget signals |
520 |
- g_signal_handlers_unblock_by_func(GTK_SCALE (current->widget), |
521 |
+ //enable widget signals |
522 |
+ g_signal_handlers_unblock_by_func(GTK_SCALE (current->widget), |
523 |
G_CALLBACK (slider_changed), all_data); |
524 |
if(current->spinbutton) |
525 |
- { |
526 |
+ { |
527 |
//disable widget signals |
528 |
- g_signal_handlers_block_by_func(GTK_SPIN_BUTTON(current->spinbutton), |
529 |
- G_CALLBACK (spin_changed), all_data); |
530 |
+ g_signal_handlers_block_by_func(GTK_SPIN_BUTTON(current->spinbutton), |
531 |
+ G_CALLBACK (spin_changed), all_data); |
532 |
gtk_spin_button_set_value (GTK_SPIN_BUTTON(current->spinbutton), current->value); |
533 |
//enable widget signals |
534 |
- g_signal_handlers_unblock_by_func(GTK_SPIN_BUTTON(current->spinbutton), |
535 |
+ g_signal_handlers_unblock_by_func(GTK_SPIN_BUTTON(current->spinbutton), |
536 |
G_CALLBACK (spin_changed), all_data); |
537 |
} |
538 |
} |
539 |
@@ -609,27 +609,27 @@ |
540 |
case V4L2_CTRL_TYPE_MENU: |
541 |
{ |
542 |
//disable widget signals |
543 |
- g_signal_handlers_block_by_func(GTK_COMBO_BOX_TEXT(current->widget), |
544 |
+ g_signal_handlers_block_by_func(GTK_COMBO_BOX_TEXT(current->widget), |
545 |
G_CALLBACK (combo_changed), all_data); |
546 |
//get new index |
547 |
int j = 0; |
548 |
int def = 0; |
549 |
- for (j = 0; current->menu[j].index <= current->control.maximum; j++) |
550 |
+ for (j = 0; current->menu[j].index <= current->control.maximum; j++) |
551 |
{ |
552 |
if(current->value == current->menu[j].index) |
553 |
def = j; |
554 |
} |
555 |
- |
556 |
+ |
557 |
gtk_combo_box_set_active(GTK_COMBO_BOX(current->widget), def); |
558 |
- //enable widget signals |
559 |
- g_signal_handlers_unblock_by_func(GTK_COMBO_BOX_TEXT(current->widget), |
560 |
+ //enable widget signals |
561 |
+ g_signal_handlers_unblock_by_func(GTK_COMBO_BOX_TEXT(current->widget), |
562 |
G_CALLBACK (combo_changed), all_data); |
563 |
break; |
564 |
} |
565 |
default: |
566 |
break; |
567 |
} |
568 |
- } |
569 |
+ } |
570 |
if((current->control.flags & V4L2_CTRL_FLAG_GRABBED) || |
571 |
(current->control.flags & V4L2_CTRL_FLAG_DISABLED)) |
572 |
{ |
573 |
@@ -649,7 +649,7 @@ |
574 |
if(current->spinbutton) |
575 |
gtk_widget_set_sensitive (current->spinbutton, TRUE); |
576 |
} |
577 |
- |
578 |
+ |
579 |
if(next == NULL) |
580 |
done = 1; |
581 |
else |
582 |
@@ -663,26 +663,26 @@ |
583 |
/* |
584 |
* creates the control associated widgets for all controls in the list |
585 |
*/ |
586 |
- |
587 |
+ |
588 |
void create_control_widgets(Control *control_list, void *all_data, int control_only, int verbose) |
589 |
-{ |
590 |
+{ |
591 |
struct ALL_DATA *data = (struct ALL_DATA *) all_data; |
592 |
struct vdIn *videoIn = data->videoIn; |
593 |
Control *current = control_list; |
594 |
Control *next = current->next; |
595 |
int done = 0; |
596 |
int i = 0; |
597 |
- |
598 |
+ |
599 |
while(!done) |
600 |
{ |
601 |
- if (verbose) |
602 |
+ if (verbose) |
603 |
{ |
604 |
g_printf("control[%d]: 0x%x",i ,current->control.id); |
605 |
g_printf (" %s, %d:%d:%d, default %d\n", current->control.name, |
606 |
current->control.minimum, current->control.maximum, current->control.step, |
607 |
current->control.default_value); |
608 |
} |
609 |
- |
610 |
+ |
611 |
if(!current->control.step) current->control.step = 1; |
612 |
gchar *tmp; |
613 |
tmp = g_strdup_printf ("%s:", gettext((char *) current->control.name)); |
614 |
@@ -690,10 +690,10 @@ |
615 |
g_free(tmp); |
616 |
gtk_widget_show (current->label); |
617 |
gtk_misc_set_alignment (GTK_MISC (current->label), 1, 0.5); |
618 |
- |
619 |
+ |
620 |
switch(current->control.type) |
621 |
{ |
622 |
-#ifndef DISABLE_STRING_CONTROLS |
623 |
+#ifndef DISABLE_STRING_CONTROLS |
624 |
case V4L2_CTRL_TYPE_STRING: |
625 |
//text box and set button |
626 |
break; |
627 |
@@ -701,20 +701,20 @@ |
628 |
case V4L2_CTRL_TYPE_INTEGER64: |
629 |
//slider |
630 |
break; |
631 |
- |
632 |
+ |
633 |
case V4L2_CTRL_TYPE_BUTTON: |
634 |
{ |
635 |
current->widget = gtk_button_new_with_label(" "); |
636 |
gtk_widget_show (current->widget); |
637 |
- |
638 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
639 |
+ |
640 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
641 |
GINT_TO_POINTER(current->control.id)); |
642 |
- |
643 |
+ |
644 |
g_signal_connect (GTK_BUTTON(current->widget), "clicked", |
645 |
G_CALLBACK (button_clicked), all_data); |
646 |
} |
647 |
break; |
648 |
- |
649 |
+ |
650 |
case V4L2_CTRL_TYPE_INTEGER: |
651 |
{ |
652 |
switch (current->control.id) |
653 |
@@ -737,47 +737,47 @@ |
654 |
PanTilt1 = gtk_button_new_with_label(_("Down")); |
655 |
PanTilt2 = gtk_button_new_with_label(_("Up")); |
656 |
} |
657 |
- |
658 |
+ |
659 |
gtk_widget_show (PanTilt1); |
660 |
gtk_widget_show (PanTilt2); |
661 |
gtk_box_pack_start(GTK_BOX(current->widget),PanTilt1,TRUE,TRUE,2); |
662 |
gtk_box_pack_start(GTK_BOX(current->widget),PanTilt2,TRUE,TRUE,2); |
663 |
- |
664 |
- g_object_set_data (G_OBJECT (PanTilt1), "control_info", |
665 |
+ |
666 |
+ g_object_set_data (G_OBJECT (PanTilt1), "control_info", |
667 |
GINT_TO_POINTER(current->control.id)); |
668 |
- g_object_set_data (G_OBJECT (PanTilt2), "control_info", |
669 |
+ g_object_set_data (G_OBJECT (PanTilt2), "control_info", |
670 |
GINT_TO_POINTER(current->control.id)); |
671 |
- |
672 |
+ |
673 |
g_signal_connect (GTK_BUTTON(PanTilt1), "clicked", |
674 |
G_CALLBACK (button_PanTilt1_clicked), all_data); |
675 |
g_signal_connect (GTK_BUTTON(PanTilt2), "clicked", |
676 |
G_CALLBACK (button_PanTilt2_clicked), all_data); |
677 |
|
678 |
gtk_widget_show (current->widget); |
679 |
- |
680 |
+ |
681 |
current->spinbutton = gtk_spin_button_new_with_range(-256, 256, 64); |
682 |
/*can't edit the spin value by hand*/ |
683 |
gtk_editable_set_editable(GTK_EDITABLE(current->spinbutton),FALSE); |
684 |
- |
685 |
+ |
686 |
gtk_spin_button_set_value (GTK_SPIN_BUTTON(current->spinbutton), 128); |
687 |
gtk_widget_show (current->spinbutton); |
688 |
}; |
689 |
break; |
690 |
- |
691 |
+ |
692 |
case V4L2_CID_PAN_RESET: |
693 |
case V4L2_CID_TILT_RESET: |
694 |
{ |
695 |
current->widget = gtk_button_new_with_label(" "); |
696 |
gtk_widget_show (current->widget); |
697 |
- |
698 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
699 |
+ |
700 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
701 |
GINT_TO_POINTER(current->control.id)); |
702 |
- |
703 |
+ |
704 |
g_signal_connect (GTK_BUTTON(current->widget), "clicked", |
705 |
G_CALLBACK (button_clicked), all_data); |
706 |
}; |
707 |
break; |
708 |
- |
709 |
+ |
710 |
case V4L2_CID_LED1_MODE_LOGITECH: |
711 |
{ |
712 |
/*turn it into a menu control*/ |
713 |
@@ -796,15 +796,15 @@ |
714 |
_("Auto")); |
715 |
gtk_combo_box_set_active (GTK_COMBO_BOX(current->widget), current->value); |
716 |
gtk_widget_show (current->widget); |
717 |
- |
718 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
719 |
+ |
720 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
721 |
GINT_TO_POINTER(current->control.id)); |
722 |
//connect signal |
723 |
g_signal_connect (GTK_COMBO_BOX_TEXT(current->widget), "changed", |
724 |
G_CALLBACK (combo_changed), all_data); |
725 |
}; |
726 |
break; |
727 |
- |
728 |
+ |
729 |
case V4L2_CID_RAW_BITS_PER_PIXEL_LOGITECH: |
730 |
{ |
731 |
/*turn it into a menu control*/ |
732 |
@@ -815,18 +815,18 @@ |
733 |
gtk_combo_box_text_append_text ( |
734 |
GTK_COMBO_BOX_TEXT (current->widget), |
735 |
_("12 bit")); |
736 |
- |
737 |
+ |
738 |
gtk_combo_box_set_active (GTK_COMBO_BOX(current->widget), current->value); |
739 |
gtk_widget_show (current->widget); |
740 |
- |
741 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
742 |
+ |
743 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
744 |
GINT_TO_POINTER(current->control.id)); |
745 |
//connect signal |
746 |
g_signal_connect (GTK_COMBO_BOX_TEXT(current->widget), "changed", |
747 |
G_CALLBACK (combo_changed), all_data); |
748 |
}; |
749 |
break; |
750 |
- |
751 |
+ |
752 |
default: //standard case - hscale |
753 |
{ |
754 |
/* check for valid range */ |
755 |
@@ -839,19 +839,19 @@ |
756 |
gtk_scale_set_draw_value (GTK_SCALE (current->widget), FALSE); |
757 |
gtk_range_set_round_digits(GTK_RANGE (current->widget), 0); |
758 |
gtk_widget_show (current->widget); |
759 |
- |
760 |
+ |
761 |
current->spinbutton = gtk_spin_button_new_with_range( |
762 |
current->control.minimum, |
763 |
current->control.maximum, |
764 |
current->control.step); |
765 |
/*can't edit the spin value by hand*/ |
766 |
gtk_editable_set_editable(GTK_EDITABLE(current->spinbutton),FALSE); |
767 |
- |
768 |
+ |
769 |
gtk_range_set_value (GTK_RANGE (current->widget), current->value); |
770 |
gtk_spin_button_set_value (GTK_SPIN_BUTTON(current->spinbutton), current->value); |
771 |
gtk_widget_show (current->spinbutton); |
772 |
- |
773 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
774 |
+ |
775 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
776 |
GINT_TO_POINTER(current->control.id)); |
777 |
g_object_set_data (G_OBJECT (current->spinbutton), "control_info", |
778 |
GINT_TO_POINTER(current->control.id)); |
779 |
@@ -870,7 +870,7 @@ |
780 |
}; |
781 |
}; |
782 |
break; |
783 |
- |
784 |
+ |
785 |
case V4L2_CTRL_TYPE_MENU: |
786 |
{ |
787 |
if(current->menu) |
788 |
@@ -878,9 +878,9 @@ |
789 |
int j = 0; |
790 |
int def = 0; |
791 |
current->widget = gtk_combo_box_text_new (); |
792 |
- for (j = 0; current->menu[j].index <= current->control.maximum; j++) |
793 |
+ for (j = 0; current->menu[j].index <= current->control.maximum; j++) |
794 |
{ |
795 |
- if (verbose) |
796 |
+ if (verbose) |
797 |
printf("adding menu entry %d: %d, %s\n",j, current->menu[j].index, current->menu[j].name); |
798 |
gtk_combo_box_text_append_text ( |
799 |
GTK_COMBO_BOX_TEXT (current->widget), |
800 |
@@ -888,11 +888,11 @@ |
801 |
if(current->value == current->menu[j].index) |
802 |
def = j; |
803 |
} |
804 |
- |
805 |
+ |
806 |
gtk_combo_box_set_active (GTK_COMBO_BOX(current->widget), def); |
807 |
gtk_widget_show (current->widget); |
808 |
- |
809 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
810 |
+ |
811 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
812 |
GINT_TO_POINTER(current->control.id)); |
813 |
//connect signal |
814 |
g_signal_connect (GTK_COMBO_BOX_TEXT(current->widget), "changed", |
815 |
@@ -900,11 +900,11 @@ |
816 |
} |
817 |
} |
818 |
break; |
819 |
- |
820 |
+ |
821 |
case V4L2_CTRL_TYPE_BOOLEAN: |
822 |
{ |
823 |
if(current->control.id ==V4L2_CID_DISABLE_PROCESSING_LOGITECH) |
824 |
- { |
825 |
+ { |
826 |
//a little hack :D we use the spin widget as a combo |
827 |
current->spinbutton = gtk_combo_box_text_new (); |
828 |
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(current->spinbutton), |
829 |
@@ -915,30 +915,30 @@ |
830 |
"BGBG... | GRGR..."); |
831 |
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(current->spinbutton), |
832 |
"RGRG... | GBGB..."); |
833 |
- |
834 |
+ |
835 |
gtk_combo_box_set_active(GTK_COMBO_BOX(current->spinbutton), 0); |
836 |
|
837 |
gtk_widget_show (current->spinbutton); |
838 |
- |
839 |
+ |
840 |
g_signal_connect (GTK_COMBO_BOX_TEXT (current->spinbutton), "changed", |
841 |
G_CALLBACK (pix_ord_changed), all_data); |
842 |
- |
843 |
+ |
844 |
videoIn->isbayer = (current->value ? TRUE : FALSE); |
845 |
} |
846 |
- |
847 |
+ |
848 |
current->widget = gtk_check_button_new(); |
849 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current->widget), |
850 |
current->value ? TRUE : FALSE); |
851 |
gtk_widget_show (current->widget); |
852 |
- |
853 |
- g_object_set_data (G_OBJECT (current->widget), "control_info", |
854 |
+ |
855 |
+ g_object_set_data (G_OBJECT (current->widget), "control_info", |
856 |
GINT_TO_POINTER(current->control.id)); |
857 |
//connect signal |
858 |
g_signal_connect (GTK_TOGGLE_BUTTON(current->widget), "toggled", |
859 |
G_CALLBACK (check_changed), all_data); |
860 |
} |
861 |
break; |
862 |
- |
863 |
+ |
864 |
default: |
865 |
printf("control type: 0x%08x not supported\n", current->control.type); |
866 |
break; |
867 |
@@ -952,7 +952,7 @@ |
868 |
next = current->next; |
869 |
} |
870 |
} |
871 |
- |
872 |
+ |
873 |
update_widget_state(control_list, all_data); |
874 |
} |
875 |
|
876 |
@@ -992,23 +992,23 @@ |
877 |
int count = 0; |
878 |
int i = 0; |
879 |
int done = 0; |
880 |
- |
881 |
- while(!done) |
882 |
- { |
883 |
+ |
884 |
+ for(; next != NULL; current = next, next = current->next) |
885 |
+ { |
886 |
if(current->control.flags & V4L2_CTRL_FLAG_WRITE_ONLY) |
887 |
- goto next_control; |
888 |
- |
889 |
+ continue; |
890 |
+ |
891 |
clist[count].id = current->control.id; |
892 |
-#ifndef DISABLE_STRING_CONTROLS |
893 |
+#ifndef DISABLE_STRING_CONTROLS |
894 |
clist[count].size = 0; |
895 |
if(current->control.type == V4L2_CTRL_TYPE_STRING) |
896 |
{ |
897 |
clist[count].size = current->control.maximum + 1; |
898 |
- clist[count].string = current->string; |
899 |
+ clist[count].string = current->string; |
900 |
} |
901 |
#endif |
902 |
count++; |
903 |
- |
904 |
+ |
905 |
if((next == NULL) || (next->class != current->class)) |
906 |
{ |
907 |
struct v4l2_ext_controls ctrls = {0}; |
908 |
@@ -1036,7 +1036,7 @@ |
909 |
} |
910 |
else |
911 |
{ |
912 |
- printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
913 |
+ printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
914 |
current->class); |
915 |
for(i=0;i < count; i++) |
916 |
{ |
917 |
@@ -1049,7 +1049,7 @@ |
918 |
} |
919 |
} |
920 |
} |
921 |
- |
922 |
+ |
923 |
//fill in the values on the control list |
924 |
for(i=0; i<count; i++) |
925 |
{ |
926 |
@@ -1061,7 +1061,7 @@ |
927 |
} |
928 |
switch(ctrl->control.type) |
929 |
{ |
930 |
-#ifndef DISABLE_STRING_CONTROLS |
931 |
+#ifndef DISABLE_STRING_CONTROLS |
932 |
case V4L2_CTRL_TYPE_STRING: |
933 |
//string gets set on VIDIOC_G_EXT_CTRLS |
934 |
//add the maximum size to value |
935 |
@@ -1073,29 +1073,20 @@ |
936 |
break; |
937 |
default: |
938 |
ctrl->value = clist[i].value; |
939 |
- //printf("control %i [0x%08x] = %i\n", |
940 |
+ //printf("control %i [0x%08x] = %i\n", |
941 |
// i, clist[i].id, clist[i].value); |
942 |
break; |
943 |
} |
944 |
} |
945 |
- |
946 |
+ |
947 |
count = 0; |
948 |
- |
949 |
- if(next == NULL) |
950 |
- done = 1; |
951 |
- } |
952 |
- |
953 |
-next_control: |
954 |
- if(!done) |
955 |
- { |
956 |
- current = next; |
957 |
- next = current->next; |
958 |
+ |
959 |
} |
960 |
} |
961 |
- |
962 |
+ |
963 |
update_ctrl_list_flags(control_list); |
964 |
- update_widget_state(control_list, all_data); |
965 |
- |
966 |
+ update_widget_state(control_list, all_data); |
967 |
+ |
968 |
} |
969 |
|
970 |
/* |
971 |
@@ -1106,12 +1097,12 @@ |
972 |
{ |
973 |
Control *control = get_ctrl_by_id(control_list, id ); |
974 |
int ret = 0; |
975 |
- |
976 |
+ |
977 |
if(!control) |
978 |
return (-1); |
979 |
if(control->control.flags & V4L2_CTRL_FLAG_WRITE_ONLY) |
980 |
return (-1); |
981 |
- |
982 |
+ |
983 |
if( control->class == V4L2_CTRL_CLASS_USER) |
984 |
{ |
985 |
struct v4l2_control ctrl; |
986 |
@@ -1121,23 +1112,23 @@ |
987 |
ret = xioctl(hdevice, VIDIOC_G_CTRL, &ctrl); |
988 |
if(ret) |
989 |
printf("control id: 0x%08x failed to get value (error %i)\n", |
990 |
- ctrl.id, ret); |
991 |
+ ctrl.id, ret); |
992 |
else |
993 |
control->value = ctrl.value; |
994 |
} |
995 |
else |
996 |
{ |
997 |
- //printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
998 |
+ //printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
999 |
// current->class); |
1000 |
struct v4l2_ext_controls ctrls = {0}; |
1001 |
struct v4l2_ext_control ctrl = {0}; |
1002 |
ctrl.id = control->control.id; |
1003 |
-#ifndef DISABLE_STRING_CONTROLS |
1004 |
+#ifndef DISABLE_STRING_CONTROLS |
1005 |
ctrl.size = 0; |
1006 |
if(control->control.type == V4L2_CTRL_TYPE_STRING) |
1007 |
{ |
1008 |
ctrl.size = control->control.maximum + 1; |
1009 |
- ctrl.string = control->string; |
1010 |
+ ctrl.string = control->string; |
1011 |
} |
1012 |
#endif |
1013 |
ctrls.count = 1; |
1014 |
@@ -1150,7 +1141,7 @@ |
1015 |
{ |
1016 |
switch(control->control.type) |
1017 |
{ |
1018 |
-#ifndef DISABLE_STRING_CONTROLS |
1019 |
+#ifndef DISABLE_STRING_CONTROLS |
1020 |
case V4L2_CTRL_TYPE_STRING: |
1021 |
//string gets set on VIDIOC_G_EXT_CTRLS |
1022 |
//add the maximum size to value |
1023 |
@@ -1162,21 +1153,21 @@ |
1024 |
break; |
1025 |
default: |
1026 |
control->value = ctrl.value; |
1027 |
- //printf("control %i [0x%08x] = %i\n", |
1028 |
+ //printf("control %i [0x%08x] = %i\n", |
1029 |
// i, clist[i].id, clist[i].value); |
1030 |
break; |
1031 |
} |
1032 |
} |
1033 |
- } |
1034 |
- |
1035 |
+ } |
1036 |
+ |
1037 |
update_ctrl_flags(control_list, id); |
1038 |
update_widget_state(control_list, all_data); |
1039 |
- |
1040 |
+ |
1041 |
return (ret); |
1042 |
} |
1043 |
|
1044 |
/* |
1045 |
- * Goes through the control list and tries to set the controls values |
1046 |
+ * Goes through the control list and tries to set the controls values |
1047 |
*/ |
1048 |
void set_ctrl_values (int hdevice, Control *control_list, int num_controls) |
1049 |
{ |
1050 |
@@ -1187,16 +1178,16 @@ |
1051 |
int count = 0; |
1052 |
int i = 0; |
1053 |
int done = 0; |
1054 |
- |
1055 |
- while(!done) |
1056 |
+ |
1057 |
+ for(; next != NULL; current = next, next = current->next) |
1058 |
{ |
1059 |
if(current->control.flags & V4L2_CTRL_FLAG_READ_ONLY) |
1060 |
- goto next_control; |
1061 |
- |
1062 |
+ continue; |
1063 |
+ |
1064 |
clist[count].id = current->control.id; |
1065 |
switch (current->control.type) |
1066 |
{ |
1067 |
-#ifndef DISABLE_STRING_CONTROLS |
1068 |
+#ifndef DISABLE_STRING_CONTROLS |
1069 |
case V4L2_CTRL_TYPE_STRING: |
1070 |
clist[count].size = current->value; |
1071 |
clist[count].string = current->string; |
1072 |
@@ -1210,7 +1201,7 @@ |
1073 |
break; |
1074 |
} |
1075 |
count++; |
1076 |
- |
1077 |
+ |
1078 |
if((next == NULL) || (next->class != current->class)) |
1079 |
{ |
1080 |
struct v4l2_ext_controls ctrls = {0}; |
1081 |
@@ -1239,13 +1230,13 @@ |
1082 |
clist[i].id, ctrl->control.name, ret); |
1083 |
else |
1084 |
printf("control(0x%08x) failed to set (error %i)\n", |
1085 |
- clist[i].id, ret); |
1086 |
+ clist[i].id, ret); |
1087 |
} |
1088 |
} |
1089 |
} |
1090 |
else |
1091 |
{ |
1092 |
- printf(" using VIDIOC_S_EXT_CTRLS on single controls for class: 0x%08x\n", |
1093 |
+ printf(" using VIDIOC_S_EXT_CTRLS on single controls for class: 0x%08x\n", |
1094 |
current->class); |
1095 |
for(i=0;i < count; i++) |
1096 |
{ |
1097 |
@@ -1265,23 +1256,13 @@ |
1098 |
} |
1099 |
} |
1100 |
} |
1101 |
- |
1102 |
- |
1103 |
- |
1104 |
- count = 0; |
1105 |
- |
1106 |
- if(next == NULL) |
1107 |
- done = 1; |
1108 |
- } |
1109 |
|
1110 |
-next_control: |
1111 |
- if(!done) |
1112 |
- { |
1113 |
- current = next; |
1114 |
- next = current->next; |
1115 |
+ |
1116 |
+ |
1117 |
+ count = 0; |
1118 |
} |
1119 |
} |
1120 |
- |
1121 |
+ |
1122 |
//update list with real values |
1123 |
//get_ctrl_values (hdevice, control_list, num_controls); |
1124 |
} |
1125 |
@@ -1294,7 +1275,7 @@ |
1126 |
Control *current = control_list; |
1127 |
Control *next = current->next; |
1128 |
int done = 0; |
1129 |
- |
1130 |
+ |
1131 |
while(!done) |
1132 |
{ |
1133 |
if(current->control.flags & V4L2_CTRL_FLAG_READ_ONLY) |
1134 |
@@ -1308,10 +1289,10 @@ |
1135 |
} |
1136 |
continue; |
1137 |
} |
1138 |
- //printf("setting 0x%08X to %i\n",current->control.id, current->control.default_value); |
1139 |
+ //printf("setting 0x%08X to %i\n",current->control.id, current->control.default_value); |
1140 |
switch (current->control.type) |
1141 |
{ |
1142 |
-#ifndef DISABLE_STRING_CONTROLS |
1143 |
+#ifndef DISABLE_STRING_CONTROLS |
1144 |
case V4L2_CTRL_TYPE_STRING: |
1145 |
break; |
1146 |
#endif |
1147 |
@@ -1324,7 +1305,7 @@ |
1148 |
current->value = current->control.default_value; |
1149 |
break; |
1150 |
} |
1151 |
- |
1152 |
+ |
1153 |
if(next == NULL) |
1154 |
done = 1; |
1155 |
else |
1156 |
@@ -1333,10 +1314,10 @@ |
1157 |
next = current->next; |
1158 |
} |
1159 |
} |
1160 |
- |
1161 |
+ |
1162 |
set_ctrl_values (hdevice, control_list, num_controls); |
1163 |
get_ctrl_values (hdevice, control_list, num_controls, all_data); |
1164 |
- |
1165 |
+ |
1166 |
} |
1167 |
|
1168 |
/* |
1169 |
@@ -1346,7 +1327,7 @@ |
1170 |
{ |
1171 |
Control *control = get_ctrl_by_id(control_list, id ); |
1172 |
int ret = 0; |
1173 |
- |
1174 |
+ |
1175 |
if(!control) |
1176 |
return (-1); |
1177 |
if(control->control.flags & V4L2_CTRL_FLAG_READ_ONLY) |
1178 |
@@ -1362,14 +1343,14 @@ |
1179 |
} |
1180 |
else |
1181 |
{ |
1182 |
- //printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
1183 |
+ //printf(" using VIDIOC_G_EXT_CTRLS on single controls for class: 0x%08x\n", |
1184 |
// current->class); |
1185 |
struct v4l2_ext_controls ctrls = {0}; |
1186 |
struct v4l2_ext_control ctrl = {0}; |
1187 |
ctrl.id = control->control.id; |
1188 |
switch (control->control.type) |
1189 |
{ |
1190 |
-#ifndef DISABLE_STRING_CONTROLS |
1191 |
+#ifndef DISABLE_STRING_CONTROLS |
1192 |
case V4L2_CTRL_TYPE_STRING: |
1193 |
ctrl.size = control->value; |
1194 |
ctrl.string = control->string; |
1195 |
@@ -1389,11 +1370,11 @@ |
1196 |
printf("control id: 0x%08x failed to set (error %i)\n", |
1197 |
ctrl.id, ret); |
1198 |
} |
1199 |
- |
1200 |
+ |
1201 |
//update real value |
1202 |
get_ctrl(hdevice, control_list, id, NULL); |
1203 |
- |
1204 |
- return (ret); |
1205 |
+ |
1206 |
+ return (ret); |
1207 |
} |
1208 |
|
1209 |
/* |
1210 |
@@ -1424,19 +1405,19 @@ |
1211 |
{ |
1212 |
Control *ctrl = NULL; |
1213 |
int id = V4L2_CID_TILT_RELATIVE; |
1214 |
- if (is_pan) |
1215 |
+ if (is_pan) |
1216 |
id = V4L2_CID_PAN_RELATIVE; |
1217 |
- |
1218 |
+ |
1219 |
ctrl = get_ctrl_by_id(control_list, id ); |
1220 |
- |
1221 |
+ |
1222 |
if (ctrl && ctrl->spinbutton) |
1223 |
{ |
1224 |
- |
1225 |
+ |
1226 |
ctrl->value = direction * gtk_spin_button_get_value_as_int ( |
1227 |
GTK_SPIN_BUTTON(ctrl->spinbutton)); |
1228 |
set_ctrl(hdevice, control_list, id); |
1229 |
} |
1230 |
- |
1231 |
+ |
1232 |
} |