Skip to content

Commit

Permalink
am 2130dc3: copybit: Use proper type casts and pointers
Browse files Browse the repository at this point in the history
* commit '2130dc33b27b36880920f72b11529c7e1087ae21':
  copybit: Use proper type casts and pointers
  • Loading branch information
Praveena Pachipulusu authored and Android Git Automerger committed Jan 9, 2015
2 parents 6536db5 + 2130dc3 commit 6520874
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
22 changes: 14 additions & 8 deletions msm8226/libcopybit/copybit.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -154,17 +154,15 @@ 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 */
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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down
57 changes: 34 additions & 23 deletions msm8226/libcopybit/copybit_c2d.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -78,8 +78,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);

Expand Down Expand Up @@ -145,7 +145,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
Expand Down Expand Up @@ -180,8 +180,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;
};

/**
Expand Down Expand Up @@ -337,10 +337,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;
Expand Down Expand Up @@ -377,11 +378,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)
Expand Down Expand Up @@ -502,7 +503,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;

Expand Down Expand Up @@ -546,7 +547,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,
Expand Down Expand Up @@ -734,7 +735,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;
Expand All @@ -747,7 +749,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;
Expand Down Expand Up @@ -961,7 +964,7 @@ static void populate_buffer_info(struct copybit_image_t const *img, bufferInfo&
*/
static int 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);
Expand Down Expand Up @@ -1071,8 +1074,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;
Expand Down Expand Up @@ -1189,7 +1191,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;
Expand Down Expand Up @@ -1274,7 +1276,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;
Expand Down Expand Up @@ -1358,7 +1360,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);
}
Expand Down Expand Up @@ -1392,8 +1394,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;
}

Expand Down Expand Up @@ -1436,9 +1441,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;
}

Expand Down Expand Up @@ -1506,10 +1514,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) {
Expand Down
19 changes: 10 additions & 9 deletions msm8226/libcopybit/software_converter.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6520874

Please sign in to comment.