Daniel Hillenbrand 11 years ago
parent 76ea68e99b
commit 09e7e82747
  1. 158
      exynos4/hal/include/FimgApi.h
  2. 142
      exynos4/hal/include/sec_g2d_4x.h
  3. 6
      exynos4/hal/libfimg4x/Android.mk
  4. 102
      exynos4/hal/libfimg4x/FimgApi.cpp
  5. 114
      exynos4/hal/libfimg4x/FimgApi.h
  6. 3
      exynos4/hal/libfimg4x/FimgExynos4.h

@ -0,0 +1,158 @@
/*
**
** Copyright 2009 Samsung Electronics Co, Ltd.
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
**
*/
#ifndef FIMG_API_H
#define FIMG_API_H
#include <utils/Log.h>
#include "sec_g2d_4x.h"
#undef REAL_DEBUG
#undef ANDROID_LOG
#if defined(REAL_DEBUG)
#ifdef ANDROID_LOG
#define PRINT SLOGE
#define PRINTD SLOGD
#else
#define PRINT printf
#define PRINTD printf
#endif
#else
void VOID_FUNC(const char *format, ...);
#define PRINT VOID_FUNC
#define PRINTD VOID_FUNC
#endif
struct Fimg {
int srcX;
int srcY;
unsigned int srcW;
unsigned int srcH;
unsigned int srcFWStride; // this is not w, just stride (w * bpp)
unsigned int srcFH;
unsigned int srcBPP;
int srcColorFormat;
unsigned char *srcAddr;
int dstX;
int dstY;
unsigned int dstW;
unsigned int dstH;
unsigned int dstFWStride; // this is not w, just stride (w * bpp)
unsigned int dstFH;
unsigned int dstBPP;
int dstColorFormat;
unsigned char *dstAddr;
int clipT;
int clipB;
int clipL;
int clipR;
int mskX;
int mskY;
unsigned int mskW;
unsigned int mskH;
unsigned int mskFWStride; // this is not w, just stride (w * bpp)
unsigned int mskFH;
unsigned int mskBPP;
int mskColorFormat;
unsigned char *mskAddr;
unsigned long fillcolor;
int rotate;
unsigned int alpha;
int xfermode;
int isDither;
int isFilter;
int colorFilter;
int matrixType;
float matrixSx;
float matrixSy;
};
#ifdef __cplusplus
struct blit_op_table {
int op;
const char *str;
};
extern struct blit_op_table optbl[];
class FimgApi
{
public:
#endif
#ifdef __cplusplus
private :
bool m_flagCreate;
protected :
FimgApi();
FimgApi(const FimgApi& rhs) {}
virtual ~FimgApi();
public:
bool Create(void);
bool Destroy(void);
inline bool FlagCreate(void) { return m_flagCreate; }
bool Stretch(struct fimg2d_blit *cmd);
bool Sync(void);
protected:
virtual bool t_Create(void);
virtual bool t_Destroy(void);
virtual bool t_Stretch(struct fimg2d_blit *cmd);
virtual bool t_Sync(void);
virtual bool t_Lock(void);
virtual bool t_UnLock(void);
};
#endif
#ifdef __cplusplus
extern "C"
#endif
struct FimgApi *createFimgApi();
#ifdef __cplusplus
extern "C"
#endif
void destroyFimgApi(FimgApi *ptrFimgApi);
#ifdef __cplusplus
extern "C"
#endif
int stretchFimgApi(struct fimg2d_blit *cmd);
#ifdef __cplusplus
extern "C"
#endif
int SyncFimgApi(void);
void printDataBlit(char *title, struct fimg2d_blit *cmd);
void printDataBlitRotate(int rotate);
void printDataBlitImage(char *title, struct fimg2d_image *image);
void printDataBlitRect(char *title, struct fimg2d_rect *rect);
void printDataBlitScale(struct fimg2d_scale *scaling);
#endif //FIMG_API_H

