高通android驱动和设备树-wifi驱动粗略记录

一、高通设备树

对驱动之类的略有了解,今天看wifi功耗问题的时候想看一下设备树的定义,一开始怎么也没找到设备树是哪个,后来经询问,得知在vendor目录下

vendor/qcom/proprietary/devicetree

这个是高通通用的设备树定义和驱动放置的位置

很想知道它是怎么被linux kernel一起编译的,最后发现其实就是个软连接

在kernel/msm-5.4/arch/arm64/boot/dts

lrwxrwxrwx 1 root root 52 10月 30 18:01 ./vendor -> ../../../../../../vendor/qcom/proprietary/devicetree

二、wifi- CNSS休眠唤醒日志:

这个是CNSS开机,到休眠,到唤醒的日志

https://download.csdn.net/download/yudelian/88602574

 如上面日志

01-01 08:04:05.915     0     0 D cnss    : De-assert WLAN_EN GPIO successfully

01-01 08:04:05.915     0     0 D cnss    : Regulator vdd-wlan-vh is being disabled
01-01 08:04:05.916     0     0 D cnss    : Regulator vdd-wlan-s5c is being disabled
01-01 08:04:05.916     0     0 D cnss    : Regulator vdd-wlan-vm is being disabled
01-01 08:04:05.916     0     0 D cnss    : Regulator vdd-wlan-vl is being disabled
01-01 08:04:05.916     0     0 D cnss    : Regulator vdd-wlan-ctrl2 is being disabled
01-01 08:04:05.916     0     0 D cnss    : Regulator vdd-wlan-ctrl1 is being disabled

休眠的时候 WLAN_EN,这个是一个引脚,会下电的,这样可以降低功耗

三、qcom wifi驱动源码文件地址:

vendor/qcom/opensource/wlan/qcacld-3.0/core/hdd/src/wlan_hdd_main.c

举功耗功能为例:

hdd_context_create       

        hdd_ctx->pm_notifier.notifier_call = hdd_pm_notify;

        register_pm_notifier(&hdd_ctx->pm_notifier);

上面在创建context的时候,在linux内核里注册一个pm事件回调hdd_pm_notify,

hdd_shutdown_wlan_in_suspend_prepare根据ucfg_pmo_get_suspend_mode配置看是否支持shutdown功能,一开始这儿不支持,当系统休眠的时候,就会走到驱动的suspend和resume函数,导致wifi模块无法下电,后来在这里不管配置,直接走下去了,最后调用到pld_idle_shutdown,我们的wifi硬件接口是pcie的,所以最后调用到了

cnss_idle_shutdown,这个是cnss的驱动接口。

static int hdd_pm_notify(struct notifier_block *b,unsigned long event, void *p){
	switch (event) {
	case PM_SUSPEND_PREPARE:
	case PM_HIBERNATION_PREPARE:
		if (0 != hdd_shutdown_wlan_in_suspend_prepare())
			return NOTIFY_STOP;
		break;
	case PM_POST_SUSPEND:
	case PM_POST_HIBERNATION:
		break;
	}

	return NOTIFY_DONE;
}

static QDF_STATUS hdd_shutdown_wlan_in_suspend_prepare(void)
{
#define SHUTDOWN_IN_SUSPEND_RETRY 10

	int count = 0;
	struct hdd_context *hdd_ctx;

	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
	if (wlan_hdd_validate_context(hdd_ctx) != 0)
		return -EINVAL;

	//if (ucfg_pmo_get_suspend_mode(hdd_ctx->psoc) != PMO_SUSPEND_SHUTDOWN) {
	//    hdd_info("shutdown in suspend not supported");
	//    return 0;
	//}

	hdd_debug("call pld idle shutdown directly");
	return pld_idle_shutdown(hdd_ctx->parent_dev, hdd_psoc_idle_shutdown);
}

四、wifi CNSS驱动

kernel/msm-5.4/drivers/net/wireless/cnss2

驱动在linux内核里,应该是通用的

这里面有MHI的使用,

MHI (Modem Host Interface) — The Linux Kernel documentation

https://download.csdn.net/download/yudelian/88602688

MHI (Modem Host Interface),就是一个Modem主机接口协议,用于主控制器和modem设备进行高速通信,主要应用于PCIE总线设备上,提供逻辑信道。

