Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b5f5469
media: s5p-mfc: signal the parsed stream format with V4L2_EVENT_SOURC…
angelrenefm Nov 13, 2026
e03b883
media: s5p-mfc: round private buffer sizes up to whole pages
angelrenefm Nov 13, 2026
1b4dc72
dt-bindings: media: s5p-mfc: Add the Google GS201 MFC
angelrenefm Nov 13, 2026
ac6db1e
media: s5p-mfc: Add support for the MFC v15 of Google GS201
angelrenefm Nov 13, 2026
4e9f064
media: s5p-mfc: decode with dynamic DPB on MFC v15
angelrenefm Nov 13, 2026
5ab72dd
arm64: dts: exynos: google: gs201: Add the MFC
angelrenefm Nov 15, 2026
b174e51
media: s5p-mfc: let dynamic DPB clients queue more capture buffers
angelrenefm Nov 13, 2026
2889c50
media: s5p-mfc: offer only H.264 decode on MFC v15
angelrenefm Nov 14, 2026
c241113
media: s5p-mfc: report the clamped OUTPUT buffer size
angelrenefm Nov 14, 2026
e47e933
media: s5p-mfc: report the coded format flags in ENUM_FMT
angelrenefm Nov 14, 2026
8e7f03b
media: s5p-mfc: don't lose the FRAME_DONE that stop_streaming waits for
angelrenefm Nov 14, 2026
2cbf7aa
media: s5p-mfc: raise the MFC clock while it is in use on MFC v15
angelrenefm Nov 14, 2026
8bdfda1
media: s5p-mfc: let the CAPTURE format be set while OUTPUT streams
angelrenefm Nov 14, 2026
d944a48
media: s5p-mfc: set the DPB plane sizes for every frame on MFC v15
angelrenefm Nov 14, 2026
0ee10ba
media: s5p-mfc: decode to single-buffer NV12 on MFC v15
angelrenefm Nov 14, 2026
f4722ab
media: s5p-mfc: enumerate the coded frame sizes on MFC v15
angelrenefm Nov 14, 2026
16d34cf
media: s5p-mfc: give MFC v15 the context buffer sizes of Google's driver
angelrenefm Nov 14, 2026
de0537d
media: s5p-mfc: keep the frame that came with the header on MFC v15
angelrenefm Nov 14, 2026
e030455
media: s5p-mfc: offer VP8, VP9 and HEVC decode on MFC v15
angelrenefm Nov 14, 2026
47386c9
media: s5p-mfc: leave capture buffers for display with dynamic DPB
angelrenefm Nov 14, 2026
da2c033
arm64: dts: exynos: google: gs201-panther: Give the MFC its memory pool
angelrenefm Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ properties:
compatible:
oneOf:
- enum:
- google,gs201-mfc # Google GS201 (MFC v15)
- samsung,exynos5433-mfc # Exynos5433
- samsung,mfc-v5 # Exynos4
- samsung,mfc-v6 # Exynos5
Expand Down Expand Up @@ -164,6 +165,7 @@ allOf:
compatible:
contains:
enum:
- google,gs201-mfc
- tesla,fsd-mfc
then:
properties:
Expand Down
28 changes: 28 additions & 0 deletions arch/arm64/boot/dts/exynos/google/gs201-panther.dts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@
reg = <0x0 0xfac00000 (1080 * 2400 * 4)>;
no-map;
};

/*
* MFC firmware, contexts and frames. The MFC takes 32-bit
* addresses, its System MMU is in bypass and the firmware
* rejects any buffer below its own base, so they all come from
* one contiguous pool below 4 GiB, firmware first. Reusable,
* so the pages serve movable allocations while no video is
* decoded. 256 MiB holds the firmware and a 4K stream decoded
* to single-buffer NV12.
*/
mfc_pool: mfc-pool {
compatible = "shared-dma-pool";
reusable;
size = <0x10000000>;
/* read with the root's #address-cells (2), not #size-cells */
alignment = <0x0 0x200000>;
alloc-ranges = <0x0 0x80000000 0x80000000>;
};
};
};

