check the model_name to set the proper alignment 27/120827/3
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 24 Mar 2017 09:50:30 +0000 (18:50 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 24 Mar 2017 10:11:08 +0000 (19:11 +0900)
 - use g_tbm_surface_alignment_plane instead of TBM_SURFACE_ALIGNMENT_PLANE
 - use g_tbm_surface_alignment_pitch_rgb instead of TBM_SURFACE_ALIGNMENT_PITCH_RGB

Change-Id: I6a557361f2df0b532035a9b4c6cc65e6a6e68968

src/tbm_bufmgr_exynos.c

index 86fad59..3151bcf 100644 (file)
@@ -54,6 +54,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <libudev.h>
 
+#include <system_info.h>
+
 #include "tbm_bufmgr_tgl.h"
 
 #define DEBUG
@@ -112,13 +114,8 @@ char *target_name()
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
-#ifdef ALIGN_EIGHT
-#define TBM_SURFACE_ALIGNMENT_PLANE (8)
-#define TBM_SURFACE_ALIGNMENT_PITCH_RGB (8)
-#else
-#define TBM_SURFACE_ALIGNMENT_PLANE (64)
-#define TBM_SURFACE_ALIGNMENT_PITCH_RGB (64)
-#endif
+static unsigned int g_tbm_surface_alignment_plane;
+static unsigned int g_tbm_surface_alignment_pitch_rgb;
 
 #define TBM_SURFACE_ALIGNMENT_PLANE_NV12 (4096)
 #define TBM_SURFACE_ALIGNMENT_PITCH_YUV (16)
@@ -1874,8 +1871,8 @@ tbm_exynos_surface_get_plane_data(int width, int height,
        case TBM_FORMAT_RGB565:
                bpp = 16;
                _offset = 0;
-               _pitch = SIZE_ALIGN((width * bpp) >> 3, TBM_SURFACE_ALIGNMENT_PITCH_RGB);
-               _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+               _pitch = SIZE_ALIGN((width * bpp) >> 3, g_tbm_surface_alignment_pitch_rgb);
+               _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                _bo_idx = 0;
                break;
                /* 24 bpp RGB */
@@ -1883,8 +1880,8 @@ tbm_exynos_surface_get_plane_data(int width, int height,
        case TBM_FORMAT_BGR888:
                bpp = 24;
                _offset = 0;
-               _pitch = SIZE_ALIGN((width * bpp) >> 3, TBM_SURFACE_ALIGNMENT_PITCH_RGB);
-               _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+               _pitch = SIZE_ALIGN((width * bpp) >> 3, g_tbm_surface_alignment_pitch_rgb);
+               _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                _bo_idx = 0;
                break;
                /* 32 bpp RGB */
@@ -1898,8 +1895,8 @@ tbm_exynos_surface_get_plane_data(int width, int height,
        case TBM_FORMAT_BGRA8888:
                bpp = 32;
                _offset = 0;
-               _pitch = SIZE_ALIGN((width * bpp) >> 3, TBM_SURFACE_ALIGNMENT_PITCH_RGB);
-               _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+               _pitch = SIZE_ALIGN((width * bpp) >> 3, g_tbm_surface_alignment_pitch_rgb);
+               _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                _bo_idx = 0;
                break;
 
@@ -1912,7 +1909,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                bpp = 32;
                _offset = 0;
                _pitch = SIZE_ALIGN((width * bpp) >> 3, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-               _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+               _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                _bo_idx = 0;
                break;
 
@@ -1944,12 +1941,12 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                if (plane_idx == 0) {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                } else if (plane_idx == 1) {
                        _offset = width * height;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * (height / 2), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height / 2), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -1961,7 +1958,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 0)
                                break;
@@ -1970,7 +1967,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -1996,7 +1993,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 0)
                                break;
@@ -2005,7 +2002,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 4, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 4);
-                       _size = SIZE_ALIGN(_pitch * (height / 4), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height / 4), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 1)
                                break;
@@ -2014,7 +2011,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 4, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 4);
-                       _size = SIZE_ALIGN(_pitch * (height / 4), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height / 4), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -2027,7 +2024,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 0)
                                break;
@@ -2036,7 +2033,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 2, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * (height / 2), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height / 2), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 1)
                                break;
@@ -2045,7 +2042,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 2, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * (height / 2), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height / 2), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -2056,7 +2053,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 0)
                                break;
@@ -2065,7 +2062,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 2, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * (height), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 1)
                                break;
@@ -2074,7 +2071,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width / 2, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
-                       _size = SIZE_ALIGN(_pitch * (height), TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * (height), g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -2085,7 +2082,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 0)
                                break;
@@ -2094,7 +2091,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                        if (plane_idx == 1)
                                break;
@@ -2103,7 +2100,7 @@ tbm_exynos_surface_get_plane_data(int width, int height,
                {
                        _offset += _size;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
+                       _size = SIZE_ALIGN(_pitch * height, g_tbm_surface_alignment_plane);
                        _bo_idx = 0;
                }
                break;
@@ -2267,6 +2264,27 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd)
                goto fail_init_backend;
        }
 
+       /* get the model name from the capi-system-info.
+        * The alignment_plane and alignment_pitch_rgb is different accoring to the target.
+        * There will be the stride issue when the right alignment_plane and alignment_pitch_rgb
+        * is not set to the backend.
+        */
+       char *value = NULL;
+       if (system_info_get_platform_string("http://tizen.org/system/model_name", &value) != SYSTEM_INFO_ERROR_NONE) {
+               TBM_EXYNOS_ERROR("Cannot get the \"http://tizen.org/system/model_name\" key value from system-info.\n");
+               TBM_EXYNOS_ERROR("May not set the right value on libtbm-exynos backend.\n");
+       } else {
+               if (!strncmp(value, "TW1", 4)) {
+                       g_tbm_surface_alignment_plane = 8;
+                       g_tbm_surface_alignment_pitch_rgb = 8;
+               } else {
+                       g_tbm_surface_alignment_plane = 64;
+                       g_tbm_surface_alignment_pitch_rgb = 64;
+               }
+       }
+
+       free(value);
+
 #ifdef DEBUG
        {
                char *env;