opt_nm33_uvc.cpp
Go to the documentation of this file.
00001 /*                                                            */
00002 /* This code is based on luvcview_wr_100823 from Opt corp.    */
00003 /*                                                            */
00004 /*                  2010/09/15    k-okada@jsk.t.u-tokyo.ac.jp */
00005 
00006 //
00007 // 2010/8/23 Opt Corporation.
00008 //
00009 //  add xu_control_tbl
00010 //  add set_xu_control()
00011 
00012 
00013 #include "opt_nm33_uvc.h"
00014 
00015 __u8 gui_extension[16] = UVC_GUID_UVC_EXTENSION;
00016 
00017 #define XU_GET UVC_CONTROL_GET_CUR
00018 #define XU_SET UVC_CONTROL_SET_CUR
00019 
00020 #define V4L2_XU_ID_BASE 0x0A046D01
00021 uvc_xu_tbl_info xu_control_tbl[] = {
00022 #ifdef NON_STD_UVC
00023   {"Firmware Version", XU_FIRMWARE_VERSION_CONTROL, 0xFF, 0, XU_GET,
00024         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00025 #else
00026   {"Firmware Version", XU_FIRMWARE_VERSION_CONTROL, 0x20, 0, XU_GET,
00027         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00028 #endif
00029   {"Flash Parameter", XU_FLASH_PARAMETER_CONTROL, 1, 0, XU_SET | XU_GET,
00030         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00031   {"Flip Screen", XU_FLIP_SCREEN_CONTROL, 1, 0, XU_SET | XU_GET,
00032         V4L2_CTRL_TYPE_MENU, UVC_CTRL_DATA_TYPE_BITMASK},
00033   {"small Hemisphere", XU_SMALL_HEMISPHERE_CONTROL, 1, 0, XU_SET | XU_GET,
00034         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00035   {"Analog Video", XU_ANALOG_VIDEO_STANDARD_CONTROL, 1, 0, XU_SET | XU_GET,
00036         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00037   {"Median Filter", XU_MEDIAN_FILTER_CONTROL, 1, 0, XU_SET | XU_GET,
00038         V4L2_CTRL_TYPE_BOOLEAN, UVC_CTRL_DATA_TYPE_BOOLEAN},
00039   {"Push Button", XU_PUSH_BUTTON_CONTROL, 2, 0, XU_SET | XU_GET,
00040         V4L2_CTRL_TYPE_MENU, UVC_CTRL_DATA_TYPE_BITMASK},
00041   {"Pending PTZR", XU_PENDING_PTZR_CONTROL, 1, 0, XU_SET | XU_GET,
00042         V4L2_CTRL_TYPE_BOOLEAN, UVC_CTRL_DATA_TYPE_BOOLEAN},
00043   {"Auto Pan", XU_AUTO_PAN_SPEED_CONTROL, 1, 0, XU_SET | XU_GET,
00044         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_SIGNED},
00045   {"JPEG Quality", XU_JPEG_QUALITY_CONTROL, 1, 0, XU_SET | XU_GET,
00046         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_SIGNED},
00047 #ifdef NON_STD_UVC
00048   {"Serial ID", XU_SERIAL_ID_CONTROL, 16, 0, XU_GET,
00049         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00050 #else
00051   {"Serial ID", XU_SERIAL_ID_CONTROL, 16, 0, XU_SET | XU_GET,
00052         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00053 #endif
00054   {"Info Display", XU_INFO_DISPLAY_CONTROL, 1, 0, XU_SET | XU_GET,
00055         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00056   {"Capture Fps", XU_CAPTURE_FPS_CONTROL, 2, 0, XU_SET | XU_GET,
00057         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00058   {"Actual Fps", XU_ACTUAL_FPS_CONTROL, 2, 0, XU_GET,
00059         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00060   {"Lens Type", XU_LENS_TYPE_CONTROL, 1, 0, XU_SET | XU_GET,
00061         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
00062   {"XPan Absolute", XU_PAN_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
00063         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00064   {"XTilt Absolute", XU_TILT_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
00065         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00066   {"XRoll Absolute", XU_ROLL_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
00067         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00068   {"XZoom Absolute", XU_ZOOM_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
00069         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00070   {"Location Absolute", XU_LOCATION_ABSOLUTE_CONTROL, 10, 0, XU_SET,
00071         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00072   {"XGain Absolute", XU_GAIN_ABSOLUTE_CONTROL, 2, 0, XU_SET | XU_GET,
00073         V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
00074 };
00075 
00076 int uvc_xu_tbl_cnt = sizeof(xu_control_tbl)/sizeof(uvc_xu_tbl_info);
00077 
00078 uvc_menu_info xu_menu_flip_table[] = {
00079   {0, "off"},
00080   {1, "horizontal"},
00081   {2, "vertical"},
00082   {3, "both"}
00083 };
00084 
00085 uvc_menu_info xu_menu_button_table[] = {
00086   {0, "off"},
00087   {1, "east"},
00088   {2, "west"},
00089   {3, "south"},
00090   {4, "north"},
00091   {5, "se"},
00092   {6, "ne"},
00093   {7, "sw"},
00094   {8, "nw"},
00095   {9, "zoom-in"},
00096   {10, "zoom-out"},
00097   {11, "menu"},
00098   {12, "select"}
00099 };
00100 
00101 int set_XU_control(int vd)
00102 {
00103   int i = 0;
00104   int value = 0;
00105   int ret = 0;
00106 
00107   struct uvc_xu_control_mapping map = {0, "", UVC_GUID_UVC_EXTENSION, 0,
00108                                        0, 0, 0, 0,
00109                                        NULL, 0, {0, 0, 0, 0}};
00110 
00111   printf("********XU registration************\n");
00112   for(i = 0; i < uvc_xu_tbl_cnt; i++){
00113     map.id = V4L2_XU_ID_BASE + i;
00114     memcpy(map.name, xu_control_tbl[i].name, 32);
00115     map.selector = xu_control_tbl[i].selector;
00116     if (xu_control_tbl[i].size == 0xFF)
00117       map.size = xu_control_tbl[i].size;
00118     else
00119       map.size = xu_control_tbl[i].size * 8;
00120     map.offset = xu_control_tbl[i].offset;
00121     map.v4l2_type = xu_control_tbl[i].v4l2_type;
00122     map.data_type = xu_control_tbl[i].data_type;
00123 
00124     switch (xu_control_tbl[i].selector) {
00125       case XU_FLIP_SCREEN_CONTROL:
00126         map.menu_info = xu_menu_flip_table;
00127         map.menu_count = sizeof(xu_menu_flip_table) / sizeof(uvc_menu_info);
00128         break;
00129       case XU_PUSH_BUTTON_CONTROL:
00130         map.menu_info = xu_menu_button_table;
00131         map.menu_count = sizeof(xu_menu_button_table) / sizeof(uvc_menu_info);
00132         break;
00133       default:
00134         map.menu_info = NULL;
00135         map.menu_count = 0;
00136     }
00137 
00138     if ((value = ioctl(vd, UVCIOC_CTRL_MAP, &map)) < 0){
00139       ret = 1;
00140       printf("XU mapping error: %s, %s\n", xu_control_tbl[i].name, strerror(errno));
00141     } else {
00142       printf("XU mapping succeeded: %s\n", xu_control_tbl[i].name);
00143     }
00144   }
00145 
00146   return 0;
00147 }
00148 


opt_camera
Author(s): Kei Okada
autogenerated on Sat Sep 9 2017 02:33:38