drm/atmel-hlcdc: Use the alpha format field in drm_format_info

Now that the drm_format_info has a alpha field to tell if a format embeds
an alpha component in it, let's use it.

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/23518426a46320dd884465cebec0961f839f2972.1516617243.git-series.maxime.ripard@free-electrons.com
This commit is contained in:
Maxime Ripard 2017-12-22 15:31:27 +01:00
parent 4cc4e1b40f
commit e2e287fa4a
No known key found for this signature in database
GPG key ID: D2B4C094214DAF74

View file

@ -194,20 +194,6 @@ static int atmel_hlcdc_format_to_plane_mode(u32 format, u32 *mode)
return 0; return 0;
} }
static bool atmel_hlcdc_format_embeds_alpha(u32 format)
{
int i;
for (i = 0; i < sizeof(format); i++) {
char tmp = (format >> (8 * i)) & 0xff;
if (tmp == 'A')
return true;
}
return false;
}
static u32 heo_downscaling_xcoef[] = { static u32 heo_downscaling_xcoef[] = {
0x11343311, 0x11343311,
0x000000f7, 0x000000f7,
@ -377,13 +363,13 @@ atmel_hlcdc_plane_update_general_settings(struct atmel_hlcdc_plane *plane,
{ {
unsigned int cfg = ATMEL_HLCDC_LAYER_DMA_BLEN_INCR16 | state->ahb_id; unsigned int cfg = ATMEL_HLCDC_LAYER_DMA_BLEN_INCR16 | state->ahb_id;
const struct atmel_hlcdc_layer_desc *desc = plane->layer.desc; const struct atmel_hlcdc_layer_desc *desc = plane->layer.desc;
u32 format = state->base.fb->format->format; const struct drm_format_info *format = state->base.fb->format;
/* /*
* Rotation optimization is not working on RGB888 (rotation is still * Rotation optimization is not working on RGB888 (rotation is still
* working but without any optimization). * working but without any optimization).
*/ */
if (format == DRM_FORMAT_RGB888) if (format->format == DRM_FORMAT_RGB888)
cfg |= ATMEL_HLCDC_LAYER_DMA_ROTDIS; cfg |= ATMEL_HLCDC_LAYER_DMA_ROTDIS;
atmel_hlcdc_layer_write_cfg(&plane->layer, ATMEL_HLCDC_LAYER_DMA_CFG, atmel_hlcdc_layer_write_cfg(&plane->layer, ATMEL_HLCDC_LAYER_DMA_CFG,
@ -395,7 +381,7 @@ atmel_hlcdc_plane_update_general_settings(struct atmel_hlcdc_plane *plane,
cfg |= ATMEL_HLCDC_LAYER_OVR | ATMEL_HLCDC_LAYER_ITER2BL | cfg |= ATMEL_HLCDC_LAYER_OVR | ATMEL_HLCDC_LAYER_ITER2BL |
ATMEL_HLCDC_LAYER_ITER; ATMEL_HLCDC_LAYER_ITER;
if (atmel_hlcdc_format_embeds_alpha(format)) if (format->has_alpha)
cfg |= ATMEL_HLCDC_LAYER_LAEN; cfg |= ATMEL_HLCDC_LAYER_LAEN;
else else
cfg |= ATMEL_HLCDC_LAYER_GAEN | cfg |= ATMEL_HLCDC_LAYER_GAEN |
@ -566,7 +552,7 @@ atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state)
ovl_state = drm_plane_state_to_atmel_hlcdc_plane_state(ovl_s); ovl_state = drm_plane_state_to_atmel_hlcdc_plane_state(ovl_s);
if (!ovl_s->fb || if (!ovl_s->fb ||
atmel_hlcdc_format_embeds_alpha(ovl_s->fb->format->format) || ovl_s->fb->format->has_alpha ||
ovl_state->alpha != 255) ovl_state->alpha != 255)
continue; continue;
@ -769,7 +755,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
if ((state->crtc_h != state->src_h || state->crtc_w != state->src_w) && if ((state->crtc_h != state->src_h || state->crtc_w != state->src_w) &&
(!desc->layout.memsize || (!desc->layout.memsize ||
atmel_hlcdc_format_embeds_alpha(state->base.fb->format->format))) state->base.fb->format->has_alpha))
return -EINVAL; return -EINVAL;
if (state->crtc_x < 0 || state->crtc_y < 0) if (state->crtc_x < 0 || state->crtc_y < 0)