• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/gbm_gralloc


Commit MetaInfo

Revisionff66db2e495ee96a82aaf55dfbb058ebb7df2c95 (tree)
Time2016-12-14 00:43:50
AuthorRob Herring <robh@kern...>
CommiterRob Herring

Log Message

Add YV12 pixel format support

GBM doesn't support YV12 and we need a single buffer, so request GR88 from
GBM instead and adjust the width and height. GR88 also ensures (hopefully)
that the GPU texture alignment requirements are met.

Signed-off-by: Rob Herring <robh@kernel.org>

Change Summary

Incremental Difference

--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -83,6 +83,9 @@ static uint32_t get_gbm_format(int format)
8383 fmt = GBM_FORMAT_ARGB8888;
8484 break;
8585 case HAL_PIXEL_FORMAT_YV12:
86+ /* YV12 is planar, but must be a single buffer so ask for GR88 */
87+ fmt = GBM_FORMAT_GR88;
88+ break;
8689 case HAL_PIXEL_FORMAT_YCbCr_422_SP:
8790 case HAL_PIXEL_FORMAT_YCrCb_420_SP:
8891 default:
@@ -131,6 +134,12 @@ static struct gralloc_gbm_bo_t *gbm_import(struct gbm_device *gbm,
131134 data.stride = handle->stride;
132135 data.format = format;
133136
137+ /* Adjust the width and height for a GBM GR88 buffer */
138+ if (handle->format == HAL_PIXEL_FORMAT_YV12) {
139+ data.width /= 2;
140+ data.height += handle->height / 2;
141+ }
142+
134143 buf->bo = gbm_bo_import(gbm, GBM_BO_IMPORT_FD, &data, 0);
135144 if (!buf->bo) {
136145 delete buf;
@@ -162,6 +171,15 @@ static struct gralloc_gbm_bo_t *gbm_alloc(struct gbm_device *gbm,
162171 height = 64;
163172 }
164173
174+ /*
175+ * For YV12, we request GR88, so halve the width since we're getting
176+ * 16bpp. Then increase the height by 1.5 for the U and V planes.
177+ */
178+ if (handle->format == HAL_PIXEL_FORMAT_YV12) {
179+ width /= 2;
180+ height += handle->height / 2;
181+ }
182+
165183 ALOGD("create BO, size=%dx%d, fmt=%d, usage=%x",
166184 handle->width, handle->height, handle->format, usage);
167185 buf->bo = gbm_bo_create(gbm, width, height, format, usage);
@@ -199,6 +217,13 @@ static int gbm_map(struct gralloc_gbm_bo_t *bo, int x, int y, int w, int h,
199217 if (bo->map_data)
200218 return -EINVAL;
201219
220+ if (bo->handle->format == HAL_PIXEL_FORMAT_YV12) {
221+ if (x || y)
222+ ALOGE("can't map with offset for planar %p - fmt %x", bo, bo->handle->format);
223+ w /= 2;
224+ h += h / 2;
225+ }
226+
202227 if (enable_write)
203228 flags |= GBM_BO_TRANSFER_WRITE;
204229