• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

external/gbm_gralloc


Commit MetaInfo

Revision82c0082b4e88b0770e3517fce76d72adfc32e499 (tree)
Time2018-07-03 07:43:28
AuthorRob Herring <robh@kern...>
CommiterRob Herring

Log Message

Move gralloc_gbm_handle_t accesses into gralloc_gbm.cpp

The only access to the gralloc_gbm_handle_t in gralloc.cpp is to set the
stride of allocated buffers. Move this into gralloc_gbm.cpp to isolate
accesses to the struct in one place.

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

Change Summary

Incremental Difference

--- a/gralloc.cpp
+++ b/gralloc.cpp
@@ -38,7 +38,6 @@
3838
3939 #include "gralloc_drm.h"
4040 #include "gralloc_gbm_priv.h"
41-#include "gralloc_drm_handle.h"
4241
4342 struct gbm_module_t {
4443 gralloc_module_t base;
@@ -47,37 +46,6 @@ struct gbm_module_t {
4746 struct gbm_device *gbm;
4847 };
4948
50-static inline int gralloc_gbm_get_bpp(int format)
51-{
52- int bpp;
53-
54- switch (format) {
55- case HAL_PIXEL_FORMAT_RGBA_8888:
56- case HAL_PIXEL_FORMAT_RGBX_8888:
57- case HAL_PIXEL_FORMAT_BGRA_8888:
58- bpp = 4;
59- break;
60- case HAL_PIXEL_FORMAT_RGB_888:
61- bpp = 3;
62- break;
63- case HAL_PIXEL_FORMAT_RGB_565:
64- case HAL_PIXEL_FORMAT_YCbCr_422_I:
65- bpp = 2;
66- break;
67- /* planar; only Y is considered */
68- case HAL_PIXEL_FORMAT_YV12:
69- case HAL_PIXEL_FORMAT_YCbCr_422_SP:
70- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
71- bpp = 1;
72- break;
73- default:
74- bpp = 0;
75- break;
76- }
77-
78- return bpp;
79-}
80-
8149 /*
8250 * Initialize the DRM device object
8351 */
@@ -217,23 +185,15 @@ static int gbm_mod_alloc_gpu0(alloc_device_t *dev,
217185 buffer_handle_t *handle, int *stride)
218186 {
219187 struct gbm_module_t *dmod = (struct gbm_module_t *) dev->common.module;
220- struct gralloc_gbm_handle_t *gbm_handle;
221188 int err = 0;
222189
223190 pthread_mutex_lock(&dmod->mutex);
224191
225- gbm_handle = gralloc_gbm_bo_create(dmod->gbm, w, h, format, usage);
226- if (!gbm_handle) {
192+ *handle = gralloc_gbm_bo_create(dmod->gbm, w, h, format, usage, stride);
193+ if (!*handle)
227194 err = -errno;
228- goto unlock;
229- }
230-
231- *handle = &gbm_handle->base;
232- /* in pixels */
233- *stride = gbm_handle->stride / gralloc_gbm_get_bpp(format);
234195
235196 ALOGV("buffer %p usage = %08x", *handle, usage);
236-unlock:
237197 pthread_mutex_unlock(&dmod->mutex);
238198 return err;
239199 }
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -100,6 +100,37 @@ static uint32_t get_gbm_format(int format)
100100 return fmt;
101101 }
102102
103+static int gralloc_gbm_get_bpp(int format)
104+{
105+ int bpp;
106+
107+ switch (format) {
108+ case HAL_PIXEL_FORMAT_RGBA_8888:
109+ case HAL_PIXEL_FORMAT_RGBX_8888:
110+ case HAL_PIXEL_FORMAT_BGRA_8888:
111+ bpp = 4;
112+ break;
113+ case HAL_PIXEL_FORMAT_RGB_888:
114+ bpp = 3;
115+ break;
116+ case HAL_PIXEL_FORMAT_RGB_565:
117+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
118+ bpp = 2;
119+ break;
120+ /* planar; only Y is considered */
121+ case HAL_PIXEL_FORMAT_YV12:
122+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
123+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
124+ bpp = 1;
125+ break;
126+ default:
127+ bpp = 0;
128+ break;
129+ }
130+
131+ return bpp;
132+}
133+
103134 static unsigned int get_pipe_bind(int usage)
104135 {
105136 unsigned int bind = 0;
@@ -359,8 +390,8 @@ static struct gralloc_gbm_handle_t *create_bo_handle(int width,
359390 /*
360391 * Create a bo.
361392 */
362-struct gralloc_gbm_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
363- int width, int height, int format, int usage)
393+buffer_handle_t gralloc_gbm_bo_create(struct gbm_device *gbm,
394+ int width, int height, int format, int usage, int *stride)
364395 {
365396 struct gbm_bo *bo;
366397 struct gralloc_gbm_handle_t *handle;
@@ -378,7 +409,10 @@ struct gralloc_gbm_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
378409 handle->data_owner = getpid();
379410 handle->data = bo;
380411
381- return handle;
412+ /* in pixels */
413+ *stride = handle->stride / gralloc_gbm_get_bpp(format);
414+
415+ return &handle->base;
382416 }
383417
384418 /*
--- a/gralloc_gbm_priv.h
+++ b/gralloc_gbm_priv.h
@@ -38,8 +38,8 @@ struct gbm_bo;
3838 int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm);
3939 int gralloc_gbm_handle_unregister(buffer_handle_t handle);
4040
41-struct gralloc_gbm_handle_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
42- int width, int height, int format, int usage);
41+buffer_handle_t gralloc_gbm_bo_create(struct gbm_device *gbm,
42+ int width, int height, int format, int usage, int *stride);
4343 void gbm_free(buffer_handle_t handle);
4444
4545 struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle);