1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 25acd3514SThierry Reding /* 35acd3514SThierry Reding * Copyright (C) 2017 NVIDIA CORPORATION. All rights reserved. 45acd3514SThierry Reding */ 55acd3514SThierry Reding 6273da5a0SThierry Reding #include <linux/iommu.h> 704d5d5dfSDmitry Osipenko #include <linux/interconnect.h> 8273da5a0SThierry Reding 95acd3514SThierry Reding #include <drm/drm_atomic.h> 105acd3514SThierry Reding #include <drm/drm_atomic_helper.h> 11eb1df694SSam Ravnborg #include <drm/drm_fourcc.h> 12820c1707SThomas Zimmermann #include <drm/drm_gem_atomic_helper.h> 135acd3514SThierry Reding #include <drm/drm_plane_helper.h> 145acd3514SThierry Reding 155acd3514SThierry Reding #include "dc.h" 165acd3514SThierry Reding #include "plane.h" 175acd3514SThierry Reding 185acd3514SThierry Reding static void tegra_plane_destroy(struct drm_plane *plane) 195acd3514SThierry Reding { 205acd3514SThierry Reding struct tegra_plane *p = to_tegra_plane(plane); 215acd3514SThierry Reding 225acd3514SThierry Reding drm_plane_cleanup(plane); 235acd3514SThierry Reding kfree(p); 245acd3514SThierry Reding } 255acd3514SThierry Reding 265acd3514SThierry Reding static void tegra_plane_reset(struct drm_plane *plane) 275acd3514SThierry Reding { 283dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 295acd3514SThierry Reding struct tegra_plane_state *state; 302e8d8749SThierry Reding unsigned int i; 315acd3514SThierry Reding 325acd3514SThierry Reding if (plane->state) 335acd3514SThierry Reding __drm_atomic_helper_plane_destroy_state(plane->state); 345acd3514SThierry Reding 355acd3514SThierry Reding kfree(plane->state); 365acd3514SThierry Reding plane->state = NULL; 375acd3514SThierry Reding 385acd3514SThierry Reding state = kzalloc(sizeof(*state), GFP_KERNEL); 395acd3514SThierry Reding if (state) { 405acd3514SThierry Reding plane->state = &state->base; 415acd3514SThierry Reding plane->state->plane = plane; 423dae08bcSDmitry Osipenko plane->state->zpos = p->index; 433dae08bcSDmitry Osipenko plane->state->normalized_zpos = p->index; 442e8d8749SThierry Reding 452e8d8749SThierry Reding for (i = 0; i < 3; i++) 462e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 475acd3514SThierry Reding } 485acd3514SThierry Reding } 495acd3514SThierry Reding 505acd3514SThierry Reding static struct drm_plane_state * 515acd3514SThierry Reding tegra_plane_atomic_duplicate_state(struct drm_plane *plane) 525acd3514SThierry Reding { 535acd3514SThierry Reding struct tegra_plane_state *state = to_tegra_plane_state(plane->state); 545acd3514SThierry Reding struct tegra_plane_state *copy; 55ebae8d07SThierry Reding unsigned int i; 565acd3514SThierry Reding 575acd3514SThierry Reding copy = kmalloc(sizeof(*copy), GFP_KERNEL); 585acd3514SThierry Reding if (!copy) 595acd3514SThierry Reding return NULL; 605acd3514SThierry Reding 615acd3514SThierry Reding __drm_atomic_helper_plane_duplicate_state(plane, ©->base); 625acd3514SThierry Reding copy->tiling = state->tiling; 635acd3514SThierry Reding copy->format = state->format; 645acd3514SThierry Reding copy->swap = state->swap; 65cd740777SDmitry Osipenko copy->reflect_x = state->reflect_x; 66e9e476f7SDmitry Osipenko copy->reflect_y = state->reflect_y; 67ebae8d07SThierry Reding copy->opaque = state->opaque; 6804d5d5dfSDmitry Osipenko copy->total_peak_memory_bandwidth = state->total_peak_memory_bandwidth; 6904d5d5dfSDmitry Osipenko copy->peak_memory_bandwidth = state->peak_memory_bandwidth; 7004d5d5dfSDmitry Osipenko copy->avg_memory_bandwidth = state->avg_memory_bandwidth; 71ebae8d07SThierry Reding 723dae08bcSDmitry Osipenko for (i = 0; i < 2; i++) 733dae08bcSDmitry Osipenko copy->blending[i] = state->blending[i]; 745acd3514SThierry Reding 752e8d8749SThierry Reding for (i = 0; i < 3; i++) { 762e8d8749SThierry Reding copy->iova[i] = DMA_MAPPING_ERROR; 77c6aeaf56SThierry Reding copy->map[i] = NULL; 782e8d8749SThierry Reding } 792e8d8749SThierry Reding 805acd3514SThierry Reding return ©->base; 815acd3514SThierry Reding } 825acd3514SThierry Reding 835acd3514SThierry Reding static void tegra_plane_atomic_destroy_state(struct drm_plane *plane, 845acd3514SThierry Reding struct drm_plane_state *state) 855acd3514SThierry Reding { 865acd3514SThierry Reding __drm_atomic_helper_plane_destroy_state(state); 875acd3514SThierry Reding kfree(state); 885acd3514SThierry Reding } 895acd3514SThierry Reding 907b6f8467SThierry Reding static bool tegra_plane_supports_sector_layout(struct drm_plane *plane) 917b6f8467SThierry Reding { 927b6f8467SThierry Reding struct drm_crtc *crtc; 937b6f8467SThierry Reding 947b6f8467SThierry Reding drm_for_each_crtc(crtc, plane->dev) { 957b6f8467SThierry Reding if (plane->possible_crtcs & drm_crtc_mask(crtc)) { 967b6f8467SThierry Reding struct tegra_dc *dc = to_tegra_dc(crtc); 977b6f8467SThierry Reding 987b6f8467SThierry Reding if (!dc->soc->supports_sector_layout) 997b6f8467SThierry Reding return false; 1007b6f8467SThierry Reding } 1017b6f8467SThierry Reding } 1027b6f8467SThierry Reding 1037b6f8467SThierry Reding return true; 1047b6f8467SThierry Reding } 1057b6f8467SThierry Reding 106e90124cbSThierry Reding static bool tegra_plane_format_mod_supported(struct drm_plane *plane, 107e90124cbSThierry Reding uint32_t format, 108e90124cbSThierry Reding uint64_t modifier) 109e90124cbSThierry Reding { 110e90124cbSThierry Reding const struct drm_format_info *info = drm_format_info(format); 111e90124cbSThierry Reding 112e90124cbSThierry Reding if (modifier == DRM_FORMAT_MOD_LINEAR) 113e90124cbSThierry Reding return true; 114e90124cbSThierry Reding 1157b6f8467SThierry Reding /* check for the sector layout bit */ 116c1d3cfbcSThierry Reding if (fourcc_mod_is_vendor(modifier, NVIDIA)) { 1177b6f8467SThierry Reding if (modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) { 1187b6f8467SThierry Reding if (!tegra_plane_supports_sector_layout(plane)) 1197b6f8467SThierry Reding return false; 1207b6f8467SThierry Reding } 1217b6f8467SThierry Reding } 1227b6f8467SThierry Reding 123e90124cbSThierry Reding if (info->num_planes == 1) 124e90124cbSThierry Reding return true; 125e90124cbSThierry Reding 126e90124cbSThierry Reding return false; 127e90124cbSThierry Reding } 128e90124cbSThierry Reding 1295acd3514SThierry Reding const struct drm_plane_funcs tegra_plane_funcs = { 1305acd3514SThierry Reding .update_plane = drm_atomic_helper_update_plane, 1315acd3514SThierry Reding .disable_plane = drm_atomic_helper_disable_plane, 1325acd3514SThierry Reding .destroy = tegra_plane_destroy, 1335acd3514SThierry Reding .reset = tegra_plane_reset, 1345acd3514SThierry Reding .atomic_duplicate_state = tegra_plane_atomic_duplicate_state, 1355acd3514SThierry Reding .atomic_destroy_state = tegra_plane_atomic_destroy_state, 136e90124cbSThierry Reding .format_mod_supported = tegra_plane_format_mod_supported, 1375acd3514SThierry Reding }; 1385acd3514SThierry Reding 1392e8d8749SThierry Reding static int tegra_dc_pin(struct tegra_dc *dc, struct tegra_plane_state *state) 1402e8d8749SThierry Reding { 1412e8d8749SThierry Reding unsigned int i; 1422e8d8749SThierry Reding int err; 1432e8d8749SThierry Reding 1442e8d8749SThierry Reding for (i = 0; i < state->base.fb->format->num_planes; i++) { 1452e8d8749SThierry Reding struct tegra_bo *bo = tegra_fb_get_plane(state->base.fb, i); 146c6aeaf56SThierry Reding struct host1x_bo_mapping *map; 1472e8d8749SThierry Reding 1481f39b1dfSThierry Reding map = host1x_bo_pin(dc->dev, &bo->base, DMA_TO_DEVICE, &dc->client.cache); 149c6aeaf56SThierry Reding if (IS_ERR(map)) { 150c6aeaf56SThierry Reding err = PTR_ERR(map); 1512e8d8749SThierry Reding goto unpin; 1522e8d8749SThierry Reding } 1532e8d8749SThierry Reding 154c6aeaf56SThierry Reding if (!dc->client.group) { 15549f82191SThierry Reding /* 15649f82191SThierry Reding * The display controller needs contiguous memory, so 15749f82191SThierry Reding * fail if the buffer is discontiguous and we fail to 15849f82191SThierry Reding * map its SG table to a single contiguous chunk of 15949f82191SThierry Reding * I/O virtual memory. 16049f82191SThierry Reding */ 161c6aeaf56SThierry Reding if (map->chunks > 1) { 16249f82191SThierry Reding err = -EINVAL; 16349f82191SThierry Reding goto unpin; 16449f82191SThierry Reding } 16549f82191SThierry Reding 166c6aeaf56SThierry Reding state->iova[i] = map->phys; 1672e8d8749SThierry Reding } else { 168c6aeaf56SThierry Reding state->iova[i] = bo->iova; 1692e8d8749SThierry Reding } 170c6aeaf56SThierry Reding 171c6aeaf56SThierry Reding state->map[i] = map; 1722e8d8749SThierry Reding } 1732e8d8749SThierry Reding 1742e8d8749SThierry Reding return 0; 1752e8d8749SThierry Reding 1762e8d8749SThierry Reding unpin: 1772e8d8749SThierry Reding dev_err(dc->dev, "failed to map plane %u: %d\n", i, err); 1782e8d8749SThierry Reding 1792e8d8749SThierry Reding while (i--) { 180c6aeaf56SThierry Reding host1x_bo_unpin(state->map[i]); 1812e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 182c6aeaf56SThierry Reding state->map[i] = NULL; 1832e8d8749SThierry Reding } 1842e8d8749SThierry Reding 1852e8d8749SThierry Reding return err; 1862e8d8749SThierry Reding } 1872e8d8749SThierry Reding 1882e8d8749SThierry Reding static void tegra_dc_unpin(struct tegra_dc *dc, struct tegra_plane_state *state) 1892e8d8749SThierry Reding { 1902e8d8749SThierry Reding unsigned int i; 1912e8d8749SThierry Reding 1922e8d8749SThierry Reding for (i = 0; i < state->base.fb->format->num_planes; i++) { 193c6aeaf56SThierry Reding host1x_bo_unpin(state->map[i]); 1942e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 195c6aeaf56SThierry Reding state->map[i] = NULL; 1962e8d8749SThierry Reding } 1972e8d8749SThierry Reding } 1982e8d8749SThierry Reding 1992e8d8749SThierry Reding int tegra_plane_prepare_fb(struct drm_plane *plane, 2002e8d8749SThierry Reding struct drm_plane_state *state) 2012e8d8749SThierry Reding { 2022e8d8749SThierry Reding struct tegra_dc *dc = to_tegra_dc(state->crtc); 203ee423808SThierry Reding int err; 2042e8d8749SThierry Reding 2052e8d8749SThierry Reding if (!state->fb) 2062e8d8749SThierry Reding return 0; 2072e8d8749SThierry Reding 208ee423808SThierry Reding err = drm_gem_plane_helper_prepare_fb(plane, state); 209ee423808SThierry Reding if (err < 0) 210ee423808SThierry Reding return err; 2112e8d8749SThierry Reding 2122e8d8749SThierry Reding return tegra_dc_pin(dc, to_tegra_plane_state(state)); 2132e8d8749SThierry Reding } 2142e8d8749SThierry Reding 2152e8d8749SThierry Reding void tegra_plane_cleanup_fb(struct drm_plane *plane, 2162e8d8749SThierry Reding struct drm_plane_state *state) 2172e8d8749SThierry Reding { 2182e8d8749SThierry Reding struct tegra_dc *dc = to_tegra_dc(state->crtc); 2192e8d8749SThierry Reding 2202e8d8749SThierry Reding if (dc) 2212e8d8749SThierry Reding tegra_dc_unpin(dc, to_tegra_plane_state(state)); 2222e8d8749SThierry Reding } 2232e8d8749SThierry Reding 22404d5d5dfSDmitry Osipenko static int tegra_plane_calculate_memory_bandwidth(struct drm_plane_state *state) 22504d5d5dfSDmitry Osipenko { 22604d5d5dfSDmitry Osipenko struct tegra_plane_state *tegra_state = to_tegra_plane_state(state); 22704d5d5dfSDmitry Osipenko unsigned int i, bpp, dst_w, dst_h, src_w, src_h, mul; 22804d5d5dfSDmitry Osipenko const struct tegra_dc_soc_info *soc; 22904d5d5dfSDmitry Osipenko const struct drm_format_info *fmt; 23004d5d5dfSDmitry Osipenko struct drm_crtc_state *crtc_state; 23104d5d5dfSDmitry Osipenko u64 avg_bandwidth, peak_bandwidth; 23204d5d5dfSDmitry Osipenko 23304d5d5dfSDmitry Osipenko if (!state->visible) 23404d5d5dfSDmitry Osipenko return 0; 23504d5d5dfSDmitry Osipenko 23604d5d5dfSDmitry Osipenko crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc); 23704d5d5dfSDmitry Osipenko if (!crtc_state) 23804d5d5dfSDmitry Osipenko return -EINVAL; 23904d5d5dfSDmitry Osipenko 24004d5d5dfSDmitry Osipenko src_w = drm_rect_width(&state->src) >> 16; 24104d5d5dfSDmitry Osipenko src_h = drm_rect_height(&state->src) >> 16; 24204d5d5dfSDmitry Osipenko dst_w = drm_rect_width(&state->dst); 24304d5d5dfSDmitry Osipenko dst_h = drm_rect_height(&state->dst); 24404d5d5dfSDmitry Osipenko 24504d5d5dfSDmitry Osipenko fmt = state->fb->format; 24604d5d5dfSDmitry Osipenko soc = to_tegra_dc(state->crtc)->soc; 24704d5d5dfSDmitry Osipenko 24804d5d5dfSDmitry Osipenko /* 24904d5d5dfSDmitry Osipenko * Note that real memory bandwidth vary depending on format and 25004d5d5dfSDmitry Osipenko * memory layout, we are not taking that into account because small 25104d5d5dfSDmitry Osipenko * estimation error isn't important since bandwidth is rounded up 25204d5d5dfSDmitry Osipenko * anyway. 25304d5d5dfSDmitry Osipenko */ 25404d5d5dfSDmitry Osipenko for (i = 0, bpp = 0; i < fmt->num_planes; i++) { 25504d5d5dfSDmitry Osipenko unsigned int bpp_plane = fmt->cpp[i] * 8; 25604d5d5dfSDmitry Osipenko 25704d5d5dfSDmitry Osipenko /* 25804d5d5dfSDmitry Osipenko * Sub-sampling is relevant for chroma planes only and vertical 25904d5d5dfSDmitry Osipenko * readouts are not cached, hence only horizontal sub-sampling 26004d5d5dfSDmitry Osipenko * matters. 26104d5d5dfSDmitry Osipenko */ 26204d5d5dfSDmitry Osipenko if (i > 0) 26304d5d5dfSDmitry Osipenko bpp_plane /= fmt->hsub; 26404d5d5dfSDmitry Osipenko 26504d5d5dfSDmitry Osipenko bpp += bpp_plane; 26604d5d5dfSDmitry Osipenko } 26704d5d5dfSDmitry Osipenko 26804d5d5dfSDmitry Osipenko /* average bandwidth in kbytes/sec */ 26904d5d5dfSDmitry Osipenko avg_bandwidth = min(src_w, dst_w) * min(src_h, dst_h); 27004d5d5dfSDmitry Osipenko avg_bandwidth *= drm_mode_vrefresh(&crtc_state->adjusted_mode); 27104d5d5dfSDmitry Osipenko avg_bandwidth = DIV_ROUND_UP(avg_bandwidth * bpp, 8) + 999; 27204d5d5dfSDmitry Osipenko do_div(avg_bandwidth, 1000); 27304d5d5dfSDmitry Osipenko 27404d5d5dfSDmitry Osipenko /* mode.clock in kHz, peak bandwidth in kbytes/sec */ 27504d5d5dfSDmitry Osipenko peak_bandwidth = DIV_ROUND_UP(crtc_state->adjusted_mode.clock * bpp, 8); 27604d5d5dfSDmitry Osipenko 27704d5d5dfSDmitry Osipenko /* 27804d5d5dfSDmitry Osipenko * Tegra30/114 Memory Controller can't interleave DC memory requests 27904d5d5dfSDmitry Osipenko * for the tiled windows because DC uses 16-bytes atom, while DDR3 28004d5d5dfSDmitry Osipenko * uses 32-bytes atom. Hence there is x2 memory overfetch for tiled 28104d5d5dfSDmitry Osipenko * framebuffer and DDR3 on these SoCs. 28204d5d5dfSDmitry Osipenko */ 28304d5d5dfSDmitry Osipenko if (soc->plane_tiled_memory_bandwidth_x2 && 28404d5d5dfSDmitry Osipenko tegra_state->tiling.mode == TEGRA_BO_TILING_MODE_TILED) 28504d5d5dfSDmitry Osipenko mul = 2; 28604d5d5dfSDmitry Osipenko else 28704d5d5dfSDmitry Osipenko mul = 1; 28804d5d5dfSDmitry Osipenko 28904d5d5dfSDmitry Osipenko /* ICC bandwidth in kbytes/sec */ 29004d5d5dfSDmitry Osipenko tegra_state->peak_memory_bandwidth = kBps_to_icc(peak_bandwidth) * mul; 29104d5d5dfSDmitry Osipenko tegra_state->avg_memory_bandwidth = kBps_to_icc(avg_bandwidth) * mul; 29204d5d5dfSDmitry Osipenko 29304d5d5dfSDmitry Osipenko return 0; 29404d5d5dfSDmitry Osipenko } 29504d5d5dfSDmitry Osipenko 2965acd3514SThierry Reding int tegra_plane_state_add(struct tegra_plane *plane, 2975acd3514SThierry Reding struct drm_plane_state *state) 2985acd3514SThierry Reding { 2995acd3514SThierry Reding struct drm_crtc_state *crtc_state; 3005acd3514SThierry Reding struct tegra_dc_state *tegra; 3015acd3514SThierry Reding int err; 3025acd3514SThierry Reding 3035acd3514SThierry Reding /* Propagate errors from allocation or locking failures. */ 3045acd3514SThierry Reding crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); 3055acd3514SThierry Reding if (IS_ERR(crtc_state)) 3065acd3514SThierry Reding return PTR_ERR(crtc_state); 3075acd3514SThierry Reding 3085acd3514SThierry Reding /* Check plane state for visibility and calculate clipping bounds */ 30981af63a4SVille Syrjälä err = drm_atomic_helper_check_plane_state(state, crtc_state, 3105acd3514SThierry Reding 0, INT_MAX, true, true); 3115acd3514SThierry Reding if (err < 0) 3125acd3514SThierry Reding return err; 3135acd3514SThierry Reding 31404d5d5dfSDmitry Osipenko err = tegra_plane_calculate_memory_bandwidth(state); 31504d5d5dfSDmitry Osipenko if (err < 0) 31604d5d5dfSDmitry Osipenko return err; 31704d5d5dfSDmitry Osipenko 3185acd3514SThierry Reding tegra = to_dc_state(crtc_state); 3195acd3514SThierry Reding 3205acd3514SThierry Reding tegra->planes |= WIN_A_ACT_REQ << plane->index; 3215acd3514SThierry Reding 3225acd3514SThierry Reding return 0; 3235acd3514SThierry Reding } 3245acd3514SThierry Reding 3255acd3514SThierry Reding int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap) 3265acd3514SThierry Reding { 3275acd3514SThierry Reding /* assume no swapping of fetched data */ 3285acd3514SThierry Reding if (swap) 3295acd3514SThierry Reding *swap = BYTE_SWAP_NOSWAP; 3305acd3514SThierry Reding 3315acd3514SThierry Reding switch (fourcc) { 332511c7023SThierry Reding case DRM_FORMAT_ARGB4444: 333511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B4G4R4A4; 3347772fdaeSThierry Reding break; 3357772fdaeSThierry Reding 336511c7023SThierry Reding case DRM_FORMAT_ARGB1555: 337511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G5R5A1; 3385acd3514SThierry Reding break; 3395acd3514SThierry Reding 340511c7023SThierry Reding case DRM_FORMAT_RGB565: 341511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G6R5; 342511c7023SThierry Reding break; 343511c7023SThierry Reding 344511c7023SThierry Reding case DRM_FORMAT_RGBA5551: 345511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A1B5G5R5; 3467772fdaeSThierry Reding break; 3477772fdaeSThierry Reding 3487772fdaeSThierry Reding case DRM_FORMAT_ARGB8888: 3495acd3514SThierry Reding *format = WIN_COLOR_DEPTH_B8G8R8A8; 3505acd3514SThierry Reding break; 3515acd3514SThierry Reding 352511c7023SThierry Reding case DRM_FORMAT_ABGR8888: 353511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R8G8B8A8; 354511c7023SThierry Reding break; 355511c7023SThierry Reding 356511c7023SThierry Reding case DRM_FORMAT_ABGR4444: 357511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R4G4B4A4; 358511c7023SThierry Reding break; 359511c7023SThierry Reding 360511c7023SThierry Reding case DRM_FORMAT_ABGR1555: 361511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G5B5A; 362511c7023SThierry Reding break; 363511c7023SThierry Reding 364511c7023SThierry Reding case DRM_FORMAT_BGRA5551: 365511c7023SThierry Reding *format = WIN_COLOR_DEPTH_AR5G5B5; 366511c7023SThierry Reding break; 367511c7023SThierry Reding 368511c7023SThierry Reding case DRM_FORMAT_XRGB1555: 369511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G5R5X1; 370511c7023SThierry Reding break; 371511c7023SThierry Reding 372511c7023SThierry Reding case DRM_FORMAT_RGBX5551: 373511c7023SThierry Reding *format = WIN_COLOR_DEPTH_X1B5G5R5; 374511c7023SThierry Reding break; 375511c7023SThierry Reding 376511c7023SThierry Reding case DRM_FORMAT_XBGR1555: 377511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G5B5X1; 378511c7023SThierry Reding break; 379511c7023SThierry Reding 380511c7023SThierry Reding case DRM_FORMAT_BGRX5551: 381511c7023SThierry Reding *format = WIN_COLOR_DEPTH_X1R5G5B5; 382511c7023SThierry Reding break; 383511c7023SThierry Reding 384511c7023SThierry Reding case DRM_FORMAT_BGR565: 385511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G6B5; 386511c7023SThierry Reding break; 387511c7023SThierry Reding 388511c7023SThierry Reding case DRM_FORMAT_BGRA8888: 389511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A8R8G8B8; 390511c7023SThierry Reding break; 391511c7023SThierry Reding 392511c7023SThierry Reding case DRM_FORMAT_RGBA8888: 393511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A8B8G8R8; 394511c7023SThierry Reding break; 395511c7023SThierry Reding 396511c7023SThierry Reding case DRM_FORMAT_XRGB8888: 397511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B8G8R8X8; 398511c7023SThierry Reding break; 399511c7023SThierry Reding 400511c7023SThierry Reding case DRM_FORMAT_XBGR8888: 401511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R8G8B8X8; 4025acd3514SThierry Reding break; 4035acd3514SThierry Reding 4045acd3514SThierry Reding case DRM_FORMAT_UYVY: 4055acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 4065acd3514SThierry Reding break; 4075acd3514SThierry Reding 4085acd3514SThierry Reding case DRM_FORMAT_YUYV: 4095acd3514SThierry Reding if (!swap) 4105acd3514SThierry Reding return -EINVAL; 4115acd3514SThierry Reding 4125acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 4135acd3514SThierry Reding *swap = BYTE_SWAP_SWAP2; 4145acd3514SThierry Reding break; 4155acd3514SThierry Reding 4165acd3514SThierry Reding case DRM_FORMAT_YUV420: 4175acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr420P; 4185acd3514SThierry Reding break; 4195acd3514SThierry Reding 4205acd3514SThierry Reding case DRM_FORMAT_YUV422: 4215acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422P; 4225acd3514SThierry Reding break; 4235acd3514SThierry Reding 424*a649b133SThierry Reding case DRM_FORMAT_NV12: 425*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr420SP; 426*a649b133SThierry Reding break; 427*a649b133SThierry Reding 428*a649b133SThierry Reding case DRM_FORMAT_NV21: 429*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb420SP; 430*a649b133SThierry Reding break; 431*a649b133SThierry Reding 432*a649b133SThierry Reding case DRM_FORMAT_NV16: 433*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422SP; 434*a649b133SThierry Reding break; 435*a649b133SThierry Reding 436*a649b133SThierry Reding case DRM_FORMAT_NV61: 437*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb422SP; 438*a649b133SThierry Reding break; 439*a649b133SThierry Reding 440*a649b133SThierry Reding case DRM_FORMAT_NV24: 441*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr444SP; 442*a649b133SThierry Reding break; 443*a649b133SThierry Reding 444*a649b133SThierry Reding case DRM_FORMAT_NV42: 445*a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb444SP; 446*a649b133SThierry Reding break; 447*a649b133SThierry Reding 4485acd3514SThierry Reding default: 4495acd3514SThierry Reding return -EINVAL; 4505acd3514SThierry Reding } 4515acd3514SThierry Reding 4525acd3514SThierry Reding return 0; 4535acd3514SThierry Reding } 4545acd3514SThierry Reding 455e16efff4SThierry Reding bool tegra_plane_format_is_indexed(unsigned int format) 456e16efff4SThierry Reding { 457e16efff4SThierry Reding switch (format) { 458e16efff4SThierry Reding case WIN_COLOR_DEPTH_P1: 459e16efff4SThierry Reding case WIN_COLOR_DEPTH_P2: 460e16efff4SThierry Reding case WIN_COLOR_DEPTH_P4: 461e16efff4SThierry Reding case WIN_COLOR_DEPTH_P8: 462e16efff4SThierry Reding return true; 463e16efff4SThierry Reding } 464e16efff4SThierry Reding 465e16efff4SThierry Reding return false; 466e16efff4SThierry Reding } 467e16efff4SThierry Reding 468*a649b133SThierry Reding bool tegra_plane_format_is_yuv(unsigned int format, unsigned int *planes, unsigned int *bpc) 4695acd3514SThierry Reding { 4705acd3514SThierry Reding switch (format) { 4715acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422: 4725acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422: 473*a649b133SThierry Reding if (planes) 474*a649b133SThierry Reding *planes = 1; 4755acd3514SThierry Reding 476e16efff4SThierry Reding if (bpc) 477e16efff4SThierry Reding *bpc = 8; 478e16efff4SThierry Reding 4795acd3514SThierry Reding return true; 4805acd3514SThierry Reding 4815acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr420P: 4825acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV420P: 4835acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422P: 4845acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422P: 4855acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422R: 4865acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422R: 4875acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422RA: 4885acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422RA: 489*a649b133SThierry Reding if (planes) 490*a649b133SThierry Reding *planes = 3; 491*a649b133SThierry Reding 492*a649b133SThierry Reding if (bpc) 493*a649b133SThierry Reding *bpc = 8; 494*a649b133SThierry Reding 495*a649b133SThierry Reding return true; 496*a649b133SThierry Reding 497*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb420SP: 498*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr420SP: 499*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb422SP: 500*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr422SP: 501*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb444SP: 502*a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr444SP: 503*a649b133SThierry Reding if (planes) 504*a649b133SThierry Reding *planes = 2; 5055acd3514SThierry Reding 506e16efff4SThierry Reding if (bpc) 507e16efff4SThierry Reding *bpc = 8; 508e16efff4SThierry Reding 5095acd3514SThierry Reding return true; 5105acd3514SThierry Reding } 5115acd3514SThierry Reding 512*a649b133SThierry Reding if (planes) 513*a649b133SThierry Reding *planes = 1; 5145acd3514SThierry Reding 5155acd3514SThierry Reding return false; 5165acd3514SThierry Reding } 517ebae8d07SThierry Reding 518ebae8d07SThierry Reding static bool __drm_format_has_alpha(u32 format) 519ebae8d07SThierry Reding { 520ebae8d07SThierry Reding switch (format) { 521ebae8d07SThierry Reding case DRM_FORMAT_ARGB1555: 522ebae8d07SThierry Reding case DRM_FORMAT_RGBA5551: 523ebae8d07SThierry Reding case DRM_FORMAT_ABGR8888: 524ebae8d07SThierry Reding case DRM_FORMAT_ARGB8888: 525ebae8d07SThierry Reding return true; 526ebae8d07SThierry Reding } 527ebae8d07SThierry Reding 528ebae8d07SThierry Reding return false; 529ebae8d07SThierry Reding } 530ebae8d07SThierry Reding 5313dae08bcSDmitry Osipenko static int tegra_plane_format_get_alpha(unsigned int opaque, 5323dae08bcSDmitry Osipenko unsigned int *alpha) 533ebae8d07SThierry Reding { 534e16efff4SThierry Reding if (tegra_plane_format_is_yuv(opaque, NULL, NULL)) { 5355467a8b8SThierry Reding *alpha = opaque; 5365467a8b8SThierry Reding return 0; 5375467a8b8SThierry Reding } 5385467a8b8SThierry Reding 539ebae8d07SThierry Reding switch (opaque) { 540ebae8d07SThierry Reding case WIN_COLOR_DEPTH_B5G5R5X1: 541ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_B5G5R5A1; 542ebae8d07SThierry Reding return 0; 543ebae8d07SThierry Reding 544ebae8d07SThierry Reding case WIN_COLOR_DEPTH_X1B5G5R5: 545ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_A1B5G5R5; 546ebae8d07SThierry Reding return 0; 547ebae8d07SThierry Reding 548ebae8d07SThierry Reding case WIN_COLOR_DEPTH_R8G8B8X8: 549ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_R8G8B8A8; 550ebae8d07SThierry Reding return 0; 551ebae8d07SThierry Reding 552ebae8d07SThierry Reding case WIN_COLOR_DEPTH_B8G8R8X8: 553ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_B8G8R8A8; 554ebae8d07SThierry Reding return 0; 5558a927d64SThierry Reding 5568a927d64SThierry Reding case WIN_COLOR_DEPTH_B5G6R5: 5578a927d64SThierry Reding *alpha = opaque; 5588a927d64SThierry Reding return 0; 559ebae8d07SThierry Reding } 560ebae8d07SThierry Reding 561ebae8d07SThierry Reding return -EINVAL; 562ebae8d07SThierry Reding } 563ebae8d07SThierry Reding 5643dae08bcSDmitry Osipenko /* 5653dae08bcSDmitry Osipenko * This is applicable to Tegra20 and Tegra30 only where the opaque formats can 5663dae08bcSDmitry Osipenko * be emulated using the alpha formats and alpha blending disabled. 5673dae08bcSDmitry Osipenko */ 5683dae08bcSDmitry Osipenko static int tegra_plane_setup_opacity(struct tegra_plane *tegra, 5693dae08bcSDmitry Osipenko struct tegra_plane_state *state) 5703dae08bcSDmitry Osipenko { 5713dae08bcSDmitry Osipenko unsigned int format; 5723dae08bcSDmitry Osipenko int err; 5733dae08bcSDmitry Osipenko 5743dae08bcSDmitry Osipenko switch (state->format) { 5753dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_B5G5R5A1: 5763dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_A1B5G5R5: 5773dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_R8G8B8A8: 5783dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_B8G8R8A8: 5793dae08bcSDmitry Osipenko state->opaque = false; 5803dae08bcSDmitry Osipenko break; 5813dae08bcSDmitry Osipenko 5823dae08bcSDmitry Osipenko default: 5833dae08bcSDmitry Osipenko err = tegra_plane_format_get_alpha(state->format, &format); 5843dae08bcSDmitry Osipenko if (err < 0) 5853dae08bcSDmitry Osipenko return err; 5863dae08bcSDmitry Osipenko 5873dae08bcSDmitry Osipenko state->format = format; 5883dae08bcSDmitry Osipenko state->opaque = true; 5893dae08bcSDmitry Osipenko break; 5903dae08bcSDmitry Osipenko } 5913dae08bcSDmitry Osipenko 5923dae08bcSDmitry Osipenko return 0; 5933dae08bcSDmitry Osipenko } 5943dae08bcSDmitry Osipenko 5953dae08bcSDmitry Osipenko static int tegra_plane_check_transparency(struct tegra_plane *tegra, 5963dae08bcSDmitry Osipenko struct tegra_plane_state *state) 5973dae08bcSDmitry Osipenko { 5983dae08bcSDmitry Osipenko struct drm_plane_state *old, *plane_state; 5993dae08bcSDmitry Osipenko struct drm_plane *plane; 6003dae08bcSDmitry Osipenko 6013dae08bcSDmitry Osipenko old = drm_atomic_get_old_plane_state(state->base.state, &tegra->base); 6023dae08bcSDmitry Osipenko 6033dae08bcSDmitry Osipenko /* check if zpos / transparency changed */ 6043dae08bcSDmitry Osipenko if (old->normalized_zpos == state->base.normalized_zpos && 6053dae08bcSDmitry Osipenko to_tegra_plane_state(old)->opaque == state->opaque) 6063dae08bcSDmitry Osipenko return 0; 6073dae08bcSDmitry Osipenko 6083dae08bcSDmitry Osipenko /* include all sibling planes into this commit */ 6093dae08bcSDmitry Osipenko drm_for_each_plane(plane, tegra->base.dev) { 6103dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 6113dae08bcSDmitry Osipenko 6123dae08bcSDmitry Osipenko /* skip this plane and planes on different CRTCs */ 6133dae08bcSDmitry Osipenko if (p == tegra || p->dc != tegra->dc) 6143dae08bcSDmitry Osipenko continue; 6153dae08bcSDmitry Osipenko 6163dae08bcSDmitry Osipenko plane_state = drm_atomic_get_plane_state(state->base.state, 6173dae08bcSDmitry Osipenko plane); 6183dae08bcSDmitry Osipenko if (IS_ERR(plane_state)) 6193dae08bcSDmitry Osipenko return PTR_ERR(plane_state); 6203dae08bcSDmitry Osipenko } 6213dae08bcSDmitry Osipenko 6223dae08bcSDmitry Osipenko return 1; 6233dae08bcSDmitry Osipenko } 6243dae08bcSDmitry Osipenko 6255e2e86f1SDmitry Osipenko static unsigned int tegra_plane_get_overlap_index(struct tegra_plane *plane, 626ebae8d07SThierry Reding struct tegra_plane *other) 627ebae8d07SThierry Reding { 628ebae8d07SThierry Reding unsigned int index = 0, i; 629ebae8d07SThierry Reding 630ebae8d07SThierry Reding WARN_ON(plane == other); 631ebae8d07SThierry Reding 632ebae8d07SThierry Reding for (i = 0; i < 3; i++) { 633ebae8d07SThierry Reding if (i == plane->index) 634ebae8d07SThierry Reding continue; 635ebae8d07SThierry Reding 636ebae8d07SThierry Reding if (i == other->index) 637ebae8d07SThierry Reding break; 638ebae8d07SThierry Reding 639ebae8d07SThierry Reding index++; 640ebae8d07SThierry Reding } 641ebae8d07SThierry Reding 642ebae8d07SThierry Reding return index; 643ebae8d07SThierry Reding } 644ebae8d07SThierry Reding 6453dae08bcSDmitry Osipenko static void tegra_plane_update_transparency(struct tegra_plane *tegra, 646ebae8d07SThierry Reding struct tegra_plane_state *state) 647ebae8d07SThierry Reding { 6483dae08bcSDmitry Osipenko struct drm_plane_state *new; 649ebae8d07SThierry Reding struct drm_plane *plane; 650ebae8d07SThierry Reding unsigned int i; 651ebae8d07SThierry Reding 6523dae08bcSDmitry Osipenko for_each_new_plane_in_state(state->base.state, plane, new, i) { 653ebae8d07SThierry Reding struct tegra_plane *p = to_tegra_plane(plane); 654ebae8d07SThierry Reding unsigned index; 655ebae8d07SThierry Reding 656ebae8d07SThierry Reding /* skip this plane and planes on different CRTCs */ 6573dae08bcSDmitry Osipenko if (p == tegra || p->dc != tegra->dc) 658ebae8d07SThierry Reding continue; 659ebae8d07SThierry Reding 660ebae8d07SThierry Reding index = tegra_plane_get_overlap_index(tegra, p); 661ebae8d07SThierry Reding 6623dae08bcSDmitry Osipenko if (new->fb && __drm_format_has_alpha(new->fb->format->format)) 6633dae08bcSDmitry Osipenko state->blending[index].alpha = true; 6643dae08bcSDmitry Osipenko else 6653dae08bcSDmitry Osipenko state->blending[index].alpha = false; 6663dae08bcSDmitry Osipenko 6673dae08bcSDmitry Osipenko if (new->normalized_zpos > state->base.normalized_zpos) 6683dae08bcSDmitry Osipenko state->blending[index].top = true; 6693dae08bcSDmitry Osipenko else 6703dae08bcSDmitry Osipenko state->blending[index].top = false; 67148519232SDmitry Osipenko 672ebae8d07SThierry Reding /* 6733dae08bcSDmitry Osipenko * Missing framebuffer means that plane is disabled, in this 6743dae08bcSDmitry Osipenko * case mark B / C window as top to be able to differentiate 6753dae08bcSDmitry Osipenko * windows indices order in regards to zPos for the middle 6763dae08bcSDmitry Osipenko * window X / Y registers programming. 677ebae8d07SThierry Reding */ 6783dae08bcSDmitry Osipenko if (!new->fb) 6793dae08bcSDmitry Osipenko state->blending[index].top = (index == 1); 680ebae8d07SThierry Reding } 681ebae8d07SThierry Reding } 682ebae8d07SThierry Reding 6833dae08bcSDmitry Osipenko static int tegra_plane_setup_transparency(struct tegra_plane *tegra, 6843dae08bcSDmitry Osipenko struct tegra_plane_state *state) 6853dae08bcSDmitry Osipenko { 6863dae08bcSDmitry Osipenko struct tegra_plane_state *tegra_state; 6873dae08bcSDmitry Osipenko struct drm_plane_state *new; 6883dae08bcSDmitry Osipenko struct drm_plane *plane; 6893dae08bcSDmitry Osipenko int err; 690ebae8d07SThierry Reding 691ebae8d07SThierry Reding /* 6923dae08bcSDmitry Osipenko * If planes zpos / transparency changed, sibling planes blending 6933dae08bcSDmitry Osipenko * state may require adjustment and in this case they will be included 6943dae08bcSDmitry Osipenko * into this atom commit, otherwise blending state is unchanged. 695ebae8d07SThierry Reding */ 6963dae08bcSDmitry Osipenko err = tegra_plane_check_transparency(tegra, state); 6973dae08bcSDmitry Osipenko if (err <= 0) 6983dae08bcSDmitry Osipenko return err; 6993dae08bcSDmitry Osipenko 7003dae08bcSDmitry Osipenko /* 7013dae08bcSDmitry Osipenko * All planes are now in the atomic state, walk them up and update 7023dae08bcSDmitry Osipenko * transparency state for each plane. 7033dae08bcSDmitry Osipenko */ 7043dae08bcSDmitry Osipenko drm_for_each_plane(plane, tegra->base.dev) { 7053dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 7063dae08bcSDmitry Osipenko 7073dae08bcSDmitry Osipenko /* skip planes on different CRTCs */ 7083dae08bcSDmitry Osipenko if (p->dc != tegra->dc) 7093dae08bcSDmitry Osipenko continue; 7103dae08bcSDmitry Osipenko 7113dae08bcSDmitry Osipenko new = drm_atomic_get_new_plane_state(state->base.state, plane); 7123dae08bcSDmitry Osipenko tegra_state = to_tegra_plane_state(new); 7133dae08bcSDmitry Osipenko 7143dae08bcSDmitry Osipenko /* 7153dae08bcSDmitry Osipenko * There is no need to update blending state for the disabled 7163dae08bcSDmitry Osipenko * plane. 7173dae08bcSDmitry Osipenko */ 7183dae08bcSDmitry Osipenko if (new->fb) 7193dae08bcSDmitry Osipenko tegra_plane_update_transparency(p, tegra_state); 720ebae8d07SThierry Reding } 7213dae08bcSDmitry Osipenko 7223dae08bcSDmitry Osipenko return 0; 7233dae08bcSDmitry Osipenko } 7243dae08bcSDmitry Osipenko 7253dae08bcSDmitry Osipenko int tegra_plane_setup_legacy_state(struct tegra_plane *tegra, 7263dae08bcSDmitry Osipenko struct tegra_plane_state *state) 7273dae08bcSDmitry Osipenko { 7283dae08bcSDmitry Osipenko int err; 7293dae08bcSDmitry Osipenko 7303dae08bcSDmitry Osipenko err = tegra_plane_setup_opacity(tegra, state); 7313dae08bcSDmitry Osipenko if (err < 0) 7323dae08bcSDmitry Osipenko return err; 7333dae08bcSDmitry Osipenko 7343dae08bcSDmitry Osipenko err = tegra_plane_setup_transparency(tegra, state); 7353dae08bcSDmitry Osipenko if (err < 0) 7363dae08bcSDmitry Osipenko return err; 7373dae08bcSDmitry Osipenko 7383dae08bcSDmitry Osipenko return 0; 739ebae8d07SThierry Reding } 74004d5d5dfSDmitry Osipenko 74104d5d5dfSDmitry Osipenko static const char * const tegra_plane_icc_names[TEGRA_DC_LEGACY_PLANES_NUM] = { 74204d5d5dfSDmitry Osipenko "wina", "winb", "winc", NULL, NULL, NULL, "cursor", 74304d5d5dfSDmitry Osipenko }; 74404d5d5dfSDmitry Osipenko 74504d5d5dfSDmitry Osipenko int tegra_plane_interconnect_init(struct tegra_plane *plane) 74604d5d5dfSDmitry Osipenko { 74704d5d5dfSDmitry Osipenko const char *icc_name = tegra_plane_icc_names[plane->index]; 74804d5d5dfSDmitry Osipenko struct device *dev = plane->dc->dev; 74904d5d5dfSDmitry Osipenko struct tegra_dc *dc = plane->dc; 75004d5d5dfSDmitry Osipenko int err; 75104d5d5dfSDmitry Osipenko 75204d5d5dfSDmitry Osipenko if (WARN_ON(plane->index >= TEGRA_DC_LEGACY_PLANES_NUM) || 75304d5d5dfSDmitry Osipenko WARN_ON(!tegra_plane_icc_names[plane->index])) 75404d5d5dfSDmitry Osipenko return -EINVAL; 75504d5d5dfSDmitry Osipenko 75604d5d5dfSDmitry Osipenko plane->icc_mem = devm_of_icc_get(dev, icc_name); 75704d5d5dfSDmitry Osipenko err = PTR_ERR_OR_ZERO(plane->icc_mem); 75804d5d5dfSDmitry Osipenko if (err) { 75904d5d5dfSDmitry Osipenko dev_err_probe(dev, err, "failed to get %s interconnect\n", 76004d5d5dfSDmitry Osipenko icc_name); 76104d5d5dfSDmitry Osipenko return err; 76204d5d5dfSDmitry Osipenko } 76304d5d5dfSDmitry Osipenko 76404d5d5dfSDmitry Osipenko /* plane B on T20/30 has a dedicated memory client for a 6-tap vertical filter */ 76504d5d5dfSDmitry Osipenko if (plane->index == 1 && dc->soc->has_win_b_vfilter_mem_client) { 76604d5d5dfSDmitry Osipenko plane->icc_mem_vfilter = devm_of_icc_get(dev, "winb-vfilter"); 76704d5d5dfSDmitry Osipenko err = PTR_ERR_OR_ZERO(plane->icc_mem_vfilter); 76804d5d5dfSDmitry Osipenko if (err) { 76904d5d5dfSDmitry Osipenko dev_err_probe(dev, err, "failed to get %s interconnect\n", 77004d5d5dfSDmitry Osipenko "winb-vfilter"); 77104d5d5dfSDmitry Osipenko return err; 77204d5d5dfSDmitry Osipenko } 77304d5d5dfSDmitry Osipenko } 77404d5d5dfSDmitry Osipenko 77504d5d5dfSDmitry Osipenko return 0; 77604d5d5dfSDmitry Osipenko } 777