On Tue, Aug 06, 2019 at 06:31:56AM +0000, Lowry Li (Arm Technology China) wrote: > From: "Lowry Li (Arm Technology China)" <Lowry.Li@xxxxxxx> > > The drm_format_info doesn't have any cpp or block_size (both are zero) > information for arm only afbc format YU08/YU10. we need to compute it > by ourselves. > > Changes since v1: > 1. Removed redundant warning check in komeda_get_afbc_format_bpp(); > 2. Removed a redundant empty line; > 3. Rebased the branch. > > Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@xxxxxxx> > --- > .../gpu/drm/arm/display/komeda/komeda_format_caps.c | 19 +++++++++++++++++++ > .../gpu/drm/arm/display/komeda/komeda_format_caps.h | 3 +++ > .../gpu/drm/arm/display/komeda/komeda_framebuffer.c | 5 +++-- > 3 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c > index cd4d9f5..c9a1edb 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c > @@ -35,6 +35,25 @@ > return NULL; > } > > +u32 komeda_get_afbc_format_bpp(const struct drm_format_info *info, u64 modifier) > +{ > + u32 bpp; > + > + switch (info->format) { > + case DRM_FORMAT_YUV420_8BIT: > + bpp = 12; > + break; > + case DRM_FORMAT_YUV420_10BIT: > + bpp = 15; > + break; > + default: > + bpp = info->cpp[0] * 8; > + break; > + } > + > + return bpp; > +} > + > /* Two assumptions > * 1. RGB always has YTR > * 2. Tiled RGB always has SC > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h > index 3631910..32273cf 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h > @@ -97,6 +97,9 @@ static inline const char *komeda_get_format_name(u32 fourcc, u64 modifier) > komeda_get_format_caps(struct komeda_format_caps_table *table, > u32 fourcc, u64 modifier); > > +u32 komeda_get_afbc_format_bpp(const struct drm_format_info *info, > + u64 modifier); > + > u32 *komeda_get_layer_fourcc_list(struct komeda_format_caps_table *table, > u32 layer_type, u32 *n_fmts); > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > index 3b0a70e..1b01a62 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c > @@ -43,7 +43,7 @@ static int komeda_fb_create_handle(struct drm_framebuffer *fb, > struct drm_framebuffer *fb = &kfb->base; > const struct drm_format_info *info = fb->format; > struct drm_gem_object *obj; > - u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks; > + u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks, bpp; > u64 min_size; > > obj = drm_gem_object_lookup(file, mode_cmd->handles[0]); > @@ -88,8 +88,9 @@ static int komeda_fb_create_handle(struct drm_framebuffer *fb, > kfb->offset_payload = ALIGN(n_blocks * AFBC_HEADER_SIZE, > alignment_header); > > + bpp = komeda_get_afbc_format_bpp(info, fb->modifier); > kfb->afbc_size = kfb->offset_payload + n_blocks * > - ALIGN(info->cpp[0] * AFBC_SUPERBLK_PIXELS, > + ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8, > AFBC_SUPERBLK_ALIGNMENT); > min_size = kfb->afbc_size + fb->offsets[0]; > if (min_size > obj->size) { Looks good to me. Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@xxxxxxx> _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel