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