drm/amd/display: expand plane caps to include fp16 and scaling capability
authorJun Lei <Jun.Lei@amd.com>
Tue, 26 Mar 2019 21:32:59 +0000 (17:32 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 15 Apr 2019 05:19:54 +0000 (00:19 -0500)
[why]
there are some scaling capabilities such as fp16 which are known to be unsupported
on a given ASIC.  exposing these static capabilities allows much simpler implementation
for OS interfaces which require to report such static capabilities to reduce the
number of dynamic validation calls

[how]
refactor the existing plane caps to be more extensible, and add fp16 and scaling
capabilities

Signed-off-by: Jun Lei <Jun.Lei@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet Lakha@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c

index 89d30ee..dd93f7d 100644 (file)
@@ -2085,7 +2085,7 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
                if (!plane->blends_with_above || !plane->blends_with_below)
                        continue;
 
-               if (!plane->supports_argb8888)
+               if (!plane->pixel_format_support.argb8888)
                        continue;
 
                if (initialize_plane(dm, NULL, primary_planes + i,
@@ -4142,7 +4142,7 @@ static int get_plane_formats(const struct drm_plane *plane,
                        formats[num_formats++] = rgb_formats[i];
                }
 
-               if (plane_cap && plane_cap->supports_nv12)
+               if (plane_cap && plane_cap->pixel_format_support.nv12)
                        formats[num_formats++] = DRM_FORMAT_NV12;
                break;
 
@@ -4196,7 +4196,7 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
        }
 
        if (plane->type == DRM_PLANE_TYPE_PRIMARY &&
-           plane_cap && plane_cap->supports_nv12) {
+           plane_cap && plane_cap->pixel_format_support.nv12) {
                /* This only affects YUV formats. */
                drm_plane_create_color_properties(
                        plane,
index 704e543..ced53db 100644 (file)
@@ -66,8 +66,27 @@ struct dc_plane_cap {
        uint32_t blends_with_above : 1;
        uint32_t blends_with_below : 1;
        uint32_t per_pixel_alpha : 1;
-       uint32_t supports_argb8888 : 1;
-       uint32_t supports_nv12 : 1;
+       struct {
+               uint32_t argb8888 : 1;
+               uint32_t nv12 : 1;
+               uint32_t fp16 : 1;
+       } pixel_format_support;
+       // max upscaling factor x1000
+       // upscaling factors are always >= 1
+       // for example, 1080p -> 8K is 4.0, or 4000 raw value
+       struct {
+               uint32_t argb8888;
+               uint32_t nv12;
+               uint32_t fp16;
+       } max_upscale_factor;
+       // max downscale factor x1000
+       // downscale factors are always <= 1
+       // for example, 8K -> 1080p is 0.25, or 250 raw value
+       struct {
+               uint32_t argb8888;
+               uint32_t nv12;
+               uint32_t fp16;
+       } max_downscale_factor;
 };
 
 struct dc_caps {
index 767d37c..f38ea29 100644 (file)
@@ -380,7 +380,24 @@ static const struct resource_caps res_cap = {
 
 static const struct dc_plane_cap plane_cap = {
        .type = DC_PLANE_TYPE_DCE_RGB,
-       .supports_argb8888 = true,
+
+       .pixel_format_support = {
+                       .argb8888 = true,
+                       .nv12 = false,
+                       .fp16 = false
+       },
+
+       .max_upscale_factor = {
+                       .argb8888 = 16000,
+                       .nv12 = 1,
+                       .fp16 = 1
+       },
+
+       .max_downscale_factor = {
+                       .argb8888 = 250,
+                       .nv12 = 1,
+                       .fp16 = 1
+       }
 };
 
 #define CTX  ctx
index 7c4914b..d5ebc45 100644 (file)
@@ -397,14 +397,48 @@ static const struct dc_plane_cap plane_cap = {
                .blends_with_below = true,
                .blends_with_above = true,
                .per_pixel_alpha = 1,
-               .supports_argb8888 = true,
+
+               .pixel_format_support = {
+                               .argb8888 = true,
+                               .nv12 = false,
+                               .fp16 = false
+               },
+
+               .max_upscale_factor = {
+                               .argb8888 = 16000,
+                               .nv12 = 1,
+                               .fp16 = 1
+               },
+
+               .max_downscale_factor = {
+                               .argb8888 = 250,
+                               .nv12 = 1,
+                               .fp16 = 1
+               }
 };
 
 static const struct dc_plane_cap underlay_plane_cap = {
                .type = DC_PLANE_TYPE_DCE_UNDERLAY,
                .blends_with_above = true,
                .per_pixel_alpha = 1,
-               .supports_nv12 = true
+
+               .pixel_format_support = {
+                               .argb8888 = false,
+                               .nv12 = true,
+                               .fp16 = false
+               },
+
+               .max_upscale_factor = {
+                               .argb8888 = 1,
+                               .nv12 = 16000,
+                               .fp16 = 1
+               },
+
+               .max_downscale_factor = {
+                               .argb8888 = 1,
+                               .nv12 = 250,
+                               .fp16 = 1
+               }
 };
 
 #define CTX  ctx
index 2f28a74..afbc82b 100644 (file)
@@ -399,7 +399,24 @@ static const struct resource_caps polaris_11_resource_cap = {
 
 static const struct dc_plane_cap plane_cap = {
        .type = DC_PLANE_TYPE_DCE_RGB,
-       .supports_argb8888 = true,
+
+       .pixel_format_support = {
+                       .argb8888 = true,
+                       .nv12 = false,
+                       .fp16 = false
+       },
+
+       .max_upscale_factor = {
+                       .argb8888 = 16000,
+                       .nv12 = 1,
+                       .fp16 = 1
+       },
+
+       .max_downscale_factor = {
+                       .argb8888 = 250,
+                       .nv12 = 1,
+                       .fp16 = 1
+       }
 };
 
 #define CTX  ctx
index 01ea503..6d49c71 100644 (file)
@@ -456,7 +456,24 @@ static const struct resource_caps res_cap = {
 
 static const struct dc_plane_cap plane_cap = {
        .type = DC_PLANE_TYPE_DCE_RGB,
-       .supports_argb8888 = true,
+
+       .pixel_format_support = {
+                       .argb8888 = true,
+                       .nv12 = false,
+                       .fp16 = false
+       },
+
+       .max_upscale_factor = {
+                       .argb8888 = 16000,
+                       .nv12 = 1,
+                       .fp16 = 1
+       },
+
+       .max_downscale_factor = {
+                       .argb8888 = 250,
+                       .nv12 = 1,
+                       .fp16 = 1
+       }
 };
 
 static const struct dc_debug_options debug_defaults = {
index c7899ec..9569f3a 100644 (file)
@@ -389,7 +389,24 @@ static const struct resource_caps res_cap_83 = {
 
 static const struct dc_plane_cap plane_cap = {
        .type = DC_PLANE_TYPE_DCE_RGB,
-       .supports_argb8888 = true,
+
+       .pixel_format_support = {
+                       .argb8888 = true,
+                       .nv12 = false,
+                       .fp16 = false
+       },
+
+       .max_upscale_factor = {
+                       .argb8888 = 16000,
+                       .nv12 = 1,
+                       .fp16 = 1
+       },
+
+       .max_downscale_factor = {
+                       .argb8888 = 250,
+                       .nv12 = 1,
+                       .fp16 = 1
+       }
 };
 
 static const struct dce_dmcu_registers dmcu_regs = {
index 79f4fbb..7eccb54 100644 (file)
@@ -521,8 +521,24 @@ static const struct dc_plane_cap plane_cap = {
        .blends_with_above = true,
        .blends_with_below = true,
        .per_pixel_alpha = true,
-       .supports_argb8888 = true,
-       .supports_nv12 = true
+
+       .pixel_format_support = {
+                       .argb8888 = true,
+                       .nv12 = true,
+                       .fp16 = true
+       },
+
+       .max_upscale_factor = {
+                       .argb8888 = 16000,
+                       .nv12 = 16000,
+                       .fp16 = 1
+       },
+
+       .max_downscale_factor = {
+                       .argb8888 = 250,
+                       .nv12 = 250,
+                       .fp16 = 1
+       }
 };
 
 static const struct dc_debug_options debug_defaults_drv = {