1 /*
2 Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following
11 disclaimer in the documentation and/or other materials provided
12 with the distribution.
13 * Neither the name of The Linux Foundation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include <pthread.h>
31 #include <fcntl.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <unistd.h>
35 #include <termios.h>
36 #include <assert.h>
37 #include <stdlib.h>
38 #include <ctype.h>
39 #include <signal.h>
40 #include <errno.h>
41 #include <sys/mman.h>
42 #include <sys/time.h>
43 #include <sys/ioctl.h>
44 #include <linux/fb.h>
45 #ifdef _ANDROID_
46 #include <cutils/log.h>
47 #endif
48 #include <dlfcn.h>
49
50 #include "camera.h"
51 #include "mm_camera_dbg.h"
52 #include "mm_qcamera_main_menu.h"
53 #include "mm_qcamera_display_dimensions.h"
54 #include "camera_defs_i.h"
55 #include "mm_qcamera_app.h"
56
57 #define CAMERA_OPENED 0
58
59 #define VIDEO_BUFFER_SIZE (PREVIEW_WIDTH * PREVIEW_HEIGHT * 3/2)
60 #define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2)
61 #define SNAPSHOT_BUFFER_SIZE (PICTURE_WIDTH * PICTURE_HEIGHT * 3/2)
62
63 extern int mm_app_take_zsl(int cam_id);
64 extern int mm_app_take_live_snapshot(int cam_id);
65 extern int stopPreview(int cam_id);
66 extern void switchRes(int cam_id);
67 extern void switchCamera(int cam_id);
68 extern int startRdi(int cam_id);
69 extern int stopRdi(int cam_id);
70
71 /*===========================================================================
72 * Macro
73 *===========================================================================*/
74 #define PREVIEW_FRAMES_NUM 4
75 #define VIDEO_FRAMES_NUM 4
76 #define THUMBNAIL_FRAMES_NUM 1
77 #define SNAPSHOT_FRAMES_NUM 1
78 #define MAX_NUM_FORMAT 32
79 /*===========================================================================
80 * Defines
81 *===========================================================================*/
82
83 const CAMERA_MAIN_MENU_TBL_T camera_main_menu_tbl[] = {
84 {STOP_CAMERA, "Stop preview/video and exit camera."},
85 {PREVIEW_VIDEO_RESOLUTION, "Preview/Video Resolution: SQCIF/QCIF/"
86 "QVGA/CIF/VGA/WVGA... Default WVGA."},
87 {TAKE_YUV_SNAPSHOT, "Take a snapshot"},
88 {TAKE_RAW_SNAPSHOT, "Take a raw snapshot"},
89 {TAKE_ZSL_SNAPSHOT, "Take a ZSL snapshot"},
90 {START_RECORDING, "Start RECORDING"},
91 {START_RDI, "Start RDI stream"},
92 {STOP_RDI, "Stop RDI stream"},
93 {SWITCH_CAMERA, "Switch Camera"},
94 #if 0
95 {SET_WHITE_BALANCE, "Set white balance mode: Auto/Off/Daylight/Incandescent/Fluorescent. Default Auto."},
96 {SET_EXP_METERING, "Set exposure metering mode: FrameAverage/CenterWeighted/SpotMetering. Default CenterWeighted"},
97 {GET_CTRL_VALUE, "Get control value menu"},
98 {TOGGLE_AFR, "Toggle auto frame rate. Default fixed frame rate"},
99 {SET_ISO, "ISO changes."},
100 {BRIGHTNESS_GOTO_SUBMENU, "Brightness changes."},
101 {CONTRAST_GOTO_SUBMENU, "Contrast changes."},
102 {EV_GOTO_SUBMENU, "EV changes."},
103 {SATURATION_GOTO_SUBMENU, "Saturation changes."},
104 {SET_ZOOM, "Set Digital Zoom."},
105 {SET_SHARPNESS, "Set Sharpness."},
106 #endif
107 };
108
109 const PREVIEW_DIMENSION_TBL_T preview_video_dimension_tbl[] = {
110 { SQCIF, SQCIF_WIDTH, SQCIF_HEIGHT, "SQCIF", "Preview/Video Resolution: SQCIF <128x96>"},
111 { QCIF, QCIF_WIDTH, QCIF_HEIGHT, "QCIF", "Preview/Video Resolution: QCIF <176x144>"},
112 { QVGA, QVGA_WIDTH, QVGA_HEIGHT, "QVGA", "Preview/Video Resolution: QVGA <320x240>"},
113 { CIF, CIF_WIDTH, CIF_HEIGHT, "CIF", "Preview/Video Resolution: CIF <352x288>"},
114 { VGA, VGA_WIDTH, VGA_HEIGHT, "VGA", "Preview/Video Resolution: VGA <640x480>"},
115 { WVGA, WVGA_WIDTH, WVGA_HEIGHT, "WVGA", "Preview/Video Resolution: WVGA <800x480>"},
116 { SVGA, SVGA_WIDTH, SVGA_HEIGHT, "SVGA", "Preview/Video Resolution: SVGA <800x600>"},
117 { XGA, XGA_WIDTH, XGA_HEIGHT, "XGA", "Preview/Video Resolution: XGA <1024x768>"},
118 { HD720, HD720_WIDTH, HD720_HEIGHT, "HD720", "Preview/Video Resolution: HD720 <1280x720>"},
119 };
120
121 const CAMERA_BRIGHTNESS_TBL_T brightness_change_tbl[] = {
122 {INC_BRIGHTNESS, "Increase Brightness by one step."},
123 {DEC_BRIGHTNESS, "Decrease Brightness by one step."},
124 };
125
126 const CAMERA_CONTRST_TBL_T contrast_change_tbl[] = {
127 {INC_CONTRAST, "Increase Contrast by one step."},
128 {DEC_CONTRAST, "Decrease Contrast by one step."},
129 };
130
131 const CAMERA_EV_TBL_T camera_EV_tbl[] = {
132 {INCREASE_EV, "Increase EV by one step."},
133 {DECREASE_EV, "Decrease EV by one step."},
134 };
135
136 const CAMERA_SATURATION_TBL_T camera_saturation_tbl[] = {
137 {INC_SATURATION, "Increase Satuation by one step."},
138 {DEC_SATURATION, "Decrease Satuation by one step."},
139 };
140
141 const CAMERA_SHARPNESS_TBL_T camera_sharpness_tbl[] = {
142 {INC_SHARPNESS, "Increase Sharpness."},
143 {DEC_SHARPNESS, "Decrease Sharpness."},
144 };
145
146 const WHITE_BALANCE_TBL_T white_balance_tbl[] = {
147 { CAMERA_WB_AUTO, "White Balance - Auto"},
148 { CAMERA_WB_DAYLIGHT, "White Balance - Daylight"},
149 { CAMERA_WB_INCANDESCENT, "White Balance - Incandescent"},
150 { CAMERA_WB_FLUORESCENT, "White Balance - Fluorescent"},
151 { CAMERA_WB_CLOUDY_DAYLIGHT, "White Balance - Cloudy"},
152 };
153
154 const CAMERA_TBL_T cam_tbl[] = {
155 { 1, "Back Camera"},
156 { 2, "Front Camera"},
157 };
158
159 const RECORD_TBL_T record_tbl[] = {
160 { LIVE_SNAPSHOT_MENU, "Take Live snapshot"},
161 { STOP_RECORDING_MENU, "Stop Recording"},
162 };
163
164 const GET_CTRL_TBL_T get_ctrl_tbl[] = {
165 { WHITE_BALANCE_STATE, "Get white balance state (auto/off)"},
166 { WHITE_BALANCE_TEMPERATURE, "Get white balance temperature"},
167 { BRIGHTNESS_CTRL, "Get brightness value"},
168 { EV, "Get exposure value"},
169 { CONTRAST_CTRL, "Get contrast value"},
170 { SATURATION_CTRL, "Get saturation value"},
171 { SHARPNESS_CTRL, "Get sharpness value"},
172 };
173
174 const EXP_METERING_TBL_T exp_metering_tbl[] = {
175 { EXP_METERING_FRAME_AVERAGE, "Exposure Metering - Frame Average"},
176 { EXP_METERING_CENTER_WEIGHTED, "Exposure Metering - Center Weighted"},
177 { EXP_METERING_SPOT_METERING, "Exposure Metering - Spot Metering"},
178 };
179
180 const ISO_TBL_T iso_tbl[] = {
181 { ISO_AUTO, "ISO: Auto"},
182 { ISO_DEBLUR, "ISO: Deblur"},
183 { ISO_100, "ISO: 100"},
184 { ISO_200, "ISO: 200"},
185 { ISO_400, "ISO: 400"},
186 { ISO_800, "ISO: 800"},
187 { ISO_1600, "ISO: 1600"},
188 };
189
190 const ZOOM_TBL_T zoom_tbl[] = {
191 { ZOOM_IN, "Zoom In one step"},
192 { ZOOM_OUT, "Zoom Out one step"},
193 };
194
195
196 struct v4l2_fmtdesc enumfmtdesc[MAX_NUM_FORMAT];
197 struct v4l2_format current_fmt;
198
199 /*===========================================================================
200 * Forward declarations
201 *===========================================================================*/
202 static int set_fps(int fps);
203 static int start_snapshot (void);
204 static int stop_snapshot (void);
205 /*===========================================================================
206 * Static global variables
207 *===========================================================================*/
208 USER_INPUT_DISPLAY_T input_display;
209 static int camframe_status = 0;
210
211 #ifdef _ANDROID_
212 char *sdcard_path = "/data";
213 #else
214 char *sdcard_path = ".";
215 #endif
216
217 //void *libqcamera = NULL;
218 //void (**LINK_jpegfragment_callback)(uint8_t * buff_ptr , uint32_t buff_size);
219 //void (**LINK_jpeg_callback)(void);
220
221 int num_supported_fmts = 0;
222 int memoryType = V4L2_MEMORY_MMAP; /* default */
223 int preview_video_resolution_flag = 0;
224 int effect = CAMERA_EFFECT_OFF;
225 int brightness = CAMERA_DEF_BRIGHTNESS;
226 int contrast = CAMERA_DEF_CONTRAST;
227 int saturation = CAMERA_DEF_SATURATION;
228 int sharpness = CAMERA_DEF_SHARPNESS;
229 int32_t ev_num = 0;
230 uint8_t ezTune = FALSE;
231 int pmemThumbnailfd = 0;
232 int pmemSnapshotfd = 0;
233 int pmemRawSnapshotfd = 0;
234 int fdSnapshot = 0;
235 int fdThumbnail = 0;
236 char snapshotBuf[256] = { 0};
237 char thumbnailBuf[256] = { 0};
238 uint32_t snapshot_buff_size = 0;
239 uint32_t raw_snapshot_buffer_size = 0;
240 static int thumbnailCntr = 0, snapshotCntr = 0;
241 unsigned char *thumbnail_buf = NULL, *main_img_buf = NULL, *raw_img_buf = NULL;
242 int32_t *sharpness_AF = NULL;
243 struct crop_info cropInfo;
244 common_crop_t cropInfo_s;
245
246 interface_ctrl_t intrfcCtrl;
247 config3a_wb_t autoWB = CAMERA_WB_AUTO;
248 isp3a_af_mode_t af_mode = AF_MODE_AUTO;
249 cam_af_focusrect_t afFocusRect = AUTO;
250
251 cam_af_ctrl_t af_ctrl;
252 camera_iso_mode_type iso = CAMERA_ISO_AUTO;
253 camera_antibanding_type antibanding = CAMERA_ANTIBANDING_OFF;
254 camera_auto_exposure_mode_type aec_mode = CAMERA_AEC_CENTER_WEIGHTED;
255 led_mode_t led_mode = LED_MODE_OFF;
256 motion_iso_t motion_iso = MOTION_ISO_OFF;
257 int32_t hue = CAMERA_DEF_HUE;
258 fps_mode_t fps_mode = FPS_MODE_AUTO;
259
260 struct v4l2_cropcap cropcap;
261 struct v4l2_queryctrl zoom_queryctrl;
262 struct v4l2_queryctrl sharpness_queryctrl;
263 int zoom_level;
264
265 Camera_Resolution Resolution;
266 //int32_t g_camParmInfo_current_value = 0;
267 //extern unsigned long preview_frames_buf;
268 //extern void test_app_mmcamera_videoframe_callback(struct msm_frame *frame); // video_cam.c
269
270 /* To flush free video buffers queue */
271 //void (*LINK_cam_frame_flush_free_video)(void);
272 static int submain();
273
274 //struct v4l2_frame_buffer frames[PREVIEW_FRAMES_NUM];
275 //struct v4l2_frame_buffer video_frames[VIDEO_FRAMES_NUM];
276
277 //pthread_t frame_thread;
278
test_app_camframe_timeout_callback(void)279 void test_app_camframe_timeout_callback(void)
280 {
281 camframe_status = -1;
282 }
283
284 /*===========================================================================
285 * FUNCTION - keypress_to_event -
286 *
287 * DESCRIPTION:
288 *==========================================================================*/
keypress_to_event(char keypress)289 int keypress_to_event(char keypress)
290 {
291 char out_buf = INVALID_KEY_PRESS;
292 if ((keypress >= 'A' && keypress <= 'Z') ||
293 (keypress >= 'a' && keypress <= 'z')) {
294 out_buf = tolower(keypress);
295 out_buf = out_buf - 'a' + 1;
296 } else if (keypress >= '1' && keypress <= '9') {
297 out_buf = keypress;
298 out_buf = keypress - '1' + BASE_OFFSET_NUM;
299 }
300 return out_buf;
301 }
302
next_menu(menu_id_change_t current_menu_id,char keypress,camera_action_t * action_id_ptr,int * action_param)303 int next_menu(menu_id_change_t current_menu_id, char keypress, camera_action_t * action_id_ptr, int * action_param)
304 {
305 int output_to_event;
306 menu_id_change_t next_menu_id = MENU_ID_INVALID;
307 * action_id_ptr = ACTION_NO_ACTION;
308
309 output_to_event = keypress_to_event(keypress);
310 CDBG("current_menu_id=%d\n",current_menu_id);
311 CDBG("output_to_event=%d\n",output_to_event);
312 switch(current_menu_id) {
313 case MENU_ID_MAIN:
314 switch(output_to_event) {
315 case STOP_CAMERA:
316 * action_id_ptr = ACTION_STOP_CAMERA;
317 CDBG("STOP_CAMERA\n");
318 break;
319
320 case PREVIEW_VIDEO_RESOLUTION:
321 next_menu_id = MENU_ID_PREVIEWVIDEORESOLUTIONCHANGE;
322 CDBG("next_menu_id = MENU_ID_PREVIEWVIDEORESOLUTIONCHANGE = %d\n", next_menu_id);
323 break;
324 #if 0
325 case SET_WHITE_BALANCE:
326 next_menu_id = MENU_ID_WHITEBALANCECHANGE;
327 CDBG("next_menu_id = MENU_ID_WHITEBALANCECHANGE = %d\n", next_menu_id);
328 break;
329
330 case SET_EXP_METERING:
331 next_menu_id = MENU_ID_EXPMETERINGCHANGE;
332 CDBG("next_menu_id = MENU_ID_EXPMETERINGCHANGE = %d\n", next_menu_id);
333 break;
334
335 case GET_CTRL_VALUE:
336 next_menu_id = MENU_ID_GET_CTRL_VALUE;
337 CDBG("next_menu_id = MENU_ID_GET_CTRL_VALUE = %d\n", next_menu_id);
338 break;
339
340 case BRIGHTNESS_GOTO_SUBMENU:
341 next_menu_id = MENU_ID_BRIGHTNESSCHANGE;
342 CDBG("next_menu_id = MENU_ID_BRIGHTNESSCHANGE = %d\n", next_menu_id);
343 break;
344
345 case CONTRAST_GOTO_SUBMENU:
346 next_menu_id = MENU_ID_CONTRASTCHANGE;
347 break;
348
349 case EV_GOTO_SUBMENU:
350 next_menu_id = MENU_ID_EVCHANGE;
351 break;
352
353 case SATURATION_GOTO_SUBMENU:
354 next_menu_id = MENU_ID_SATURATIONCHANGE;
355 break;
356
357 case TOGGLE_AFR:
358 * action_id_ptr = ACTION_TOGGLE_AFR;
359 CDBG("next_menu_id = MENU_ID_TOGGLEAFR = %d\n", next_menu_id);
360 break;
361
362 case SET_ISO:
363 next_menu_id = MENU_ID_ISOCHANGE;
364 CDBG("next_menu_id = MENU_ID_ISOCHANGE = %d\n", next_menu_id);
365 break;
366
367 case SET_ZOOM:
368 next_menu_id = MENU_ID_ZOOMCHANGE;
369 CDBG("next_menu_id = MENU_ID_ZOOMCHANGE = %d\n", next_menu_id);
370 break;
371
372 case SET_SHARPNESS:
373 next_menu_id = MENU_ID_SHARPNESSCHANGE;
374 CDBG("next_menu_id = MENU_ID_SHARPNESSCHANGE = %d\n", next_menu_id);
375 break;
376 #endif
377 case TAKE_YUV_SNAPSHOT:
378 * action_id_ptr = ACTION_TAKE_YUV_SNAPSHOT;
379 CDBG("Taking YUV snapshot\n");
380 break;
381
382 case TAKE_RAW_SNAPSHOT:
383 * action_id_ptr = ACTION_TAKE_RAW_SNAPSHOT;
384 CDBG("Taking RAW snapshot\n");
385 break;
386 case START_RECORDING:
387 *action_id_ptr = ACTION_START_RECORDING;
388 next_menu_id = MENU_ID_RECORD;
389 CDBG("Start recording\n");
390 break;
391 /*case STOP_RECORDING:
392 * action_id_ptr = ACTION_STOP_RECORDING;
393 CDBG("Stop recording\n");
394 break;*/
395 case SWITCH_CAMERA:
396 next_menu_id = MENU_ID_SWITCHCAMERA;
397 CDBG("SWitch Camera\n");
398 break;
399 case TAKE_ZSL_SNAPSHOT:
400 * action_id_ptr = ACTION_TAKE_ZSL_SNAPSHOT;
401 CDBG("Taking ZSL snapshot\n");
402 break;
403 case START_RDI:
404 * action_id_ptr = ACTION_START_RDI;
405 break;
406 case STOP_RDI:
407 * action_id_ptr = ACTION_STOP_RDI;
408 break;
409 default:
410 next_menu_id = MENU_ID_MAIN;
411 CDBG("next_menu_id = MENU_ID_MAIN = %d\n", next_menu_id);
412 break;
413 }
414 break;
415
416 case MENU_ID_PREVIEWVIDEORESOLUTIONCHANGE:
417 printf("MENU_ID_PREVIEWVIDEORESOLUTIONCHANGE\n");
418 * action_id_ptr = ACTION_PREVIEW_VIDEO_RESOLUTION;
419 if (output_to_event > RESOLUTION_PREVIEW_VIDEO_MAX ||
420 output_to_event < RESOLUTION_MIN) {
421 next_menu_id = current_menu_id;
422 }
423 else {
424 next_menu_id = MENU_ID_MAIN;
425 * action_param = output_to_event;
426 }
427 break;
428
429 case MENU_ID_WHITEBALANCECHANGE:
430 printf("MENU_ID_WHITEBALANCECHANGE\n");
431 * action_id_ptr = ACTION_SET_WHITE_BALANCE;
432 if (output_to_event > 0 &&
433 output_to_event <= sizeof(white_balance_tbl)/sizeof(white_balance_tbl[0])) {
434 next_menu_id = MENU_ID_MAIN;
435 * action_param = output_to_event;
436 }
437 else {
438 next_menu_id = current_menu_id;
439 }
440 break;
441
442 case MENU_ID_EXPMETERINGCHANGE:
443 printf("MENU_ID_EXPMETERINGCHANGE\n");
444 * action_id_ptr = ACTION_SET_EXP_METERING;
445 if (output_to_event > 0 &&
446 output_to_event <= sizeof(exp_metering_tbl)/sizeof(exp_metering_tbl[0])) {
447 next_menu_id = MENU_ID_MAIN;
448 * action_param = output_to_event;
449 }
450 else {
451 next_menu_id = current_menu_id;
452 }
453 break;
454
455 case MENU_ID_GET_CTRL_VALUE:
456 printf("MENU_ID_GET_CTRL_VALUE\n");
457 * action_id_ptr = ACTION_GET_CTRL_VALUE;
458 if (output_to_event > 0 &&
459 output_to_event <= sizeof(get_ctrl_tbl)/sizeof(get_ctrl_tbl[0])) {
460 next_menu_id = MENU_ID_MAIN;
461 * action_param = output_to_event;
462 }
463 else {
464 next_menu_id = current_menu_id;
465 }
466 break;
467
468 case MENU_ID_BRIGHTNESSCHANGE:
469 switch (output_to_event) {
470 case INC_BRIGHTNESS:
471 * action_id_ptr = ACTION_BRIGHTNESS_INCREASE;
472 next_menu_id = MENU_ID_MAIN;
473 break;
474
475 case DEC_BRIGHTNESS:
476 * action_id_ptr = ACTION_BRIGHTNESS_DECREASE;
477 next_menu_id = MENU_ID_MAIN;
478 break;
479
480 default:
481 next_menu_id = MENU_ID_BRIGHTNESSCHANGE;
482 break;
483 }
484 break;
485
486 case MENU_ID_CONTRASTCHANGE:
487 switch (output_to_event) {
488 case INC_CONTRAST:
489 * action_id_ptr = ACTION_CONTRAST_INCREASE;
490 next_menu_id = MENU_ID_MAIN;
491 break;
492
493 case DEC_CONTRAST:
494 * action_id_ptr = ACTION_CONTRAST_DECREASE;
495 next_menu_id = MENU_ID_MAIN;
496 break;
497
498 default:
499 next_menu_id = MENU_ID_CONTRASTCHANGE;
500 break;
501 }
502 break;
503
504 case MENU_ID_EVCHANGE:
505 switch (output_to_event) {
506 case INCREASE_EV:
507 * action_id_ptr = ACTION_EV_INCREASE;
508 next_menu_id = MENU_ID_MAIN;
509 break;
510
511 case DECREASE_EV:
512 * action_id_ptr = ACTION_EV_DECREASE;
513 next_menu_id = MENU_ID_MAIN;
514 break;
515
516 default:
517 next_menu_id = MENU_ID_EVCHANGE;
518 break;
519 }
520 break;
521
522 case MENU_ID_SATURATIONCHANGE:
523 switch (output_to_event) {
524 case INC_SATURATION:
525 * action_id_ptr = ACTION_SATURATION_INCREASE;
526 next_menu_id = MENU_ID_MAIN;
527 break;
528
529 case DEC_SATURATION:
530 * action_id_ptr = ACTION_SATURATION_DECREASE;
531 next_menu_id = MENU_ID_MAIN;
532 break;
533
534 default:
535 next_menu_id = MENU_ID_EVCHANGE;
536 break;
537 }
538 break;
539
540 case MENU_ID_ISOCHANGE:
541 printf("MENU_ID_ISOCHANGE\n");
542 * action_id_ptr = ACTION_SET_ISO;
543 if (output_to_event > 0 &&
544 output_to_event <= sizeof(iso_tbl)/sizeof(iso_tbl[0])) {
545 next_menu_id = MENU_ID_MAIN;
546 * action_param = output_to_event;
547 } else {
548 next_menu_id = current_menu_id;
549 }
550 break;
551
552 case MENU_ID_ZOOMCHANGE:
553 * action_id_ptr = ACTION_SET_ZOOM;
554 if (output_to_event > 0 &&
555 output_to_event <= sizeof(zoom_tbl)/sizeof(zoom_tbl[0])) {
556 next_menu_id = MENU_ID_MAIN;
557 * action_param = output_to_event;
558 } else {
559 next_menu_id = current_menu_id;
560 }
561 break;
562
563 case MENU_ID_SHARPNESSCHANGE:
564 switch (output_to_event) {
565 case INC_SHARPNESS:
566 * action_id_ptr = ACTION_SHARPNESS_INCREASE;
567 next_menu_id = MENU_ID_MAIN;
568 break;
569 case DEC_SHARPNESS:
570 * action_id_ptr = ACTION_SHARPNESS_DECREASE;
571 next_menu_id = MENU_ID_MAIN;
572 break;
573 default:
574 next_menu_id = MENU_ID_SHARPNESSCHANGE;
575 break;
576 }
577 break;
578 case MENU_ID_SWITCHCAMERA:
579 * action_id_ptr = ACTION_SWITCH_CAMERA;
580 if (output_to_event >= 0 &&
581 output_to_event <= sizeof(cam_tbl)/sizeof(cam_tbl[0])) {
582 next_menu_id = MENU_ID_MAIN;
583 * action_param = output_to_event;
584 } else {
585 next_menu_id = current_menu_id;
586 }
587 break;
588 case MENU_ID_RECORD:
589 switch (output_to_event) {
590 case LIVE_SNAPSHOT_MENU:
591 * action_id_ptr = ACTION_TAKE_LIVE_SNAPSHOT;
592 next_menu_id = MENU_ID_RECORD;
593 break;
594
595 default:
596 case STOP_RECORDING_MENU:
597 * action_id_ptr = ACTION_STOP_RECORDING;
598 next_menu_id = MENU_ID_MAIN;
599 break;
600 }
601 default:
602 CDBG("menu id is wrong: %d\n", current_menu_id);
603 break;
604 }
605
606 return next_menu_id;
607 }
608
609 /*===========================================================================
610 * FUNCTION - print_menu_preview_video -
611 *
612 * DESCRIPTION:
613 * ===========================================================================*/
print_menu_preview_video(void)614 static void print_menu_preview_video(void) {
615 unsigned int i;
616
617 printf("\n");
618 printf("===========================================\n");
619 printf(" Camera is in preview/video mode now \n");
620 printf("===========================================\n\n");
621
622 char menuNum = 'A';
623 for (i = 0; i < sizeof(camera_main_menu_tbl)/sizeof(camera_main_menu_tbl[0]); i++) {
624 if (i == BASE_OFFSET) {
625 menuNum = '1';
626 }
627
628 printf("%c. %s\n", menuNum, camera_main_menu_tbl[i].menu_name);
629 menuNum++;
630 }
631
632 printf("\nPlease enter your choice: ");
633
634 return;
635 }
636
camera_preview_video_resolution_change_tbl(void)637 static void camera_preview_video_resolution_change_tbl(void) {
638 unsigned int i;
639
640 printf("\n");
641 printf("==========================================================\n");
642 printf(" Camera is in preview/video resolution mode \n");
643 printf("==========================================================\n\n");
644
645 char previewVideomenuNum = 'A';
646 for (i = 0; i < sizeof(preview_video_dimension_tbl) /
647 sizeof(preview_video_dimension_tbl[0]); i++) {
648 printf("%c. %s\n", previewVideomenuNum,
649 preview_video_dimension_tbl[i].str_name);
650 previewVideomenuNum++;
651 }
652
653 printf("\nPlease enter your choice for Preview/Video Resolution: ");
654 return;
655 }
656
camera_preview_video_wb_change_tbl(void)657 static void camera_preview_video_wb_change_tbl(void) {
658 unsigned int i;
659 printf("\n");
660 printf("==========================================================\n");
661 printf(" Camera is in white balance change mode \n");
662 printf("==========================================================\n\n");
663
664 char submenuNum = 'A';
665 for (i = 0 ; i < sizeof(white_balance_tbl) /
666 sizeof(white_balance_tbl[0]); i++) {
667 //printf("%c. %s\n", submenuNum, white_balance_tbl[i].wb_name);
668 submenuNum++;
669 }
670 printf("\nPlease enter your choice for White Balance modes: ");
671 return;
672 }
673
camera_preview_video_get_ctrl_value_tbl(void)674 static void camera_preview_video_get_ctrl_value_tbl(void) {
675 unsigned int i;
676 printf("\n");
677 printf("==========================================================\n");
678 printf(" Camera is in get control value mode \n");
679 printf("==========================================================\n\n");
680
681 char submenuNum = 'A';
682 for (i = 0 ; i < sizeof(get_ctrl_tbl) /
683 sizeof(get_ctrl_tbl[0]); i++) {
684 printf("%c. %s\n", submenuNum, get_ctrl_tbl[i].get_ctrl_name);
685 submenuNum++;
686 }
687 printf("\nPlease enter your choice for control value you want to get: ");
688 return;
689 }
690
camera_preview_video_exp_metering_change_tbl(void)691 static void camera_preview_video_exp_metering_change_tbl(void) {
692 unsigned int i;
693 printf("\n");
694 printf("==========================================================\n");
695 printf(" Camera is in exposure metering change mode \n");
696 printf("==========================================================\n\n");
697
698 char submenuNum = 'A';
699 for (i = 0 ; i < sizeof(exp_metering_tbl) /
700 sizeof(exp_metering_tbl[0]); i++) {
701 printf("%c. %s\n", submenuNum, exp_metering_tbl[i].exp_metering_name);
702 submenuNum++;
703 }
704 printf("\nPlease enter your choice for exposure metering modes: ");
705 return;
706 }
707
camera_contrast_change_tbl(void)708 static void camera_contrast_change_tbl(void) {
709 unsigned int i;
710
711 printf("\n");
712 printf("==========================================================\n");
713 printf(" Camera is in change contrast resolution mode \n");
714 printf("==========================================================\n\n");
715
716 char contrastmenuNum = 'A';
717 for (i = 0; i < sizeof(contrast_change_tbl) /
718 sizeof(contrast_change_tbl[0]); i++) {
719 printf("%c. %s\n", contrastmenuNum,
720 contrast_change_tbl[i].contrast_name);
721 contrastmenuNum++;
722 }
723
724 printf("\nPlease enter your choice for contrast Change: ");
725 return;
726 }
727
camera_EV_change_tbl(void)728 static void camera_EV_change_tbl(void) {
729 unsigned int i;
730
731 printf("\n");
732 printf("===========================================\n");
733 printf(" Camera is in EV change mode now \n");
734 printf("===========================================\n\n");
735
736 char submenuNum = 'A';
737 for (i = 0; i < sizeof(camera_EV_tbl)/sizeof(camera_EV_tbl[0]); i++) {
738 printf("%c. %s\n", submenuNum, camera_EV_tbl[i].EV_name);
739 submenuNum++;
740 }
741
742 printf("\nPlease enter your choice for EV changes: ");
743 return;
744 }
745
camera_preview_video_zoom_change_tbl(void)746 static void camera_preview_video_zoom_change_tbl(void) {
747 unsigned int i;
748 struct v4l2_control ctrl;
749
750 memset(&ctrl, 0, sizeof(ctrl));
751 ctrl.id = V4L2_CID_ZOOM_ABSOLUTE;
752 #if 0 /* TBD */
753 if (ioctl(camfd, VIDIOC_G_CTRL, &ctrl) >= 0) {
754 zoom_level = ctrl.value;
755 printf("\n");
756 printf("==========================================================\n");
757 printf(" Camera is in zoom change mode: %d, [%d..%d] \n",
758 ctrl.value, zoom_queryctrl.minimum, zoom_queryctrl.maximum);
759 printf("==========================================================\n\n");
760
761 char submenuNum = 'A';
762 for (i = 0 ; i < sizeof(zoom_tbl) /
763 sizeof(zoom_tbl[0]); i++) {
764 printf("%c. %s\n", submenuNum, zoom_tbl[i].zoom_direction_name);
765 submenuNum++;
766 }
767 printf("\nPlease enter your choice for zoom change direction: ");
768 } else {
769 printf("\nVIDIOC_G_CTRL error: %d\n", errno);
770 }
771 #endif /* TBD */
772 return;
773 }
774
camera_brightness_change_tbl(void)775 static void camera_brightness_change_tbl(void) {
776 unsigned int i;
777
778 printf("\n");
779 printf("==========================================================\n");
780 printf(" Camera is in change brightness mode \n");
781 printf("==========================================================\n\n");
782
783 char brightnessmenuNum = 'A';
784 for (i = 0; i < sizeof(brightness_change_tbl) /
785 sizeof(brightness_change_tbl[0]); i++) {
786 printf("%c. %s\n", brightnessmenuNum,
787 brightness_change_tbl[i].brightness_name);
788 brightnessmenuNum++;
789 }
790
791 printf("\nPlease enter your choice for Brightness Change: ");
792 return;
793 }
794
camera_saturation_change_tbl(void)795 static void camera_saturation_change_tbl(void) {
796 unsigned int i;
797
798 printf("\n");
799 printf("==========================================================\n");
800 printf(" Camera is in change saturation mode \n");
801 printf("==========================================================\n\n");
802
803 char saturationmenuNum = 'A';
804 for (i = 0; i < sizeof(camera_saturation_tbl) /
805 sizeof(camera_saturation_tbl[0]); i++) {
806 printf("%c. %s\n", saturationmenuNum,
807 camera_saturation_tbl[i].saturation_name);
808 saturationmenuNum++;
809 }
810
811 printf("\nPlease enter your choice for Saturation Change: ");
812 return;
813 }
814
set_preview_video_dimension_tbl(Camera_Resolution cs_id,uint16_t * width,uint16_t * height)815 char * set_preview_video_dimension_tbl(Camera_Resolution cs_id, uint16_t * width, uint16_t * height)
816 {
817 unsigned int i;
818 char * ptr = NULL;
819 for (i = 0; i < sizeof(preview_video_dimension_tbl) /
820 sizeof(preview_video_dimension_tbl[0]); i++) {
821 if (cs_id == preview_video_dimension_tbl[i].cs_id) {
822 *width = preview_video_dimension_tbl[i].width;
823 *height = preview_video_dimension_tbl[i].height;
824 ptr = preview_video_dimension_tbl[i].name;
825 break;
826 }
827 }
828 return ptr;
829 }
830
camera_preview_video_iso_change_tbl(void)831 static void camera_preview_video_iso_change_tbl(void) {
832 unsigned int i;
833 printf("\n");
834 printf("==========================================================\n");
835 printf(" Camera is in ISO change mode \n");
836 printf("==========================================================\n\n");
837
838 char submenuNum = 'A';
839 for (i = 0 ; i < sizeof(iso_tbl) /
840 sizeof(iso_tbl[0]); i++) {
841 printf("%c. %s\n", submenuNum, iso_tbl[i].iso_modes_name);
842 submenuNum++;
843 }
844 printf("\nPlease enter your choice for iso modes: ");
845 return;
846 }
847
camera_preview_video_sharpness_change_tbl(void)848 static void camera_preview_video_sharpness_change_tbl(void) {
849 unsigned int i;
850 printf("\n");
851 printf("==========================================================\n");
852 printf(" Camera is in sharpness change mode \n");
853 printf("==========================================================\n\n");
854
855 char submenuNum = 'A';
856 for (i = 0 ; i < sizeof(camera_sharpness_tbl) /
857 sizeof(camera_sharpness_tbl[0]); i++) {
858 printf("%c. %s\n", submenuNum, camera_sharpness_tbl[i].sharpness_name);
859 submenuNum++;
860 }
861 printf("\nPlease enter your choice for sharpness modes: ");
862 return;
863 }
864
camera_record_tbl(void)865 static void camera_record_tbl(void) {
866 unsigned int i;
867 printf("\n");
868 printf("==========================================================\n");
869 printf(" Camera is in record mode \n");
870 printf("==========================================================\n\n");
871
872 char submenuNum = 'A';
873 for (i = 0 ; i < sizeof(record_tbl) /
874 sizeof(record_tbl[0]); i++) {
875 printf("%c. %s\n", submenuNum, record_tbl[i].act_name);
876 submenuNum++;
877 }
878 printf("\nPlease enter your choice: ");
879 return;
880 }
881
camera_switch_tbl(void)882 static void camera_switch_tbl(void) {
883 unsigned int i;
884 printf("\n");
885 printf("==========================================================\n");
886 printf(" Camera is in switch camera mode \n");
887 printf("==========================================================\n\n");
888
889 char submenuNum = 'A';
890 for (i = 0 ; i < sizeof(cam_tbl) /
891 sizeof(cam_tbl[0]); i++) {
892 printf("%c. %s\n", submenuNum, cam_tbl[i].cam_name);
893 submenuNum++;
894 }
895 printf("\nPlease enter your choice for camera modes: ");
896 return;
897 }
898 /*===========================================================================
899 * FUNCTION - increase_contrast -
900 *
901 * DESCRIPTION:
902 * ===========================================================================*/
increase_contrast(void)903 int increase_contrast (void) {
904 ++contrast;
905 if (contrast > CAMERA_MAX_CONTRAST) {
906 contrast = CAMERA_MAX_CONTRAST;
907 printf("Reached max CONTRAST. \n");
908 } else
909 printf("Increase CONTRAST to %d\n", contrast);
910
911 /*intrfcCtrl.setContrast(camfd, contrast);*/
912
913 struct v4l2_queryctrl queryctrl;
914 struct v4l2_control control;
915
916 memset (&queryctrl, 0, sizeof (queryctrl));
917 queryctrl.id = V4L2_CID_CONTRAST;
918 #if 0 /* TBD */
919 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
920 if (errno != EINVAL) {
921 perror ("VIDIOC_QUERYCTRL");
922 exit (EXIT_FAILURE);
923 } else {
924 printf ("V4L2_CID_contrast is not supported\n");
925 }
926 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
927 printf ("V4L2_CID_contrast is not supported\n");
928 } else {
929 memset (&control, 0, sizeof (control));
930 control.id = V4L2_CID_CONTRAST;
931 /* Decreasing the contrast */
932 control.value = contrast;
933
934 // if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
935 // perror ("VIDIOC_S_CTRL");
936 // return -1;
937 // }
938 }
939 #endif /* TBD */
940 return 0;
941 }
942
943 /*===========================================================================
944 * FUNCTION - decrease_contrast -
945 *
946 * DESCRIPTION:
947 * ===========================================================================*/
decrease_contrast(void)948 int decrease_contrast (void) {
949 --contrast;
950 if (contrast < CAMERA_MIN_CONTRAST) {
951 contrast = CAMERA_MIN_CONTRAST;
952 printf("Reached min CONTRAST. \n");
953 } else
954 printf("Decrease CONTRAST to %d\n", contrast);
955
956 /*intrfcCtrl.setContrast(camfd, contrast);*/
957 struct v4l2_queryctrl queryctrl;
958 struct v4l2_control control;
959
960 memset (&queryctrl, 0, sizeof (queryctrl));
961 queryctrl.id = V4L2_CID_CONTRAST;
962 #if 0 /* TBD */
963 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
964 if (errno != EINVAL) {
965 perror ("VIDIOC_QUERYCTRL");
966 exit (EXIT_FAILURE);
967 } else {
968 printf ("V4L2_CID_contrast is not supported\n");
969 }
970 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
971 printf ("V4L2_CID_contrast is not supported\n");
972 } else {
973 memset (&control, 0, sizeof (control));
974 control.id = V4L2_CID_CONTRAST;
975 /* Decreasing the contrast */
976 control.value = contrast;
977
978 // if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
979 // perror ("VIDIOC_S_CTRL");
980 // return -1;
981 // }
982 }
983 #endif /* TBD */
984 return 0;
985 }
986
987 /*===========================================================================
988 * FUNCTION - decrease_brightness -
989 *
990 * DESCRIPTION:
991 * ===========================================================================*/
decrease_brightness(void)992 int decrease_brightness (void) {
993 brightness -= CAMERA_BRIGHTNESS_STEP;
994 if (brightness < CAMERA_MIN_BRIGHTNESS) {
995 brightness = CAMERA_MIN_BRIGHTNESS;
996 printf("Reached min BRIGHTNESS. \n");
997 } else
998 printf("Decrease BRIGHTNESS to %d\n", brightness);
999
1000 struct v4l2_queryctrl queryctrl;
1001 struct v4l2_control control;
1002
1003 memset (&queryctrl, 0, sizeof (queryctrl));
1004 queryctrl.id = V4L2_CID_BRIGHTNESS;
1005 #if 0 /* TBD */
1006 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1007 if (errno != EINVAL) {
1008 perror ("VIDIOC_QUERYCTRL");
1009 exit (EXIT_FAILURE);
1010 } else {
1011 printf ("V4L2_CID_BRIGHTNESS is not supported\n");
1012 }
1013 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1014 printf ("V4L2_CID_BRIGHTNESS is not supported\n");
1015 } else {
1016 memset (&control, 0, sizeof (control));
1017 control.id = V4L2_CID_BRIGHTNESS;
1018 /* Decreasing the Brightness */
1019 control.value = brightness;
1020
1021 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1022 perror ("VIDIOC_S_CTRL");
1023 return -1;
1024 }
1025 }
1026 #endif /* TBD */
1027 return 0;
1028 }
1029
1030 /*===========================================================================
1031 * FUNCTION - increase_brightness -
1032 *
1033 * DESCRIPTION:
1034 * ===========================================================================*/
increase_brightness(void)1035 int increase_brightness (void) {
1036 brightness += CAMERA_BRIGHTNESS_STEP;
1037 if (brightness > CAMERA_MAX_BRIGHTNESS) {
1038 brightness = CAMERA_MAX_BRIGHTNESS;
1039 printf("Reached max BRIGHTNESS. \n");
1040 } else
1041 printf("Increase BRIGHTNESS to %d\n", brightness);
1042
1043 struct v4l2_queryctrl queryctrl;
1044 struct v4l2_control control;
1045
1046 memset (&queryctrl, 0, sizeof (queryctrl));
1047 queryctrl.id = V4L2_CID_BRIGHTNESS;
1048 #if 0 /* TBD */
1049 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1050 if (errno != EINVAL) {
1051 perror ("VIDIOC_QUERYCTRL");
1052 exit (EXIT_FAILURE);
1053 } else {
1054 printf ("V4L2_CID_BRIGHTNESS is not supported\n");
1055 }
1056 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1057 printf ("V4L2_CID_BRIGHTNESS is not supported\n");
1058 } else {
1059 memset (&control, 0, sizeof (control));
1060 control.id = V4L2_CID_BRIGHTNESS;
1061 /* Increasing the Brightness */
1062 control.value = brightness;
1063
1064 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1065 perror ("VIDIOC_S_CTRL");
1066 return -1;
1067 }
1068 }
1069 #endif /* TBD */
1070 return 0;
1071 }
1072
1073 /*===========================================================================
1074 * FUNCTION - increase_EV -
1075 *
1076 * DESCRIPTION:
1077 * ===========================================================================*/
increase_EV(void)1078 int increase_EV (void) {
1079 int32_t ev = 0;
1080 if (++ev_num <= 12) {
1081 ev = (ev_num << 16) | 6;
1082 printf("Increase EV to %d\n", ev_num);
1083 } else {
1084 printf("Reached max EV. \n");
1085 ev = ev_num;
1086 }
1087
1088 struct v4l2_queryctrl queryctrl;
1089 struct v4l2_control control;
1090
1091 memset (&queryctrl, 0, sizeof (queryctrl));
1092 queryctrl.id = V4L2_CID_EXPOSURE;
1093 #if 0 /* TBD */
1094 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1095 if (errno != EINVAL) {
1096 perror ("VIDIOC_QUERYCTRL");
1097 exit (EXIT_FAILURE);
1098 } else {
1099 printf ("V4L2_CID_EXPOSURE is not supported\n");
1100 }
1101 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1102 printf ("V4L2_CID_EXPOSURE is not supported\n");
1103 } else {
1104 memset (&control, 0, sizeof (control));
1105 control.id = V4L2_CID_EXPOSURE;
1106 /* Increasing the EV*/
1107 control.value = ev;
1108
1109 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1110 perror ("VIDIOC_S_CTRL");
1111 return -1;
1112 }
1113 }
1114 #endif /* TBD */
1115 return 0;
1116 }
1117
1118 /*===========================================================================
1119 * FUNCTION - decrease_EV -
1120 *
1121 * DESCRIPTION:
1122 * ===========================================================================*/
decrease_EV(void)1123 int decrease_EV (void) {
1124 int32_t ev = 0;
1125 if (--ev_num > -12) {
1126 ev = (ev_num << 16) | 6;
1127 printf("Decrease EV to %d\n", ev_num);
1128 } else {
1129 printf("Reached min EV. \n");
1130 ev = ev_num;
1131 }
1132
1133 struct v4l2_queryctrl queryctrl;
1134 struct v4l2_control control;
1135
1136 memset (&queryctrl, 0, sizeof (queryctrl));
1137 queryctrl.id = V4L2_CID_EXPOSURE;
1138 #if 0 /* TBD */
1139 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1140 if (errno != EINVAL) {
1141 perror ("VIDIOC_QUERYCTRL");
1142 exit (EXIT_FAILURE);
1143 } else {
1144 printf ("V4L2_CID_EXPOSURE is not supported\n");
1145 }
1146 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1147 printf ("V4L2_CID_EXPOSURE is not supported\n");
1148 } else {
1149 memset (&control, 0, sizeof (control));
1150 control.id = V4L2_CID_EXPOSURE;
1151 /* Increasing the EV*/
1152 control.value = ev;
1153
1154 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1155 perror ("VIDIOC_S_CTRL");
1156 return -1;
1157 }
1158 }
1159 #endif /* TBD */
1160 return 0;
1161 }
1162
1163 /*===========================================================================
1164 * FUNCTION - increase_contrast -
1165 *
1166 * DESCRIPTION:
1167 * ===========================================================================*/
increase_saturation(void)1168 int increase_saturation (void) {
1169 ++saturation;
1170 if (saturation > CAMERA_MAX_SATURATION) {
1171 saturation = CAMERA_MAX_SATURATION;
1172 printf("Reached max saturation. \n");
1173 } else
1174 printf("Increase saturation to %d\n", saturation);
1175
1176 /*intrfcCtrl.setContrast(camfd, contrast);*/
1177
1178 struct v4l2_queryctrl queryctrl;
1179 struct v4l2_control control;
1180
1181 memset (&queryctrl, 0, sizeof (queryctrl));
1182 queryctrl.id = V4L2_CID_SATURATION;
1183 #if 0 /* TBD */
1184 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1185 if (errno != EINVAL) {
1186 perror ("VIDIOC_QUERYCTRL");
1187 exit (EXIT_FAILURE);
1188 } else {
1189 printf ("V4L2_CID_saturation is not supported\n");
1190 }
1191 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1192 printf ("V4L2_CID_saturation is not supported\n");
1193 } else {
1194 memset (&control, 0, sizeof (control));
1195 control.id = V4L2_CID_SATURATION;
1196 /* Decreasing the contrast */
1197 control.value = saturation;
1198
1199 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1200 perror ("VIDIOC_S_CTRL");
1201 return -1;
1202 }
1203 }
1204 #endif /* TBD */
1205 return 0;
1206 }
1207
1208 /*===========================================================================
1209 * FUNCTION - decrease_saturation -
1210 *
1211 * DESCRIPTION:
1212 * ===========================================================================*/
decrease_saturation(void)1213 int decrease_saturation (void) {
1214 --saturation;
1215 if (saturation < CAMERA_MIN_SATURATION) {
1216 saturation = CAMERA_MIN_SATURATION;
1217 printf("Reached min saturation. \n");
1218 } else
1219 printf("Decrease saturation to %d\n", saturation);
1220
1221 /*intrfcCtrl.setContrast(camfd, contrast);*/
1222 struct v4l2_queryctrl queryctrl;
1223 struct v4l2_control control;
1224
1225 memset (&queryctrl, 0, sizeof (queryctrl));
1226 queryctrl.id = V4L2_CID_SATURATION;
1227 #if 0 /* TBD */
1228 if (-1 == ioctl (camfd, VIDIOC_QUERYCTRL, &queryctrl)) {
1229 if (errno != EINVAL) {
1230 perror ("VIDIOC_QUERYCTRL");
1231 exit (EXIT_FAILURE);
1232 } else {
1233 printf ("V4L2_CID_saturation is not supported\n");
1234 }
1235 } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
1236 printf ("V4L2_CID_saturation is not supported\n");
1237 } else {
1238 memset (&control, 0, sizeof (control));
1239 control.id = V4L2_CID_SATURATION;
1240 /* Decreasing the contrast */
1241 control.value = saturation;
1242
1243 if (-1 == ioctl (camfd, VIDIOC_S_CTRL, &control)) {
1244 perror ("VIDIOC_S_CTRL");
1245 return -1;
1246 }
1247 }
1248 #endif /* TBD */
1249 return 0;
1250 }
1251
takePicture_yuv(int cam_id)1252 int takePicture_yuv(int cam_id)
1253 {
1254 int rc = 0;
1255 CDBG("%s:BEGIN\n", __func__);
1256 if(0 != (rc = mm_app_take_picture(cam_id))) {
1257 CDBG_ERROR("%s: mm_app_take_picture() err=%d\n", __func__, rc);
1258 }
1259 return rc;
1260 }
1261
takePicture_zsl(int cam_id)1262 int takePicture_zsl(int cam_id)
1263 {
1264 int rc = 0;
1265 CDBG("%s:BEGIN\n", __func__);
1266 if(0 != (rc = mm_app_take_zsl(cam_id))) {
1267 CDBG_ERROR("%s: mm_app_take_picture() err=%d\n", __func__, rc);
1268 }
1269 return rc;
1270 }
1271
takePicture_live(int cam_id)1272 int takePicture_live(int cam_id)
1273 {
1274 int rc = 0;
1275 CDBG("%s:BEGIN\n", __func__);
1276 if(0 != (rc = mm_app_take_live_snapshot(cam_id))) {
1277 CDBG_ERROR("%s: mm_app_take_picture() err=%d\n", __func__, rc);
1278 }
1279 return rc;
1280 }
1281
takePicture_raw(int cam_id)1282 int takePicture_raw(int cam_id)
1283 {
1284 int rc = 0;
1285 CDBG("%s:BEGIN\n", __func__);
1286 if(0 != (rc = mm_app_take_raw(cam_id))) {
1287 CDBG("%s: mm_app_take_raw_picture() err=%d\n", __func__, rc);
1288 }
1289 return rc;
1290 }
system_dimension_set(int cam_id)1291 int system_dimension_set(int cam_id)
1292 {
1293 static cam_ctrl_dimension_t dim;
1294 int rc = 0;
1295
1296 if (preview_video_resolution_flag == 0) {
1297 mm_app_set_dim_def(&dim);
1298 } else {
1299 dim.video_width = input_display.user_input_display_width;
1300 dim.video_width = CEILING32(dim.video_width);
1301 dim.video_height = input_display.user_input_display_height;
1302 dim.orig_video_width = dim.video_width;
1303 dim.orig_video_height = dim.video_height;
1304 dim.display_width = dim.video_width;
1305 dim.display_height = dim.video_height;
1306 }
1307 rc = mm_app_set_dim(cam_id, &dim);
1308 return rc;
1309 }
1310
1311 /*int run_test_harness()
1312 {
1313 int good_test_cnt = 0;
1314
1315 rc = run_test_1();
1316 if(rc < 0)
1317 CDBG_EROR("%s: run_test_1 err = %d", __func__, rc);
1318 rc = run_test_2();
1319 }*/
1320 /*===========================================================================
1321 * FUNCTION - main -
1322 *
1323 * DESCRIPTION:
1324 *==========================================================================*/
main(int argc,char ** argv)1325 int main(int argc, char **argv)
1326 {
1327 int keep_on_going = 1;
1328 int c, rc = 0, tmp_fd;
1329 int run_tc = 0;
1330 int run_dual_tc = 0;
1331 struct v4l2_capability v4l2_cap;
1332
1333 /* get v4l2 params - memory type etc */
1334 while ((c = getopt(argc, argv, "tdh")) != -1) {
1335 //printf("usage: %s [-m] [-u] [-o]\n", argv[1]);
1336 switch (c) {
1337 #if 0
1338 case 'm':
1339 memoryType = V4L2_MEMORY_MMAP;
1340 break;
1341
1342 case 'o':
1343 /*use_overlay_fb_display_driver();*/
1344 break;
1345 case 'u':
1346 memoryType = V4L2_MEMORY_USERPTR;
1347 break;
1348 #endif
1349 case 't':
1350 run_tc = 1;
1351 break;
1352 case 'd':
1353 run_dual_tc = 1;
1354 break;
1355 case 'h':
1356 default:
1357 printf("usage: %s [-m] [-u] [-o]\n", argv[0]);
1358 printf("-m: V4L2_MEMORY_MMAP. \n");
1359 printf("-o: use overlay fb display driver\n");
1360 printf("-u: V4L2_MEMORY_USERPTR\n");
1361 exit(0);
1362 }
1363 }
1364
1365 CDBG("\nCamera Test Application\n");
1366
1367 struct timeval tdBeforePreviewVideo, tdStopCamera;
1368 struct timezone tz;
1369
1370 //return run_test_harness();
1371 if((rc = mm_app_load_hal())) {
1372 CDBG_ERROR("%s:mm_app_init err=%d\n", __func__, rc);
1373 exit(-1);
1374 }
1375 /* we must init mm_app first */
1376 if(mm_app_init() != MM_CAMERA_OK) {
1377 CDBG_ERROR("%s:mm_app_init err=%d\n", __func__, rc);
1378 exit(-1);
1379 }
1380
1381 if(run_tc) {
1382 printf("\tRunning unit test engine only\n");
1383 rc = mm_app_unit_test();
1384 printf("\tUnit test engine. EXIT(%d)!!!\n", rc);
1385 exit(rc);
1386 }
1387
1388 if(run_dual_tc) {
1389 printf("\tRunning Dual camera test engine only\n");
1390 rc = mm_app_dual_test();
1391 printf("\t Dual camera engine. EXIT(%d)!!!\n", rc);
1392 exit(rc);
1393 }
1394
1395 gettimeofday(&tdBeforePreviewVideo, &tz);
1396
1397 CDBG("Profiling: Start Camera timestamp = %ld ms\n",
1398 (tdBeforePreviewVideo.tv_sec * 1000) + (tdBeforePreviewVideo.tv_usec/1000));
1399
1400 /* launch the primary camera in default mode */
1401 if( mm_app_open(CAMERA_OPENED)) {
1402 CDBG_ERROR("%s:mm_app_open() err=%d\n",__func__, rc);
1403 exit(-2);
1404 }
1405
1406 /* main loop doing the work*/
1407 do {
1408 keep_on_going = submain();
1409 } while ( keep_on_going );
1410
1411 /* Clean up and exit. */
1412 CDBG("Exiting the app\n");
1413
1414 error_ionfd_open:
1415 mm_app_close(CAMERA_OPENED);
1416
1417 gettimeofday(&tdStopCamera, &tz);
1418 CDBG("Exiting application\n");
1419 CDBG("Profiling: Stop camera end timestamp = %ld ms\n",
1420 (tdStopCamera.tv_sec * 1000) + (tdStopCamera.tv_usec/1000));
1421
1422 return 0;
1423 }
1424
1425
1426 /*===========================================================================
1427 * FUNCTION - submain -
1428 *
1429 * DESCRIPTION:
1430 * ===========================================================================*/
submain()1431 static int submain()
1432 {
1433 int rc = 0;
1434 int back_mainflag = 0;
1435 char tc_buf[3];
1436 int stop_preview = 1;
1437 menu_id_change_t current_menu_id = MENU_ID_MAIN, next_menu_id;
1438 camera_action_t action_id;
1439 int action_param;
1440 int i;
1441 int cam_id;
1442
1443 CDBG("%s:E", __func__);
1444 struct timeval tdStopCamera;
1445 struct timezone tz;
1446
1447 cam_id = my_cam_app.cam_open;
1448
1449 rc = system_dimension_set(cam_id);
1450 CDBG("Start Preview");
1451 if( 0 != (rc = startPreview(cam_id))) {
1452 CDBG("%s: startPreview() err=%d\n", __func__, rc);
1453 return 0;
1454 }
1455
1456 do {
1457 print_current_menu (current_menu_id);
1458 fgets(tc_buf, 3, stdin);
1459
1460 next_menu_id = next_menu(current_menu_id, tc_buf[0], &action_id, &action_param);
1461
1462 if (next_menu_id != MENU_ID_INVALID) {
1463 current_menu_id = next_menu_id;
1464 }
1465 if (action_id == ACTION_NO_ACTION) {
1466 continue;
1467 }
1468 if(camframe_status == -1) {
1469 printf("Preview/Video ERROR condition reported Closing Camera APP\n");
1470 break;
1471 }
1472
1473 switch(action_id) {
1474 case ACTION_STOP_CAMERA:
1475 CDBG("ACTION_STOP_CAMERA \n");
1476 stopPreview(cam_id);
1477 break;
1478
1479 case ACTION_PREVIEW_VIDEO_RESOLUTION:
1480 back_mainflag = 1;
1481 CDBG("Selection for the preview/video resolution change\n");
1482 switchRes(cam_id);
1483 preview_video_resolution (action_param);
1484 break;
1485 case ACTION_SET_WHITE_BALANCE:
1486 CDBG("Selection for the White Balance changes\n");
1487 set_whitebalance(action_param);
1488 break;
1489
1490 case ACTION_SET_EXP_METERING:
1491 CDBG("Selection for the Exposure Metering changes\n");
1492 set_exp_metering(action_param);
1493 break;
1494
1495 case ACTION_GET_CTRL_VALUE:
1496 CDBG("Selection for getting control value\n");
1497 get_ctrl_value(action_param);
1498 break;
1499
1500 case ACTION_BRIGHTNESS_INCREASE:
1501 printf("Increase brightness\n");
1502 increase_brightness();
1503 break;
1504
1505 case ACTION_BRIGHTNESS_DECREASE:
1506 printf("Decrease brightness\n");
1507 decrease_brightness();
1508 break;
1509
1510 case ACTION_CONTRAST_INCREASE:
1511 CDBG("Selection for the contrast increase\n");
1512 increase_contrast ();
1513 break;
1514
1515 case ACTION_CONTRAST_DECREASE:
1516 CDBG("Selection for the contrast decrease\n");
1517 decrease_contrast ();
1518 break;
1519
1520 case ACTION_EV_INCREASE:
1521 CDBG("Selection for the EV increase\n");
1522 increase_EV ();
1523 break;
1524
1525 case ACTION_EV_DECREASE:
1526 CDBG("Selection for the EV decrease\n");
1527 decrease_EV ();
1528 break;
1529
1530 case ACTION_SATURATION_INCREASE:
1531 CDBG("Selection for the EV increase\n");
1532 increase_saturation ();
1533 break;
1534
1535 case ACTION_SATURATION_DECREASE:
1536 CDBG("Selection for the EV decrease\n");
1537 decrease_saturation ();
1538 break;
1539
1540 case ACTION_TOGGLE_AFR:
1541 CDBG("Select for auto frame rate toggling\n");
1542 toggle_afr();
1543 break;
1544
1545 case ACTION_SET_ISO:
1546 CDBG("Select for ISO changes\n");
1547 set_iso(action_param);
1548 break;
1549
1550 case ACTION_SET_ZOOM:
1551 CDBG("Selection for the zoom direction changes\n");
1552 set_zoom(action_param);
1553 break;
1554
1555 case ACTION_SHARPNESS_INCREASE:
1556 CDBG("Selection for sharpness increase\n");
1557 increase_sharpness();
1558 break;
1559
1560 case ACTION_SHARPNESS_DECREASE:
1561 CDBG("Selection for sharpness decrease\n");
1562 decrease_sharpness();
1563 break;
1564
1565 case ACTION_TAKE_YUV_SNAPSHOT:
1566 CDBG("Take YUV snapshot\n");
1567 if (takePicture_yuv(cam_id) < 0)
1568 goto ERROR;
1569 break;
1570 case ACTION_TAKE_RAW_SNAPSHOT:
1571 CDBG("Take YUV snapshot\n");
1572 if (takePicture_raw(cam_id) < 0)
1573 goto ERROR;
1574 break;
1575 case ACTION_START_RECORDING:
1576 CDBG("Start recording action\n");
1577 if (startRecording(cam_id) < 0)
1578 goto ERROR;
1579 break;
1580 case ACTION_STOP_RECORDING:
1581 CDBG("Stop recording action\n");
1582 if (stopRecording(cam_id) < 0)
1583 goto ERROR;
1584 break;
1585 case ACTION_NO_ACTION:
1586 printf("Go back to main menu");
1587 break;
1588 case ACTION_SWITCH_CAMERA:
1589 CDBG("Toggle Camera action\n");
1590 back_mainflag = 1;
1591 switchCamera(action_param - 1);
1592 break;
1593
1594 case ACTION_TAKE_ZSL_SNAPSHOT:
1595 CDBG("Take ZSL snapshot\n");
1596 if (takePicture_zsl(cam_id) < 0)
1597 {
1598 CDBG("Error");
1599 goto ERROR;
1600 }
1601 break;
1602 case ACTION_START_RDI:
1603 CDBG("Start RDI Stream\n");
1604 startRdi(cam_id);
1605 break;
1606 case ACTION_STOP_RDI:
1607 CDBG("Stop RDI Stream\n");
1608 stopRdi(cam_id);
1609 break;
1610 case ACTION_TAKE_LIVE_SNAPSHOT:
1611 CDBG("Take Live snapshot\n");
1612 if (takePicture_live(cam_id) < 0)
1613 {
1614 CDBG("Error");
1615 goto ERROR;
1616 }
1617 break;
1618
1619 default:
1620 printf("\n\n!!!!!WRONG INPUT: %d!!!!\n", action_id);
1621 break;
1622 }
1623
1624 usleep(1000 * 1000);
1625 CDBG("action_id = %d\n", action_id);
1626 camframe_status = 0;
1627
1628 } while ((action_id != ACTION_STOP_CAMERA) &&
1629 (action_id != ACTION_PREVIEW_VIDEO_RESOLUTION) && (action_id !=ACTION_SWITCH_CAMERA));
1630 action_id = ACTION_NO_ACTION;
1631
1632 //system_destroy();
1633
1634
1635 return back_mainflag;
1636
1637 ERROR:
1638 back_mainflag = 0;
1639 return back_mainflag;
1640 }
1641
1642
1643 /*===========================================================================
1644 * FUNCTION - preview_resolution -
1645 *
1646 * DESCRIPTION:
1647 * ===========================================================================*/
preview_video_resolution(int preview_video_action_param)1648 int preview_video_resolution (int preview_video_action_param) {
1649 char * resolution_name;
1650 CDBG("Selecting the action for preview/video resolution = %d \n", preview_video_action_param);
1651 resolution_name = set_preview_video_dimension_tbl(preview_video_action_param,
1652 & input_display.user_input_display_width,
1653 & input_display.user_input_display_height);
1654
1655 CDBG("Selected preview/video resolution is %s\n", resolution_name);
1656
1657 if (resolution_name == NULL) {
1658 CDBG("main:%d set_preview_dimension failed!\n", __LINE__);
1659 goto ERROR;
1660 }
1661
1662 CDBG("Selected Preview Resolution: display_width = %d, display_height = %d\n",
1663 input_display.user_input_display_width, input_display.user_input_display_height);
1664
1665 preview_video_resolution_flag = 1;
1666 return 0;
1667
1668 ERROR:
1669 return -1;
1670 }
1671
1672 /*===========================================================================
1673 * FUNCTION - set_whitebalance -
1674 *
1675 * DESCRIPTION:
1676 * ===========================================================================*/
set_whitebalance(int wb_action_param)1677 int set_whitebalance (int wb_action_param) {
1678
1679 int rc = 0;
1680 struct v4l2_control ctrl_awb, ctrl_temperature;
1681
1682 ctrl_awb.id = V4L2_CID_AUTO_WHITE_BALANCE;
1683 ctrl_awb.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE;
1684
1685 switch (wb_action_param) {
1686 case CAMERA_WB_INCANDESCENT:
1687 ctrl_awb.value = FALSE;
1688 ctrl_temperature.value = 2800;
1689 break;
1690 case CAMERA_WB_DAYLIGHT:
1691 ctrl_awb.value = FALSE;
1692 ctrl_temperature.value = 6500;
1693 break;
1694 case CAMERA_WB_FLUORESCENT:
1695 ctrl_awb.value = FALSE;
1696 ctrl_temperature.value = 4200;
1697 break;
1698 case CAMERA_WB_CLOUDY_DAYLIGHT:
1699 ctrl_awb.value = FALSE;
1700 ctrl_temperature.value = 7500;
1701 break;
1702 case CAMERA_WB_AUTO:
1703 default:
1704 ctrl_awb.value = TRUE;
1705 break;
1706 }
1707
1708 DONE:
1709 return rc;
1710 }
1711
1712
1713 /*===========================================================================
1714 * FUNCTION - set_exp_metering -
1715 *
1716 * DESCRIPTION:
1717 * ===========================================================================*/
set_exp_metering(int exp_metering_action_param)1718 int set_exp_metering (int exp_metering_action_param) {
1719
1720 int rc = 0;
1721 struct v4l2_control ctrl;
1722
1723 ctrl.id = MSM_V4L2_PID_EXP_METERING;
1724 ctrl.value = exp_metering_action_param;
1725 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1726
1727 return rc;
1728 }
1729
get_ctrl_value(int ctrl_value_mode_param)1730 int get_ctrl_value (int ctrl_value_mode_param){
1731
1732 int rc = 0;
1733 struct v4l2_control ctrl;
1734
1735 if (ctrl_value_mode_param == WHITE_BALANCE_STATE) {
1736 printf("You chose WHITE_BALANCE_STATE\n");
1737 ctrl.id = V4L2_CID_AUTO_WHITE_BALANCE;
1738 }
1739 else if (ctrl_value_mode_param == WHITE_BALANCE_TEMPERATURE) {
1740 printf("You chose WHITE_BALANCE_TEMPERATURE\n");
1741 ctrl.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE;
1742 }
1743 else if (ctrl_value_mode_param == BRIGHTNESS_CTRL) {
1744 printf("You chose brightness value\n");
1745 ctrl.id = V4L2_CID_BRIGHTNESS;
1746 }
1747 else if (ctrl_value_mode_param == EV) {
1748 printf("You chose exposure value\n");
1749 ctrl.id = V4L2_CID_EXPOSURE;
1750 }
1751 else if (ctrl_value_mode_param == CONTRAST_CTRL) {
1752 printf("You chose contrast value\n");
1753 ctrl.id = V4L2_CID_CONTRAST;
1754 }
1755 else if (ctrl_value_mode_param == SATURATION_CTRL) {
1756 printf("You chose saturation value\n");
1757 ctrl.id = V4L2_CID_SATURATION;
1758 } else if (ctrl_value_mode_param == SHARPNESS_CTRL) {
1759 printf("You chose sharpness value\n");
1760 ctrl.id = V4L2_CID_SHARPNESS;
1761 }
1762
1763 // rc = ioctl(camfd, VIDIOC_G_CTRL, &ctrl);
1764
1765 return rc;
1766 }
1767
1768 /*===========================================================================
1769 * FUNCTION - toggle_afr -
1770 *
1771 * DESCRIPTION:
1772 * ===========================================================================*/
toggle_afr()1773 int toggle_afr () {
1774 int rc = 0;
1775 struct v4l2_control ctrl;
1776
1777 memset(&ctrl, 0, sizeof(ctrl));
1778 ctrl.id = V4L2_CID_EXPOSURE_AUTO;
1779 // rc = ioctl(camfd, VIDIOC_G_CTRL, &ctrl);
1780 if (rc == -1) {
1781 CDBG("%s: VIDIOC_G_CTRL V4L2_CID_EXPOSURE_AUTO failed: %s\n",
1782 __func__, strerror(errno));
1783 return rc;
1784 }
1785
1786 /* V4L2_CID_EXPOSURE_AUTO needs to be AUTO or SHUTTER_PRIORITY */
1787 if (ctrl.value != V4L2_EXPOSURE_AUTO &&
1788 ctrl.value != V4L2_EXPOSURE_SHUTTER_PRIORITY) {
1789 CDBG("%s: V4L2_CID_EXPOSURE_AUTO needs to be AUTO/SHUTTER_PRIORITY\n",
1790 __func__);
1791 return -1;
1792 }
1793
1794 /* Get V4L2_CID_EXPOSURE_AUTO_PRIORITY */
1795 memset(&ctrl, 0, sizeof(ctrl));
1796 ctrl.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY;
1797 // rc = ioctl(camfd, VIDIOC_G_CTRL, &ctrl);
1798 if (rc == -1) {
1799 CDBG("%s: VIDIOC_G_CTRL V4L2_CID_EXPOSURE_AUTO_PRIORITY failed: %s\n",
1800 __func__, strerror(errno));
1801 return rc;
1802 }
1803
1804 ctrl.value = !ctrl.value;
1805 printf("V4L2_CID_EXPOSURE_AUTO_PRIORITY changed to %d\n", ctrl.value);
1806 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1807 if (rc == -1) {
1808 CDBG("%s: VIDIOC_S_CTRL V4L2_CID_EXPOSURE_AUTO_PRIORITY failed: %s\n",
1809 __func__, strerror(errno));
1810 }
1811 return rc;
1812 }
1813
set_zoom(int zoom_action_param)1814 int set_zoom (int zoom_action_param) {
1815 int rc = 0;
1816 struct v4l2_control ctrl;
1817
1818 if (zoom_action_param == ZOOM_IN) {
1819 zoom_level += zoom_queryctrl.step;
1820 if (zoom_level > zoom_queryctrl.maximum)
1821 zoom_level = zoom_queryctrl.maximum;
1822 } else if (zoom_action_param == ZOOM_OUT) {
1823 zoom_level -= zoom_queryctrl.step;
1824 if (zoom_level < zoom_queryctrl.minimum)
1825 zoom_level = zoom_queryctrl.minimum;
1826 } else {
1827 CDBG("%s: Invalid zoom_action_param value\n", __func__);
1828 return -EINVAL;
1829 }
1830 ctrl.id = V4L2_CID_ZOOM_ABSOLUTE;
1831 ctrl.value = zoom_level;
1832 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1833
1834 return rc;
1835 }
1836
1837 /*===========================================================================
1838 * FUNCTION - set_iso -
1839 *
1840 * DESCRIPTION:
1841 * ===========================================================================*/
set_iso(int iso_action_param)1842 int set_iso (int iso_action_param) {
1843 int rc = 0;
1844 struct v4l2_control ctrl;
1845
1846 ctrl.id = MSM_V4L2_PID_ISO;
1847 ctrl.value = iso_action_param - 1;
1848 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1849
1850 return rc;
1851 }
1852
1853 /*===========================================================================
1854 * FUNCTION - increase_sharpness -
1855 *
1856 * DESCRIPTION:
1857 * ===========================================================================*/
increase_sharpness()1858 int increase_sharpness () {
1859 int rc = 0;
1860 struct v4l2_control ctrl;
1861
1862 sharpness += sharpness_queryctrl.step;
1863 if (sharpness > sharpness_queryctrl.maximum)
1864 sharpness = sharpness_queryctrl.maximum;
1865
1866 ctrl.id = V4L2_CID_SHARPNESS;
1867 ctrl.value = sharpness;
1868 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1869
1870 return rc;
1871 }
1872
1873 /*===========================================================================
1874 * FUNCTION - decrease_sharpness -
1875 *
1876 * DESCRIPTION:
1877 * ===========================================================================*/
decrease_sharpness()1878 int decrease_sharpness () {
1879 int rc = 0;
1880 struct v4l2_control ctrl;
1881
1882 sharpness -= sharpness_queryctrl.step;
1883 if (sharpness < sharpness_queryctrl.minimum)
1884 sharpness = sharpness_queryctrl.minimum;
1885
1886 ctrl.id = V4L2_CID_SHARPNESS;
1887 ctrl.value = sharpness;
1888 // rc = ioctl(camfd, VIDIOC_S_CTRL, &ctrl);
1889
1890 return rc;
1891 }
1892
1893 /*===========================================================================
1894 * FUNCTION - print_current_menu -
1895 *
1896 * DESCRIPTION:
1897 * ===========================================================================*/
print_current_menu(menu_id_change_t current_menu_id)1898 int print_current_menu (menu_id_change_t current_menu_id) {
1899 if (current_menu_id == MENU_ID_MAIN) {
1900 print_menu_preview_video ();
1901 } else if (current_menu_id == MENU_ID_PREVIEWVIDEORESOLUTIONCHANGE) {
1902 camera_preview_video_resolution_change_tbl ();
1903 }else if (current_menu_id == MENU_ID_WHITEBALANCECHANGE) {
1904 camera_preview_video_wb_change_tbl();
1905 } else if (current_menu_id == MENU_ID_EXPMETERINGCHANGE) {
1906 camera_preview_video_exp_metering_change_tbl();
1907 } else if (current_menu_id == MENU_ID_GET_CTRL_VALUE) {
1908 camera_preview_video_get_ctrl_value_tbl();
1909 } else if (current_menu_id == MENU_ID_ISOCHANGE) {
1910 camera_preview_video_iso_change_tbl();
1911 } else if (current_menu_id == MENU_ID_BRIGHTNESSCHANGE) {
1912 camera_brightness_change_tbl ();
1913 } else if (current_menu_id == MENU_ID_CONTRASTCHANGE) {
1914 camera_contrast_change_tbl ();
1915 } else if (current_menu_id == MENU_ID_EVCHANGE) {
1916 camera_EV_change_tbl ();
1917 } else if (current_menu_id == MENU_ID_SATURATIONCHANGE) {
1918 camera_saturation_change_tbl ();
1919 } else if (current_menu_id == MENU_ID_ZOOMCHANGE) {
1920 camera_preview_video_zoom_change_tbl();
1921 } else if (current_menu_id == MENU_ID_SHARPNESSCHANGE) {
1922 camera_preview_video_sharpness_change_tbl();
1923 }else if (current_menu_id == MENU_ID_SWITCHCAMERA) {
1924 camera_switch_tbl();
1925 }else if (current_menu_id == MENU_ID_RECORD) {
1926 camera_record_tbl();
1927 }
1928
1929 return 0;
1930 }
1931
1932