blob: 3e8c911df11d5d1c2f063af39191f4bcd0c79b11 [file] [log] [blame]
Petr Havlenac9288142012-11-15 14:07:10 +05301/*
2 * Copyright (C) 2012 Havlena Petr, <havlenapetr@gmail.com>
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 "hardware/hdmi.h"
18
19#include <stdint.h>
20#include <string.h>
21#include <errno.h>
22#include <fcntl.h>
23#include <sys/types.h>
24#include <linux/videodev2.h>
25
26#include "sec_lcd.h"
27
28#include "test.h"
29
30static void dump_fbs(int count) {
31 char name[64];
32 char const * const fb_template = {
33 "/dev/graphics/fb%u"};
34
35 for(int i = 0; i < count; i++) {
36 snprintf(name, 64, fb_template, i);
37 int fd = open(name, O_RDWR, 0);
38 if(fd < 0) {
39 LOGE("%s:: Can't open %s", __func__, name);
40 continue;
41 }
42
43 struct s3cfb_next_info fb_info;
44 int ret = ioctl(fd, S3CFB_GET_CURR_FB_INFO, &fb_info);
45 if (ret < 0) {
46 LOGE("%s:: ioctl(S3CFB_GET_FB_PHY__ADDR) fail: %d for %s",
47 __func__, ret, name);
48 goto close;
49 }
50
51 LOGI("%s:: %s addr=0x%08x", __func__, name, fb_info.phy_start_addr);
52
53close:
54 close(fd);
55 }
56}
57
58int main(int argc, char** argv) {
59 hw_module_t* module;
60 hdmi_device_t* hdmi;
61 int ret;
62
63 ret = hw_get_module(HDMI_HARDWARE_MODULE_ID,
64 (const hw_module_t**)&module);
65 if(ret) {
66 LOGE("%s:: Hdmi device not presented", __func__);
67 goto fail;
68 }
69
70 ret = module->methods->open(module, "hdmi-test",
71 (hw_device_t **)&hdmi);
72 if(ret < 0) {
73 LOGE("%s:: Can't open hdmi device", __func__);
74 goto fail;
75 }
76
77 ret = hdmi->connect(hdmi);
78 if(ret < 0) {
79 LOGE("%s:: Can't connect hdmi device", __func__);
80 goto close;
81 }
82
83#if 1
84 dump_fbs(5);
85#endif
86
87 for(int i = 0; i < 5; i++) {
88 LOGI("Blit cycle: %d", i);
89 ret = hdmi->blit(hdmi,
90 600, /* default lcd width */
91 1024, /* default lcd height */
92 HAL_PIXEL_FORMAT_BGRA_8888, /* our default pixel format */
93 0, 0, 0, /* use default frame buffer */
94 0, 0,
95 HDMI_MODE_UI,
96 0);
97 if(ret < 0) {
98 LOGE("%s:: Can't blit to hdmi device", __func__);
99 break;
100 }
101 }
102
103disconnect:
104 if(hdmi->disconnect(hdmi) < 0) {
105 LOGE("%s:: Can't disconnect hdmi device", __func__);
106 }
107
108close:
109 if(hdmi->common.close(&hdmi->common) < 0) {
110 LOGE("%s:: Can't close hdmi device", __func__);
111 }
112
113fail:
114 LOGI("HDMI result: %d", ret);
115 return ret;
116}