xref: /rockchip-linux_mpp/mpp/hal/rkdec/avsd/hal_avsd_base.c (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define MODULE_TAG "hal_avsd_base"
18 #include <assert.h>
19 #include "mpp_log.h"
20 #include "mpp_common.h"
21 
22 #include "hal_avsd_base.h"
23 
24 
25 RK_U32 avsd_hal_debug = 0;
26 
avsd_ver_align(RK_U32 val)27 RK_U32 avsd_ver_align(RK_U32 val)
28 {
29     return MPP_ALIGN(val, 16);
30 }
31 
avsd_hor_align(RK_U32 val)32 RK_U32 avsd_hor_align(RK_U32 val)
33 {
34     return MPP_ALIGN(val, 16);
35 }
36 
avsd_len_align(RK_U32 val)37 RK_U32 avsd_len_align(RK_U32 val)
38 {
39     return (2 * MPP_ALIGN(val, 16));
40 }
41 
get_queue_pic(AvsdHalCtx_t * p_hal)42 RK_S32 get_queue_pic(AvsdHalCtx_t *p_hal)
43 {
44     RK_U32 i = 0;
45     RK_S32 ret_idx = -1;
46 
47     for (i = 0; i < MPP_ARRAY_ELEMS(p_hal->pic); i++) {
48         if (!p_hal->pic[i].valid) {
49             ret_idx = i;
50             p_hal->pic[i].valid = 1;
51             break;
52         }
53     }
54 
55     return ret_idx;
56 }
57 
get_packet_fd(AvsdHalCtx_t * p_hal,RK_S32 idx)58 RK_S32 get_packet_fd(AvsdHalCtx_t *p_hal, RK_S32 idx)
59 {
60     RK_S32 ret_fd = 0;
61     MppBuffer mbuffer = NULL;
62 
63     mpp_buf_slot_get_prop(p_hal->packet_slots, idx, SLOT_BUFFER, &mbuffer);
64     assert(mbuffer);
65     ret_fd =  mpp_buffer_get_fd(mbuffer);
66 
67     return ret_fd;
68 }
69 
get_frame_fd(AvsdHalCtx_t * p_hal,RK_S32 idx)70 RK_S32 get_frame_fd(AvsdHalCtx_t *p_hal, RK_S32 idx)
71 {
72     RK_S32 ret_fd = 0;
73     MppBuffer mbuffer = NULL;
74 
75     mpp_buf_slot_get_prop(p_hal->frame_slots, idx, SLOT_BUFFER, &mbuffer);
76     assert(mbuffer);
77     ret_fd = mpp_buffer_get_fd(mbuffer);
78 
79     return ret_fd;
80 }
81