Expand Down Expand Up @@ -246,6 +264,16 @@
status = "okay";
};

/*
* Left disabled until its two System MMUs are described: in bypass, the
* closed firmware parsing untrusted video can reach all memory below
* 4 GiB. omarchy-mobile's device/panther overlay enables it for owners who
* want hardware video.
*/
&mfc {
memory-region = <&mfc_pool>;
};

&usbdrd31_phy {
status = "okay";
};
Expand Down
20 changes: 20 additions & 0 deletions arch/arm64/boot/dts/exynos/google/gs201.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,26 @@
};
};

/*
* MFC v15.6 video codec. Its two System MMUs (0x1c870000,
* 0x1c8a0000) are left in bypass and CMU_MFC is not described
* yet, so the firmware and its buffers need memory below 4 GiB
* from the board's memory-region, and the block runs on the
* power domain the bootloader leaves on. Its rate (and voltage)
* is the ACPM firmware's MFC DVFS domain. CMU_TOP's
* gout_cmu_mfc_mfc gate feeds the block too and stays on only
* because the boards boot with clk_ignore_unused: without that
* flag the first register access would hit an unclocked block.
*/
mfc: video-codec@1c8d0000 {
compatible = "google,gs201-mfc";
reg = <0x1c8d0000 0x10000>;
interrupts = <GIC_SPI 504 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&acpm_ipc GS201_CLK_ACPM_DVFS_MFC>;
clock-names = "mfc";
status = "disabled";
};

gpu: gpu@28000000 {
compatible = "google,gs201-mali", "arm,mali-valhall-csf";
reg = <0x28000000 0x480000>;
Expand Down
47 changes: 47 additions & 0 deletions drivers/media/platform/samsung/s5p-mfc/regs-mfc-v15.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Register definition file for Samsung MFC V15.x Interface (FIMV) driver
*
* MFC v15.6 is found in the Google GS201 SoC. Its register map is the v8+
* map used by v12; only the differences used by this driver are listed here.
*/

#ifndef _REGS_MFC_V15_H
#define _REGS_MFC_V15_H

#include <linux/sizes.h>
#include "regs-mfc-v12.h"

/* Firmware base for the non-secure firmware; 0x0054 is the secure one */
#define S5P_FIMV_RISC_NONSECURE_BASE_ADDR_V15 0x0068
#define S5P_FIMV_MFC_VERSION_V15 0xF028
#define S5P_FIMV_FW_STATUS_INFO_V15 0xF0A4
#define S5P_FIMV_FW_STATUS_READY_V15 BIT(0)

/* Dynamic DPB */
#define S5P_FIMV_D_NAL_START_OPTIONS_V15 0xF5AC
#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_UPPER_V15 0xF5B8
#define S5P_FIMV_D_DYNAMIC_DPB_FLAG_UPPER_V15 0xF5D4
#define S5P_FIMV_D_DYNAMIC_DPB_FLAG_LOWER_V15 0xF5D8
#define S5P_FIMV_D_USED_DPB_FLAG_UPPER_V15 0xF720
#define S5P_FIMV_D_USED_DPB_FLAG_LOWER_V15 0xF724
#define S5P_FIMV_D_INIT_BUF_OPT_DYNAMIC_DPB_V15 BIT(3)

/* MFCv15 variant defines */
#define MFC_VERSION_V15 0xF0
#define MFC_HW_VERSION_V15 0x15060000
#define MFC_NUM_PORTS_V15 1
#define MAX_FW_SIZE_V15 (SZ_1M)
#define MAX_CPB_SIZE_V15 (7 * SZ_1M)
#define MFC_OTHER_DEC_CTX_BUF_SIZE_V15 (60 * SZ_1K)
#define MFC_HEVC_ENC_CTX_BUF_SIZE_V15 (50 * SZ_1K)
#define MFC_OTHER_ENC_CTX_BUF_SIZE_V15 (50 * SZ_1K)

/*
* The firmware rejects every buffer below its own base address, so the
* firmware and all the driver's private buffers share one region with the
* firmware at its start.
*/
#define MFC_MEM_SIZE_V15 (64 * SZ_1M)

#endif /*_REGS_MFC_V15_H*/
101 changes: 98 additions & 3 deletions drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsigned int err)
ctx->luma_size);
vb2_set_plane_payload(&dst_buf->b->vb2_buf, 1,
ctx->chroma_size);
/* NV12 in one buffer: plane 0 holds the whole frame */
if (ctx->dst_fmt->num_planes == 1)
vb2_set_plane_payload(&dst_buf->b->vb2_buf, 0,
s5p_mfc_dec_nv12_size(ctx));
clear_bit(dst_buf->b->vb2_buf.index,
&ctx->dec_dst_flag);