MHI (Modem Host Interface)
This document provides information about the MHI protocol.

Overview
MHI is a protocol developed by Qualcomm Innovation Center, Inc. It is used by the host processors to control and communicate with modem devices over high speed peripheral buses or shared memory. Even though MHI can be easily adapted to any peripheral buses, it is primarily used with PCIe based devices. MHI provides logical channels over the physical buses and allows transporting the modem protocols, such as IP data packets, modem control messages, and diagnostics over at least one of those logical channels. Also, the MHI protocol provides data acknowledgment feature and manages the power state of the modems via one or more logical channels.
 

在 `vendor/qcom/proprietary/chi-cdk/` 目录下,如果你已经获取到源码并编译完成,可以使用以下步骤获取yuv420图像: 1. 找到要获取yuv420图像的摄像头的camera ID。你可以在 `vendor/qcom/proprietary/chi-cdk/Android.mk` 文件中找到这些摄像头的 ID。 2. 配置 `CameraDevice`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxdeviceapi/camxhwcontext.cpp` 文件中,你可以找到 `SetCameraDevice()` 函数,可以在该函数中配置 `CameraDevice`。例如,以下代码可以配置一个摄像头为前置摄像头(ID为0): ``` CAMX_LOG_INFO(CamxLogGroupHAL, "Open camera device for ID %d", cameraId); m_hCameraDevice = CameraDevice::Create(cameraId, "qcom.camera.front", this); ``` 3. 打开 `CameraDevice`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxdeviceapi/camxhwcontext.cpp` 文件中,你可以找到 `Initialize()` 函数,在该函数中可以打开 `CameraDevice`。例如: ``` m_hCameraDevice->Open(); ``` 4. 创建 `CameraBufferManager`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `Initialize()` 函数,在该函数中创建 `CameraBufferManager`。例如: ``` m_pBufferManager = BufferManager::Create("qcom.camera.front", m_hCameraDevice); ``` 5. 获取 `CameraBufferManager`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetBufferManager()` 函数,可以通过该函数获取到 `CameraBufferManager` 的指针。例如: ``` CameraBufferManager* pBufferManager = GetBufferManager("qcom.camera.front"); ``` 6. 获取 `Stream`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetStream()` 函数,可以通过该函数获取到 `Stream` 的指针。例如: ``` Stream* pStream = GetStream("qcom.camera.front", streamId); ``` 7. 获取 `Buffer`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetBuffer()` 函数,可以通过该函数获取到 `Buffer` 的指针。例如: ``` Buffer* pBuffer = pBufferManager->GetBuffer(pStream->GetFormat(), pStream->GetBufferProperties()); ``` 8. 获取 `ImageFormat`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetImageFormat()` 函数,可以通过该函数获取到 `ImageFormat` 的指针。例如: ``` const ImageFormat* pImageFormat = ImageFormatUtils::GetImageFormatFromPixelFormat(pStream->GetFormat()); ``` 9. 获取 `ImageBuffer`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetImageBuffer()` 函数,可以通过该函数获取到 `ImageBuffer` 的指针。例如: ``` ImageBuffer* pImageBuffer = ImageBufferUtils::GetImageBuffer(pBuffer->GetBuffer(), pImageFormat, pBuffer->GetPlaneStride(), pBuffer->GetPlaneOffset()); ``` 10. 获取 `Plane`。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetPlane()` 函数,可以通过该函数获取到 `Plane` 的指针。例如: ``` Plane* pPlane = pImageBuffer->GetPlane(pImageFormat->componentOrder[0]); ``` 11. 获取 `Plane` 的数据。在 `vendor/qcom/proprietary/chi-cdk/frameworks/camx/src/core/camxhwcontext.cpp` 文件中,你可以找到 `GetBuffer()` 函数,可以通过该函数获取到 `Plane` 的数据。例如: ``` UINT8* pPlaneData = static_cast<UINT8*>(pPlane->GetBuffer()); ``` 通过以上步骤,你就可以获取到 yuv420 图像数据了。注意,以上代码只是提供了获取 yuv420 图像数据的一个示例,实际上在使用时还需要根据具体的需求进行适当的修改和调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值