.. include:: /keyword.rst .. _hdmirx-common: ======= HDMI-RX ======= .. contents:: Sections :local: :depth: 2 .. note:: HDMI-RX is only available on |G1200-EVK|. .. note:: Command operations and test results presented in this chapter are based on the `IoT Yocto v23.1` and |G1200-EVK-REF-BOARD| board. High-Definition Multimedia Interface Receiver (HDMI-RX) ======================================================= The High-definition Multimedia Interface (HDMI) RX IP supports video data and audio packet data reception according to the HDMI standard specification. The HDMIRX module receives uncompressed digital data streams in TMDS format from an HDMI-compatible source device and decodes the video, audio and control data based on HDMI Specification 2.0b. Architecture ------------ .. figure:: /_asset/hdmirx/architecture.png :alt: HDMI-RX Architecture :align: center :width: 75% HDMI-RX Architecture The three major drivers for the HDMI-RX: * HDMIRX driver - HDMIRX HW control * V4L2 capture device - for receiving video frame * ALSA audio source - for receiving audio bitstream While HDMI timing(video) locked, a `V4L2`_ capture device, named ``mdp-capture``, will be registered. And also, ALSA source ``hdmi_rx`` can be used for recording after HDMI-RX audio locked. Features -------- The HDMIRX supports the following video features: * Deep Color mode: up to 10 bits * Maximum operating frequency: up to 594 MHz * Video color space options: RGB 4:4:4, YCbCr 4:2:2 (ITU BT.601 and BT.709), YCbCr 4:4:4 (ITU BT.601 and BT.709), and YCbCr 4:2:0 * SD mode resolutions: * 720 x 480p @ 59.94/60 Hz * 720 x 576p @ 50 Hz * HD/FHD/UFHD mode resolutions: * 1280 x 720p @ 59.94/60/50 Hz * 1920 x 1080p @ 59.94/60/50 Hz * 1920 x 1080p @ 23.97/24 Hz * 1920 x 1080p @ 25 Hz * 1920 x 1080p @ 29.97/30 Hz * 3840 x 2160p @ 29.97/30 Hz * 3840 x 2160p @ 59.94/60/50 Hz The HDMIRX supports the following audio features: * Single Linear Pulse Code (LPC) S/PDIF IEC60958 (up to 192 kHz and up to 24 bits), 32 kHz, 44.1 kHz, 48 kHz, 88.2 kHz, 96 kHz, 176.4 kHz, 192 kHz * Multi-channel Pulse Code Modulation (PCM) input (maximum 8 channels) Additionally, the HDMIRX supports the following features: * Internal Extended Display Identification Data (EDID), 512 bytes * Compatibility with Digital Visual Interface (DVI) 1.0 * Single Hot-Plug Detect (HPD) line .. _feature-hdmi-rx-tool: HDMI-RX Tool ============ The ``hdmirx_tool`` is an executable program that used for checking HDMIRX information. It includes following function: * Enable / disable HDMIRX * Check HDMI cable connection * Get device info * Check video signal (locked / unlocked) * Get video info * Check audio signal (locked / unlocked) * Get audio info * Retrieve HDMIRX events (via UEVENT) .. figure:: /_asset/hdmirx/hdmirx_tool-01-menu.png :alt: HDMI-RX Tool Menu :align: center :width: 35% HDMI-RX Tool Menu Manual controlled with input key: * ‘1’ to enable HDMIRX (HW power on) * ‘2’ to disable HDMIRX (HW power off) * ‘4’ to check `cable status` .. figure:: /_asset/hdmirx/hdmirx_tool-04-cable-status.png :alt: `hdmirx_tool` Cable Status :align: center :width: 45% ``hdmirx_tool`` Cable Status * ‘3’ to get `device info` .. figure:: /_asset/hdmirx/hdmirx_tool-05-device-info.png :alt: `hdmirx_tool` Device Info :align: center :width: 45% ``hdmirx_tool`` Cable Status * ‘6’ to check `video lock status` .. figure:: /_asset/hdmirx/hdmirx_tool-06-video-lock-status.png :alt: `hdmirx_tool` Video Lock Status :align: center :width: 50% ``hdmirx_tool`` Video Lock Status * ‘5’ to get `video info` .. figure:: /_asset/hdmirx/hdmirx_tool-07-video-info.png :alt: `hdmirx_tool` Video Info :align: center :width: 50% ``hdmirx_tool`` Video Info * ‘8’ to check `audio lock status` .. figure:: /_asset/hdmirx/hdmirx_tool-08-audio-lock-status.png :alt: `hdmirx_tool` Audio Lock Status :align: center :width: 50% ``hdmirx_tool`` Audio Lock Status * ‘7’ to get `audio info` .. figure:: /_asset/hdmirx/hdmirx_tool-09-audio-info.png :alt: `hdmirx_tool` Audio Info :align: center :width: 70% ``hdmirx_tool`` Audio Info * ‘a’/‘b’ to start/stop observing (notification via UEVENT) .. figure:: /_asset/hdmirx/hdmirx_tool-10-start-observing.png :alt: `hdmirx_tool` Start Observing :align: center :width: 22% ``hdmirx_tool`` Start Observing * Example – Observing “Cable Plug-out” flow .. figure:: /_asset/hdmirx/hdmirx_tool-12-uevent-plugout-cable.png :alt: `hdmirx_tool` Unplug Cable :align: center :width: 95% Unplug Cable Flow .. figure:: /_asset/hdmirx/hdmirx_tool-11-notify.png :alt: `hdmirx_tool` Notifications :align: center :width: 20% Notifications .. _feature-hdmirx-gstreamer: HDMI-RX Usage with GStreamer ============================ On |IOT-YOCTO|, the HDMIRX video capture device is register as a `V4L2`_ capture device. `GStreamer`_ is integrated to provide wrapper plugins over the V4L2 interface and to assist in setting up video processing pipelines. .. _V4L2: https://www.kernel.org/doc/html/v5.15/userspace-api/media/v4l/v4l2.html#v4l2spec .. _GStreamer: https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c .. note:: The input source of following examples is 4K60fps video and 48KHz-24bits-2ch audio. The ``mdp-capture`` device is registered as ``/dev/video5`` and the ALSA device is ``hdmi_rx``. Example: Capture Preview ------------------------ The following examples use GStreamer ``v4l2src`` plug-in for the HDMI-RX video capture device. .. note:: The output format and size are MUST given in the command. Please refer to :ref:`MDP Video Capture formats ` for the format list. .. prompt:: bash # auto # gst-launch-1.0 -v v4l2src device=/dev/video5 ! video/x-raw,width=3840,height=2160,format=YUY2 ! queue ! \ fpsdisplaysink video-sink=waylandsink text-overlay=false .. figure:: /_asset/hdmirx/capture-preview-performace.png :alt: capture-preview-performace :align: center :width: 60% Capture Preview with FPS Info Example: Video and Audio Recording ---------------------------------- The following examples use GStreamer ``v4l2h264enc`` plug-in for hardware-accelerated video encoding, ``alsasrc`` for ALSA audio source to encode & mux a 10 seconds video. .. prompt:: bash # auto # gst-launch-1.0 -v v4l2src device=/dev/video5 num-buffers=600 ! video/x-raw,width=3840,height=2160,format=NV12 ! queue ! \ v4l2h264enc output-io-mode=dmabuf-import capture-io-mode=mmap ! queue ! h264parse ! qtmux name=mux ! filesink location=out_3840x2160.mp4 \ alsasrc device=hdmi_rx num-buffers=1000 ! audio/x-raw,format=S24LE,rate=48000,channels=2 ! audioconvert ! queue ! mux.audio_0 Example: Video Encoding with Snapshot ------------------------------------- To encode 4K60fps video for 10 sec and do snapshot (by ``v4l2jpegenc``) every second. .. prompt:: bash # auto # gst-launch-1.0 -v v4l2src device=/dev/video5 io-mode=dmabuf num-buffers=600 ! video/x-raw,width=3840,height=2160,format=NV12 ! tee name=t \ t. ! queue ! videorate ! 'video/x-raw,framerate=1/1' ! v4l2jpegenc ! jpegparse ! multifilesink location=ss_%03d.jpeg \ t. ! queue ! v4l2h264enc output-io-mode=dmabuf-import capture-io-mode=mmap ! queue ! h264parse ! matroskamux ! filesink location=h264.mkv