Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5625574rwb; Tue, 1 Aug 2023 05:49:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/P40Xuus+A3UWUBfz1TgH3Dmv7/k5f9zuAqb1CXzA8v5QBTfy4Z/M/2jKMbeY7HGzejuf X-Received: by 2002:a05:6870:612a:b0:1ba:466d:5f9e with SMTP id s42-20020a056870612a00b001ba466d5f9emr12844275oae.49.1690894167878; Tue, 01 Aug 2023 05:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690894167; cv=none; d=google.com; s=arc-20160816; b=lQdbMoFh+dgMxV2kFQi7HhaUEVHKy4Cbprb9m0UBnvlU/s7SO669qTcbl/Uks5KnzK zdRv6L+5ADgBFWzn+YmOIEjWvx1W/1aexlZWm3lebjAKdZbeU6/xDN86uWJpmO+NaYyF KnM3SyUS5ujY/ZQFxoO8tJOAQeXHqRECelxqJx6bWsP9AvLMXnX/Jh75O1o165Y4QZ9w qzi9oB7sboObm/L/cGUKRUvOAf7G6i5hl+8//suNr2Bd6BlULlX+vX7fLNDcWgTUmeq1 kgbHZwY+YF+E8HZFR/a63xTNqSWernymzZPdN+rckl0P+eKDzzDPwC1hjtNH27A75rLx ZUWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=k1HPpCK9XihCW4BUmhaa1RcFpOINSgJEK8QyedaHmRI=; fh=QnSQ1bJDQGk2HDDChCBX8yRjGxdar6vliWpO1zTD8r8=; b=Q6DI/1NIZ0EYK9ItBpfs7uvzbdCFpCHq3FxzwS4U5Mc/WJGhCxs8LaMSX4kUue3ZHy D1wmqW+bq+UqdsNaFLfgpm9R7B7c/W0Nn8CdGgl4BM6Jj5ybsGdzNej+oDTAzwDbmIzQ kYR4xr6TSyYt1TSD7Vl0wpM4MajmQnjDT2sK69qk0RqSwQcuXYaa19RdFuADNDSUA+lQ hiDFt1ls+HBqPTuvglTSpy8f5UqwnF67cCGMN5Q3afyO0V+YfAMloYEeECUf6rx7VLeK zu3sOdFaO87ns0FvzlEk7PoBgawZOdQs8vy1hH3JQ8MwdJrswuuYWzSO2a5dsVCv3bbl E44A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KqMPTZxl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a65480b000000b0056473d8c884si528366pgs.307.2023.08.01.05.49.14; Tue, 01 Aug 2023 05:49:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KqMPTZxl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231958AbjHAMG1 (ORCPT + 99 others); Tue, 1 Aug 2023 08:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234126AbjHAMGO (ORCPT ); Tue, 1 Aug 2023 08:06:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC496198C; Tue, 1 Aug 2023 05:06:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 698D06156E; Tue, 1 Aug 2023 12:06:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D416C433C7; Tue, 1 Aug 2023 12:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690891569; bh=s6YECtfwRWz+nn+e8dtTgfPFMuDS2G9MlvdIBiOeJvo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KqMPTZxlteTlX/vW0spt/IyKiVoPJYdtMr2lPEmfbuQmmwhfCC21GhGz+yQWZ8GEd RJW1lK9JN1DnTZJmTBwsvxtaZhWyU6xXWtVcaFKkx5L8z9m/yft5TuURPQh/J+IL7U PHvcq8WNXFxjoQvwm9S5/fvJ1NcSpL5MoMmgslMiMQ5qDQ3DsuwUBL05Ll8j2x2V0T Fmi+ZB4B+y3YDp+rI657BSpL6UbzABRJfYD+Czas7wkqLfwlQX9ueJGii9FSPJqKBt 8HPA9376cD/cny4bwakf8t2KopaxquTpFCkgWx5XoRWckS8rxRoyjnuCN7kB9nASW2 lheIZ7XLLLVog== Date: Tue, 1 Aug 2023 14:06:06 +0200 From: Maxime Ripard To: Keith Zhao Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Emil Renner Berthing , Paul Walmsley , Palmer Dabbelt , Albert Ou , Maarten Lankhorst , Thomas Zimmermann , Philipp Zabel , Sumit Semwal , christian.koenig@amd.com, Bjorn Andersson , Heiko Stuebner , Shawn Guo , Jagan Teki , Chris Morgan , Jack Zhu , Shengyang Chen , Changhuang Liang Subject: Re: [PATCH v1 v1 6/7] drm/vs: Add KMS crtc&plane Message-ID: <7sfzkc6b46izrfnhcoajllugfofh7otseocbiiftjx344hxiuf@jkjb5syqwo24> References: <20230801101030.2040-1-keith.zhao@starfivetech.com> <20230801101030.2040-7-keith.zhao@starfivetech.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="duuftomxabqjg5ol" Content-Disposition: inline In-Reply-To: <20230801101030.2040-7-keith.zhao@starfivetech.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --duuftomxabqjg5ol Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Tue, Aug 01, 2023 at 06:10:29PM +0800, Keith Zhao wrote: > +static int vs_crtc_atomic_set_property(struct drm_crtc *crtc, > + struct drm_crtc_state *state, > + struct drm_property *property, > + uint64_t val) > +{ > + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); > + struct vs_crtc_state *vs_crtc_state = to_vs_crtc_state(state); > + > + if (property == vs_crtc->sync_mode) > + vs_crtc_state->sync_mode = val; > + else if (property == vs_crtc->mmu_prefetch) > + vs_crtc_state->mmu_prefetch = val; > + else if (property == vs_crtc->bg_color) > + vs_crtc_state->bg_color = val; > + else if (property == vs_crtc->panel_sync) > + vs_crtc_state->sync_enable = val; > + else if (property == vs_crtc->dither) > + vs_crtc_state->dither_enable = val; > + else > + return -EINVAL; > + > + return 0; > +} > + > +static int vs_crtc_atomic_get_property(struct drm_crtc *crtc, > + const struct drm_crtc_state *state, > + struct drm_property *property, > + uint64_t *val) > +{ > + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); > + const struct vs_crtc_state *vs_crtc_state = > + container_of(state, const struct vs_crtc_state, base); > + > + if (property == vs_crtc->sync_mode) > + *val = vs_crtc_state->sync_mode; > + else if (property == vs_crtc->mmu_prefetch) > + *val = vs_crtc_state->mmu_prefetch; > + else if (property == vs_crtc->bg_color) > + *val = vs_crtc_state->bg_color; > + else if (property == vs_crtc->panel_sync) > + *val = vs_crtc_state->sync_enable; > + else if (property == vs_crtc->dither) > + *val = vs_crtc_state->dither_enable; > + else > + return -EINVAL; > + > + return 0; > +} Any new property needs to follow these requirements: https://docs.kernel.org/gpu/drm-kms.html#requirements https://docs.kernel.org/gpu/drm-uapi.html#open-source-userspace-requirements Also, most of them are suspicious, like sync_mode, mmu_prefetch, panel_sync or dither_enable. Why would you want userspace to change those ? > +static int vs_crtc_late_register(struct drm_crtc *crtc) > +{ > + return 0; > +} You can drop that. > +static int vs_crtc_enable_vblank(struct drm_crtc *crtc) > +{ > + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); > + > + vs_dc_enable_vblank(vs_crtc->dev, true); > + > + return 0; > +} > + > +static void vs_crtc_disable_vblank(struct drm_crtc *crtc) > +{ > + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); > + > + vs_dc_enable_vblank(vs_crtc->dev, false); > +} > + > +static const struct drm_crtc_funcs vs_crtc_funcs = { > + .set_config = drm_atomic_helper_set_config, > + .page_flip = drm_atomic_helper_page_flip, > + .reset = vs_crtc_reset, > + .atomic_duplicate_state = vs_crtc_atomic_duplicate_state, > + .atomic_destroy_state = vs_crtc_atomic_destroy_state, > + .atomic_set_property = vs_crtc_atomic_set_property, > + .atomic_get_property = vs_crtc_atomic_get_property, > + .late_register = vs_crtc_late_register, > + .enable_vblank = vs_crtc_enable_vblank, > + .disable_vblank = vs_crtc_disable_vblank, > +}; > + > +static u8 cal_pixel_bits(u32 bus_format) > +{ > + u8 bpp; > + > + switch (bus_format) { > + case MEDIA_BUS_FMT_RGB565_1X16: > + case MEDIA_BUS_FMT_UYVY8_1X16: > + bpp = 16; > + break; > + case MEDIA_BUS_FMT_RGB666_1X18: > + case MEDIA_BUS_FMT_RGB666_1X24_CPADHI: > + bpp = 18; > + break; > + case MEDIA_BUS_FMT_UYVY10_1X20: > + bpp = 20; > + break; > + case MEDIA_BUS_FMT_BGR888_1X24: > + case MEDIA_BUS_FMT_UYYVYY8_0_5X24: > + case MEDIA_BUS_FMT_YUV8_1X24: > + bpp = 24; > + break; > + case MEDIA_BUS_FMT_RGB101010_1X30: > + case MEDIA_BUS_FMT_UYYVYY10_0_5X30: > + case MEDIA_BUS_FMT_YUV10_1X30: > + bpp = 30; > + break; > + default: > + bpp = 24; > + break; > + } > + > + return bpp; > +} > + > +static bool vs_crtc_mode_fixup(struct drm_crtc *crtc, > + const struct drm_display_mode *mode, > + struct drm_display_mode *adjusted_mode) > +{ > + struct vs_crtc *vs_crtc = to_vs_crtc(crtc); > + > + return vs_dc_mode_fixup(vs_crtc->dev, mode, adjusted_mode); > +} You should be using atomic_check. Maxime --duuftomxabqjg5ol Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZMj1LgAKCRDj7w1vZxhR xcuiAQDVAHuCXQLiF4aho3J76b/1omEGtDLrJYqMFou4trNeDQEA9a+4doYz0r8T e4MChnbgb7U5q3ndReWR8iY6I4VZ/wc= =sNPG -----END PGP SIGNATURE----- --duuftomxabqjg5ol--