1/*
2// Copyright (c) 2014 Intel 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#include <common/utils/HwcTrace.h>
18#include <linux/psb_drm.h>
19#include <Hwcomposer.h>
20#include <ips/common/DrmControl.h>
21
22namespace android {
23namespace intel {
24
25DrmControl::DrmControl()
26    : mVideoExtCommand(0)
27{
28}
29
30DrmControl::~DrmControl()
31{
32}
33
34int DrmControl::getVideoExtCommand()
35{
36    if (mVideoExtCommand) {
37        return mVideoExtCommand;
38    }
39
40    int fd = Hwcomposer::getInstance().getDrm()->getDrmFd();
41
42    union drm_psb_extension_arg video_getparam_arg;
43    strncpy(video_getparam_arg.extension,
44            "lnc_video_getparam", sizeof(video_getparam_arg.extension));
45    int ret = drmCommandWriteRead(fd, DRM_PSB_EXTENSION,
46            &video_getparam_arg, sizeof(video_getparam_arg));
47    if (ret != 0) {
48        VLOGTRACE("failed to get video extension command");
49        return 0;
50    }
51
52    mVideoExtCommand = video_getparam_arg.rep.driver_ioctl_offset;
53
54    return mVideoExtCommand;
55}
56
57} // namespace intel
58} // namespace android
59