Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-gbm_gralloc: Commit

external/gbm_gralloc


Commit MetaInfo

Revisionc2518c799dc8b0db28626edd0b72c3f0fe9dace7 (tree)
Zeit2020-09-28 08:08:35
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge remote-tracking branch 'origin/master' into nougat-x86

Ändern Zusammenfassung

Diff

--- a/Android.mk
+++ b/Android.mk
@@ -30,7 +30,8 @@ LOCAL_SHARED_LIBRARIES := \
3030 libdrm \
3131 libgbm \
3232 liblog \
33- libcutils
33+ libcutils \
34+ libhardware \
3435
3536 LOCAL_STATIC_LIBRARIES := libdrm_framebuffer
3637
--- a/gralloc.cpp
+++ b/gralloc.cpp
@@ -24,7 +24,7 @@
2424
2525 #define LOG_TAG "GRALLOC-GBM"
2626
27-#include <cutils/log.h>
27+#include <log/log.h>
2828 #include <stdlib.h>
2929 #include <stdarg.h>
3030 #include <string.h>
@@ -154,6 +154,19 @@ static int gbm_mod_unlock(const gralloc_module_t *mod, buffer_handle_t handle)
154154 return err;
155155 }
156156
157+static int gbm_mod_lock_ycbcr(gralloc_module_t const *mod, buffer_handle_t handle,
158+ int usage, int x, int y, int w, int h, struct android_ycbcr *ycbcr)
159+{
160+ struct gbm_module_t *dmod = (struct gbm_module_t *) mod;
161+ int err;
162+
163+ pthread_mutex_lock(&dmod->mutex);
164+ err = gralloc_gbm_bo_lock_ycbcr(handle, usage, x, y, w, h, ycbcr);
165+ pthread_mutex_unlock(&dmod->mutex);
166+
167+ return err;
168+}
169+
157170 static int gbm_mod_close_gpu0(struct hw_device_t *dev)
158171 {
159172 struct gbm_module_t *dmod = (struct gbm_module_t *)dev->module;
@@ -270,6 +283,7 @@ struct gbm_module_t HAL_MODULE_INFO_SYM = {
270283 .unregisterBuffer = gbm_mod_unregister_buffer,
271284 .lock = gbm_mod_lock,
272285 .unlock = gbm_mod_unlock,
286+ .lock_ycbcr = gbm_mod_lock_ycbcr,
273287 .perform = gbm_mod_perform
274288 },
275289
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -24,11 +24,12 @@
2424
2525 #define LOG_TAG "GRALLOC-GBM"
2626
27-#include <cutils/log.h>
27+#include <log/log.h>
2828 #include <cutils/atomic.h>
2929 #include <cutils/properties.h>
3030 #include <stdlib.h>
3131 #include <string.h>
32+#include <unistd.h>
3233 #include <errno.h>
3334 #include <sys/types.h>
3435 #include <sys/stat.h>
@@ -422,7 +423,7 @@ int gralloc_gbm_bo_lock(buffer_handle_t handle,
422423 gbm_bo_set_user_data(bo, bo_data, gralloc_gbm_destroy_user_data);
423424 }
424425
425- ALOGI("lock bo %p, cnt=%d, usage=%x", bo, bo_data->lock_count, usage);
426+ ALOGV("lock bo %p, cnt=%d, usage=%x", bo, bo_data->lock_count, usage);
426427
427428 /* allow multiple locks with compatible usages */
428429 if (bo_data->lock_count && (bo_data->locked_for & usage) != usage)
@@ -430,6 +431,15 @@ int gralloc_gbm_bo_lock(buffer_handle_t handle,
430431
431432 usage |= bo_data->locked_for;
432433
434+ /*
435+ * Some users will lock with an null crop rect.
436+ * Interpret this as no-crop (full buffer WxH).
437+ */
438+ if (w == 0 && h == 0) {
439+ w = gbm_handle->width;
440+ h = gbm_handle->height;
441+ }
442+
433443 if (usage & (GRALLOC_USAGE_SW_WRITE_MASK |
434444 GRALLOC_USAGE_SW_READ_MASK)) {
435445 /* the driver is supposed to wait for the bo */
@@ -475,3 +485,50 @@ int gralloc_gbm_bo_unlock(buffer_handle_t handle)
475485
476486 return 0;
477487 }
488+
489+#define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
490+
491+int gralloc_gbm_bo_lock_ycbcr(buffer_handle_t handle,
492+ int usage, int x, int y, int w, int h,
493+ struct android_ycbcr *ycbcr)
494+{
495+ struct gralloc_handle_t *hnd = gralloc_handle(handle);
496+ int ystride, cstride;
497+ void *addr = 0;
498+ int err;
499+
500+ ALOGV("handle %p, hnd %p, usage 0x%x", handle, hnd, usage);
501+
502+ err = gralloc_gbm_bo_lock(handle, usage, x, y, w, h, &addr);
503+ if (err)
504+ return err;
505+
506+ memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
507+
508+ switch (hnd->format) {
509+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
510+ ystride = cstride = GRALLOC_ALIGN(hnd->width, 16);
511+ ycbcr->y = addr;
512+ ycbcr->cr = (unsigned char *)addr + ystride * hnd->height;
513+ ycbcr->cb = (unsigned char *)addr + ystride * hnd->height + 1;
514+ ycbcr->ystride = ystride;
515+ ycbcr->cstride = cstride;
516+ ycbcr->chroma_step = 2;
517+ break;
518+ case HAL_PIXEL_FORMAT_YV12:
519+ ystride = hnd->width;
520+ cstride = GRALLOC_ALIGN(ystride / 2, 16);
521+ ycbcr->y = addr;
522+ ycbcr->cr = (unsigned char *)addr + ystride * hnd->height;
523+ ycbcr->cb = (unsigned char *)addr + ystride * hnd->height + cstride * hnd->height / 2;
524+ ycbcr->ystride = ystride;
525+ ycbcr->cstride = cstride;
526+ ycbcr->chroma_step = 1;
527+ break;
528+ default:
529+ ALOGE("Can not lock buffer, invalid format: 0x%x", hnd->format);
530+ return -EINVAL;
531+ }
532+
533+ return 0;
534+}
--- a/gralloc_gbm_priv.h
+++ b/gralloc_gbm_priv.h
@@ -43,8 +43,10 @@ struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle);
4343 buffer_handle_t gralloc_gbm_bo_get_handle(struct gbm_bo *bo);
4444 int gralloc_gbm_get_gem_handle(buffer_handle_t handle);
4545
46-int gralloc_gbm_bo_lock(buffer_handle_t handle, int x, int y, int w, int h, int enable_write, void **addr);
46+int gralloc_gbm_bo_lock(buffer_handle_t handle, int usage, int x, int y, int w, int h, void **addr);
4747 int gralloc_gbm_bo_unlock(buffer_handle_t handle);
48+int gralloc_gbm_bo_lock_ycbcr(buffer_handle_t handle, int usage,
49+ int x, int y, int w, int h, struct android_ycbcr *ycbcr);
4850
4951 struct gbm_device *gbm_dev_create(bool master);
5052 void gbm_dev_destroy(struct gbm_device *gbm);
Show on old repository browser