1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016 MediaTek Inc.
4 * Author: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
10 #include <linux/platform_device.h>
13 * VPU (video processor unit) is a tiny processor controlling video hardware
14 * related to video codec, scaling and color format converting.
15 * VPU interfaces with other blocks by share memory and interrupt.
18 typedef void (*ipi_handler_t
) (const void *data
,
23 * enum ipi_id - the id of inter-processor interrupt
25 * @IPI_VPU_INIT: The interrupt from vpu is to notfiy kernel
26 * VPU initialization completed.
27 * IPI_VPU_INIT is sent from VPU when firmware is
28 * loaded. AP doesn't need to send IPI_VPU_INIT
30 * For other IPI below, AP should send the request
31 * to VPU to trigger the interrupt.
32 * @IPI_VDEC_H264: The interrupt from vpu is to notify kernel to
33 * handle H264 vidoe decoder job, and vice versa.
34 * Decode output format is always MT21 no matter what
35 * the input format is.
36 * @IPI_VDEC_VP8: The interrupt from is to notify kernel to
37 * handle VP8 video decoder job, and vice versa.
38 * Decode output format is always MT21 no matter what
39 * the input format is.
40 * @IPI_VDEC_VP9: The interrupt from vpu is to notify kernel to
41 * handle VP9 video decoder job, and vice versa.
42 * Decode output format is always MT21 no matter what
43 * the input format is.
44 * @IPI_VENC_H264: The interrupt from vpu is to notify kernel to
45 * handle H264 video encoder job, and vice versa.
46 * @IPI_VENC_VP8: The interrupt fro vpu is to notify kernel to
47 * handle VP8 video encoder job,, and vice versa.
48 * @IPI_MDP: The interrupt from vpu is to notify kernel to
49 * handle MDP (Media Data Path) job, and vice versa.
50 * @IPI_MAX: The maximum IPI number
65 * enum rst_id - reset id to register reset function for VPU watchdog timeout
67 * @VPU_RST_ENC: encoder reset id
68 * @VPU_RST_DEC: decoder reset id
69 * @VPU_RST_MDP: MDP (Media Data Path) reset id
70 * @VPU_RST_MAX: maximum reset id
80 * vpu_ipi_register - register an ipi function
82 * @pdev: VPU platform device
84 * @handler: IPI handler
86 * @priv: private data for IPI handler
88 * Register an ipi function to receive ipi interrupt from VPU.
90 * Return: Return 0 if ipi registers successfully, otherwise it is failed.
92 int vpu_ipi_register(struct platform_device
*pdev
, enum ipi_id id
,
93 ipi_handler_t handler
, const char *name
, void *priv
);
96 * vpu_ipi_send - send data from AP to vpu.
98 * @pdev: VPU platform device
100 * @buf: the data buffer
101 * @len: the data buffer length
103 * This function is thread-safe. When this function returns,
104 * VPU has received the data and starts the processing.
105 * When the processing completes, IPI handler registered
106 * by vpu_ipi_register will be called in interrupt context.
108 * Return: Return 0 if sending data successfully, otherwise it is failed.
110 int vpu_ipi_send(struct platform_device
*pdev
,
111 enum ipi_id id
, void *buf
,
115 * vpu_get_plat_device - get VPU's platform device
117 * @pdev: the platform device of the module requesting VPU platform
118 * device for using VPU API.
120 * Return: Return NULL if it is failed.
121 * otherwise it is VPU's platform device
123 struct platform_device
*vpu_get_plat_device(struct platform_device
*pdev
);
126 * vpu_wdt_reg_handler - register a VPU watchdog handler
128 * @pdev: VPU platform device
129 * @vpu_wdt_reset_func: the callback reset function
130 * @private_data: the private data for reset function
133 * Register a handler performing own tasks when vpu reset by watchdog
135 * Return: Return 0 if the handler is added successfully,
136 * otherwise it is failed.
139 int vpu_wdt_reg_handler(struct platform_device
*pdev
,
140 void vpu_wdt_reset_func(void *),
141 void *priv
, enum rst_id id
);
144 * vpu_get_vdec_hw_capa - get video decoder hardware capability
146 * @pdev: VPU platform device
148 * Return: video decoder hardware capability
150 unsigned int vpu_get_vdec_hw_capa(struct platform_device
*pdev
);
153 * vpu_get_venc_hw_capa - get video encoder hardware capability
155 * @pdev: VPU platform device
157 * Return: video encoder hardware capability
159 unsigned int vpu_get_venc_hw_capa(struct platform_device
*pdev
);
162 * vpu_load_firmware - download VPU firmware and boot it
164 * @pdev: VPU platform device
166 * Return: Return 0 if downloading firmware successfully,
167 * otherwise it is failed
169 int vpu_load_firmware(struct platform_device
*pdev
);
172 * vpu_mapping_dm_addr - Mapping DTCM/DMEM to kernel virtual address
174 * @pdev: VPU platform device
175 * @dmem_addr: VPU's data memory address
177 * Mapping the VPU's DTCM (Data Tightly-Coupled Memory) /
178 * DMEM (Data Extended Memory) memory address to
179 * kernel virtual address.
181 * Return: Return ERR_PTR(-EINVAL) if mapping failed,
182 * otherwise the mapped kernel virtual address
184 void *vpu_mapping_dm_addr(struct platform_device
*pdev
,
186 #endif /* _MTK_VPU_H */