xref: /rockchip-linux_mpp/mpp/base/mpp_sys_cfg_st.c (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3  * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
4  */
5 
6 #define MODULE_TAG "mpp_sys_cfg_st"
7 
8 #include "mpp_log.h"
9 #include "mpp_mem.h"
10 #include "mpp_time.h"
11 #include "mpp_common.h"
12 
13 #include "rk_mpp_cfg.h"
14 #include "mpp_sys_cfg.h"
15 #include "mpp_sys_cfg_st.h"
16 
mpp_sys_cfg_st_get_h_stride(MppSysCfgStHStrd * h_stride_cfg)17 MPP_RET mpp_sys_cfg_st_get_h_stride(MppSysCfgStHStrd *h_stride_cfg)
18 {
19     MPP_RET ret = MPP_OK;
20     MppSysCfg cfg;
21 
22     ret = mpp_sys_cfg_get(&cfg);
23     if (ret) {
24         mpp_err("mpp_sys_cfg_get failed\n");
25         goto DONE;
26     }
27 
28     /* set correct parameter */
29     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
30     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", h_stride_cfg->type);
31     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", h_stride_cfg->fmt_fbc);
32     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", h_stride_cfg->width);
33     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", h_stride_cfg->h_stride_by_byte);
34 
35     /* get result */
36     mpp_sys_cfg_ioctl(cfg);
37 
38     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_pixel",
39                               &h_stride_cfg->h_stride_by_pixel);
40 
41     ret = mpp_sys_cfg_put(cfg);
42     if (ret) {
43         mpp_err("mpp_sys_cfg_put failed\n");
44         goto DONE;
45     }
46 
47 DONE:
48     mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
49     return ret;
50 }
51 
mpp_sys_cfg_st_get_byte_stride(MppSysCfgStHByteStrd * byte_stride_cfg)52 MPP_RET mpp_sys_cfg_st_get_byte_stride(MppSysCfgStHByteStrd *byte_stride_cfg)
53 {
54     MPP_RET ret = MPP_OK;
55     MppSysCfg cfg;
56 
57     ret = mpp_sys_cfg_get(&cfg);
58     if (ret) {
59         mpp_err("mpp_sys_cfg_get failed\n");
60         goto DONE;
61     }
62 
63     /* set correct parameter */
64     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
65     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", byte_stride_cfg->type);
66     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_codec", byte_stride_cfg->fmt_codec);
67     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", byte_stride_cfg->fmt_fbc);
68     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", byte_stride_cfg->width);
69     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", byte_stride_cfg->h_stride_by_byte);
70 
71     /* get result */
72     mpp_sys_cfg_ioctl(cfg);
73 
74     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_byte",
75                               &byte_stride_cfg->h_stride_by_byte);
76 
77     ret = mpp_sys_cfg_put(cfg);
78     if (ret) {
79         mpp_err("mpp_sys_cfg_put failed\n");
80         goto DONE;
81     }
82 
83 DONE:
84     mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
85     return ret;
86 }
87 
mpp_sys_cfg_st_get_v_stride(MppSysCfgStVStrd * v_stride_cfg)88 MPP_RET mpp_sys_cfg_st_get_v_stride(MppSysCfgStVStrd *v_stride_cfg)
89 {
90     MPP_RET ret = MPP_OK;
91     MppSysCfg cfg;
92 
93     ret = mpp_sys_cfg_get(&cfg);
94     if (ret) {
95         mpp_err("mpp_sys_cfg_get failed\n");
96         goto DONE;
97     }
98 
99     /* set correct parameter */
100     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
101     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", v_stride_cfg->type);
102     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", v_stride_cfg->fmt_fbc);
103     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:height", v_stride_cfg->height);
104     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:v_stride", v_stride_cfg->v_stride);
105 
106     /* get result */
107     mpp_sys_cfg_ioctl(cfg);
108 
109     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:v_stride", &v_stride_cfg->v_stride);
110 
111     ret = mpp_sys_cfg_put(cfg);
112     if (ret) {
113         mpp_err("mpp_sys_cfg_put failed\n");
114         goto DONE;
115     }
116 
117 DONE:
118     mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
119     return ret;
120 }
121 
mpp_sys_cfg_st_get_size(MppSysCfgStSize * size_cfg)122 MPP_RET mpp_sys_cfg_st_get_size(MppSysCfgStSize *size_cfg)
123 {
124     MPP_RET ret = MPP_OK;
125     MppSysCfg cfg;
126 
127     ret = mpp_sys_cfg_get(&cfg);
128     if (ret) {
129         mpp_err("mpp_sys_cfg_get failed\n");
130         goto DONE;
131     }
132 
133     /* set correct parameter */
134     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:enable", 1);
135     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:type", size_cfg->type);
136     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_codec", size_cfg->fmt_codec);
137     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:fmt_fbc", size_cfg->fmt_fbc);
138     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:width", size_cfg->width);
139     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:height", size_cfg->height);
140     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:h_stride_by_byte", size_cfg->h_stride_by_byte);
141     ret = mpp_sys_cfg_set_u32(cfg, "dec_buf_chk:v_stride", size_cfg->v_stride);
142 
143     /* get result */
144     mpp_sys_cfg_ioctl(cfg);
145 
146     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_byte", &size_cfg->h_stride_by_byte);
147     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:h_stride_by_pixel", &size_cfg->h_stride_by_pixel);
148     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:v_stride", &size_cfg->v_stride);
149     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_total", &size_cfg->size_total);
150     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_fbc_hdr", &size_cfg->size_fbc_hdr);
151     ret = mpp_sys_cfg_get_u32(cfg, "dec_buf_chk:size_fbc_bdy", &size_cfg->size_fbc_bdy);
152 
153     ret = mpp_sys_cfg_put(cfg);
154     if (ret) {
155         mpp_err("mpp_sys_cfg_put failed\n");
156         goto DONE;
157     }
158 
159 DONE:
160     mpp_err_f("sys cfg get paras %s\n", ret ? "failed" : "success");
161     return ret;
162 }
163