Lines Matching refs:hwc_dev
331 static void dump_set_info(omap4_hwc_device_t *hwc_dev, hwc_display_contents_1_t* list) in dump_set_info() argument
333 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in dump_set_info()
347 if (hwc_dev->post2_blit_buffers) { in dump_set_info()
348 if ((i + 1) < hwc_dev->post2_layers) in dump_set_info()
380 for (i = 0; i < hwc_dev->post2_layers; i++) { in dump_set_info()
383 dump_printf(&log, "%p", hwc_dev->buffers[i]); in dump_set_info()
385 if (hwc_dev->post2_blit_buffers) { in dump_set_info()
387 for (i = hwc_dev->post2_layers; in dump_set_info()
388 i < hwc_dev->post2_blit_buffers + hwc_dev->post2_layers; i++) { in dump_set_info()
389 dump_printf(&log, "%p ", hwc_dev->buffers[i]); in dump_set_info()
392 dump_printf(&log, "}%s\n", hwc_dev->use_sgx ? " swap" : ""); in dump_set_info()
504 static int is_upscaled_NV12(omap4_hwc_device_t *hwc_dev, hwc_layer_1_t *layer) in is_upscaled_NV12() argument
519 return (WIDTH(layer->displayFrame) >= w * hwc_dev->upscaled_nv12_limit || in is_upscaled_NV12()
520 HEIGHT(layer->displayFrame) >= h * hwc_dev->upscaled_nv12_limit); in is_upscaled_NV12()
551 static void wakeup_hdmi_thread(omap4_hwc_device_t *hwc_dev) in wakeup_hdmi_thread() argument
554 write(hwc_dev->wakeup_evt, &tmp, sizeof(tmp)); in wakeup_hdmi_thread()
557 static void fire_vsync_event(omap4_hwc_device_t *hwc_dev, uint64_t timestamp) in fire_vsync_event() argument
559 pthread_mutex_lock(&hwc_dev->vsync_lock); in fire_vsync_event()
561 hwc_dev->last_vsync_time_valid = 1; in fire_vsync_event()
562 hwc_dev->last_vsync_time = timestamp; in fire_vsync_event()
564 pthread_mutex_unlock(&hwc_dev->vsync_lock); in fire_vsync_event()
566 if (hwc_dev->procs && hwc_dev->procs->vsync) in fire_vsync_event()
567 hwc_dev->procs->vsync(hwc_dev->procs, 0, timestamp); in fire_vsync_event()
642 omap4_hwc_setup_layer(omap4_hwc_device_t *hwc_dev, struct dss2_ovl_info *ovl, in omap4_hwc_setup_layer() argument
892 omap4_hwc_adjust_primary_display_layer(omap4_hwc_device_t *hwc_dev, struct dss2_ovl_info *ovl) in omap4_hwc_adjust_primary_display_layer() argument
896 if (crop_to_rect(&ovl->cfg, hwc_dev->primary_region) != 0) { in omap4_hwc_adjust_primary_display_layer()
901 omap4_hwc_apply_transform(hwc_dev->primary_m, oc); in omap4_hwc_adjust_primary_display_layer()
904 oc->rotation += (oc->mirror ? -1 : 1) * hwc_dev->primary_rotation; in omap4_hwc_adjust_primary_display_layer()
955 static int omap4_hwc_can_scale_layer(omap4_hwc_device_t *hwc_dev, hwc_layer_1_t *layer, IMG_native_… in omap4_hwc_can_scale_layer() argument
968 … return omap4_hwc_can_scale(src_w, src_h, dst_w, dst_h, is_NV12(handle), &hwc_dev->fb_dis, &limits, in omap4_hwc_can_scale_layer()
969 hwc_dev->fb_dis.timings.pixel_clock, handle); in omap4_hwc_can_scale_layer()
972 static int omap4_hwc_is_valid_layer(omap4_hwc_device_t *hwc_dev, in omap4_hwc_is_valid_layer() argument
991 return omap4_hwc_can_scale_layer(hwc_dev, layer, handle); in omap4_hwc_is_valid_layer()
1032 static int omap4_hwc_set_best_hdmi_mode(omap4_hwc_device_t *hwc_dev, __u32 xres, __u32 yres, in omap4_hwc_set_best_hdmi_mode() argument
1035 int dis_ix = hwc_dev->on_tv ? 0 : 1; in omap4_hwc_set_best_hdmi_mode()
1042 omap4_hwc_ext_t *ext = &hwc_dev->ext; in omap4_hwc_set_best_hdmi_mode()
1045 int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &d); in omap4_hwc_set_best_hdmi_mode()
1186 ioctl(hwc_dev->dsscomp_fd, DSSCIOC_SETUP_DISPLAY, &sdis); in omap4_hwc_set_best_hdmi_mode()
1212 static void gather_layer_statistics(omap4_hwc_device_t *hwc_dev, struct counts *num, hwc_display_co… in gather_layer_statistics() argument
1223 if (omap4_hwc_is_valid_layer(hwc_dev, layer, handle)) { in gather_layer_statistics()
1227 if (scaled(layer) || is_NV12(handle) || hwc_dev->primary_transform) in gather_layer_statistics()
1249 hwc_dev->stats = *num; in gather_layer_statistics()
1252 static void decide_supported_cloning(omap4_hwc_device_t *hwc_dev, struct counts *num) in decide_supported_cloning() argument
1254 omap4_hwc_ext_t *ext = &hwc_dev->ext; in decide_supported_cloning()
1267 hwc_dev->ext_ovls = (num->dockable || ext->force_dock) ? 1 : 0; in decide_supported_cloning()
1268 num->max_hw_overlays -= max(hwc_dev->ext_ovls, hwc_dev->last_ext_ovls); in decide_supported_cloning()
1285 hwc_dev->ext_ovls = MAX_HW_OVERLAYS - num->max_hw_overlays; in decide_supported_cloning()
1288 num->max_hw_overlays -= hwc_dev->last_ext_ovls; in decide_supported_cloning()
1289 hwc_dev->ext_ovls = 0; in decide_supported_cloning()
1298 hwc_dev->ext_ovls_wanted = hwc_dev->ext_ovls; in decide_supported_cloning()
1299 hwc_dev->ext_ovls = min(MAX_HW_OVERLAYS - hwc_dev->last_int_ovls, hwc_dev->ext_ovls); in decide_supported_cloning()
1303 if (!num->protected && hwc_dev->ext_ovls && ext->current.enabled && !ext->current.docking) in decide_supported_cloning()
1304 num->max_hw_overlays = hwc_dev->ext_ovls; in decide_supported_cloning()
1307 if (hwc_dev->primary_transform) { in decide_supported_cloning()
1317 static int can_dss_render_all(omap4_hwc_device_t *hwc_dev, struct counts *num) in can_dss_render_all() argument
1319 omap4_hwc_ext_t *ext = &hwc_dev->ext; in can_dss_render_all()
1320 int on_tv = hwc_dev->on_tv || (ext->on_tv && ext->current.enabled); in can_dss_render_all()
1323 return !hwc_dev->force_sgx && in can_dss_render_all()
1336 (num->BGR == 0 || (num->RGB == 0 && !on_tv) || !hwc_dev->flags_rgb_order) && in can_dss_render_all()
1341 static inline int can_dss_render_layer(omap4_hwc_device_t *hwc_dev, in can_dss_render_layer() argument
1346 omap4_hwc_ext_t *ext = &hwc_dev->ext; in can_dss_render_layer()
1348 int on_tv = hwc_dev->on_tv || (ext->on_tv && cloning); in can_dss_render_layer()
1351 return omap4_hwc_is_valid_layer(hwc_dev, layer, handle) && in can_dss_render_layer()
1355 (!hwc_dev->flags_nv12_only || (!hwc_dev->use_sgx || is_NV12(handle))) && in can_dss_render_layer()
1357 (!(hwc_dev->swap_rb ? is_RGB(handle) : is_BGR(handle)) || in can_dss_render_layer()
1358 !hwc_dev->flags_rgb_order) && in can_dss_render_layer()
1368 static int clone_layer(omap4_hwc_device_t *hwc_dev, int ix) { in clone_layer() argument
1369 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in clone_layer()
1370 omap4_hwc_ext_t *ext = &hwc_dev->ext; in clone_layer()
1371 int ext_ovl_ix = dsscomp->num_ovls - hwc_dev->post2_layers; in clone_layer()
1392 if (ix == 0 && hwc_dev->ion_handles[sync_id%2] && hwc_dev->use_sgx) { in clone_layer()
1394 o->ba = (int)hwc_dev->ion_handles[sync_id%2]; in clone_layer()
1401 o->cfg.zorder += hwc_dev->post2_layers; in clone_layer()
1403 omap4_hwc_adjust_ext_layer(&hwc_dev->ext, o); in clone_layer()
1408 static int clone_external_layer(omap4_hwc_device_t *hwc_dev, int ix) { in clone_external_layer() argument
1409 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in clone_external_layer()
1410 omap4_hwc_ext_t *ext = &hwc_dev->ext; in clone_external_layer()
1433 if (omap4_hwc_set_best_hdmi_mode(hwc_dev, xres, yres, xpy)) { in clone_external_layer()
1444 set_ext_matrix(&hwc_dev->ext, region); in clone_external_layer()
1446 return clone_layer(hwc_dev, ix); in clone_external_layer()
1449 static int setup_mirroring(omap4_hwc_device_t *hwc_dev) in setup_mirroring() argument
1451 omap4_hwc_ext_t *ext = &hwc_dev->ext; in setup_mirroring()
1457 if (omap4_hwc_set_best_hdmi_mode(hwc_dev, xres, yres, ext->lcd_xpy)) in setup_mirroring()
1493 static void blit_reset(omap4_hwc_device_t *hwc_dev, int flags) in blit_reset() argument
1495 hwc_dev->blit_flags = 0; in blit_reset()
1496 hwc_dev->blit_num = 0; in blit_reset()
1497 hwc_dev->post2_blit_buffers = 0; in blit_reset()
1498 hwc_dev->comp_data.blit_data.rgz_items = 0; in blit_reset()
1505 static int blit_layers(omap4_hwc_device_t *hwc_dev, hwc_display_contents_1_t *list, int bufoff) in blit_layers() argument
1508 if (!list || hwc_dev->force_sgx) in blit_layers()
1514 switch (hwc_dev->blt_mode) { in blit_layers()
1575 hwc_dev->blit_flags |= HWC_BLT_FLAG_USE_FB; in blit_layers()
1576 hwc_dev->blit_num = out.data.bvc.out_blits; in blit_layers()
1577 hwc_dev->post2_blit_buffers = out.data.bvc.out_nhndls; in blit_layers()
1578 for (i = 0; i < hwc_dev->post2_blit_buffers; i++) { in blit_layers()
1580 hwc_dev->buffers[bufoff++] = out.data.bvc.out_hndls[i]; in blit_layers()
1584 …memcpy(hwc_dev->comp_data.blit_data.rgz_blts, res_blit_ops, sizeof(*res_blit_ops) * out.data.bvc.c… in blit_layers()
1586 …ALOGE_IF(hwc_dev->blit_num != out.data.bvc.cmdlen,"blit_num != out.data.bvc.cmdlen, %d != %d", hwc… in blit_layers()
1604 void debug_post2(omap4_hwc_device_t *hwc_dev, int nbufs) in debug_post2() argument
1608 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in debug_post2()
1611 ALOGI("buf[%d] hndl %p", i, hwc_dev->buffers[i]); in debug_post2()
1618 static int free_tiler2d_buffers(omap4_hwc_device_t *hwc_dev) in free_tiler2d_buffers() argument
1623 ion_free(hwc_dev->ion_fd, hwc_dev->ion_handles[i]); in free_tiler2d_buffers()
1624 hwc_dev->ion_handles[i] = NULL; in free_tiler2d_buffers()
1629 static int allocate_tiler2d_buffers(omap4_hwc_device_t *hwc_dev) in allocate_tiler2d_buffers() argument
1634 if (hwc_dev->ion_fd < 0) { in allocate_tiler2d_buffers()
1640 if (hwc_dev->ion_handles[i]) in allocate_tiler2d_buffers()
1645 … ret = ion_alloc_tiler(hwc_dev->ion_fd, hwc_dev->fb_dev->base.width, hwc_dev->fb_dev->base.height, in allocate_tiler2d_buffers()
1646 … TILER_PIXEL_FMT_32BIT, 0, &hwc_dev->ion_handles[i], &stride); in allocate_tiler2d_buffers()
1650 ALOGI("ion handle[%d][%p]", i, hwc_dev->ion_handles[i]); in allocate_tiler2d_buffers()
1655 free_tiler2d_buffers(hwc_dev); in allocate_tiler2d_buffers()
1667 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; in omap4_hwc_prepare() local
1668 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in omap4_hwc_prepare()
1672 pthread_mutex_lock(&hwc_dev->lock); in omap4_hwc_prepare()
1676 gather_layer_statistics(hwc_dev, &num, list); in omap4_hwc_prepare()
1678 decide_supported_cloning(hwc_dev, &num); in omap4_hwc_prepare()
1681 if (can_dss_render_all(hwc_dev, &num)) { in omap4_hwc_prepare()
1683 hwc_dev->use_sgx = 0; in omap4_hwc_prepare()
1684 hwc_dev->swap_rb = num.BGR != 0; in omap4_hwc_prepare()
1687 hwc_dev->use_sgx = 1; in omap4_hwc_prepare()
1688 hwc_dev->swap_rb = is_BGR_format(hwc_dev->fb_dev->base.format); in omap4_hwc_prepare()
1699 blit_reset(hwc_dev, list ? list->flags : 0); in omap4_hwc_prepare()
1704 int needs_fb = hwc_dev->use_sgx; in omap4_hwc_prepare()
1706 if (hwc_dev->blt_policy == BLTPOLICY_ALL) { in omap4_hwc_prepare()
1708 blit_all = blit_layers(hwc_dev, list, 0); in omap4_hwc_prepare()
1711 hwc_dev->use_sgx = 0; in omap4_hwc_prepare()
1727 can_dss_render_layer(hwc_dev, layer) && in omap4_hwc_prepare()
1728 (!hwc_dev->force_sgx || in omap4_hwc_prepare()
1731 is_upscaled_NV12(hwc_dev, layer) || in omap4_hwc_prepare()
1732 (hwc_dev->ext.current.docking && hwc_dev->ext.current.enabled && dockable(layer))) && in omap4_hwc_prepare()
1750 if (hwc_dev->use_sgx && !is_BLENDED(layer)) in omap4_hwc_prepare()
1753 hwc_dev->buffers[dsscomp->num_ovls] = layer->handle; in omap4_hwc_prepare()
1755 omap4_hwc_setup_layer(hwc_dev, in omap4_hwc_prepare()
1763 … dsscomp->ovls[dsscomp->num_ovls].cfg.ix = dsscomp->num_ovls + hwc_dev->primary_transform; in omap4_hwc_prepare()
1768 if ((dsscomp->num_ovls == 0) && (!hwc_dev->primary_transform)) { in omap4_hwc_prepare()
1790 } else if (hwc_dev->use_sgx) { in omap4_hwc_prepare()
1807 if (hwc_dev->blt_policy == BLTPOLICY_DEFAULT) { in omap4_hwc_prepare()
1808 if (hwc_dev->use_sgx) { in omap4_hwc_prepare()
1809 if (blit_layers(hwc_dev, list, dsscomp->num_ovls == 1 ? 0 : dsscomp->num_ovls)) { in omap4_hwc_prepare()
1810 hwc_dev->use_sgx = 0; in omap4_hwc_prepare()
1821 if (!hwc_dev->blt_policy != BLTPOLICY_DISABLED && num.composited_layers) in omap4_hwc_prepare()
1829 if (hwc_dev->use_sgx) { in omap4_hwc_prepare()
1830 hwc_dev->buffers[0] = NULL; in omap4_hwc_prepare()
1833 hwc_dev->fb_dev->base.format, in omap4_hwc_prepare()
1835 hwc_dev->fb_dev->base.width, in omap4_hwc_prepare()
1836 hwc_dev->fb_dev->base.height); in omap4_hwc_prepare()
1840 dsscomp->ovls[0].cfg.ix = hwc_dev->primary_transform; in omap4_hwc_prepare()
1844 hwc_dev->post2_layers = dsscomp->num_ovls; in omap4_hwc_prepare()
1846 omap4_hwc_ext_t *ext = &hwc_dev->ext; in omap4_hwc_prepare()
1847 if (ext->current.enabled && hwc_dev->ext_ovls) { in omap4_hwc_prepare()
1849 if (clone_external_layer(hwc_dev, ix_docking) == 0) in omap4_hwc_prepare()
1857 if (clone_external_layer(hwc_dev, ix_docking) == 0) { in omap4_hwc_prepare()
1867 res = setup_mirroring(hwc_dev); in omap4_hwc_prepare()
1870 for (ix = 0; res == 0 && ix < hwc_dev->post2_layers; ix++) { in omap4_hwc_prepare()
1871 if (clone_layer(hwc_dev, ix)) in omap4_hwc_prepare()
1879 if (hwc_dev->primary_transform) in omap4_hwc_prepare()
1882 omap4_hwc_adjust_primary_display_layer(hwc_dev, &dsscomp->ovls[i]); in omap4_hwc_prepare()
1904 dsscomp->mgrs[0].swap_rb = hwc_dev->swap_rb; in omap4_hwc_prepare()
1907 if (ext->current.enabled || hwc_dev->last_ext_ovls) { in omap4_hwc_prepare()
1911 hwc_dev->ext_ovls = dsscomp->num_ovls - hwc_dev->post2_layers; in omap4_hwc_prepare()
1918 if (ext->last_mode == 0 && hwc_dev->on_tv) { in omap4_hwc_prepare()
1925 hwc_dev->use_sgx ? "SGX+OVL" : "all-OVL", in omap4_hwc_prepare()
1933 … hwc_dev->ext_ovls, num.max_hw_overlays, hwc_dev->last_ext_ovls, hwc_dev->last_int_ovls); in omap4_hwc_prepare()
1936 pthread_mutex_unlock(&hwc_dev->lock); in omap4_hwc_prepare()
1940 static void omap4_hwc_reset_screen(omap4_hwc_device_t *hwc_dev) in omap4_hwc_reset_screen() argument
1951 ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_SETUP_DISPC, &d); in omap4_hwc_reset_screen()
1958 ret = ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_POWERDOWN); in omap4_hwc_reset_screen()
1962 ret = ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); in omap4_hwc_reset_screen()
1982 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; in omap4_hwc_set() local
1983 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in omap4_hwc_set()
1987 pthread_mutex_lock(&hwc_dev->lock); in omap4_hwc_set()
1992 if (!hwc_dev->on_tv) in omap4_hwc_set()
1993 omap4_hwc_reset_screen(hwc_dev); in omap4_hwc_set()
1995 invalidate = hwc_dev->ext_ovls_wanted && (hwc_dev->ext_ovls < hwc_dev->ext_ovls_wanted) && in omap4_hwc_set()
1996 (hwc_dev->stats.protected || !hwc_dev->ext_ovls); in omap4_hwc_set()
1999 dump_set_info(hwc_dev, list); in omap4_hwc_set()
2006 if (hwc_dev->use_sgx) { in omap4_hwc_set()
2017 wakeup_hdmi_thread(hwc_dev); in omap4_hwc_set()
2018 if (hwc_dev->force_sgx > 0) in omap4_hwc_set()
2019 hwc_dev->force_sgx--; in omap4_hwc_set()
2021 hwc_dev->comp_data.blit_data.rgz_flags = hwc_dev->blit_flags; in omap4_hwc_set()
2022 hwc_dev->comp_data.blit_data.rgz_items = hwc_dev->blit_num; in omap4_hwc_set()
2023 int omaplfb_comp_data_sz = sizeof(hwc_dev->comp_data) + in omap4_hwc_set()
2024 (hwc_dev->comp_data.blit_data.rgz_items * sizeof(struct rgz_blt_entry)); in omap4_hwc_set()
2027 unsigned int nbufs = hwc_dev->post2_layers; in omap4_hwc_set()
2028 if (hwc_dev->post2_blit_buffers) { in omap4_hwc_set()
2034 nbufs += hwc_dev->post2_blit_buffers - 1; in omap4_hwc_set()
2036 if (hwc_dev->post2_layers > 1) { in omap4_hwc_set()
2039 hwc_dev->buffers[i] = hwc_dev->buffers[i+1]; in omap4_hwc_set()
2041 for (i = 1, j= 1; j < hwc_dev->post2_layers; i++, j++) { in omap4_hwc_set()
2046 ALOGI_IF(debugblt && hwc_dev->blt_policy != BLTPOLICY_DISABLED, in omap4_hwc_set()
2048 hwc_dev->blit_num, hwc_dev->post2_layers, hwc_dev->post2_blit_buffers, in omap4_hwc_set()
2049 hwc_dev->use_sgx); in omap4_hwc_set()
2051 debug_post2(hwc_dev, nbufs); in omap4_hwc_set()
2052 err = hwc_dev->fb_dev->Post2((framebuffer_device_t *)hwc_dev->fb_dev, in omap4_hwc_set()
2053 hwc_dev->buffers, in omap4_hwc_set()
2059 if (!hwc_dev->use_sgx) { in omap4_hwc_set()
2061 int err2 = ioctl(hwc_dev->fb_fd, FBIO_WAITFORVSYNC, &crt); in omap4_hwc_set()
2069 hwc_dev->last_ext_ovls = hwc_dev->ext_ovls; in omap4_hwc_set()
2070 hwc_dev->last_int_ovls = hwc_dev->post2_layers; in omap4_hwc_set()
2077 pthread_mutex_unlock(&hwc_dev->lock); in omap4_hwc_set()
2079 if (invalidate && hwc_dev->procs && hwc_dev->procs->invalidate) in omap4_hwc_set()
2080 hwc_dev->procs->invalidate(hwc_dev->procs); in omap4_hwc_set()
2087 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *)dev; in omap4_hwc_dump() local
2088 struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; in omap4_hwc_dump()
2096 dump_printf(&log, " idle timeout: %dms\n", hwc_dev->idle); in omap4_hwc_dump()
2103 cfg->enabled ? "true" : "false", hwc_dev->buffers[i], in omap4_hwc_dump()
2111 if (hwc_dev->blt_policy != BLTPOLICY_DISABLED) { in omap4_hwc_dump()
2113 hwc_dev->blt_policy == BLTPOLICY_DEFAULT ? "default" : in omap4_hwc_dump()
2114 hwc_dev->blt_policy == BLTPOLICY_ALL ? "all" : "unknown", in omap4_hwc_dump()
2115 hwc_dev->blt_mode == BLTMODE_PAINT ? "paint" : "regionize"); in omap4_hwc_dump()
2120 static void free_png_image(omap4_hwc_device_t *hwc_dev, struct omap4_hwc_img *img) in free_png_image() argument
2125 static int load_png_image(omap4_hwc_device_t *hwc_dev, char *path, struct omap4_hwc_img *img) in load_png_image() argument
2197 if (img->size > hwc_dev->img_mem_size) { in load_png_image()
2198 … ALOGE("image does not fit into framebuffer area (%d > %d)", img->size, hwc_dev->img_mem_size); in load_png_image()
2201 img->ptr = hwc_dev->img_mem_ptr; in load_png_image()
2225 free_png_image(hwc_dev, img); in load_png_image()
2238 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) device;; in omap4_hwc_device_close() local
2240 if (hwc_dev) { in omap4_hwc_device_close()
2241 if (hwc_dev->dsscomp_fd >= 0) in omap4_hwc_device_close()
2242 close(hwc_dev->dsscomp_fd); in omap4_hwc_device_close()
2243 if (hwc_dev->hdmi_fb_fd >= 0) in omap4_hwc_device_close()
2244 close(hwc_dev->hdmi_fb_fd); in omap4_hwc_device_close()
2245 if (hwc_dev->fb_fd >= 0) in omap4_hwc_device_close()
2246 close(hwc_dev->fb_fd); in omap4_hwc_device_close()
2247 if (hwc_dev->ion_fd >= 0) in omap4_hwc_device_close()
2248 ion_close(hwc_dev->ion_fd); in omap4_hwc_device_close()
2251 pthread_mutex_destroy(&hwc_dev->lock); in omap4_hwc_device_close()
2252 pthread_mutex_destroy(&hwc_dev->vsync_lock); in omap4_hwc_device_close()
2253 free(hwc_dev); in omap4_hwc_device_close()
2285 static void set_primary_display_transform_matrix(omap4_hwc_device_t *hwc_dev) in set_primary_display_transform_matrix() argument
2288 hwc_dev->fb_dis.ix = 0;/*Default display*/ in set_primary_display_transform_matrix()
2290 int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &hwc_dev->fb_dis); in set_primary_display_transform_matrix()
2294 int lcd_w = hwc_dev->fb_dis.timings.x_res; in set_primary_display_transform_matrix()
2295 int lcd_h = hwc_dev->fb_dis.timings.y_res; in set_primary_display_transform_matrix()
2296 int orig_w = hwc_dev->fb_dev->base.width; in set_primary_display_transform_matrix()
2297 int orig_h = hwc_dev->fb_dev->base.height; in set_primary_display_transform_matrix()
2299 hwc_dev->primary_region = region; in set_primary_display_transform_matrix()
2300 hwc_dev->primary_rotation = ((lcd_w > lcd_h) ^ (orig_w > orig_h)) ? 1 : 0; in set_primary_display_transform_matrix()
2301 hwc_dev->primary_transform = ((lcd_w != orig_w)||(lcd_h != orig_h)) ? 1 : 0; in set_primary_display_transform_matrix()
2303 …ALOGI("transforming FB (%dx%d) => (%dx%d) rot%d", orig_w, orig_h, lcd_w, lcd_h, hwc_dev->primary_r… in set_primary_display_transform_matrix()
2308 memcpy(hwc_dev->primary_m, m_unit, sizeof(m_unit)); in set_primary_display_transform_matrix()
2309 m_translate(hwc_dev->primary_m, -(orig_w >> 1), -(orig_h >> 1)); in set_primary_display_transform_matrix()
2310 m_rotate(hwc_dev->primary_m, hwc_dev->primary_rotation); in set_primary_display_transform_matrix()
2311 if (hwc_dev->primary_rotation & 1) in set_primary_display_transform_matrix()
2313 m_scale(hwc_dev->primary_m, orig_w, lcd_w, orig_h, lcd_h); in set_primary_display_transform_matrix()
2314 m_translate(hwc_dev->primary_m, lcd_w >> 1, lcd_h >> 1); in set_primary_display_transform_matrix()
2318 static void handle_hotplug(omap4_hwc_device_t *hwc_dev) in handle_hotplug() argument
2320 omap4_hwc_ext_t *ext = &hwc_dev->ext; in handle_hotplug()
2324 if (hwc_dev->on_tv) { in handle_hotplug()
2328 __u32 xres = hwc_dev->fb_dev->base.width; in handle_hotplug()
2329 __u32 yres = hwc_dev->fb_dev->base.height; in handle_hotplug()
2330 if (omap4_hwc_set_best_hdmi_mode(hwc_dev, xres, yres, ext->lcd_xpy)) { in handle_hotplug()
2333 set_primary_display_transform_matrix(hwc_dev); in handle_hotplug()
2335 ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); in handle_hotplug()
2337 if (hwc_dev->procs && hwc_dev->procs->invalidate) { in handle_hotplug()
2338 hwc_dev->procs->invalidate(hwc_dev->procs); in handle_hotplug()
2346 pthread_mutex_lock(&hwc_dev->lock); in handle_hotplug()
2363 …property_get("persist.hwc.mirroring.transform", value, hwc_dev->fb_dis.timings.y_res > hwc_dev->fb… in handle_hotplug()
2376 load_png_image(hwc_dev, value, &dock_image); in handle_hotplug()
2384 if (setup_mirroring(hwc_dev) == 0) { in handle_hotplug()
2386 ioctl(hwc_dev->hdmi_fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); in handle_hotplug()
2395 allocate_tiler2d_buffers(hwc_dev); in handle_hotplug()
2401 free_tiler2d_buffers(hwc_dev); in handle_hotplug()
2414 pthread_mutex_unlock(&hwc_dev->lock); in handle_hotplug()
2419 if (hwc_dev->procs && hwc_dev->procs->invalidate) in handle_hotplug()
2420 hwc_dev->procs->invalidate(hwc_dev->procs); in handle_hotplug()
2423 static void handle_uevents(omap4_hwc_device_t *hwc_dev, const char *buff, int len) in handle_uevents() argument
2456 fire_vsync_event(hwc_dev, timestamp); in handle_uevents()
2459 hwc_dev->ext.force_dock = state == 1; in handle_uevents()
2465 if (hwc_dev->on_tv) { in handle_uevents()
2468 pthread_mutex_lock(&hwc_dev->vsync_lock); in handle_uevents()
2471 state_change = (new_state != hwc_dev->ext.hdmi_state); in handle_uevents()
2472 hwc_dev->ext.hdmi_state = new_state; in handle_uevents()
2474 wakeup_hdmi_thread(hwc_dev); in handle_uevents()
2476 pthread_mutex_unlock(&hwc_dev->vsync_lock); in handle_uevents()
2478 hwc_dev->ext.hdmi_state = state == 1; in handle_uevents()
2481 handle_hotplug(hwc_dev); in handle_uevents()
2487 omap4_hwc_device_t *hwc_dev = data; in omap4_hwc_hdmi_thread() local
2500 fds[1].fd = hwc_dev->wakeup_evt; in omap4_hwc_hdmi_thread()
2503 timeout = hwc_dev->idle ? hwc_dev->idle : -1; in omap4_hwc_hdmi_thread()
2517 if (hwc_dev->on_tv) { in omap4_hwc_hdmi_thread()
2518 pthread_mutex_lock(&hwc_dev->vsync_lock); in omap4_hwc_hdmi_thread()
2520 if (!hwc_dev->ext.hdmi_state && hwc_dev->vsync_enabled) { in omap4_hwc_hdmi_thread()
2521 vsync_wakeup = hwc_dev->last_vsync_time_valid in omap4_hwc_hdmi_thread()
2522 ? hwc_dev->last_vsync_time in omap4_hwc_hdmi_thread()
2525 vsync_wakeup += hwc_dev->fake_vsync_period; in omap4_hwc_hdmi_thread()
2531 pthread_mutex_unlock(&hwc_dev->vsync_lock); in omap4_hwc_hdmi_thread()
2555 fire_vsync_event(hwc_dev, vsync_wakeup); in omap4_hwc_hdmi_thread()
2559 if (hwc_dev->idle && (now >= idle_wakeup)) { in omap4_hwc_hdmi_thread()
2560 if (hwc_dev->procs) { in omap4_hwc_hdmi_thread()
2561 pthread_mutex_lock(&hwc_dev->lock); in omap4_hwc_hdmi_thread()
2562 invalidate = hwc_dev->last_int_ovls > 1 && !hwc_dev->force_sgx; in omap4_hwc_hdmi_thread()
2564 hwc_dev->force_sgx = 2; in omap4_hwc_hdmi_thread()
2566 pthread_mutex_unlock(&hwc_dev->lock); in omap4_hwc_hdmi_thread()
2569 hwc_dev->procs->invalidate(hwc_dev->procs); in omap4_hwc_hdmi_thread()
2590 read(hwc_dev->wakeup_evt, &tmp, sizeof(tmp)); in omap4_hwc_hdmi_thread()
2592 if (!hwc_dev->force_sgx) in omap4_hwc_hdmi_thread()
2593 timeout = hwc_dev->idle ? hwc_dev->idle : -1; in omap4_hwc_hdmi_thread()
2599 handle_uevents(hwc_dev, uevent_desc, len); in omap4_hwc_hdmi_thread()
2609 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; in omap4_hwc_registerProcs() local
2611 hwc_dev->procs = (typeof(hwc_dev->procs)) procs; in omap4_hwc_registerProcs()
2617 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; in omap4_hwc_query() local
2626 value[0] = 1000000000.0 / hwc_dev->fb_dev->base.fps; in omap4_hwc_query()
2638 omap4_hwc_device_t *hwc_dev = (omap4_hwc_device_t *) dev; in omap4_hwc_event_control() local
2650 if (hwc_dev->on_tv) { in omap4_hwc_event_control()
2651 pthread_mutex_lock(&hwc_dev->vsync_lock); in omap4_hwc_event_control()
2654 hwc_dev->last_vsync_time_valid = 0; in omap4_hwc_event_control()
2660 if (!hwc_dev->ext.hdmi_state && !hwc_dev->vsync_enabled && val) in omap4_hwc_event_control()
2661 wakeup_hdmi_thread(hwc_dev); in omap4_hwc_event_control()
2663 hwc_dev->vsync_enabled = val; in omap4_hwc_event_control()
2665 err = ioctl(hwc_dev->fb_fd, OMAPFB_ENABLEVSYNC, &val); in omap4_hwc_event_control()
2666 pthread_mutex_unlock(&hwc_dev->vsync_lock); in omap4_hwc_event_control()
2668 err = ioctl(hwc_dev->fb_fd, OMAPFB_ENABLEVSYNC, &val); in omap4_hwc_event_control()
2692 omap4_hwc_device_t *hwc_dev; in omap4_hwc_device_open() local
2711 hwc_dev = (omap4_hwc_device_t *)malloc(sizeof(*hwc_dev)); in omap4_hwc_device_open()
2712 if (hwc_dev == NULL) in omap4_hwc_device_open()
2715 memset(hwc_dev, 0, sizeof(*hwc_dev)); in omap4_hwc_device_open()
2717 hwc_dev->base.common.tag = HARDWARE_DEVICE_TAG; in omap4_hwc_device_open()
2718 hwc_dev->base.common.version = HWC_DEVICE_API_VERSION_1_0; in omap4_hwc_device_open()
2719 hwc_dev->base.common.module = (hw_module_t *)module; in omap4_hwc_device_open()
2720 hwc_dev->base.common.close = omap4_hwc_device_close; in omap4_hwc_device_open()
2721 hwc_dev->base.prepare = omap4_hwc_prepare; in omap4_hwc_device_open()
2722 hwc_dev->base.set = omap4_hwc_set; in omap4_hwc_device_open()
2723 hwc_dev->base.eventControl = omap4_hwc_event_control; in omap4_hwc_device_open()
2724 hwc_dev->base.blank = omap4_hwc_blank; in omap4_hwc_device_open()
2725 hwc_dev->base.query = omap4_hwc_query; in omap4_hwc_device_open()
2726 hwc_dev->base.registerProcs = omap4_hwc_registerProcs; in omap4_hwc_device_open()
2727 hwc_dev->base.dump = omap4_hwc_dump; in omap4_hwc_device_open()
2728 hwc_dev->fb_dev = hwc_mod->fb_dev; in omap4_hwc_device_open()
2729 hwc_dev->wakeup_evt = -1; in omap4_hwc_device_open()
2730 *device = &hwc_dev->base.common; in omap4_hwc_device_open()
2732 hwc_dev->vsync_enabled = 0; in omap4_hwc_device_open()
2733 hwc_dev->last_vsync_time_valid = 0; in omap4_hwc_device_open()
2734 hwc_dev->fake_vsync_period = 1000000000ull/60; in omap4_hwc_device_open()
2736 hwc_dev->dsscomp_fd = open("/dev/dsscomp", O_RDWR); in omap4_hwc_device_open()
2737 if (hwc_dev->dsscomp_fd < 0) { in omap4_hwc_device_open()
2743 int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_PLATFORM, &limits); in omap4_hwc_device_open()
2750 hwc_dev->fb_fd = open("/dev/graphics/fb0", O_RDWR); in omap4_hwc_device_open()
2751 if (hwc_dev->fb_fd < 0) { in omap4_hwc_device_open()
2758 if (ioctl(hwc_dev->fb_fd, FBIOGET_FSCREENINFO, &fix)) { in omap4_hwc_device_open()
2764 hwc_dev->img_mem_size = fix.smem_len; in omap4_hwc_device_open()
2765 hwc_dev->img_mem_ptr = mmap(NULL, fix.smem_len, PROT_WRITE, MAP_SHARED, hwc_dev->fb_fd, 0); in omap4_hwc_device_open()
2766 if (hwc_dev->img_mem_ptr == MAP_FAILED) { in omap4_hwc_device_open()
2773 hwc_dev->buffers = malloc(sizeof(buffer_handle_t) * MAX_HWC_LAYERS); in omap4_hwc_device_open()
2774 if (!hwc_dev->buffers) { in omap4_hwc_device_open()
2779 ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &hwc_dev->fb_dis); in omap4_hwc_device_open()
2786 hwc_dev->ion_fd = ion_open(); in omap4_hwc_device_open()
2787 if (hwc_dev->ion_fd < 0) { in omap4_hwc_device_open()
2793 hwc_dev->ion_handles[i] = NULL; in omap4_hwc_device_open()
2797 hwc_dev->ext.lcd_xpy = 1.0; in omap4_hwc_device_open()
2798 if (hwc_dev->fb_dis.timings.x_res && hwc_dev->fb_dis.height_in_mm) { in omap4_hwc_device_open()
2799 hwc_dev->ext.lcd_xpy = (float) in omap4_hwc_device_open()
2800 hwc_dev->fb_dis.width_in_mm / hwc_dev->fb_dis.timings.x_res / in omap4_hwc_device_open()
2801 hwc_dev->fb_dis.height_in_mm * hwc_dev->fb_dis.timings.y_res; in omap4_hwc_device_open()
2804 if (hwc_dev->fb_dis.channel == OMAP_DSS_CHANNEL_DIGIT) { in omap4_hwc_device_open()
2806 hwc_dev->on_tv = 1; in omap4_hwc_device_open()
2809 hwc_dev->hdmi_fb_fd = open("/dev/graphics/fb1", O_RDWR); in omap4_hwc_device_open()
2810 if (hwc_dev->hdmi_fb_fd < 0) { in omap4_hwc_device_open()
2816 set_primary_display_transform_matrix(hwc_dev); in omap4_hwc_device_open()
2818 if ((hwc_dev->wakeup_evt = eventfd(0, EFD_NONBLOCK)) < 0) { in omap4_hwc_device_open()
2824 if (pthread_mutex_init(&hwc_dev->lock, NULL)) { in omap4_hwc_device_open()
2830 if (pthread_mutex_init(&hwc_dev->vsync_lock, NULL)) { in omap4_hwc_device_open()
2836 if (pthread_create(&hwc_dev->hdmi_thread, NULL, omap4_hwc_hdmi_thread, hwc_dev)) in omap4_hwc_device_open()
2848 hwc_dev->flags_rgb_order = atoi(value); in omap4_hwc_device_open()
2850 hwc_dev->flags_nv12_only = atoi(value); in omap4_hwc_device_open()
2852 hwc_dev->idle = atoi(value); in omap4_hwc_device_open()
2858 &hwc_dev->ext.mirror_region.left, &hwc_dev->ext.mirror_region.top, in omap4_hwc_device_open()
2859 &hwc_dev->ext.mirror_region.right, &hwc_dev->ext.mirror_region.bottom) != 4 || in omap4_hwc_device_open()
2860 hwc_dev->ext.mirror_region.left >= hwc_dev->ext.mirror_region.right || in omap4_hwc_device_open()
2861 hwc_dev->ext.mirror_region.top >= hwc_dev->ext.mirror_region.bottom) { in omap4_hwc_device_open()
2862 …struct hwc_rect fb_region = { .right = hwc_dev->fb_dev->base.width, .bottom = hwc_dev->fb_dev->bas… in omap4_hwc_device_open()
2863 hwc_dev->ext.mirror_region = fb_region; in omap4_hwc_device_open()
2866 hwc_dev->ext.mirror_region.left, hwc_dev->ext.mirror_region.top, in omap4_hwc_device_open()
2867 hwc_dev->ext.mirror_region.right, hwc_dev->ext.mirror_region.bottom); in omap4_hwc_device_open()
2874 hwc_dev->ext.hdmi_state = value == '1'; in omap4_hwc_device_open()
2881 hwc_dev->ext.force_dock = value == '1'; in omap4_hwc_device_open()
2884 handle_hotplug(hwc_dev); in omap4_hwc_device_open()
2887 hwc_dev->flags_rgb_order, hwc_dev->flags_nv12_only); in omap4_hwc_device_open()
2892 hwc_dev->blt_policy = BLTPOLICY_DISABLED; in omap4_hwc_device_open()
2895 hwc_dev->blt_mode = atoi(value); in omap4_hwc_device_open()
2897 hwc_dev->blt_policy = atoi(value); in omap4_hwc_device_open()
2898 … ALOGI("blitter present, blits mode %d, blits policy %d", hwc_dev->blt_mode, hwc_dev->blt_policy); in omap4_hwc_device_open()
2901 if (rgz_get_screengeometry(hwc_dev->fb_fd, &gscrngeom, in omap4_hwc_device_open()
2902 hwc_dev->fb_dev->base.format) != 0) { in omap4_hwc_device_open()
2909 sscanf(value, "%f", &hwc_dev->upscaled_nv12_limit); in omap4_hwc_device_open()
2910 if (hwc_dev->upscaled_nv12_limit < 0. || hwc_dev->upscaled_nv12_limit > 2048.) { in omap4_hwc_device_open()
2912 hwc_dev->upscaled_nv12_limit = 2.; in omap4_hwc_device_open()
2916 if (err && hwc_dev) { in omap4_hwc_device_open()
2917 if (hwc_dev->dsscomp_fd >= 0) in omap4_hwc_device_open()
2918 close(hwc_dev->dsscomp_fd); in omap4_hwc_device_open()
2919 if (hwc_dev->hdmi_fb_fd >= 0) in omap4_hwc_device_open()
2920 close(hwc_dev->hdmi_fb_fd); in omap4_hwc_device_open()
2921 if (hwc_dev->fb_fd >= 0) in omap4_hwc_device_open()
2922 close(hwc_dev->fb_fd); in omap4_hwc_device_open()
2923 if (hwc_dev->wakeup_evt >= 0) in omap4_hwc_device_open()
2924 close(hwc_dev->wakeup_evt); in omap4_hwc_device_open()
2925 pthread_mutex_destroy(&hwc_dev->lock); in omap4_hwc_device_open()
2926 pthread_mutex_destroy(&hwc_dev->vsync_lock); in omap4_hwc_device_open()
2927 free(hwc_dev->buffers); in omap4_hwc_device_open()
2928 free(hwc_dev); in omap4_hwc_device_open()