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 */
80 * Replicate what the default ->reset hook does: free the state pointer and
86 struct malidp_plane_state *state = to_malidp_plane_state(plane->state); in malidp_plane_reset()
89 __drm_atomic_helper_plane_destroy_state(&state->base); in malidp_plane_reset()
91 plane->state = NULL; in malidp_plane_reset()
94 __drm_atomic_helper_plane_reset(plane, &state->base); in malidp_plane_reset()
102 if (!plane->state) in malidp_duplicate_plane_state()
109 m_state = to_malidp_plane_state(plane->state); in malidp_duplicate_plane_state()
110 __drm_atomic_helper_plane_duplicate_state(plane, &state->base); in malidp_duplicate_plane_state()
111 state->rotmem_size = m_state->rotmem_size; in malidp_duplicate_plane_state()
112 state->format = m_state->format; in malidp_duplicate_plane_state()
113 state->n_planes = m_state->n_planes; in malidp_duplicate_plane_state()
115 state->mmu_prefetch_mode = m_state->mmu_prefetch_mode; in malidp_duplicate_plane_state()
116 state->mmu_prefetch_pgsize = m_state->mmu_prefetch_pgsize; in malidp_duplicate_plane_state()
118 return &state->base; in malidp_duplicate_plane_state()
141 drm_printf(p, "\trotmem_size=%u\n", ms->rotmem_size); in malidp_plane_atomic_print_state()
142 drm_printf(p, "\tformat_id=%u\n", ms->format); in malidp_plane_atomic_print_state()
143 drm_printf(p, "\tn_planes=%u\n", ms->n_planes); in malidp_plane_atomic_print_state()
145 prefetch_mode_names[ms->mmu_prefetch_mode]); in malidp_plane_atomic_print_state()
146 drm_printf(p, "\tmmu_prefetch_pgsize=%d\n", ms->mmu_prefetch_pgsize); in malidp_plane_atomic_print_state()
154 struct malidp_drm *malidp = drm->dev_private; in malidp_format_mod_supported()
155 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_format_mod_supported()
205 if (info->num_planes != 1) { in malidp_format_mod_supported()
220 if (!(info->is_yuv) != !!(modifier & AFBC_FORMAT_MOD_YTR)) { in malidp_format_mod_supported()
222 info->is_yuv ? "disallowed" : "mandatory", in malidp_format_mod_supported()
223 info->is_yuv ? "YUV" : "RGB"); in malidp_format_mod_supported()
228 if (!info->is_yuv) { in malidp_format_mod_supported()
229 if (info->cpp[0] <= 2) { in malidp_format_mod_supported()
235 if ((info->hsub != 1) || (info->vsub != 1)) { in malidp_format_mod_supported()
237 (map->features & MALIDP_DEVICE_AFBC_YUV_420_10_SUPPORT_SPLIT))) { in malidp_format_mod_supported()
238 DRM_DEBUG_KMS("Formats which are sub-sampled should never be split\n"); in malidp_format_mod_supported()
245 if ((info->hsub == 1) || (info->vsub == 1)) { in malidp_format_mod_supported()
246 DRM_DEBUG_KMS("Formats which are not sub-sampled should not have CBR set\n"); in malidp_format_mod_supported()
257 return malidp_format_mod_supported(plane->dev, format, modifier); in malidp_format_mod_supported_per_plane()
275 drm_atomic_get_existing_crtc_state(state->state, state->crtc); in malidp_se_check_scaling()
281 return -EINVAL; in malidp_se_check_scaling()
290 if (state->rotation & MALIDP_ROTATED_MASK) { in malidp_se_check_scaling()
291 src_w = state->src_h >> 16; in malidp_se_check_scaling()
292 src_h = state->src_w >> 16; in malidp_se_check_scaling()
294 src_w = state->src_w >> 16; in malidp_se_check_scaling()
295 src_h = state->src_h >> 16; in malidp_se_check_scaling()
298 if ((state->crtc_w == src_w) && (state->crtc_h == src_h)) { in malidp_se_check_scaling()
300 mc->scaled_planes_mask &= ~(mp->layer->id); in malidp_se_check_scaling()
304 if (mp->layer->id & (DE_SMART | DE_GRAPHICS2)) in malidp_se_check_scaling()
305 return -EINVAL; in malidp_se_check_scaling()
307 mc->scaled_planes_mask |= mp->layer->id; in malidp_se_check_scaling()
316 mmu_dom = iommu_get_domain_for_dev(mp->base.dev->dev); in malidp_get_pgsize_bitmap()
318 return mmu_dom->pgsize_bitmap; in malidp_get_pgsize_bitmap()
334 for (i = 0; i < ms->n_planes; i++) { in malidp_check_pages_threshold()
340 obj = drm_gem_fb_get_obj(ms->base.fb, i); in malidp_check_pages_threshold()
343 if (dma_obj->sgt) in malidp_check_pages_threshold()
344 sgt = dma_obj->sgt; in malidp_check_pages_threshold()
346 sgt = obj->funcs->get_sg_table(obj); in malidp_check_pages_threshold()
351 sgl = sgt->sgl; in malidp_check_pages_threshold()
354 if (sgl->length < pgsize) { in malidp_check_pages_threshold()
355 if (!dma_obj->sgt) in malidp_check_pages_threshold()
362 if (!dma_obj->sgt) in malidp_check_pages_threshold()
370 * Check if it is possible to enable partial-frame MMU prefetch given the
427 * Select the preferred MMU prefetch mode. Full-frame prefetch is preferred as
428 * long as the framebuffer is all large pages. Otherwise partial-frame prefetch
437 /* get the full-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
448 pgsizes -= largest_pgsize; in malidp_mmu_prefetch_select_mode()
451 /* get the partial-frame prefetch page size(s) supported by the MMU */ in malidp_mmu_prefetch_select_mode()
454 if (malidp_partial_prefetch_supported(ms->base.fb->format->format, in malidp_mmu_prefetch_select_mode()
455 ms->base.fb->modifier, in malidp_mmu_prefetch_select_mode()
456 ms->base.rotation)) { in malidp_mmu_prefetch_select_mode()
492 if (!mp->layer->mmu_ctrl_offset) in malidp_de_prefetch_settings()
496 ms->mmu_prefetch_pgsize = malidp_get_pgsize_bitmap(mp); in malidp_de_prefetch_settings()
497 ms->mmu_prefetch_mode = in malidp_de_prefetch_settings()
498 malidp_mmu_prefetch_select_mode(ms, &ms->mmu_prefetch_pgsize); in malidp_de_prefetch_settings()
508 bool rotated = new_plane_state->rotation & MALIDP_ROTATED_MASK; in malidp_de_plane_check()
510 u16 pixel_alpha = new_plane_state->pixel_blend_mode; in malidp_de_plane_check()
514 if (!new_plane_state->crtc || WARN_ON(!new_plane_state->fb)) in malidp_de_plane_check()
517 fb = new_plane_state->fb; in malidp_de_plane_check()
519 ms->format = malidp_hw_get_format_id(&mp->hwdev->hw->map, in malidp_de_plane_check()
520 mp->layer->id, fb->format->format, in malidp_de_plane_check()
521 !!fb->modifier); in malidp_de_plane_check()
522 if (ms->format == MALIDP_INVALID_FORMAT_ID) in malidp_de_plane_check()
523 return -EINVAL; in malidp_de_plane_check()
525 ms->n_planes = fb->format->num_planes; in malidp_de_plane_check()
526 for (i = 0; i < ms->n_planes; i++) { in malidp_de_plane_check()
527 u8 alignment = malidp_hw_get_pitch_align(mp->hwdev, rotated); in malidp_de_plane_check()
529 if (((fb->pitches[i] * drm_format_info_block_height(fb->format, i)) in malidp_de_plane_check()
530 & (alignment - 1)) && !(fb->modifier)) { in malidp_de_plane_check()
532 fb->pitches[i], i); in malidp_de_plane_check()
533 return -EINVAL; in malidp_de_plane_check()
537 block_w = drm_format_info_block_width(fb->format, 0); in malidp_de_plane_check()
538 block_h = drm_format_info_block_height(fb->format, 0); in malidp_de_plane_check()
539 if (fb->width % block_w || fb->height % block_h) { in malidp_de_plane_check()
541 return -EINVAL; in malidp_de_plane_check()
543 if ((new_plane_state->src_x >> 16) % block_w || (new_plane_state->src_y >> 16) % block_h) { in malidp_de_plane_check()
545 return -EINVAL; in malidp_de_plane_check()
548 if ((new_plane_state->crtc_w > mp->hwdev->max_line_size) || in malidp_de_plane_check()
549 (new_plane_state->crtc_h > mp->hwdev->max_line_size) || in malidp_de_plane_check()
550 (new_plane_state->crtc_w < mp->hwdev->min_line_size) || in malidp_de_plane_check()
551 (new_plane_state->crtc_h < mp->hwdev->min_line_size)) in malidp_de_plane_check()
552 return -EINVAL; in malidp_de_plane_check()
556 * fb->pitches[1] == fb->pitches[2] since they don't have a in malidp_de_plane_check()
559 if (ms->n_planes == 3 && in malidp_de_plane_check()
560 !(mp->hwdev->hw->features & MALIDP_DEVICE_LV_HAS_3_STRIDES) && in malidp_de_plane_check()
561 (new_plane_state->fb->pitches[1] != new_plane_state->fb->pitches[2])) in malidp_de_plane_check()
562 return -EINVAL; in malidp_de_plane_check()
569 if (new_plane_state->rotation != DRM_MODE_ROTATE_0) { in malidp_de_plane_check()
570 if (mp->layer->rot == ROTATE_NONE) in malidp_de_plane_check()
571 return -EINVAL; in malidp_de_plane_check()
572 if ((mp->layer->rot == ROTATE_COMPRESSED) && !(fb->modifier)) in malidp_de_plane_check()
573 return -EINVAL; in malidp_de_plane_check()
578 if ((fb->format->format == DRM_FORMAT_RGB888 || in malidp_de_plane_check()
579 fb->format->format == DRM_FORMAT_BGR888) && !(fb->modifier)) in malidp_de_plane_check()
580 return -EINVAL; in malidp_de_plane_check()
584 if (mp->layer->id == DE_SMART && fb->modifier) { in malidp_de_plane_check()
586 return -EINVAL; in malidp_de_plane_check()
589 ms->rotmem_size = 0; in malidp_de_plane_check()
590 if (new_plane_state->rotation & MALIDP_ROTATED_MASK) { in malidp_de_plane_check()
593 val = mp->hwdev->hw->rotmem_required(mp->hwdev, new_plane_state->crtc_w, in malidp_de_plane_check()
594 new_plane_state->crtc_h, in malidp_de_plane_check()
595 fb->format->format, in malidp_de_plane_check()
596 !!(fb->modifier)); in malidp_de_plane_check()
600 ms->rotmem_size = val; in malidp_de_plane_check()
604 if ((new_plane_state->alpha != DRM_BLEND_ALPHA_OPAQUE) && in malidp_de_plane_check()
606 fb->format->has_alpha) in malidp_de_plane_check()
607 return -EINVAL; in malidp_de_plane_check()
620 if (!mp->layer->stride_offset) in malidp_de_set_plane_pitches()
624 num_strides = (mp->hwdev->hw->features & in malidp_de_set_plane_pitches()
633 unsigned int block_h = drm_format_info_block_height(mp->base.state->fb->format, i); in malidp_de_set_plane_pitches()
635 malidp_hw_write(mp->hwdev, pitches[i] * block_h, in malidp_de_set_plane_pitches()
636 mp->layer->base + in malidp_de_set_plane_pitches()
637 mp->layer->stride_offset + i * 4); in malidp_de_set_plane_pitches()
645 1192, -401, -832,
651 1024, -352, -731,
657 1192, -218, -546,
663 1024, -192, -479,
669 1024, -165, -572,
675 1024, -168, -585,
689 malidp_hw_write(plane->hwdev, malidp_yuv2rgb_coeffs[enc][range][i], in malidp_de_set_color_encoding()
690 plane->layer->base + plane->layer->yuv2rgb_offset + in malidp_de_set_color_encoding()
701 if (!mp->layer->mmu_ctrl_offset) in malidp_de_set_mmu_control()
704 mmu_ctrl = malidp_calc_mmu_control_value(ms->mmu_prefetch_mode, in malidp_de_set_mmu_control()
706 ms->n_planes, in malidp_de_set_mmu_control()
707 ms->mmu_prefetch_pgsize); in malidp_de_set_mmu_control()
709 malidp_hw_write(mp->hwdev, mmu_ctrl, in malidp_de_set_mmu_control()
710 mp->layer->base + mp->layer->mmu_ctrl_offset); in malidp_de_set_mmu_control()
719 struct drm_plane *plane = &mp->base; in malidp_set_plane_base_addr()
720 bool afbc = fb->modifier ? true : false; in malidp_set_plane_base_addr()
722 ptr = mp->layer->ptr + (plane_index << 4); in malidp_set_plane_base_addr()
726 * framebuffer as per the plane's src_x, src_y co-ordinates (ie to in malidp_set_plane_base_addr()
732 dma_addr = drm_fb_dma_get_gem_addr(fb, plane->state, in malidp_set_plane_base_addr()
741 dma_addr = obj->dma_addr; in malidp_set_plane_base_addr()
744 malidp_hw_write(mp->hwdev, lower_32_bits(dma_addr), ptr); in malidp_set_plane_base_addr()
745 malidp_hw_write(mp->hwdev, upper_32_bits(dma_addr), ptr + 4); in malidp_set_plane_base_addr()
752 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_set_plane_afbc()
757 if (!mp->layer->afbc_decoder_offset) in malidp_de_set_plane_afbc()
760 if (!fb->modifier) { in malidp_de_set_plane_afbc()
761 malidp_hw_write(mp->hwdev, 0, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
766 src_w = plane->state->src_w >> 16; in malidp_de_set_plane_afbc()
767 src_h = plane->state->src_h >> 16; in malidp_de_set_plane_afbc()
768 src_x = plane->state->src_x >> 16; in malidp_de_set_plane_afbc()
769 src_y = plane->state->src_y >> 16; in malidp_de_set_plane_afbc()
771 val = ((fb->width - (src_x + src_w)) << MALIDP_AD_CROP_RIGHT_OFFSET) | in malidp_de_set_plane_afbc()
773 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
774 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_H); in malidp_de_set_plane_afbc()
776 val = ((fb->height - (src_y + src_h)) << MALIDP_AD_CROP_BOTTOM_OFFSET) | in malidp_de_set_plane_afbc()
778 malidp_hw_write(mp->hwdev, val, in malidp_de_set_plane_afbc()
779 mp->layer->afbc_decoder_offset + MALIDP_AD_CROP_V); in malidp_de_set_plane_afbc()
782 if (fb->modifier & AFBC_FORMAT_MOD_SPLIT) in malidp_de_set_plane_afbc()
784 if (fb->modifier & AFBC_FORMAT_MOD_YTR) in malidp_de_set_plane_afbc()
787 malidp_hw_write(mp->hwdev, val, mp->layer->afbc_decoder_offset); in malidp_de_set_plane_afbc()
796 struct malidp_plane_state *ms = to_malidp_plane_state(plane->state); in malidp_de_plane_update()
799 u16 pixel_alpha = new_state->pixel_blend_mode; in malidp_de_plane_update()
800 u8 plane_alpha = new_state->alpha >> 8; in malidp_de_plane_update()
803 struct drm_framebuffer *fb = plane->state->fb; in malidp_de_plane_update()
811 if (fb->modifier) { in malidp_de_plane_update()
812 src_w = fb->width; in malidp_de_plane_update()
813 src_h = fb->height; in malidp_de_plane_update()
816 src_w = new_state->src_w >> 16; in malidp_de_plane_update()
817 src_h = new_state->src_h >> 16; in malidp_de_plane_update()
820 dest_w = new_state->crtc_w; in malidp_de_plane_update()
821 dest_h = new_state->crtc_h; in malidp_de_plane_update()
823 val = malidp_hw_read(mp->hwdev, mp->layer->base); in malidp_de_plane_update()
824 val = (val & ~LAYER_FORMAT_MASK) | ms->format; in malidp_de_plane_update()
825 malidp_hw_write(mp->hwdev, val, mp->layer->base); in malidp_de_plane_update()
827 for (i = 0; i < ms->n_planes; i++) in malidp_de_plane_update()
832 malidp_de_set_plane_pitches(mp, ms->n_planes, in malidp_de_plane_update()
833 new_state->fb->pitches); in malidp_de_plane_update()
835 if ((plane->state->color_encoding != old_state->color_encoding) || in malidp_de_plane_update()
836 (plane->state->color_range != old_state->color_range)) in malidp_de_plane_update()
837 malidp_de_set_color_encoding(mp, plane->state->color_encoding, in malidp_de_plane_update()
838 plane->state->color_range); in malidp_de_plane_update()
840 malidp_hw_write(mp->hwdev, LAYER_H_VAL(src_w) | LAYER_V_VAL(src_h), in malidp_de_plane_update()
841 mp->layer->base + MALIDP_LAYER_SIZE); in malidp_de_plane_update()
843 malidp_hw_write(mp->hwdev, LAYER_H_VAL(dest_w) | LAYER_V_VAL(dest_h), in malidp_de_plane_update()
844 mp->layer->base + MALIDP_LAYER_COMP_SIZE); in malidp_de_plane_update()
846 malidp_hw_write(mp->hwdev, LAYER_H_VAL(new_state->crtc_x) | in malidp_de_plane_update()
847 LAYER_V_VAL(new_state->crtc_y), in malidp_de_plane_update()
848 mp->layer->base + MALIDP_LAYER_OFFSET); in malidp_de_plane_update()
850 if (mp->layer->id == DE_SMART) { in malidp_de_plane_update()
855 malidp_hw_write(mp->hwdev, 1, in malidp_de_plane_update()
856 mp->layer->base + MALIDP550_LS_ENABLE); in malidp_de_plane_update()
857 malidp_hw_write(mp->hwdev, in malidp_de_plane_update()
859 mp->layer->base + MALIDP550_LS_R1_IN_SIZE); in malidp_de_plane_update()
865 val = malidp_hw_read(mp->hwdev, mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
869 if (new_state->rotation & DRM_MODE_ROTATE_MASK) in malidp_de_plane_update()
870 val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) << in malidp_de_plane_update()
872 if (new_state->rotation & DRM_MODE_REFLECT_X) in malidp_de_plane_update()
874 if (new_state->rotation & DRM_MODE_REFLECT_Y) in malidp_de_plane_update()
879 if (new_state->alpha != DRM_BLEND_ALPHA_OPAQUE) { in malidp_de_plane_update()
881 } else if (new_state->fb->format->has_alpha) { in malidp_de_plane_update()
895 if (new_state->crtc) { in malidp_de_plane_update()
897 to_malidp_crtc_state(new_state->crtc->state); in malidp_de_plane_update()
899 if (m->scaler_config.scale_enable && in malidp_de_plane_update()
900 m->scaler_config.plane_src_id == mp->layer->id) in malidp_de_plane_update()
907 malidp_hw_write(mp->hwdev, val, in malidp_de_plane_update()
908 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_update()
916 malidp_hw_clearbits(mp->hwdev, in malidp_de_plane_disable()
918 mp->layer->base + MALIDP_LAYER_CONTROL); in malidp_de_plane_disable()
934 struct malidp_drm *malidp = drm->dev_private; in malidp_de_planes_init()
935 const struct malidp_hw_regmap *map = &malidp->dev->hw->map; in malidp_de_planes_init()
938 unsigned long crtcs = BIT(drm->mode_config.num_crtc); in malidp_de_planes_init()
951 if (!(map->features & MALIDP_DEVICE_AFBC_SUPPORT_SPLIT)) { in malidp_de_planes_init()
966 formats = kcalloc(map->n_pixel_formats, sizeof(*formats), GFP_KERNEL); in malidp_de_planes_init()
968 ret = -ENOMEM; in malidp_de_planes_init()
972 for (i = 0; i < map->n_layers; i++) { in malidp_de_planes_init()
973 u8 id = map->layers[i].id; in malidp_de_planes_init()
977 ret = -ENOMEM; in malidp_de_planes_init()
982 for (n = 0, j = 0; j < map->n_pixel_formats; j++) { in malidp_de_planes_init()
983 if ((map->pixel_formats[j].layer & id) == id) in malidp_de_planes_init()
984 formats[n++] = map->pixel_formats[j].format; in malidp_de_planes_init()
993 ret = drm_universal_plane_init(drm, &plane->base, crtcs, in malidp_de_planes_init()
1001 drm_plane_helper_add(&plane->base, in malidp_de_planes_init()
1003 plane->hwdev = malidp->dev; in malidp_de_planes_init()
1004 plane->layer = &map->layers[i]; in malidp_de_planes_init()
1006 drm_plane_create_alpha_property(&plane->base); in malidp_de_planes_init()
1007 drm_plane_create_blend_mode_property(&plane->base, blend_caps); in malidp_de_planes_init()
1014 drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, flags); in malidp_de_planes_init()
1015 malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT, in malidp_de_planes_init()
1016 plane->layer->base + MALIDP_LAYER_COMPOSE); in malidp_de_planes_init()
1018 /* Attach the YUV->RGB property only to video layers */ in malidp_de_planes_init()
1020 /* default encoding for YUV->RGB is BT601 NARROW */ in malidp_de_planes_init()
1024 ret = drm_plane_create_color_properties(&plane->base, in malidp_de_planes_init()