2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 #include <linux/platform_device.h>
21 * VPU (video processor unit) is a tiny processor controlling video hardware
22 * related to video codec, scaling and color format converting.
23 * VPU interfaces with other blocks by share memory and interrupt.
26 typedef void (*ipi_handler_t) (void *data,
31 * enum ipi_id - the id of inter-processor interrupt
33 * @IPI_VPU_INIT: The interrupt from vpu is to notfiy kernel
34 VPU initialization completed.
35 IPI_VPU_INIT is sent from VPU when firmware is
36 loaded. AP doesn't need to send IPI_VPU_INIT
38 For other IPI below, AP should send the request
39 to VPU to trigger the interrupt.
40 * @IPI_VENC_H264: The interrupt from vpu is to notify kernel to
41 handle H264 video encoder job, and vice versa.
42 * @IPI_VENC_VP8: The interrupt fro vpu is to notify kernel to
43 handle VP8 video encoder job,, and vice versa.
44 * @IPI_MAX: The maximum IPI number
55 * enum rst_id - reset id to register reset function for VPU watchdog timeout
57 * @VPU_RST_ENC: encoder reset id
58 * @VPU_RST_MAX: maximum reset id
66 * vpu_ipi_register - register an ipi function
68 * @pdev: VPU platform device
70 * @handler: IPI handler
72 * @priv: private data for IPI handler
74 * Register an ipi function to receive ipi interrupt from VPU.
76 * Return: Return 0 if ipi registers successfully, otherwise it is failed.
78 int vpu_ipi_register(struct platform_device *pdev, enum ipi_id id,
79 ipi_handler_t handler, const char *name, void *priv);
82 * vpu_ipi_send - send data from AP to vpu.
84 * @pdev: VPU platform device
86 * @buf: the data buffer
87 * @len: the data buffer length
89 * This function is thread-safe. When this function returns,
90 * VPU has received the data and starts the processing.
91 * When the processing completes, IPI handler registered
92 * by vpu_ipi_register will be called in interrupt context.
94 * Return: Return 0 if sending data successfully, otherwise it is failed.
96 int vpu_ipi_send(struct platform_device *pdev,
97 enum ipi_id id, void *buf,
101 * vpu_get_plat_device - get VPU's platform device
103 * @pdev: the platform device of the module requesting VPU platform
104 * device for using VPU API.
106 * Return: Return NULL if it is failed.
107 * otherwise it is VPU's platform device
109 struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
112 * vpu_wdt_reg_handler - register a VPU watchdog handler
114 * @pdev: VPU platform device
115 * @vpu_wdt_reset_func: the callback reset function
116 * @private_data: the private data for reset function
119 * Register a handler performing own tasks when vpu reset by watchdog
121 * Return: Return 0 if the handler is added successfully,
122 * otherwise it is failed.
125 int vpu_wdt_reg_handler(struct platform_device *pdev,
126 void vpu_wdt_reset_func(void *),
127 void *priv, enum rst_id id);
129 * vpu_get_venc_hw_capa - get video encoder hardware capability
131 * @pdev: VPU platform device
133 * Return: video encoder hardware capability
135 unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev);
138 * vpu_load_firmware - download VPU firmware and boot it
140 * @pdev: VPU platform device
142 * Return: Return 0 if downloading firmware successfully,
143 * otherwise it is failed
145 int vpu_load_firmware(struct platform_device *pdev);
148 * vpu_mapping_dm_addr - Mapping DTCM/DMEM to kernel virtual address
150 * @pdev: VPU platform device
151 * @dmem_addr: VPU's data memory address
153 * Mapping the VPU's DTCM (Data Tightly-Coupled Memory) /
154 * DMEM (Data Extended Memory) memory address to
155 * kernel virtual address.
157 * Return: Return ERR_PTR(-EINVAL) if mapping failed,
158 * otherwise the mapped kernel virtual address
160 void *vpu_mapping_dm_addr(struct platform_device *pdev,
162 #endif /* _MTK_VPU_H */