summaryrefslogtreecommitdiff
path: root/drivers/frame_provider/decoder/utils/vdec_input.h (plain)
blob: 4e871e74a4f9a524a55c410f059ed08d226852c3
1/*
2 * drivers/amlogic/media/frame_provider/decoder/utils/vdec_input.h
3 *
4 * Copyright (C) 2016 Amlogic, Inc. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 */
17
18#ifndef VDEC_INPUT_H
19#define VDEC_INPUT_H
20
21struct vdec_s;
22struct vdec_input_s;
23
24struct vframe_block_list_s {
25 u32 magic;
26 int id;
27 struct list_head list;
28 ulong start;
29 void *start_virt;
30 ulong addr;
31 bool is_mapped;
32 int type;
33 u32 size;
34 u32 wp;
35 u32 rp;
36 int data_size;
37 int chunk_count;
38 int is_out_buf;
39 u32 handle;
40 struct vdec_input_s *input;
41};
42
43#define VFRAME_CHUNK_FLAG_CONSUMED 0x0001
44
45struct vframe_chunk_s {
46 u32 magic;
47 struct list_head list;
48 int flag;
49 u32 offset;
50 u32 size;
51 u32 pts;
52 u32 pading_size;
53 u64 pts64;
54 bool pts_valid;
55 u64 timestamp;
56 bool timestamp_valid;
57 u64 sequence;
58 struct vframe_block_list_s *block;
59};
60
61#define VDEC_INPUT_TARGET_VLD 0
62#define VDEC_INPUT_TARGET_HEVC 1
63#define VLD_PADDING_SIZE 1024
64#define HEVC_PADDING_SIZE (1024*16)
65
66struct vdec_input_s {
67 struct list_head vframe_block_list;
68 struct list_head vframe_chunk_list;
69 struct list_head vframe_block_free_list;
70 struct vframe_block_list_s *wr_block;
71 int have_free_blocks;
72 int no_mem_err_cnt;/*when alloc no mem cnt++*/
73 int block_nums;
74 int block_id_seq;
75 int id;
76 spinlock_t lock;
77 int type;
78 int target;
79 struct vdec_s *vdec;
80 bool swap_valid;
81 bool swap_needed;
82 bool eos;
83 struct page *swap_page;
84 unsigned long swap_page_phys;
85 u64 total_wr_count;
86 u64 total_rd_count;
87 u64 streaming_rp;
88 u32 swap_rp;
89 bool last_swap_slave;
90 int dirty_count;
91 u64 sequence;
92 unsigned start;
93 unsigned size;
94 int default_block_size;
95 int data_size;
96 int frame_max_size;
97 int prepare_level;
98/*for check frame delay.*/
99 u64 last_inpts_u64;
100 u64 last_comsumed_pts_u64;
101 int last_in_nopts_cnt;
102 int last_comsumed_no_pts_cnt;
103 int last_duration;
104/*for check frame delay.*/
105 int have_frame_num;
106 int stream_cookie; /* wrap count for vld_mem and
107 HEVC_SHIFT_BYTE_COUNT for hevc */
108 bool (*vdec_is_input_frame_empty)(struct vdec_s *);
109 void (*vdec_up)(struct vdec_s *);
110};
111
112struct vdec_input_status_s {
113 int size;
114 int data_len;
115 int free_len;
116 int read_pointer;
117};
118
119#define input_frame_based(input) \
120 (((input)->type == VDEC_TYPE_FRAME_BLOCK) || \
121 ((input)->type == VDEC_TYPE_FRAME_CIRCULAR))
122#define input_stream_based(input) \
123 (((input)->type == VDEC_TYPE_STREAM_PARSER) || \
124 ((input)->type == VDEC_TYPE_SINGLE))
125
126/* Initialize vdec_input structure */
127extern void vdec_input_init(struct vdec_input_s *input, struct vdec_s *vdec);
128extern int vdec_input_prepare_bufs(struct vdec_input_s *input,
129 int frame_width, int frame_height);
130
131/* Get available input data size */
132extern int vdec_input_level(struct vdec_input_s *input);
133
134/* Set input type and target */
135extern void vdec_input_set_type(struct vdec_input_s *input, int type,
136 int target);
137
138/* Set stream buffer information for stream based input */
139extern int vdec_input_set_buffer(struct vdec_input_s *input, u32 start,
140 u32 size);
141
142/* Add enqueue video data into decoder's input */
143extern int vdec_input_add_frame(struct vdec_input_s *input, const char *buf,
144 size_t count);
145
146extern int vdec_input_add_frame_with_dma(struct vdec_input_s *input, ulong addr,
147 size_t count, u32 handle);
148
149/* Peek next frame data from decoder's input */
150extern struct vframe_chunk_s *vdec_input_next_chunk(
151 struct vdec_input_s *input);
152
153/* Peek next frame data from decoder's input, not marked as consumed */
154extern struct vframe_chunk_s *vdec_input_next_input_chunk(
155 struct vdec_input_s *input);
156
157/* Consume next frame data from decoder's input */
158extern void vdec_input_release_chunk(struct vdec_input_s *input,
159 struct vframe_chunk_s *chunk);
160
161/* Get decoder input buffer status */
162extern int vdec_input_get_status(struct vdec_input_s *input,
163 struct vdec_input_status_s *status);
164
165extern unsigned long vdec_input_lock(struct vdec_input_s *input);
166
167extern void vdec_input_unlock(struct vdec_input_s *input, unsigned long lock);
168
169/* release all resource for decoder's input */
170extern void vdec_input_release(struct vdec_input_s *input);
171/* return block handle and free block */
172extern u32 vdec_input_get_freed_handle(struct vdec_s *vdec);
173int vdec_input_dump_chunks(int id, struct vdec_input_s *input,
174 char *bufs, int size);
175int vdec_input_dump_blocks(struct vdec_input_s *input,
176 char *bufs, int size);
177
178int vdec_input_get_duration_u64(struct vdec_input_s *input);
179
180#endif /* VDEC_INPUT_H */
181