From nobody Thu Oct 2 02:18:08 2025 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7471224CEE8 for ; Tue, 30 Sep 2025 03:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759204564; cv=none; b=MTXjeSpbqMO4l+pAm5W57xZ6BK0pXO0eMWdhEiP6HJMvZJdEMSBOD1iHuVJqsHTlzcIuNKZgYRbUI9bAFO4uyQoGNVvQhZuB7L2c0ztq9so85TfMmzH1MB+RBSvmS27Dfk+XumGCi0I3gS6d2AYd4Izkll7xbs9NebwNBaSa0Jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759204564; c=relaxed/simple; bh=Am5/2bFOpxd6fg7eUXfGB5nSzGmXmMVZoHrCMNKOzy4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=lZp092s5iqUFA9HfXlo4g2WfEXvnZdH6dJRHYHX4Hm2wq7ib3WYXvUw90Zv+25Noh8b2im6fPaIwPx189PnsXJuGgbokDzaH8ZGeWT9uN0rGZrVvpWb5qDSrwFTIV8V6TP4d7wIaV5UodhmpV19S6l/G20FWXMjv7Et6CRyCmH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=bwKPpVWC; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="bwKPpVWC" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20250930035559epoutp0458dd02e638fc807aa81a1ef80313b32a~p8zoEWH0j2001720017epoutp04P for ; Tue, 30 Sep 2025 03:55:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20250930035559epoutp0458dd02e638fc807aa81a1ef80313b32a~p8zoEWH0j2001720017epoutp04P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1759204560; bh=fsLERXRDyCNEbx47LNmWUKpYJ8hnbQ5zgukn3NjaXDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bwKPpVWC+wivdYROWHtesymjGoIStzcQzuzRfrzFP1VoC3k9jx7vhjPpwF+db1d9/ XCsWA1oTHxqJfKpSmY3q+1fZmsv+eU1iT/EIGlgUUVJXHsttDuQx96wAesgJH9eP7R jpcSCzF1yeBePyi/gdnT7EnEUVVaFHVsET3qiBK0= Received: from epsnrtp03.localdomain (unknown [182.195.42.155]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPS id 20250930035559epcas5p42b42e0b13edc7de117b553724cb92261~p8znkYwHP2781827818epcas5p4T; Tue, 30 Sep 2025 03:55:59 +0000 (GMT) Received: from epcas5p2.samsung.com (unknown [182.195.38.90]) by epsnrtp03.localdomain (Postfix) with ESMTP id 4cbPNt2NNtz3hhTB; Tue, 30 Sep 2025 03:55:58 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20250930035557epcas5p2efa9fa41298b8a9aabb46e5fac70d49e~p8zl-U8Rm0060500605epcas5p2a; Tue, 30 Sep 2025 03:55:57 +0000 (GMT) Received: from bose.samsungds.net (unknown [107.108.83.9]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250930035551epsmtip10b3f862702187955e4e92c4cc8153c6e~p8zgNeRAr2931929319epsmtip1N; Tue, 30 Sep 2025 03:55:51 +0000 (GMT) From: Himanshu Dewangan To: mchehab@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, sumit.semwal@linaro.org, christian.koenig@amd.com, alim.akhtar@samsung.com, manjun@samsung.com, nagaraju.s@samsung.com, ih0206.lee@samsung.com, jehyung.lee@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Himanshu Dewangan Subject: [PATCH 09/29] =?UTF-8?q?media:=20mfc:=20Add=20bus=E2=80=91devfreq?= =?UTF-8?q?,=20QoS,=20multi=E2=80=91view=20and=20control=20infrastructure?= Date: Tue, 30 Sep 2025 09:33:28 +0530 Message-Id: <20250930040348.3702923-10-h.dewangan@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250930040348.3702923-1-h.dewangan@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMS-MailID: 20250930035557epcas5p2efa9fa41298b8a9aabb46e5fac70d49e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P cpgsPolicy: CPGSC10-542,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250930035557epcas5p2efa9fa41298b8a9aabb46e5fac70d49e References: <20250930040348.3702923-1-h.dewangan@samsung.com> From: Nagaraju Siddineni - Optional bus=E2=80=91devfreq support (CONFIG_MFC_USE_BUS_DEVFREQ). - New control framework (mfc_ctrl_type, mfc_ctrl_mode, ops structs). - QoS and per=E2=80=91context/core power=E2=80=91clock handling. - Multi=E2=80=91view / depth=E2=80=91map support with related buffers and c= onstants. - Added helper macros (mfc_macros.h) and extra pixel formats. Signed-off-by: Nagaraju Siddineni Signed-off-by: Himanshu Dewangan --- .../samsung/exynos-mfc/base/mfc_data_struct.h | 659 +++++++++++++++++- .../samsung/exynos-mfc/base/mfc_format.h | 132 ++++ .../samsung/exynos-mfc/base/mfc_macros.h | 95 +++ 3 files changed, 882 insertions(+), 4 deletions(-) create mode 100644 drivers/media/platform/samsung/exynos-mfc/base/mfc_form= at.h create mode 100644 drivers/media/platform/samsung/exynos-mfc/base/mfc_macr= os.h diff --git a/drivers/media/platform/samsung/exynos-mfc/base/mfc_data_struct= .h b/drivers/media/platform/samsung/exynos-mfc/base/mfc_data_struct.h index 59fef39095d2..34b4b13b4f01 100644 --- a/drivers/media/platform/samsung/exynos-mfc/base/mfc_data_struct.h +++ b/drivers/media/platform/samsung/exynos-mfc/base/mfc_data_struct.h @@ -12,6 +12,13 @@ #ifndef __MFC_DATA_STRUCT_H #define __MFC_DATA_STRUCT_H __FILE__ =20 +#if IS_ENABLED(CONFIG_EXYNOS_PM_QOS) || IS_ENABLED(CONFIG_EXYNOS_PM_QOS_MO= DULE) +#define CONFIG_MFC_USE_BUS_DEVFREQ +#endif + +#ifdef CONFIG_MFC_USE_BUS_DEVFREQ +#include +#endif #include #include #include @@ -24,6 +31,7 @@ #include "mfc_media.h" =20 /* DEBUGFS */ +#define MFC_DEFAULT_MEMLOG_LEVEL 0x7 #define MFC_DEFAULT_LOGGING_OPTION 0x7 =20 #define MFC_NUM_CORE 2 @@ -36,6 +44,9 @@ #define MFC_SFR_LOGGING_COUNT_SET1 28 #define MFC_SFR_LOGGING_COUNT_SET2 32 #define MFC_LOGGING_DATA_SIZE 950 +#define MFC_MAX_DEFAULT_PARAM 100 +#define MFC_NUM_EXTRA_DPB 5 +#define MFC_MAX_MB_TABLE 30 /* the number of priority is 2N(num of OPP) + 2 */ #define MFC_MAX_PRIO 12 /* The number of display DRC max frames that can occur continuously in NAL= _Q */ @@ -60,6 +71,14 @@ #define MFC_FMT_FLAG_MULTI_VIEW 0x0010 #define MFC_FMT_FLAG_DEPTH_MAP 0x0020 =20 +/* MFC Multi-View */ +#define MFC_NUM_FD_DEPTH_MAP 1 +#define MFC_NUM_MULTI_VIEW 2 +#define MFC_NUM_FD_SUB_VIEW_META 1 + +/* MFC meminfo */ +#define MFC_MEMINFO_MAX_NUM 10 + #define MFC_NUM_SPECIAL_BUF_NAME 25 =20 #define BANK_L_CTX 0 @@ -102,10 +121,59 @@ enum mfc_inst_type { enum mfc_inst_state { MFCINST_FREE =3D 0, MFCINST_INIT =3D 100, + MFCINST_GOT_INST, + MFCINST_HEAD_PARSED, + MFCINST_RUNNING_BUF_FULL, MFCINST_RUNNING, + MFCINST_FINISHING, MFCINST_RETURN_INST, MFCINST_ERROR, - MFCINST_ABORT + MFCINST_ABORT, + MFCINST_RES_CHANGE_INIT, + MFCINST_RES_CHANGE_FLUSH, + MFCINST_RES_CHANGE_FLUSH_FINISHED, + MFCINST_RES_CHANGE_END, + MFCINST_FINISHED, + MFCINST_ABORT_INST, + MFCINST_DPB_FLUSHING, + MFCINST_MOVE_INST, + MFCINST_BUF_INIT_BUT_MULTI_MODE_NOT_CHECKED_YET, +}; + +enum mfc_inst_state_query { + EQUAL =3D 0, + BIGGER, + SMALLER, + EQUAL_BIGGER, + EQUAL_SMALLER, + EQUAL_OR, +}; + +/** + * enum mfc_queue_state - The state of buffer queue. + */ +enum mfc_queue_state { + QUEUE_FREE =3D 0, + QUEUE_BUFS_REQUESTED, + QUEUE_BUFS_QUERIED, + QUEUE_BUFS_MMAPED, +}; + +enum mfc_dec_wait_state { + WAIT_NONE =3D 0, + WAIT_G_FMT =3D BIT(0), + WAIT_STOP =3D BIT(1), +}; + +/** + * enum mfc_check_state - The state for user notification + */ +enum mfc_check_state { + MFCSTATE_PROCESSING =3D 0, + MFCSTATE_DEC_RES_DETECT, + MFCSTATE_DEC_TERMINATING, + MFCSTATE_ENC_NO_OUTPUT, + MFCSTATE_DEC_S3D_REALLOC, }; =20 enum mfc_buf_usage_type { @@ -116,6 +184,54 @@ enum mfc_buf_usage_type { MFCBUF_DRM_FW, }; =20 +enum mfc_buf_process_type { + MFCBUFPROC_DEFAULT =3D 0x0, + MFCBUFPROC_COPY =3D BIT(0), + MFCBUFPROC_SHARE =3D BIT(1), + MFCBUFPROC_META =3D BIT(2), + MFCBUFPROC_ANBSHARE =3D BIT(3), + MFCBUFPROC_ANBSHARE_NV12L =3D BIT(4), +}; + +enum mfc_ctrl_type { + MFC_CTRL_TYPE_GET_SRC =3D 0x1, + MFC_CTRL_TYPE_GET_DST =3D 0x2, + MFC_CTRL_TYPE_SET_SRC =3D 0x4, + MFC_CTRL_TYPE_SET_DST =3D 0x8, +}; + +enum mfc_ctrl_mode { + MFC_CTRL_MODE_NONE =3D 0x0, + MFC_CTRL_MODE_SFR =3D 0x1, +}; + +enum mfc_mb_flag { + /* Driver set to user when DST DQbuf */ + MFC_FLAG_HDR_CONTENT_LIGHT =3D 0, + MFC_FLAG_HDR_DISPLAY_COLOUR =3D 1, + MFC_FLAG_HDR_MAXTIX_COEFF =3D 2, + MFC_FLAG_HDR_COLOUR_DESC =3D 3, + MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE =3D 4, + MFC_FLAG_BLACKBAR_DETECT =3D 5, + MFC_FLAG_HDR_PLUS =3D 6, + MFC_FLAG_DISP_RES_CHANGE =3D 7, + MFC_FLAG_UNCOMP =3D 8, + MFC_FLAG_FRAMERATE_CH =3D 9, + MFC_FLAG_SYNC_FRAME =3D 10, + MFC_FLAG_AV1_FILM_GRAIN =3D 11, + MFC_FLAG_MULTIFRAME =3D 12, + MFC_FLAG_RIGHT_IS_MAIN_VIEW =3D 13, + /* Driver set to user when SRC DQbuf */ + MFC_FLAG_CONSUMED_ONLY =3D 15, + /* User set to driver when SRC Qbuf */ + MFC_FLAG_ENC_SRC_VOTF =3D 26, + MFC_FLAG_ENC_SRC_FAKE =3D 27, + MFC_FLAG_ENC_SRC_UNCOMP =3D 28, + MFC_FLAG_CSD =3D 29, + MFC_FLAG_EMPTY_DATA =3D 30, + MFC_FLAG_LAST_FRAME =3D 31, +}; + enum mfc_frame_error_type { MFC_ERR_FRAME_NO_ERR =3D 0, MFC_ERR_FRAME_CONCEALMENT =3D 1, @@ -152,6 +268,31 @@ enum mfc_debug_cause { MFC_CAUSE_FAIL_DPB_FLUSH =3D 12, MFC_CAUSE_FAIL_CACHE_FLUSH =3D 13, MFC_CAUSE_FAIL_MOVE_INST =3D 14, + /* last information */ + MFC_LAST_INFO_BLACK_BAR =3D 26, + MFC_LAST_INFO_NAL_QUEUE =3D 27, + MFC_LAST_INFO_CLOCK =3D 28, + MFC_LAST_INFO_POWER =3D 29, + MFC_LAST_INFO_SHUTDOWN =3D 30, + MFC_LAST_INFO_DRM =3D 31, +}; + +enum mfc_request_work { + MFC_WORK_BUTLER =3D 0x1, + MFC_WORK_TRY =3D 0x2, +}; + +enum mfc_qos_control { + MFC_QOS_ON =3D 0x1, + MFC_QOS_OFF =3D 0x2, + MFC_QOS_TRIGGER =3D 0x3, +}; + +enum mfc_ts_type { + MFC_TS_SRC =3D 0x1, + MFC_TS_DST_Q =3D 0x2, + MFC_TS_SRC_Q =3D 0x3, + MFC_TS_DST_DQ =3D 0x4, }; =20 enum mfc_core_type { @@ -200,6 +341,13 @@ enum mfc_real_time { MFC_RT_UNDEFINED =3D 4, }; =20 +enum mfc_hwapg_status { + MFC_HWAPG_CLEAR =3D 0, + MFC_HWAPG_ENABLE =3D 1, + MFC_HWAPG_HOST_SET =3D 2, + MFC_HWAPG_HOST_CLEAR =3D 3, +}; + enum mfc_sched_type { MFC_SCHED_RR =3D 0, MFC_SCHED_PRIO =3D 1, @@ -236,6 +384,7 @@ struct mfc_debug { u8 power_cnt; u8 clock_cnt; /* for decoder only */ + u64 dynamic_used; u32 last_src_addr; u32 last_dst_addr[MFC_MAX_PLANES]; /* total logging data */ @@ -268,6 +417,7 @@ struct mfc_buf { unsigned char *vir_addr[MFC_MAX_PLANES]; u32 flag; unsigned long i_ino; + int select_view; }; =20 struct mfc_buf_queue { @@ -275,6 +425,12 @@ struct mfc_buf_queue { unsigned int count; }; =20 +struct mfc_bits { + unsigned long bits; + /* protection */ + spinlock_t lock; +}; + struct mfc_hwlock { struct list_head waiting_list; unsigned int wl_count; @@ -307,9 +463,11 @@ struct mfc_core_intlock { =20 struct mfc_core_lock { int cnt; + int migrate; /* protection */ spinlock_t lock; wait_queue_head_t wq; + wait_queue_head_t migrate_wq; }; =20 struct mfc_pm { @@ -344,6 +502,7 @@ struct mfc_fw { =20 struct mfc_ctx_buf_size { size_t dev_ctx; + size_t h264_dec_ctx; size_t dbg_info_buf; }; =20 @@ -487,6 +646,7 @@ struct mfc_debugfs { unsigned int sfr_dump; unsigned int logging_option; unsigned int feature_option; + unsigned int core_balance; unsigned int sched_perf_disable; unsigned int sched_type; }; @@ -524,6 +684,74 @@ struct mfc_mem { size_t size; }; =20 +enum mfc_meminfo_type { + MFC_MEMINFO_FW =3D 0, + MFC_MEMINFO_INTERNAL =3D 1, + MFC_MEMINFO_INPUT =3D 2, + MFC_MEMINFO_OUTPUT =3D 3, + MFC_MEMINFO_CTX_ALL =3D 4, + MFC_MEMINFO_CTX_MAX =3D 5, + MFC_MEMINFO_DEV_ALL =3D 6, +}; + +struct mfc_meminfo { + enum mfc_meminfo_type type; + const char *name; + unsigned int count; + size_t size; + size_t total; +}; + +struct mfc_bw_data { + unsigned int peak; + unsigned int read; + unsigned int write; +}; + +struct mfc_bw_info { + struct mfc_bw_data bw_dec_h264; +}; + +/* + * threshold_mb - threshold of total MB(macroblock) count + * Total MB count can be calculated by + * (MB of width) * (MB of height) * fps + */ +struct mfc_qos { + unsigned int threshold_mb; + unsigned int freq_mfc; + unsigned int freq_int; + unsigned int freq_mif; + unsigned int mo_value; + unsigned int time_fw; + unsigned int bts_scen_idx; + const char *name; +}; + +struct mfc_qos_boost { + unsigned int num_cluster; + unsigned int num_cpu[MAX_NUM_CLUSTER]; + unsigned int freq_mfc; + unsigned int freq_int; + unsigned int freq_mif; + unsigned int freq_cluster[MAX_NUM_CLUSTER]; + unsigned int bts_scen_idx; + const char *name; +}; + +struct mfc_qos_ctrl { + unsigned int idx; + unsigned int table_type; + unsigned int mfc_freq; +}; + +struct mfc_qos_weight { + unsigned int weight_h264_hevc; + unsigned int weight_3plane; + unsigned int weight_num_of_tile; + unsigned int weight_mbaff; +}; + struct mfc_feature { unsigned int support; unsigned int version; @@ -537,25 +765,58 @@ struct mfc_resource { struct mfc_platdata { /* Debug mode */ unsigned int debug_mode; + unsigned int stride_align; + unsigned int stride_type; + unsigned int stream_buf_limit; + unsigned int support_8K_cavlc; + /* Formats */ + unsigned int support_10bit; + unsigned int support_422; + /* Resolution */ + unsigned int support_check_res; + + /* error type for sync_point display */ + unsigned int display_err_type; + /* output buffer Q framerate */ + unsigned int display_framerate; =20 /* Resource */ struct mfc_resource mfc_resource[MFC_MAX_CODEC_TYPE]; /* Features */ + struct mfc_feature skype; + struct mfc_feature black_bar; + struct mfc_feature color_aspect_dec; + struct mfc_feature static_info_dec; + struct mfc_feature vp9_stride_align; struct mfc_feature mem_clear; struct mfc_feature wait_fw_status; + struct mfc_feature hevc_pic_output_flag; + + struct mfc_bw_info mfc_bw_info; + unsigned int dynamic_weight; + struct mfc_qos_weight qos_weight; =20 const char *fw_name; unsigned int fw_mem_size; unsigned int reserved_start; unsigned int dma_bit_mask; unsigned int ip_ver; + int num_mfc_freq; + unsigned int mfc_freqs[MAX_NUM_MFC_FREQ]; + unsigned int core_balance; unsigned int iova_threshold; + unsigned int idle_clk_ctrl; + unsigned int qos_ctrl_level; =20 unsigned int memlog_size; + unsigned int memlog_sfr_size; + + unsigned int reg_h264_loop_filter_disable; =20 unsigned int scheduler; unsigned int pbs_num_prio; enum mfc_hwacg_type support_hwacg; + unsigned int support_mv_hevc; }; =20 struct mfc_core_platdata { @@ -575,6 +836,36 @@ struct mfc_core_platdata { unsigned int masterid_shift; unsigned int masterid_mask; unsigned int tsmux_masterid; + /* QoS */ + unsigned int num_default_qos_steps; + unsigned int max_mb; + unsigned int max_hw_mb; + unsigned int mfc_freq_control; + unsigned int mo_control; + unsigned int bw_control; + unsigned int pm_qos_id; + unsigned int mfc_bw_index; + struct mfc_qos *default_qos_table; + struct mfc_qos *encoder_qos_table; + struct mfc_qos_boost *qos_boost_table; +}; + +struct mfc_perf { + void __iomem *regs_base0; + void __iomem *regs_base1; + + struct timespec64 begin; + struct timespec64 end; + + int new_start; + int count; + int drv_margin; + unsigned int latency; +}; + +struct mfc_dump_ops { + void (*dump_info_context)(struct mfc_dev *dev); + void (*dump_and_stop_debug_mode)(struct mfc_dev *dev); }; =20 struct mfc_dev_memlog { @@ -618,14 +909,17 @@ struct mfc_dev { =20 /* protection */ struct mutex mfc_mutex; + /* protection */ + struct mutex mfc_migrate_mutex; =20 struct mfc_ctx *ctx[MFC_NUM_CONTEXTS]; struct mfc_ctx *move_ctx[MFC_NUM_CONTEXTS]; dma_addr_t dma_base[BANK_NUM]; - + int move_ctx_cnt; struct list_head ctx_list; /* protection */ spinlock_t ctx_list_lock; + unsigned int core_balance; =20 atomic_t queued_bits; /* protection */ @@ -641,14 +935,45 @@ struct mfc_dev { =20 /* Debugfs and dump */ struct mfc_debugfs debugfs; + struct mfc_dump_ops *dump_ops; + + /* Instance migration worker */ + struct workqueue_struct *migration_wq; + struct work_struct migration_work; + + /* Butler */ + struct workqueue_struct *butler_wq; + struct work_struct butler_work; + + /* Lazy unmap disable */ + int skip_lazy_unmap; + + int tmu_fps; + + int max_kbps; + + /* Reg test */ + char *reg_buf; + unsigned int *reg_val; + unsigned int reg_cnt; =20 + struct mfc_meminfo meminfo[MFC_MEMINFO_DEV_ALL + 1]; struct mfc_dev_memlog memlog; =20 + const struct mfc_votf_ops *votf_ops; }; =20 struct mfc_core_ops { int (*instance_init)(struct mfc_core *core, struct mfc_ctx *ctx); int (*instance_deinit)(struct mfc_core *core, struct mfc_ctx *ctx); + int (*instance_open)(struct mfc_core *core, struct mfc_ctx *ctx); + void (*instance_cache_flush)(struct mfc_core *core, struct mfc_ctx *ctx); + int (*instance_move_to)(struct mfc_core *core, struct mfc_ctx *ctx); + int (*instance_move_from)(struct mfc_core *core, struct mfc_ctx *ctx); + int (*request_work)(struct mfc_core *core, enum mfc_request_work work, st= ruct mfc_ctx *ctx); + /* for DEC */ + void (*instance_dpb_flush)(struct mfc_core *core, struct mfc_ctx *ctx); + int (*instance_init_buf)(struct mfc_core *core, struct mfc_ctx *ctx); }; =20 struct dump_info { @@ -693,6 +1018,7 @@ struct mfc_core { /* Power and Clock */ atomic_t clk_ref; struct mfc_pm pm; + struct mfc_perf perf; bool continue_clock_on; bool sleep; bool shutdown; @@ -725,13 +1051,17 @@ struct mfc_core { int next_ctx_idx; =20 /* HW lock */ + struct mfc_bits work_bits; struct mfc_hwlock hwlock; struct mfc_listable_wq hwlock_wq; wait_queue_head_t cmd_wq; =20 + struct mfc_core_dump_ops *dump_ops; + /* batch mode */ int batch_enable; int batch_index; + enum mfc_hwapg_status hwapg_status; /* protection */ spinlock_t batch_lock; =20 @@ -748,10 +1078,20 @@ struct mfc_core { int cache_flush_flag; int last_cmd_has_cache_flush; =20 + /* Butler */ + struct workqueue_struct *butler_wq; + struct work_struct butler_work; + /* QoS */ struct list_head qos_queue; atomic_t qos_req_cur; - +#ifdef CONFIG_MFC_USE_BUS_DEVFREQ + struct exynos_pm_qos_request qos_req_mfc_noidle; + struct exynos_pm_qos_request qos_req_mfc; + struct exynos_pm_qos_request qos_req_int; + struct exynos_pm_qos_request qos_req_mif; + struct freq_qos_request qos_req_cluster[MAX_NUM_CLUSTER]; +#endif /* protection */ struct mutex qos_mutex; int mfc_freq_by_bps; @@ -760,6 +1100,14 @@ struct mfc_core { unsigned long total_mb; unsigned int cpu_boost_enable; =20 + /* QoS control depending on MFC H/W run */ + struct workqueue_struct *qos_ctrl_wq; + struct work_struct qos_ctrl_work; + struct mfc_qos_ctrl qos_ctrl[MAX_NUM_QOS_DYNAMIC]; + unsigned int qos_ctrl_last_idx; + atomic_t qos_ctrl_cnt; + /* protection */ + struct mutex pm_qos_mutex; /* Logging trace data */ atomic_t trace_ref_log; struct _mfc_trace_logging *mfc_trace_logging; @@ -773,6 +1121,10 @@ struct mfc_core { struct dump_info dbg_info; =20 /* Debug */ + char *reg_buf; + unsigned int *reg_val; + unsigned int reg_cnt; + struct mfc_meminfo meminfo[MFC_MEMINFO_DEV_ALL + 1]; struct mfc_core_memlog memlog; }; =20 @@ -783,6 +1135,7 @@ struct mfc_ctx_ctrl_val { =20 struct mfc_ctx_ctrl { struct list_head list; + enum mfc_ctrl_type type; unsigned int id; unsigned int addr; struct mfc_ctx_ctrl_val set; @@ -792,6 +1145,7 @@ struct mfc_ctx_ctrl { struct mfc_buf_ctrl { struct list_head list; unsigned int id; + enum mfc_ctrl_type type; int has_new; int val; unsigned int old_val; /* only for MFC_CTRL_TYPE_SET */ @@ -808,6 +1162,7 @@ struct mfc_buf_ctrl { }; =20 struct mfc_ctrl_cfg { + enum mfc_ctrl_type type; unsigned int id; unsigned int is_volatile; /* only for MFC_CTRL_TYPE_SET */ unsigned int mode; @@ -819,6 +1174,46 @@ struct mfc_ctrl_cfg { unsigned int flag_shft; /* only for MFC_CTRL_TYPE_SET */ }; =20 +/* per buffer control */ +extern struct mfc_ctrls_ops mfc_ctrls_ops; +struct mfc_ctrls_ops { + void (*cleanup_ctx_ctrls)(struct mfc_ctx *ctx); + int (*init_ctx_ctrls)(struct mfc_ctx *ctx); + void (*reset_buf_ctrls)(struct list_head *head); + int (*cleanup_buf_ctrls)(struct mfc_ctx *ctx, enum mfc_ctrl_type type, un= signed int index); + int (*init_buf_ctrls)(struct mfc_ctx *ctx, enum mfc_ctrl_type type, unsig= ned int index); + void (*to_buf_ctrls)(struct mfc_ctx *ctx, struct list_head *head); + void (*to_ctx_ctrls)(struct mfc_ctx *ctx, struct list_head *head); + int (*get_buf_ctrl_val)(struct mfc_ctx *ctx, struct list_head *head, unsi= gned int id); + void (*update_buf_val)(struct mfc_ctx *ctx, struct list_head *head, + unsigned int id, int value); +}; + +extern struct mfc_bufs_ops mfc_bufs_ops; +struct mfc_bufs_ops { + int (*core_set_buf_ctrls)(struct mfc_core *core, + struct mfc_ctx *ctx, struct list_head *head); + int (*core_get_buf_ctrls)(struct mfc_core *core, + struct mfc_ctx *ctx, struct list_head *head); + int (*core_recover_buf_ctrls)(struct mfc_core *core, + struct mfc_ctx *ctx, struct list_head *head); + int (*core_restore_buf_ctrls)(struct mfc_ctx *ctx, struct list_head *head= ); +}; + +struct stored_dpb_info { + int fd[MFC_MAX_PLANES]; +}; + +struct dec_dpb_ref_info { + int index; + struct stored_dpb_info dpb[MFC_MAX_BUFFERS]; +}; + +struct temporal_layer_info { + unsigned int temporal_layer_count; + unsigned int temporal_layer_bitrate[VIDEO_MAX_TEMPORAL_LAYERS]; +}; + struct mfc_user_shared_handle { int fd; struct dma_buf *dma_buf; @@ -835,6 +1230,35 @@ struct mfc_raw_info { unsigned int total_plane_size; }; =20 +struct mfc_timestamp { + struct list_head list; + struct timespec64 timestamp; + int index; + int interval; +}; + +struct mfc_ts_control { + struct mfc_timestamp ts_array[MAX_TIME_INDEX]; + int ts_interval_array[MAX_TIME_INDEX]; + struct list_head ts_list; + int ts_count; + int ts_is_full; + int ts_last_interval; + /* protection */ + spinlock_t ts_lock; +}; + +struct mfc_bitrate { + struct list_head list; + int bytesused; +}; + +struct mfc_mb_control { + struct list_head list; + unsigned long mb_per_sec; + unsigned int fps; +}; + struct dpb_table { dma_addr_t addr[MFC_MAX_PLANES]; phys_addr_t paddr; @@ -849,6 +1273,97 @@ struct dpb_table { struct sg_table *sgt[MFC_MAX_PLANES]; }; =20 +struct disp_drc_info { + int disp_res_change; + int push_idx; + int pop_idx; + int width[MFC_MAX_DRC_FRAME]; + int height[MFC_MAX_DRC_FRAME]; +}; + +struct mfc_dec { + int total_dpb_count; + + unsigned int src_buf_size; + + int loop_filter_mpeg4; + int display_delay; + int immediate_display; + int slice_enable; + int mv_count; + int idr_decoding; + int is_interlaced; + int is_mbaff; + int is_dts_mode; + int inter_res_change; + struct disp_drc_info disp_drc; + + int crc_enable; + unsigned int *crc; + int crc_idx; + + unsigned int consumed; + + int sei_parse; + + int cr_left, cr_right, cr_top, cr_bot; + + int detect_black_bar; + bool black_bar_updated; + struct v4l2_rect black_bar; + + /* For dynamic DPB */ + int is_dynamic_dpb; + int is_dpb_full; + int display_index; + unsigned long queued_dpb; + unsigned long dynamic_set; + unsigned long dynamic_used; + + int is_multiframe; + int has_multiframe; + int is_multiple_show; + + unsigned int num_of_tile_over_4; + unsigned int super64_bframe; + + unsigned int color_range; + unsigned int color_space; + + unsigned int decoding_order; + unsigned int frame_display_delay; + + struct mfc_fmt *uncomp_fmt; + + /* for Internal DPB */ + struct mfc_special_buf internal_dpb[MFC_MAX_DPBS]; + unsigned long plugin_used; + + /* for Dynamic DPB */ + struct dpb_table dpb[MFC_MAX_DPBS]; + /* protection */ + struct mutex dpb_mutex; + unsigned long dpb_table_used; + struct dec_dpb_ref_info *ref_info; + struct stored_dpb_info ref_buf[MFC_MAX_BUFFERS]; + int refcnt; + int last_dpb_max_index; + struct mfc_user_shared_handle sh_handle_dpb; + + /* for debugging about black bar detection */ + void *frame_vaddr[3][30]; + dma_addr_t frame_daddr[3][30]; + int index[3][30]; + int fd[3][30]; + unsigned int frame_size[3][30]; + unsigned char frame_cnt; +}; + +struct mfc_resolution { + int width; + int height; +}; + struct mfc_fmt { char *name; u32 fourcc; @@ -868,18 +1383,65 @@ enum mfc_multi_view_buf_idx { MFC_MV_BUF_IDX_MAX, }; =20 +struct mfc_multi_view_buf_info { + int offset; + int num_fd; +}; + /** * struct mfc_ctx - This struct contains the instance context */ struct mfc_ctx { struct mfc_dev *dev; + struct mfc_dec *dec_priv; =20 int num; int prio; int user_prio; enum mfc_real_time rt; =20 + struct mfc_fmt *src_fmt; + struct mfc_fmt *dst_fmt; + + struct mfc_buf_queue src_buf_ready_queue; + struct mfc_buf_queue dst_buf_queue; + struct mfc_buf_queue err_buf_queue; + struct mfc_buf_queue ref_buf_queue; /* Encoder only */ + spinlock_t buf_queue_lock; + enum mfc_inst_type type; + int subcore_inst_no; + + int img_width; + int img_height; + int crop_width; + int crop_height; + int crop_left; + int crop_top; + int mb_width; + int mb_height; + int dpb_count; + int rgb_bpp; + + int min_dpb_size[3]; + int min_dpb_size_2bits[3]; + + int bytesperline[3]; + struct mfc_raw_info raw_buf; + + int num_fd_frame; + struct mfc_multi_view_buf_info view_buf_info[MFC_MV_BUF_IDX_MAX]; + int select_view; + int select_view_irq; + + enum mfc_queue_state capture_state; + enum mfc_queue_state output_state; + + DECLARE_BITMAP(src_ctrls_avail, MFC_MAX_BUFFERS); + DECLARE_BITMAP(dst_ctrls_avail, MFC_MAX_BUFFERS); + + unsigned int sequence; + int stored_tag; =20 /* operation mode */ int op_core_num[MFC_NUM_CORE]; @@ -888,7 +1450,9 @@ struct mfc_ctx { enum mfc_op_mode op_mode; enum mfc_op_core_type op_core_type; struct mfc_core_lock corelock; - + int serial_src_index; + int curr_src_index; + int cmd_counter; /* protection */ struct mutex op_mode_mutex; int last_op_core; @@ -900,10 +1464,20 @@ struct mfc_ctx { int codec_mode; __u32 pix_format; =20 + /* Profile information */ + int is_422; + int bit_depth_luma; + int bit_depth_chroma; + + /* for AV1 Annex B */ + int is_av1_annex_b; + int is_heif_mode; =20 int is_dpb_realloc; + enum mfc_dec_wait_state wait_state; /* protection */ + struct mutex drc_wait_mutex; int clear_work_bit; =20 /* Extra Buffers */ @@ -911,8 +1485,25 @@ struct mfc_ctx { struct mfc_special_buf mv_buf; =20 unsigned long framerate; + unsigned long last_framerate; + unsigned long operating_framerate; + unsigned long dst_q_framerate; + unsigned long dst_dq_framerate; + unsigned long src_q_framerate; + unsigned long max_framerate; + unsigned int qos_ratio; + bool update_framerate; + bool update_bitrate; + bool check_src_ts_full; + bool ktime_used; + + struct mfc_ts_control src_ts; + struct mfc_ts_control dst_q_ts; + struct mfc_ts_control src_q_ts; + struct mfc_ts_control dst_dq_ts; =20 /* bitrate control for QoS*/ + struct mfc_bitrate bitrate_array[MAX_TIME_INDEX]; struct list_head bitrate_list; int bitrate_index; int bitrate_is_full; @@ -922,6 +1513,7 @@ struct mfc_ctx { unsigned long weighted_mb; struct list_head list; =20 + unsigned int *mfc_qos_portion; int disp_ratio; =20 int buf_process_type; @@ -939,11 +1531,35 @@ struct mfc_ctx { /* QoS idle */ enum mfc_idle_mode idle_mode; =20 + /* Lazy unmap disable */ + int skip_lazy_unmap; + /* external structure */ struct v4l2_fh fh; struct vb2_queue vq_src; struct vb2_queue vq_dst; =20 + /* per buffer controls */ + struct mfc_ctrls_ops *c_ops; + struct mfc_bufs_ops *b_ops; + struct list_head ctrls; + struct list_head src_ctrls[MFC_MAX_BUFFERS]; + struct list_head dst_ctrls[MFC_MAX_BUFFERS]; + + /* Extra Buffers size */ + size_t mv_size; + size_t scratch_buf_size; + size_t loopfilter_luma_size; + size_t loopfilter_chroma_size; + + /* mem info */ + struct mfc_buf_queue meminfo_inbuf_q; + struct mfc_buf_queue meminfo_outbuf_q; + /* protection */ + spinlock_t meminfo_queue_lock; + struct mfc_meminfo meminfo[MFC_MEMINFO_MAX_NUM]; + size_t meminfo_size[MFC_MEMINFO_CTX_MAX + 1]; + u32 ready_to_be_multi_view_enable; u32 multi_view_enable; u32 left_view_id; @@ -963,11 +1579,35 @@ struct mfc_core_ctx { unsigned int int_err; bool check_dump; =20 + struct mfc_buf_queue src_buf_queue; + struct mfc_buf_queue dst_buf_queue; + /* protection */ + spinlock_t buf_queue_lock; + unsigned long dynamic_set; + enum mfc_inst_state state; enum mfc_inst_state prev_state; =20 + /* QoS */ + struct list_head qos_list; + + /* MB control for QoS */ + struct mfc_mb_control mb_table[MFC_MAX_MB_TABLE]; + struct list_head mb_list; + int mb_index; + int mb_is_full; + int dynamic_weight_level; + unsigned int dynamic_weight_started; + int mb_update_time; + unsigned int avg_runtime; + unsigned long mb_not_coded_time; + /* Extra Buffers */ + int codec_buffer_allocated; + int scratch_buffer_allocated; + struct mfc_special_buf codec_buf; struct mfc_special_buf instance_ctx_buf; + struct mfc_special_buf scratch_buf; =20 /* wait queue */ wait_queue_head_t cmd_wq; @@ -979,7 +1619,18 @@ struct mfc_sched_class { void (*create_work)(struct mfc_core *core); void (*init_work)(struct mfc_core *core); void (*clear_all_work)(struct mfc_core *core); + void (*queue_work)(struct mfc_core *core); + int (*is_work)(struct mfc_core *core); + int (*pick_next_work)(struct mfc_core *core); + int (*get_next_work)(struct mfc_core *core); + void (*set_work)(struct mfc_core *core, struct mfc_core_ctx *core_ctx); void (*clear_work)(struct mfc_core *core, struct mfc_core_ctx *core_ctx); + int (*enqueue_work)(struct mfc_core *core, struct mfc_core_ctx *core_ctx); + int (*enqueue_otf_work)(struct mfc_core *core, struct mfc_core_ctx *core_= ctx, bool flag); + int (*dequeue_work)(struct mfc_core *core, struct mfc_core_ctx *core_ctx); + void (*yield_work)(struct mfc_core *core, struct mfc_core_ctx *core_ctx); + int (*change_prio_work)(struct mfc_core *core, struct mfc_ctx *ctx, + int cur_rt, int cur_prio, int new_rt, int new_prio); }; #endif /* __MFC_DATA_STRUCT_H */ diff --git a/drivers/media/platform/samsung/exynos-mfc/base/mfc_format.h b/= drivers/media/platform/samsung/exynos-mfc/base/mfc_format.h new file mode 100644 index 000000000000..3307c2eeaebb --- /dev/null +++ b/drivers/media/platform/samsung/exynos-mfc/base/mfc_format.h @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * mfc_format.h file + * + * Nagaraju Siddineni, + * Himanshu Dewangan, + */ + +#ifndef __MFC_FORMAT_H +#define __MFC_FORMAT_H __FILE__ + +#define MFC_NUM_FORMATS ARRAY_SIZE(mfc_formats) + +static struct mfc_fmt mfc_formats[] =3D { + { + .name =3D "Unknown", + .fourcc =3D 0, + .codec_mode =3D 0, + .type =3D 0, + .num_planes =3D 0, + .mem_planes =3D 0, + }, + { + .name =3D "YUV420M", + .fourcc =3D V4L2_PIX_FMT_YUV420M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME, + .num_planes =3D 3, + .mem_planes =3D 3, + }, + { + .name =3D "YVU420M", + .fourcc =3D V4L2_PIX_FMT_YVU420M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME, + .num_planes =3D 3, + .mem_planes =3D 3, + }, + { + .name =3D "NV12M", + .fourcc =3D V4L2_PIX_FMT_NV12M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME, + .num_planes =3D 2, + .mem_planes =3D 2, + }, + { + .name =3D "NV21M", + .fourcc =3D V4L2_PIX_FMT_NV21M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME, + .num_planes =3D 2, + .mem_planes =3D 2, + }, + { + .name =3D "NV16M", + .fourcc =3D V4L2_PIX_FMT_NV16M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_422, + .num_planes =3D 2, + .mem_planes =3D 2, + }, + { + .name =3D "NV61M", + .fourcc =3D V4L2_PIX_FMT_NV61M, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_422, + .num_planes =3D 2, + .mem_planes =3D 2, + }, + { + .name =3D "RGB888 24bpp", + .fourcc =3D V4L2_PIX_FMT_RGB24, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "RGB565 16bpp", + .fourcc =3D V4L2_PIX_FMT_RGB565, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "RGBX8888 32bpp", + .fourcc =3D V4L2_PIX_FMT_RGB32X, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "BGRA8888 32bpp", + .fourcc =3D V4L2_PIX_FMT_BGR32, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "ARGB8888 32bpp", + .fourcc =3D V4L2_PIX_FMT_ARGB32, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "RGB8888 32bpp", + .fourcc =3D V4L2_PIX_FMT_RGB32, + .codec_mode =3D MFC_FORMATS_NO_CODEC, + .type =3D MFC_FMT_FRAME | MFC_FMT_RGB, + .num_planes =3D 1, + .mem_planes =3D 1, + }, + { + .name =3D "DEC H264", + .fourcc =3D V4L2_PIX_FMT_H264, + .codec_mode =3D MFC_REG_CODEC_H264_DEC, + .type =3D MFC_FMT_STREAM | MFC_FMT_DEC, + .num_planes =3D 1, + .mem_planes =3D 1, + }, +}; + +#endif /* __MFC_FORMAT_H */ diff --git a/drivers/media/platform/samsung/exynos-mfc/base/mfc_macros.h b/= drivers/media/platform/samsung/exynos-mfc/base/mfc_macros.h new file mode 100644 index 000000000000..a41686214988 --- /dev/null +++ b/drivers/media/platform/samsung/exynos-mfc/base/mfc_macros.h @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) 2025 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * mfc_macros.h file + * Nagaraju Siddineni, + * Himanshu Dewangan, + */ + +#ifndef __MFC_MACROS_H +#define __MFC_MACROS_H __FILE__ + +/* helper macros */ +#ifndef __ALIGN_UP +#define __ALIGN_UP(x, a) ({ \ + typeof(a) _a =3D (a); \ + (((x) + (_a - 1)) & ~(_a - 1)); \ +}) +#endif + +#define WIDTH_MB(x_size) (((x_size) + 15) / 16) +#define HEIGHT_MB(y_size) (((y_size) + 15) / 16) + +/* + * Note that lcu_width and lcu_height are defined as follows : + * lcu_width =3D (frame_width + lcu_size - 1)/lcu_size + * lcu_height =3D (frame_height + lcu_size - 1)/lcu_size. + * (lcu_size is 32(encoder) or 64(decoder)) + * + * Note that ctb_width and ctb_height are defined as follows : + * ctb_width =3D (frame_width + ctb_size - 1)/ctb_size + * ctb_height =3D (frame_hegiht + ctb_size - 1)/ctb_size + * (ctb_size is 128(AV1 decoder)) + * + */ +#define DEC_LCU_WIDTH(x_size) (((x_size) + 63) / 64) +#define ENC_LCU_WIDTH(x_size) (((x_size) + 31) / 32) +#define DEC_LCU_HEIGHT(y_size) (((y_size) + 63) / 64) +#define ENC_LCU_HEIGHT(y_size) (((y_size) + 31) / 32) + +#define DEC_CTB_WIDTH(x_size) (((x_size) + 127) / 128) +#define DEC_CTB_HEIGHT(y_size) (((y_size) + 127) / 128) + +#define STREAM_BUF_ALIGN SZ_512 +#define MFC_LINEAR_BUF_SIZE SZ_256 + +#define DEC_STATIC_BUFFER_SIZE 20480 +/* STATIC buffer for AV1 will be aligned by 32 */ +#define DEC_AV1_STATIC_BUFFER_SIZE(x_size, y_size) \ + __ALIGN_UP((440192 + (DEC_LCU_WIDTH(x_size) * DEC_LCU_HEIGHT(y_size) * SZ= _8K)), SZ_32) + +#define DEC_MV_SIZE_MB(x, y) (WIDTH_MB(x) \ + * (((HEIGHT_MB(y) + SZ_1) / SZ_2) * SZ_2) * SZ_64 + SZ_1K) +#define DEC_HEVC_MV_SIZE(x, y) (DEC_LCU_WIDTH(x) * DEC_LCU_HEIGHT(y) * SZ_= 256 + SZ_512) +#define DEC_AV1_MV_SIZE(x, y) ((DEC_CTB_WIDTH(x) * DEC_CTB_HEIGHT(y) * 153= 6) * 10) + +#define ENC_LUMA_DPB_SIZE(x, y) ((((x) + 63) / 64) * 64 * (((y) + 31) / = 32) * 32 + 64) +#define ENC_CHROMA_DPB_SIZE(x, y) ((((x) + 63) / 64) * 64 * (((((y) + 31) = / 32) * 32) / 2) + 64) + +#define ENC_V100_H264_ME_SIZE(x, y) \ + ({ \ + typeof(x) __x =3D (x); \ + typeof(y) __y =3D (y); \ + ((((__x) + 3) * ((__y) + 3) * 8) + (((((__x) * (__y)) + 63) / 64) * 32) = + \ + ((((__y) * 64) + 2304) * ((__x) + 7) / 8)); \ + }) +#define ENC_V100_MPEG4_ME_SIZE(x, y) \ + ({ \ + typeof(x) __x =3D (x); \ + typeof(y) __y =3D (y); \ + ((((__x) + 3) * ((__y) + 3) * 8) + (((((__x) * (__y)) + 127) / 128) * 16= ) + \ + ((((__y) * 64) + 2304) * ((__x) + 7) / 8)); \ + }) +#define ENC_V100_VP8_ME_SIZE(x, y) \ + ({ \ + typeof(x) __x =3D (x); \ + typeof(y) __y =3D (y); \ + ((((__x) + 3) * ((__y) + 3) * 8) + ((((__y) * 64) + 2304) * ((__x) + 7) = / 8)); \ + }) +#define ENC_V100_VP9_ME_SIZE(x, y) \ + ({ \ + typeof(x) __x =3D (x); \ + typeof(y) __y =3D (y); \ + (((((__x) * 2) + 3) * (((__y) * 2) + 3) * 128) + \ + ((((__y) * 256) + 2304) * ((__x) + 1) / 2)); \ + }) +#define ENC_V100_HEVC_ME_SIZE(x, y) \ + ({ \ + typeof(x) __x =3D (x); \ + typeof(y) __y =3D (y); \ + ((((__x) + 3) * ((__y) + 3) * 32) + ((((__y) * 128) + 2304) * ((__x) + 3= ) / 4)); \ + }) + +#endif /* __MFC_MACROS_H */ --=20 2.34.1