1 /*
2 * Copyright (c) 2019 Rockchip Corporation
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
18 #include "sample_comm.h"
19
20 /*
21 ******************************
22 *
23 * Module level API Sample Func
24 *
25 ******************************
26 */
27
sample_dpcc_set_attr(const rk_aiq_sys_ctx_t * ctx,rk_aiq_uapi_mode_sync_e sync)28 static int sample_dpcc_set_attr(const rk_aiq_sys_ctx_t *ctx,
29 rk_aiq_uapi_mode_sync_e sync) {
30 XCamReturn ret = XCAM_RETURN_NO_ERROR;
31 rk_aiq_dpcc_attrib_V20_t attr;
32 memset(&attr, 0, sizeof(rk_aiq_dpcc_attrib_V20_t));
33
34 ret = rk_aiq_user_api2_adpcc_GetAttrib(ctx, &attr);
35 RKAIQ_SAMPLE_CHECK_RET(ret, "set dpccAttr failed in getting dpcc attrib!");
36
37 printf("dpcc set config:[%d][%d][%d]\n",
38 attr.stManual.stOnfly.expert_mode.stage1_use_set_1,
39 attr.stManual.stOnfly.expert_mode.stage1_use_set_2,
40 attr.stManual.stOnfly.expert_mode.stage1_use_set_3);
41
42 attr.sync.sync_mode = sync;
43 if (attr.eMode == ADPCC_OP_MODE_AUTO) {
44 attr.eMode = ADPCC_OP_MODE_MANUAL;
45 attr.stManual.stOnfly.mode = ADPCC_ONFLY_MODE_EXPERT;
46 attr.stManual.stOnfly.expert_mode.stage1_use_set_1 = 1;
47 attr.stManual.stOnfly.expert_mode.stage1_use_set_2 = 1;
48 attr.stManual.stOnfly.expert_mode.stage1_use_set_3 = 1;
49 } else {
50 attr.eMode = ADPCC_OP_MODE_AUTO;
51 }
52 // set
53 ret = rk_aiq_user_api2_adpcc_SetAttrib(ctx, &attr);
54 RKAIQ_SAMPLE_CHECK_RET(ret, "set dpcc Attr failed!");
55 printf("set dpcc Attr\n\n");
56
57 return 0;
58 }
59
sample_dpcc_get_attr(const rk_aiq_sys_ctx_t * ctx)60 static int sample_dpcc_get_attr(const rk_aiq_sys_ctx_t *ctx) {
61 XCamReturn ret = XCAM_RETURN_NO_ERROR;
62 rk_aiq_dpcc_attrib_V20_t attr;
63 memset(&attr, 0, sizeof(rk_aiq_dpcc_attrib_V20_t));
64 // get
65 ret = rk_aiq_user_api2_adpcc_GetAttrib(ctx, &attr);
66 RKAIQ_SAMPLE_CHECK_RET(ret, "get dpcc Attr failed!");
67 printf("get dpcc Attr:\n\n");
68 printf("\t sync = %d, done = %d\n", attr.sync.sync_mode, attr.sync.done);
69 if (attr.eMode == ADPCC_OP_MODE_MANUAL) {
70 printf("\t mode = Manual\n");
71 printf("dpcc set config:[%d][%d][%d]\n",
72 attr.stManual.stOnfly.expert_mode.stage1_use_set_1,
73 attr.stManual.stOnfly.expert_mode.stage1_use_set_2,
74 attr.stManual.stOnfly.expert_mode.stage1_use_set_3);
75 } else if (attr.eMode == ADPCC_OP_MODE_AUTO) {
76 printf("\t mode = Auto\n");
77 } else {
78 printf("\t mode is unkown");
79 }
80 return 0;
81 }
82
sample_dpcc_set_attr_async(const rk_aiq_sys_ctx_t * ctx)83 static int sample_dpcc_set_attr_async(const rk_aiq_sys_ctx_t *ctx) {
84 sample_dpcc_set_attr(ctx, RK_AIQ_UAPI_MODE_ASYNC);
85 sample_dpcc_get_attr(ctx);
86 usleep(40 * 1000);
87 sample_dpcc_get_attr(ctx);
88
89 return 0;
90 }
91
sample_dpcc_set_attr_sync(const rk_aiq_sys_ctx_t * ctx)92 static int sample_dpcc_set_attr_sync(const rk_aiq_sys_ctx_t *ctx) {
93 sample_dpcc_set_attr(ctx, RK_AIQ_UAPI_MODE_DEFAULT);
94 sample_dpcc_get_attr(ctx);
95
96 return 0;
97 }
98
99 uapi_case_t dpcc_uapi_list[] = {
100 {
101 .desc = "Adpcc: set dpcc config async",
102 .func = (uapi_case_func)sample_dpcc_set_attr_async
103 },
104 {
105 .desc = "Adpcc: set dpcc config sync",
106 .func = (uapi_case_func)sample_dpcc_set_attr_sync
107 },
108 {
109 .desc = "Adpcc: get dpcc config",
110 .func = (uapi_case_func)sample_dpcc_get_attr
111 },
112 {
113 .desc = NULL,
114 .func = NULL,
115 }
116 };
117
sample_adpcc_module(const void * arg)118 XCamReturn sample_adpcc_module(const void *arg) {
119 int key = -1;
120 CLEAR();
121 const demo_context_t *demo_ctx = (demo_context_t *)arg;
122 const rk_aiq_sys_ctx_t *ctx;
123 if (demo_ctx->camGroup) {
124 ctx = (rk_aiq_sys_ctx_t *)(demo_ctx->camgroup_ctx);
125 } else {
126 ctx = (rk_aiq_sys_ctx_t *)(demo_ctx->aiq_ctx);
127 }
128
129 if (ctx == nullptr) {
130 ERR("%s, ctx is nullptr\n", __FUNCTION__);
131 return XCAM_RETURN_ERROR_PARAM;
132 }
133
134 uapi_process_loop(ctx, dpcc_uapi_list);
135
136 return XCAM_RETURN_NO_ERROR;
137 }
138