From patchwork Mon Apr 15 07:09:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 10900167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60638139A for ; Mon, 15 Apr 2019 07:09:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46D9828812 for ; Mon, 15 Apr 2019 07:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B23D28820; Mon, 15 Apr 2019 07:09:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 37D4C28814 for ; Mon, 15 Apr 2019 07:09:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 324A78919A; Mon, 15 Apr 2019 07:09:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30056.outbound.protection.outlook.com [40.107.3.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id DECBF8919A for ; Mon, 15 Apr 2019 07:09:33 +0000 (UTC) Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB5151.eurprd08.prod.outlook.com (20.179.30.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.14; Mon, 15 Apr 2019 07:09:31 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::6ca6:1d85:8903:90d7]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::6ca6:1d85:8903:90d7%5]) with mapi id 15.20.1792.018; Mon, 15 Apr 2019 07:09:31 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH v1 6/6] drm/komeda: Add image enhancement support Thread-Topic: [PATCH v1 6/6] drm/komeda: Add image enhancement support Thread-Index: AQHU81orSKx7HPFRv0ONxxssyQ0uLA== Date: Mon, 15 Apr 2019 07:09:31 +0000 Message-ID: <20190415070828.24075-7-james.qian.wang@arm.com> References: <20190415070828.24075-1-james.qian.wang@arm.com> In-Reply-To: <20190415070828.24075-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK0P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::23) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 288645c2-dc33-4729-88f6-08d6c1714e46 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600140)(711020)(4605104)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR08MB5151; x-ms-traffictypediagnostic: VE1PR08MB5151: nodisclaimer: True x-microsoft-antispam-prvs: x-forefront-prvs: 000800954F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(396003)(39850400004)(376002)(136003)(346002)(366004)(199004)(189003)(446003)(11346002)(486006)(2616005)(14454004)(476003)(6486002)(52116002)(86362001)(4326008)(97736004)(102836004)(8936002)(5660300002)(6506007)(6512007)(386003)(53936002)(76176011)(103116003)(2201001)(1076003)(6436002)(55236004)(26005)(186003)(478600001)(7736002)(110136005)(2906002)(14444005)(5024004)(256004)(81156014)(105586002)(54906003)(81166006)(99286004)(316002)(3846002)(6116002)(106356001)(305945005)(8676002)(2501003)(66066001)(25786009)(71190400001)(71200400001)(50226002)(68736007)(36756003)(309714004)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5151; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 430P11KheWqxWpeNTbUQqnPfe2/VO73LssFnibie2MMmLU0qCt3GOhAJnMKM1uiMB82aqlu+PQU7QL7g2BnFU4EEOGEYPM+44UtatGBhApTQo51N+m3WPOS0/d32fEEQUMLSGkqkZP6W6TZjjZNUHrgP20BhaeC2uItR1y/x+7qaxIrsSGOeEkgsQc2k+JZj5vVoFSlaE1Tzph+ZfZqeUKVkPyWGkZuvofYEFDMrDwE8D/WCfn3DwBYPvGzuqDV5jRm6INPc0BEK4bEMHXuiqNtbNTO48DhcfsAgbnXkC+Ch/KDzJXlz7IOqsBILettauG7yBTra4Ht9xXXqKg9dar08Qo/jugbFOcUdiQwYkAE6J/XHtV7U+iC2GXXuuPWkCr3c7WFSr34BUqRS4Kq/+wsLo1HJClrVh0O+8OBHizY= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 288645c2-dc33-4729-88f6-08d6c1714e46 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2019 07:09:31.1096 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5151 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H681B3umMbytc//z8YXxpXKvOwb3FYghhdtdj6v3BMM=; b=cbKnB2NCKlkchTEo5drg8WLaAtvCzwCX54APWFr5tWLp4bdUAAXmNGV9UN/ukt1WEffX0ZtchXxN9rJK6N9wFiOxPicMgY0FPPKo5GjCP+jZPoYiy9GPdGnDQ7bNrj9XCZhDDQkHkdZI4Syikmud3iz8Bru7azlQeIPfIc0WQJc= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Besides scaling, Arm display scaler also can support image enhancement. For support it, Add a new property "img_enhancement" to plane, then user can turn on/off it by this property, and kernel follow user's requirement to maitain the state and enable/disable the real HW image enhancement. Signed-off-by: James Qian Wang (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 1 + .../gpu/drm/arm/display/komeda/komeda_kms.h | 6 +- .../drm/arm/display/komeda/komeda_pipeline.h | 6 +- .../display/komeda/komeda_pipeline_state.c | 3 +- .../gpu/drm/arm/display/komeda/komeda_plane.c | 75 ++++++++++++++++++- 5 files changed, 84 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c index bf214dc9e372..21d2b3a5c630 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -610,6 +610,7 @@ static void d71_scaler_update(struct komeda_component *c, ctrl = 0; ctrl |= st->en_scaling ? SC_CTRL_SCL : 0; ctrl |= st->en_alpha ? SC_CTRL_AP : 0; + ctrl |= st->en_img_enhancement ? SC_CTRL_IENH : 0; malidp_write32(reg, BLK_CONTROL, ctrl); malidp_write32(reg, BLK_INPUT_ID0, to_d71_input_id(&state->inputs[0])); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index db59a9042beb..e6e059f2af52 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -32,6 +32,9 @@ struct komeda_plane { * Layers with same capabilities. */ struct komeda_layer *layer; + + /** @prop_img_enhancement: for on/off image enhancement */ + struct drm_property *prop_img_enhancement; }; /** @@ -44,7 +47,8 @@ struct komeda_plane_state { /** @base: &drm_plane_state */ struct drm_plane_state base; - /* private properties */ + /* @img_enhancement: on/off image enhancement */ + u8 img_enhancement : 1; }; /** diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index b26c8552a2d1..a32a8d697f34 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -254,7 +254,8 @@ struct komeda_scaler_state { u16 hsize_in, vsize_in; u16 hsize_out, vsize_out; u8 en_scaling : 1, - en_alpha : 1; /* enable alpha processing */ + en_alpha : 1, /* enable alpha processing */ + en_img_enhancement : 1; }; struct komeda_compiz { @@ -313,7 +314,8 @@ struct komeda_data_flow_cfg { u32 rot; int blending_zorder; u8 pixel_blend_mode, layer_alpha; - u8 needs_scaling : 1; + u8 needs_scaling : 1, + needs_img_enhancement : 1; }; /* struct komeda_pipeline_funcs */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c index 53eb40941281..2430388a78c3 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -455,7 +455,7 @@ komeda_scaler_validate(void *user, struct komeda_scaler *scaler; int err = 0; - if (!dflow->needs_scaling) + if (!(dflow->needs_scaling || dflow->needs_img_enhancement)) return 0; scaler = komeda_component_get_avail_scaler(dflow->input.component, @@ -483,6 +483,7 @@ komeda_scaler_validate(void *user, st->en_scaling = dflow->needs_scaling; /* Enable alpha processing if the next stage needs the pixel alpha */ st->en_alpha = dflow->pixel_blend_mode != DRM_MODE_BLEND_PIXEL_NONE; + st->en_img_enhancement = dflow->needs_img_enhancement; komeda_component_add_input(&st->base, &dflow->input, 0); komeda_component_set_output(&dflow->input, &scaler->base, 0); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c index 5de462172151..fa455665aa77 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c @@ -14,6 +14,7 @@ static int komeda_plane_init_data_flow(struct drm_plane_state *st, struct komeda_data_flow_cfg *dflow) { + struct komeda_plane_state *kplane_st = to_kplane_st(st); struct drm_framebuffer *fb = st->fb; memset(dflow, 0, sizeof(*dflow)); @@ -22,7 +23,7 @@ komeda_plane_init_data_flow(struct drm_plane_state *st, /* if format doesn't have alpha, fix blend mode to PIXEL_NONE */ dflow->pixel_blend_mode = fb->format->has_alpha ? - st->pixel_blend_mode : DRM_MODE_BLEND_PIXEL_NONE; + st->pixel_blend_mode : DRM_MODE_BLEND_PIXEL_NONE; dflow->layer_alpha = st->alpha >> 8; dflow->out_x = st->crtc_x; @@ -35,6 +36,8 @@ komeda_plane_init_data_flow(struct drm_plane_state *st, dflow->in_w = st->src_w >> 16; dflow->in_h = st->src_h >> 16; + dflow->needs_img_enhancement = kplane_st->img_enhancement; + komeda_complete_data_flow_cfg(dflow); return 0; @@ -130,7 +133,7 @@ static void komeda_plane_reset(struct drm_plane *plane) static struct drm_plane_state * komeda_plane_atomic_duplicate_state(struct drm_plane *plane) { - struct komeda_plane_state *new; + struct komeda_plane_state *new, *old; if (WARN_ON(!plane->state)) return NULL; @@ -141,6 +144,10 @@ komeda_plane_atomic_duplicate_state(struct drm_plane *plane) __drm_atomic_helper_plane_duplicate_state(plane, &new->base); + old = to_kplane_st(plane->state); + + new->img_enhancement = old->img_enhancement; + return &new->base; } @@ -152,6 +159,40 @@ komeda_plane_atomic_destroy_state(struct drm_plane *plane, kfree(to_kplane_st(state)); } +static int +komeda_plane_atomic_get_property(struct drm_plane *plane, + const struct drm_plane_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct komeda_plane *kplane = to_kplane(plane); + struct komeda_plane_state *st = to_kplane_st(state); + + if (property == kplane->prop_img_enhancement) + *val = st->img_enhancement; + else + return -EINVAL; + + return 0; +} + +static int +komeda_plane_atomic_set_property(struct drm_plane *plane, + struct drm_plane_state *state, + struct drm_property *property, + uint64_t val) +{ + struct komeda_plane *kplane = to_kplane(plane); + struct komeda_plane_state *st = to_kplane_st(state); + + if (property == kplane->prop_img_enhancement) + st->img_enhancement = !!val; + else + return -EINVAL; + + return 0; +} + static bool komeda_plane_format_mod_supported(struct drm_plane *plane, u32 format, u64 modifier) @@ -171,9 +212,33 @@ static const struct drm_plane_funcs komeda_plane_funcs = { .reset = komeda_plane_reset, .atomic_duplicate_state = komeda_plane_atomic_duplicate_state, .atomic_destroy_state = komeda_plane_atomic_destroy_state, + .atomic_get_property = komeda_plane_atomic_get_property, + .atomic_set_property = komeda_plane_atomic_set_property, .format_mod_supported = komeda_plane_format_mod_supported, }; +static int +komeda_plane_create_layer_properties(struct komeda_plane *kplane, + struct komeda_layer *layer) +{ + struct drm_device *drm = kplane->base.dev; + struct drm_plane *plane = &kplane->base; + struct drm_property *prop = NULL; + + /* property: layer image_enhancement */ + if (layer->base.supported_outputs & KOMEDA_PIPELINE_SCALERS) { + prop = drm_property_create_bool(drm, DRM_MODE_PROP_ATOMIC, + "img_enhancement"); + if (!prop) + return -ENOMEM; + + drm_object_attach_property(&plane->base, prop, 0); + kplane->prop_img_enhancement = prop; + } + + return 0; +} + /* for komeda, which is pipeline can be share between crtcs */ static u32 get_possible_crtcs(struct komeda_kms_dev *kms, struct komeda_pipeline *pipe) @@ -241,11 +306,15 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, err = drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PIXEL_NONE) | - BIT(DRM_MODE_BLEND_PREMULTI) | + BIT(DRM_MODE_BLEND_PREMULTI) | BIT(DRM_MODE_BLEND_COVERAGE)); if (err) goto cleanup; + err = komeda_plane_create_layer_properties(kplane, layer); + if (err) + goto cleanup; + return 0; cleanup: komeda_plane_destroy(plane);