blob: ff9ef4a45a8513402965cc399892ed429047f8a3 [file] [log] [blame]
Chirayu Desai0a336cc2012-07-12 14:37:05 +05301/*
2 * Copyright (C) 2010 The Android Open Source Project
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/*
18 *
19 * @author Rama, Meka(v.meka@samsung.com)
20 Sangwoo, Park(sw5771.park@samsung.com)
21 Jamie, Oh (jung-min.oh@samsung.com)
22 * @date 2011-07-28
23 *
24 */
25
26#ifndef ANDROID_SEC_HWC_UTILS_H_
27#define ANDROID_SEC_HWC_UTILS_H_
28#include <fcntl.h>
29#include <errno.h>
30#include <cutils/log.h>
31#include <stdlib.h>
32#include <sys/ioctl.h>
33#include <sys/mman.h>
34#include "linux/fb.h"
35#include <linux/videodev.h>
36
37#include <hardware/gralloc.h>
38#include <hardware/hardware.h>
39#include <hardware/hwcomposer.h>
Petr Havlena1386f442012-10-26 17:52:00 +053040#if defined(BOARD_USES_HDMI)
41#include "hardware/hdmi.h"
42#endif
Chirayu Desai0a336cc2012-07-12 14:37:05 +053043
44#include "s5p_fimc.h"
45#include "sec_lcd.h"
46#include "sec_format.h"
47#include "sec_utils.h"
48#include "hal_public.h"
49
50#define GRALLOC_USAGE_PHYS_CONTIG GRALLOC_USAGE_PRIVATE_1
51
52#define NUM_OF_WIN (1)
53#define NUM_OF_WIN_BUF (3)
54#define NUM_OF_MEM_OBJ (1)
55#define MAX_NUM_PLANES (3)
56
57#define MAX_RESIZING_RATIO_LIMIT (63)
58
59struct sec_rect {
60 uint32_t x;
61 uint32_t y;
62 uint32_t w;
63 uint32_t h;
64};
65
66struct sec_img {
67 uint32_t w;
68 uint32_t h;
69 uint32_t format;
70 uint32_t base;
71 uint32_t offset;
72 int mem_id;
73 int mem_type;
74};
75
76inline int SEC_MIN(int x, int y) {
77 return ((x < y) ? x : y);
78}
79
80inline int SEC_MAX(int x, int y) {
81 return ((x > y) ? x : y);
82}
83
84struct hwc_win_info_t {
85 int fd;
86 int size;
87 sec_rect rect_info;
88 uint32_t addr[NUM_OF_WIN_BUF];
89 int buf_index;
90 int power_state;
91 int blending;
92 int layer_index;
93 uint32_t layer_prev_buf;
94 int set_win_flag;
95 int status;
96 int vsync;
97
98 struct fb_fix_screeninfo fix_info;
99 struct fb_var_screeninfo var_info;
100 struct fb_var_screeninfo lcd_info;
101};
102
103enum {
104 HWC_WIN_FREE = 0,
105 HWC_WIN_RESERVED,
106};
107
108enum {
109 HWC_UNKNOWN_MEM_TYPE = 0,
110 HWC_PHYS_MEM_TYPE,
111 HWC_VIRT_MEM_TYPE,
112};
113
114struct hwc_context_t {
Pawit Pornkitprasanb9ae8e02012-11-23 14:24:32 +0700115 hwc_composer_device_1_t device;
Chirayu Desai0a336cc2012-07-12 14:37:05 +0530116
117 /* our private state goes below here */
118 struct hwc_win_info_t win[NUM_OF_WIN];
119 struct hwc_win_info_t global_lcd_win;
120 struct fb_var_screeninfo lcd_info;
121 s5p_fimc_t fimc;
122 hwc_procs_t *procs;
123 pthread_t vsync_thread;
124 unsigned int num_of_fb_layer;
125 unsigned int num_of_hwc_layer;
126 unsigned int num_of_fb_layer_prev;
Petr Havlena1386f442012-10-26 17:52:00 +0530127#if defined(BOARD_USES_HDMI)
128 hdmi_device_t* hdmi;
129#endif
Chirayu Desai0a336cc2012-07-12 14:37:05 +0530130};
131
132int window_open(struct hwc_win_info_t *win, int id);
133int window_close(struct hwc_win_info_t *win);
134int window_set_pos(struct hwc_win_info_t *win);
135int window_get_info(struct hwc_win_info_t *win);
136int window_pan_display(struct hwc_win_info_t *win);
137int window_show(struct hwc_win_info_t *win);
138int window_hide(struct hwc_win_info_t *win);
139int window_get_global_lcd_info(struct hwc_context_t *ctx);
140
141int createFimc(s5p_fimc_t *fimc);
142int destroyFimc(s5p_fimc_t *fimc);
143int runFimc(struct hwc_context_t *ctx,
144 struct sec_img *src_img, struct sec_rect *src_rect,
145 struct sec_img *dst_img, struct sec_rect *dst_rect,
146 unsigned int *phyAddr,
147 uint32_t transform);
148#endif /* ANDROID_SEC_HWC_UTILS_H_*/
149