return HAL_TBM_ERROR_NONE;
}
+static const unsigned short std_res[] = {
+ 600, 640, 720, 768, 800, 854, 864, 900, 960, 1024, 1050, 1080, 1152,
+ 1200, 1280, 1440, 1504, 1536, 1600, 1620, 1800, 1920, 2048, 2100, 2160, 2400, 2560, 2880,
+ 3072, 3456, 4320
+};
+
+static uint8_t tbm_dumb_try_std_res(uint32_t val, uint32_t* width, uint32_t* height) {
+ double sval = sqrt((double)val);
+ uint64_t lval = lround(sval);
+
+ if (sval != lval) {
+ for(uint8_t idy = 0; idy < sizeof(std_res)/sizeof(std_res[0]); idy++) {
+ for(uint8_t idx = 0; idx < sizeof(std_res)/sizeof(std_res[0]); idx++) {
+ unsigned short _x = std_res[idx];
+ unsigned short _y = std_res[idy];
+ if (_x * _y == val) {
+ *width = _x;
+ *height = _y;
+ return 1;
+ }
+ }
+ }
+ } else {
+ *width = lval;
+ *height = lval;
+ return 1;
+ }
+ return 0;
+}
+
static hal_tbm_bo *
tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size,
hal_tbm_bo_memory_type flags, hal_tbm_error *error)
dumb_flags = _get_dumb_flag_from_tbm(flags);
- //as we know only size for new bo set height=1 and bpp=8 and in this case
- //width will by equal to size in bytes;
- create_dumb_arg.height = 1;
- create_dumb_arg.bpp = 8;
- create_dumb_arg.width = size;
+ if (size == 4096000) {
+ create_dumb_arg.width = 1280;
+ create_dumb_arg.height = 720;
+ } else {
+ if(!tbm_dumb_try_std_res(size >> 2, &create_dumb_arg.height, &create_dumb_arg.width)) {
+ TBM_BACKEND_INFO("tbm_dumb_try_std_res FAILS: %ld ", size);
+ create_dumb_arg.width = 2048;
+ create_dumb_arg.height = ((uint32_t) size + (create_dumb_arg.width * 4) - 1) / (create_dumb_arg.width * 4);
+ }
+ }
+
create_dumb_arg.flags = dumb_flags;
+ create_dumb_arg.size = size;
if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb_arg)) {
TBM_BACKEND_ERR("fail to DRM_IOCTL_MODE_CREATE_DUMB flag:%x size:%d",
create_dumb_arg.flags, (unsigned int)size);