From patchwork Tue Jan 22 11:06:22 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: 10775369 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 8DE5D17F0 for ; Tue, 22 Jan 2019 11:06:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 762862860A for ; Tue, 22 Jan 2019 11:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 673D02A0B0; Tue, 22 Jan 2019 11:06:28 +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 33AC02860A for ; Tue, 22 Jan 2019 11:06:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C9156EC8C; Tue, 22 Jan 2019 11:06:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40068.outbound.protection.outlook.com [40.107.4.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEB2F6EC8C for ; Tue, 22 Jan 2019 11:06:24 +0000 (UTC) Received: from DB6PR0801MB1990.eurprd08.prod.outlook.com (10.168.81.21) by DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Tue, 22 Jan 2019 11:06:22 +0000 Received: from DB6PR0801MB1990.eurprd08.prod.outlook.com ([fe80::b9be:3d28:78a2:6e33]) by DB6PR0801MB1990.eurprd08.prod.outlook.com ([fe80::b9be:3d28:78a2:6e33%2]) with mapi id 15.20.1537.031; Tue, 22 Jan 2019 11:06:22 +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 v2 5/5] drm/komeda: Add komeda_plane/plane_helper_funcs Thread-Topic: [PATCH v2 5/5] drm/komeda: Add komeda_plane/plane_helper_funcs Thread-Index: AQHUskKCF0KwCqI+2kmiQGQ+rCgcTg== Date: Tue, 22 Jan 2019 11:06:22 +0000 Message-ID: <20190122110431.5025-6-james.qian.wang@arm.com> References: <20190122110431.5025-1-james.qian.wang@arm.com> In-Reply-To: <20190122110431.5025-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: SYAPR01CA0021.ausprd01.prod.outlook.com (2603:10c6:1::33) To DB6PR0801MB1990.eurprd08.prod.outlook.com (2603:10a6:4:6c::21) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB1989; 6:546P6yePM7Uzq5fvXhQo2UexgFAVmk6bIzWvFc26303jB2aLmHPQmg7sY0DFixxmiKzAYk7qIZzgiGlqAHcHwpNwFk+L5j0OdG5IxrboCo93aMcuNJsASS0ZD5GYQwgFIxtoy2cCXc9ORdSwy5s/4HyE5CDnzWCe3AR1hL3oUzmciWAZbNfc8BqsI55zTaKhyej/P1uicpCCyJdidbZySyCcgcWKgLpgSocCOyHopo7FMqTArhqZEaWtcLp/BjTKbtSsUio/w5np2VQAzVxCU+eunPWZcj8TXsHYXw6w8AlU1LlJN4lrgiwRvGMg8mqJzVCy0b16eY8fu0TsygKWf3cjCgReWqbVSpd86aWhH49+n70mYD3FK7zKykz11oM71oZX9KSHlP5gtjqU0h7UGxsvUAVJ9PjUSf7On6J3zEn0ICsQVdk3hO7l3XCaKN9TntmHb0hAgNDv7OE6hgOjVw==; 5:8i4bynMZg9Y3MOmqpodaKmZ/R+XLcS0c3If8bdTtti7gF8+XBmtP0/464S76Zlk2XL4iB0t0okSXv9Y8jrOrVXefAPH264PbuA3HmuCJpGGVdtVYriLi7MbM1yx2pna9XW3h7M/crRVQWg46y7zi3n/E7Gw0CHLthDEL6BejycKsGneCRVeZw/LG8ENygkh6eUeA+63/sicSGQyxWhnKzg==; 7:1pJcMUQ0PqtgXfzSK7s4JWYb1y0+IGKXUcafVNQiCGWzWlcQmrpx7CzJplPTXt3avMYVxxqUPHLoVyupznlfncpfgmrV4lYz5e5T7VRiWL7qJY89AkgFNUFylxDmGiudYhGaH1n387enbBCNWH9XPw== x-ms-office365-filtering-correlation-id: aaeb320f-ff82-48b5-8979-08d68059a467 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB6PR0801MB1989; x-ms-traffictypediagnostic: DB6PR0801MB1989: nodisclaimer: True x-microsoft-antispam-prvs: x-forefront-prvs: 0925081676 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(346002)(396003)(376002)(39860400002)(189003)(199004)(4326008)(106356001)(105586002)(316002)(25786009)(2501003)(8936002)(256004)(14444005)(2201001)(1076003)(86362001)(52116002)(53936002)(2906002)(54906003)(110136005)(478600001)(14454004)(6512007)(99286004)(26005)(102836004)(55236004)(97736004)(36756003)(386003)(6506007)(66066001)(76176011)(68736007)(2616005)(476003)(81166006)(50226002)(186003)(11346002)(6116002)(3846002)(7736002)(486006)(103116003)(8676002)(6486002)(305945005)(71190400001)(71200400001)(6436002)(446003)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1989; H:DB6PR0801MB1990.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: LzeDApEPeEhZ9GzyzOcjBsF9sKDAazNwX9vPATiHauEXf8noTISPooTVrlMK7/osCjtQmNjGvxd/o4yndN6fVpenBzd0qT3E+BpazXyiPxFVVYdv1RWjb9uEoQ75lc30K3kTJNW8JYT2PW/wMDDh+hJWVVDgQ6dlCozLSADcCIiWx8KgSaYmLWRJN/eKBYVWbUqONlkRiW725EHa036VEWELwXnrMJ1MpoFleP+VlEHnJWmK5+bvgW/HwRTCQeRrgwwGOx0pFqJmZFvIYH5IOY95GoGj5ZmX1HobG1rvTa9HmhWZ3sPQ+Txy+0zeHFP0drZRs4/NagsCmExKVJK++H6FrLJO9K4rCJy4BQjodLzMy6dP9kWpDPvlyHLziwsqAQP/Y/t2U+DKFEtEBMgkGPvsqkyUB5MBH5/Yx5hu9Q0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: aaeb320f-ff82-48b5-8979-08d68059a467 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jan 2019 11:06:12.6946 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1989 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\)" , "malidp@foss.arm.com" , "Yiqi Kang \(Arm Technology China\)" , "thomas Sun \(Arm Technology China\)" , "Jin Gao \(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 From: "james qian wang (Arm Technology China)" Per komeda design KMS-plane maps to komeda layer input pipeline. komeda_plane_atomic_check is for building a komeda layer input pipeline. And KMS-plane is only a user of komeda resources. so there is no real HW update for plane, but all HW update will be handled in crtc->flush. v2: Rebase Signed-off-by: James Qian Wang (Arm Technology China) --- .../gpu/drm/arm/display/komeda/komeda_plane.c | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c index 0a4953a9a909..af51f0cc9c16 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c @@ -10,7 +10,82 @@ #include "komeda_dev.h" #include "komeda_kms.h" +static int +komeda_plane_init_data_flow(struct drm_plane_state *st, + struct komeda_data_flow_cfg *dflow) +{ + struct drm_framebuffer *fb = st->fb; + + memset(dflow, 0, sizeof(*dflow)); + + dflow->blending_zorder = st->zpos; + + /* 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; + dflow->layer_alpha = st->alpha >> 8; + + dflow->out_x = st->crtc_x; + dflow->out_y = st->crtc_y; + dflow->out_w = st->crtc_w; + dflow->out_h = st->crtc_h; + + dflow->in_x = st->src_x >> 16; + dflow->in_y = st->src_y >> 16; + dflow->in_w = st->src_w >> 16; + dflow->in_h = st->src_h >> 16; + + return 0; +} + +int komeda_plane_atomic_check(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct komeda_plane *kplane = to_kplane(plane); + struct komeda_plane_state *kplane_st = to_kplane_st(state); + struct komeda_layer *layer = kplane->layer; + struct drm_crtc_state *crtc_st; + struct komeda_crtc *kcrtc; + struct komeda_crtc_state *kcrtc_st; + struct komeda_data_flow_cfg dflow; + int err; + + if (!state->crtc || !state->fb) + return 0; + + crtc_st = drm_atomic_get_crtc_state(state->state, state->crtc); + if (!crtc_st->enable) { + DRM_DEBUG_ATOMIC("Cannot update plane on a disabled CRTC.\n"); + return -EINVAL; + } + + /* crtc is inactive, skip the resource assignment */ + if (!crtc_st->active) + return 0; + + kcrtc = to_kcrtc(state->crtc); + kcrtc_st = to_kcrtc_st(crtc_st); + + err = komeda_plane_init_data_flow(state, &dflow); + if (err) + return err; + + err = komeda_build_layer_data_flow(layer, kplane_st, kcrtc_st, &dflow); + + return err; +} + +/* plane doesn't represent a real HW, so there is no HW update for plane. + * komeda handles all the HW update in crtc->atomic_flush + */ +void komeda_plane_atomic_update(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ +} + static const struct drm_plane_helper_funcs komeda_plane_helper_funcs = { + .atomic_check = komeda_plane_atomic_check, + .atomic_update = komeda_plane_atomic_update, }; static void komeda_plane_destroy(struct drm_plane *plane) @@ -20,7 +95,60 @@ static void komeda_plane_destroy(struct drm_plane *plane) kfree(to_kplane(plane)); } +static void komeda_plane_reset(struct drm_plane *plane) +{ + struct komeda_plane_state *state; + struct komeda_plane *kplane = to_kplane(plane); + + if (plane->state) + __drm_atomic_helper_plane_destroy_state(plane->state); + + kfree(plane->state); + plane->state = NULL; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (state) { + state->base.rotation = DRM_MODE_ROTATE_0; + state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; + state->base.alpha = DRM_BLEND_ALPHA_OPAQUE; + state->base.zpos = kplane->layer->base.id; + plane->state = &state->base; + plane->state->plane = plane; + } +} + +static struct drm_plane_state * +komeda_plane_atomic_duplicate_state(struct drm_plane *plane) +{ + struct komeda_plane_state *new; + + if (WARN_ON(!plane->state)) + return NULL; + + new = kzalloc(sizeof(*new), GFP_KERNEL); + if (!new) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, &new->base); + + return &new->base; +} + +static void +komeda_plane_atomic_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + __drm_atomic_helper_plane_destroy_state(state); + kfree(to_kplane_st(state)); +} + static const struct drm_plane_funcs komeda_plane_funcs = { + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, + .destroy = komeda_plane_destroy, + .reset = komeda_plane_reset, + .atomic_duplicate_state = komeda_plane_atomic_duplicate_state, + .atomic_destroy_state = komeda_plane_atomic_destroy_state, }; /* for komeda, which is pipeline can be share between crtcs */