hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
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
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * NVIDIA Tegra Video decoder driver
 *
 * Copyright (C) 2016-2019 GRATE-DRIVER project
 */
 
#ifndef TEGRA_VDE_H
#define TEGRA_VDE_H
 
#include <linux/completion.h>
#include <linux/dma-direction.h>
#include <linux/iova.h>
#include <linux/list.h>
#include <linux/miscdevice.h>
#include <linux/mutex.h>
#include <linux/types.h>
 
struct clk;
struct dma_buf;
struct gen_pool;
struct iommu_group;
struct iommu_domain;
struct reset_control;
struct dma_buf_attachment;
 
struct tegra_vde {
   void __iomem *sxe;
   void __iomem *bsev;
   void __iomem *mbe;
   void __iomem *ppe;
   void __iomem *mce;
   void __iomem *tfe;
   void __iomem *ppb;
   void __iomem *vdma;
   void __iomem *frameid;
   struct mutex lock;
   struct mutex map_lock;
   struct list_head map_list;
   struct miscdevice miscdev;
   struct reset_control *rst;
   struct reset_control *rst_mc;
   struct gen_pool *iram_pool;
   struct completion decode_completion;
   struct clk *clk;
   struct iommu_domain *domain;
   struct iommu_group *group;
   struct iova_domain iova;
   struct iova *iova_resv_static_addresses;
   struct iova *iova_resv_last_page;
   dma_addr_t iram_lists_addr;
   u32 *iram;
};
 
int tegra_vde_iommu_init(struct tegra_vde *vde);
void tegra_vde_iommu_deinit(struct tegra_vde *vde);
int tegra_vde_iommu_map(struct tegra_vde *vde,
           struct sg_table *sgt,
           struct iova **iovap,
           size_t size);
void tegra_vde_iommu_unmap(struct tegra_vde *vde, struct iova *iova);
 
int tegra_vde_dmabuf_cache_map(struct tegra_vde *vde,
                  struct dma_buf *dmabuf,
                  enum dma_data_direction dma_dir,
                  struct dma_buf_attachment **ap,
                  dma_addr_t *addrp);
void tegra_vde_dmabuf_cache_unmap(struct tegra_vde *vde,
                 struct dma_buf_attachment *a,
                 bool release);
void tegra_vde_dmabuf_cache_unmap_sync(struct tegra_vde *vde);
void tegra_vde_dmabuf_cache_unmap_all(struct tegra_vde *vde);
 
static __maybe_unused char const *
tegra_vde_reg_base_name(struct tegra_vde *vde, void __iomem *base)
{
   if (vde->sxe == base)
       return "SXE";
 
   if (vde->bsev == base)
       return "BSEV";
 
   if (vde->mbe == base)
       return "MBE";
 
   if (vde->ppe == base)
       return "PPE";
 
   if (vde->mce == base)
       return "MCE";
 
   if (vde->tfe == base)
       return "TFE";
 
   if (vde->ppb == base)
       return "PPB";
 
   if (vde->vdma == base)
       return "VDMA";
 
   if (vde->frameid == base)
       return "FRAMEID";
 
   return "???";
}
 
#endif /* TEGRA_VDE_H */