hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * rk_aiq_uapi_aldch_int.cpp
 *
 *  Copyright (c) 2019 Rockchip Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
 
#include "xcam_log.h"
#include "aldch/rk_aiq_uapi_aldch_int.h"
#include "aldch/rk_aiq_types_aldch_algo_prvt.h"
 
XCamReturn
rk_aiq_uapi_aldch_SetAttrib(RkAiqAlgoContext *ctx,
                           rk_aiq_ldch_attrib_t attr,
                           bool need_sync)
{
    LDCHHandle_t ldch_contex = (LDCHHandle_t)ctx->hLDCH;;
 
    if (!ldch_contex->ldch_en && !attr.en) {
        LOGE_AFEC("failed, ldch is disalbed!");
        return XCAM_RETURN_ERROR_FAILED;
    }
 
    if (ldch_contex->correct_level_max != 255 && \
        ldch_contex->user_config.correct_level != attr.correct_level)
        attr.correct_level = MAP_TO_255LEVEL(attr.correct_level, ldch_contex->correct_level_max);
 
    if (0 != memcmp(&ldch_contex->user_config, &attr, sizeof(rk_aiq_ldch_attrib_t))) {
        memcpy(&ldch_contex->user_config, &attr, sizeof(rk_aiq_ldch_attrib_t));
 
        SmartPtr<rk_aiq_ldch_attrib_t> attrPtr = new rk_aiq_ldch_attrib_t;
 
        attrPtr->en = ldch_contex->user_config.en;
        attrPtr->correct_level = ldch_contex->user_config.correct_level;
        ldch_contex->aldchReadMeshThread->clear_attr();
        ldch_contex->aldchReadMeshThread->push_attr(attrPtr);
        LOGV_ALDCH("ldch en(%d-%d), level(%d)\n",
                  ldch_contex->ldch_en, attrPtr->en, attrPtr->correct_level);
    }
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
rk_aiq_uapi_aldch_GetAttrib(const RkAiqAlgoContext *ctx,
                           rk_aiq_ldch_attrib_t *attr)
{
    LDCHHandle_t ldch_contex = (LDCHHandle_t)ctx->hLDCH;;
 
    memcpy(attr, &ldch_contex->user_config, sizeof(rk_aiq_ldch_attrib_t));
 
    return XCAM_RETURN_NO_ERROR;
}