在Android5.0上Audio Patch和Patch Panel的一些分析

好久没写博客了,最近整理了下画的流程图和描述图,这次是关于Android5.0里新加的Patch Panel,使用了Audio Patch机制来实现的,正所谓有图有真相,具体请看图。


Patch Panel的路径:frameworks/av/services/audioflinger/PatchPanel.cpp


  • Patch Panel有关的结构:



一个Audio Patch用来表示一个或多个source端到一个或多个sink端。这个是从代码的注释翻译来的,大家可以把它比作大坝,可以有好几个入水口和出水口,每次储水和防水的入水口和出水口的数量可以不一样多,比如一个入水口和两个出水口。实际场景就是一个音频文件播放到喇叭和耳机里,或者两个麦克风录左右声道到一个音频文件里。


应用也可以直接用这个特性的,但是前提是先要有这个permission: android.permission.MODIFY_AUDIO_ROUTING


就像刚刚说的那样一个Audio Patch有多个source端和多个sink端,所以audio_patch的结构体里就有了两个array,这里每个端口都是一个audio_port。

这个port里都包含了基本需要的一些基本参数,包括stream和device的。大家看名字脑补下吧。

一些新的函数列一下:



每个audio_patch都会通过APS指定的参数在Audioflinger生成,然后通过Audioflinger调用被AudioHAL处理。

