File Index
Files and directories
Sign in
FILE

mtk_vpu.h

File preview with syntax highlighting.

linux-6.19.14/drivers/media/platform/mediatek/vpu/mtk_vpu.h 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_H
  8#define _MTK_VPU_H
  9
 10#include <linux/platform_device.h>
 11
 12/**
 13 * DOC: VPU
 14 *
 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.
 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 interrupt
 26 *
 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
 53 */
 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 timeout
 68 *
 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
 73 */
 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 function
 83 *
 84 * @pdev:	VPU platform device
 85 * @id:		IPI ID
 86 * @handler:	IPI handler
 87 * @name:	IPI name
 88 * @priv:	private data for IPI handler
 89 *
 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 device
101 * @id:		IPI ID
102 * @buf:	the data buffer
103 * @len:	the data buffer length
104 *
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.
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 device
118 *
119 * @pdev:	the platform device of the module requesting VPU platform
120 *		device for using VPU API.
121 *
122 * Return: Return NULL if it is failed.
123 * otherwise it is VPU's platform device
124 **/
125struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
126
127/**
128 * vpu_wdt_reg_handler - register a VPU watchdog handler
129 *
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
135 *
136 * Register a handler performing own tasks when vpu reset by watchdog
137 *
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 capability
147 *
148 * @pdev:	VPU platform device
149 *
150 * Return: video decoder hardware capability
151 **/
152unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);
153
154/**
155 * vpu_get_venc_hw_capa - get video encoder hardware capability
156 *
157 * @pdev:	VPU platform device
158 *
159 * Return: video encoder hardware capability
160 **/
161unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev);
162
163/**
164 * vpu_load_firmware - download VPU firmware and boot it
165 *
166 * @pdev:	VPU platform device
167 *
168 * Return: Return 0 if downloading firmware successfully,
169 * otherwise it is failed
170 **/
171int vpu_load_firmware(struct platform_device *pdev);
172
173/**
174 * vpu_mapping_dm_addr - Mapping DTCM/DMEM to kernel virtual address
175 *
176 * @pdev:		VPU platform device
177 * @dtcm_dmem_addr:	VPU's data memory address
178 *
179 * Mapping the VPU's DTCM (Data Tightly-Coupled Memory) /
180 * DMEM (Data Extended Memory) memory address to
181 * kernel virtual address.
182 *
183 * Return: Return ERR_PTR(-EINVAL) if mapping failed,
184 * otherwise the mapped kernel virtual address
185 **/
186void *vpu_mapping_dm_addr(struct platform_device *pdev,
187			  u32 dtcm_dmem_addr);
188#endif /* _MTK_VPU_H */
~/ Read-only file preview.