summaryrefslogtreecommitdiff
path: root/libcopybit
diff options
context:
space:
mode:
authorPraveena Pachipulusu <pveena@codeaurora.org>2014-02-12 11:46:39 +0530
committerPraveena Pachipulusu <pveena@codeaurora.org>2014-03-21 09:16:54 +0530
commitaef031c135a04bea679bc0771bcda9bb1d1f8269 (patch)
treeb0114133469fb029cef781e228682c1b67e2fc61 /libcopybit
parent4232357fa8d45d101543ef68693f5d024bf089d4 (diff)
downloaddisplay-aef031c135a04bea679bc0771bcda9bb1d1f8269.tar.gz
copybit: Use proper type casts and pointers
- Remove unused variables - Use proper type casts for pointers. Change-Id: Ie07c67d759d76f418fae08accdcfb1855511dedf
Diffstat (limited to 'libcopybit')
-rw-r--r--libcopybit/copybit.cpp22
-rw-r--r--libcopybit/copybit_c2d.cpp57
-rw-r--r--libcopybit/software_converter.cpp19
3 files changed, 58 insertions, 40 deletions
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index c0246e3f..645cd81d 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2010 - 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010 - 2014, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are retained
* for attribution purposes only.
@@ -154,7 +154,7 @@ static void set_image(struct mdp_img *img, const struct copybit_image_t *rhs)
img->width = rhs->w;
img->height = rhs->h;
img->format = get_format(rhs->format);
- img->offset = hnd->offset;
+ img->offset = (uint32_t)hnd->offset;
img->memory_id = hnd->fd;
}
/** setup rectangles */
@@ -162,9 +162,7 @@ static void set_rects(struct copybit_context_t *dev,
struct mdp_blit_req *e,
const struct copybit_rect_t *dst,
const struct copybit_rect_t *src,
- const struct copybit_rect_t *scissor,
- uint32_t horiz_padding,
- uint32_t vert_padding) {
+ const struct copybit_rect_t *scissor) {
struct copybit_rect_t clip;
intersect(&clip, scissor, dst);
@@ -312,7 +310,7 @@ static int set_parameter_copybit(
case COPYBIT_PLANE_ALPHA:
if (value < 0) value = MDP_ALPHA_NOP;
if (value >= 256) value = 255;
- ctx->mAlpha = value;
+ ctx->mAlpha = (uint8_t)value;
break;
case COPYBIT_DITHER:
if (value == COPYBIT_ENABLE) {
@@ -491,7 +489,8 @@ static int stretch_copybit(
return -EINVAL;
}
}
- const uint32_t maxCount = sizeof(list->req)/sizeof(list->req[0]);
+ const uint32_t maxCount =
+ (uint32_t)(sizeof(list->req)/sizeof(list->req[0]));
const struct copybit_rect_t bounds = { 0, 0, (int)dst->w, (int)dst->h };
struct copybit_rect_t clip;
status = 0;
@@ -508,7 +507,7 @@ static int stretch_copybit(
set_infos(ctx, req, flags);
set_image(&req->dst, dst);
set_image(&req->src, src);
- set_rects(ctx, req, dst_rect, src_rect, &clip, src->horiz_padding, src->vert_padding);
+ set_rects(ctx, req, dst_rect, src_rect, &clip);
if (req->src_rect.w<=0 || req->src_rect.h<=0)
continue;
@@ -553,6 +552,9 @@ static int blit_copybit(
static int finish_copybit(struct copybit_device_t *dev)
{
// NOP for MDP copybit
+ if(!dev)
+ return -EINVAL;
+
return 0;
}
static int clear_copybit(struct copybit_device_t *dev,
@@ -702,6 +704,10 @@ static int open_copybit(const struct hw_module_t* module, const char* name,
struct hw_device_t** device)
{
int status = -EINVAL;
+
+ if (!strcmp(name, COPYBIT_HARDWARE_COPYBIT0)) {
+ return COPYBIT_FAILURE;
+ }
copybit_context_t *ctx;
ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t));
memset(ctx, 0, sizeof(*ctx));
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index 231bb2d3..852b8c0b 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are retained
* for attribution purposes only.
@@ -80,8 +80,8 @@ C2D_STATUS (*LINK_c2dWaitTimestamp)( c2d_ts_handle timestamp );
C2D_STATUS (*LINK_c2dDestroySurface)( uint32 surface_id );
-C2D_STATUS (*LINK_c2dMapAddr) ( int mem_fd, void * hostptr, uint32 len,
- uint32 offset, uint32 flags, void ** gpuaddr);
+C2D_STATUS (*LINK_c2dMapAddr) ( int mem_fd, void * hostptr, size_t len,
+ size_t offset, uint32 flags, void ** gpuaddr);
C2D_STATUS (*LINK_c2dUnMapAddr) ( void * gpuaddr);
@@ -147,7 +147,7 @@ struct copybit_context_t {
alloc_data temp_src_buffer;
alloc_data temp_dst_buffer;
unsigned int dst[NUM_SURFACE_TYPES]; // dst surfaces
- unsigned int mapped_gpu_addr[MAX_SURFACES]; // GPU addresses mapped inside copybit
+ uintptr_t mapped_gpu_addr[MAX_SURFACES]; // GPU addresses mapped inside copybit
int blit_rgb_count; // Total RGB surfaces being blit
int blit_yuv_2_plane_count; // Total 2 plane YUV surfaces being
int blit_yuv_3_plane_count; // Total 3 plane YUV surfaces being blit
@@ -182,8 +182,8 @@ struct yuvPlaneInfo {
int yStride; //luma stride
int plane1_stride;
int plane2_stride;
- int plane1_offset;
- int plane2_offset;
+ size_t plane1_offset;
+ size_t plane2_offset;
};
/**
@@ -334,10 +334,11 @@ int c2diGetBpp(int32 colorformat)
return c2dBpp;
}
-static uint32 c2d_get_gpuaddr(copybit_context_t* ctx,
+static size_t c2d_get_gpuaddr(copybit_context_t* ctx,
struct private_handle_t *handle, int &mapped_idx)
{
- uint32 memtype, *gpuaddr = 0;
+ uint32 memtype;
+ size_t *gpuaddr = 0;
C2D_STATUS rc;
int freeindex = 0;
bool mapaddr = false;
@@ -374,11 +375,11 @@ static uint32 c2d_get_gpuaddr(copybit_context_t* ctx,
if (rc == C2D_STATUS_OK) {
// We have mapped the GPU address inside copybit. We need to unmap
// this address after the blit. Store this address
- ctx->mapped_gpu_addr[freeindex] = (uint32) gpuaddr;
+ ctx->mapped_gpu_addr[freeindex] = (size_t)gpuaddr;
mapped_idx = freeindex;
}
}
- return (uint32) gpuaddr;
+ return (size_t)gpuaddr;
}
static void unmap_gpuaddr(copybit_context_t* ctx, int mapped_idx)
@@ -498,7 +499,7 @@ static int set_image(copybit_context_t* ctx, uint32 surfaceId,
struct private_handle_t* handle = (struct private_handle_t*)rhs->handle;
C2D_SURFACE_TYPE surfaceType;
int status = COPYBIT_SUCCESS;
- uint32 gpuaddr = 0;
+ uintptr_t gpuaddr = 0;
int c2d_format;
mapped_idx = -1;
@@ -542,7 +543,7 @@ static int set_image(copybit_context_t* ctx, uint32 surfaceId,
((flags & FLAGS_PREMULTIPLIED_ALPHA) ? C2D_FORMAT_PREMULTIPLIED : 0);
surfaceDef.width = rhs->w;
surfaceDef.height = rhs->h;
- int aligned_width = ALIGN(surfaceDef.width,32);
+ int aligned_width = ALIGN((int)surfaceDef.width,32);
surfaceDef.stride = (aligned_width * c2diGetBpp(surfaceDef.format))>>3;
if(LINK_c2dUpdateSurface( surfaceId,C2D_TARGET | C2D_SOURCE, surfaceType,
@@ -730,7 +731,8 @@ static void set_rects(struct copybit_context_t *ctx,
(ctx->trg_transform & C2D_TARGET_ROTATE_180)) {
/* target rotation is 270 */
c2dObject->target_rect.x = (dst->t)<<16;
- c2dObject->target_rect.y = ctx->fb_width?(ALIGN(ctx->fb_width,32)- dst->r):dst->r;
+ c2dObject->target_rect.y = ctx->fb_width?
+ (ALIGN(ctx->fb_width,32)- dst->r):dst->r;
c2dObject->target_rect.y = c2dObject->target_rect.y<<16;
c2dObject->target_rect.height = ((dst->r) - (dst->l))<<16;
c2dObject->target_rect.width = ((dst->b) - (dst->t))<<16;
@@ -743,7 +745,8 @@ static void set_rects(struct copybit_context_t *ctx,
} else if(ctx->trg_transform & C2D_TARGET_ROTATE_180) {
c2dObject->target_rect.y = ctx->fb_height?(ctx->fb_height - dst->b):dst->b;
c2dObject->target_rect.y = c2dObject->target_rect.y<<16;
- c2dObject->target_rect.x = ctx->fb_width?(ALIGN(ctx->fb_width,32) - dst->r):dst->r;
+ c2dObject->target_rect.x = ctx->fb_width?
+ (ALIGN(ctx->fb_width,32) - dst->r):dst->r;
c2dObject->target_rect.x = c2dObject->target_rect.x<<16;
c2dObject->target_rect.height = ((dst->b) - (dst->t))<<16;
c2dObject->target_rect.width = ((dst->r) - (dst->l))<<16;
@@ -957,7 +960,7 @@ static void populate_buffer_info(struct copybit_image_t const *img, bufferInfo&
*/
static size_t get_size(const bufferInfo& info)
{
- size_t size = 0;
+ int size = 0;
int w = info.width;
int h = info.height;
int aligned_w = ALIGN(w, 32);
@@ -1067,8 +1070,7 @@ static void delete_handle(private_handle_t *handle)
}
}
-static bool need_to_execute_draw(struct copybit_context_t* ctx,
- eC2DFlags flags)
+static bool need_to_execute_draw(eC2DFlags flags)
{
if (flags & FLAGS_TEMP_SRC_DST) {
return true;
@@ -1185,7 +1187,7 @@ static int stretch_copybit_internal(
dst_hnd->fd = ctx->temp_dst_buffer.fd;
dst_hnd->size = ctx->temp_dst_buffer.size;
dst_hnd->flags = ctx->temp_dst_buffer.allocType;
- dst_hnd->base = (int)(ctx->temp_dst_buffer.base);
+ dst_hnd->base = (uintptr_t)(ctx->temp_dst_buffer.base);
dst_hnd->offset = ctx->temp_dst_buffer.offset;
dst_hnd->gpuaddr = 0;
dst_image.handle = dst_hnd;
@@ -1270,7 +1272,7 @@ static int stretch_copybit_internal(
src_hnd->fd = ctx->temp_src_buffer.fd;
src_hnd->size = ctx->temp_src_buffer.size;
src_hnd->flags = ctx->temp_src_buffer.allocType;
- src_hnd->base = (int)(ctx->temp_src_buffer.base);
+ src_hnd->base = (uintptr_t)(ctx->temp_src_buffer.base);
src_hnd->offset = ctx->temp_src_buffer.offset;
src_hnd->gpuaddr = 0;
src_image.handle = src_hnd;
@@ -1354,7 +1356,7 @@ static int stretch_copybit_internal(
// Check if we need to perform an early draw-finish.
flags |= (need_temp_dst || need_temp_src) ? FLAGS_TEMP_SRC_DST : 0;
- if (need_to_execute_draw(ctx, (eC2DFlags)flags))
+ if (need_to_execute_draw((eC2DFlags)flags))
{
finish_copybit(dev);
}
@@ -1388,8 +1390,11 @@ static int stretch_copybit_internal(
}
static int set_sync_copybit(struct copybit_device_t *dev,
- int acquireFenceFd)
+ int /*acquireFenceFd*/)
{
+ if(!dev)
+ return -EINVAL;
+
return 0;
}
@@ -1432,9 +1437,12 @@ static int blit_copybit(
static int fill_color(struct copybit_device_t *dev,
struct copybit_image_t const *dst,
struct copybit_rect_t const *rect,
- uint32_t color)
+ uint32_t /*color*/)
{
// TODO: Implement once c2d driver supports color fill
+ if(!dev || !dst || !rect)
+ return -EINVAL;
+
return -EINVAL;
}
@@ -1502,10 +1510,13 @@ static int open_copybit(const struct hw_module_t* module, const char* name,
struct hw_device_t** device)
{
int status = COPYBIT_SUCCESS;
+ if (strcmp(name, COPYBIT_HARDWARE_COPYBIT0)) {
+ return COPYBIT_FAILURE;
+ }
+
C2D_RGB_SURFACE_DEF surfDefinition = {0};
C2D_YUV_SURFACE_DEF yuvSurfaceDef = {0} ;
struct copybit_context_t *ctx;
- char fbName[64];
ctx = (struct copybit_context_t *)malloc(sizeof(struct copybit_context_t));
if(!ctx) {
diff --git a/libcopybit/software_converter.cpp b/libcopybit/software_converter.cpp
index e26b7957..71e685e8 100644
--- a/libcopybit/software_converter.cpp
+++ b/libcopybit/software_converter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -52,7 +52,7 @@ int convertYV12toYCrCb420SP(const copybit_image_t *src, private_handle_t *yv12_h
unsigned int width = src->w - src->horiz_padding;
unsigned int height = src->h;
unsigned int y_size = stride * src->h;
- unsigned int c_width = ALIGN(stride/2, 16);
+ unsigned int c_width = ALIGN(stride/2, (unsigned int)16);
unsigned int c_size = c_width * src->h/2;
unsigned int chromaPadding = c_width - width/2;
unsigned int chromaSize = c_size * 2;
@@ -128,19 +128,20 @@ struct copyInfo{
int height;
int src_stride;
int dst_stride;
- int src_plane1_offset;
- int src_plane2_offset;
- int dst_plane1_offset;
- int dst_plane2_offset;
+ size_t src_plane1_offset;
+ size_t src_plane2_offset;
+ size_t dst_plane1_offset;
+ size_t dst_plane2_offset;
};
/* Internal function to do the actual copy of source to destination */
-static int copy_source_to_destination(const int src_base, const int dst_base,
+static int copy_source_to_destination(const uintptr_t src_base,
+ const uintptr_t dst_base,
copyInfo& info)
{
if (!src_base || !dst_base) {
- ALOGE("%s: invalid memory src_base = 0x%x dst_base=0x%x",
- __FUNCTION__, src_base, dst_base);
+ ALOGE("%s: invalid memory src_base = 0x%p dst_base=0x%p",
+ __FUNCTION__, (void*)src_base, (void*)dst_base);
return COPYBIT_FAILURE;
}