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 int set_XU_control(int vd)
00079 {
00080   int i = 0;
00081   int value = 0;
00082   int ret = 0;
00083   struct uvc_xu_control_info info = {UVC_GUID_UVC_EXTENSION,0,0,0,0};
00084   struct uvc_xu_control_mapping map = {0,"",UVC_GUID_UVC_EXTENSION,0,0,0,(v4l2_ctrl_type)0,0};
00085 
00086   printf("********XU registration************\n");
00087   for(i = 0; i < uvc_xu_tbl_cnt; i++){
00088     info.index = i + 1 ;
00089     info.selector = xu_control_tbl[i].selector;
00090     info.size = xu_control_tbl[i].size;
00091     info.flags = xu_control_tbl[i].flag;
00092     if ((value = ioctl(vd, UVCIOC_CTRL_ADD, &info)) != -1){
00093       map.id = V4L2_XU_ID_BASE + i;
00094       memcpy(map.name, xu_control_tbl[i].name, 32);
00095       map.selector = xu_control_tbl[i].selector;
00096       if(xu_control_tbl[i].size == 0xFF)
00097         map.size = xu_control_tbl[i].size;
00098       else
00099         map.size = xu_control_tbl[i].size*8;
00100       map.offset = xu_control_tbl[i].offset;
00101       map.v4l2_type = xu_control_tbl[i].v4l2_type;
00102       map.data_type = xu_control_tbl[i].data_type;
00103       if ((value = ioctl(vd, UVCIOC_CTRL_MAP, &map)) < 0){
00104         ret = 1;
00105         printf("XU mapping error:%s\n", xu_control_tbl[i].name);
00106       }
00107     }
00108     else {
00109       if(errno == EEXIST){
00110         printf("XU add already:%s\n", xu_control_tbl[i].name);
00111       }
00112       else{
00113         ret = 1;
00114         printf("XU add error:%s\n", xu_control_tbl[i].name);
00115       }
00116     }
00117   }
00118 
00119   return 0;
00120 }
00121 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


opt_camera
Author(s): Kei Okada
autogenerated on Sat Mar 23 2013 21:00:15