Files
2026-08-24 10:03:24 +08:00

89 lines
1.5 KiB
C++

/*
* Copyright (c) 2014 Amlogic, Inc. All rights reserved.
*
* This source code is subject to the terms and conditions defined in the
* file 'LICENSE' which is part of this source code package.
*
* Description: c++ file
*/
#define LOG_MODULE_TAG "TV"
#define LOG_CLASS_TAG "CVrr"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "CTvLog.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include "CVrr.h"
CVrr *CVrr::mInstance;
CVrr *CVrr::getInstance()
{
if (NULL == mInstance) {
mInstance = new CVrr();
}
return mInstance;
}
CVrr::CVrr()
{
mVrrDeviceId = VrrOpenModule();
}
CVrr::~CVrr()
{
VrrCloseModule();
}
int CVrr::VrrOpenModule()
{
int fd = open ( CS_VRR_DEV_PATH, O_RDWR );
if ( fd < 0 ) {
LOGE("Open %s error(%s)!\n", CS_VRR_DEV_PATH, strerror ( errno ));
return -1;
}
return fd;
}
int CVrr::VrrCloseModule()
{
if ( mVrrDeviceId != -1 ) {
close ( mVrrDeviceId );
mVrrDeviceId = -1;
}
return 0;
}
int CVrr::VrrDeviceIOCtl(int request, ...)
{
int ret = -1;
va_list ap;
void *arg;
va_start ( ap, request );
arg = va_arg ( ap, void *);
va_end ( ap );
ret = ioctl(mVrrDeviceId, request, arg);
return ret;
}
bool CVrr::GetVrrSupport()
{
unsigned int isSupport = 0;
VrrDeviceIOCtl(VRR_IOC_CMD_GET_SUPPORT, &isSupport);
LOGD("%s, support[%s] !\n", __FUNCTION__, isSupport ? "true":"false");
return isSupport ? true:false;
}