Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
felix920506 committed Nov 9, 2024
1 parent bdab9ad commit a1ad5e5
Showing 1 changed file with 62 additions and 63 deletions.
125 changes: 62 additions & 63 deletions docs/general/administration/hardware-acceleration/rockchip.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,75 +237,74 @@ LXC setup idea is a bit similar to docker - you need to pass the **device files*

1. To find the list of device files to pass inside container, use the next one-liner in Linux host:

```shell
for dev in dri dma_heap mali0 rga mpp_service iep mpp-service vpu_service vpu-service hevc_service hevc-service rkvdec rkvenc vepu h265e ; do [ -e "/dev/$dev" ] && echo "device /dev/$dev"; done
```

```shell
device /dev/dri
device /dev/dma_heap
device /dev/mali0
device /dev/rga
device /dev/mpp_service
```

Example of the minumum requried extra (not full) container configuration to make VPU hardware accelearion working is presented below:

```shell
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dma_heap dev/dma_heap none bind,optional,create=dir
lxc.mount.entry: /dev/mpp_service dev/mpp_service none bind,optional,create=file
lxc.mount.entry: /dev/rga dev/rga none bind,optional,create=file
lxc.mount.entry: /dev/mali0 dev/mali0 none bind,optional,create=file
lxc.cgroup2.devices.allow: a
```

