mirror of
https://github.com/openharmony/device_board_osware.git
synced 2026-07-01 00:27:53 -04:00
modify camera/wifi/audio compile problem
Signed-off-by: zhaoxc0502 <zhaoxc0502@thundersoft.com>
This commit is contained in:
@@ -1335,7 +1335,7 @@ static int32_t CodecDriverInit(struct HdfDeviceObject *device)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (CodecSetConfigInfo(&g_g8904_codec_data, &g_g8904_codec_dai_data) != HDF_SUCCESS) {
|
||||
if (CodecSetConfigInfoOfControls(&g_g8904_codec_data, &g_g8904_codec_dai_data) != HDF_SUCCESS) {
|
||||
WM8904_CODEC_LOG_ERR("set config info failed.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
/* SAI Transmit and Receive Configuration 3 Register */
|
||||
#define FSL_SAI_CR3_TRCE_MASK (0xff << 16)
|
||||
#define FSL_SAI_CR3_TRCE(x) ((x) << 16))
|
||||
#define FSL_SAI_CR3_TRCE(x) ((x) << 16)
|
||||
#define FSL_SAI_CR3_WDFL(x) (x)
|
||||
#define FSL_SAI_CR3_WDFL_MASK (0x1f)
|
||||
|
||||
|
||||
@@ -1211,7 +1211,6 @@ int32_t SaiDriverInit(struct PlatformData *pd)
|
||||
char tmp[8];
|
||||
int irq = 0, ret = 0, i = 0;
|
||||
unsigned long clk_rate = 0;
|
||||
int ret = 0;
|
||||
|
||||
sai = &ppd->sai;
|
||||
g_sai = sai;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_IMX8MM_IMAGE_INFO_H
|
||||
#define HOS_CAMERA_IMX8MM_IMAGE_INFO_H
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class Imx8mmImageAdditionalInfo {
|
||||
public:
|
||||
Imx8mmImageAdditionalInfo();
|
||||
|
||||
virtual ~Imx8mmImageAdditionalInfo();
|
||||
|
||||
static Imx8mmImageAdditionalInfo * GetInstance();
|
||||
|
||||
virtual uint32_t GetOffset() const;
|
||||
virtual uint32_t GetLength() const;
|
||||
|
||||
virtual void SetOffset(const uint32_t offset);
|
||||
virtual void SetLength(const uint32_t length);
|
||||
|
||||
virtual void Free();
|
||||
|
||||
private:
|
||||
uint32_t offset_ = 0;
|
||||
uint32_t length_ = 0;
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "v4l2_temp.h"
|
||||
#endif
|
||||
#include "v4l2_common.h"
|
||||
#include "imx8mm_image_buffer.h"
|
||||
|
||||
typedef struct AdapterBuffer {
|
||||
void* start;
|
||||
@@ -71,6 +72,8 @@ private:
|
||||
|
||||
enum v4l2_memory memoryType_;
|
||||
enum v4l2_buf_type bufferType_;
|
||||
|
||||
Imx8mmImageAdditionalInfo *additional_info_;
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
#endif // HOS_CAMERA_V4L2_BUFFER_H
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_V4L2_COMMON_H
|
||||
#define HOS_CAMERA_V4L2_COMMON_H
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
|
||||
#include "v4l2_temp.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS::Camera {
|
||||
#define MAXSTREAMCOUNT 4
|
||||
#define MAXVIDEODEVICE 24
|
||||
#define DEVICENAMEX "/dev/video"
|
||||
#define MAXUVCNODE 10
|
||||
|
||||
struct V4l2Fract {
|
||||
int32_t numerator;
|
||||
int32_t denominator;
|
||||
};
|
||||
|
||||
struct V4l2Rect {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
struct V4l2CropCap {
|
||||
struct V4l2Rect bounds;
|
||||
struct V4l2Rect defrect;
|
||||
struct V4l2Fract pixelaspect;
|
||||
};
|
||||
|
||||
struct V4l2FmtDesc {
|
||||
std::string description;
|
||||
uint32_t pixelformat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t sizeimage;
|
||||
struct V4l2Fract fps;
|
||||
uint32_t capturemode;
|
||||
};
|
||||
|
||||
using DeviceFormat = struct _V4l2DeviceFormat {
|
||||
uint32_t portId;
|
||||
struct V4l2CropCap cropcap;
|
||||
struct V4l2Rect crop;
|
||||
struct V4l2FmtDesc fmtdesc;
|
||||
};
|
||||
|
||||
struct V4l2Menu {
|
||||
uint32_t id;
|
||||
uint32_t index;
|
||||
int64_t value;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
using DeviceControl = struct _V4l2Control {
|
||||
uint32_t id;
|
||||
uint32_t ctrl_class;
|
||||
uint32_t type;
|
||||
uint32_t flags;
|
||||
int32_t minimum;
|
||||
int32_t maximum;
|
||||
int32_t step;
|
||||
int32_t default_value;
|
||||
int32_t value;
|
||||
std::string name;
|
||||
std::vector<V4l2Menu> menu;
|
||||
};
|
||||
|
||||
enum V4l2FmtCmd : uint32_t {
|
||||
CMD_V4L2_GET_FORMAT,
|
||||
CMD_V4L2_SET_FORMAT,
|
||||
CMD_V4L2_GET_CROPCAP,
|
||||
CMD_V4L2_SET_CROP,
|
||||
CMD_V4L2_GET_CROP,
|
||||
CMD_V4L2_SET_FPS,
|
||||
CMD_V4L2_GET_FPS,
|
||||
};
|
||||
|
||||
namespace {
|
||||
static constexpr uint32_t RCERRORFD = -1;
|
||||
}
|
||||
|
||||
using BufCallback = std::function<void(std::shared_ptr<FrameSpec>)>;
|
||||
using UvcCallback = std::function<void(const std::string, std::vector<DeviceControl>&,
|
||||
std::vector<DeviceFormat>&, bool)>;
|
||||
}
|
||||
#endif // HOS_CAMERA_V4L2_COMMON_H
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_V4L2_CONTROL_H
|
||||
#define HOS_CAMERA_V4L2_CONTROL_H
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "v4l2_common.h"
|
||||
#if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
|
||||
#include "v4l2_temp.h"
|
||||
#else
|
||||
#include <camera.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class HosV4L2Control {
|
||||
public:
|
||||
HosV4L2Control();
|
||||
~HosV4L2Control();
|
||||
|
||||
RetCode V4L2GetCtrl(int fd, unsigned int id, int& value);
|
||||
RetCode V4L2SetCtrl(int fd, unsigned int id, int value);
|
||||
RetCode V4L2GetControls(int fd, std::vector<DeviceControl>& control);
|
||||
RetCode V4L2SetCtrls(int fd, std::vector<DeviceControl>& control, const int numControls);
|
||||
RetCode V4L2GetCtrls(int fd, std::vector<DeviceControl>& control, const int numControls);
|
||||
|
||||
private:
|
||||
void V4L2SetValue(int fd, std::vector<DeviceControl>& control, DeviceControl& ctrl,
|
||||
v4l2_queryctrl& qCtrl);
|
||||
int ExtControl(int fd, struct v4l2_queryctrl *ctrl);
|
||||
void V4L2EnumExtControls(int fd, std::vector<DeviceControl>& control);
|
||||
void V4L2EnumControls(int fd, std::vector<DeviceControl>& control);
|
||||
int V4L2GetControl(int fd, std::vector<DeviceControl>& control, unsigned int id);
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
|
||||
#endif // HOS_CAMERA_V4L2_CONTROL_H
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "v4l2_stream.h"
|
||||
#include "v4l2_control.h"
|
||||
#include "v4l2_common.h"
|
||||
#include <v4l2_uvc.h>
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class HosV4L2Dev {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_V4L2_FILEFORMAT_H
|
||||
#define HOS_CAMERA_V4L2_FILEFORMAT_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "v4l2_common.h"
|
||||
#if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
|
||||
#include "v4l2_temp.h"
|
||||
#else
|
||||
#include <camera.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class HosFileFormat {
|
||||
public:
|
||||
HosFileFormat();
|
||||
~HosFileFormat();
|
||||
RetCode V4L2GetFmt(int fd, DeviceFormat& format);
|
||||
RetCode V4L2SetFmt(int fd, DeviceFormat& format);
|
||||
RetCode V4L2GetCrop(int fd, DeviceFormat& format);
|
||||
RetCode V4L2SetCrop(int fd, DeviceFormat& format);
|
||||
RetCode V4L2GetCropCap(int fd, DeviceFormat& format);
|
||||
RetCode V4L2GetFmtDescs(int fd, std::vector<DeviceFormat>& fmtDesc);
|
||||
int V4L2OpenDevice(const std::string& deviceName);
|
||||
void V4L2CloseDevice(int fd);
|
||||
void V4L2MatchDevice(std::vector<std::string>& cameraIDs);
|
||||
int V4L2SearchBufType(int fd);
|
||||
|
||||
private:
|
||||
RetCode V4L2GetCapability(int fd, const std::string& dev_name, std::string& cameraId);
|
||||
RetCode V4L2SearchFormat(int fd, std::vector<DeviceFormat>& fmtDesc);
|
||||
enum v4l2_buf_type bufType_ = V4L2_BUF_TYPE_PRIVATE;
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
#endif // HOS_CAMERA_V4L2_FILEFORMAT_H
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_V4L2_STREAM_H
|
||||
#define HOS_CAMERA_V4L2_STREAM_H
|
||||
|
||||
#include "v4l2_common.h"
|
||||
#if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
|
||||
#include "v4l2_temp.h"
|
||||
#else
|
||||
#include <camera.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class HosV4L2Streams {
|
||||
public:
|
||||
HosV4L2Streams(enum v4l2_buf_type bufferType);
|
||||
~HosV4L2Streams();
|
||||
|
||||
RetCode V4L2StreamOn(int fd);
|
||||
RetCode V4L2StreamOff(int fd);
|
||||
RetCode V4L2StreamFPSGet(int fd, DeviceFormat& format);
|
||||
RetCode V4L2StreamFPSSet(int fd, DeviceFormat& format);
|
||||
|
||||
private:
|
||||
enum v4l2_buf_type bufferType_ = V4L2_BUF_TYPE_PRIVATE;
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
#endif // HOS_CAMERA_V4L2_STREAM_H
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HOS_CAMERA_TEMP_H
|
||||
#define HOS_CAMERA_TEMP_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class IBuffer {
|
||||
public:
|
||||
IBuffer() {}
|
||||
~IBuffer(){}
|
||||
|
||||
int32_t GetIndex()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
uint32_t GetSize()
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
uint32_t GetOffset()
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
uint32_t GetLength()
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
void* GetVirAddress()
|
||||
{
|
||||
return virAddr_;
|
||||
}
|
||||
|
||||
uint64_t GetUsage()
|
||||
{
|
||||
return usage_;
|
||||
}
|
||||
|
||||
void SetIndex(const uint32_t index)
|
||||
{
|
||||
index_ = index;
|
||||
return;
|
||||
}
|
||||
|
||||
void SetSize(const uint32_t size)
|
||||
{
|
||||
size_ = size;
|
||||
return;
|
||||
}
|
||||
void SetOffset(const uint32_t offset)
|
||||
{
|
||||
offset_ = offset;
|
||||
return;
|
||||
}
|
||||
|
||||
void SetLength(const uint32_t length)
|
||||
{
|
||||
length_ = length;
|
||||
return;
|
||||
}
|
||||
void SetVirAddress(void* addr)
|
||||
{
|
||||
virAddr_ = addr;
|
||||
return;
|
||||
}
|
||||
|
||||
void SetUsage(const uint64_t usage)
|
||||
{
|
||||
usage_ = usage;
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t index_ = -1;
|
||||
uint32_t size_ = 0;
|
||||
void* virAddr_ = nullptr;
|
||||
uint64_t usage_ = 0;
|
||||
uint32_t offset_ = 0;
|
||||
uint32_t length_ = 0;
|
||||
};
|
||||
|
||||
struct FrameSpec {
|
||||
int64_t bufferPoolId_;
|
||||
std::shared_ptr<IBuffer> buffer_;
|
||||
};
|
||||
|
||||
using FrameSpec = struct FrameSpec;
|
||||
|
||||
enum AdapterCmd : uint32_t {
|
||||
CMD_AE_EXPO,
|
||||
CMD_AWB_MODE,
|
||||
CMD_AE_EXPOTIME,
|
||||
CMD_AWB_COLORGAINS
|
||||
};
|
||||
|
||||
#ifdef DISABLE_LOGD
|
||||
#define CAMERA_LOGD(...)
|
||||
#else
|
||||
#define CAMERA_LOGD(fmt, ...) \
|
||||
do { \
|
||||
printf("INFO:" fmt "\n", ##__VA_ARGS__); \
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
#define CAMERA_LOGE(fmt, ...) \
|
||||
do { \
|
||||
printf("ERROR:" fmt "\n", ##__VA_ARGS__); \
|
||||
} while (0);
|
||||
|
||||
enum RetCode {
|
||||
RC_OK = 0,
|
||||
RC_ERROR,
|
||||
};
|
||||
|
||||
#define CHECK_IF_NOT_EQUAL_RETURN_VALUE(arg1, arg2, ret) \
|
||||
if ((arg1) != (arg2)) { \
|
||||
CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, \
|
||||
#ret); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define CHECK_IF_EQUAL_RETURN_VALUE(arg1, arg2, ret) \
|
||||
if ((arg1) == (arg2)) { \
|
||||
CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, #ret); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define CHECK_IF_PTR_NULL_RETURN_VALUE(ptr, ret) CHECK_IF_EQUAL_RETURN_VALUE(ptr, nullptr, ret)
|
||||
|
||||
#define CHECK_IF_NOT_EQUAL_RETURN_VOID(arg1, arg2) \
|
||||
if ((arg1) != (arg2)) { \
|
||||
CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return", __LINE__, #arg1, #arg2); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define CHECK_IF_EQUAL_RETURN_VOID(arg1, arg2) \
|
||||
if ((arg1) == (arg2)) { \
|
||||
CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return", __LINE__, #arg1, #arg2); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define CHECK_IF_PTR_NULL_RETURN_VOID(ptr) CHECK_IF_EQUAL_RETURN_VOID(ptr, nullptr)
|
||||
} // namespace OHOS::Camera
|
||||
#endif // HOS_CAMERA_TEMP_H
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef HOS_CAMERA_V4L2_UVC_H
|
||||
#define HOS_CAMERA_V4L2_UVC_H
|
||||
|
||||
#include <thread>
|
||||
#include <fcntl.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include "v4l2_common.h"
|
||||
#if defined(V4L2_UTEST) || defined (V4L2_MAIN_TEST)
|
||||
#include "v4l2_temp.h"
|
||||
#else
|
||||
#include <camera.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS::Camera {
|
||||
class HosV4L2UVC {
|
||||
public:
|
||||
HosV4L2UVC();
|
||||
~HosV4L2UVC();
|
||||
|
||||
RetCode V4L2UvcDetectInit(UvcCallback cb);
|
||||
void V4L2UvcDetectUnInit();
|
||||
|
||||
private:
|
||||
void V4L2UvcSearchCapability(const std::string devName, const std::string v4l2Device, bool inOut);
|
||||
RetCode V4L2UvcGetCap(const std::string v4l2Device, struct v4l2_capability& cap);
|
||||
void V4L2UvcMatchDev(const std::string name, const std::string v4l2Device, bool inOut);
|
||||
void V4L2UvcEnmeDevices();
|
||||
void loopUvcDevice();
|
||||
int CheckBuf(unsigned int len, char *buf);
|
||||
void UpdateV4L2UvcMatchDev(std::string& action, std::string& subsystem, std::string& devnode);
|
||||
const char* V4L2GetUsbValue(const char* key, const char* str, int len);
|
||||
void V4L2GetUsbString(std::string& action, std::string& subsystem,
|
||||
std::string& devnode, char* buf, unsigned int len);
|
||||
RetCode V4L2UVCGetCapability(int fd, const std::string devName, std::string& cameraId);
|
||||
|
||||
int uDevFd_ = -1;
|
||||
int eventFd_ = -1;
|
||||
int uvcDetectEnable_ = 0;
|
||||
|
||||
UvcCallback uvcCallbackFun_ = nullptr;
|
||||
|
||||
std::vector<DeviceControl> control_;
|
||||
std::vector<DeviceFormat> format_;
|
||||
|
||||
std::thread* uvcDetectThread_ = nullptr;
|
||||
};
|
||||
} // namespace OHOS::Camera
|
||||
|
||||
#endif // HOS_CAMERA_V4L2_UVC_H
|
||||
@@ -63,6 +63,7 @@ ohos_shared_library("camera_v4l2_adapter") {
|
||||
"src/v4l2_dev.cpp",
|
||||
"src/v4l2_fileformat.cpp",
|
||||
"src/v4l2_stream.cpp",
|
||||
"src/imx8mm_image_buffer.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
|
||||
@@ -56,13 +56,13 @@ ohos_executable("v4l2_main") {
|
||||
"$camera_path/adapter/platform/v4l2/src/driver_adapter/src/v4l2_control.cpp",
|
||||
"$camera_path/adapter/platform/v4l2/src/driver_adapter/src/v4l2_uvc.cpp",
|
||||
"./v4l2_main.cpp",
|
||||
"$board_camera_path/src/driver_adapter/src/imx8mm_image_buffer.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"$board_camera_path/src/driver_adapter/main_test",
|
||||
"$camera_path/include",
|
||||
"$board_camera_path/include/driver_adapter",
|
||||
"//drivers/peripheral/camera/hal/adapter/platform/v4l2/src/driver_adapter/include",
|
||||
]
|
||||
|
||||
deps = [ "$hdf_uhdf_path/utils:libhdf_utils" ]
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "imx8mm_image_buffer.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
Imx8mmImageAdditionalInfo::Imx8mmImageAdditionalInfo()
|
||||
{
|
||||
offset_ = 0;
|
||||
length_ = 0;
|
||||
}
|
||||
|
||||
Imx8mmImageAdditionalInfo::~Imx8mmImageAdditionalInfo()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
Imx8mmImageAdditionalInfo * Imx8mmImageAdditionalInfo::GetInstance()
|
||||
{
|
||||
static Imx8mmImageAdditionalInfo addiInfo;
|
||||
return &addiInfo;
|
||||
}
|
||||
|
||||
uint32_t Imx8mmImageAdditionalInfo::GetOffset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
uint32_t Imx8mmImageAdditionalInfo::GetLength() const
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
void Imx8mmImageAdditionalInfo::SetOffset(const uint32_t offset)
|
||||
{
|
||||
offset_ = offset;
|
||||
return;
|
||||
}
|
||||
|
||||
void Imx8mmImageAdditionalInfo::SetLength(const uint32_t length)
|
||||
{
|
||||
length_ = length;
|
||||
return;
|
||||
}
|
||||
|
||||
void Imx8mmImageAdditionalInfo::Free()
|
||||
{
|
||||
offset_ = 0;
|
||||
length_ = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Camera
|
||||
|
||||
@@ -24,9 +24,13 @@ namespace OHOS::Camera {
|
||||
HosV4L2Buffers::HosV4L2Buffers(enum v4l2_memory memType, enum v4l2_buf_type bufferType)
|
||||
: memoryType_(memType), bufferType_(bufferType)
|
||||
{
|
||||
additional_info_ = Imx8mmImageAdditionalInfo::GetInstance();
|
||||
}
|
||||
|
||||
HosV4L2Buffers::~HosV4L2Buffers() {}
|
||||
HosV4L2Buffers::~HosV4L2Buffers()
|
||||
{
|
||||
delete(additional_info_);
|
||||
}
|
||||
|
||||
RetCode HosV4L2Buffers::V4L2ReqBuffers(int fd, int unsigned buffCont)
|
||||
{
|
||||
@@ -73,7 +77,7 @@ RetCode HosV4L2Buffers::V4L2QueueBuffer(int fd, const std::shared_ptr<FrameSpec>
|
||||
|
||||
uint32_t index = (uint32_t)frameSpec->buffer_->GetIndex();
|
||||
adapterBufferList[index].userBufPtr = frameSpec->buffer_->GetVirAddress();
|
||||
adapterBufferList[index].length = frameSpec->buffer_->GetLength();
|
||||
adapterBufferList[index].length = additional_info_->GetLength();
|
||||
|
||||
buf.index = (uint32_t)frameSpec->buffer_->GetIndex();
|
||||
buf.type = bufferType_;
|
||||
@@ -92,8 +96,8 @@ RetCode HosV4L2Buffers::V4L2QueueBuffer(int fd, const std::shared_ptr<FrameSpec>
|
||||
switch (memoryType_) {
|
||||
case V4L2_MEMORY_MMAP:
|
||||
{
|
||||
adapterBufferList[index].start = mmap(NULL, frameSpec->buffer_->GetLength(),
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, frameSpec->buffer_->GetOffset());
|
||||
adapterBufferList[index].start = mmap(NULL, additional_info_->GetLength(),
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, additional_info_->GetOffset());
|
||||
if (MAP_FAILED == adapterBufferList[index].start) {
|
||||
CAMERA_LOGE("v4l2 mmap failed\n");
|
||||
return RC_ERROR;
|
||||
@@ -241,8 +245,8 @@ RetCode HosV4L2Buffers::V4L2AllocBuffer(int fd, const std::shared_ptr<FrameSpec>
|
||||
CAMERA_LOGE("ERROR:user buff < V4L2 buf.length\n");
|
||||
return RC_ERROR;
|
||||
}
|
||||
frameSpec->buffer_->SetLength(buf.length);
|
||||
frameSpec->buffer_->SetOffset(buf.m.offset);
|
||||
additional_info_->SetLength(buf.length);
|
||||
additional_info_->SetOffset(buf.m.offset);
|
||||
|
||||
break;
|
||||
case V4L2_MEMORY_OVERLAY:
|
||||
|
||||
@@ -113,7 +113,7 @@ ohos_shared_library("camera_pipeline_core") {
|
||||
"../device_manager/include",
|
||||
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node",
|
||||
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node",
|
||||
"//drivers/peripheral/camera/hal/adapter/platform/v4l2/src/driver_adapter/include/",
|
||||
"$board_camera_path/include/driver_adapter",
|
||||
"//foundation/communication/ipc/ipc/native/src/core/include",
|
||||
"//utils/native/base/include",
|
||||
"//drivers/peripheral/camera/interfaces/metadata/include",
|
||||
|
||||
@@ -557,7 +557,7 @@ int32_t WalRemoveIf(struct NetDevice *netDev, WifiIfRemove *ifRemove)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
removeNetdev = NetDeviceGetInstByName((const char*)(ifRemove->ifname));
|
||||
removeNetdev = NetDeviceGetInstByName((const char*)(ifRemove->ifName));
|
||||
if (removeNetdev == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ $(KERNEL_IMAGE_FILE):
|
||||
$(hide) echo "build kernel..."
|
||||
$(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfL $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/
|
||||
$(hide) $(OHOS_BUILD_HOME)/device/board/osware/imx8mm/kernel/patch_imx.sh $(KERNEL_PATCH_PATH) $(KERNEL_SRC_TMP_PATH)
|
||||
$(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE)
|
||||
$(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) ${DEVICE_NAME}
|
||||
$(hide) cp -rf $(KERNEL_CONFIG_PATH)/. $(KERNEL_SRC_TMP_PATH)/
|
||||
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) distclean
|
||||
$(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(DEFCONFIG_FILE)
|
||||
|
||||
Reference in New Issue
Block a user