/*************************************************************************************************
// INTEL CONFIDENTIAL Copyright 2025-2026 Intel Corporation All Rights Reserved.
//
// The source code contained or described herein and all documents related to the source code
// ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material
// remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets
// and proprietary and confidential information of Intel or its suppliers and licensors. The Material is
// protected by worldwide copyright and trade secret laws and treaty provisions. No part of the
// Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted,
// distributed, or disclosed in any way without Intel's prior express written permission.
//
// No license under any patent, copyright, trade secret or other intellectual property right is
// granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by
// implication, inducement, estoppel or otherwise. Any license under such intellectual property
// rights must be express and approved by Intel in writing.
//*************************************************************************************************/

#ifndef __FOCUS_TLEN__
#define __FOCUS_TLEN__

// TLen Control Board Registers
#define TLEN_DAC_MODE                   0x00    // [0  ] [RW] 0: PD50 in standby mode, 1: PD50 in active mode
                                                // [2:1] [RW] 0: Reserved, keep default value
#define TLEN_DAC_SPEED                  0x01    // [3:0] [RW] Charge pump speed and analog control speed. Keep default value
                                                // [5:4] [RW] Current Sink Strength. Keep default value
#define TLEN_DAC_MSB                    0x02    // [1:0] [RW] DAC[9:8] 2 MSB bits of the 10-bit DAC code
                                                // [6:2] [RO] Not used
                                                // [7  ] [RW] Polarity selection, 1: Positive polarity; OutP >= OutN
                                                //                                0: Negative polarity; OutP <= OutN
#define TLEN_DAC_LSB                    0x03    // [7:0] [RW] LSB of DAC
                                                //            Register write will update DAC_MSB and DAC_LSB to voltage control system
#define TLEN_DAC_STATUS                 0x04    // [0  ] [RO] VOUT_LOCK: 0: Output voltage out of range
                                                //                       1: Output voltage within +/-VLOCK_DIFF range
                                                // [1  ] [RW] Dac Write Error latch. Write 0 to STATUS register to reset latch
                                                //            0: No Dac write error event since last write.
                                                //            1: DAC_LSB write while VOUT_LOCKED=0.
                                                // [2:7] [R0] Reserved
#define TLEN_CHIP_ID                    0x07    // [7:0] [RO] 0xA2 Revision ID for PD50.

// Focus configuration
#define TLEN_HOME_FOCUS_POS             200 // Todo: to align default pos with tuning, 0 is a far focus
#define TLEN_MIN_DAC                    0 // (-183) is real min DAC but negative valtage is not nessary for front camera
#define TLEN_MAX_DAC                    875 // PD50LE MAX_DAC value for 3.3V Power Supply, 920 for 3.5v Power Supply
#define TLEN_DEFAULT_FOCUS_POS          TLEN_HOME_FOCUS_POS
#define TLEN_CHIPID_NAME                0xA3
#define TLEN_CHIPID_NAME_EX             0xA2
#define TlEN_RESET_DELAY                1

#define TlEN_MODE_ACTIVE                1
#define TlEN_MODE_STANDBY               0

NTSTATUS TLen_Init(
    PVCM_CONTEXT pSsVcm
    );

NTSTATUS TLen_ResetPos(
    PVCM_CONTEXT pSsVcm
    );

NTSTATUS TLen_SetPos(
    PVCM_CONTEXT pSsVcm,
    USHORT FocusPos
    );

NTSTATUS TLen_GetPos(
    PVCM_CONTEXT pSsVcm,
    USHORT * FocusPos
    );

NTSTATUS TLen_GetStatus(
    PVCM_CONTEXT pSsVcm,
    PULONG Status
    );

NTSTATUS TLen_GetHPStatus(
    PVCM_CONTEXT pSsVcm,
    PULONG Status
    );

NTSTATUS TLen_SetConfig(
    PVCM_CONTEXT pSsVcm,
    SNSR_VCMDATA * pSnsrVcmData
    );

#endif __FOCUS_TLEN__
