Lines Matching +full:sub +full:- +full:sampled
1 // SPDX-License-Identifier: GPL-2.0-only
57 * This 4-entry look-up-table is used to determine the full 8-bit alpha value
58 * for formats with 1- or 2-bit alpha channels.
59 * We set it to give 100%/0% opacity for 1-bit formats and 100%/66%/33%/0%
60 * opacity for 2-bit formats.
68 /* readahead for partial-frame prefetch */
72 * Replicate what the default ->reset hook does: free the state pointer and
78 struct malidp_plane_state *state = to_malidp_plane_state(plane->state); in malidp_plane_reset()
81 __drm_atomic_helper_plane_destroy_state(&state->base); in malidp_plane_reset()
83 plane->state = NULL; in malidp_plane_reset()
86 __drm_atomic_helper_plane_reset(plane, &state->base); in malidp_plane_reset()
94 if (!plane->state) in malidp_duplicate_plane_state()
101 m_state = to_malidp_plane_state(plane->state); in malidp_duplicate_plane_state()
102 __drm_atomic_helper_plane_duplicate_state(plane, &state->base); in malidp_duplicate_plane_state()
103 state->rotmem_size = m_state->rotmem_size; in malidp_duplicate_plane_state()
104 state->format = m_state->format; in malidp_duplicate_plane_state()
105 state->n_planes = m_state->n_planes; in malidp_duplicate_plane_state()
107 state->mmu_prefetch_mode = m_state->mmu_prefetch_mode; in malidp_duplicate_plane_state()
108 state->mmu_prefetch_pgsize = m_state->mmu_prefetch_pgsize; in malidp_duplicate_plane_state()
110 return &state->base; in malidp_duplicate_plane_state()
133 drm_printf(p, "\trotmem_size=%u\n", ms->rotmem_size); in malidp_plane_atomic_print_state()
134 drm_printf(p, "\tformat_id=%u\n", ms->format); in malidp_plane_atomic_print_state()
135 drm_printf(p, "\tn_planes=%u\n", ms->n_planes); in malidp_plane_atomic_print_state()
137 prefetch_mode_names[ms->mmu_prefetch_mode]); in malidp_plane_atomic_print_state()
138 drm_printf(p, "\tmmu_prefetch_pgsize=%d\n", ms->mmu_prefetch_pgsize); in malidp_plane_atomic_print_state()
147 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_format_mod_supported()
197 if (info->num_planes != 1) { in malidp_format_mod_supported()
212 if (!(info->is_yuv) != !!(modifier & AFBC_FORMAT_MOD_YTR)) { in malidp_format_mod_supported()
214 info->is_yuv ? "disallowed" : "mandatory", in malidp_format_mod_supported()
215 info->is_yuv ? "YUV" : "RGB"); in malidp_format_mod_supported()
220 if (!info->is_yuv) { in malidp_format_mod_supported()
221 if (info->cpp[0] <= 2) { in malidp_format_mod_supported()
227 if ((info->hsub != 1) || (info->vsub != 1)) { in malidp_format_mod_supported()
229 (map->features & MALIDP_DEVICE_AFBC_YUV_420_10_SUPPORT_SPLIT))) { in malidp_format_mod_supported()
230 DRM_DEBUG_KMS("Formats which are sub-sampled should never be split\n"); in malidp_format_mod_supported()
237 if ((info->hsub == 1) || (info->vsub == 1)) { in malidp_format_mod_supported()
238 DRM_DEBUG_KMS("Formats which are not sub-sampled should not have CBR set\n"); in malidp_format_mod_supported()
249 return malidp_format_mod_supported(plane->dev, format, modifier); in malidp_format_mod_supported_per_plane()
266 drm_atomic_get_existing_crtc_state(state->state, state->crtc); in malidp_se_check_scaling()
272 return -EINVAL; in malidp_se_check_scaling()
281 if (state->rotation & MALIDP_ROTATED_MASK) { in malidp_se_check_scaling()
282 src_w = state->src_h >> 16; in malidp_se_check_scaling()
283 src_h = state->src_w >> 16; in malidp_se_check_scaling()
285 src_w = state->src_w >> 16; in malidp_se_check_scaling()
286 src_h = state->src_h >> 16; in malidp_se_check_scaling()
289 if ((state->crtc_w == src_w) && (state->crtc_h == src_h)) { in malidp_se_check_scaling()
291 mc->scaled_planes_mask &= ~(mp->layer->id); in malidp_se_check_scaling()
295 if (mp->layer->id & (DE_SMART | DE_GRAPHICS2)) in malidp_se_check_scaling()
296 return -EINVAL; in malidp_se_check_scaling()
298 mc->scaled_planes_mask |= mp->layer->id; in malidp_se_check_scaling()
307 mmu_dom = iommu_get_domain_for_dev(mp->base.dev->dev); in malidp_get_pgsize_bitmap()
309 return mmu_dom->pgsize_bitmap; in malidp_get_pgsize_bitmap()
325 for (i = 0; i < ms->n_planes; i++) { in malidp_check_pages_threshold()
331 obj = drm_gem_fb_get_obj(ms->base.fb, i); in malidp_check_pages_threshold()
334 if (dma_obj->sgt) in malidp_check_pages_threshold()
335 sgt = dma_obj->sgt; in malidp_check_pages_threshold()
337 sgt = obj->funcs->get_sg_table(obj); in malidp_check_pages_threshold()
342 sgl = sgt->sgl; in malidp_check_pages_threshold()
345 if (sgl->length < pgsize) { in malidp_check_pages_threshold()
346 if (!dma_obj->sgt) in malidp_check_pages_threshold()
353 if (!dma_obj->sgt) in malidp_check_pages_threshold()
361 * Check if it is possible to enable partial-frame MMU prefetch given the
418 * Select the preferred MMU prefetch mode. Full-frame prefetch is preferred as
419 * long as the framebuffer is all large pages. Otherwise partial-frame prefetch
428 /* get the full-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
439 pgsizes -= largest_pgsize; in malidp_mmu_prefetch_select_mode()
442 /* get the partial-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
445 if (malidp_partial_prefetch_supported(ms->base.fb->format->format, in malidp_mmu_prefetch_select_mode()
446 ms->base.fb->modifier, in malidp_mmu_prefetch_select_mode()
447 ms->base.rotation)) { in malidp_mmu_prefetch_select_mode()
483 if (!mp->layer->mmu_ctrl_offset) in malidp_de_prefetch_settings()
487 ms->mmu_prefetch_pgsize = malidp_get_pgsize_bitmap(mp); in malidp_de_prefetch_settings()
488 ms->mmu_prefetch_mode = in malidp_de_prefetch_settings()
489 malidp_mmu_prefetch_select_mode(ms, &ms->mmu_prefetch_pgsize); in malidp_de_prefetch_settings()
499 bool rotated = new_plane_state->rotation & MALIDP_ROTATED_MASK; in malidp_de_plane_check()
501 u16 pixel_alpha = new_plane_state->pixel_blend_mode; in malidp_de_plane_check()
505 if (!new_plane_state->crtc || WARN_ON(!new_plane_state->fb)) in malidp_de_plane_check()
508 fb = new_plane_state->fb; in malidp_de_plane_check()
510 ms->format = malidp_hw_get_format_id(&mp->hwdev->hw->map, in malidp_de_plane_check()
511 mp->layer->id, fb->format->format, in malidp_de_plane_check()
512 !!fb->modifier); in malidp_de_plane_check()
513 if (ms->format == MALIDP_INVALID_FORMAT_ID) in malidp_de_plane_check()
514 return -EINVAL; in malidp_de_plane_check()
516 ms->n_planes = fb->format->num_planes; in malidp_de_plane_check()
517 for (i = 0; i < ms->n_planes; i++) { in malidp_de_plane_check()
518 u8 alignment = malidp_hw_get_pitch_align(mp->hwdev, rotated); in malidp_de_plane_check()
520 if (((fb->pitches[i] * drm_format_info_block_height(fb->format, i)) in malidp_de_plane_check()
521 & (alignment - 1)) && !(fb->modifier)) { in malidp_de_plane_check()
523 fb->pitches[i], i); in malidp_de_plane_check()
524 return -EINVAL; in malidp_de_plane_check()
528 block_w = drm_format_info_block_width(fb->format, 0); in malidp_de_plane_check()
529 block_h = drm_format_info_block_height(fb->format, 0); in malidp_de_plane_check()
530 if (fb->width % block_w || fb->height % block_h) { in malidp_de_plane_check()
532 return -EINVAL; in malidp_de_plane_check()
534 if ((new_plane_state->src_x >> 16) % block_w || (new_plane_state->src_y >> 16) % block_h) { in malidp_de_plane_check()
536 return -EINVAL; in malidp_de_plane_check()
539 if ((new_plane_state->crtc_w > mp->hwdev->max_line_size) || in malidp_de_plane_check()
540 (new_plane_state->crtc_h > mp->hwdev->max_line_size) || in malidp_de_plane_check()
541 (new_plane_state->crtc_w < mp->hwdev->min_line_size) || in malidp_de_plane_check()
542 (new_plane_state->crtc_h < mp->hwdev->min_line_size)) in malidp_de_plane_check()
543 return -EINVAL; in malidp_de_plane_check()
547 * fb->pitches[1] == fb->pitches[2] since they don't have a in malidp_de_plane_check()
550 if (ms->n_planes == 3 && in malidp_de_plane_check()
551 !(mp->hwdev->hw->features & MALIDP_DEVICE_LV_HAS_3_STRIDES) && in malidp_de_plane_check()
552 (new_plane_state->fb->pitches[1] != new_plane_state->fb->pitches[2])) in malidp_de_plane_check()
553 return -EINVAL; in malidp_de_plane_check()
560 if (new_plane_state->rotation != DRM_MODE_ROTATE_0) { in malidp_de_plane_check()
561 if (mp->layer->rot == ROTATE_NONE) in malidp_de_plane_check()
562 return -EINVAL; in malidp_de_plane_check()
563 if ((mp->layer->rot == ROTATE_COMPRESSED) && !(fb->modifier)) in malidp_de_plane_check()
564 return -EINVAL; in malidp_de_plane_check()
569 if ((fb->format->format == DRM_FORMAT_RGB888 || in malidp_de_plane_check()
570 fb->format->format == DRM_FORMAT_BGR888) && !(fb->modifier)) in malidp_de_plane_check()
571 return -EINVAL; in malidp_de_plane_check()
575 if (mp->layer->id == DE_SMART && fb->modifier) { in malidp_de_plane_check()
577 return -EINVAL; in malidp_de_plane_check()
580 ms->rotmem_size = 0; in malidp_de_plane_check()
581 if (new_plane_state->rotation & MALIDP_ROTATED_MASK) { in malidp_de_plane_check()
584 val = mp->hwdev->hw->rotmem_required(mp->hwdev, new_plane_state->crtc_w, in malidp_de_plane_check()
585 new_plane_state->crtc_h, in malidp_de_plane_check()
586 fb->format->format, in malidp_de_plane_check()
587 !!(fb->modifier)); in malidp_de_plane_check()
591 ms->rotmem_size = val; in malidp_de_plane_check()
595 if ((new_plane_state->alpha != DRM_BLEND_ALPHA_OPAQUE) && in malidp_de_plane_check()
597 fb->format->has_alpha) in malidp_de_plane_check()
598 return -EINVAL; in malidp_de_plane_check()
611 if (!mp->layer->stride_offset) in malidp_de_set_plane_pitches()
615 num_strides = (mp->hwdev->hw->features & in malidp_de_set_plane_pitches()
624 unsigned int block_h = drm_format_info_block_height(mp->base.state->fb->format, i); in malidp_de_set_plane_pitches()
626 malidp_hw_write(mp->hwdev, pitches[i] * block_h, in malidp_de_set_plane_pitches()
627 mp->layer->base + in malidp_de_set_plane_pitches()
628 mp->layer->stride_offset + i * 4); in malidp_de_set_plane_pitches()
636 1192, -401, -832,
642 1024, -352, -731,
648 1192, -218, -546,
654 1024, -192, -479,
660 1024, -165, -572,
666 1024, -168, -585,
680 malidp_hw_write(plane->hwdev, malidp_yuv2rgb_coeffs[enc][range][i], in malidp_de_set_color_encoding()
681 plane->layer->base + plane->layer->yuv2rgb_offset + in malidp_de_set_color_encoding()
692 if (!mp->layer->mmu_ctrl_offset) in malidp_de_set_mmu_control()
695 mmu_ctrl = malidp_calc_mmu_control_value(ms->mmu_prefetch_mode, in malidp_de_set_mmu_control()
697 ms->n_planes, in malidp_de_set_mmu_control()
698 ms->mmu_prefetch_pgsize); in malidp_de_set_mmu_control()
700 malidp_hw_write(mp->hwdev, mmu_ctrl, in malidp_de_set_mmu_control()
701 mp->layer->base + mp->layer->mmu_ctrl_offset); in malidp_de_set_mmu_control()
710 struct drm_plane *plane = &mp->base; in malidp_set_plane_base_addr()
711 bool afbc = fb->modifier ? true : false; in malidp_set_plane_base_addr()
713 ptr = mp->layer->ptr + (plane_index << 4); in malidp_set_plane_base_addr()
717 * framebuffer as per the plane's src_x, src_y co-ordinates (ie to in malidp_set_plane_base_addr()
723 dma_addr = drm_fb_dma_get_gem_addr(fb, plane->state, in malidp_set_plane_base_addr()
732 dma_addr = obj->dma_addr; in malidp_set_plane_base_addr()
735 malidp_hw_write(mp->hwdev, lower_32_bits(dma_addr), ptr); in malidp_set_plane_base_addr()
736 malidp_hw_write(mp->hwdev, upper_32_bits(dma_addr), ptr + 4); in malidp_set_plane_base_addr()
743 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_set_plane_afbc()
748 if (!mp->layer->afbc_decoder_offset) in malidp_de_set_plane_afbc()
751 if (!fb->modifier) { in malidp_de_set_plane_afbc()
752 malidp_hw_write(mp->hwdev, 0, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
757 src_w = plane->state->src_w >> 16; in malidp_de_set_plane_afbc()
758 src_h = plane->state->src_h >> 16; in malidp_de_set_plane_afbc()
759 src_x = plane->state->src_x >> 16; in malidp_de_set_plane_afbc()
760 src_y = plane->state->src_y >> 16; in malidp_de_set_plane_afbc()
762 val = ((fb->width - (src_x + src_w)) << MALIDP_AD_CROP_RIGHT_OFFSET) | in malidp_de_set_plane_afbc()
764 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
765 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_H); in malidp_de_set_plane_afbc()
767 val = ((fb->height - (src_y + src_h)) << MALIDP_AD_CROP_BOTTOM_OFFSET) | in malidp_de_set_plane_afbc()
769 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
770 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_V); in malidp_de_set_plane_afbc()
773 if (fb->modifier & AFBC_FORMAT_MOD_SPLIT) in malidp_de_set_plane_afbc()
775 if (fb->modifier & AFBC_FORMAT_MOD_YTR) in malidp_de_set_plane_afbc()
778 malidp_hw_write(mp->hwdev, val, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
787 struct malidp_plane_state *ms = to_malidp_plane_state(plane->state); in malidp_de_plane_update()
790 u16 pixel_alpha = new_state->pixel_blend_mode; in malidp_de_plane_update()
791 u8 plane_alpha = new_state->alpha >> 8; in malidp_de_plane_update()
794 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_plane_update()
802 if (fb->modifier) { in malidp_de_plane_update()
803 src_w = fb->width; in malidp_de_plane_update()
804 src_h = fb->height; in malidp_de_plane_update()
807 src_w = new_state->src_w >> 16; in malidp_de_plane_update()
808 src_h = new_state->src_h >> 16; in malidp_de_plane_update()
811 dest_w = new_state->crtc_w; in malidp_de_plane_update()
812 dest_h = new_state->crtc_h; in malidp_de_plane_update()
814 val = malidp_hw_read(mp->hwdev, mp->layer->base); in malidp_de_plane_update()
815 val = (val & ~LAYER_FORMAT_MASK) | ms->format; in malidp_de_plane_update()
816 malidp_hw_write(mp->hwdev, val, mp->layer->base); in malidp_de_plane_update()
818 for (i = 0; i < ms->n_planes; i++) in malidp_de_plane_update()
823 malidp_de_set_plane_pitches(mp, ms->n_planes, in malidp_de_plane_update()
824 new_state->fb->pitches); in malidp_de_plane_update()
826 if ((plane->state->color_encoding != old_state->color_encoding) || in malidp_de_plane_update()
827 (plane->state->color_range != old_state->color_range)) in malidp_de_plane_update()
828 malidp_de_set_color_encoding(mp, plane->state->color_encoding, in malidp_de_plane_update()
829 plane->state->color_range); in malidp_de_plane_update()
831 malidp_hw_write(mp->hwdev, LAYER_H_VAL(src_w) | LAYER_V_VAL(src_h), in malidp_de_plane_update()
832 mp->layer->base + MALIDP_LAYER_SIZE); in malidp_de_plane_update()
834 malidp_hw_write(mp->hwdev, LAYER_H_VAL(dest_w) | LAYER_V_VAL(dest_h), in malidp_de_plane_update()
835 mp->layer->base + MALIDP_LAYER_COMP_SIZE); in malidp_de_plane_update()
837 malidp_hw_write(mp->hwdev, LAYER_H_VAL(new_state->crtc_x) | in malidp_de_plane_update()
838 LAYER_V_VAL(new_state->crtc_y), in malidp_de_plane_update()
839 mp->layer->base + MALIDP_LAYER_OFFSET); in malidp_de_plane_update()
841 if (mp->layer->id == DE_SMART) { in malidp_de_plane_update()
846 malidp_hw_write(mp->hwdev, 1, in malidp_de_plane_update()
847 mp->layer->base + MALIDP550_LS_ENABLE); in malidp_de_plane_update()
848 malidp_hw_write(mp->hwdev, in malidp_de_plane_update()
850 mp->layer->base + MALIDP550_LS_R1_IN_SIZE); in malidp_de_plane_update()
856 val = malidp_hw_read(mp->hwdev, mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
860 if (new_state->rotation & DRM_MODE_ROTATE_MASK) in malidp_de_plane_update()
861 val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) << in malidp_de_plane_update()
863 if (new_state->rotation & DRM_MODE_REFLECT_X) in malidp_de_plane_update()
865 if (new_state->rotation & DRM_MODE_REFLECT_Y) in malidp_de_plane_update()
870 if (new_state->alpha != DRM_BLEND_ALPHA_OPAQUE) { in malidp_de_plane_update()
872 } else if (new_state->fb->format->has_alpha) { in malidp_de_plane_update()
886 if (new_state->crtc) { in malidp_de_plane_update()
888 to_malidp_crtc_state(new_state->crtc->state); in malidp_de_plane_update()
890 if (m->scaler_config.scale_enable && in malidp_de_plane_update()
891 m->scaler_config.plane_src_id == mp->layer->id) in malidp_de_plane_update()
898 malidp_hw_write(mp->hwdev, val, in malidp_de_plane_update()
899 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
907 malidp_hw_clearbits(mp->hwdev, in malidp_de_plane_disable()
909 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_disable()
926 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_de_planes_init()
929 unsigned long crtcs = BIT(drm->mode_config.num_crtc); in malidp_de_planes_init()
942 if (!(map->features & MALIDP_DEVICE_AFBC_SUPPORT_SPLIT)) { in malidp_de_planes_init()
957 formats = kcalloc(map->n_pixel_formats, sizeof(*formats), GFP_KERNEL); in malidp_de_planes_init()
959 ret = -ENOMEM; in malidp_de_planes_init()
963 for (i = 0; i < map->n_layers; i++) { in malidp_de_planes_init()
964 u8 id = map->layers[i].id; in malidp_de_planes_init()
967 for (n = 0, j = 0; j < map->n_pixel_formats; j++) { in malidp_de_planes_init()
968 if ((map->pixel_formats[j].layer & id) == id) in malidp_de_planes_init()
969 formats[n++] = map->pixel_formats[j].format; in malidp_de_planes_init()
987 drm_plane_helper_add(&plane->base, in malidp_de_planes_init()
989 plane->hwdev = malidp->dev; in malidp_de_planes_init()
990 plane->layer = &map->layers[i]; in malidp_de_planes_init()
992 drm_plane_create_alpha_property(&plane->base); in malidp_de_planes_init()
993 drm_plane_create_blend_mode_property(&plane->base, blend_caps); in malidp_de_planes_init()
1000 drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, flags); in malidp_de_planes_init()
1001 malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT, in malidp_de_planes_init()
1002 plane->layer->base + MALIDP_LAYER_COMPOSE); in malidp_de_planes_init()
1004 /* Attach the YUV->RGB property only to video layers */ in malidp_de_planes_init()
1006 /* default encoding for YUV->RGB is BT601 NARROW */ in malidp_de_planes_init()
1010 ret = drm_plane_create_color_properties(&plane->base, in malidp_de_planes_init()