]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/komeda: Add rotation support on Komeda driver
authorLowry Li (Arm Technology China) <Lowry.Li@arm.com>
Mon, 22 Apr 2019 03:16:26 +0000 (04:16 +0100)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Wed, 19 Jun 2019 10:42:16 +0000 (11:42 +0100)
- Adds rotation property to plane.
- Komeda display rotation support diverges from the specific formats,
so need to check the user required rotation type with the format caps
and reject the commit if it can not be supported.
- In the layer validate flow, sets the rotation value to the layer
state. If r90 or r270, swap the width and height of the data flow
for next stage.

Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
drivers/gpu/drm/arm/display/komeda/komeda_plane.c

index bc3b2df361b9e7b25987176fab10d9e658acb0bf..96de22ecfa08b2e0a8c90969072bf339c941b1de 100644 (file)
@@ -79,6 +79,17 @@ struct komeda_format_caps_table {
 
 extern u64 komeda_supported_modifiers[];
 
+static inline const char *komeda_get_format_name(u32 fourcc, u64 modifier)
+{
+       struct drm_format_name_buf buf;
+       static char name[64];
+
+       snprintf(name, sizeof(name), "%s with modifier: 0x%llx.",
+                drm_get_format_name(fourcc, &buf), modifier);
+
+       return name;
+}
+
 const struct komeda_format_caps *
 komeda_get_format_caps(struct komeda_format_caps_table *table,
                       u32 fourcc, u64 modifier);
index db34ea26760c351b1b55ac7fceaf8604ebebbe0f..34737c0b8156ca044287870684215e6010209832 100644 (file)
@@ -339,6 +339,13 @@ komeda_layer_validate(struct komeda_layer *layer,
        /* update the data flow for the next stage */
        komeda_component_set_output(&dflow->input, &layer->base, 0);
 
+       /*
+        * The rotation has been handled by layer, so adjusted the data flow for
+        * the next stage.
+        */
+       if (drm_rotation_90_or_270(st->rot))
+               swap(dflow->in_h, dflow->in_w);
+
        return 0;
 }
 
index b86a517cf92f77186b877904ce06a15f083b9323..e55b7be9bbb0ca4cbfa4f1b94d64c1568042235a 100644 (file)
@@ -10,6 +10,7 @@
 #include <drm/drm_print.h>
 #include "komeda_dev.h"
 #include "komeda_kms.h"
+#include "komeda_framebuffer.h"
 
 static int
 komeda_plane_init_data_flow(struct drm_plane_state *st,
@@ -17,6 +18,7 @@ komeda_plane_init_data_flow(struct drm_plane_state *st,
 {
        struct komeda_plane_state *kplane_st = to_kplane_st(st);
        struct drm_framebuffer *fb = st->fb;
+       const struct komeda_format_caps *caps = to_kfb(fb)->format_caps;
 
        memset(dflow, 0, sizeof(*dflow));
 
@@ -39,6 +41,15 @@ komeda_plane_init_data_flow(struct drm_plane_state *st,
 
        dflow->en_img_enhancement = kplane_st->img_enhancement;
 
+       dflow->rot = drm_rotation_simplify(st->rotation, caps->supported_rots);
+       if (!has_bits(dflow->rot, caps->supported_rots)) {
+               DRM_DEBUG_ATOMIC("rotation(0x%x) isn't supported by %s.\n",
+                                dflow->rot,
+                                komeda_get_format_name(caps->fourcc,
+                                                       fb->modifier));
+               return -EINVAL;
+       }
+
        komeda_complete_data_flow_cfg(dflow);
 
        return 0;
@@ -301,6 +312,11 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
 
        drm_plane_helper_add(plane, &komeda_plane_helper_funcs);
 
+       err = drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
+                                                layer->supported_rots);
+       if (err)
+               goto cleanup;
+
        err = drm_plane_create_alpha_property(plane);
        if (err)
                goto cleanup;