• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HOS_CAMERA_V4L2_CONTROL_H
17 #define HOS_CAMERA_V4L2_CONTROL_H
18 
19 #include <errno.h>
20 #include <sys/ioctl.h>
21 #include <linux/videodev2.h>
22 #include "v4l2_common.h"
23 #if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
24 #include "v4l2_temp.h"
25 #else
26 #include <camera.h>
27 #endif
28 
29 namespace OHOS::Camera {
30 class HosV4L2Control {
31 public:
32     HosV4L2Control();
33     ~HosV4L2Control();
34 
35     RetCode V4L2GetCtrl(int fd, unsigned int id, int& value);
36     RetCode V4L2SetCtrl(int fd, unsigned int id, int value);
37     RetCode V4L2GetControls(int fd, std::vector<DeviceControl>& control);
38     RetCode V4L2SetCtrls(int fd, std::vector<DeviceControl>& control, const int numControls);
39     RetCode V4L2GetCtrls(int fd, std::vector<DeviceControl>& control, const int numControls);
40 
41 private:
42     void V4L2SetValue(int fd, std::vector<DeviceControl>& control, DeviceControl& ctrl,
43         v4l2_queryctrl& qCtrl);
44     int ExtControl(int fd, struct v4l2_queryctrl *ctrl);
45     void V4L2EnumExtControls(int fd, std::vector<DeviceControl>& control);
46     void V4L2EnumControls(int fd, std::vector<DeviceControl>& control);
47     int V4L2GetControl(int fd, std::vector<DeviceControl>& control, unsigned int id);
48 };
49 } // namespace OHOS::Camera
50 
51 #endif // HOS_CAMERA_V4L2_CONTROL_H
52