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