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> 12*720cf96dSVille Syrjälä #include <drm/drm_framebuffer.h> 13820c1707SThomas Zimmermann #include <drm/drm_gem_atomic_helper.h> 145acd3514SThierry Reding #include <drm/drm_plane_helper.h> 155acd3514SThierry Reding 165acd3514SThierry Reding #include "dc.h" 175acd3514SThierry Reding #include "plane.h" 185acd3514SThierry Reding 195acd3514SThierry Reding static void tegra_plane_destroy(struct drm_plane *plane) 205acd3514SThierry Reding { 215acd3514SThierry Reding struct tegra_plane *p = to_tegra_plane(plane); 225acd3514SThierry Reding 235acd3514SThierry Reding drm_plane_cleanup(plane); 245acd3514SThierry Reding kfree(p); 255acd3514SThierry Reding } 265acd3514SThierry Reding 275acd3514SThierry Reding static void tegra_plane_reset(struct drm_plane *plane) 285acd3514SThierry Reding { 293dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 305acd3514SThierry Reding struct tegra_plane_state *state; 312e8d8749SThierry Reding unsigned int i; 325acd3514SThierry Reding 335acd3514SThierry Reding if (plane->state) 345acd3514SThierry Reding __drm_atomic_helper_plane_destroy_state(plane->state); 355acd3514SThierry Reding 365acd3514SThierry Reding kfree(plane->state); 375acd3514SThierry Reding plane->state = NULL; 385acd3514SThierry Reding 395acd3514SThierry Reding state = kzalloc(sizeof(*state), GFP_KERNEL); 405acd3514SThierry Reding if (state) { 415acd3514SThierry Reding plane->state = &state->base; 425acd3514SThierry Reding plane->state->plane = plane; 433dae08bcSDmitry Osipenko plane->state->zpos = p->index; 443dae08bcSDmitry Osipenko plane->state->normalized_zpos = p->index; 452e8d8749SThierry Reding 462e8d8749SThierry Reding for (i = 0; i < 3; i++) 472e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 485acd3514SThierry Reding } 495acd3514SThierry Reding } 505acd3514SThierry Reding 515acd3514SThierry Reding static struct drm_plane_state * 525acd3514SThierry Reding tegra_plane_atomic_duplicate_state(struct drm_plane *plane) 535acd3514SThierry Reding { 545acd3514SThierry Reding struct tegra_plane_state *state = to_tegra_plane_state(plane->state); 555acd3514SThierry Reding struct tegra_plane_state *copy; 56ebae8d07SThierry Reding unsigned int i; 575acd3514SThierry Reding 585acd3514SThierry Reding copy = kmalloc(sizeof(*copy), GFP_KERNEL); 595acd3514SThierry Reding if (!copy) 605acd3514SThierry Reding return NULL; 615acd3514SThierry Reding 625acd3514SThierry Reding __drm_atomic_helper_plane_duplicate_state(plane, ©->base); 635acd3514SThierry Reding copy->tiling = state->tiling; 645acd3514SThierry Reding copy->format = state->format; 655acd3514SThierry Reding copy->swap = state->swap; 66cd740777SDmitry Osipenko copy->reflect_x = state->reflect_x; 67e9e476f7SDmitry Osipenko copy->reflect_y = state->reflect_y; 68ebae8d07SThierry Reding copy->opaque = state->opaque; 6904d5d5dfSDmitry Osipenko copy->total_peak_memory_bandwidth = state->total_peak_memory_bandwidth; 7004d5d5dfSDmitry Osipenko copy->peak_memory_bandwidth = state->peak_memory_bandwidth; 7104d5d5dfSDmitry Osipenko copy->avg_memory_bandwidth = state->avg_memory_bandwidth; 72ebae8d07SThierry Reding 733dae08bcSDmitry Osipenko for (i = 0; i < 2; i++) 743dae08bcSDmitry Osipenko copy->blending[i] = state->blending[i]; 755acd3514SThierry Reding 762e8d8749SThierry Reding for (i = 0; i < 3; i++) { 772e8d8749SThierry Reding copy->iova[i] = DMA_MAPPING_ERROR; 78c6aeaf56SThierry Reding copy->map[i] = NULL; 792e8d8749SThierry Reding } 802e8d8749SThierry Reding 815acd3514SThierry Reding return ©->base; 825acd3514SThierry Reding } 835acd3514SThierry Reding 845acd3514SThierry Reding static void tegra_plane_atomic_destroy_state(struct drm_plane *plane, 855acd3514SThierry Reding struct drm_plane_state *state) 865acd3514SThierry Reding { 875acd3514SThierry Reding __drm_atomic_helper_plane_destroy_state(state); 885acd3514SThierry Reding kfree(state); 895acd3514SThierry Reding } 905acd3514SThierry Reding 917b6f8467SThierry Reding static bool tegra_plane_supports_sector_layout(struct drm_plane *plane) 927b6f8467SThierry Reding { 937b6f8467SThierry Reding struct drm_crtc *crtc; 947b6f8467SThierry Reding 957b6f8467SThierry Reding drm_for_each_crtc(crtc, plane->dev) { 967b6f8467SThierry Reding if (plane->possible_crtcs & drm_crtc_mask(crtc)) { 977b6f8467SThierry Reding struct tegra_dc *dc = to_tegra_dc(crtc); 987b6f8467SThierry Reding 997b6f8467SThierry Reding if (!dc->soc->supports_sector_layout) 1007b6f8467SThierry Reding return false; 1017b6f8467SThierry Reding } 1027b6f8467SThierry Reding } 1037b6f8467SThierry Reding 1047b6f8467SThierry Reding return true; 1057b6f8467SThierry Reding } 1067b6f8467SThierry Reding 107e90124cbSThierry Reding static bool tegra_plane_format_mod_supported(struct drm_plane *plane, 108e90124cbSThierry Reding uint32_t format, 109e90124cbSThierry Reding uint64_t modifier) 110e90124cbSThierry Reding { 111e90124cbSThierry Reding const struct drm_format_info *info = drm_format_info(format); 112e90124cbSThierry Reding 113e90124cbSThierry Reding if (modifier == DRM_FORMAT_MOD_LINEAR) 114e90124cbSThierry Reding return true; 115e90124cbSThierry Reding 1167b6f8467SThierry Reding /* check for the sector layout bit */ 117c1d3cfbcSThierry Reding if (fourcc_mod_is_vendor(modifier, NVIDIA)) { 1187b6f8467SThierry Reding if (modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) { 1197b6f8467SThierry Reding if (!tegra_plane_supports_sector_layout(plane)) 1207b6f8467SThierry Reding return false; 1217b6f8467SThierry Reding } 1227b6f8467SThierry Reding } 1237b6f8467SThierry Reding 124e90124cbSThierry Reding if (info->num_planes == 1) 125e90124cbSThierry Reding return true; 126e90124cbSThierry Reding 127e90124cbSThierry Reding return false; 128e90124cbSThierry Reding } 129e90124cbSThierry Reding 1305acd3514SThierry Reding const struct drm_plane_funcs tegra_plane_funcs = { 1315acd3514SThierry Reding .update_plane = drm_atomic_helper_update_plane, 1325acd3514SThierry Reding .disable_plane = drm_atomic_helper_disable_plane, 1335acd3514SThierry Reding .destroy = tegra_plane_destroy, 1345acd3514SThierry Reding .reset = tegra_plane_reset, 1355acd3514SThierry Reding .atomic_duplicate_state = tegra_plane_atomic_duplicate_state, 1365acd3514SThierry Reding .atomic_destroy_state = tegra_plane_atomic_destroy_state, 137e90124cbSThierry Reding .format_mod_supported = tegra_plane_format_mod_supported, 1385acd3514SThierry Reding }; 1395acd3514SThierry Reding 1402e8d8749SThierry Reding static int tegra_dc_pin(struct tegra_dc *dc, struct tegra_plane_state *state) 1412e8d8749SThierry Reding { 1422e8d8749SThierry Reding unsigned int i; 1432e8d8749SThierry Reding int err; 1442e8d8749SThierry Reding 1452e8d8749SThierry Reding for (i = 0; i < state->base.fb->format->num_planes; i++) { 1462e8d8749SThierry Reding struct tegra_bo *bo = tegra_fb_get_plane(state->base.fb, i); 147c6aeaf56SThierry Reding struct host1x_bo_mapping *map; 1482e8d8749SThierry Reding 1491f39b1dfSThierry Reding map = host1x_bo_pin(dc->dev, &bo->base, DMA_TO_DEVICE, &dc->client.cache); 150c6aeaf56SThierry Reding if (IS_ERR(map)) { 151c6aeaf56SThierry Reding err = PTR_ERR(map); 1522e8d8749SThierry Reding goto unpin; 1532e8d8749SThierry Reding } 1542e8d8749SThierry Reding 155c6aeaf56SThierry Reding if (!dc->client.group) { 15649f82191SThierry Reding /* 15749f82191SThierry Reding * The display controller needs contiguous memory, so 15849f82191SThierry Reding * fail if the buffer is discontiguous and we fail to 15949f82191SThierry Reding * map its SG table to a single contiguous chunk of 16049f82191SThierry Reding * I/O virtual memory. 16149f82191SThierry Reding */ 162c6aeaf56SThierry Reding if (map->chunks > 1) { 16349f82191SThierry Reding err = -EINVAL; 16449f82191SThierry Reding goto unpin; 16549f82191SThierry Reding } 16649f82191SThierry Reding 167c6aeaf56SThierry Reding state->iova[i] = map->phys; 1682e8d8749SThierry Reding } else { 169c6aeaf56SThierry Reding state->iova[i] = bo->iova; 1702e8d8749SThierry Reding } 171c6aeaf56SThierry Reding 172c6aeaf56SThierry Reding state->map[i] = map; 1732e8d8749SThierry Reding } 1742e8d8749SThierry Reding 1752e8d8749SThierry Reding return 0; 1762e8d8749SThierry Reding 1772e8d8749SThierry Reding unpin: 1782e8d8749SThierry Reding dev_err(dc->dev, "failed to map plane %u: %d\n", i, err); 1792e8d8749SThierry Reding 1802e8d8749SThierry Reding while (i--) { 181c6aeaf56SThierry Reding host1x_bo_unpin(state->map[i]); 1822e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 183c6aeaf56SThierry Reding state->map[i] = NULL; 1842e8d8749SThierry Reding } 1852e8d8749SThierry Reding 1862e8d8749SThierry Reding return err; 1872e8d8749SThierry Reding } 1882e8d8749SThierry Reding 1892e8d8749SThierry Reding static void tegra_dc_unpin(struct tegra_dc *dc, struct tegra_plane_state *state) 1902e8d8749SThierry Reding { 1912e8d8749SThierry Reding unsigned int i; 1922e8d8749SThierry Reding 1932e8d8749SThierry Reding for (i = 0; i < state->base.fb->format->num_planes; i++) { 194c6aeaf56SThierry Reding host1x_bo_unpin(state->map[i]); 1952e8d8749SThierry Reding state->iova[i] = DMA_MAPPING_ERROR; 196c6aeaf56SThierry Reding state->map[i] = NULL; 1972e8d8749SThierry Reding } 1982e8d8749SThierry Reding } 1992e8d8749SThierry Reding 2002e8d8749SThierry Reding int tegra_plane_prepare_fb(struct drm_plane *plane, 2012e8d8749SThierry Reding struct drm_plane_state *state) 2022e8d8749SThierry Reding { 2032e8d8749SThierry Reding struct tegra_dc *dc = to_tegra_dc(state->crtc); 204ee423808SThierry Reding int err; 2052e8d8749SThierry Reding 2062e8d8749SThierry Reding if (!state->fb) 2072e8d8749SThierry Reding return 0; 2082e8d8749SThierry Reding 209ee423808SThierry Reding err = drm_gem_plane_helper_prepare_fb(plane, state); 210ee423808SThierry Reding if (err < 0) 211ee423808SThierry Reding return err; 2122e8d8749SThierry Reding 2132e8d8749SThierry Reding return tegra_dc_pin(dc, to_tegra_plane_state(state)); 2142e8d8749SThierry Reding } 2152e8d8749SThierry Reding 2162e8d8749SThierry Reding void tegra_plane_cleanup_fb(struct drm_plane *plane, 2172e8d8749SThierry Reding struct drm_plane_state *state) 2182e8d8749SThierry Reding { 2192e8d8749SThierry Reding struct tegra_dc *dc = to_tegra_dc(state->crtc); 2202e8d8749SThierry Reding 2212e8d8749SThierry Reding if (dc) 2222e8d8749SThierry Reding tegra_dc_unpin(dc, to_tegra_plane_state(state)); 2232e8d8749SThierry Reding } 2242e8d8749SThierry Reding 22504d5d5dfSDmitry Osipenko static int tegra_plane_calculate_memory_bandwidth(struct drm_plane_state *state) 22604d5d5dfSDmitry Osipenko { 22704d5d5dfSDmitry Osipenko struct tegra_plane_state *tegra_state = to_tegra_plane_state(state); 22804d5d5dfSDmitry Osipenko unsigned int i, bpp, dst_w, dst_h, src_w, src_h, mul; 22904d5d5dfSDmitry Osipenko const struct tegra_dc_soc_info *soc; 23004d5d5dfSDmitry Osipenko const struct drm_format_info *fmt; 23104d5d5dfSDmitry Osipenko struct drm_crtc_state *crtc_state; 23204d5d5dfSDmitry Osipenko u64 avg_bandwidth, peak_bandwidth; 23304d5d5dfSDmitry Osipenko 23404d5d5dfSDmitry Osipenko if (!state->visible) 23504d5d5dfSDmitry Osipenko return 0; 23604d5d5dfSDmitry Osipenko 23704d5d5dfSDmitry Osipenko crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc); 23804d5d5dfSDmitry Osipenko if (!crtc_state) 23904d5d5dfSDmitry Osipenko return -EINVAL; 24004d5d5dfSDmitry Osipenko 24104d5d5dfSDmitry Osipenko src_w = drm_rect_width(&state->src) >> 16; 24204d5d5dfSDmitry Osipenko src_h = drm_rect_height(&state->src) >> 16; 24304d5d5dfSDmitry Osipenko dst_w = drm_rect_width(&state->dst); 24404d5d5dfSDmitry Osipenko dst_h = drm_rect_height(&state->dst); 24504d5d5dfSDmitry Osipenko 24604d5d5dfSDmitry Osipenko fmt = state->fb->format; 24704d5d5dfSDmitry Osipenko soc = to_tegra_dc(state->crtc)->soc; 24804d5d5dfSDmitry Osipenko 24904d5d5dfSDmitry Osipenko /* 25004d5d5dfSDmitry Osipenko * Note that real memory bandwidth vary depending on format and 25104d5d5dfSDmitry Osipenko * memory layout, we are not taking that into account because small 25204d5d5dfSDmitry Osipenko * estimation error isn't important since bandwidth is rounded up 25304d5d5dfSDmitry Osipenko * anyway. 25404d5d5dfSDmitry Osipenko */ 25504d5d5dfSDmitry Osipenko for (i = 0, bpp = 0; i < fmt->num_planes; i++) { 25604d5d5dfSDmitry Osipenko unsigned int bpp_plane = fmt->cpp[i] * 8; 25704d5d5dfSDmitry Osipenko 25804d5d5dfSDmitry Osipenko /* 25904d5d5dfSDmitry Osipenko * Sub-sampling is relevant for chroma planes only and vertical 26004d5d5dfSDmitry Osipenko * readouts are not cached, hence only horizontal sub-sampling 26104d5d5dfSDmitry Osipenko * matters. 26204d5d5dfSDmitry Osipenko */ 26304d5d5dfSDmitry Osipenko if (i > 0) 26404d5d5dfSDmitry Osipenko bpp_plane /= fmt->hsub; 26504d5d5dfSDmitry Osipenko 26604d5d5dfSDmitry Osipenko bpp += bpp_plane; 26704d5d5dfSDmitry Osipenko } 26804d5d5dfSDmitry Osipenko 26904d5d5dfSDmitry Osipenko /* average bandwidth in kbytes/sec */ 27004d5d5dfSDmitry Osipenko avg_bandwidth = min(src_w, dst_w) * min(src_h, dst_h); 27104d5d5dfSDmitry Osipenko avg_bandwidth *= drm_mode_vrefresh(&crtc_state->adjusted_mode); 27204d5d5dfSDmitry Osipenko avg_bandwidth = DIV_ROUND_UP(avg_bandwidth * bpp, 8) + 999; 27304d5d5dfSDmitry Osipenko do_div(avg_bandwidth, 1000); 27404d5d5dfSDmitry Osipenko 27504d5d5dfSDmitry Osipenko /* mode.clock in kHz, peak bandwidth in kbytes/sec */ 27604d5d5dfSDmitry Osipenko peak_bandwidth = DIV_ROUND_UP(crtc_state->adjusted_mode.clock * bpp, 8); 27704d5d5dfSDmitry Osipenko 27804d5d5dfSDmitry Osipenko /* 27904d5d5dfSDmitry Osipenko * Tegra30/114 Memory Controller can't interleave DC memory requests 28004d5d5dfSDmitry Osipenko * for the tiled windows because DC uses 16-bytes atom, while DDR3 28104d5d5dfSDmitry Osipenko * uses 32-bytes atom. Hence there is x2 memory overfetch for tiled 28204d5d5dfSDmitry Osipenko * framebuffer and DDR3 on these SoCs. 28304d5d5dfSDmitry Osipenko */ 28404d5d5dfSDmitry Osipenko if (soc->plane_tiled_memory_bandwidth_x2 && 28504d5d5dfSDmitry Osipenko tegra_state->tiling.mode == TEGRA_BO_TILING_MODE_TILED) 28604d5d5dfSDmitry Osipenko mul = 2; 28704d5d5dfSDmitry Osipenko else 28804d5d5dfSDmitry Osipenko mul = 1; 28904d5d5dfSDmitry Osipenko 29004d5d5dfSDmitry Osipenko /* ICC bandwidth in kbytes/sec */ 29104d5d5dfSDmitry Osipenko tegra_state->peak_memory_bandwidth = kBps_to_icc(peak_bandwidth) * mul; 29204d5d5dfSDmitry Osipenko tegra_state->avg_memory_bandwidth = kBps_to_icc(avg_bandwidth) * mul; 29304d5d5dfSDmitry Osipenko 29404d5d5dfSDmitry Osipenko return 0; 29504d5d5dfSDmitry Osipenko } 29604d5d5dfSDmitry Osipenko 2975acd3514SThierry Reding int tegra_plane_state_add(struct tegra_plane *plane, 2985acd3514SThierry Reding struct drm_plane_state *state) 2995acd3514SThierry Reding { 3005acd3514SThierry Reding struct drm_crtc_state *crtc_state; 3015acd3514SThierry Reding struct tegra_dc_state *tegra; 3025acd3514SThierry Reding int err; 3035acd3514SThierry Reding 3045acd3514SThierry Reding /* Propagate errors from allocation or locking failures. */ 3055acd3514SThierry Reding crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); 3065acd3514SThierry Reding if (IS_ERR(crtc_state)) 3075acd3514SThierry Reding return PTR_ERR(crtc_state); 3085acd3514SThierry Reding 3095acd3514SThierry Reding /* Check plane state for visibility and calculate clipping bounds */ 31081af63a4SVille Syrjälä err = drm_atomic_helper_check_plane_state(state, crtc_state, 3115acd3514SThierry Reding 0, INT_MAX, true, true); 3125acd3514SThierry Reding if (err < 0) 3135acd3514SThierry Reding return err; 3145acd3514SThierry Reding 31504d5d5dfSDmitry Osipenko err = tegra_plane_calculate_memory_bandwidth(state); 31604d5d5dfSDmitry Osipenko if (err < 0) 31704d5d5dfSDmitry Osipenko return err; 31804d5d5dfSDmitry Osipenko 3195acd3514SThierry Reding tegra = to_dc_state(crtc_state); 3205acd3514SThierry Reding 3215acd3514SThierry Reding tegra->planes |= WIN_A_ACT_REQ << plane->index; 3225acd3514SThierry Reding 3235acd3514SThierry Reding return 0; 3245acd3514SThierry Reding } 3255acd3514SThierry Reding 3265acd3514SThierry Reding int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap) 3275acd3514SThierry Reding { 3285acd3514SThierry Reding /* assume no swapping of fetched data */ 3295acd3514SThierry Reding if (swap) 3305acd3514SThierry Reding *swap = BYTE_SWAP_NOSWAP; 3315acd3514SThierry Reding 3325acd3514SThierry Reding switch (fourcc) { 333511c7023SThierry Reding case DRM_FORMAT_ARGB4444: 334511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B4G4R4A4; 3357772fdaeSThierry Reding break; 3367772fdaeSThierry Reding 337511c7023SThierry Reding case DRM_FORMAT_ARGB1555: 338511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G5R5A1; 3395acd3514SThierry Reding break; 3405acd3514SThierry Reding 341511c7023SThierry Reding case DRM_FORMAT_RGB565: 342511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G6R5; 343511c7023SThierry Reding break; 344511c7023SThierry Reding 345511c7023SThierry Reding case DRM_FORMAT_RGBA5551: 346511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A1B5G5R5; 3477772fdaeSThierry Reding break; 3487772fdaeSThierry Reding 3497772fdaeSThierry Reding case DRM_FORMAT_ARGB8888: 3505acd3514SThierry Reding *format = WIN_COLOR_DEPTH_B8G8R8A8; 3515acd3514SThierry Reding break; 3525acd3514SThierry Reding 353511c7023SThierry Reding case DRM_FORMAT_ABGR8888: 354511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R8G8B8A8; 355511c7023SThierry Reding break; 356511c7023SThierry Reding 357511c7023SThierry Reding case DRM_FORMAT_ABGR4444: 358511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R4G4B4A4; 359511c7023SThierry Reding break; 360511c7023SThierry Reding 361511c7023SThierry Reding case DRM_FORMAT_ABGR1555: 362511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G5B5A; 363511c7023SThierry Reding break; 364511c7023SThierry Reding 365511c7023SThierry Reding case DRM_FORMAT_BGRA5551: 366511c7023SThierry Reding *format = WIN_COLOR_DEPTH_AR5G5B5; 367511c7023SThierry Reding break; 368511c7023SThierry Reding 369511c7023SThierry Reding case DRM_FORMAT_XRGB1555: 370511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B5G5R5X1; 371511c7023SThierry Reding break; 372511c7023SThierry Reding 373511c7023SThierry Reding case DRM_FORMAT_RGBX5551: 374511c7023SThierry Reding *format = WIN_COLOR_DEPTH_X1B5G5R5; 375511c7023SThierry Reding break; 376511c7023SThierry Reding 377511c7023SThierry Reding case DRM_FORMAT_XBGR1555: 378511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G5B5X1; 379511c7023SThierry Reding break; 380511c7023SThierry Reding 381511c7023SThierry Reding case DRM_FORMAT_BGRX5551: 382511c7023SThierry Reding *format = WIN_COLOR_DEPTH_X1R5G5B5; 383511c7023SThierry Reding break; 384511c7023SThierry Reding 385511c7023SThierry Reding case DRM_FORMAT_BGR565: 386511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R5G6B5; 387511c7023SThierry Reding break; 388511c7023SThierry Reding 389511c7023SThierry Reding case DRM_FORMAT_BGRA8888: 390511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A8R8G8B8; 391511c7023SThierry Reding break; 392511c7023SThierry Reding 393511c7023SThierry Reding case DRM_FORMAT_RGBA8888: 394511c7023SThierry Reding *format = WIN_COLOR_DEPTH_A8B8G8R8; 395511c7023SThierry Reding break; 396511c7023SThierry Reding 397511c7023SThierry Reding case DRM_FORMAT_XRGB8888: 398511c7023SThierry Reding *format = WIN_COLOR_DEPTH_B8G8R8X8; 399511c7023SThierry Reding break; 400511c7023SThierry Reding 401511c7023SThierry Reding case DRM_FORMAT_XBGR8888: 402511c7023SThierry Reding *format = WIN_COLOR_DEPTH_R8G8B8X8; 4035acd3514SThierry Reding break; 4045acd3514SThierry Reding 4055acd3514SThierry Reding case DRM_FORMAT_UYVY: 4065acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 4075acd3514SThierry Reding break; 4085acd3514SThierry Reding 4095acd3514SThierry Reding case DRM_FORMAT_YUYV: 4105acd3514SThierry Reding if (!swap) 4115acd3514SThierry Reding return -EINVAL; 4125acd3514SThierry Reding 4135acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 4145acd3514SThierry Reding *swap = BYTE_SWAP_SWAP2; 4155acd3514SThierry Reding break; 4165acd3514SThierry Reding 417cf5086d3SThierry Reding case DRM_FORMAT_YVYU: 418cf5086d3SThierry Reding if (!swap) 419cf5086d3SThierry Reding return -EINVAL; 420cf5086d3SThierry Reding 421cf5086d3SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 422cf5086d3SThierry Reding *swap = BYTE_SWAP_SWAP4; 423cf5086d3SThierry Reding break; 424cf5086d3SThierry Reding 425cf5086d3SThierry Reding case DRM_FORMAT_VYUY: 426cf5086d3SThierry Reding if (!swap) 427cf5086d3SThierry Reding return -EINVAL; 428cf5086d3SThierry Reding 429cf5086d3SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422; 430cf5086d3SThierry Reding *swap = BYTE_SWAP_SWAP4HW; 431cf5086d3SThierry Reding break; 432cf5086d3SThierry Reding 4335acd3514SThierry Reding case DRM_FORMAT_YUV420: 4345acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr420P; 4355acd3514SThierry Reding break; 4365acd3514SThierry Reding 4375acd3514SThierry Reding case DRM_FORMAT_YUV422: 4385acd3514SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422P; 4395acd3514SThierry Reding break; 4405acd3514SThierry Reding 441cf5086d3SThierry Reding case DRM_FORMAT_YUV444: 442cf5086d3SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr444P; 443cf5086d3SThierry Reding break; 444cf5086d3SThierry Reding 445a649b133SThierry Reding case DRM_FORMAT_NV12: 446a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr420SP; 447a649b133SThierry Reding break; 448a649b133SThierry Reding 449a649b133SThierry Reding case DRM_FORMAT_NV21: 450a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb420SP; 451a649b133SThierry Reding break; 452a649b133SThierry Reding 453a649b133SThierry Reding case DRM_FORMAT_NV16: 454a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr422SP; 455a649b133SThierry Reding break; 456a649b133SThierry Reding 457a649b133SThierry Reding case DRM_FORMAT_NV61: 458a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb422SP; 459a649b133SThierry Reding break; 460a649b133SThierry Reding 461a649b133SThierry Reding case DRM_FORMAT_NV24: 462a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCbCr444SP; 463a649b133SThierry Reding break; 464a649b133SThierry Reding 465a649b133SThierry Reding case DRM_FORMAT_NV42: 466a649b133SThierry Reding *format = WIN_COLOR_DEPTH_YCrCb444SP; 467a649b133SThierry Reding break; 468a649b133SThierry Reding 4695acd3514SThierry Reding default: 4705acd3514SThierry Reding return -EINVAL; 4715acd3514SThierry Reding } 4725acd3514SThierry Reding 4735acd3514SThierry Reding return 0; 4745acd3514SThierry Reding } 4755acd3514SThierry Reding 476e16efff4SThierry Reding bool tegra_plane_format_is_indexed(unsigned int format) 477e16efff4SThierry Reding { 478e16efff4SThierry Reding switch (format) { 479e16efff4SThierry Reding case WIN_COLOR_DEPTH_P1: 480e16efff4SThierry Reding case WIN_COLOR_DEPTH_P2: 481e16efff4SThierry Reding case WIN_COLOR_DEPTH_P4: 482e16efff4SThierry Reding case WIN_COLOR_DEPTH_P8: 483e16efff4SThierry Reding return true; 484e16efff4SThierry Reding } 485e16efff4SThierry Reding 486e16efff4SThierry Reding return false; 487e16efff4SThierry Reding } 488e16efff4SThierry Reding 489a649b133SThierry Reding bool tegra_plane_format_is_yuv(unsigned int format, unsigned int *planes, unsigned int *bpc) 4905acd3514SThierry Reding { 4915acd3514SThierry Reding switch (format) { 4925acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422: 4935acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422: 494a649b133SThierry Reding if (planes) 495a649b133SThierry Reding *planes = 1; 4965acd3514SThierry Reding 497e16efff4SThierry Reding if (bpc) 498e16efff4SThierry Reding *bpc = 8; 499e16efff4SThierry Reding 5005acd3514SThierry Reding return true; 5015acd3514SThierry Reding 5025acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr420P: 5035acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV420P: 5045acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422P: 5055acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422P: 5065acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422R: 5075acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422R: 5085acd3514SThierry Reding case WIN_COLOR_DEPTH_YCbCr422RA: 5095acd3514SThierry Reding case WIN_COLOR_DEPTH_YUV422RA: 510cf5086d3SThierry Reding case WIN_COLOR_DEPTH_YCbCr444P: 511a649b133SThierry Reding if (planes) 512a649b133SThierry Reding *planes = 3; 513a649b133SThierry Reding 514a649b133SThierry Reding if (bpc) 515a649b133SThierry Reding *bpc = 8; 516a649b133SThierry Reding 517a649b133SThierry Reding return true; 518a649b133SThierry Reding 519a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb420SP: 520a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr420SP: 521a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb422SP: 522a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr422SP: 523a649b133SThierry Reding case WIN_COLOR_DEPTH_YCrCb444SP: 524a649b133SThierry Reding case WIN_COLOR_DEPTH_YCbCr444SP: 525a649b133SThierry Reding if (planes) 526a649b133SThierry Reding *planes = 2; 5275acd3514SThierry Reding 528e16efff4SThierry Reding if (bpc) 529e16efff4SThierry Reding *bpc = 8; 530e16efff4SThierry Reding 5315acd3514SThierry Reding return true; 5325acd3514SThierry Reding } 5335acd3514SThierry Reding 534a649b133SThierry Reding if (planes) 535a649b133SThierry Reding *planes = 1; 5365acd3514SThierry Reding 5375acd3514SThierry Reding return false; 5385acd3514SThierry Reding } 539ebae8d07SThierry Reding 540ebae8d07SThierry Reding static bool __drm_format_has_alpha(u32 format) 541ebae8d07SThierry Reding { 542ebae8d07SThierry Reding switch (format) { 543ebae8d07SThierry Reding case DRM_FORMAT_ARGB1555: 544ebae8d07SThierry Reding case DRM_FORMAT_RGBA5551: 545ebae8d07SThierry Reding case DRM_FORMAT_ABGR8888: 546ebae8d07SThierry Reding case DRM_FORMAT_ARGB8888: 547ebae8d07SThierry Reding return true; 548ebae8d07SThierry Reding } 549ebae8d07SThierry Reding 550ebae8d07SThierry Reding return false; 551ebae8d07SThierry Reding } 552ebae8d07SThierry Reding 5533dae08bcSDmitry Osipenko static int tegra_plane_format_get_alpha(unsigned int opaque, 5543dae08bcSDmitry Osipenko unsigned int *alpha) 555ebae8d07SThierry Reding { 556e16efff4SThierry Reding if (tegra_plane_format_is_yuv(opaque, NULL, NULL)) { 5575467a8b8SThierry Reding *alpha = opaque; 5585467a8b8SThierry Reding return 0; 5595467a8b8SThierry Reding } 5605467a8b8SThierry Reding 561ebae8d07SThierry Reding switch (opaque) { 562ebae8d07SThierry Reding case WIN_COLOR_DEPTH_B5G5R5X1: 563ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_B5G5R5A1; 564ebae8d07SThierry Reding return 0; 565ebae8d07SThierry Reding 566ebae8d07SThierry Reding case WIN_COLOR_DEPTH_X1B5G5R5: 567ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_A1B5G5R5; 568ebae8d07SThierry Reding return 0; 569ebae8d07SThierry Reding 570ebae8d07SThierry Reding case WIN_COLOR_DEPTH_R8G8B8X8: 571ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_R8G8B8A8; 572ebae8d07SThierry Reding return 0; 573ebae8d07SThierry Reding 574ebae8d07SThierry Reding case WIN_COLOR_DEPTH_B8G8R8X8: 575ebae8d07SThierry Reding *alpha = WIN_COLOR_DEPTH_B8G8R8A8; 576ebae8d07SThierry Reding return 0; 5778a927d64SThierry Reding 5788a927d64SThierry Reding case WIN_COLOR_DEPTH_B5G6R5: 5798a927d64SThierry Reding *alpha = opaque; 5808a927d64SThierry Reding return 0; 581ebae8d07SThierry Reding } 582ebae8d07SThierry Reding 583ebae8d07SThierry Reding return -EINVAL; 584ebae8d07SThierry Reding } 585ebae8d07SThierry Reding 5863dae08bcSDmitry Osipenko /* 5873dae08bcSDmitry Osipenko * This is applicable to Tegra20 and Tegra30 only where the opaque formats can 5883dae08bcSDmitry Osipenko * be emulated using the alpha formats and alpha blending disabled. 5893dae08bcSDmitry Osipenko */ 5903dae08bcSDmitry Osipenko static int tegra_plane_setup_opacity(struct tegra_plane *tegra, 5913dae08bcSDmitry Osipenko struct tegra_plane_state *state) 5923dae08bcSDmitry Osipenko { 5933dae08bcSDmitry Osipenko unsigned int format; 5943dae08bcSDmitry Osipenko int err; 5953dae08bcSDmitry Osipenko 5963dae08bcSDmitry Osipenko switch (state->format) { 5973dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_B5G5R5A1: 5983dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_A1B5G5R5: 5993dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_R8G8B8A8: 6003dae08bcSDmitry Osipenko case WIN_COLOR_DEPTH_B8G8R8A8: 6013dae08bcSDmitry Osipenko state->opaque = false; 6023dae08bcSDmitry Osipenko break; 6033dae08bcSDmitry Osipenko 6043dae08bcSDmitry Osipenko default: 6053dae08bcSDmitry Osipenko err = tegra_plane_format_get_alpha(state->format, &format); 6063dae08bcSDmitry Osipenko if (err < 0) 6073dae08bcSDmitry Osipenko return err; 6083dae08bcSDmitry Osipenko 6093dae08bcSDmitry Osipenko state->format = format; 6103dae08bcSDmitry Osipenko state->opaque = true; 6113dae08bcSDmitry Osipenko break; 6123dae08bcSDmitry Osipenko } 6133dae08bcSDmitry Osipenko 6143dae08bcSDmitry Osipenko return 0; 6153dae08bcSDmitry Osipenko } 6163dae08bcSDmitry Osipenko 6173dae08bcSDmitry Osipenko static int tegra_plane_check_transparency(struct tegra_plane *tegra, 6183dae08bcSDmitry Osipenko struct tegra_plane_state *state) 6193dae08bcSDmitry Osipenko { 6203dae08bcSDmitry Osipenko struct drm_plane_state *old, *plane_state; 6213dae08bcSDmitry Osipenko struct drm_plane *plane; 6223dae08bcSDmitry Osipenko 6233dae08bcSDmitry Osipenko old = drm_atomic_get_old_plane_state(state->base.state, &tegra->base); 6243dae08bcSDmitry Osipenko 6253dae08bcSDmitry Osipenko /* check if zpos / transparency changed */ 6263dae08bcSDmitry Osipenko if (old->normalized_zpos == state->base.normalized_zpos && 6273dae08bcSDmitry Osipenko to_tegra_plane_state(old)->opaque == state->opaque) 6283dae08bcSDmitry Osipenko return 0; 6293dae08bcSDmitry Osipenko 6303dae08bcSDmitry Osipenko /* include all sibling planes into this commit */ 6313dae08bcSDmitry Osipenko drm_for_each_plane(plane, tegra->base.dev) { 6323dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 6333dae08bcSDmitry Osipenko 6343dae08bcSDmitry Osipenko /* skip this plane and planes on different CRTCs */ 6353dae08bcSDmitry Osipenko if (p == tegra || p->dc != tegra->dc) 6363dae08bcSDmitry Osipenko continue; 6373dae08bcSDmitry Osipenko 6383dae08bcSDmitry Osipenko plane_state = drm_atomic_get_plane_state(state->base.state, 6393dae08bcSDmitry Osipenko plane); 6403dae08bcSDmitry Osipenko if (IS_ERR(plane_state)) 6413dae08bcSDmitry Osipenko return PTR_ERR(plane_state); 6423dae08bcSDmitry Osipenko } 6433dae08bcSDmitry Osipenko 6443dae08bcSDmitry Osipenko return 1; 6453dae08bcSDmitry Osipenko } 6463dae08bcSDmitry Osipenko 6475e2e86f1SDmitry Osipenko static unsigned int tegra_plane_get_overlap_index(struct tegra_plane *plane, 648ebae8d07SThierry Reding struct tegra_plane *other) 649ebae8d07SThierry Reding { 650ebae8d07SThierry Reding unsigned int index = 0, i; 651ebae8d07SThierry Reding 652ebae8d07SThierry Reding WARN_ON(plane == other); 653ebae8d07SThierry Reding 654ebae8d07SThierry Reding for (i = 0; i < 3; i++) { 655ebae8d07SThierry Reding if (i == plane->index) 656ebae8d07SThierry Reding continue; 657ebae8d07SThierry Reding 658ebae8d07SThierry Reding if (i == other->index) 659ebae8d07SThierry Reding break; 660ebae8d07SThierry Reding 661ebae8d07SThierry Reding index++; 662ebae8d07SThierry Reding } 663ebae8d07SThierry Reding 664ebae8d07SThierry Reding return index; 665ebae8d07SThierry Reding } 666ebae8d07SThierry Reding 6673dae08bcSDmitry Osipenko static void tegra_plane_update_transparency(struct tegra_plane *tegra, 668ebae8d07SThierry Reding struct tegra_plane_state *state) 669ebae8d07SThierry Reding { 6703dae08bcSDmitry Osipenko struct drm_plane_state *new; 671ebae8d07SThierry Reding struct drm_plane *plane; 672ebae8d07SThierry Reding unsigned int i; 673ebae8d07SThierry Reding 6743dae08bcSDmitry Osipenko for_each_new_plane_in_state(state->base.state, plane, new, i) { 675ebae8d07SThierry Reding struct tegra_plane *p = to_tegra_plane(plane); 676ebae8d07SThierry Reding unsigned index; 677ebae8d07SThierry Reding 678ebae8d07SThierry Reding /* skip this plane and planes on different CRTCs */ 6793dae08bcSDmitry Osipenko if (p == tegra || p->dc != tegra->dc) 680ebae8d07SThierry Reding continue; 681ebae8d07SThierry Reding 682ebae8d07SThierry Reding index = tegra_plane_get_overlap_index(tegra, p); 683ebae8d07SThierry Reding 6843dae08bcSDmitry Osipenko if (new->fb && __drm_format_has_alpha(new->fb->format->format)) 6853dae08bcSDmitry Osipenko state->blending[index].alpha = true; 6863dae08bcSDmitry Osipenko else 6873dae08bcSDmitry Osipenko state->blending[index].alpha = false; 6883dae08bcSDmitry Osipenko 6893dae08bcSDmitry Osipenko if (new->normalized_zpos > state->base.normalized_zpos) 6903dae08bcSDmitry Osipenko state->blending[index].top = true; 6913dae08bcSDmitry Osipenko else 6923dae08bcSDmitry Osipenko state->blending[index].top = false; 69348519232SDmitry Osipenko 694ebae8d07SThierry Reding /* 6953dae08bcSDmitry Osipenko * Missing framebuffer means that plane is disabled, in this 6963dae08bcSDmitry Osipenko * case mark B / C window as top to be able to differentiate 6973dae08bcSDmitry Osipenko * windows indices order in regards to zPos for the middle 6983dae08bcSDmitry Osipenko * window X / Y registers programming. 699ebae8d07SThierry Reding */ 7003dae08bcSDmitry Osipenko if (!new->fb) 7013dae08bcSDmitry Osipenko state->blending[index].top = (index == 1); 702ebae8d07SThierry Reding } 703ebae8d07SThierry Reding } 704ebae8d07SThierry Reding 7053dae08bcSDmitry Osipenko static int tegra_plane_setup_transparency(struct tegra_plane *tegra, 7063dae08bcSDmitry Osipenko struct tegra_plane_state *state) 7073dae08bcSDmitry Osipenko { 7083dae08bcSDmitry Osipenko struct tegra_plane_state *tegra_state; 7093dae08bcSDmitry Osipenko struct drm_plane_state *new; 7103dae08bcSDmitry Osipenko struct drm_plane *plane; 7113dae08bcSDmitry Osipenko int err; 712ebae8d07SThierry Reding 713ebae8d07SThierry Reding /* 7143dae08bcSDmitry Osipenko * If planes zpos / transparency changed, sibling planes blending 7153dae08bcSDmitry Osipenko * state may require adjustment and in this case they will be included 7163dae08bcSDmitry Osipenko * into this atom commit, otherwise blending state is unchanged. 717ebae8d07SThierry Reding */ 7183dae08bcSDmitry Osipenko err = tegra_plane_check_transparency(tegra, state); 7193dae08bcSDmitry Osipenko if (err <= 0) 7203dae08bcSDmitry Osipenko return err; 7213dae08bcSDmitry Osipenko 7223dae08bcSDmitry Osipenko /* 7233dae08bcSDmitry Osipenko * All planes are now in the atomic state, walk them up and update 7243dae08bcSDmitry Osipenko * transparency state for each plane. 7253dae08bcSDmitry Osipenko */ 7263dae08bcSDmitry Osipenko drm_for_each_plane(plane, tegra->base.dev) { 7273dae08bcSDmitry Osipenko struct tegra_plane *p = to_tegra_plane(plane); 7283dae08bcSDmitry Osipenko 7293dae08bcSDmitry Osipenko /* skip planes on different CRTCs */ 7303dae08bcSDmitry Osipenko if (p->dc != tegra->dc) 7313dae08bcSDmitry Osipenko continue; 7323dae08bcSDmitry Osipenko 7333dae08bcSDmitry Osipenko new = drm_atomic_get_new_plane_state(state->base.state, plane); 7343dae08bcSDmitry Osipenko tegra_state = to_tegra_plane_state(new); 7353dae08bcSDmitry Osipenko 7363dae08bcSDmitry Osipenko /* 7373dae08bcSDmitry Osipenko * There is no need to update blending state for the disabled 7383dae08bcSDmitry Osipenko * plane. 7393dae08bcSDmitry Osipenko */ 7403dae08bcSDmitry Osipenko if (new->fb) 7413dae08bcSDmitry Osipenko tegra_plane_update_transparency(p, tegra_state); 742ebae8d07SThierry Reding } 7433dae08bcSDmitry Osipenko 7443dae08bcSDmitry Osipenko return 0; 7453dae08bcSDmitry Osipenko } 7463dae08bcSDmitry Osipenko 7473dae08bcSDmitry Osipenko int tegra_plane_setup_legacy_state(struct tegra_plane *tegra, 7483dae08bcSDmitry Osipenko struct tegra_plane_state *state) 7493dae08bcSDmitry Osipenko { 7503dae08bcSDmitry Osipenko int err; 7513dae08bcSDmitry Osipenko 7523dae08bcSDmitry Osipenko err = tegra_plane_setup_opacity(tegra, state); 7533dae08bcSDmitry Osipenko if (err < 0) 7543dae08bcSDmitry Osipenko return err; 7553dae08bcSDmitry Osipenko 7563dae08bcSDmitry Osipenko err = tegra_plane_setup_transparency(tegra, state); 7573dae08bcSDmitry Osipenko if (err < 0) 7583dae08bcSDmitry Osipenko return err; 7593dae08bcSDmitry Osipenko 7603dae08bcSDmitry Osipenko return 0; 761ebae8d07SThierry Reding } 76204d5d5dfSDmitry Osipenko 76304d5d5dfSDmitry Osipenko static const char * const tegra_plane_icc_names[TEGRA_DC_LEGACY_PLANES_NUM] = { 76404d5d5dfSDmitry Osipenko "wina", "winb", "winc", NULL, NULL, NULL, "cursor", 76504d5d5dfSDmitry Osipenko }; 76604d5d5dfSDmitry Osipenko 76704d5d5dfSDmitry Osipenko int tegra_plane_interconnect_init(struct tegra_plane *plane) 76804d5d5dfSDmitry Osipenko { 76904d5d5dfSDmitry Osipenko const char *icc_name = tegra_plane_icc_names[plane->index]; 77004d5d5dfSDmitry Osipenko struct device *dev = plane->dc->dev; 77104d5d5dfSDmitry Osipenko struct tegra_dc *dc = plane->dc; 77204d5d5dfSDmitry Osipenko int err; 77304d5d5dfSDmitry Osipenko 77404d5d5dfSDmitry Osipenko if (WARN_ON(plane->index >= TEGRA_DC_LEGACY_PLANES_NUM) || 77504d5d5dfSDmitry Osipenko WARN_ON(!tegra_plane_icc_names[plane->index])) 77604d5d5dfSDmitry Osipenko return -EINVAL; 77704d5d5dfSDmitry Osipenko 77804d5d5dfSDmitry Osipenko plane->icc_mem = devm_of_icc_get(dev, icc_name); 77904d5d5dfSDmitry Osipenko err = PTR_ERR_OR_ZERO(plane->icc_mem); 78004d5d5dfSDmitry Osipenko if (err) { 78104d5d5dfSDmitry Osipenko dev_err_probe(dev, err, "failed to get %s interconnect\n", 78204d5d5dfSDmitry Osipenko icc_name); 78304d5d5dfSDmitry Osipenko return err; 78404d5d5dfSDmitry Osipenko } 78504d5d5dfSDmitry Osipenko 78604d5d5dfSDmitry Osipenko /* plane B on T20/30 has a dedicated memory client for a 6-tap vertical filter */ 78704d5d5dfSDmitry Osipenko if (plane->index == 1 && dc->soc->has_win_b_vfilter_mem_client) { 78804d5d5dfSDmitry Osipenko plane->icc_mem_vfilter = devm_of_icc_get(dev, "winb-vfilter"); 78904d5d5dfSDmitry Osipenko err = PTR_ERR_OR_ZERO(plane->icc_mem_vfilter); 79004d5d5dfSDmitry Osipenko if (err) { 79104d5d5dfSDmitry Osipenko dev_err_probe(dev, err, "failed to get %s interconnect\n", 79204d5d5dfSDmitry Osipenko "winb-vfilter"); 79304d5d5dfSDmitry Osipenko return err; 79404d5d5dfSDmitry Osipenko } 79504d5d5dfSDmitry Osipenko } 79604d5d5dfSDmitry Osipenko 79704d5d5dfSDmitry Osipenko return 0; 79804d5d5dfSDmitry Osipenko } 799