mirror of
https://github.com/terrapkg/packages.git
synced 2026-05-31 17:11:56 +00:00
[IPU6 Part 2] Add: ipu6-camera-hal (#2924)
* Add: ipu6-camera-hal * Fix: Only build for x86_64 Signed-off-by: Gil <rockgrub@protonmail.com> * Cleanup: Formatting because mobile made it wonky Signed-off-by: Gil <rockgrub@protonmail.com> --------- Signed-off-by: Gil <rockgrub@protonmail.com> Co-authored-by: Cappy Ishihara <cappy@cappuchino.xyz>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
From 50bfe3c1d2d2d357b518e5951244dd244b03ad78 Mon Sep 17 00:00:00 2001
|
||||
From: Kate Hsuan <hpa@redhat.com>
|
||||
Date: Fri, 15 Mar 2024 14:09:39 +0800
|
||||
Subject: [PATCH] Patch lib path to align fedora path usage
|
||||
|
||||
---
|
||||
src/hal/hal_adaptor/HalAdaptor.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/hal/hal_adaptor/HalAdaptor.cpp b/src/hal/hal_adaptor/HalAdaptor.cpp
|
||||
index e14418a..17e9697 100644
|
||||
--- a/src/hal/hal_adaptor/HalAdaptor.cpp
|
||||
+++ b/src/hal/hal_adaptor/HalAdaptor.cpp
|
||||
@@ -62,7 +62,7 @@ static void load_camera_hal_library() {
|
||||
CheckAndLogError((strlen(pciID) == 0), VOID_VALUE, "%s, Failed to read PCI id. %d", __func__,
|
||||
ret);
|
||||
|
||||
- std::string libName = "/usr/lib/";
|
||||
+ std::string libName = "/usr/lib64/";
|
||||
if (IPU6_UPSTREAM) {
|
||||
if (strstr(pciID, "0x7d19") != nullptr /* MTL */) {
|
||||
libName += "ipu_mtl_upstream";
|
||||
--
|
||||
2.44.0
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -266,7 +266,7 @@ add_library(camhal_static STATIC ${LIBCAMHAL_SRCS})
|
||||
if (NOT CAL_BUILD AND (NOT "${CMAKE_INSTALL_SUB_PATH}" STREQUAL ""))
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
set_target_properties(camhal PROPERTIES LINK_FLAGS
|
||||
- "-Wl,-rpath,/usr/lib/${CMAKE_INSTALL_SUB_PATH}")
|
||||
+ "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}")
|
||||
add_compile_definitions(SUB_CONFIG_PATH="${CMAKE_INSTALL_SUB_PATH}")
|
||||
endif()
|
||||
set_target_properties(camhal_static PROPERTIES OUTPUT_NAME "camhal")
|
||||
@@ -399,9 +399,9 @@ endif() #ENABLE_SANDBOXING
|
||||
if (NOT CAL_BUILD)
|
||||
# Install headers
|
||||
if ("${CMAKE_INSTALL_SUB_PATH}" STREQUAL "")
|
||||
- install(DIRECTORY include/ DESTINATION usr/include/libcamhal)
|
||||
+ install(DIRECTORY include/ DESTINATION include/libcamhal)
|
||||
if (SUPPORT_LIVE_TUNING)
|
||||
- install(FILES modules/livetune/LiveTuning.h DESTINATION usr/include/libcamhal/api)
|
||||
+ install(FILES modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api)
|
||||
endif() #SUPPORT_LIVE_TUNING
|
||||
endif()
|
||||
|
||||
@@ -421,18 +421,18 @@ endif()
|
||||
# Install libraries
|
||||
if (${CMAKE_VERSION} VERSION_LESS 3.11)
|
||||
install(TARGETS camhal camhal_static
|
||||
- LIBRARY DESTINATION usr/lib/${CMAKE_INSTALL_SUB_PATH}
|
||||
- ARCHIVE DESTINATION usr/lib/${CMAKE_INSTALL_SUB_PATH}
|
||||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}
|
||||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}
|
||||
)
|
||||
else()
|
||||
-install(TARGETS camhal camhal_static DESTINATION usr/lib/${CMAKE_INSTALL_SUB_PATH})
|
||||
+install(TARGETS camhal camhal_static DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH})
|
||||
endif()
|
||||
|
||||
# Install package config file
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/libcamhal.pc.cmakein
|
||||
${PROJECT_SOURCE_DIR}/libcamhal.pc @ONLY)
|
||||
install(FILES libcamhal.pc
|
||||
- DESTINATION usr/${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}/pkgconfig)
|
||||
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}/pkgconfig)
|
||||
|
||||
endif() #NOT CAL_BUILD
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/src/v4l2/MediaControl.cpp
|
||||
+++ b/src/v4l2/MediaControl.cpp
|
||||
@@ -886,6 +886,15 @@ int MediaControl::mediaCtlSetup(int cameraId, MediaCtlConf* mc, int width, int h
|
||||
ivscName.c_str(), link.sinkEntityName.c_str());
|
||||
link.srcEntity = ivsc->info.id;
|
||||
link.srcEntityName = ivscName;
|
||||
+ /*
|
||||
+ * Since mainline kernel commit 48f5fd8967f8 ("media:
|
||||
+ * ivsc: csi: Swap SINK and SOURCE pads") the src-pad
|
||||
+ * on the mainline ivsc mc-entity is pad 1, where on
|
||||
+ * older versions it is pad 0, so this needs to be set
|
||||
+ * dynamically.
|
||||
+ * The src-pad is the other pad of the found ivsc sink.
|
||||
+ */
|
||||
+ link.srcPad = !ivsc->links[i].sink->index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Tiger Lake
|
||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x9a19", GOTO="ipu6_tgl"
|
||||
# Alder Lake-N
|
||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x465d", GOTO="ipu6_adl"
|
||||
# Alder Lake-P
|
||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x462e", GOTO="ipu6_adl"
|
||||
# Raptor Lake-P
|
||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0xa75d", GOTO="ipu6_adl"
|
||||
# Meteor Lake
|
||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x7d19", GOTO="ipu6_mtl"
|
||||
|
||||
GOTO="ipu6_end"
|
||||
|
||||
LABEL="ipu6_tgl"
|
||||
RUN+="/bin/ln -sf /usr/share/defaults/etc/camera/ipu_tgl/v4l2-relayd /run/v4l2-relayd"
|
||||
GOTO="ipu6_end"
|
||||
|
||||
LABEL="ipu6_adl"
|
||||
RUN+="/bin/ln -sf /usr/share/defaults/etc/camera/ipu_adl/v4l2-relayd /run/v4l2-relayd"
|
||||
GOTO="ipu6_end"
|
||||
|
||||
LABEL="ipu6_mtl"
|
||||
RUN+="/bin/ln -sf /usr/share/defaults/etc/camera/ipu_mtl/v4l2-relayd /run/v4l2-relayd"
|
||||
GOTO="ipu6_end"
|
||||
|
||||
LABEL="ipu6_end"
|
||||
|
||||
KERNEL=="ipu-psys0", TAG+="uaccess"
|
||||
@@ -0,0 +1,9 @@
|
||||
project pkg {
|
||||
arches = ["x86_64"]
|
||||
rpm {
|
||||
spec = "ipu6-camera-hal.spec"
|
||||
}
|
||||
labels {
|
||||
weekly = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Move the special isys /dev/video# node out of the way of
|
||||
# normal v4l2 devices such as v4l2loopback
|
||||
options icamera_ipu6_isys video_nr=8,9,10,11,12,13,14,15
|
||||
@@ -0,0 +1,141 @@
|
||||
%global commit 289e645dffbd0ea633f10bb4f93855f1e4429e9a
|
||||
%global commitdate 20240509
|
||||
%global shortcommit %(c=%{commit}; echo ${c:0:7})
|
||||
%global __cmake_in_source_build 1
|
||||
|
||||
Name: ipu6-camera-hal
|
||||
Summary: Hardware abstraction layer for Intel IPU6
|
||||
URL: https://github.com/intel/ipu6-camera-hal
|
||||
Version: %{commitdate}.%{shortcommit}
|
||||
Release: 1%{?dist}
|
||||
License: Apache-2.0
|
||||
Source0: https://github.com/intel/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
|
||||
Source1: 60-intel-ipu6.rules
|
||||
Source2: v4l2-relayd-adl
|
||||
Source3: v4l2-relayd-tgl
|
||||
Source4: icamera_ipu6_isys.conf
|
||||
Source5: ipu6-driver-select.sh
|
||||
### RPM Fusion | [ipu6-camera-hal] Update to the latest commit
|
||||
## https://lists.rpmfusion.org/archives/list/rpmfusion-commits@lists.rpmfusion.org/thread/O6IPZMHMP7A3LQBDY4AEORTDEX4P6ESY
|
||||
Patch00: 0000-lib-path.patch
|
||||
### intel/ipu6-camera-hal | PR #113 | CMakeLists fixes
|
||||
## https://github.com/intel/ipu6-camera-hal/pull/113
|
||||
Patch01: 0001-CMakeLists-fixes.patch
|
||||
### intel/ipu6-camera-hal | PR #114 | MediaControl: Dymically set mainline IVSC media-entity src-pad index
|
||||
## https://github.com/intel/ipu6-camera-hal/pull/114
|
||||
Patch02: 0002-set-mainline.patch
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: ipu6-camera-bins-devel >= 0.0-11
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc
|
||||
BuildRequires: g++
|
||||
BuildRequires: expat-devel
|
||||
BuildRequires: libdrm-devel
|
||||
ExclusiveArch: x86_64
|
||||
Requires: ipu6-camera-bins >= 0.0-11
|
||||
|
||||
%description
|
||||
This package provides the basic Hardware Avstraction Layer (HAL) access APIs for IPU6.
|
||||
|
||||
%package devel
|
||||
Summary: IPU6 header files for HAL
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Requires: ipu6-camera-bins-devel
|
||||
|
||||
%description devel
|
||||
This provides the necessary header files for IPU6 HAL development.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n %{name}-%{commit}
|
||||
sed -i "s|/etc/camera/|/usr/share/defaults/etc/camera/|g" \
|
||||
src/platformdata/PlatformData.h
|
||||
|
||||
|
||||
%build
|
||||
for i in ipu_tgl ipu_adl ipu_mtl; do
|
||||
export PKG_CONFIG_PATH=%{_libdir}/$i/pkgconfig/
|
||||
export LDFLAGS="$RPM_LD_FLAGS -Wl,-rpath=%{_libdir}/$i"
|
||||
mkdir $i && pushd $i
|
||||
if [ $i = "ipu_tgl" ]; then
|
||||
IPU_VERSION=ipu6
|
||||
elif [ $i = "ipu_adl" ]; then
|
||||
IPU_VERSION=ipu6ep
|
||||
elif [ $i = "ipu_mtl" ]; then
|
||||
IPU_VERSION=ipu6epmtl
|
||||
else
|
||||
IPU_VERSION=ipu
|
||||
fi
|
||||
%cmake -DCMAKE_BUILD_TYPE=Release -DIPU_VER=$IPU_VERSION \
|
||||
-DCMAKE_INSTALL_SUB_PATH:PATH="$i" \
|
||||
-DCMAKE_INSTALL_SYSCONFDIR:PATH="share/defaults/etc" \
|
||||
-DBUILD_CAMHAL_TESTS=OFF -DUSE_PG_LITE_PIPE=ON ..
|
||||
%make_build
|
||||
popd
|
||||
done
|
||||
|
||||
### hal_adaptor.so dispatches between different libcamhal.so builds so only build it once!
|
||||
mkdir hal_adaptor && pushd hal_adaptor
|
||||
%cmake ../src/hal/hal_adaptor
|
||||
%make_build
|
||||
popd
|
||||
|
||||
|
||||
%install
|
||||
for i in ipu_tgl ipu_adl ipu_mtl; do
|
||||
pushd $i
|
||||
%make_install
|
||||
rm %{buildroot}%{_libdir}/$i/libcamhal.a
|
||||
### New icamerasrc must use hal_adaptor so drop libcamhal.pc!
|
||||
rm -r %{buildroot}%{_libdir}/$i/pkgconfig
|
||||
popd
|
||||
done
|
||||
|
||||
pushd hal_adaptor
|
||||
%make_install
|
||||
popd
|
||||
|
||||
### udev-rules set the ipu_xxx /run/v4l2-relayd cfg link + /dev/ipu-psys0 uaccess
|
||||
install -p -m 0644 -D %{SOURCE1} %{buildroot}%{_udevrulesdir}/60-intel-ipu6.rules
|
||||
|
||||
### v4l2-relayd configuration examples (mtl uses same config as adl)
|
||||
install -p -m 0644 %{SOURCE2} %{buildroot}%{_datadir}/defaults/etc/camera/ipu_adl/v4l2-relayd
|
||||
install -p -m 0644 %{SOURCE2} %{buildroot}%{_datadir}/defaults/etc/camera/ipu_mtl/v4l2-relayd
|
||||
install -p -m 0644 %{SOURCE3} %{buildroot}%{_datadir}/defaults/etc/camera/ipu_tgl/v4l2-relayd
|
||||
|
||||
### Make kmod-intel-ipu6 use /dev/video7 leaving /dev/video0 for loopback
|
||||
install -p -D -m 0644 %{SOURCE4} %{buildroot}%{_modprobedir}/icamera_ipu6_isys.conf
|
||||
|
||||
### Script to switch between proprietary and foss ipu6 stacks
|
||||
install -p -D -m 0755 %{SOURCE5} %{buildroot}%{_bindir}/ipu6-driver-select
|
||||
|
||||
|
||||
%posttrans
|
||||
### Ensure that v4l2-relayd service enabled if ipu6-driver-select is installed
|
||||
if [ ! -f /etc/modprobe.d/ipu6-driver-select.conf ]; then
|
||||
/usr/bin/ipu6-driver-select proprietary
|
||||
fi
|
||||
### Skip triggering if udevd isn't accessible
|
||||
if [ -S /run/udev/control ]; then
|
||||
/usr/bin/udevadm control --reload
|
||||
/usr/bin/udevadm trigger /sys/devices/pci0000:00/0000:00:05.0
|
||||
fi
|
||||
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%ghost %{_sysconfdir}/modprobe.d/ipu6-driver-select.conf
|
||||
%{_bindir}/ipu6-driver-select
|
||||
%{_libdir}/*/libcamhal.so*
|
||||
%{_libdir}/libhal_adaptor.so.*
|
||||
%{_datadir}/defaults
|
||||
%{_modprobedir}/icamera_ipu6_isys.conf
|
||||
%{_udevrulesdir}/60-intel-ipu6.rules
|
||||
|
||||
%files devel
|
||||
%{_includedir}/hal_adaptor
|
||||
%{_libdir}/libhal_adaptor.so
|
||||
%{_libdir}/pkgconfig/hal_adaptor.pc
|
||||
|
||||
|
||||
%changelog
|
||||
%autochangelog
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function show_help () {
|
||||
echo "Usage: 'ipu6-driver-select [ proprietary | open ]'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function needs_reboot () {
|
||||
echo "Reboot your system for the changes to take effect"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (( $# != 1 )); then
|
||||
show_help
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
"open")
|
||||
echo "blacklist icamera-ipu6" > /etc/modprobe.d/ipu6-driver-select.conf
|
||||
echo "blacklist icamera-ipu6-isys" >> /etc/modprobe.d/ipu6-driver-select.conf
|
||||
echo "blacklist icamera-ipu6-psys" >> /etc/modprobe.d/ipu6-driver-select.conf
|
||||
systemctl disable v4l2-relayd.service
|
||||
needs_reboot
|
||||
;;
|
||||
"proprietary")
|
||||
echo "blacklist intel-ipu6" > /etc/modprobe.d/ipu6-driver-select.conf
|
||||
systemctl enable v4l2-relayd.service
|
||||
needs_reboot
|
||||
;;
|
||||
*)
|
||||
show_help
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,15 @@
|
||||
# GStreamer source element name:
|
||||
VIDEOSRC="icamerasrc"
|
||||
#SPLASHSRC="filesrc location=/.../splash.png ! pngdec ! imagefreeze num-buffers=4 ! videoscale ! videoconvert"
|
||||
|
||||
# Output format, width, height, and frame rate:
|
||||
FORMAT=NV12
|
||||
WIDTH=1280
|
||||
HEIGHT=720
|
||||
FRAMERATE=30/1
|
||||
|
||||
# Virtual video device name:
|
||||
CARD_LABEL="Intel MIPI Camera"
|
||||
|
||||
# Extra options to pass to v4l2-relayd:
|
||||
#EXTRA_OPTS=-d
|
||||
@@ -0,0 +1,15 @@
|
||||
# GStreamer source element name:
|
||||
VIDEOSRC="icamerasrc"
|
||||
#SPLASHSRC="filesrc location=/.../splash.png ! pngdec ! imagefreeze num-buffers=4 ! videoscale ! videoconvert"
|
||||
|
||||
# Output format, width, height, and frame rate:
|
||||
FORMAT=YUY2
|
||||
WIDTH=1280
|
||||
HEIGHT=720
|
||||
FRAMERATE=30/1
|
||||
|
||||
# Virtual video device name:
|
||||
CARD_LABEL="Intel MIPI Camera"
|
||||
|
||||
# Extra options to pass to v4l2-relayd:
|
||||
#EXTRA_OPTS=-d
|
||||
Reference in New Issue
Block a user