Lines Matching refs:hwc_dev

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