Home | History | Annotate | Download | only in libhwcomposer
      1 /*
      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 (at) samsung.com)
     20            Sangwoo, Park(sw5771.park (at) samsung.com)
     21            Jamie, Oh (jung-min.oh (at) 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>
     40 
     41 #include "s5p_fimc.h"
     42 #include "sec_lcd.h"
     43 #include "sec_format.h"
     44 #include "sec_utils.h"
     45 #include "hal_public.h"
     46 
     47 #define GRALLOC_USAGE_PHYS_CONTIG GRALLOC_USAGE_PRIVATE_1
     48 
     49 #define NUM_OF_WIN          (1)
     50 #define NUM_OF_WIN_BUF      (3)
     51 #define NUM_OF_MEM_OBJ      (1)
     52 #define MAX_NUM_PLANES      (3)
     53 
     54 #define MAX_RESIZING_RATIO_LIMIT  (63)
     55 
     56 struct sec_rect {
     57     uint32_t x;
     58     uint32_t y;
     59     uint32_t w;
     60     uint32_t h;
     61 };
     62 
     63 struct sec_img {
     64     uint32_t w;
     65     uint32_t h;
     66     uint32_t format;
     67     uint32_t base;
     68     uint32_t offset;
     69     int      mem_id;
     70     int      mem_type;
     71 };
     72 
     73 inline int SEC_MIN(int x, int y) {
     74     return ((x < y) ? x : y);
     75 }
     76 
     77 inline int SEC_MAX(int x, int y) {
     78     return ((x > y) ? x : y);
     79 }
     80 
     81 struct hwc_win_info_t {
     82     int        fd;
     83     int        size;
     84     sec_rect   rect_info;
     85     uint32_t   addr[NUM_OF_WIN_BUF];
     86     int        buf_index;
     87     int        power_state;
     88     int        blending;
     89     int        layer_index;
     90     uint32_t   layer_prev_buf;
     91     int        set_win_flag;
     92     int        status;
     93     int        vsync;
     94 
     95     struct fb_fix_screeninfo fix_info;
     96     struct fb_var_screeninfo var_info;
     97     struct fb_var_screeninfo lcd_info;
     98 };
     99 
    100 enum {
    101     HWC_WIN_FREE = 0,
    102     HWC_WIN_RESERVED,
    103 };
    104 
    105 enum {
    106     HWC_UNKNOWN_MEM_TYPE = 0,
    107     HWC_PHYS_MEM_TYPE,
    108     HWC_VIRT_MEM_TYPE,
    109 };
    110 
    111 struct hwc_context_t {
    112     hwc_composer_device_t     device;
    113 
    114     /* our private state goes below here */
    115     struct hwc_win_info_t     win[NUM_OF_WIN];
    116     struct hwc_win_info_t     global_lcd_win;
    117     struct fb_var_screeninfo  lcd_info;
    118     s5p_fimc_t                fimc;
    119     hwc_procs_t               *procs;
    120     pthread_t                 vsync_thread;
    121     unsigned int              num_of_fb_layer;
    122     unsigned int              num_of_hwc_layer;
    123     unsigned int              num_of_fb_layer_prev;
    124 };
    125 
    126 int window_open(struct hwc_win_info_t *win, int id);
    127 int window_close(struct hwc_win_info_t *win);
    128 int window_set_pos(struct hwc_win_info_t *win);
    129 int window_get_info(struct hwc_win_info_t *win);
    130 int window_pan_display(struct hwc_win_info_t *win);
    131 int window_show(struct hwc_win_info_t *win);
    132 int window_hide(struct hwc_win_info_t *win);
    133 int window_get_global_lcd_info(struct hwc_context_t *ctx);
    134 
    135 int createFimc(s5p_fimc_t *fimc);
    136 int destroyFimc(s5p_fimc_t *fimc);
    137 int runFimc(struct hwc_context_t *ctx,
    138             struct sec_img *src_img, struct sec_rect *src_rect,
    139             struct sec_img *dst_img, struct sec_rect *dst_rect,
    140             unsigned int *phyAddr,
    141             uint32_t transform);
    142 #endif /* ANDROID_SEC_HWC_UTILS_H_*/
    143 
    144