Expand All @@ -381,6 +385,9 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
& S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
dec_frame_status = s5p_mfc_hw_call(dev->mfc_ops, get_dec_status, dev)
& S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK;
/* DPBs the firmware still holds (references or not yet displayed) */
if (dev->dynamic_dpb)
ctx->dpb_used = readl(dev->mfc_regs->d_used_dpb_flag_lower);
res_change = (s5p_mfc_hw_call(dev->mfc_ops, get_dspl_status, dev)
& S5P_FIMV_DEC_STATUS_RESOLUTION_MASK)
>> S5P_FIMV_DEC_STATUS_RESOLUTION_SHIFT;
Expand Down Expand Up @@ -540,13 +547,34 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
if (FW_HAS_E_MIN_SCRATCH_BUF(dev))
ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
get_min_scratch_buf_size, dev);
if (ctx->img_width == 0 || ctx->img_height == 0)
if (ctx->img_width == 0 || ctx->img_height == 0) {
ctx->state = MFCINST_ERROR;
else
} else {
static const struct v4l2_event ev_src_ch = {
.type = V4L2_EVENT_SOURCE_CHANGE,
.u.src_change.changes =
V4L2_EVENT_SRC_CH_RESOLUTION,
};

ctx->state = MFCINST_HEAD_PARSED;
/*
* The stateful decoder interface (dev-decoder.rst,
* "Initialization"): the client learns the stream's
* format from this event, not by calling G_FMT on
* CAPTURE in a loop.
*/
v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
}

/*
* The buffer the header came in may hold the first frame too.
* Keep it for decoding unless the header used it up: on MFC
* v15 for every codec, as the first HEVC IRAP picture and the
* first VP8/VP9 key frame share the header's buffer.
*/
if ((ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
ctx->codec_mode == S5P_MFC_CODEC_H264_MVC_DEC) &&
ctx->codec_mode == S5P_MFC_CODEC_H264_MVC_DEC ||
IS_MFCV15(dev)) &&
!list_empty(&ctx->src_queue)) {
struct s5p_mfc_buf *src_buf;

Expand Down Expand Up @@ -1219,10 +1247,28 @@ static int s5p_mfc_configure_common_memory(struct s5p_mfc_dev *mfc_dev)
{
struct device *dev = &mfc_dev->plat_dev->dev;
unsigned long mem_size = SZ_4M;
int ret;

if (IS_ENABLED(CONFIG_DMA_CMA) || exynos_is_iommu_available(dev))
mem_size = SZ_8M;

if (IS_MFCV15(mfc_dev)) {
/*
* The firmware sees physical addresses through 32-bit
* registers and rejects buffers below its own base, so all of
* the private buffers (codec buffers included) live in this
* region, after the firmware. An optional "memory-region"
* also serves the vb2 buffers from the same pool.
*/
mem_size = MFC_MEM_SIZE_V15;
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret)
return ret;
ret = of_reserved_mem_device_init(dev);
if (ret && ret != -ENODEV)
return ret;
}

if (mfc_mem_size)
mem_size = memparse(mfc_mem_size, NULL);

Expand All @@ -1234,6 +1280,8 @@ static int s5p_mfc_configure_common_memory(struct s5p_mfc_dev *mfc_dev)
&mfc_dev->mem_base, GFP_KERNEL);
if (!mfc_dev->mem_virt) {
bitmap_free(mfc_dev->mem_bitmap);
if (IS_MFCV15(mfc_dev))
of_reserved_mem_device_release(dev);
dev_err(dev, "failed to preallocate %ld MiB for the firmware and context buffers\n",
(mem_size / SZ_1M));
return -ENOMEM;
Expand Down Expand Up @@ -1274,6 +1322,8 @@ static void s5p_mfc_unconfigure_common_memory(struct s5p_mfc_dev *mfc_dev)
mfc_dev->mem_base);
bitmap_free(mfc_dev->mem_bitmap);
vb2_dma_contig_clear_max_seg_size(dev);
if (IS_MFCV15(mfc_dev))
of_reserved_mem_device_release(dev);
}

