blob: e93900e744fd41086992a4484b1a13ab484081cb
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 | #define DEBUG |
28 | |
29 | typedef unsigned long long u64; |
30 | typedef signed long long s64; |
31 | typedef unsigned int u32; |
32 | typedef unsigned short int u16; |
33 | typedef short int s16; |
34 | typedef unsigned char u8; |
35 | |
36 | #define CODEC_MODE(a, b, c, d)\ |
37 | (((u8)(a) << 24) | ((u8)(b) << 16) | ((u8)(c) << 8) | (u8)(d)) |
38 | |
39 | struct aml_vcodec_mem { |
40 | ulong addr; |
41 | u32 size; |
42 | void *vaddr; |
43 | u32 bytes_used; |
44 | u32 offset; |
45 | dma_addr_t dma_addr; |
46 | }; |
47 | |
48 | struct aml_vcodec_ctx; |
49 | struct aml_vcodec_dev; |
50 | |
51 | extern int aml_v4l2_dbg_level; |
52 | extern bool aml_vcodec_dbg; |
53 | |
54 | |
55 | #if defined(DEBUG) |
56 | |
57 | #define aml_v4l2_debug(level, fmt, args...) \ |
58 | do { \ |
59 | if (aml_v4l2_dbg_level >= level) \ |
60 | pr_info(fmt "\n", ##args); \ |
61 | } while (0) |
62 | |
63 | #define aml_v4l2_debug_enter() aml_v4l2_debug(3, "+") |
64 | #define aml_v4l2_debug_leave() aml_v4l2_debug(3, "-") |
65 | |
66 | #define aml_vcodec_debug(h, fmt, args...) \ |
67 | do { \ |
68 | if (aml_vcodec_dbg) \ |
69 | pr_info("[%d]: %s() " fmt "\n", \ |
70 | ((struct aml_vcodec_ctx *)h->ctx)->id, \ |
71 | __func__, ##args); \ |
72 | } while (0) |
73 | |
74 | #define aml_vcodec_debug_enter(h) aml_vcodec_debug(h, "+") |
75 | #define aml_vcodec_debug_leave(h) aml_vcodec_debug(h, "-") |
76 | |
77 | #else |
78 | |
79 | #define aml_v4l2_debug(level, fmt, args...) |
80 | #define aml_v4l2_debug_enter() |
81 | #define aml_v4l2_debug_leave() |
82 | |
83 | #define aml_vcodec_debug(h, fmt, args...) |
84 | #define aml_vcodec_debug_enter(h) |
85 | #define aml_vcodec_debug_leave(h) |
86 | |
87 | #endif |
88 | |
89 | #define aml_v4l2_err(fmt, args...) \ |
90 | pr_err("[ERR]" fmt "\n", ##args) |
91 | |
92 | #define aml_vcodec_err(h, fmt, args...) \ |
93 | pr_err("[ERR][%d]" fmt "\n", \ |
94 | ((struct aml_vcodec_ctx *)h->ctx)->id, ##args) |
95 | |
96 | void __iomem *aml_vcodec_get_reg_addr(struct aml_vcodec_ctx *data, |
97 | unsigned int reg_idx); |
98 | int aml_vcodec_mem_alloc(struct aml_vcodec_ctx *data, |
99 | struct aml_vcodec_mem *mem); |
100 | void aml_vcodec_mem_free(struct aml_vcodec_ctx *data, |
101 | struct aml_vcodec_mem *mem); |
102 | void aml_vcodec_set_curr_ctx(struct aml_vcodec_dev *dev, |
103 | struct aml_vcodec_ctx *ctx); |
104 | struct aml_vcodec_ctx *aml_vcodec_get_curr_ctx(struct aml_vcodec_dev *dev); |
105 | |
106 | #endif /* _AML_VCODEC_UTIL_H_ */ |
107 |