opt_nm33_uvc.cpp
Go to the documentation of this file.
1 /* */
2 /* This code is based on luvcview_wr_100823 from Opt corp. */
3 /* */
4 /* 2010/09/15 k-okada@jsk.t.u-tokyo.ac.jp */
5 
6 //
7 // 2010/8/23 Opt Corporation.
8 //
9 // add xu_control_tbl
10 // add set_xu_control()
11 
12 
13 #include "opt_nm33_uvc.h"
14 
16 
17 #define XU_GET UVC_CONTROL_GET_CUR
18 #define XU_SET UVC_CONTROL_SET_CUR
19 
20 #define V4L2_XU_ID_BASE 0x0A046D01
22 #ifdef NON_STD_UVC
23  {"Firmware Version", XU_FIRMWARE_VERSION_CONTROL, 0xFF, 0, XU_GET,
24  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
25 #else
26  {"Firmware Version", XU_FIRMWARE_VERSION_CONTROL, 0x20, 0, XU_GET,
27  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
28 #endif
29  {"Flash Parameter", XU_FLASH_PARAMETER_CONTROL, 1, 0, XU_SET | XU_GET,
30  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
31  {"Flip Screen", XU_FLIP_SCREEN_CONTROL, 1, 0, XU_SET | XU_GET,
32  V4L2_CTRL_TYPE_MENU, UVC_CTRL_DATA_TYPE_BITMASK},
33  {"small Hemisphere", XU_SMALL_HEMISPHERE_CONTROL, 1, 0, XU_SET | XU_GET,
34  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
35  {"Analog Video", XU_ANALOG_VIDEO_STANDARD_CONTROL, 1, 0, XU_SET | XU_GET,
36  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
37  {"Median Filter", XU_MEDIAN_FILTER_CONTROL, 1, 0, XU_SET | XU_GET,
38  V4L2_CTRL_TYPE_BOOLEAN, UVC_CTRL_DATA_TYPE_BOOLEAN},
39  {"Push Button", XU_PUSH_BUTTON_CONTROL, 2, 0, XU_SET | XU_GET,
40  V4L2_CTRL_TYPE_MENU, UVC_CTRL_DATA_TYPE_BITMASK},
41  {"Pending PTZR", XU_PENDING_PTZR_CONTROL, 1, 0, XU_SET | XU_GET,
42  V4L2_CTRL_TYPE_BOOLEAN, UVC_CTRL_DATA_TYPE_BOOLEAN},
43  {"Auto Pan", XU_AUTO_PAN_SPEED_CONTROL, 1, 0, XU_SET | XU_GET,
44  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_SIGNED},
45  {"JPEG Quality", XU_JPEG_QUALITY_CONTROL, 1, 0, XU_SET | XU_GET,
46  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_SIGNED},
47 #ifdef NON_STD_UVC
48  {"Serial ID", XU_SERIAL_ID_CONTROL, 16, 0, XU_GET,
49  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
50 #else
51  {"Serial ID", XU_SERIAL_ID_CONTROL, 16, 0, XU_SET | XU_GET,
52  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
53 #endif
54  {"Info Display", XU_INFO_DISPLAY_CONTROL, 1, 0, XU_SET | XU_GET,
55  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
56  {"Capture Fps", XU_CAPTURE_FPS_CONTROL, 2, 0, XU_SET | XU_GET,
57  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
58  {"Actual Fps", XU_ACTUAL_FPS_CONTROL, 2, 0, XU_GET,
59  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
60  {"Lens Type", XU_LENS_TYPE_CONTROL, 1, 0, XU_SET | XU_GET,
61  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_UNSIGNED},
62  {"XPan Absolute", XU_PAN_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
63  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
64  {"XTilt Absolute", XU_TILT_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
65  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
66  {"XRoll Absolute", XU_ROLL_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
67  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
68  {"XZoom Absolute", XU_ZOOM_ABSOLUTE_CONTROL, 6, 0, XU_SET | XU_GET,
69  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
70  {"Location Absolute", XU_LOCATION_ABSOLUTE_CONTROL, 10, 0, XU_SET,
71  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
72  {"XGain Absolute", XU_GAIN_ABSOLUTE_CONTROL, 2, 0, XU_SET | XU_GET,
73  V4L2_CTRL_TYPE_INTEGER, UVC_CTRL_DATA_TYPE_RAW},
74 };
75 
77 
78 uvc_menu_info xu_menu_flip_table[] = {
79  {0, "off"},
80  {1, "horizontal"},
81  {2, "vertical"},
82  {3, "both"}
83 };
84 
85 uvc_menu_info xu_menu_button_table[] = {
86  {0, "off"},
87  {1, "east"},
88  {2, "west"},
89  {3, "south"},
90  {4, "north"},
91  {5, "se"},
92  {6, "ne"},
93  {7, "sw"},
94  {8, "nw"},
95  {9, "zoom-in"},
96  {10, "zoom-out"},
97  {11, "menu"},
98  {12, "select"}
99 };
100 
101 int set_XU_control(int vd)
102 {
103  int i = 0;
104  int value = 0;
105  int ret = 0;
106 
107  struct uvc_xu_control_mapping map = {0, "", UVC_GUID_UVC_EXTENSION, 0,
108  0, 0, 0, 0,
109  NULL, 0, {0, 0, 0, 0}};
110 
111  printf("********XU registration************\n");
112  for(i = 0; i < uvc_xu_tbl_cnt; i++){
113  map.id = V4L2_XU_ID_BASE + i;
114  memcpy(map.name, xu_control_tbl[i].name, 32);
115  map.selector = xu_control_tbl[i].selector;
116  if (xu_control_tbl[i].size == 0xFF)
117  map.size = xu_control_tbl[i].size;
118  else
119  map.size = xu_control_tbl[i].size * 8;
120  map.offset = xu_control_tbl[i].offset;
121  map.v4l2_type = xu_control_tbl[i].v4l2_type;
122  map.data_type = xu_control_tbl[i].data_type;
123 
124  switch (xu_control_tbl[i].selector) {
126  map.menu_info = xu_menu_flip_table;
127  map.menu_count = sizeof(xu_menu_flip_table) / sizeof(uvc_menu_info);
128  break;
130  map.menu_info = xu_menu_button_table;
131  map.menu_count = sizeof(xu_menu_button_table) / sizeof(uvc_menu_info);
132  break;
133  default:
134  map.menu_info = NULL;
135  map.menu_count = 0;
136  }
137 
138  if ((value = ioctl(vd, UVCIOC_CTRL_MAP, &map)) < 0){
139  ret = 1;
140  printf("XU mapping error: %s, %s\n", xu_control_tbl[i].name, strerror(errno));
141  } else {
142  printf("XU mapping succeeded: %s\n", xu_control_tbl[i].name);
143  }
144  }
145 
146  return 0;
147 }
148 
#define XU_GET
uvc_menu_info xu_menu_button_table[]
__u8 gui_extension[16]
int uvc_xu_tbl_cnt
int set_XU_control(int vd)
#define V4L2_XU_ID_BASE
uvc_menu_info xu_menu_flip_table[]
#define XU_CAPTURE_FPS_CONTROL
Definition: uvcvideo.h:61
#define XU_ZOOM_ABSOLUTE_CONTROL
Definition: uvcvideo.h:67
#define XU_PAN_ABSOLUTE_CONTROL
Definition: uvcvideo.h:64
enum v4l2_ctrl_type v4l2_type
Definition: opt_nm33_uvc.h:28
#define XU_FIRMWARE_VERSION_CONTROL
Definition: uvcvideo.h:49
#define XU_JPEG_QUALITY_CONTROL
Definition: uvcvideo.h:58
#define XU_SET
#define XU_TILT_ABSOLUTE_CONTROL
Definition: uvcvideo.h:65
#define XU_ANALOG_VIDEO_STANDARD_CONTROL
Definition: uvcvideo.h:53
#define XU_GAIN_ABSOLUTE_CONTROL
Definition: uvcvideo.h:69
#define XU_AUTO_PAN_SPEED_CONTROL
Definition: uvcvideo.h:57
#define XU_SERIAL_ID_CONTROL
Definition: uvcvideo.h:59
#define XU_SMALL_HEMISPHERE_CONTROL
Definition: uvcvideo.h:52
uvc_xu_tbl_info xu_control_tbl[]
#define XU_ROLL_ABSOLUTE_CONTROL
Definition: uvcvideo.h:66
#define XU_LOCATION_ABSOLUTE_CONTROL
Definition: uvcvideo.h:68
#define XU_FLASH_PARAMETER_CONTROL
Definition: uvcvideo.h:50
#define XU_MEDIAN_FILTER_CONTROL
Definition: uvcvideo.h:54
#define XU_LENS_TYPE_CONTROL
Definition: uvcvideo.h:63
#define UVC_GUID_UVC_EXTENSION
Definition: uvcvideo.h:45
#define XU_INFO_DISPLAY_CONTROL
Definition: uvcvideo.h:60
#define XU_ACTUAL_FPS_CONTROL
Definition: uvcvideo.h:62
#define XU_PENDING_PTZR_CONTROL
Definition: uvcvideo.h:56
#define XU_FLIP_SCREEN_CONTROL
Definition: uvcvideo.h:51
#define XU_PUSH_BUTTON_CONTROL
Definition: uvcvideo.h:55


opt_camera
Author(s): Kei Okada
autogenerated on Wed Jul 10 2019 03:47:11