diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-07-07 18:24:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-07-07 18:24:20 +0000 |
commit | 540c9ade686178b677db83ce7ae74f3553acdd54 (patch) | |
tree | adb02753ba1072226bed05fa70c80a5542e40d93 | |
parent | d24f77b99007067760affb618bbf9b022d983d40 (diff) | |
parent | eea8bb4e80911280f040e7126b69c164fe2d2968 (diff) |
Merge changes I1b6bd84e,I847db96b am: 132b45f0a2 am: eea8bb4e80
Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/1356424
Change-Id: I443256cfa6b656bdce290740bb3bd58b4d817a72
-rw-r--r-- | fstab.common | 1 | ||||
-rw-r--r-- | gralloc/gralloc.cpp | 14 | ||||
-rw-r--r-- | gralloc/gralloc_gbm.cpp | 47 | ||||
-rw-r--r-- | gralloc/gralloc_gbm_priv.h | 2 |
4 files changed, 64 insertions, 0 deletions
diff --git a/fstab.common b/fstab.common index b23e7f8..dbba930 100644 --- a/fstab.common +++ b/fstab.common @@ -4,3 +4,4 @@ # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK /dev/block/platform/soc@0/1d84000.ufshc/by-name/userdata /data ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized /dev/block/by-name/metadata /metadata ext4 noatime,nosuid,nodev,discard wait,formattable +/devices/platform/soc@0/8804000.sdhci/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto diff --git a/gralloc/gralloc.cpp b/gralloc/gralloc.cpp index 2753ee9..c71e901 100644 --- a/gralloc/gralloc.cpp +++ b/gralloc/gralloc.cpp @@ -150,6 +150,19 @@ static int gbm_mod_unlock(const gralloc_module_t *mod, buffer_handle_t handle) return err; } +static int gbm_mod_lock_ycbcr(gralloc_module_t const *mod, buffer_handle_t handle, + int usage, int x, int y, int w, int h, struct android_ycbcr *ycbcr) +{ + struct gbm_module_t *dmod = (struct gbm_module_t *) mod; + int err; + + pthread_mutex_lock(&dmod->mutex); + err = gralloc_gbm_bo_lock_ycbcr(handle, usage, x, y, w, h, ycbcr); + pthread_mutex_unlock(&dmod->mutex); + + return err; +} + static int gbm_mod_close_gpu0(struct hw_device_t *dev) { struct gbm_module_t *dmod = (struct gbm_module_t *)dev->module; @@ -251,6 +264,7 @@ struct gbm_module_t HAL_MODULE_INFO_SYM = { .unregisterBuffer = gbm_mod_unregister_buffer, .lock = gbm_mod_lock, .unlock = gbm_mod_unlock, + .lock_ycbcr = gbm_mod_lock_ycbcr, .perform = gbm_mod_perform }, diff --git a/gralloc/gralloc_gbm.cpp b/gralloc/gralloc_gbm.cpp index 43907e5..bdb41b8 100644 --- a/gralloc/gralloc_gbm.cpp +++ b/gralloc/gralloc_gbm.cpp @@ -482,3 +482,50 @@ int gralloc_gbm_bo_unlock(buffer_handle_t handle) return 0; } + +#define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1)) + +int gralloc_gbm_bo_lock_ycbcr(buffer_handle_t handle, + int usage, int x, int y, int w, int h, + struct android_ycbcr *ycbcr) +{ + struct gralloc_handle_t *hnd = gralloc_handle(handle); + int ystride, cstride; + void *addr; + int err; + + ALOGD("handle %p, hnd %p, usage 0x%x", handle, hnd, usage); + + err = gralloc_gbm_bo_lock(handle, usage, x, y, w, h, &addr); + if (err) + return err; + + memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved)); + + switch (hnd->format) { + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + ystride = cstride = GRALLOC_ALIGN(hnd->width, 16); + ycbcr->y = addr; + ycbcr->cr = (unsigned char *)addr + ystride * hnd->height; + ycbcr->cb = (unsigned char *)addr + ystride * hnd->height + 1; + ycbcr->ystride = ystride; + ycbcr->cstride = cstride; + ycbcr->chroma_step = 2; + break; + case HAL_PIXEL_FORMAT_YV12: + ystride = hnd->width; + cstride = GRALLOC_ALIGN(ystride / 2, 16); + ycbcr->y = addr; + ycbcr->cr = (unsigned char *)addr + ystride * hnd->height; + ycbcr->cb = (unsigned char *)addr + ystride * hnd->height + cstride * hnd->height / 2; + ycbcr->ystride = ystride; + ycbcr->cstride = cstride; + ycbcr->chroma_step = 1; + break; + default: + ALOGE("Can not lock buffer, invalid format: 0x%x", hnd->format); + return -EINVAL; + } + + return 0; +} diff --git a/gralloc/gralloc_gbm_priv.h b/gralloc/gralloc_gbm_priv.h index d0326c5..cbe9256 100644 --- a/gralloc/gralloc_gbm_priv.h +++ b/gralloc/gralloc_gbm_priv.h @@ -45,6 +45,8 @@ int gralloc_gbm_get_gem_handle(buffer_handle_t handle); int gralloc_gbm_bo_lock(buffer_handle_t handle, int usage, int x, int y, int w, int h, void **addr); int gralloc_gbm_bo_unlock(buffer_handle_t handle); +int gralloc_gbm_bo_lock_ycbcr(buffer_handle_t handle, int usage, + int x, int y, int w, int h, struct android_ycbcr *ycbcr); struct gbm_device *gbm_dev_create(void); void gbm_dev_destroy(struct gbm_device *gbm); |