blob: 8e479a6e0a8af26ba99d0257147ec910c1a0f243
1 | /* |
2 | * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | * more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 | * |
18 | * Description: |
19 | */ |
20 | #ifndef _AML_VCODEC_UTIL_H_ |
21 | #define _AML_VCODEC_UTIL_H_ |
22 | |
23 | #include <linux/types.h> |
24 | #include <linux/dma-direction.h> |
25 | #include <linux/amlogic/media/codec_mm/codec_mm.h> |
26 | |
27 | typedef unsigned long long u64; |
28 | typedef signed long long s64; |
29 | typedef unsigned int u32; |
30 | typedef unsigned short int u16; |
31 | typedef short int s16; |
32 | typedef unsigned char u8; |
33 | |
34 | #define CODEC_MODE(a, b, c, d)\ |
35 | (((u8)(a) << 24) | ((u8)(b) << 16) | ((u8)(c) << 8) | (u8)(d)) |
36 | |
37 | #define BUFF_IDX(h, i)\ |
38 | (((ulong)(h) << 8) | (u8)(i)) |
39 | |
40 | struct aml_vcodec_mem { |
41 | int index; |
42 | ulong addr; |
43 | u32 size; |
44 | void *vaddr; |
45 | u32 bytes_used; |
46 | u32 offset; |
47 | dma_addr_t dma_addr; |
48 | u32 model; |
49 | }; |
50 | |
51 | struct aml_vcodec_ctx; |
52 | struct aml_vcodec_dev; |
53 | |
54 | extern u32 debug_mode; |
55 | |
56 | #ifdef v4l_dbg |
57 | #undef v4l_dbg |
58 | #endif |
59 | |
60 | /* v4l debug define. */ |
61 | #define V4L_DEBUG_CODEC_ERROR (0) |
62 | #define V4L_DEBUG_CODEC_PRINFO (1 << 0) |
63 | #define V4L_DEBUG_CODEC_STATE (1 << 1) |
64 | #define V4L_DEBUG_CODEC_BUFMGR (1 << 2) |
65 | #define V4L_DEBUG_CODEC_INPUT (1 << 3) |
66 | #define V4L_DEBUG_CODEC_OUTPUT (1 << 4) |
67 | #define V4L_DEBUG_CODEC_COUNT (1 << 5) |
68 | #define V4L_DEBUG_CODEC_PARSER (1 << 6) |
69 | #define V4L_DEBUG_CODEC_PROT (1 << 7) |
70 | #define V4L_DEBUG_CODEC_EXINFO (1 << 8) |
71 | |
72 | #define __v4l_dbg(h, id, fmt, args...) \ |
73 | do { \ |
74 | if (h) \ |
75 | pr_info("[%d]: " fmt, id, ##args); \ |
76 | else \ |
77 | pr_info(fmt, ##args); \ |
78 | } while (0) |
79 | |
80 | #define v4l_dbg(h, flags, fmt, args...) \ |
81 | do { \ |
82 | struct aml_vcodec_ctx *__ctx = (struct aml_vcodec_ctx *) h; \ |
83 | if ((flags == V4L_DEBUG_CODEC_ERROR) || \ |
84 | (flags == V4L_DEBUG_CODEC_PRINFO) || \ |
85 | (debug_mode & flags)) { \ |
86 | if (flags == V4L_DEBUG_CODEC_ERROR) { \ |
87 | __v4l_dbg(h, __ctx->id, "[ERR]: " fmt, ##args); \ |
88 | } else { \ |
89 | __v4l_dbg(h, __ctx->id, fmt, ##args); \ |
90 | } \ |
91 | } \ |
92 | } while (0) |
93 | |
94 | void __iomem *aml_vcodec_get_reg_addr(struct aml_vcodec_ctx *data, |
95 | unsigned int reg_idx); |
96 | int aml_vcodec_mem_alloc(struct aml_vcodec_ctx *data, |
97 | struct aml_vcodec_mem *mem); |
98 | void aml_vcodec_mem_free(struct aml_vcodec_ctx *data, |
99 | struct aml_vcodec_mem *mem); |
100 | void aml_vcodec_set_curr_ctx(struct aml_vcodec_dev *dev, |
101 | struct aml_vcodec_ctx *ctx); |
102 | struct aml_vcodec_ctx *aml_vcodec_get_curr_ctx(struct aml_vcodec_dev *dev); |
103 | |
104 | #endif /* _AML_VCODEC_UTIL_H_ */ |
105 |