Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp752070lqd; Wed, 24 Apr 2024 16:26:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8T9pGbiZeKfDnse8TJ9R6PCjtaMuSQmQVIhePqQYDl4CYCsR8KX/CXa/w4ar3QHFBuzDtsOyAF0cm+KHEhusxyS4qN7e4jGTG6GYyVw== X-Google-Smtp-Source: AGHT+IGqdzNx2AkSFaox5wWTNjEJ+Tnc0/SZUbdQNwh81NeH/DV/9p9RhwdWv0gJQm9LTR2V8rbI X-Received: by 2002:a05:6a00:230a:b0:6ea:b9a1:63d7 with SMTP id h10-20020a056a00230a00b006eab9a163d7mr4435457pfh.10.1714001165332; Wed, 24 Apr 2024 16:26:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714001165; cv=pass; d=google.com; s=arc-20160816; b=jxtTJggSn61MPLYUYCHATsaXZ7APCJBkkvIDMaMpY4d88xzVSbNOGXZSHgIhzDtKmj rf1g5dOahx/gl7GhP8UCsG8NIziU7v7UVeaIXGIFBy8zOZ6B0m3WC0II+gS6jGwt8zO3 D5o1JhMfJVaqyhQq2KNMuJl9h5nRe8n0/kPQUWBrVpb6uX/HbcPKZgQYx4vHzSR9EGl+ kfwKoVHw8p9fxXN+lfCB7GAH9KdoDsntQ2McESpdbGhAVm1wjAylzjMZAChuxXU+J+FM oKxlM8MTA2BQakoHGuoLlcMkpz0TYjDeziNYjS5miVVPiZ3rwtZl5rmYfG8QkFZCBnfQ X6Lg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=1qmcwM8RwSJ8RvR8mUmf7ZCMdq1Mj/o54DavtjLG99s=; fh=sQPKsdT4HvBoFSPkHj0Po/fjDR3wX/j/Q7QUzDtBKws=; b=IX/PBmMVxzRWPDFEI33r0n25xBcXKCmaBGP1esYdZ/9pDubJlsTHE6nPe5hwAP8BUi g4ImRygDboWdIOoxSm/LvPhLCmRO1pTAIzVc9XiAnIPJWE5sAo4tx8qK1FDbadRGkkQ6 yopUgJ3I+d3GTo8b2Kx+hNad/tvxWgzp3d+MiVRsiiozCZ6AA59X1NqAHLuqls6LhSIf ZBOkAj0XSf+WU2KSnzkxlDZGqCy3kQYL15sY8kR6ExtM0IuYsnb/PNdcKwC4VOkyXeeZ w93Mu7LIl99ji8IgX2n2WMOuWBZD3jaU6pxtixBICtrE3xzk+GZ0sOconiEtAhmsxMbs gDFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="DLCey4c/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b7-20020a056a000a8700b006eccec776c3si12538046pfl.377.2024.04.24.16.26.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="DLCey4c/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7B3F228532A for ; Wed, 24 Apr 2024 23:25:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E973916F0E2; Wed, 24 Apr 2024 23:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DLCey4c/" Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 424DD156964 for ; Wed, 24 Apr 2024 23:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714001126; cv=none; b=LHMTq31jDHoPNTf/9OLgylomyJ+iMGEFyDDRtePgxkHDQvCi4jMsGIheA/VgG/GPXTg/qKn3nf/oX42ogD44nPvIJ3Ah1cooVlHgqeisNBFps2MIDiLu3ldo0Px+LZkDQl+EfgFLfkLFvDG62hsFkY4NG8qXmwg5AFSp3SM3fqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714001126; c=relaxed/simple; bh=w82ER0IflDrSeOEkY+ItZ9K207uzmYQ+tSNVV9wr/sI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=tB3u06sSxfuMHEE8+8lXkfrMBujTzhn5brpgsHPbYkX+vI6fadVciQiIa0O/i4Via9IZgTAkrX29YhAT1uCfjEhY+JhcOgplQziUPtNG5+CsmTrNpZxYiWankWVhzpT9yyNcZogfRRPjBBtEii9gxl0DImEJg1BTQGSFjNvHFpE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DLCey4c/; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-439b1c72676so105951cf.1 for ; Wed, 24 Apr 2024 16:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714001124; x=1714605924; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1qmcwM8RwSJ8RvR8mUmf7ZCMdq1Mj/o54DavtjLG99s=; b=DLCey4c/ELKypx0LIOrQEJWfxb8iu6/gZ59KA1wKK0Q2KA32sxjjz8WXvAVa5PgShw ZHXadfG897dga0007ttbPgVVX/KKVCjQoYjHRheT3aeraTt/nssDx+Fb/U9DnBaXtQ6j urdBV3IHeCpy0l/Urp1B6vGPWWQW8YfZE9bUeW+rsV2vwV/UWERRJgjftOu9i4ZSNniX 1V3AGthCSBeC6vWYnU6PYhEsClBbaxBfjivOm+0D/ya7s9t70weSy1zf8wG1Qqfdmr4j plEcUF2xDkeHP9f1XoWI0uCvsRbdmEO+L+aCVkm21TJS30rq8Lk9pULkhKhyusAtZ/0u hSgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714001124; x=1714605924; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1qmcwM8RwSJ8RvR8mUmf7ZCMdq1Mj/o54DavtjLG99s=; b=tZ5W+qQp7vY0tBenWPVoKROzqa9ckw1kzq0FW6MyBjnncf6JIbPRrHjvTtMpZW/tER okiumPSGFz37WAKa4oSQDtblgTubv2SR81BnQC3wsmsOeKOa2DZxJulrWffcwMBvzK6J lEVGDtigsbSjT9kVexqbk4+60k03ppoub5QAF2HVwHTSSS0D+JVosMaD4ibd1un5JKwK KBHs2FpRL0oWf39u8QLgqpzgzmGADDdYJj4fD9fn2nNqIOKDxbDXldjGibptT7Q9d3YP dYgryYHAU1teBZAOJmy2rqWHmj8tej+yU1DxHtrYUjdzj3bBohqZlVWBbbuP9uue2pw7 ZqKQ== X-Forwarded-Encrypted: i=1; AJvYcCX/Ih1/tl8dER2rc4GCi/WlIeu85O4z1qijuoiaJn0e2/5H+WHT86NOZ0fcBzGyCDh0mWeum6qd0Y7LpwA/A4G9VElPt6gh994FOK0G X-Gm-Message-State: AOJu0YzdmyQUPpz5pMXCD0w1dmYBobju3U+kEMaYxMQCt9+w3hWYMYCx vUKHIOKq17s37mPGK4102+iJi2RGqjCV5QXtfwq5i8O4scqTBp4w8iPLrY/6TwWX8mNnsNS7Ttl wCcuaZrAdaQ4b4TpiG3Pkdir5Sz2AKV6/PQST X-Received: by 2002:ac8:6604:0:b0:437:816e:48e5 with SMTP id c4-20020ac86604000000b00437816e48e5mr47052qtp.29.1714001123922; Wed, 24 Apr 2024 16:25:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240418081548.12160-1-lvzhaoxiong@huaqin.corp-partner.google.com> <20240418081548.12160-3-lvzhaoxiong@huaqin.corp-partner.google.com> In-Reply-To: From: Doug Anderson Date: Wed, 24 Apr 2024 16:25:07 -0700 Message-ID: Subject: Re: [PATCH v1 2/2] drm/panel: kd101ne3: add new panel driver To: Dmitry Baryshkov Cc: Hsin-Yi Wang , lvzhaoxiong , mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, cong yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, Apr 24, 2024 at 3:51=E2=80=AFPM Dmitry Baryshkov wrote: > > On Thu, 25 Apr 2024 at 01:15, Hsin-Yi Wang wrote: > > > > On Wed, Apr 24, 2024 at 2:49=E2=80=AFPM Dmitry Baryshkov > > wrote: > > > > > > On Thu, 25 Apr 2024 at 00:04, Doug Anderson wro= te: > > > > > > > > Hi, > > > > > > > > On Tue, Apr 23, 2024 at 2:20=E2=80=AFPM Dmitry Baryshkov > > > > wrote: > > > > > > > > > > On Tue, Apr 23, 2024 at 01:41:59PM -0700, Doug Anderson wrote: > > > > > > Hi, > > > > > > > > > > > > On Tue, Apr 23, 2024 at 11:10=E2=80=AFAM Hsin-Yi Wang wrote: > > > > > > > > > > > > > > > > > > +#define _INIT_DCS_CMD(...) { \ > > > > > > > > > > > + .type =3D INIT_DCS_CMD, \ > > > > > > > > > > > + .len =3D sizeof((char[]){__VA_ARGS__}), \ > > > > > > > > > > > + .data =3D (char[]){__VA_ARGS__} } > > > > > > > > > > > + > > > > > > > > > > > +#define _INIT_DELAY_CMD(...) { \ > > > > > > > > > > > + .type =3D DELAY_CMD,\ > > > > > > > > > > > + .len =3D sizeof((char[]){__VA_ARGS__}), \ > > > > > > > > > > > + .data =3D (char[]){__VA_ARGS__} } > > > > > > > > > > > > > > > > > > > > This is the third panel driver using the same appoach. = Can you use > > > > > > > > > > mipi_dsi_generic_write_seq() instead of the huge table?= Or if you prefer > > > > > > > > > > the table, we should extract this framework to a common= helper. > > > > > > > > > > (my preference is shifted towards mipi_dsi_generic_writ= e_seq()). > > > > > > > > > > > > > > > > > > > The drawback of mipi_dsi_generic_write_seq() is that it c= an cause the > > > > > > > > > kernel size grows a lot since every sequence will be expa= nded. > > > > > > > > > > > > > > > > > > Similar discussion in here: > > > > > > > > > https://lore.kernel.org/dri-devel/CAD=3DFV=3DWju3WS45=3DE= pXMUg7FjYDh3-=3Dmvm_jS7TF1tsaAzbb4Uw@mail.gmail.com/ > > > > > > > > > > > > > > > > > > This patch would increase the module size from 157K to 57= 2K. > > > > > > > > > scripts/bloat-o-meter shows chg +235.95%. > > > > > > > > > > > > > > > > > > So maybe the common helper is better regarding the kernel= module size? > > > > > > > > > > > > > > > > Yes, let's get a framework done in a useful way. > > > > > > > > I'd say, drop the _INIT_DELAY_CMD. msleep() and usleep_rang= e() should be > > > > > > > > used instead (and it's up to the developer to select correc= t delay > > > > > > > > function). > > > > > > > > > > > > > > > > > > > > > > > > > > > > + > > > > > > > > > > > +static const struct panel_init_cmd kingdisplay_kd101= ne3_init_cmd[] =3D { > > > > > > > > > > > + _INIT_DELAY_CMD(50), > > > > > > > > > > > + _INIT_DCS_CMD(0xE0, 0x00), > > > > > > > > > > > > > > > > [skipped the body of the table] > > > > > > > > > > > > > > > > > > > + _INIT_DCS_CMD(0x0E, 0x48), > > > > > > > > > > > + > > > > > > > > > > > + _INIT_DCS_CMD(0xE0, 0x00), > > > > > > > > > > > > > > > > > > > + _INIT_DCS_CMD(0X11), > > > > > > > > > > > > > > > > Also, at least this is mipi_dsi_dcs_exit_sleep_mode(). > > > > > > > > > > > > > > > > > > > + /* T6: 120ms */ > > > > > > > > > > > + _INIT_DELAY_CMD(120), > > > > > > > > > > > + _INIT_DCS_CMD(0X29), > > > > > > > > > > > > > > > > And this is mipi_dsi_dcs_set_display_on(). > > > > > > > > > > > > > > > > Having a single table enourages people to put known command= s into the > > > > > > > > table, the practice that must be frowned upon and forbidden= . > > > > > > > > > > > > > > > > We have functions for some of the standard DCS commands. So= , maybe > > > > > > > > instead of adding a single-table based approach we can impr= ove > > > > > > > > mipi_dsi_generic_write_seq() to reduce the bloat. E.g. by m= oving the > > > > > > > > error handling to a common part of enable() / prepare() fun= ction. > > > > > > > > > > > > > > > > > > > > > > For this panel, I think it can also refer to how > > > > > > > panel-kingdisplay-kd097d04.c does. Create the table for init = cmd data, > > > > > > > not what operation to use, and use mipi_dsi_generic_write_seq= () when > > > > > > > looping through the table. > > > > > > > > > > > > Even more similar discussion: > > > > > > > > > > > > https://lore.kernel.org/r/CAD=3DFV=3DUGDbNvAMjzWSOvxybGikQcvW9J= sRtbxHVg8_97YPEQCA@mail.gmail.com > > > > > > > > > > It seems I skipped that thread. > > > > > > > > > > I'd still suggest a code-based solution compared to table-based o= ne, for > > > > > the reasons I've outlined before. Having a tables puts a pressure= on the > > > > > developer to put commands there for which we already have a > > > > > command-specific function. > > > > > > > > The problem is that with these panels that need big init sequences = the > > > > code based solution is _a lot_ bigger. If it were a few bytes or a > > > > 1-2KB then fine, but when Hsin-Yi measured Linus W's attempt to mov= e > > > > from a table to code it was 100K difference in code [1]. I would al= so > > > > say that having these long init sequences done as separate commands > > > > encourages people to skip checking the return values of each of the > > > > transfer functions and I don't love that idea. > > > > > > > > It would be ideal if these panels didn't need these long init > > > > sequences, but I don't have any inside knowledge here saying that t= hey > > > > could be removed. So assume we can't get rid of the init sequences = it > > > > feels like we have to find some way to make the tables work for at > > > > least the large chunks of init code and encourage people to make th= e > > > > tables readable... > > > > > > > > > I did a quick check on the boe-tv101wum-nl6 driver by converting the > > > writes to use the following macro: > > > > > > #define mipi_dsi_dcs_write_cmd_seq(dsi, cmd, seq...) > > > \ > > > do { = \ > > > static const u8 d[] =3D { cmd, seq }; = \ > > > ret =3D mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(= d)); \ > > > if (ret < 0) = \ > > > goto err; = \ > > > } while (0) > > > > > > And then at the end of the init funciton having > > > > > > err: > > > dev_err(panel->dev, > > > "failed to write command %d\n", ret); > > > return ret; > > > } > > > > > > > I'm not sure about the coding style rule here, would it be considered > > unclear that caller of mipi_dsi_dcs_write_cmd_seq() needs to have err > > block, but the block may not be directly used in that caller and is > > only jumped from the macro? > > I'm also not sure here. It was a quick and dirty test. > We might as well do something like > > ret =3D mipi_dsi_dcs_write_cmd_seq(dsi, ...); > if (ret) > goto err; > > all over the place. Oh. This is actually very simple to fix and requires no code changes to clients. :-P We just need to hoist the printing out of the macro and into "drm_mipi_dsi.c". Let me double-confirm and then I'll post a patch. -Doug