static int s5p_mfc_configure_dma_memory(struct s5p_mfc_dev *mfc_dev)
Expand Down Expand Up @@ -1322,6 +1372,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to get device MFC hardware variant information\n");
return -ENOENT;
}
dev->dynamic_dpb = IS_MFCV15(dev);

dev->regs_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(dev->regs_base))
Expand Down Expand Up @@ -1419,6 +1470,18 @@ static int s5p_mfc_probe(struct platform_device *pdev)
v4l2_info(&dev->v4l2_dev,
"decoder registered as /dev/video%d\n", dev->vfd_dec->num);

/*
* The v15 encoder's registers differ from v12's (0xF770/0xF774 clash
* with the decoder's) and nothing here programs them yet: no encoder
* node rather than one that hangs the firmware.
*/
if (IS_MFCV15(dev)) {
video_device_release(dev->vfd_enc);
dev->vfd_enc = NULL;
pr_debug("%s--\n", __func__);
return 0;
}

ret = video_register_device(dev->vfd_enc, VFL_TYPE_VIDEO, 0);
if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
Expand Down Expand Up @@ -1705,6 +1768,35 @@ static struct s5p_mfc_variant mfc_drvdata_v12 = {
.num_clocks = 1,
};

/* Google's gs201 sizes (mfc_ctx_buf_size in its exynos-mfc driver) */
static const struct s5p_mfc_buf_size_v6 mfc_buf_size_v15 = {
.dev_ctx = MFC_CTX_BUF_SIZE_V12,
.h264_dec_ctx = MFC_H264_DEC_CTX_BUF_SIZE_V12,
.other_dec_ctx = MFC_OTHER_DEC_CTX_BUF_SIZE_V15,
.h264_enc_ctx = MFC_H264_ENC_CTX_BUF_SIZE_V12,
.hevc_enc_ctx = MFC_HEVC_ENC_CTX_BUF_SIZE_V15,
.other_enc_ctx = MFC_OTHER_ENC_CTX_BUF_SIZE_V15,
};

static const struct s5p_mfc_buf_size buf_size_v15 = {
.fw = MAX_FW_SIZE_V15,
.cpb = MAX_CPB_SIZE_V15,
.priv = &mfc_buf_size_v15,
};

static const struct s5p_mfc_variant mfc_drvdata_v15 = {
.version = MFC_VERSION_V15,
.version_bit = MFC_V15_BIT,
.port_num = MFC_NUM_PORTS_V15,
.buf_size = &buf_size_v15,
.fw_name[0] = "s5p-mfc-v15.fw",
.clk_names = {"mfc"},
.num_clocks = 1,
.clocks_optional = true,
/* The top MFC rate of Google's gs201 tables (mfc_freqs) */
.active_clk_rate = 666000000,
};

static const struct of_device_id exynos_mfc_match[] = {
{
.compatible = "samsung,mfc-v5",
Expand All @@ -1730,6 +1822,9 @@ static const struct of_device_id exynos_mfc_match[] = {
}, {
.compatible = "tesla,fsd-mfc",
.data = &mfc_drvdata_v12,
}, {
.compatible = "google,gs201-mfc",
.data = &mfc_drvdata_v15,
},
{},
};
Expand Down
Loading