1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2022 MediaTek Inc. 4 * Author: Ping-Hsun Wu <ping-hsun.wu@mediatek.com> 5 */ 6 7 #ifndef __MTK_MDP3_CORE_H__ 8 #define __MTK_MDP3_CORE_H__ 9 10 #include <media/v4l2-device.h> 11 #include <media/v4l2-mem2mem.h> 12 #include <linux/soc/mediatek/mtk-mmsys.h> 13 #include <linux/soc/mediatek/mtk-mutex.h> 14 #include "mtk-mdp3-comp.h" 15 #include "mtk-mdp3-vpu.h" 16 17 #define MDP_MODULE_NAME "mtk-mdp3" 18 #define MDP_DEVICE_NAME "MediaTek MDP3" 19 #define MDP_PHANDLE_NAME "mediatek,mdp3" 20 21 enum mdp_infra_id { 22 MDP_INFRA_MMSYS, 23 MDP_INFRA_MUTEX, 24 MDP_INFRA_SCP, 25 MDP_INFRA_MAX 26 }; 27 28 enum mdp_buffer_usage { 29 MDP_BUFFER_USAGE_HW_READ, 30 MDP_BUFFER_USAGE_MDP, 31 MDP_BUFFER_USAGE_MDP2, 32 MDP_BUFFER_USAGE_ISP, 33 MDP_BUFFER_USAGE_WPE, 34 }; 35 36 struct mdp_platform_config { 37 bool rdma_support_10bit; 38 bool rdma_rsz1_sram_sharing; 39 bool rdma_upsample_repeat_only; 40 bool rsz_disable_dcm_small_sample; 41 bool wrot_filter_constraint; 42 }; 43 44 /* indicate which mutex is used by each pipepline */ 45 enum mdp_pipe_id { 46 MDP_PIPE_RDMA0, 47 MDP_PIPE_IMGI, 48 MDP_PIPE_WPEI, 49 MDP_PIPE_WPEI2, 50 MDP_PIPE_MAX 51 }; 52 53 struct mtk_mdp_driver_data { 54 const struct of_device_id *mdp_probe_infra; 55 const struct mdp_platform_config *mdp_cfg; 56 const u32 *mdp_mutex_table_idx; 57 }; 58 59 struct mdp_dev { 60 struct platform_device *pdev; 61 struct device *mdp_mmsys; 62 struct mtk_mutex *mdp_mutex[MDP_PIPE_MAX]; 63 struct mdp_comp *comp[MDP_MAX_COMP_COUNT]; 64 const struct mtk_mdp_driver_data *mdp_data; 65 66 struct workqueue_struct *job_wq; 67 struct workqueue_struct *clock_wq; 68 struct mdp_vpu_dev vpu; 69 struct mtk_scp *scp; 70 struct rproc *rproc_handle; 71 /* synchronization protect for accessing vpu working buffer info */ 72 struct mutex vpu_lock; 73 s32 vpu_count; 74 u32 id_count; 75 struct ida mdp_ida; 76 struct cmdq_client *cmdq_clt; 77 wait_queue_head_t callback_wq; 78 79 struct v4l2_device v4l2_dev; 80 struct video_device *m2m_vdev; 81 struct v4l2_m2m_dev *m2m_dev; 82 /* synchronization protect for m2m device operation */ 83 struct mutex m2m_lock; 84 atomic_t suspended; 85 atomic_t job_count; 86 }; 87 88 int mdp_vpu_get_locked(struct mdp_dev *mdp); 89 void mdp_vpu_put_locked(struct mdp_dev *mdp); 90 int mdp_vpu_register(struct mdp_dev *mdp); 91 void mdp_vpu_unregister(struct mdp_dev *mdp); 92 void mdp_video_device_release(struct video_device *vdev); 93 94 #endif /* __MTK_MDP3_CORE_H__ */ 95