drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / media / platform / mediatek / vpu / mtk_vpu.h
blobda05f3e74081084dd965284ecfe7e38af2fef99c
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2016 MediaTek Inc.
4 * Author: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
5 */
7 #ifndef _MTK_VPU_H
8 #define _MTK_VPU_H
10 #include <linux/platform_device.h>
12 /**
13 * DOC: VPU
15 * VPU (video processor unit) is a tiny processor controlling video hardware
16 * related to video codec, scaling and color format converting.
17 * VPU interfaces with other blocks by share memory and interrupt.
20 typedef void (*ipi_handler_t) (void *data,
21 unsigned int len,
22 void *priv);
24 /**
25 * enum ipi_id - the id of inter-processor interrupt
27 * @IPI_VPU_INIT: The interrupt from vpu is to notfiy kernel
28 * VPU initialization completed.
29 * IPI_VPU_INIT is sent from VPU when firmware is
30 * loaded. AP doesn't need to send IPI_VPU_INIT
31 * command to VPU.
32 * For other IPI below, AP should send the request
33 * to VPU to trigger the interrupt.
34 * @IPI_VDEC_H264: The interrupt from vpu is to notify kernel to
35 * handle H264 vidoe decoder job, and vice versa.
36 * Decode output format is always MT21 no matter what
37 * the input format is.
38 * @IPI_VDEC_VP8: The interrupt from is to notify kernel to
39 * handle VP8 video decoder job, and vice versa.
40 * Decode output format is always MT21 no matter what
41 * the input format is.
42 * @IPI_VDEC_VP9: The interrupt from vpu is to notify kernel to
43 * handle VP9 video decoder job, and vice versa.
44 * Decode output format is always MT21 no matter what
45 * the input format is.
46 * @IPI_VENC_H264: The interrupt from vpu is to notify kernel to
47 * handle H264 video encoder job, and vice versa.
48 * @IPI_VENC_VP8: The interrupt fro vpu is to notify kernel to
49 * handle VP8 video encoder job,, and vice versa.
50 * @IPI_MDP: The interrupt from vpu is to notify kernel to
51 * handle MDP (Media Data Path) job, and vice versa.
52 * @IPI_MAX: The maximum IPI number
55 enum ipi_id {
56 IPI_VPU_INIT = 0,
57 IPI_VDEC_H264,
58 IPI_VDEC_VP8,
59 IPI_VDEC_VP9,
60 IPI_VENC_H264,
61 IPI_VENC_VP8,
62 IPI_MDP,
63 IPI_MAX,
66 /**
67 * enum rst_id - reset id to register reset function for VPU watchdog timeout
69 * @VPU_RST_ENC: encoder reset id
70 * @VPU_RST_DEC: decoder reset id
71 * @VPU_RST_MDP: MDP (Media Data Path) reset id
72 * @VPU_RST_MAX: maximum reset id
74 enum rst_id {
75 VPU_RST_ENC,
76 VPU_RST_DEC,
77 VPU_RST_MDP,
78 VPU_RST_MAX,
81 /**
82 * vpu_ipi_register - register an ipi function
84 * @pdev: VPU platform device
85 * @id: IPI ID
86 * @handler: IPI handler
87 * @name: IPI name
88 * @priv: private data for IPI handler
90 * Register an ipi function to receive ipi interrupt from VPU.
92 * Return: Return 0 if ipi registers successfully, otherwise it is failed.
94 int vpu_ipi_register(struct platform_device *pdev, enum ipi_id id,
95 ipi_handler_t handler, const char *name, void *priv);
97 /**
98 * vpu_ipi_send - send data from AP to vpu.
100 * @pdev: VPU platform device
101 * @id: IPI ID
102 * @buf: the data buffer
103 * @len: the data buffer length
105 * This function is thread-safe. When this function returns,
106 * VPU has received the data and starts the processing.
107 * When the processing completes, IPI handler registered
108 * by vpu_ipi_register will be called in interrupt context.
110 * Return: Return 0 if sending data successfully, otherwise it is failed.
112 int vpu_ipi_send(struct platform_device *pdev,
113 enum ipi_id id, void *buf,
114 unsigned int len);
117 * vpu_get_plat_device - get VPU's platform device
119 * @pdev: the platform device of the module requesting VPU platform
120 * device for using VPU API.
122 * Return: Return NULL if it is failed.
123 * otherwise it is VPU's platform device
125 struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
128 * vpu_wdt_reg_handler - register a VPU watchdog handler
130 * @pdev: VPU platform device
131 * @vpu_wdt_reset_func(): the callback reset function
132 * @priv: the private data for reset function
133 * @priv: the private data for reset function
134 * @id: reset id
136 * Register a handler performing own tasks when vpu reset by watchdog
138 * Return: Return 0 if the handler is added successfully,
139 * otherwise it is failed.
141 int vpu_wdt_reg_handler(struct platform_device *pdev,
142 void vpu_wdt_reset_func(void *priv),
143 void *priv, enum rst_id id);
146 * vpu_get_vdec_hw_capa - get video decoder hardware capability
148 * @pdev: VPU platform device
150 * Return: video decoder hardware capability
152 unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);
155 * vpu_get_venc_hw_capa - get video encoder hardware capability
157 * @pdev: VPU platform device
159 * Return: video encoder hardware capability
161 unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev);
164 * vpu_load_firmware - download VPU firmware and boot it
166 * @pdev: VPU platform device
168 * Return: Return 0 if downloading firmware successfully,
169 * otherwise it is failed
171 int vpu_load_firmware(struct platform_device *pdev);
174 * vpu_mapping_dm_addr - Mapping DTCM/DMEM to kernel virtual address
176 * @pdev: VPU platform device
177 * @dtcm_dmem_addr: VPU's data memory address
179 * Mapping the VPU's DTCM (Data Tightly-Coupled Memory) /
180 * DMEM (Data Extended Memory) memory address to
181 * kernel virtual address.
183 * Return: Return ERR_PTR(-EINVAL) if mapping failed,
184 * otherwise the mapped kernel virtual address
186 void *vpu_mapping_dm_addr(struct platform_device *pdev,
187 u32 dtcm_dmem_addr);
188 #endif /* _MTK_VPU_H */