Use [lxc.container.conf](https://linuxcontainers.org/lxc/manpages//man5/lxc.container.conf.5.html) man page for reference, what _lxc.mount.entry_ and _lxc.cgroup2.devices_ options are used for.
If you want - and you have concerns about it - you can replace _lxc.cgroup2.devices.allow: a_ rule with more restricted "_allowlist device program_" (example could be found inside the same man page) enumerating each character VPU device, that container namespace should have access inside the host.
```shell
for dev in dri dma_heap mali0 rga mpp_service iep mpp-service vpu_service vpu-service hevc_service hevc-service rkvdec rkvenc vepu h265e ; do [ -e "/dev/$dev" ] && echo "device /dev/$dev"; done
```

:::warning
```shell
device /dev/dri
device /dev/dma_heap
device /dev/mali0
device /dev/rga
device /dev/mpp_service
```

Privileged LXC containers are considered unsafe by design - read more [here](https://linuxcontainers.org/lxc/security/). This guide however does not cover steps required to make jellyfin VPU hardware acceleration working in unprivileged container.
Example of the minumum requried extra (not full) container configuration to make VPU hardware accelearion working is presented below:

:::
```shell
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dma_heap dev/dma_heap none bind,optional,create=dir
lxc.mount.entry: /dev/mpp_service dev/mpp_service none bind,optional,create=file
lxc.mount.entry: /dev/rga dev/rga none bind,optional,create=file
lxc.mount.entry: /dev/mali0 dev/mali0 none bind,optional,create=file
lxc.cgroup2.devices.allow: a
```

Use [lxc.container.conf](https://linuxcontainers.org/lxc/manpages//man5/lxc.container.conf.5.html) man page for reference, what _lxc.mount.entry_ and _lxc.cgroup2.devices_ options are used for.
If you want - and you have concerns about it - you can replace _lxc.cgroup2.devices.allow: a_ rule with more restricted "_allowlist device program_" (example could be found inside the same man page) enumerating each character VPU device, that container namespace should have access inside the host.

:::warning

Privileged LXC containers are considered unsafe by design - read more [here](https://linuxcontainers.org/lxc/security/). This guide however does not cover steps required to make jellyfin VPU hardware acceleration working in unprivileged container.

:::

2. Install supported [jellyfin package](https://jellyfin.org/docs/general/installation/linux) into LXC container or optionally you can even use an official docker image inside LXC container.
3. Verify OpenCL runtime status as following - example is collected from LXC runtime of Ubuntu Jammy - steps are the same as docker deployments:

- _libmali user-space drivers should be installed inside LXC container, otherwise opencl=ocl@rk device won't be initialized_

```shell
dpkg -l | egrep "libmali|clinfo|jellyfin"
```

```shell
ii clinfo 3.0.21.02.21-1 arm64 Query OpenCL system information
ii jellyfin 10.10.1+ubu2204 all Jellyfin is the Free Software Media System.
ii jellyfin-ffmpeg7 7.0.2-5-jammy arm64 Tools for transcoding, streaming and playing of multimedia files
ii jellyfin-server 10.10.1+ubu2204 arm64 Jellyfin is the Free Software Media System.
ii jellyfin-web 10.10.1+ubu2204 all Jellyfin is the Free Software Media System.
ii libmali-valhall-g610-g13p0-gbm 1.9-1 arm64 Mali GPU User-Space Binary Drivers
```


```shell
sudo /usr/lib/jellyfin-ffmpeg/ffmpeg -v debug -init_hw_device rkmpp=rk -init_hw_device opencl=ocl@rk
```

```shell
< -- snip -- >
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
[AVHWDeviceContext @ 0x55a5b30a00] 1 OpenCL platforms found.
[AVHWDeviceContext @ 0x55a5b30a00] 1 OpenCL devices found on platform "ARM Platform".
[AVHWDeviceContext @ 0x55a5b30a00] 0.0: ARM Platform / Mali-G610 r0p0
[AVHWDeviceContext @ 0x55a5b30a00] cl_arm_import_memory found as platform extension.
[AVHWDeviceContext @ 0x55a5b30a00] cl_khr_image2d_from_buffer found as platform extension.
[AVHWDeviceContext @ 0x55a5b30a00] DRM to OpenCL mapping on ARM function found (clImportMemoryARM).
Successfully parsed a group of options.
< -- snip -- >
```

3. Enable RKMPP in Jellyfin GUI, check supported (and desired) codecs and uncheck the unsupported - see [Select SoC/VPU Hardware](#select-socvpu-hardware) section for more details.

- _libmali user-space drivers should be installed inside LXC container, otherwise opencl=ocl@rk device won't be initialized_

```shell
dpkg -l | egrep "libmali|clinfo|jellyfin"
```

```shell
ii clinfo 3.0.21.02.21-1 arm64 Query OpenCL system information
ii jellyfin 10.10.1+ubu2204 all Jellyfin is the Free Software Media System.
ii jellyfin-ffmpeg7 7.0.2-5-jammy arm64 Tools for transcoding, streaming and playing of multimedia files
ii jellyfin-server 10.10.1+ubu2204 arm64 Jellyfin is the Free Software Media System.
ii jellyfin-web 10.10.1+ubu2204 all Jellyfin is the Free Software Media System.
ii libmali-valhall-g610-g13p0-gbm 1.9-1 arm64 Mali GPU User-Space Binary Drivers
```

```shell
sudo /usr/lib/jellyfin-ffmpeg/ffmpeg -v debug -init_hw_device rkmpp=rk -init_hw_device opencl=ocl@rk
```

```shell
< -- snip -- >
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
[AVHWDeviceContext @ 0x55a5b30a00] 1 OpenCL platforms found.
[AVHWDeviceContext @ 0x55a5b30a00] 1 OpenCL devices found on platform "ARM Platform".
[AVHWDeviceContext @ 0x55a5b30a00] 0.0: ARM Platform / Mali-G610 r0p0
[AVHWDeviceContext @ 0x55a5b30a00] cl_arm_import_memory found as platform extension.
[AVHWDeviceContext @ 0x55a5b30a00] cl_khr_image2d_from_buffer found as platform extension.
[AVHWDeviceContext @ 0x55a5b30a00] DRM to OpenCL mapping on ARM function found (clImportMemoryARM).
Successfully parsed a group of options.
< -- snip -- >
```

4. Enable RKMPP in Jellyfin GUI, check supported (and desired) codecs and uncheck the unsupported - see [Select SoC/VPU Hardware](#select-socvpu-hardware) section for more details.

### Verify On Linux

Expand Down

0 comments on commit a1ad5e5

Please sign in to comment.