summaryrefslogtreecommitdiff
path: root/src/gralloc/gralloc_mod.h
blob: 176ea6372764c7a93727e83750ace5845f5a93fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _GRALLOC_DRM_H
#define _GRALLOC_DRM_H

#include <hardware/gralloc.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <pthread.h>

struct drm_module_t {
   gralloc_module_t base;

   pthread_mutex_t mutex;

   /* initialized by drm_gem_init */
   int fd;

   /* initialized by drm_kms_init */
   drmModeResPtr resources;
   uint32_t crtc_id;
   uint32_t connector_id;
   drmModeModeInfo mode;
   int xdpi, ydpi;
   int format;
#ifdef DRM_MODE_FEATURE_DIRTYFB
   drmModeClip clip;
#endif

   /* initialized by drm_gem_drv_init */
   void *drv;
   void *gem;
   int mode_dirty_fb;
   int mode_page_flip;
   int swap_interval;
   int vblank_secondary;

   int first_post;
};

static inline int
drm_mod_get_bpp(int format)
{
   int bpp;

   switch (format) {
   case HAL_PIXEL_FORMAT_RGBA_8888:
   case HAL_PIXEL_FORMAT_RGBX_8888:
   case HAL_PIXEL_FORMAT_BGRA_8888:
      bpp = 4;
      break;
   case HAL_PIXEL_FORMAT_RGB_888:
      bpp = 3;
      break;
   case HAL_PIXEL_FORMAT_RGB_565:
   case HAL_PIXEL_FORMAT_RGBA_5551:
   case HAL_PIXEL_FORMAT_RGBA_4444:
      bpp = 2;
      break;
   default:
      bpp = 0;
      break;
   }

   return bpp;
}

#endif /* _GRALLOC_DRM_H */