Lines Matching +full:sub +full:- +full:sampled

1 // SPDX-License-Identifier: GPL-2.0-only
56 * This 4-entry look-up-table is used to determine the full 8-bit alpha value
57 * for formats with 1- or 2-bit alpha channels.
58 * We set it to give 100%/0% opacity for 1-bit formats and 100%/66%/33%/0%
59 * opacity for 2-bit formats.
67 /* readahead for partial-frame prefetch */
79 * Replicate what the default ->reset hook does: free the state pointer and
85 struct malidp_plane_state *state = to_malidp_plane_state(plane->state); in malidp_plane_reset()
88 __drm_atomic_helper_plane_destroy_state(&state->base); in malidp_plane_reset()
90 plane->state = NULL; in malidp_plane_reset()
93 __drm_atomic_helper_plane_reset(plane, &state->base); in malidp_plane_reset()
101 if (!plane->state) in malidp_duplicate_plane_state()
108 m_state = to_malidp_plane_state(plane->state); in malidp_duplicate_plane_state()
109 __drm_atomic_helper_plane_duplicate_state(plane, &state->base); in malidp_duplicate_plane_state()
110 state->rotmem_size = m_state->rotmem_size; in malidp_duplicate_plane_state()
111 state->format = m_state->format; in malidp_duplicate_plane_state()
112 state->n_planes = m_state->n_planes; in malidp_duplicate_plane_state()
114 state->mmu_prefetch_mode = m_state->mmu_prefetch_mode; in malidp_duplicate_plane_state()
115 state->mmu_prefetch_pgsize = m_state->mmu_prefetch_pgsize; in malidp_duplicate_plane_state()
117 return &state->base; in malidp_duplicate_plane_state()
140 drm_printf(p, "\trotmem_size=%u\n", ms->rotmem_size); in malidp_plane_atomic_print_state()
141 drm_printf(p, "\tformat_id=%u\n", ms->format); in malidp_plane_atomic_print_state()
142 drm_printf(p, "\tn_planes=%u\n", ms->n_planes); in malidp_plane_atomic_print_state()
144 prefetch_mode_names[ms->mmu_prefetch_mode]); in malidp_plane_atomic_print_state()
145 drm_printf(p, "\tmmu_prefetch_pgsize=%d\n", ms->mmu_prefetch_pgsize); in malidp_plane_atomic_print_state()
153 struct malidp_drm *malidp = drm->dev_private; in malidp_format_mod_supported()
154 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_format_mod_supported()
204 if (info->num_planes != 1) { in malidp_format_mod_supported()
219 if (!(info->is_yuv) != !!(modifier & AFBC_FORMAT_MOD_YTR)) { in malidp_format_mod_supported()
221 info->is_yuv ? "disallowed" : "mandatory", in malidp_format_mod_supported()
222 info->is_yuv ? "YUV" : "RGB"); in malidp_format_mod_supported()
227 if (!info->is_yuv) { in malidp_format_mod_supported()
228 if (info->cpp[0] <= 2) { in malidp_format_mod_supported()
234 if ((info->hsub != 1) || (info->vsub != 1)) { in malidp_format_mod_supported()
236 (map->features & MALIDP_DEVICE_AFBC_YUV_420_10_SUPPORT_SPLIT))) { in malidp_format_mod_supported()
237 DRM_DEBUG_KMS("Formats which are sub-sampled should never be split\n"); in malidp_format_mod_supported()
244 if ((info->hsub == 1) || (info->vsub == 1)) { in malidp_format_mod_supported()
245 DRM_DEBUG_KMS("Formats which are not sub-sampled should not have CBR set\n"); in malidp_format_mod_supported()
256 return malidp_format_mod_supported(plane->dev, format, modifier); in malidp_format_mod_supported_per_plane()
274 drm_atomic_get_existing_crtc_state(state->state, state->crtc); in malidp_se_check_scaling()
280 return -EINVAL; in malidp_se_check_scaling()
289 if (state->rotation & MALIDP_ROTATED_MASK) { in malidp_se_check_scaling()
290 src_w = state->src_h >> 16; in malidp_se_check_scaling()
291 src_h = state->src_w >> 16; in malidp_se_check_scaling()
293 src_w = state->src_w >> 16; in malidp_se_check_scaling()
294 src_h = state->src_h >> 16; in malidp_se_check_scaling()
297 if ((state->crtc_w == src_w) && (state->crtc_h == src_h)) { in malidp_se_check_scaling()
299 mc->scaled_planes_mask &= ~(mp->layer->id); in malidp_se_check_scaling()
303 if (mp->layer->id & (DE_SMART | DE_GRAPHICS2)) in malidp_se_check_scaling()
304 return -EINVAL; in malidp_se_check_scaling()
306 mc->scaled_planes_mask |= mp->layer->id; in malidp_se_check_scaling()
317 iommu_get_domain_for_dev(mp->base.dev->dev); in malidp_get_pgsize_bitmap()
320 pgsize_bitmap = mmu_dom->pgsize_bitmap; in malidp_get_pgsize_bitmap()
337 for (i = 0; i < ms->n_planes; i++) { in malidp_check_pages_threshold()
343 obj = drm_gem_fb_get_obj(ms->base.fb, i); in malidp_check_pages_threshold()
346 if (cma_obj->sgt) in malidp_check_pages_threshold()
347 sgt = cma_obj->sgt; in malidp_check_pages_threshold()
349 sgt = obj->funcs->get_sg_table(obj); in malidp_check_pages_threshold()
354 sgl = sgt->sgl; in malidp_check_pages_threshold()
357 if (sgl->length < pgsize) { in malidp_check_pages_threshold()
358 if (!cma_obj->sgt) in malidp_check_pages_threshold()
365 if (!cma_obj->sgt) in malidp_check_pages_threshold()
373 * Check if it is possible to enable partial-frame MMU prefetch given the
430 * Select the preferred MMU prefetch mode. Full-frame prefetch is preferred as
431 * long as the framebuffer is all large pages. Otherwise partial-frame prefetch
440 /* get the full-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
451 pgsizes -= largest_pgsize; in malidp_mmu_prefetch_select_mode()
454 /* get the partial-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
457 if (malidp_partial_prefetch_supported(ms->base.fb->format->format, in malidp_mmu_prefetch_select_mode()
458 ms->base.fb->modifier, in malidp_mmu_prefetch_select_mode()
459 ms->base.rotation)) { in malidp_mmu_prefetch_select_mode()
495 if (!mp->layer->mmu_ctrl_offset) in malidp_de_prefetch_settings()
499 ms->mmu_prefetch_pgsize = malidp_get_pgsize_bitmap(mp); in malidp_de_prefetch_settings()
500 ms->mmu_prefetch_mode = in malidp_de_prefetch_settings()
501 malidp_mmu_prefetch_select_mode(ms, &ms->mmu_prefetch_pgsize); in malidp_de_prefetch_settings()
509 bool rotated = state->rotation & MALIDP_ROTATED_MASK; in malidp_de_plane_check()
511 u16 pixel_alpha = state->pixel_blend_mode; in malidp_de_plane_check()
515 if (!state->crtc || WARN_ON(!state->fb)) in malidp_de_plane_check()
518 fb = state->fb; in malidp_de_plane_check()
520 ms->format = malidp_hw_get_format_id(&mp->hwdev->hw->map, in malidp_de_plane_check()
521 mp->layer->id, fb->format->format, in malidp_de_plane_check()
522 !!fb->modifier); in malidp_de_plane_check()
523 if (ms->format == MALIDP_INVALID_FORMAT_ID) in malidp_de_plane_check()
524 return -EINVAL; in malidp_de_plane_check()
526 ms->n_planes = fb->format->num_planes; in malidp_de_plane_check()
527 for (i = 0; i < ms->n_planes; i++) { in malidp_de_plane_check()
528 u8 alignment = malidp_hw_get_pitch_align(mp->hwdev, rotated); in malidp_de_plane_check()
530 if (((fb->pitches[i] * drm_format_info_block_height(fb->format, i)) in malidp_de_plane_check()
531 & (alignment - 1)) && !(fb->modifier)) { in malidp_de_plane_check()
533 fb->pitches[i], i); in malidp_de_plane_check()
534 return -EINVAL; in malidp_de_plane_check()
538 block_w = drm_format_info_block_width(fb->format, 0); in malidp_de_plane_check()
539 block_h = drm_format_info_block_height(fb->format, 0); in malidp_de_plane_check()
540 if (fb->width % block_w || fb->height % block_h) { in malidp_de_plane_check()
542 return -EINVAL; in malidp_de_plane_check()
544 if ((state->src_x >> 16) % block_w || (state->src_y >> 16) % block_h) { in malidp_de_plane_check()
546 return -EINVAL; in malidp_de_plane_check()
549 if ((state->crtc_w > mp->hwdev->max_line_size) || in malidp_de_plane_check()
550 (state->crtc_h > mp->hwdev->max_line_size) || in malidp_de_plane_check()
551 (state->crtc_w < mp->hwdev->min_line_size) || in malidp_de_plane_check()
552 (state->crtc_h < mp->hwdev->min_line_size)) in malidp_de_plane_check()
553 return -EINVAL; in malidp_de_plane_check()
557 * fb->pitches[1] == fb->pitches[2] since they don't have a in malidp_de_plane_check()
560 if (ms->n_planes == 3 && in malidp_de_plane_check()
561 !(mp->hwdev->hw->features & MALIDP_DEVICE_LV_HAS_3_STRIDES) && in malidp_de_plane_check()
562 (state->fb->pitches[1] != state->fb->pitches[2])) in malidp_de_plane_check()
563 return -EINVAL; in malidp_de_plane_check()
570 if (state->rotation != DRM_MODE_ROTATE_0) { in malidp_de_plane_check()
571 if (mp->layer->rot == ROTATE_NONE) in malidp_de_plane_check()
572 return -EINVAL; in malidp_de_plane_check()
573 if ((mp->layer->rot == ROTATE_COMPRESSED) && !(fb->modifier)) in malidp_de_plane_check()
574 return -EINVAL; in malidp_de_plane_check()
579 if ((fb->format->format == DRM_FORMAT_RGB888 || in malidp_de_plane_check()
580 fb->format->format == DRM_FORMAT_BGR888) && !(fb->modifier)) in malidp_de_plane_check()
581 return -EINVAL; in malidp_de_plane_check()
585 if (mp->layer->id == DE_SMART && fb->modifier) { in malidp_de_plane_check()
587 return -EINVAL; in malidp_de_plane_check()
590 ms->rotmem_size = 0; in malidp_de_plane_check()
591 if (state->rotation & MALIDP_ROTATED_MASK) { in malidp_de_plane_check()
594 val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_w, in malidp_de_plane_check()
595 state->crtc_h, in malidp_de_plane_check()
596 fb->format->format, in malidp_de_plane_check()
597 !!(fb->modifier)); in malidp_de_plane_check()
601 ms->rotmem_size = val; in malidp_de_plane_check()
605 if ((state->alpha != DRM_BLEND_ALPHA_OPAQUE) && in malidp_de_plane_check()
607 fb->format->has_alpha) in malidp_de_plane_check()
608 return -EINVAL; in malidp_de_plane_check()
621 if (!mp->layer->stride_offset) in malidp_de_set_plane_pitches()
625 num_strides = (mp->hwdev->hw->features & in malidp_de_set_plane_pitches()
634 unsigned int block_h = drm_format_info_block_height(mp->base.state->fb->format, i); in malidp_de_set_plane_pitches()
636 malidp_hw_write(mp->hwdev, pitches[i] * block_h, in malidp_de_set_plane_pitches()
637 mp->layer->base + in malidp_de_set_plane_pitches()
638 mp->layer->stride_offset + i * 4); in malidp_de_set_plane_pitches()
646 1192, -401, -832,
652 1024, -352, -731,
658 1192, -218, -546,
664 1024, -192, -479,
670 1024, -165, -572,
676 1024, -168, -585,
690 malidp_hw_write(plane->hwdev, malidp_yuv2rgb_coeffs[enc][range][i], in malidp_de_set_color_encoding()
691 plane->layer->base + plane->layer->yuv2rgb_offset + in malidp_de_set_color_encoding()
702 if (!mp->layer->mmu_ctrl_offset) in malidp_de_set_mmu_control()
705 mmu_ctrl = malidp_calc_mmu_control_value(ms->mmu_prefetch_mode, in malidp_de_set_mmu_control()
707 ms->n_planes, in malidp_de_set_mmu_control()
708 ms->mmu_prefetch_pgsize); in malidp_de_set_mmu_control()
710 malidp_hw_write(mp->hwdev, mmu_ctrl, in malidp_de_set_mmu_control()
711 mp->layer->base + mp->layer->mmu_ctrl_offset); in malidp_de_set_mmu_control()
720 struct drm_plane *plane = &mp->base; in malidp_set_plane_base_addr()
721 bool afbc = fb->modifier ? true : false; in malidp_set_plane_base_addr()
723 ptr = mp->layer->ptr + (plane_index << 4); in malidp_set_plane_base_addr()
727 * framebuffer as per the plane's src_x, src_y co-ordinates (ie to in malidp_set_plane_base_addr()
733 paddr = drm_fb_cma_get_gem_addr(fb, plane->state, in malidp_set_plane_base_addr()
742 paddr = obj->paddr; in malidp_set_plane_base_addr()
745 malidp_hw_write(mp->hwdev, lower_32_bits(paddr), ptr); in malidp_set_plane_base_addr()
746 malidp_hw_write(mp->hwdev, upper_32_bits(paddr), ptr + 4); in malidp_set_plane_base_addr()
753 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_set_plane_afbc()
758 if (!mp->layer->afbc_decoder_offset) in malidp_de_set_plane_afbc()
761 if (!fb->modifier) { in malidp_de_set_plane_afbc()
762 malidp_hw_write(mp->hwdev, 0, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
767 src_w = plane->state->src_w >> 16; in malidp_de_set_plane_afbc()
768 src_h = plane->state->src_h >> 16; in malidp_de_set_plane_afbc()
769 src_x = plane->state->src_x >> 16; in malidp_de_set_plane_afbc()
770 src_y = plane->state->src_y >> 16; in malidp_de_set_plane_afbc()
772 val = ((fb->width - (src_x + src_w)) << MALIDP_AD_CROP_RIGHT_OFFSET) | in malidp_de_set_plane_afbc()
774 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
775 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_H); in malidp_de_set_plane_afbc()
777 val = ((fb->height - (src_y + src_h)) << MALIDP_AD_CROP_BOTTOM_OFFSET) | in malidp_de_set_plane_afbc()
779 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
780 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_V); in malidp_de_set_plane_afbc()
783 if (fb->modifier & AFBC_FORMAT_MOD_SPLIT) in malidp_de_set_plane_afbc()
785 if (fb->modifier & AFBC_FORMAT_MOD_YTR) in malidp_de_set_plane_afbc()
788 malidp_hw_write(mp->hwdev, val, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
795 struct malidp_plane_state *ms = to_malidp_plane_state(plane->state); in malidp_de_plane_update()
796 struct drm_plane_state *state = plane->state; in malidp_de_plane_update()
797 u16 pixel_alpha = state->pixel_blend_mode; in malidp_de_plane_update()
798 u8 plane_alpha = state->alpha >> 8; in malidp_de_plane_update()
801 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_plane_update()
809 if (fb->modifier) { in malidp_de_plane_update()
810 src_w = fb->width; in malidp_de_plane_update()
811 src_h = fb->height; in malidp_de_plane_update()
814 src_w = state->src_w >> 16; in malidp_de_plane_update()
815 src_h = state->src_h >> 16; in malidp_de_plane_update()
818 dest_w = state->crtc_w; in malidp_de_plane_update()
819 dest_h = state->crtc_h; in malidp_de_plane_update()
821 val = malidp_hw_read(mp->hwdev, mp->layer->base); in malidp_de_plane_update()
822 val = (val & ~LAYER_FORMAT_MASK) | ms->format; in malidp_de_plane_update()
823 malidp_hw_write(mp->hwdev, val, mp->layer->base); in malidp_de_plane_update()
825 for (i = 0; i < ms->n_planes; i++) in malidp_de_plane_update()
830 malidp_de_set_plane_pitches(mp, ms->n_planes, in malidp_de_plane_update()
831 state->fb->pitches); in malidp_de_plane_update()
833 if ((plane->state->color_encoding != old_state->color_encoding) || in malidp_de_plane_update()
834 (plane->state->color_range != old_state->color_range)) in malidp_de_plane_update()
835 malidp_de_set_color_encoding(mp, plane->state->color_encoding, in malidp_de_plane_update()
836 plane->state->color_range); in malidp_de_plane_update()
838 malidp_hw_write(mp->hwdev, LAYER_H_VAL(src_w) | LAYER_V_VAL(src_h), in malidp_de_plane_update()
839 mp->layer->base + MALIDP_LAYER_SIZE); in malidp_de_plane_update()
841 malidp_hw_write(mp->hwdev, LAYER_H_VAL(dest_w) | LAYER_V_VAL(dest_h), in malidp_de_plane_update()
842 mp->layer->base + MALIDP_LAYER_COMP_SIZE); in malidp_de_plane_update()
844 malidp_hw_write(mp->hwdev, LAYER_H_VAL(state->crtc_x) | in malidp_de_plane_update()
845 LAYER_V_VAL(state->crtc_y), in malidp_de_plane_update()
846 mp->layer->base + MALIDP_LAYER_OFFSET); in malidp_de_plane_update()
848 if (mp->layer->id == DE_SMART) { in malidp_de_plane_update()
853 malidp_hw_write(mp->hwdev, 1, in malidp_de_plane_update()
854 mp->layer->base + MALIDP550_LS_ENABLE); in malidp_de_plane_update()
855 malidp_hw_write(mp->hwdev, in malidp_de_plane_update()
857 mp->layer->base + MALIDP550_LS_R1_IN_SIZE); in malidp_de_plane_update()
863 val = malidp_hw_read(mp->hwdev, mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
867 if (state->rotation & DRM_MODE_ROTATE_MASK) in malidp_de_plane_update()
868 val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) << in malidp_de_plane_update()
870 if (state->rotation & DRM_MODE_REFLECT_X) in malidp_de_plane_update()
872 if (state->rotation & DRM_MODE_REFLECT_Y) in malidp_de_plane_update()
877 if (state->alpha != DRM_BLEND_ALPHA_OPAQUE) { in malidp_de_plane_update()
879 } else if (state->fb->format->has_alpha) { in malidp_de_plane_update()
893 if (state->crtc) { in malidp_de_plane_update()
895 to_malidp_crtc_state(state->crtc->state); in malidp_de_plane_update()
897 if (m->scaler_config.scale_enable && in malidp_de_plane_update()
898 m->scaler_config.plane_src_id == mp->layer->id) in malidp_de_plane_update()
905 malidp_hw_write(mp->hwdev, val, in malidp_de_plane_update()
906 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
914 malidp_hw_clearbits(mp->hwdev, in malidp_de_plane_disable()
916 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_disable()
927 struct malidp_drm *malidp = drm->dev_private; in malidp_de_planes_init()
928 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_de_planes_init()
931 unsigned long crtcs = BIT(drm->mode_config.num_crtc); in malidp_de_planes_init()
944 if (!(map->features & MALIDP_DEVICE_AFBC_SUPPORT_SPLIT)) { in malidp_de_planes_init()
959 formats = kcalloc(map->n_pixel_formats, sizeof(*formats), GFP_KERNEL); in malidp_de_planes_init()
961 ret = -ENOMEM; in malidp_de_planes_init()
965 for (i = 0; i < map->n_layers; i++) { in malidp_de_planes_init()
966 u8 id = map->layers[i].id; in malidp_de_planes_init()
970 ret = -ENOMEM; in malidp_de_planes_init()
975 for (n = 0, j = 0; j < map->n_pixel_formats; j++) { in malidp_de_planes_init()
976 if ((map->pixel_formats[j].layer & id) == id) in malidp_de_planes_init()
977 formats[n++] = map->pixel_formats[j].format; in malidp_de_planes_init()
986 ret = drm_universal_plane_init(drm, &plane->base, crtcs, in malidp_de_planes_init()
994 drm_plane_helper_add(&plane->base, in malidp_de_planes_init()
996 plane->hwdev = malidp->dev; in malidp_de_planes_init()
997 plane->layer = &map->layers[i]; in malidp_de_planes_init()
999 drm_plane_create_alpha_property(&plane->base); in malidp_de_planes_init()
1000 drm_plane_create_blend_mode_property(&plane->base, blend_caps); in malidp_de_planes_init()
1007 drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, flags); in malidp_de_planes_init()
1008 malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT, in malidp_de_planes_init()
1009 plane->layer->base + MALIDP_LAYER_COMPOSE); in malidp_de_planes_init()
1011 /* Attach the YUV->RGB property only to video layers */ in malidp_de_planes_init()
1013 /* default encoding for YUV->RGB is BT601 NARROW */ in malidp_de_planes_init()
1017 ret = drm_plane_create_color_properties(&plane->base, in malidp_de_planes_init()