Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,12 @@ LOCAL_SRC_FILES := \
LOCAL_SHARED_LIBRARIES := \
libgbm \
liblog \
libcutils

LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)
libcutils \
libdrm

LOCAL_MODULE := gralloc.gbm
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)

LOCAL_MODULE := libgralloc_drm
LOCAL_MODULE_TAGS := optional
LOCAL_PROPRIETARY_MODULE := true

include $(BUILD_SHARED_LIBRARY)
41 changes: 2 additions & 39 deletions gralloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@

#include <hardware/gralloc.h>
#include <system/graphics.h>
#include <gralloc_handle.h>

#include <gbm.h>

#include "gralloc_drm.h"
#include "gralloc_gbm_priv.h"
#include "gralloc_drm_handle.h"

struct gbm_module_t {
gralloc_module_t base;
Expand Down Expand Up @@ -96,41 +95,6 @@ static int gbm_init(struct gbm_module_t *dmod)
return err;
}

static int gbm_mod_perform(const struct gralloc_module_t *mod, int op, ...)
{
struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
va_list args;
int err;
uint32_t uop = static_cast<uint32_t>(op);

err = gbm_init(dmod);
if (err)
return err;

va_start(args, op);
switch (uop) {
case GRALLOC_MODULE_PERFORM_GET_DRM_FD:
{
int *fd = va_arg(args, int *);
*fd = gbm_device_get_fd(dmod->gbm);
err = 0;
}
break;
/* TODO: This is a stub and should be implemented fully */
case GRALLOC_MODULE_PERFORM_GET_USAGE:
{
err = 0;
}
break;
default:
err = -EINVAL;
break;
}
va_end(args);

return err;
}

static int gbm_mod_register_buffer(const gralloc_module_t *mod,
buffer_handle_t handle)
{
Expand Down Expand Up @@ -217,7 +181,7 @@ static int gbm_mod_alloc_gpu0(alloc_device_t *dev,
buffer_handle_t *handle, int *stride)
{
struct gbm_module_t *dmod = (struct gbm_module_t *) dev->common.module;
struct gralloc_gbm_handle_t *gbm_handle;
struct gralloc_handle_t *gbm_handle;
int err = 0;

pthread_mutex_lock(&dmod->mutex);
Expand Down Expand Up @@ -297,7 +261,6 @@ struct gbm_module_t HAL_MODULE_INFO_SYM = {
.unregisterBuffer = gbm_mod_unregister_buffer,
.lock = gbm_mod_lock,
.unlock = gbm_mod_unlock,
.perform = gbm_mod_perform
},

.mutex = PTHREAD_MUTEX_INITIALIZER,
Expand Down
49 changes: 0 additions & 49 deletions gralloc_drm.h

This file was deleted.

99 changes: 0 additions & 99 deletions gralloc_drm_handle.h

This file was deleted.

44 changes: 11 additions & 33 deletions gralloc_gbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <hardware/gralloc.h>
#include <system/graphics.h>
#include <gralloc_handle.h>

#include <gbm.h>

#include "gralloc_gbm_priv.h"
#include "gralloc_drm_handle.h"

#define MAX(a, b) (((a) > (b)) ? (a) : (b))

Expand Down Expand Up @@ -117,7 +117,7 @@ static unsigned int get_pipe_bind(int usage)
}

static struct gbm_bo *gbm_import(struct gbm_device *gbm,
struct gralloc_gbm_handle_t *handle)
struct gralloc_handle_t *handle)
{
struct gbm_bo *bo;
#ifdef GBM_BO_IMPORT_FD_MODIFIER
Expand Down Expand Up @@ -156,7 +156,7 @@ static struct gbm_bo *gbm_import(struct gbm_device *gbm,
}

static struct gbm_bo *gbm_alloc(struct gbm_device *gbm,
struct gralloc_gbm_handle_t *handle)
struct gralloc_handle_t *handle)
{
struct gbm_bo *bo;
int format = get_gbm_format(handle->format);
Expand Down Expand Up @@ -215,7 +215,7 @@ void gbm_free(buffer_handle_t handle)
struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle)
{
int pid = getpid();
struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);

if (!gbm_handle)
return NULL;
Expand All @@ -233,7 +233,7 @@ static int gbm_map(buffer_handle_t handle, int x, int y, int w, int h,
{
int err = 0;
int flags = GBM_BO_TRANSFER_READ;
struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);
struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
struct bo_data_t *bo_data = gbm_bo_data(bo);
uint32_t stride;
Expand Down Expand Up @@ -305,7 +305,7 @@ struct gbm_device *gbm_dev_create(void)
int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
{
struct gbm_bo *bo;
struct gralloc_gbm_handle_t *handle = gralloc_gbm_handle(_handle);
struct gralloc_handle_t *handle = gralloc_handle(_handle);

if (!handle)
return -EINVAL;
Expand All @@ -325,7 +325,7 @@ int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
*/
int gralloc_gbm_handle_unregister(buffer_handle_t handle)
{
struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);

gbm_free(handle);
gbm_handle->data_owner = 0;
Expand All @@ -334,38 +334,16 @@ int gralloc_gbm_handle_unregister(buffer_handle_t handle)
return 0;
}

/*
* Create a buffer handle.
*/
static struct gralloc_gbm_handle_t *create_bo_handle(int width,
int height, int format, int usage)
{
struct gralloc_gbm_handle_t *handle;

handle = (gralloc_gbm_handle_t *)native_handle_create(GRALLOC_GBM_HANDLE_NUM_FDS, GRALLOC_GBM_HANDLE_NUM_INTS);
if (!handle)
return NULL;

handle->magic = GRALLOC_GBM_HANDLE_MAGIC;
handle->width = width;
handle->height = height;
handle->format = format;
handle->usage = usage;
handle->prime_fd = -1;

return handle;
}

/*
* Create a bo.
*/
struct gralloc_gbm_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
struct gralloc_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
int width, int height, int format, int usage)
{
struct gbm_bo *bo;
struct gralloc_gbm_handle_t *handle;
struct gralloc_handle_t *handle;

handle = create_bo_handle(width, height, format, usage);
handle = gralloc_handle_create(width, height, format, usage);
if (!handle)
return NULL;

Expand All @@ -388,7 +366,7 @@ int gralloc_gbm_bo_lock(buffer_handle_t handle,
int usage, int x, int y, int w, int h,
void **addr)
{
struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
struct gralloc_handle_t *gbm_handle = gralloc_handle(handle);
struct gbm_bo *bo = gralloc_gbm_bo_from_handle(handle);
struct bo_data_t *bo_data;

Expand Down
6 changes: 1 addition & 5 deletions gralloc_gbm_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ extern "C" {
struct gbm_device;
struct gbm_bo;

#define gralloc_gbm_handle_t gralloc_drm_handle_t
#define gralloc_gbm_handle gralloc_drm_handle

int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm);
int gralloc_gbm_handle_unregister(buffer_handle_t handle);

struct gralloc_gbm_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
struct gralloc_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
int width, int height, int format, int usage);
void gbm_free(buffer_handle_t handle);

struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle);
buffer_handle_t gralloc_gbm_bo_get_handle(struct gbm_bo *bo);
int gralloc_gbm_get_gem_handle(buffer_handle_t handle);

int gralloc_gbm_bo_lock(buffer_handle_t handle, int x, int y, int w, int h, int enable_write, void **addr);
int gralloc_gbm_bo_unlock(buffer_handle_t handle);
Expand Down