这个目录是是/home/wsf/ky-015的#include "ky015_driver.h" #include "hdf_base.h" #include "hdf_log.h" #include "osal_irq.h" #include "osal_time.h" #include "gpio_if.h" #include "device_resource_if.h" #include "hdf_sbuf.h" #include "hdf_io_service_if.h" #define HDF_LOG_TAG "KY015_DRIVER" // 单总线协议时序定义 #define KY015_START_LOW_US 18000 // 开始信号低电平18ms #define KY015_START_HIGH_US 40 // 开始信号高电平20-40us #define KY015_BIT_TIMEOUT_US 100 // 位读取超时时间 #define KY015_RESPONSE_TIMEOUT_US 1000 // 响应超时时间 // GPIO操作宏 #define KY015_SET_OUTPUT(dev) GpioSetDir((dev)->gpioNum, GPIO_DIR_OUT) #define KY015_SET_INPUT(dev) GpioSetDir((dev)->gpioNum, GPIO_DIR_IN) #define KY015_WRITE_HIGH(dev) GpioWrite((dev)->gpioNum, GPIO_VAL_HIGH) #define KY015_WRITE_LOW(dev) GpioWrite((dev)->gpioNum, GPIO_VAL_LOW) #define KY015_READ(dev, val) GpioRead((dev)->gpioNum, val) // Dispatch函数实现 int32_t Ky015DriverDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { struct Ky015Device *dev = NULL; int32_t ret = HDF_SUCCESS; int32_t temp, humidity; HDF_LOGI("%s: Received cmd: 0x%04x", __func__, cmd); // 获取设备实例 if (client == NULL || client->device == NULL || client->device->priv == NULL) { HDF_LOGE("%s: Invalid client or device", __func__); return HDF_ERR_INVALID_PARAM; } dev = (struct Ky015Device *)client->device->priv; switch (cmd) { case KY015_CMD_GET_TEMPERATURE: ret = Ky015ServiceGetTemperature(dev, &temp); if (ret == HDF_SUCCESS) { if (!HdfSbufWriteInt32(reply, temp)) { HDF_LOGE("%s: Write temperature to reply failed", __func__); ret = HDF_ERR_IO; } } break; case KY015_CMD_GET_HUMIDITY: ret = Ky015ServiceGetHumidity(dev, &humidity); if (ret == HDF_SUCCESS) { if (!HdfSbufWriteInt32(reply, humidity)) { HDF_LOGE("%s: Write humidity to reply failed", __func__); ret = HDF_ERR_IO; } } break; case KY015_CMD_GET_SENSOR_DATA: ret = Ky015ServiceGetTemperature(dev, &temp); if (ret == HDF_SUCCESS) { ret = Ky015ServiceGetHumidity(dev, &humidity); } if (ret == HDF_SUCCESS) { if (!HdfSbufWriteInt32(reply, temp) || !HdfSbufWriteInt32(reply, humidity)) { HDF_LOGE("%s: Write sensor data to reply failed", __func__); ret = HDF_ERR_IO; } } break; case KY015_CMD_START_POLLING: Ky015StartPolling(dev); HDF_LOGI("%s: Start polling", __func__); break; case KY015_CMD_STOP_POLLING: Ky015StopPolling(dev); HDF_LOGI("%s: Stop polling", __func__); break; default: HDF_LOGE("%s: Unknown command: 0x%04x", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; break; } return ret; } // 等待GPIO电平变化 static int32_t Ky015WaitForLevel(struct Ky015Device *dev, uint16_t level, uint32_t timeoutUs) { uint32_t count = 0; uint16_t currentLevel; while (count < timeoutUs) { if (KY015_READ(dev, &currentLevel) != HDF_SUCCESS) { return HDF_FAILURE; } if (currentLevel == level) { return HDF_SUCCESS; } OsalUDelay(1); count++; } HDF_LOGE("%s: Wait for level %d timeout", __func__, level); return HDF_FAILURE; } // 发送开始信号 static int32_t Ky015SendStartSignal(struct Ky015Device *dev) { int32_t ret; // 设置为输出模式 ret = KY015_SET_OUTPUT(dev); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Set output failed", __func__); return ret; } // 拉低18ms ret = KY015_WRITE_LOW(dev); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Write low failed", __func__); return ret; } OsalMDelay(18); // 拉高20-40us ret = KY015_WRITE_HIGH(dev); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Write high failed", __func__); return ret; } OsalUDelay(40); return HDF_SUCCESS; } // 读取一位数据 static int32_t Ky015ReadBit(struct Ky015Device *dev, uint8_t *bit) { int32_t ret; uint16_t level; // 等待低电平开始(传感器拉低50us) ret = Ky015WaitForLevel(dev, GPIO_VAL_LOW, KY015_BIT_TIMEOUT_US); if (ret != HDF_SUCCESS) { return ret; } // 等待50us后读取电平 OsalUDelay(50); ret = KY015_READ(dev, &level); if (ret != HDF_SUCCESS) { return ret; } *bit = (level == GPIO_VAL_HIGH) ? 1 : 0; // 等待位结束 OsalUDelay(30); return HDF_SUCCESS; } // 读取完整数据 int32_t Ky015ReadData(struct Ky015Device *dev) { int32_t ret; uint8_t bit; uint16_t i; if (dev == NULL) { return HDF_ERR_INVALID_PARAM; } OsalMutexLock(&dev->dataLock); // 重置数据缓冲区 memset(dev->dataBuffer, 0, sizeof(dev->dataBuffer)); dev->bitCount = 0; dev->byteCount = 0; dev->dataValid = false; // 发送开始信号 ret = Ky015SendStartSignal(dev); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Send start signal failed", __func__); goto exit; } // 设置为输入模式 ret = KY015_SET_INPUT(dev); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Set input failed", __func__); goto exit; } // 等待传感器响应(80us低电平) ret = Ky015WaitForLevel(dev, GPIO_VAL_LOW, KY015_RESPONSE_TIMEOUT_US); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Wait for sensor response low failed", __func__); goto exit; } // 等待传感器响应(80us高电平) ret = Ky015WaitForLevel(dev, GPIO_VAL_HIGH, KY015_RESPONSE_TIMEOUT_US); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Wait for sensor response high failed", __func__); goto exit; } // 读取40位数据 for (i = 0; i < KY015_DATA_BITS; i++) { ret = Ky015ReadBit(dev, &bit); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read bit %d failed", __func__, i); goto exit; } dev->dataBuffer[dev->byteCount] = (dev->dataBuffer[dev->byteCount] << 1) | bit; dev->bitCount++; if ((dev->bitCount % 8) == 0) { dev->byteCount++; } } dev->dataValid = true; HDF_LOGD("%s: Read data success", __func__); exit: OsalMutexUnlock(&dev->dataLock); return ret; } // 解析温湿度数据 int32_t Ky015ParseData(struct Ky015Device *dev) { uint8_t checksum; if (dev == NULL || !dev->dataValid) { return HDF_ERR_INVALID_PARAM; } OsalMutexLock(&dev->dataLock); // 计算校验 checksum = dev->dataBuffer[0] + dev->dataBuffer[1] + dev->dataBuffer[2] + dev->dataBuffer[3]; if (checksum != dev->dataBuffer[4]) { HDF_LOGE("%s: Checksum error: %d != %d", __func__, checksum, dev->dataBuffer[4]); OsalMutexUnlock(&dev->dataLock); return HDF_ERR_IO; } // 解析湿度(整数部分) dev->humidity = dev->dataBuffer[0]; // 解析温度(整数部分) dev->temperature = dev->dataBuffer[2]; HDF_LOGI("%s: Temperature: %d°C, Humidity: %d%%", __func__, dev->temperature, dev->humidity); OsalMutexUnlock(&dev->dataLock); return HDF_SUCCESS; } // 轮询线程函数 static int32_t Ky015PollThread(void *arg) { struct Ky015Device *dev = (struct Ky015Device *)arg; int32_t ret; if (dev == NULL) { return HDF_FAILURE; } HDF_LOGI("%s: Poll thread started", __func__); while (dev->threadRunning) { ret = Ky015ReadData(dev); if (ret == HDF_SUCCESS) { Ky015ParseData(dev); } else { HDF_LOGW("%s: Read data failed: %d", __func__, ret); } // 等待轮询间隔 OsalMSleep(dev->pollInterval); } HDF_LOGI("%s: Poll thread stopped", __func__); return HDF_SUCCESS; } // 启动轮询 void Ky015StartPolling(struct Ky015Device *dev) { if (dev == NULL || dev->threadRunning) { return; } dev->threadRunning = true; // 创建轮询线程 struct OsalThreadParam threadCfg = { .name = "ky015_poll", .priority = OSAL_THREAD_PRI_LOW, .stackSize = 0x1000 }; if (OsalThreadCreate(&dev->pollThread, Ky015PollThread, // 移除强制类型转换 dev) != HDF_SUCCESS) { HDF_LOGE("%s: Create poll thread failed", __func__); dev->threadRunning = false; return; } if (OsalThreadStart(&dev->pollThread, &threadCfg) != HDF_SUCCESS) { HDF_LOGE("%s: Start poll thread failed", __func__); OsalThreadDestroy(&dev->pollThread); dev->threadRunning = false; } } // 停止轮询 void Ky015StopPolling(struct Ky015Device *dev) { if (dev == NULL || !dev->threadRunning) { return; } dev->threadRunning = false; OsalThreadDestroy(&dev->pollThread); } // 读取配置 static int32_t Ky015ReadConfig(struct Ky015Device *dev, const struct DeviceResourceNode *node) { int32_t ret; struct DeviceResourceIface *drsOps = NULL; drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); if (drsOps == NULL || drsOps->GetUint32 == NULL) { HDF_LOGE("%s: Invalid drs ops", __func__); return HDF_ERR_NOT_SUPPORT; } // 读取GPIO引脚号 ret = drsOps->GetUint16(node, "gpioNum", &dev->gpioNum, 22); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read gpioNum failed", __func__); return ret; } // 读取轮询间隔 ret = drsOps->GetUint32(node, "pollInterval", &dev->pollInterval, 2000); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read pollInterval failed", __func__); return ret; } // 修正:正确读取字符串 const char *chipName = NULL; ret = drsOps->GetString(node, "chipName", &chipName, NULL); if (ret == HDF_SUCCESS && chipName != NULL) { strncpy(dev->deviceName, chipName, KY015_NAME_LEN - 1); dev->deviceName[KY015_NAME_LEN - 1] = '\0'; } else { strncpy(dev->deviceName, "KY015", KY015_NAME_LEN - 1); dev->deviceName[KY015_NAME_LEN - 1] = '\0'; } HDF_LOGI("%s: Config: gpio=%d, interval=%d, name=%s", __func__, dev->gpioNum, dev->pollInterval, dev->deviceName); return HDF_SUCCESS; } // 服务接口:获取温度 int32_t Ky015ServiceGetTemperature(struct Ky015Device *dev, int32_t *temp) { if (dev == NULL || temp == NULL) { return HDF_ERR_INVALID_PARAM; } OsalMutexLock(&dev->dataLock); *temp = dev->temperature; OsalMutexUnlock(&dev->dataLock); return HDF_SUCCESS; } // 服务接口:获取湿度 int32_t Ky015ServiceGetHumidity(struct Ky015Device *dev, int32_t *humidity) { if (dev == NULL || humidity == NULL) { return HDF_ERR_INVALID_PARAM; } OsalMutexLock(&dev->dataLock); *humidity = dev->humidity; OsalMutexUnlock(&dev->dataLock); return HDF_SUCCESS; } // HDF驱动绑定 // HDF驱动绑定 int32_t Ky015DriverBind(struct HdfDeviceObject *device) { struct Ky015Device *ky015Dev = NULL; if (device == NULL) { return HDF_ERR_INVALID_PARAM; } ky015Dev = (struct Ky015Device *)OsalMemCalloc(sizeof(*ky015Dev)); if (ky015Dev == NULL) { HDF_LOGE("%s: Alloc Ky015Device failed", __func__); return HDF_ERR_MALLOC_FAIL; } ky015Dev->device = device; // 设置服务接口 ky015Dev->service.Dispatch = Ky015DriverDispatch; // 注册Dispatch函数 device->service = &ky015Dev->service; device->priv = ky015Dev; HDF_LOGI("%s: Bind success with Dispatch", __func__); return HDF_SUCCESS; } // HDF驱动初始化 int32_t Ky015DriverInit(struct HdfDeviceObject *device) { struct Ky015Device *ky015Dev = NULL; int32_t ret; if (device == NULL || device->priv == NULL) { return HDF_ERR_INVALID_PARAM; } ky015Dev = (struct Ky015Device *)device->priv; // 读取配置 ret = Ky015ReadConfig(ky015Dev, device->property); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read config failed", __func__); goto err; } // 初始化同步对象 ret = OsalMutexInit(&ky015Dev->dataLock); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Init mutex failed", __func__); goto err; } ret = OsalSemInit(&ky015Dev->dataSem, 0); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Init semaphore failed", __func__); goto err_mutex; } // 初始化GPIO ret = GpioSetDir(ky015Dev->gpioNum, GPIO_DIR_IN); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Init GPIO failed", __func__); goto err_sem; } // 启动轮询 Ky015StartPolling(ky015Dev); HDF_LOGI("%s: Init success", __func__); return HDF_SUCCESS; err_sem: OsalSemDestroy(&ky015Dev->dataSem); err_mutex: OsalMutexDestroy(&ky015Dev->dataLock); err: return ret; } // HDF驱动释放 void Ky015DriverRelease(struct HdfDeviceObject *device) { struct Ky015Device *ky015Dev = NULL; if (device == NULL || device->priv == NULL) { return; } ky015Dev = (struct Ky015Device *)device->priv; // 停止轮询 Ky015StopPolling(ky015Dev); // 释放资源 OsalSemDestroy(&ky015Dev->dataSem); OsalMutexDestroy(&ky015Dev->dataLock); OsalMemFree(ky015Dev); device->priv = NULL; HDF_LOGI("%s: Release success", __func__); } // 驱动入口 struct HdfDriverEntry g_ky015DriverEntry = { .moduleVersion = 1, .moduleName = "KY015_DRIVER", .Bind = Ky015DriverBind, .Init = Ky015DriverInit, .Release = Ky015DriverRelease, }; HDF_INIT(g_ky015DriverEntry); // 添加必要的头文件这个目录是/home/wsf/ky_015 #ifndef KY015_DRIVER_H #define KY015_DRIVER_H #include "hdf_device_desc.h" #include "osal_mutex.h" #include "osal_sem.h" #include "osal_thread.h" #include "osal_mem.h" #include <string.h> #define KY015_NAME_LEN 32 #define KY015_DATA_BITS 40 // 定义IO控制命令码 #define KY015_CMD_GET_TEMPERATURE 0x0001 #define KY015_CMD_GET_HUMIDITY 0x0002 #define KY015_CMD_GET_SENSOR_DATA 0x0003 #define KY015_CMD_START_POLLING 0x0004 #define KY015_CMD_STOP_POLLING 0x0005 struct Ky015Device { struct IDeviceIoService service; struct HdfDeviceObject *device; uint16_t gpioNum; uint32_t pollInterval; char deviceName[KY015_NAME_LEN]; struct OsalMutex dataLock; struct OsalSem dataSem; struct OsalThread pollThread; bool threadRunning; uint8_t dataBuffer[5]; uint8_t bitCount; uint8_t byteCount; bool dataValid; int32_t temperature; int32_t humidity; }; // 函数声明 int32_t Ky015ReadData(struct Ky015Device *dev); int32_t Ky015ParseData(struct Ky015Device *dev); void Ky015StartPolling(struct Ky015Device *dev); void Ky015StopPolling(struct Ky015Device *dev); int32_t Ky015ServiceGetTemperature(struct Ky015Device *dev, int32_t *temp); int32_t Ky015ServiceGetHumidity(struct Ky015Device *dev, int32_t *humidity); // 添加Dispatch函数声明 int32_t Ky015DriverDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply); #endif // KY015_DRIVER_H 这个目录是/home/wsf/ky-015 include drivers/hdf/khdf/platform/platform.mk obj-y +=ky015_driver.o 这个的目录是/home/wsf/vendor/industio/purple_pi_oh/hdf_config/khdf/device_info$ root { device_info { match_attr = "hdf_manager"; template host { hostName = ""; priority = 100; template device { template deviceNode { policy = 0; priority = 100; preload = 0; permission = 0664; moduleName = ""; serviceName = ""; deviceMatchAttr = ""; } } } base :: host { hostName = "base_host"; priority = 50; device_support :: device { device0 :: deviceNode { policy = 2; priority = 10; permission = 0644; moduleName = "HDF_KEVENT"; serviceName = "hdf_kevent"; } } } platform :: host { hostName = "platform_host"; priority = 50; device_ky015 :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0644; moduleName = "KY015_DRIVER"; serviceName = "ky015_service"; deviceMatchAttr = "ky015_sensor"; } } device_gpio :: device { device0 :: deviceNode { policy = 2; priority = 10; permission = 0644; moduleName = "HDF_PLATFORM_GPIO_MANAGER"; serviceName = "HDF_PLATFORM_GPIO_MANAGER"; } device1 :: deviceNode { policy = 0; priority = 10; permission = 0644; moduleName = "linux_gpio_adapter"; deviceMatchAttr = "linux_gpio_adapter"; } } device_watchdog :: device { device0 :: deviceNode { policy = 1; priority = 20; permission = 0644; moduleName = "HDF_PLATFORM_WATCHDOG"; serviceName = "HDF_PLATFORM_WATCHDOG_0"; deviceMatchAttr = "rockchip_rk3568_watchdog_0"; } } device_rtc :: device { device0 :: deviceNode { policy = 2; priority = 30; permission = 0644; moduleName = "HDF_PLATFORM_RTC"; serviceName = "HDF_PLATFORM_RTC"; deviceMatchAttr = "rockchip_rk3568_rtc"; } } device_uart :: device { device0 :: deviceNode { policy = 2; priority = 40; permission = 0644; moduleName = "HDF_PLATFORM_UART"; serviceName = "HDF_PLATFORM_UART_0"; deviceMatchAttr = "rockchip_rk3568_uart_0"; } device1 :: deviceNode { policy = 2; permission = 0644; priority = 40; moduleName = "HDF_PLATFORM_UART"; serviceName = "HDF_PLATFORM_UART_1"; deviceMatchAttr = "rockchip_rk3568_uart_1"; } device2 :: deviceNode { policy = 2; permission = 0644; priority = 40; moduleName = "HDF_PLATFORM_UART"; serviceName = "HDF_PLATFORM_UART_3"; deviceMatchAttr = "rockchip_rk3568_uart_3"; } } device_i2c :: device { device0 :: deviceNode { policy = 2; priority = 50; permission = 0644; moduleName = "HDF_PLATFORM_I2C_MANAGER"; serviceName = "HDF_PLATFORM_I2C_MANAGER"; deviceMatchAttr = "hdf_platform_i2c_manager"; } device1 :: deviceNode { policy = 0; priority = 55; permission = 0644; moduleName = "linux_i2c_adapter"; deviceMatchAttr = "linux_i2c_adapter"; } } device_adc :: device { device0 :: deviceNode { policy = 2; priority = 60; permission = 0644; moduleName = "HDF_PLATFORM_ADC_MANAGER"; serviceName = "HDF_PLATFORM_ADC_MANAGER"; deviceMatchAttr = "hdf_platform_adc_manager"; } device1 :: deviceNode { policy = 0; priority = 65; permission = 0644; moduleName = "linux_adc_adapter"; deviceMatchAttr = "linux_adc_adapter_0"; } } device_spi :: device { device0 :: deviceNode { policy = 1; priority = 60; permission = 0644; moduleName = "HDF_PLATFORM_SPI"; serviceName = "HDF_PLATFORM_SPI_0"; deviceMatchAttr = "rockchip_rk3568_spi_0"; } device1 :: deviceNode { policy = 1; priority = 60; permission = 0644; moduleName = "HDF_PLATFORM_SPI"; serviceName = "HDF_PLATFORM_SPI_1"; deviceMatchAttr = "rockchip_rk3568_spi_1"; } device2 :: deviceNode { policy = 1; priority = 60; permission = 0644; moduleName = "HDF_PLATFORM_SPI"; serviceName = "HDF_PLATFORM_SPI_2"; deviceMatchAttr = "rockchip_rk3568_spi_2"; } device3 :: deviceNode { policy = 1; priority = 60; permission = 0644; moduleName = "HDF_PLATFORM_SPI"; serviceName = "HDF_PLATFORM_SPI_3"; deviceMatchAttr = "rockchip_rk3568_spi_3"; } } device_sdio :: device { device0 :: deviceNode { policy = 1; priority = 70; permission = 0644; moduleName = "HDF_PLATFORM_SDIO"; serviceName = "HDF_PLATFORM_MMC_2"; deviceMatchAttr = "hisilicon_hi35xx_sdio_0"; } } device_emmc :: device { device0 :: deviceNode { policy = 2; priority = 20; permission = 0644; moduleName = "HDF_PLATFORM_EMMC"; serviceName = "HDF_PLATFORM_MMC_0"; deviceMatchAttr = "hisilicon_hi35xx_emmc_0"; } } device_pwm :: device { device0 :: deviceNode { policy = 2; priority = 80; permission = 0644; moduleName = "HDF_PLATFORM_PWM"; serviceName = "HDF_PLATFORM_PWM_0"; deviceMatchAttr = "linux_pwm_adapter_0"; } device1 :: deviceNode { policy = 2; priority = 80; permission = 0644; moduleName = "HDF_PLATFORM_PWM"; serviceName = "HDF_PLATFORM_PWM_1"; deviceMatchAttr = "linux_pwm_adapter_1"; } device2 :: deviceNode { policy = 2; priority = 80; permission = 0644; moduleName = "HDF_PLATFORM_PWM"; serviceName = "HDF_PLATFORM_PWM_2"; deviceMatchAttr = "linux_pwm_adapter_2"; } device3 :: deviceNode { policy = 2; priority = 80; permission = 0644; moduleName = "HDF_PLATFORM_PWM"; serviceName = "HDF_PLATFORM_PWM_3"; deviceMatchAttr = "linux_pwm_adapter_3"; } device4 :: deviceNode { policy = 2; priority = 80; permission = 0644; moduleName = "HDF_PLATFORM_PWM"; serviceName = "HDF_PLATFORM_PWM_4"; deviceMatchAttr = "linux_pwm_adapter_4"; } } device_mipi_dsi:: device { device0 :: deviceNode { policy = 0; priority = 150; permission = 0644; moduleName = "HDF_MIPI_TX"; serviceName = "HDF_MIPI_TX"; } } } display :: host { hostName = "display_host"; device_hdf_drm_panel :: device { device0 :: deviceNode { policy = 0; priority = 197; preload = 0; moduleName = "HDF_DRMPANEL"; } } device_hdf_disp :: device { device0 :: deviceNode { policy = 2; priority = 196; permission = 0660; moduleName = "HDF_DISP"; serviceName = "hdf_disp"; } } device_hi35xx_disp :: device { device0 :: deviceNode { policy = 0; priority = 195; moduleName = "HI351XX_DISP"; } } device_lcd :: device { device0 :: deviceNode { policy = 0; priority = 100; preload = 2; moduleName = "LITE_LCDKIT"; deviceMatchAttr = "hdf_lcdkit_driver"; } device1 :: deviceNode { policy = 0; priority = 100; preload = 0; moduleName = "LCD_ICN9700"; } device2 :: deviceNode { policy = 0; priority = 100; preload = 2; moduleName = "LCD_ST7789"; } device3 :: deviceNode { policy = 0; priority = 100; preload = 0; moduleName = "LCD_ILI9881_ST_5P5"; } } device_pwm_bl :: device { device0 :: deviceNode { policy = 0; priority = 95; preload = 0; moduleName = "PWM_BL"; deviceMatchAttr = "pwm_bl_dev"; } } device_backlight :: device { device0 :: deviceNode { policy = 2; priority = 90; preload = 0; permission = 0660; moduleName = "HDF_BL"; serviceName = "hdf_bl"; } } } input :: host { hostName = "input_host"; priority = 100; device_input_manager :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0660; moduleName = "HDF_INPUT_MANAGER"; serviceName = "hdf_input_host"; deviceMatchAttr = ""; } } device_hdf_touch :: device { device0 :: deviceNode { policy = 2; priority = 120; preload = 0; permission = 0660; moduleName = "HDF_TOUCH"; serviceName = "hdf_input_event1"; deviceMatchAttr = "touch_device1"; } } device_touch_chip :: device { device0 :: deviceNode { policy = 0; priority = 130; preload = 0; permission = 0660; moduleName = "HDF_TOUCH_GT911"; serviceName = "hdf_touch_gt911_service"; deviceMatchAttr = "zsj_gt911_5p5"; } } device_hdf_hid :: device { device0 :: deviceNode { policy = 2; priority = 200; preload = 0; permission = 0660; moduleName = "HDF_HID"; } } device_hdf_infrared :: device { device0 :: deviceNode { policy = 2; priority = 200; preload = 2; permission = 0660; moduleName = "HDF_INFRARED"; serviceName = "hdf_input_event2"; deviceMatchAttr = "Infrared_device0"; } } } network :: host { hostName = "network_host"; device_wifi :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_WIFI"; deviceMatchAttr = "hdf_wlan_driver"; serviceName = "hdfwifi"; } } device_wlan_chips :: device { device0 :: deviceNode { policy = 0; preload = 2; moduleName = "HDF_WLAN_CHIPS_AP6275S"; deviceMatchAttr = "hdf_wlan_chips_ap6275s"; serviceName = "ap6275s"; } } } camera :: host { hostName = "camera_host0"; device_camera :: device { camera0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_CAMERA"; serviceName = "hdfcamera"; deviceMatchAttr = "hdf_camera_driver"; } } camera_adapter :: device { camera0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_CAMERA_ADAPTER"; serviceName = "hdfcamera0"; } } } sensor :: host { hostName = "sensor_host"; device_sensor_manager :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_MGR_AP"; serviceName = "hdf_sensor_manager_ap"; } } device_sensor_accel :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_ACCEL"; serviceName = "sensor_accel"; deviceMatchAttr = "hdf_sensor_accel_driver"; } } device_sensor_mxc6655xa :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_ACCEL_MXC6655XA"; serviceName = "hdf_accel_mxc6655xa"; deviceMatchAttr = "hdf_sensor_accel_mxc6655xa_driver"; } } device_sensor_accel_bmi270 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_ACCEL_BMI270"; serviceName = "hdf_accel_bmi270"; deviceMatchAttr = "hdf_sensor_accel_bmi270_driver"; } } device_sensor_gyro :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_GYRO"; serviceName = "sensor_gyro"; deviceMatchAttr = "hdf_sensor_gyro_driver"; } } device_sensor_gyro_bmi270 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_GYRO_BMI270"; serviceName = "hdf_gyro_bmi270"; deviceMatchAttr = "hdf_sensor_gyro_bmi270_driver"; } } device_sensor_gas :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_GAS"; serviceName = "sensor_gas"; deviceMatchAttr = "hdf_sensor_gas_driver"; } } device_sensor_gas_bme688 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_GAS_BME688"; serviceName = "hdf_gas_bme688"; deviceMatchAttr = "hdf_sensor_gas_bme688_driver"; } } device_sensor_barometer :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_BAROMETER"; serviceName = "sensor_barometer"; deviceMatchAttr = "hdf_sensor_barometer_driver"; } } device_sensor_barometer_bmp581 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_BAROMETER_BMP581"; serviceName = "hdf_barometer_bmp581"; deviceMatchAttr = "hdf_sensor_barometer_bmp581_driver"; } hostName = "network_host"; } device_sensor_als :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_ALS"; serviceName = "hdf_sensor_als"; deviceMatchAttr = "hdf_sensor_als_driver"; } } device_sensor_bh1745 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_ALS_BH1745"; serviceName = "hdf_als_bh1745"; deviceMatchAttr = "hdf_sensor_als_bh1745_driver"; } } device_sensor_proximity :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_PROXIMITY"; serviceName = "hdf_sensor_proximity"; deviceMatchAttr = "hdf_sensor_proximity_driver"; } } device_sensor_apds9960 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_PROXIMITY_APDS9960"; serviceName = "hdf_proximity_apds9960"; deviceMatchAttr = "hdf_sensor_proximity_adps9960_driver"; } } device_sensor_magnetic :: device { device0 :: deviceNode { policy = 1; priority = 110; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_MAGNETIC"; serviceName = "hdf_sensor_magnetic"; deviceMatchAttr = "hdf_sensor_magnetic_driver"; } } device_sensor_lsm303 :: device { device0 :: deviceNode { policy = 1; priority = 120; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_MAGNETIC_LSM303"; serviceName = "hdf_magnetic_lsm303"; deviceMatchAttr = "hdf_sensor_magnetic_lsm303_driver"; } } device_sensor_temperature :: device { device0 :: deviceNode { policy = 1; priority = 130; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_TEMPERATURE"; serviceName = "hdf_sensor_temperature"; deviceMatchAttr = "hdf_sensor_temperature_driver"; } } device_temperature_aht20 :: device { device0 :: deviceNode { policy = 1; priority = 140; preload = 2; permission = 0664; moduleName = "HDF_SENSOR_TEMPERATURE_AHT20"; serviceName = "hdf_temperature_aht20"; deviceMatchAttr = "hdf_sensor_temperature_aht20_driver"; } } device_temperature_sht30 :: device { device0 :: deviceNode { policy = 1; priority = 150; preload = 2; permission = 0664; moduleName = "HDF_SENSOR_TEMPERATURE_SHT30"; serviceName = "hdf_temperature_sht30"; deviceMatchAttr = "hdf_sensor_temperature_sht30_driver"; } } device_sensor_humidity :: device { device0 :: deviceNode { policy = 1; priority = 160; preload = 0; permission = 0664; moduleName = "HDF_SENSOR_HUMIDITY"; serviceName = "hdf_sensor_humidity"; deviceMatchAttr = "hdf_sensor_humidity_driver"; } } device_humidity_aht20 :: device { device0 :: deviceNode { policy = 1; priority = 170; preload = 2; permission = 0664; moduleName = "HDF_SENSOR_HUMIDITY_AHT20"; serviceName = "hdf_humidity_aht20"; deviceMatchAttr = "hdf_sensor_humidity_aht20_driver"; } } device_humidity_sht30 :: device { device0 :: deviceNode { policy = 1; priority = 180; preload = 2; permission = 0664; moduleName = "HDF_SENSOR_HUMIDITY_SHT30"; serviceName = "hdf_humidity_sht30"; deviceMatchAttr = "hdf_sensor_humidity_sht30_driver"; } } } usb_pnp_linux :: host { hostName = "usb_pnp_linux_host"; device_usb_pnp_linux :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_USB_PNP_NOTIFY"; serviceName = "hdf_usb_pnp_notify_service"; deviceMatchAttr = "hdf_usb_pnp_notify_config"; } hostName = "network_host"; } } usb_net_linux :: host { hostName = "usb_net_linux_host"; device_usb_net_linux :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 2; permission = 0664; moduleName = "HDF_USB_NET"; serviceName = "hdf_usb_net_service"; deviceMatchAttr = "hdf_usb_net_config"; } } } audio :: host { hostName = "audio_host"; priority = 110; device_dai :: device { device_primary :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "DAI_RK3568"; serviceName = "dai_service"; deviceMatchAttr = "hdf_dai_driver"; } device_hdmi :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "DAI_RK3568"; serviceName = "hdmi_dai_service"; deviceMatchAttr = "hdf_hdmi_dai_driver"; } } device_codec :: device { device_primary :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "CODEC_RK809"; serviceName = "codec_service_0"; deviceMatchAttr = "hdf_codec_driver_0"; } device_hdmi :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "AUDIO_HDMI_CODEC"; serviceName = "codec_service_1"; deviceMatchAttr = "hdf_codec_driver_1"; } device_usb :: deviceNode { policy = 1; priority = 50; preload = 2; permission = 0664; moduleName = "AUDIO_USB_CODEC"; serviceName = "audio_usb_service_0"; } } device_dsp :: device { device0 :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "DSP_RK3568"; serviceName = "dsp_service_0"; deviceMatchAttr = "hdf_dsp_driver"; } } device_dma :: device { device_primary :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "DMA_RK3568"; serviceName = "dma_service_0"; deviceMatchAttr = "hdf_dma_driver"; } device_hdmi :: deviceNode { policy = 1; priority = 50; preload = 0; permission = 0666; moduleName = "DMA_RK3568"; serviceName = "hdmi_dma_service_0"; deviceMatchAttr = "hdf_hdmi_dma_driver"; } device_usb :: deviceNode { policy = 1; priority = 50; preload = 2; permission = 0666; moduleName = "AUDIO_USB_DMA"; serviceName = "usb_dma_service_0"; } } device_audio :: device { device_primary :: deviceNode { policy = 2; priority = 60; preload = 0; permission = 0666; moduleName = "HDF_AUDIO"; deviceMatchAttr = "hdf_audio_driver_0"; serviceName = "hdf_audio_codec_primary_dev0"; } device_hdmi :: deviceNode { policy = 2; priority = 60; preload = 2; permission = 0666; moduleName = "HDF_AUDIO"; deviceMatchAttr = "hdf_audio_driver_1"; serviceName = "hdf_audio_codec_hdmi_dev0"; } device_usb :: deviceNode { policy = 2; priority = 60; preload = 2; permission = 0666; moduleName = "HDF_AUDIO"; deviceMatchAttr = "hdf_audio_driver_2"; serviceName = "hdf_audio_codec_usb_dev0"; } } device_stream :: device { device0 :: deviceNode { policy = 2; priority = 80; preload = 0; permission = 0666; moduleName = "HDF_AUDIO_STREAM"; serviceName = "hdf_audio_render"; } device1 :: deviceNode { policy = 2; priority = 80; preload = 0; permission = 0666; moduleName = "HDF_AUDIO_STREAM"; serviceName = "hdf_audio_capture"; } } device_control :: device { device0 :: deviceNode { policy = 2; priority = 80; preload = 0; permission = 0666; moduleName = "HDF_AUDIO_CONTROL";light serviceName = "hdf_audio_control"; } } device_analog_headset :: device { device0 :: deviceNode { policy = 1; priority = 90; preload = 0; permission = 0666; moduleName = "AUDIO_ANALOG_HEADSET"; serviceName = "analog_headset_service"; deviceMatchAttr = "analog_headset_attr"; } } } vibrator :: host { hostName = "vibrator_host"; device_vibrator :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_VIBRATOR"; serviceName = "hdf_misc_vibrator"; deviceMatchAttr = "hdf_vibrator_driver"; } } device_linear_vibrator :: device { device0 :: deviceNode { policy = 1; priority = 105; preload = 0; permission = 0664; moduleName = "HDF_LINEAR_VIBRATOR"; serviceName = "hdf_misc_linear_vibrator"; deviceMatchAttr = "hdf_linear_vibrator_driver"; } } device_drv2605l_vibrator :: device { device0 :: deviceNode { policy = 1; priority = 105; preload = 0; permission = 0664; moduleName = "HDF_DRV2605L_VIBRATOR"; serviceName = "hdf_misc_drv2605l_vibrator"; deviceMatchAttr = "hdf_drv2605l_linear_vibrator_driver"; } } } light :: host { hostName = "light_host"; device_light :: device { device0 :: deviceNode { policy = 2; priority = 100; preload = 0; permission = 0664; moduleName = "HDF_LIGHT"; serviceName = "hdf_light"; deviceMatchAttr = "hdf_light_driver"; } } } } } 这个目录是/home/wsf/vendor/industio/purple_pi_oh/hdf_config/khd #include "device_info/device_info.hcs" #include "platform/adc_config_linux.hcs" #include "platform/pwm_config.hcs" #include "platform/rk3568_watchdog_config.hcs" #include "platform/rk3568_uart_config.hcs" #include "platform/sdio_config.hcs" #include "platform/emmc_config.hcs" #include "platform/rk3568_spi_config.hcs" #include "input/input_config.hcs" #include "wifi/wlan_platform.hcs" #include "wifi/wlan_chip_ap6275s.hcs" #include "camera/camera_config.hcs" #include "sensor/sensor_config.hcs" #include "audio/audio_config.hcs" #include "audio/codec_config.hcs" #include "audio/dai_config.hcs" #include "audio/dma_config.hcs" #include "audio/dsp_config.hcs" #include "audio/analog_headset_config.hcs" #include "light/light_config.hcs" #include "vibrator/vibrator_config.hcs" #include "vibrator/linear_vibrator_config.hcs" #include "vibrator/drv2605l_linear_vibrator_config.hcs" #include "lcd/lcd_config.hcs" #include "ky_015/ky015_sensor.hcs" root { module = "rockchip,rk3568_chip"; } 这个目录是/home/wsf/vendor/industio/purple_pi_oh/hdf_config/khdf/ky_015root { platform { template sensor_chip { chipName = ""; busType = 0; busNum = 0; gpioNum = 22; pollInterval = 2000; } ky015_sensor :: sensor_chip { match_attr = "ky015_sensor"; chipName = "KY015"; gpioNum = 22; } } } #这个目录是/home/wsf/drivers/hdf_core/adapter/khdf/linux$ # Copyright (c) 2020-2022 Huawei Device Co., Ltd. # # This software is licensed under the terms of the GNU General Public # License version 2, as published by the Free Software Foundation, and # may be copied, distributed, and modified under those terms. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # CURRENT_DIR := $(abspath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) obj-$(CONFIG_DRIVERS_HDF) += osal/ obj-$(CONFIG_DRIVERS_HDF) += utils/ $(warning PRODUCT_PATH=$(PRODUCT_PATH)) ifeq ($(PRODUCT_PATH),) $(error PRODUCT_PATH is not set) endif HCS_DIR := ../../../../../$(PRODUCT_PATH)/hdf_config/khdf ifeq ($(wildcard $(CURRENT_DIR)/$(HCS_DIR)),) HCS_DIR := ../../../../../$(PRODUCT_PATH)/hdf_config endif ifeq ($(CONFIG_DRIVERS_HDF), y) ifeq ($(wildcard $(CURRENT_DIR)/$(HCS_DIR)),) HCS_ABS_DIR := $(abspath $(CURRENT_DIR)/$(HCS_DIR)) $(error miss hcs config in $(HCS_ABS_DIR) for small system\ or $(HCS_ABS_DIR)/khdf for standrad system) endif ifeq ($(CONFIG_DRIVERS_HDF_TEST), y) obj-$(CONFIG_DRIVERS_HDF_TEST) += test/ obj-$(CONFIG_DRIVERS_HDF_TEST) += $(HCS_DIR)/hdf_test/ else obj-$(CONFIG_DRIVERS_HDF) += $(HCS_DIR)/ endif endif obj-$(CONFIG_DRIVERS_HDF) += manager/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM) += platform/ obj-$(CONFIG_DRIVERS_HDF_DISP) += model/display/ obj-$(CONFIG_DRIVERS_HDF_INPUT) += model/input/ obj-$(CONFIG_DRIVERS_HDF_WIFI) += model/network/wifi/ obj-$(CONFIG_DRIVERS_HDF_USB_PNP_NOTIFY) += model/usb/host/ obj-$(CONFIG_DRIVERS_HDF_SENSOR) += model/sensor/ obj-$(CONFIG_DRIVERS_HDF_STORAGE) += model/storage/ obj-$(CONFIG_DRIVERS_HDF_BT) += model/network/bluetooth/ obj-$(CONFIG_DRIVERS_HDF_LIGHT) += model/misc/light/ obj-$(CONFIG_DRIVERS_HDF_VIBRATOR) += model/misc/vibrator/ obj-$(CONFIG_DRIVERS_HDF_AUDIO) += model/audio/ obj-$(CONFIG_DRIVERS_HDF_DSOFTBUS) += model/misc/dsoftbus/ obj-$(CONFIG_DRIVERS_HDF_NETWORK) += network/ obj-$(CONFIG_DRIVERS_HDF) += ../../../../../ky_015/这是我所有的有关KY-015的HDF驱动文件独立的不在sensor模型下在out/kernel下有ky015_driver.o文件但为什么没有编入产品内 不需要生成ko文件 编译入内核
最新发布
12-06
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值