diff --git a/config/linux/ipu75xa/libcamhal_configs.json b/config/linux/ipu75xa/libcamhal_configs.json index 97fda2e..b81ce7e 100644 --- a/config/linux/ipu75xa/libcamhal_configs.json +++ b/config/linux/ipu75xa/libcamhal_configs.json @@ -46,7 +46,9 @@ "ar0830-1-mipi-0", "ar0830-2-mipi-2", "isx031-1-mipi-0", - "isx031-2-mipi-2" + "isx031-2-mipi-2", + "acpi", + "d4xx" ], "videoStreamNum" : 2 } diff --git a/config/linux/ipu75xa/sensors/acpi.json b/config/linux/ipu75xa/sensors/acpi.json new file mode 100644 index 0000000..b90ac76 --- /dev/null +++ b/config/linux/ipu75xa/sensors/acpi.json @@ -0,0 +1,322 @@ +// +// Copyright (C) 2025-2026 Intel Corporation +// +// 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. +// + +{ + "CameraSettings": { + "Sensor": [ + { + "name": "acpi-1", + "description": "acpi GMSL sensor on Link A", + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [1920, 1536], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 0", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH00.SER0.CAM0", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 1 , + "configMode": "AUTO", + "output": [1920, 1080], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 0", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH00.SER0.CAM0", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 2 , + "configMode": "AUTO", + "output": [1280, 720], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 0", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH00.SER0.CAM0", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1536], "field": 0, "mcId": 0 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1080], "field": 0, "mcId": 1 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1280, 720], "field": 0, "mcId": 2 + } + ] + }, + + "supportedISysSizes": [[1280, 720], [1920, 1080], [1920, 1536]], + "supportedISysFormat": ["V4L2_PIX_FMT_UYVY"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "acpi-2", + "description": "acpi GMSL sensor on Link B", + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [1920, 1536], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 1", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH01.SER1.CAM1", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 1 , + "configMode": "AUTO", + "output": [1920, 1080], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 1", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH01.SER1.CAM1", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 2 , + "configMode": "AUTO", + "output": [1280, 720], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 1", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH01.SER1.CAM1", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1536], "field": 0, "mcId": 0 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1080], "field": 0, "mcId": 1 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1280, 720], "field": 0, "mcId": 2 + } + ] + }, + + "supportedISysSizes": [[1280, 720], [1920, 1080], [1920, 1536]], + "supportedISysFormat": ["V4L2_PIX_FMT_UYVY"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "acpi-3", + "description": "acpi GMSL sensor on Link C", + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [1920, 1536], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 2", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH02.SER2.CAM2", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 1 , + "configMode": "AUTO", + "output": [1920, 1080], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 2", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH02.SER2.CAM2", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 2 , + "configMode": "AUTO", + "output": [1280, 720], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 2", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH02.SER2.CAM2", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1536], "field": 0, "mcId": 0 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1080], "field": 0, "mcId": 1 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1280, 720], "field": 0, "mcId": 2 + } + ] + }, + + "supportedISysSizes": [[1280, 720], [1920, 1080], [1920, 1536]], + "supportedISysFormat": ["V4L2_PIX_FMT_UYVY"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "acpi-4", + "description": "acpi GMSL sensor on Link D", + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [1920, 1536], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 3", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH03.SER3.CAM3", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 1 , + "configMode": "AUTO", + "output": [1920, 1080], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 3", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH03.SER3.CAM3", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + { + "id": 2 , + "configMode": "AUTO", + "output": [1280, 720], + "format": "V4L2_PIX_FMT_UYVY", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 3", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH03.SER3.CAM3", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + }, + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1536], "field": 0, "mcId": 0 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1920, 1080], "field": 0, "mcId": 1 + }, + { + "format": "V4L2_PIX_FMT_UYVY", "size": [1280, 720], "field": 0, "mcId": 2 + } + ] + }, + + "supportedISysSizes": [[1280, 720], [1920, 1080], [1920, 1536]], + "supportedISysFormat": ["V4L2_PIX_FMT_UYVY"], + "enableAIQ": false, + "usePSysProcessor": false + } + ] + } +} diff --git a/config/linux/ipu75xa/sensors/d4xx.json b/config/linux/ipu75xa/sensors/d4xx.json new file mode 100644 index 0000000..e37042d --- /dev/null +++ b/config/linux/ipu75xa/sensors/d4xx.json @@ -0,0 +1,323 @@ +// +// Copyright (C) 2025-2026 Intel Corporation +// +// 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. +// + +{ + "CameraSettings": { + "Sensor": [ + { + "name": "d4xx-1", + "description": "D4XX GMSL sensor on DES0 Link A", + "vcCount": 4, + "vcId": 1, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 4", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH00.SER0.CAM0", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-2", + "description": "D4XX GMSL sensor on DES0 Link B", + "vcCount": 4, + "vcId": 3, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 5", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH01.SER1.CAM1", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-3", + "description": "D4XX GMSL sensor on DES0 Link C", + "vcCount": 4, + "vcId": 2, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 6", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH02.SER2.CAM2", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-4", + "description": "D4XX GMSL sensor on DES0 Link D", + "vcCount": 4, + "vcId": 3, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 7", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 0", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES0.CH03.SER3.CAM3", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-5", + "description": "D4XX GMSL sensor on DES1 Link A", + "vcCount": 4, + "vcId": 1, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 36", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 2", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES1.CH00.SER0.CAM0", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-6", + "description": "D4XX GMSL sensor on DES1 Link B", + "vcCount": 4, + "vcId": 3, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 37", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 2", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES1.CH01.SER1.CAM1", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + }, + { + "name": "d4xx-7", + "description": "D4XX GMSL sensor on DES1 Link C", + "vcCount": 4, + "vcId": 3, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 38", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 2", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES1.CH02.SER2.CAM2", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + } + , + { + "name": "d4xx-8", + "description": "D4XX GMSL sensor on DES1 Link D", + "vcCount": 4, + "vcId": 3, + "vcGroupId": 0, + "MediaCtlConfig": [ + { + "id": 0 , + "configMode": "AUTO", + "output": [640, 480], + "format": "V4L2_PIX_FMT_YUYV", + "videonode": [ + { + "name": "Intel IPU7 ISYS Capture 39", "videoNodeType": "VIDEO_GENERIC" + }, + { + "name": "Intel IPU7 CSI2 2", "videoNodeType": "VIDEO_ISYS_RECEIVER" + }, + { + "acpiName": "\\_SB_.PC00.DES1.CH03.SER3.CAM3", "subEntity": "D4XX rgb", "videoNodeType": "VIDEO_PIXEL_ARRAY" + } + ] + } + ], + "StaticMetadata": { + "supportedStreamConfig": [ + { + "format": "V4L2_PIX_FMT_YUYV", "size": [640, 480], "field": 0, "mcId": 0 + } + ] + }, + "supportedISysSizes": [[640, 480]], + "supportedISysFormat": ["V4L2_PIX_FMT_YUYV"], + "enableAIQ": false, + "usePSysProcessor": false + } + ] + } +} diff --git a/src/platformdata/CameraParserInvoker.cpp b/src/platformdata/CameraParserInvoker.cpp index 6f3924e..125097f 100644 --- a/src/platformdata/CameraParserInvoker.cpp +++ b/src/platformdata/CameraParserInvoker.cpp @@ -110,6 +110,16 @@ std::vector> CameraParserInvoker::getAvailabl SensorInfo sensorInfo = {sensor, true}; availableSensors.push_back({sensor, sensorInfo}); LOG1("@%s, found %s", __func__, sensor.c_str()); + continue; + } + + // Look for ACPI-described sensors: any pure-source entity in + // the media graph that exposes a non-empty firmware_node/path is + // treated as ACPI-described. + if (mMediaCtl && mMediaCtl->checkAvailableAcpiSensor()) { + SensorInfo sensorInfo = {sensor, false}; + availableSensors.push_back({sensor, sensorInfo}); + LOG1("@%s, found ACPI-described sensor %s", __func__, sensor.c_str()); } } else { // sensors with suffix port number diff --git a/src/platformdata/CameraSensorsParser.cpp b/src/platformdata/CameraSensorsParser.cpp index 4212ae4..33622a2 100644 --- a/src/platformdata/CameraSensorsParser.cpp +++ b/src/platformdata/CameraSensorsParser.cpp @@ -179,6 +179,14 @@ void CameraSensorsParser::parseMediaCtlControlObject(const Json::Value& node, Me if (mMediaCtl) ctl.entity = mMediaCtl->getEntityIdByName(ctl.entityName); } + if (ele.isMember("acpiName")) { + const std::string subEntity = + ele.isMember("subEntity") ? ele["subEntity"].asString() : std::string(); + ctl.entityName = + mMediaCtl->acpiName2EntityName(ele["acpiName"].asString(), subEntity); + if (mMediaCtl) + ctl.entity = mMediaCtl->getEntityIdByName(ctl.entityName); + } if (ele.isMember("ctrlId")) { const auto target = ele["ctrlId"].asString(); if (ctlCmdMapTable.find(target) != ctlCmdMapTable.end()) @@ -231,7 +239,14 @@ void CameraSensorsParser::parseMediaCtlVideoNodeObject(const Json::Value& node, const auto ele = node[i]; McVideoNode videoNode; - videoNode.name = resolveI2CBusString(ele["name"].asString()); + if (ele.isMember("name")) { + videoNode.name = resolveI2CBusString(ele["name"].asString()); + } else if (ele.isMember("acpiName") && mMediaCtl != nullptr) { + const std::string subEntity = + ele.isMember("subEntity") ? ele["subEntity"].asString() : std::string(); + videoNode.name = + mMediaCtl->acpiName2EntityName(ele["acpiName"].asString(), subEntity); + } videoNode.videoNodeType = GetNodeType(ele["videoNodeType"].asString().c_str()); conf->videoNodes.push_back(videoNode); } @@ -338,6 +353,15 @@ void CameraSensorsParser::parseMediaCtlSelectionObject(const Json::Value& node, sel.entity = mMediaCtl->getEntityIdByName(sel.entityName); } } + if (ele.isMember("acpiName")) { + const std::string subEntity = + ele.isMember("subEntity") ? ele["subEntity"].asString() : std::string(); + sel.entityName = + mMediaCtl->acpiName2EntityName(ele["acpiName"].asString(), subEntity); + if (mMediaCtl != nullptr) { + sel.entity = mMediaCtl->getEntityIdByName(sel.entityName); + } + } if (ele.isMember("pad")) { sel.pad = ele["pad"].asInt(); } @@ -1003,9 +1027,12 @@ int CameraSensorsParser::getCameraModuleNameFromEEPROM(const std::string& nvmDir void CameraSensorsParser::updateNVMDir() { // OLD Code. Do not change unless you know what you are doing. // I2CBus is adaptor-bus, like 18-0010, and use adaptor id to select NVM path. - if ((mI2CBus.size() < 2) && mNVMDeviceInfo.empty()) { + + if (mNVMDeviceInfo.empty()) + return; + + if ((mI2CBus.size() < 2)) return; - } // attach i2c adaptor id, like 18-0010 std::size_t found = mI2CBus.find("-"); diff --git a/src/v4l2/MediaControl.cpp b/src/v4l2/MediaControl.cpp index f0345cf..aa667d0 100644 --- a/src/v4l2/MediaControl.cpp +++ b/src/v4l2/MediaControl.cpp @@ -61,6 +61,7 @@ struct MediaEntity { unsigned int numLinks; char devname[32]; + char acpiname[32]; }; MediaControl* MediaControl::sInstance = nullptr; @@ -504,7 +505,7 @@ int MediaControl::getDevnameFromSysfs(MediaEntity* entity) { ret = readlink(sysName, target, MAX_TARGET_NAME); if (ret <= 0) { - LOGE("readlink sysName %s failed ret %d.", sysName, ret); + LOGE("readlink entity %s sysName %s failed ret %d.", entity->info.name, sysName, ret); return -EINVAL; } target[MAX_TARGET_NAME - 1] = '\0'; @@ -530,6 +531,20 @@ int MediaControl::getDevnameFromSysfs(MediaEntity* entity) { snprintf(entity->devname, sizeof(entity->devname), "/dev/%s", d); } + strlcat(sysName, "/device/firmware_node/path", sizeof(sysName)); + FILE* fp = fopen(sysName, "rb"); + if (fp) { + fgets(entity->acpiname, sizeof(entity->acpiname), fp); + + size_t len = strlen(entity->acpiname); + if (len > 0 && entity->acpiname[len - 1] == '\n') { + entity->acpiname[len - 1] = '\0'; + } + + fclose(fp); + } + LOG1("name %s devname %s acpiname %s", entity->info.name, entity->devname, entity->acpiname); + return 0; } @@ -1072,6 +1087,53 @@ bool MediaControl::checkAvailableSensor(const std::string& sensorEntityName, return false; } +// This function must be called after enumEntities(). +// Recursively walk the source side of the given sink and return true if any +// pure source entity has a non-empty acpiname (i.e. is ACPI-described). +bool MediaControl::checkHasAcpiSource(const MediaEntity* sink) { + for (unsigned int i = 0U; i < sink->numLinks; ++i) { + if (sink->links[i].sink->entity == sink) { + MediaEntity* pre = sink->links[i].source->entity; + if (isMediaSourceEntity(pre)) { + if (pre->acpiname[0] != '\0') { + return true; + } + } else { + if (checkHasAcpiSource(pre)) { + return true; + } + } + } + } + return false; +} + +bool MediaControl::checkAvailableAcpiSensor(const std::string& sinkEntityName) { + LOG1("@%s, sinkEntityName:%s", __func__, sinkEntityName.c_str()); + + for (auto& entity : mEntities) { + if (strcmp(sinkEntityName.c_str(), entity.info.name) == 0) { + return checkHasAcpiSource(&entity); + } + } + + return false; +} + +bool MediaControl::checkAvailableAcpiSensor() { + LOG1("@%s", __func__); + + for (auto& entity : mEntities) { + if (isMediaSourceEntity(&entity) && entity.acpiname[0] != '\0') { + LOG1("@%s, found ACPI source entity %s (acpiname=%s)", __func__, + entity.info.name, entity.acpiname); + return true; + } + } + + return false; +} + // This function must be called after enumEntities(). int MediaControl::getI2CBusAddress(const string& sensorEntityName, const string& sinkEntityName, string* i2cBus) { @@ -1102,6 +1164,20 @@ int MediaControl::getI2CBusAddress(const string& sensorEntityName, const string& return UNKNOWN_ERROR; } +std::string MediaControl::acpiName2EntityName(const std::string& acpiName, + const std::string& subEntity) { + for (auto& entity : mEntities) { + if (strcmp(entity.acpiname, acpiName.c_str()) == 0) { + if (subEntity.empty() || + strstr(entity.info.name, subEntity.c_str()) != nullptr) { + return std::string(entity.info.name); + } + } + } + + return ""; +} + // DUMP_ENTITY_TOPOLOGY_S void MediaControl::dumpTopologyDot() { printf("digraph board {\n"); diff --git a/src/v4l2/MediaControl.h b/src/v4l2/MediaControl.h index 8395721..418ef97 100644 --- a/src/v4l2/MediaControl.h +++ b/src/v4l2/MediaControl.h @@ -258,6 +258,9 @@ class MediaControl { bool checkAvailableSensor(const std::string& sensorEntityName); bool checkAvailableSensor(const std::string& sensorEntityName, const std::string& sinkEntityName); + + bool checkAvailableAcpiSensor(const std::string& sinkEntityName); + bool checkAvailableAcpiSensor(); /** * Getting I2C bus address by the name of sensor entity and the name of sensor's sink entity. * @@ -269,6 +272,9 @@ class MediaControl { int getI2CBusAddress(const std::string& sensorEntityName, const std::string& sinkEntityName, std::string* i2cBus); + std::string acpiName2EntityName(const std::string& acpiName, + const std::string& subEntity = ""); + private: MediaControl& operator=(const MediaControl&); MediaControl(const char* devName); @@ -291,6 +297,7 @@ class MediaControl { MediaEntity* getEntityById(uint32_t id); MediaEntity* getEntityByName(const std::string &name); bool checkHasSource(const MediaEntity* sink, const std::string& source); + bool checkHasAcpiSource(const MediaEntity* sink); // set up entity link.