> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 构建视频源组件

视频软件栈由 GStreamer 插件和 V4L2 组件组成。

V4L2 源组件作为整个软件构建包的一部分，包含在 `meta-qcom-multimedia-image` 或 `qcom-multimedia-proprietary-image` 镜像中。有关同步和构建 `meta-qcom-multimedia` 镜像过程的更多信息，请参阅 [Qualcomm Linux 构建指南](https://dragonwingdocs.qualcomm.com/Key-Documents/Firmware-Guide/build-firmware)。

## **验证视频软件**

本节提供有关视频 recipe 的信息以及构建 VPU 驱动所需的步骤。

以下 BitBake recipe 文件用于在 `qcom-multimedia-proprietary-image` 中构建 Adreno VPU 驱动：

> `<meta-qcom workspace>/recipes-kernel/iris-video-module/iris-video-dlkm_git_<version>.bb`

<div
  style={{
borderLeft: '4px solid #3B5BDB',
backgroundColor: '#EEF2FF',
padding: '12px 16px',
borderRadius: '4px',
marginTop: '12px',
marginBottom: '16px'
}}
>
  <p style={{ margin: '0 0 6px 0', fontWeight: 'bold', color: '#1E3A8A' }}>注意：</p>
  <p style={{ margin: 0 }}><code>version</code> 是该 recipe 的最新标签。例如：<code>1.0.10</code>，即 <code>iris-video-dlkm\_git\_1.0.10.bb</code>。</p>
</div>

### **VPU 驱动构建说明 - `qcom-multimedia-proprietary-image`**

以下是将代码更改应用于视频驱动的说明：

1. 按照以下步骤创建补丁文件：
   > a. 使用以下命令克隆视频驱动仓库：
   >
   > ```text theme={null}
   > git clone https://github.com/qualcomm-linux/video-driver.git -b video.qclinux.main
   > ```
   >
   > b. 使用以下命令切换到克隆的仓库目录：
   >
   > ```text theme={null}
   > cd video-driver
   > ```
   >
   > c. 进行所需的代码更改并在本地提交更改。
   >
   > d. 使用以下命令从最新提交创建补丁文件：
   >
   > ```text theme={null}
   > git format-patch HEAD~1
   > ```
   >
   > e. 打开生成的补丁文件，并在 signed-off 之后添加以下行：
   >
   > ```text theme={null}
   > Upstream-Status: Pending
   > ```
   >
   > f. 将补丁文件复制到 `iris-video-dlkm` recipe 中的以下位置。
   >
   > ```text theme={null}
   > recipes-kernel/iris-video-module/iris-video-dlkm/
   > ```
2. 更新 `recipes-kernel/iris-video-module/iris-video-dlkm_<version>.bb` 文件中的 `SRC_URI`，以包含补丁文件，如下所示：
   ```text theme={null}
   SRC_URI = " \
       git://github.com/qualcomm-linux/video-driver.git;protocol=https;branch=video.qclinux.main \
       file://0001-video-driver-follow-v4l2_fh_add-_del-API-changes.patch \
       file://0001-video-driver-stop-playing-tricks-with-Kbuild.patch \
   "
   ```
3. 要构建 Adreno 视频驱动，请运行以下命令：
   ```text theme={null}
   kas shell meta-qcom/ci/<MACHINE>:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/linux-qcom-6.18.yml
   bitbake iris-video-dlkm
   ```
   例如：
   ```text theme={null}
   kas shell meta-qcom/ci/rb3gen2-core-kit.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/linux-qcom-6.18.yml:meta-qcom/ci/lock.yml
   bitbake iris-video-dlkm
   ```
   <div style={{ borderLeft: '4px solid #3B5BDB', backgroundColor: '#EEF2FF', padding: '12px 16px', borderRadius: '4px', marginTop: '12px' }}>
     <p style={{ margin: '0 0 6px 0', fontWeight: 'bold', color: '#1E3A8A' }}>注意：</p>
     <p style={{ margin: 0 }}>有关各种 <code>\<machine></code> 组合，请参阅<a href="https://dragonwingdocs.qualcomm.com/Key-Documents/Software-Release-Notes/introduction" style={{ color: '#1D4ED8', textDecoration: 'none' }}>发行说明</a>。</p>
   </div>
4. 编译后，对应的 `iris_vpu.ko` 位于：
   `<meta-qcom workspace>\build\tmp\sysroots-components\<MACHINE>\iris-video-dlkm\usr\lib\modules\<kernel version>\updates\video\>`
5. 进入 SSH shell，并使用以下命令将编译好的库传输到设备：

   <div style={{ borderLeft: '4px solid #3B5BDB', backgroundColor: '#EEF2FF', padding: '12px 16px', borderRadius: '4px', marginBottom: '12px' }}>
     <p style={{ margin: '0 0 6px 0', fontWeight: 'bold', color: '#1E3A8A' }}>注意：</p>
     <p style={{ margin: 0 }}>您必须启动 SSH shell 才能访问 Linux 主机计算机。有关说明，请参阅***使用 SSH 登录*** </p>

     <Expandable title="使用 SSH 登录">
       <SignInUsingSsh />
     </Expandable>
   </div>

   ```text theme={null}
   mount -o rw,remount /
   ```
6. 根据您的 `<workspace-path>` 和 `<IP address of the device>` 修改以下命令，并在 Linux 主机计算机上运行以下命令：
   ```text theme={null}
   scp <meta-qcom workspace>\build\tmp\sysroots-components\<MACHINE>\iris-video-dlkm\usr\lib\modules\<kernel version>\updates\video\iris_vpu.ko root@<IP address of the device>/lib/modules/<kernel version>/updates/video/
   ```
   <div style={{ borderLeft: '4px solid #3B5BDB', backgroundColor: '#EEF2FF', padding: '12px 16px', borderRadius: '4px', marginTop: '12px' }}>
     <p style={{ margin: '0 0 6px 0', fontWeight: 'bold', color: '#1E3A8A' }}>注意：</p>
     <p style={{ margin: 0 }}>当提示输入密码时，请输入 <code>oelinux123</code>。</p>
   </div>
7. 要查看更新后的调试更改，请先关闭设备电源，然后再打开设备电源。

### **VPU 驱动构建说明 - `qcom-multimedia-image`**

以下是将代码更改应用于视频驱动的说明：

1. 按照以下步骤创建补丁文件：
   > a. 克隆包含视频驱动的内核：
   >
   > ```text theme={null}
   > git clone https://github.com/qualcomm-linux/kernel.git
   > ```
   >
   > b. 切换到克隆的仓库目录：
   >
   > ```text theme={null}
   > cd drivers/media/platform/qcom
   > ```
   >
   > * QCS615 使用：`drivers/media/platform/qcom/venus`。
   > * Dragonwing IQ-8275/Dragonwing IQ-9075/QCS6490 使用：`drivers/media/platform/qcom/iris`
   >
   > c. 进行所需的代码更改并在本地提交更改。
   >
   > d. 从最新提交创建补丁文件：
   >
   > ```text theme={null}
   > git format-patch HEAD~1
   > ```
   >
   > e. 打开生成的补丁文件，并在 Signed-off 之后添加以下行：
   >
   > ```text theme={null}
   > Upstream-Status: Pending
   > ```
   >
   > f. 将补丁文件复制到内核 recipe 中的以下位置。
   >
   > ```text theme={null}
   > <meta qcom workspace>\recipes-kernel\linux\linux-qcom-<kernel version>_git.bb
   > ```
2. 更新 recipe `(.bb)` 文件中的 `SRC_URI`，以包含补丁文件，如下所示：
   ```text theme={null}
   SRC_URI = "git://github.com/qualcomm-linux/kernel.git;${SRCBRANCH};protocol=https"
   SRC_URI += "file://0001-tools-use-basename-to-identify-file-in-gen-mach-type.patch"
   SRC_URI += "file://0001-PR_308.patch"
   ```
3. 要构建 Adreno 视频驱动，请运行以下命令：
   ```text theme={null}
   kas shell meta-qcom/ci/<MACHINE>:meta-qcom/ci/qcom-distro-image.yml:meta-qcom/ci/linux-qcom-6.18.yml
   bitbake qcom-multimedia-image
   ```
   例如：
   ```text theme={null}
   kas shell meta-qcom/ci/rb3gen2-core-kit.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/linux-qcom-6.18.yml:meta-qcom/ci/lock.yml
   bitbake qcom-multimedia-image
   ```
   <div style={{ borderLeft: '4px solid #3B5BDB', backgroundColor: '#EEF2FF', padding: '12px 16px', borderRadius: '4px', marginTop: '12px' }}>
     <p style={{ margin: '0 0 6px 0', fontWeight: 'bold', color: '#1E3A8A' }}>注意：</p>
     <p style={{ margin: 0 }}>有关不同的 <code>\<machine></code> 组合，请参阅<a href="https://dragonwingdocs.qualcomm.com/Key-Documents/Software-Release-Notes/introduction" style={{ color: '#1D4ED8', textDecoration: 'none' }}>发行说明</a>。</p>
   </div>
4. 烧录 `qcom-multimedia-image`。有关更多信息，请参阅 [Qualcomm Linux 构建指南](https://dragonwingdocs.qualcomm.com/Key-Documents/Firmware-Guide/build-firmware)。

## **视频 GStreamer 插件**

Qualcomm IM SDK 包含用于视频解码和编码的 GStreamer 插件。下载 Qualcomm IM SDK 即可使用 `v4l2h264dec`、`v4l2h265dec`、`v4l2h264enc`、`v4l2h265enc` 和 `v4l2vp9dec` 插件。

下表列出了 GStreamer 插件及其对应的参考链接：

<div
  style={{
border: '2px solid #0050D8',
borderRadius: '16px',
padding: '24px',
marginTop: '25px',
backgroundColor: '#FFFFFF',
boxShadow: '0 0 25px rgba(0, 80, 216, 0.15)'
}}
>
  <div style={{ borderRadius: '12px', overflow: 'hidden', border: '2px solid #0050D8', width: '100%' }}>
    <div
      style={{
  background: 'linear-gradient(90deg, #0050D8 0%, #0037A5 100%)',
  color: 'white',
  padding: '14px',
  textAlign: 'center',
  fontWeight: 'bold'
}}
    >
      表：视频 GStreamer 插件
    </div>

    <div style={{ width: '100%', display: 'block' }}>
      <table
        style={{
      display: 'table',
      width: '100%',
      minWidth: '100%',
      maxWidth: '100%',
      borderCollapse: 'collapse',
      backgroundColor: 'white',
      tableLayout: 'fixed',
      boxSizing: 'border-box'
    }}
      >
        <colgroup>
          <col style={{ width: '30%' }} />

          <col style={{ width: '70%' }} />
        </colgroup>

        <thead>
          <tr style={{ backgroundColor: '#F8FAFC' }}>
            <th
              style={{
          border: '1px solid #E5E7EB',
          padding: '16px',
          textAlign: 'center',
          fontWeight: 'bold',
          color: '#111827',
          boxSizing: 'border-box'
        }}
            >
              插件
            </th>

            <th
              style={{
          border: '1px solid #E5E7EB',
          padding: '16px',
          textAlign: 'center',
          fontWeight: 'bold',
          color: '#111827',
          boxSizing: 'border-box'
        }}
            >
              描述/参考链接
            </th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', color: '#111827', fontWeight: '600', boxSizing: 'border-box' }}>
              v4l2h264dec
            </td>

            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', boxSizing: 'border-box' }}>
              [解码 H.264 视频流](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/plugin-reference/v4l2h264dec)
            </td>
          </tr>

          <tr>
            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', color: '#111827', fontWeight: '600', boxSizing: 'border-box' }}>
              v4l2h265dec
            </td>

            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', boxSizing: 'border-box' }}>
              [解码 H.265 视频流](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/plugin-reference/v4l2h265dec)
            </td>
          </tr>

          <tr>
            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', color: '#111827', fontWeight: '600', boxSizing: 'border-box' }}>
              v4l2h264enc
            </td>

            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', boxSizing: 'border-box' }}>
              [编码 H.264 视频流](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/plugin-reference/v4l2h264enc)
            </td>
          </tr>

          <tr>
            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', color: '#111827', fontWeight: '600', boxSizing: 'border-box' }}>
              v4l2h265enc
            </td>

            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', boxSizing: 'border-box' }}>
              [编码 H.265 视频流](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/plugin-reference/v4l2h265enc)
            </td>
          </tr>

          <tr>
            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', color: '#111827', fontWeight: '600', boxSizing: 'border-box' }}>
              v4l2vp9dec
            </td>

            <td style={{ border: '1px solid #E5E7EB', padding: '14px 16px', boxSizing: 'border-box' }}>
              [解码 VP9 视频流](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/plugin-reference/v4l2vp9dec)
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

有关下载和构建步骤的信息，请参阅 [Qualcomm 智能多媒体 SDK (IM SDK) 快速入门](https://dragonwingdocs.qualcomm.com/SDKs/IMSDK/quickstart)。

## **后续步骤**

* [视频故障排除](https://dragonwingdocs.qualcomm.com/Technologies/Video/troubleshoot-video)