@ -13,28 +13,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SEC_G2D_4X_H
#define __SEC_G2D_4X_H __FILE__
#ifndef _SEC_G2D_DRIVER_H_
#define _SEC_G2D_DRIVER_H_
#define SEC_G2D_DEV_NAME "/dev/fimg2d"
#define G2D_ALPHA_VALUE_MAX (255)
/* ioctl commands */
#define FIMG2D_IOCTL_MAGIC 'F'
#define FIMG2D_BITBLT_BLIT _IOWR(FIMG2D_IOCTL_MAGIC, 0, struct fimg2d_blit)
#define FIMG2D_BITBLT_SYNC _IO(FIMG2D_IOCTL_MAGIC, 1)
#define FIMG2D_BITBLT_VERSION _IOR(FIMG2D_IOCTL_MAGIC, 2, struct fimg2d_version)
#define FIMG2D_BITBLT_BLIT _IOWR(FIMG2D_IOCTL_MAGIC, 0, \
struct fimg2d_blit)
#define FIMG2D_BITBLT_SYNC _IOW(FIMG2D_IOCTL_MAGIC, 1, int)
#define FIMG2D_BITBLT_VERSION _IOR(FIMG2D_IOCTL_MAGIC, 2, \
struct fimg2d_version)
#define G2D_ALPHA_VALUE_MAX (255)
/**
* @BLIT_SYNC: sync mode, to wait for blit done irq
* @BLIT_ASYNC: async mode, not to wait for blit done irq
*
*/
enum blit_sync {
BLIT_SYNC,
BLIT_ASYNC,
};
/**
* @ADDR_PHYS: physical address
* @ADDR_USER: user virtual address (physically Non-contiguous)
* @ADDR_USER_RSVD: user virtual address (physically Contiguous)
* @ADDR_DEVICE: specific device virtual address
*/
enum addr_space {
ADDR_UNKNOWN,
ADDR_NONE,
ADDR_PHYS,
ADDR_KERN,
ADDR_USER,
ADDR_USER_RSVD,
ADDR_DEVICE,
};
/**
* Pixel order complies with little-endian style
*
* DO NOT CHANGE THIS ORDER
*/
enum pixel_order {
@ -117,12 +139,12 @@ enum scaling {
};
/**
* @SCALING_PERCENTAGE: percentage of width, height
* @SCALING_PIXELS: coordinate of src, dest
* @SCALING_PIXELS: ratio in pixels
* @SCALING_RATIO: ratio in fixed point 16
*/
enum scaling_factor {
SCALING_PERCENTAGE,
SCALING_PIXELS,
SCALING_RATIO,
};
/**
@ -188,11 +210,13 @@ enum blit_op {
BLIT_OP_CONJ_DST_ATOP, BLIT_OP_CONJ_ATOP_REV = BLIT_OP_CONJ_DST_ATOP,
BLIT_OP_CONJ_XOR,
/* Add new operation type here */
/* user select coefficient manually */
BLIT_OP_USER_COEFF,
BLIT_OP_USER_SRC_GA,
/* Add new operation type here */
/* end of blit operation */
BLIT_OP_END,
@ -200,25 +224,12 @@ enum blit_op {
BLIT_OP_NOT_SUPPORTED
};
#define MAX_FIMG2D_BLIT_OP (int)BLIT_OP_END
struct fimg2d_version {
unsigned int hw;
unsigned int sw;
};
/**
* @start: start address or unique id of image
* @size: whole length of allocated image
* @cacheable: memory is cacheable
* @pinnable: memory is pinnable. currently not supported.
*/
struct fimg2d_addr {
enum addr_space type;
unsigned long start;
size_t size;
int cacheable;
int pinnable;
};
struct fimg2d_rect {
@ -229,25 +240,16 @@ struct fimg2d_rect {
};
/**
* if factor is percentage, scale_w and scale_h are valid
* if factor is pixels, src_w, src_h, dst_w, dst_h are valid
* pixels can be different from src, dst or clip rect
*/
struct fimg2d_scale {
enum scaling mode;
enum scaling_factor factor;
/* percentage */
int scale_w;
int scale_h;
/* pixels */
/* ratio in pixels */
int src_w, src_h;
int dst_w, dst_h;
};
/**
* coordinate from start address(0,0) of image
*/
struct fimg2d_clip {
bool enable;
int x1;
@ -272,55 +274,65 @@ struct fimg2d_bluscr {
/**
* @plane2: address info for CbCr in YCbCr 2plane mode
* @rect: crop/clip rect
* @need_cacheopr: true if cache coherency is required
*/
struct fimg2d_image {
struct fimg2d_addr addr;
struct fimg2d_addr plane2;
int width;
int height;
int stride;
enum pixel_order order;
enum color_format fmt;
struct fimg2d_addr addr;
struct fimg2d_addr plane2;
struct fimg2d_rect rect;
bool need_cacheopr;
};
/**
* @solid_color:
* src color instead of src image / dst color instead of dst read image.
* color format and order must be ARGB8888(A is MSB).
* premultiplied format must be same to 'premult' of this struct.
* @g_alpha: global(constant) alpha. 0xff is opaque, 0 is transparnet
* @dither: dithering
* @rotate: rotation degree in clockwise
* @premult: alpha premultiplied mode for read & write
* @scaling: common scaling info for src and mask image.
* @repeat: repeat type (tile mode)
* @bluscr: blue screen and transparent mode
*/
struct fimg2d_param {
enum blit_op op;
unsigned long fillcolor;
unsigned long solid_color;
unsigned char g_alpha;
enum premultiplied premult;
bool dither;
enum rotation rotate;
struct fimg2d_scale *scaling;
struct fimg2d_repeat *repeat;
struct fimg2d_bluscr *bluscr;
struct fimg2d_clip *clipping;
enum premultiplied premult;
struct fimg2d_scale scaling;
struct fimg2d_repeat repeat;
struct fimg2d_bluscr bluscr;
struct fimg2d_clip clipping;
};
/**
* @g_alpha: 0xff is opaque, 0x0 is transparnet
* @seq_no: used for debugging
* @op: blit operation mode
* @src: set when using src image
* @msk: set when using mask image
* @tmp: set when using 2-step blit at a single command
* @dst: dst must not be null
* * tmp image must be the same to dst except memory address
* @seq_no: user debugging info.
* for example, user can set sequence number or pid.
*/
struct fimg2d_blit {
enum blit_op op;
enum premultiplied premult;
unsigned char g_alpha;
bool dither;
enum rotation rotate;
struct fimg2d_scale *scaling;
struct fimg2d_repeat *repeat;
struct fimg2d_bluscr *bluscr;
struct fimg2d_clip *clipping;
unsigned long solid_color;
struct fimg2d_param param;
struct fimg2d_image *src;
struct fimg2d_image *dst;
struct fimg2d_image *msk;
struct fimg2d_rect *src_rect;
struct fimg2d_rect *dst_rect;
struct fimg2d_rect *msk_rect;
struct fimg2d_image *tmp;
struct fimg2d_image *dst;
enum blit_sync sync;
unsigned int seq_no;
};
#endif /* __SEC_G2D_4X_H__ */
#endif /*_SEC_G2D_DRIVER_H_*/

@ -2,15 +2,15 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
ifeq ($(BOARD_USES_FIMGAPI),true)
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include
LOCAL_C_INCLUDES += external/skia/include/core
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
FimgApi.cpp \
FimgExynos4.cpp
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../include
LOCAL_SHARED_LIBRARIES:= liblog libutils libbinder
LOCAL_MODULE:= libfimg

@ -270,107 +270,61 @@ extern "C" int SyncFimgApi(void)
void printDataBlit(char *title, struct fimg2d_blit *cmd)
{
ALOGI("%s\n", title);
SLOGI("%s\n", title);
ALOGI(" sequence_no. = %u\n", cmd->seq_no);
ALOGI(" blit_op = %d(%s)\n", cmd->op, optbl[cmd->op].str);
ALOGI(" fill_color = %X\n", cmd->solid_color);
ALOGI(" global_alpha = %u\n", (unsigned int)cmd->g_alpha);
ALOGI(" PREMULT = %s\n", cmd->premult == PREMULTIPLIED ? "PREMULTIPLIED" : "NON-PREMULTIPLIED");
ALOGI(" do_dither = %s\n", cmd->dither == true ? "dither" : "no-dither");
SLOGI(" sequence_no. = %u\n", cmd->seq_no);
SLOGI(" blit_op = %d(%s)\n", cmd->op, optbl[cmd->op].str);
SLOGI(" fill_color = %X\n", cmd->param.solid_color);
SLOGI(" global_alpha = %u\n", (unsigned int)cmd->param.g_alpha);
SLOGI(" PREMULT = %s\n", cmd->param.premult == PREMULTIPLIED ? "PREMULTIPLIED" : "NON-PREMULTIPLIED");
SLOGI(" do_dither = %s\n", cmd->param.dither == true ? "dither" : "no-dither");
printDataBlitRotate(cmd->rotate);
printDataBlitRotate(cmd->param.rotate);
printDataBlitScale(cmd->scaling);
printDataBlitScale(&cmd->param.scaling);
printDataBlitImage("SRC", cmd->src);
printDataBlitImage("DST", cmd->dst);
printDataBlitImage("MSK", cmd->msk);
printDataBlitRect("SRC", cmd->src_rect);
printDataBlitRect("DST", cmd->dst_rect);
printDataBlitRect("MSK", cmd->msk_rect);
printDataBlitClip(cmd->clipping);
printDataBlitRect("SRC", &cmd->src->rect);
printDataBlitRect("DST", &cmd->dst->rect);
printDataBlitRect("MSK", &cmd->msk->rect);
}
void printDataBlitImage(char *title, struct fimg2d_image *image)
{
if (NULL != image) {
ALOGI(" Image_%s\n", title);
ALOGI(" addr = %X\n", image->addr.start);
ALOGI(" size = %u\n", image->addr.size);
ALOGI(" (width, height) = (%d, %d)\n", image->width, image->height);
ALOGI(" format = %d\n", image->fmt);
SLOGI(" Image_%s\n", title);
SLOGI(" addr = %X\n", image->addr.start);
SLOGI(" format = %d\n", image->fmt);
} else
ALOGI(" Image_%s : NULL\n", title);
SLOGI(" Image_%s : NULL\n", title);
}
void printDataBlitRect(char *title, struct fimg2d_rect *rect)
{
if (NULL != rect) {
ALOGI(" RECT_%s\n", title);
ALOGI(" (x1, y1) = (%d, %d)\n", rect->x1, rect->y1);
ALOGI(" (x2, y2) = (%d, %d)\n", rect->x2, rect->y2);
ALOGI(" (width, height) = (%d, %d)\n", rect->x2 - rect->x1, rect->y2 - rect->y1);
SLOGI(" RECT_%s\n", title);
SLOGI(" (x1, y1) = (%d, %d)\n", rect->x1, rect->y1);
SLOGI(" (x2, y2) = (%d, %d)\n", rect->x2, rect->y2);
SLOGI(" (width, height) = (%d, %d)\n", rect->x2 - rect->x1, rect->y2 - rect->y1);
} else
ALOGI(" RECT_%s : NULL\n", title);
}
void printDataBlitRotate(enum rotation rotate)
{
ALOGI(" ROTATE : %d\n", rotate);
SLOGI(" RECT_%s : NULL\n", title);
}
void printDataBlitClip(struct fimg2d_clip *clip)
void printDataBlitRotate(int rotate)
{
if (NULL != clip) {
ALOGI(" CLIP\n");
ALOGI(" clip %s\n", clip->enable == true ? "enabled" : "disabled");
ALOGI(" (x1, y1) = (%d, %d)\n", clip->x1, clip->y1);
ALOGI(" (x2, y2) = (%d, %d)\n", clip->x2, clip->y2);
ALOGI(" (width, hight) = (%d, %d)\n", clip->x2 - clip->x1, clip->y2 - clip->y1);
} else
ALOGI(" CLIP : NULL\n");
SLOGI(" ROTATE : %d\n", rotate);
}
void printDataBlitScale(struct fimg2d_scale *scaling)
{
if (NULL != scaling) {
ALOGI(" SCALING\n");
ALOGI(" scale_mode : %s\n", scaling->mode == 0 ?
SLOGI(" SCALING\n");
SLOGI(" scale_mode : %s\n", scaling->mode == 0 ?
"NO_SCALING" :
(scaling->mode == 1 ? "SCALING_NEAREST" : "SCALING_BILINEAR"));
ALOGI(" scaling_factor_unit : %s\n", scaling->factor == 0 ? "PERCENT" : "PIXEL");
if (scaling->factor == 0)
ALOGI(" scaling_factor : (scale_w, scale_y) = (%d, %d)\n", scaling->scale_w, scaling->scale_h);
else {
ALOGI(" src : (src_w, src_h) = (%d, %d)\n", scaling->src_w, scaling->src_h);
ALOGI(" dst : (dst_w, dst_h) = (%d, %d)\n", scaling->dst_w, scaling->dst_h);
ALOGI(" scaling_factor : (scale_w, scale_y) = (%3.2f, %3.2f)\n", (double)scaling->dst_w / scaling->src_w, (double)scaling->dst_h / scaling->src_h);
}
} else
ALOGI(" SCALING : NULL(NO SCALE MODE)\n");
}
void printDataMatrix(int matrixType)
{
ALOGI(" MATRIX\n");
if (matrixType & SkMatrix::kIdentity_Mask)
ALOGI(" Matrix_type : Identity_Mask\n");
if (matrixType & SkMatrix::kTranslate_Mask)
ALOGI(" Matrix_type : Translate_Mask(the matrix has translation)\n");
if (matrixType & SkMatrix::kScale_Mask)
ALOGI(" Matrix_type : Scale_Mask(the matrix has X or Y scale)\n");
if (matrixType & SkMatrix::kAffine_Mask)
ALOGI(" Matrix_type : Affine_Mask(the matrix skews or rotates)\n");
if (matrixType & SkMatrix::kPerspective_Mask)
ALOGI(" Matrix_type : Perspective_Mask(the matrix is in perspective)\n");
SLOGI(" src : (src_w, src_h) = (%d, %d)\n", scaling->src_w, scaling->src_h);
SLOGI(" dst : (dst_w, dst_h) = (%d, %d)\n", scaling->dst_w, scaling->dst_h);
SLOGI(" scaling_factor : (scale_w, scale_y) = (%3.2f, %3.2f)\n", (double)scaling->dst_w / scaling->src_w, (double)scaling->dst_h / scaling->src_h);
}

@ -1,114 +0,0 @@
/*
**
** Copyright 2009 Samsung Electronics Co, Ltd.
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
**
*/
#ifndef FIMG_API_H
#define FIMG_API_H
#include <utils/Log.h>
#include "SkMatrix.h"
#include "sec_g2d_4x.h"
#define REAL_DEBUG
#define ANDROID_ALOG
#if defined(REAL_DEBUG)
#ifdef ANDROID_ALOG
#define PRINT ALOGE
#define PRINTD ALOGD
#else
#define PRINT printf
#define PRINTD printf
#endif
#else
void VOID_FUNC(const char *format, ...);
#define PRINT VOID_FUNC
#define PRINTD VOID_FUNC
#endif
#ifdef __cplusplus
struct blit_op_table {
int op;
const char *str;
};
extern struct blit_op_table optbl[];
class FimgApi
{
public:
#endif
#ifdef __cplusplus
private :
bool m_flagCreate;
protected :
FimgApi();
FimgApi(const FimgApi& rhs) {}
virtual ~FimgApi();
public:
bool Create(void);
bool Destroy(void);
inline bool FlagCreate(void) { return m_flagCreate; }
bool Stretch(struct fimg2d_blit *cmd);
bool Sync(void);
protected:
virtual bool t_Create(void);
virtual bool t_Destroy(void);
virtual bool t_Stretch(struct fimg2d_blit *cmd);
virtual bool t_Sync(void);
virtual bool t_Lock(void);
virtual bool t_UnLock(void);
};
#endif
#ifdef __cplusplus
extern "C"
#endif
struct FimgApi *createFimgApi();
#ifdef __cplusplus
extern "C"
#endif
void destroyFimgApi(FimgApi *ptrFimgApi);
#ifdef __cplusplus
extern "C"
#endif
int stretchFimgApi(struct fimg2d_blit *cmd);
#ifdef __cplusplus
extern "C"
#endif
int SyncFimgApi(void);
void printDataBlit(char *title, struct fimg2d_blit *cmd);
void printDataBlitRotate(enum rotation rotate);
void printDataBlitImage(char *title, struct fimg2d_image *image);
void printDataBlitRect(char *title, struct fimg2d_rect *rect);
void printDataBlitClip(struct fimg2d_clip *clip);
void printDataBlitScale(struct fimg2d_scale *scaling);
void printDataMatrix(int matrixType);
#endif //FIMG_API_H

@ -35,7 +35,6 @@
#include <sys/poll.h>
#include <sys/stat.h>
#include <linux/android_pmem.h>
#include <utils/threads.h>
#include <utils/StopWatch.h>
@ -46,7 +45,7 @@
namespace android
{
#define NUMBER_FIMG_LIST (1) // kcoolsw : because of pmem
#define NUMBER_FIMG_LIST (1)
#define GET_RECT_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel))
#define GET_REAL_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel))
#define GET_START_ADDR(rect) (rect->virt_addr + ((rect->y * rect->full_w) * rect->bytes_per_pixel))

Loading…
Cancel
Save