brintos

brintos / linux-shallow public Read only

0
0
Text · 5.3 KiB · da05f3e Raw
189 lines · c
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*/6 7#ifndef _MTK_VPU_H8#define _MTK_VPU_H9 10#include <linux/platform_device.h>11 12/**13 * DOC: VPU14 *15 * VPU (video processor unit) is a tiny processor controlling video hardware16 * related to video codec, scaling and color format converting.17 * VPU interfaces with other blocks by share memory and interrupt.18 */19 20typedef void (*ipi_handler_t) (void *data,21			       unsigned int len,22			       void *priv);23 24/**25 * enum ipi_id - the id of inter-processor interrupt26 *27 * @IPI_VPU_INIT:	 The interrupt from vpu is to notfiy kernel28 *			 VPU initialization completed.29 *			 IPI_VPU_INIT is sent from VPU when firmware is30 *			 loaded. AP doesn't need to send IPI_VPU_INIT31 *			 command to VPU.32 *			 For other IPI below, AP should send the request33 *			 to VPU to trigger the interrupt.34 * @IPI_VDEC_H264:	 The interrupt from vpu is to notify kernel to35 *			 handle H264 vidoe decoder job, and vice versa.36 *			 Decode output format is always MT21 no matter what37 *			 the input format is.38 * @IPI_VDEC_VP8:	 The interrupt from is to notify kernel to39 *			 handle VP8 video decoder job, and vice versa.40 *			 Decode output format is always MT21 no matter what41 *			 the input format is.42 * @IPI_VDEC_VP9:	 The interrupt from vpu is to notify kernel to43 *			 handle VP9 video decoder job, and vice versa.44 *			 Decode output format is always MT21 no matter what45 *			 the input format is.46 * @IPI_VENC_H264:	 The interrupt from vpu is to notify kernel to47 *			 handle H264 video encoder job, and vice versa.48 * @IPI_VENC_VP8:	 The interrupt fro vpu is to notify kernel to49 *			 handle VP8 video encoder job,, and vice versa.50 * @IPI_MDP:		 The interrupt from vpu is to notify kernel to51 *			 handle MDP (Media Data Path) job, and vice versa.52 * @IPI_MAX:		 The maximum IPI number53 */54 55enum 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,64};65 66/**67 * enum rst_id - reset id to register reset function for VPU watchdog timeout68 *69 * @VPU_RST_ENC: encoder reset id70 * @VPU_RST_DEC: decoder reset id71 * @VPU_RST_MDP: MDP (Media Data Path) reset id72 * @VPU_RST_MAX: maximum reset id73 */74enum rst_id {75	VPU_RST_ENC,76	VPU_RST_DEC,77	VPU_RST_MDP,78	VPU_RST_MAX,79};80 81/**82 * vpu_ipi_register - register an ipi function83 *84 * @pdev:	VPU platform device85 * @id:		IPI ID86 * @handler:	IPI handler87 * @name:	IPI name88 * @priv:	private data for IPI handler89 *90 * Register an ipi function to receive ipi interrupt from VPU.91 *92 * Return: Return 0 if ipi registers successfully, otherwise it is failed.93 */94int vpu_ipi_register(struct platform_device *pdev, enum ipi_id id,95		     ipi_handler_t handler, const char *name, void *priv);96 97/**98 * vpu_ipi_send - send data from AP to vpu.99 *100 * @pdev:	VPU platform device101 * @id:		IPI ID102 * @buf:	the data buffer103 * @len:	the data buffer length104 *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 registered108 * by vpu_ipi_register will be called in interrupt context.109 *110 * Return: Return 0 if sending data successfully, otherwise it is failed.111 **/112int vpu_ipi_send(struct platform_device *pdev,113		 enum ipi_id id, void *buf,114		 unsigned int len);115 116/**117 * vpu_get_plat_device - get VPU's platform device118 *119 * @pdev:	the platform device of the module requesting VPU platform120 *		device for using VPU API.121 *122 * Return: Return NULL if it is failed.123 * otherwise it is VPU's platform device124 **/125struct platform_device *vpu_get_plat_device(struct platform_device *pdev);126 127/**128 * vpu_wdt_reg_handler - register a VPU watchdog handler129 *130 * @pdev:               VPU platform device131 * @vpu_wdt_reset_func():	the callback reset function132 *	@priv: the private data for reset function133 * @priv:		the private data for reset function134 * @id:			reset id135 *136 * Register a handler performing own tasks when vpu reset by watchdog137 *138 * Return: Return 0 if the handler is added successfully,139 * otherwise it is failed.140 **/141int vpu_wdt_reg_handler(struct platform_device *pdev,142			void vpu_wdt_reset_func(void *priv),143			void *priv, enum rst_id id);144 145/**146 * vpu_get_vdec_hw_capa - get video decoder hardware capability147 *148 * @pdev:	VPU platform device149 *150 * Return: video decoder hardware capability151 **/152unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);153 154/**155 * vpu_get_venc_hw_capa - get video encoder hardware capability156 *157 * @pdev:	VPU platform device158 *159 * Return: video encoder hardware capability160 **/161unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev);162 163/**164 * vpu_load_firmware - download VPU firmware and boot it165 *166 * @pdev:	VPU platform device167 *168 * Return: Return 0 if downloading firmware successfully,169 * otherwise it is failed170 **/171int vpu_load_firmware(struct platform_device *pdev);172 173/**174 * vpu_mapping_dm_addr - Mapping DTCM/DMEM to kernel virtual address175 *176 * @pdev:		VPU platform device177 * @dtcm_dmem_addr:	VPU's data memory address178 *179 * Mapping the VPU's DTCM (Data Tightly-Coupled Memory) /180 * DMEM (Data Extended Memory) memory address to181 * kernel virtual address.182 *183 * Return: Return ERR_PTR(-EINVAL) if mapping failed,184 * otherwise the mapped kernel virtual address185 **/186void *vpu_mapping_dm_addr(struct platform_device *pdev,187			  u32 dtcm_dmem_addr);188#endif /* _MTK_VPU_H */189