Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3228539rdb; Thu, 16 Nov 2023 04:08:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/EaxfuomALebOq4lNYpkPrxKK9C9X2k7drNAm3ccixhC/ZBnE2rxoI1URQRHQi6q4KGJv X-Received: by 2002:a05:6808:6494:b0:3b2:dda7:d2b8 with SMTP id fh20-20020a056808649400b003b2dda7d2b8mr18011136oib.2.1700136532441; Thu, 16 Nov 2023 04:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700136532; cv=none; d=google.com; s=arc-20160816; b=tEmtX1wqAwrPkaY9yl27kAKGczxeHAXoCd6KQj1xISjGmvfhFkKUnxXg+unstaNP/K qkPQnK3FodYUdkhMfSTv0XlfTzutO5fsGOj2X0g9jJ7+ulqoIG2Ovyg01+yNZGkGkTtp FVGgFNq5snEzpXiW6qU74zSZM7neFgTiMmcqsKLB92iFiybMNk5HPgNV1SbNdiebp8t7 E5EPyfjq0aMQZVxNd+eu35wuszpQBb8YcLq/fMxaixE4WNr/+45k+FOO3RSQ4sedDp0X oYgf2fbefanXpoKMz2TZzCOLahYLdnLTwz7VzwKMKhbpcpSWRY2i5HdjbIr0EBX5H9JA Fsiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=k9oetIw2tFldJiOGCUKM2J/cABhuLHaFmSF5ziLE1Pg=; fh=L6MbuOTOK7FHgIF89LITj4O+NnVze0RQCyrYNOhkPmg=; b=KMr1CggQpRWyTc2w6o7mfwDZBsHQb6tR0wIMK9AYRF02QlXY2SPWkH5dbcrgb1GAKn G5rroEmZHYnv23cbIzW5VhrC9buVlYB5msngkXlMjDTXRDoWTgZ4quMpuLL7u69SYZvH TaKbRSigOU2jkGPpyOYI/SpCbeb+VhgaYp9va8APpogRTdwM931wPkDBf/M5IlnoBHqr TMUP2CkY26MN+syNfJ3vUBshqQrfADo3kjTi35VldP7iumRWYwP/FPOBmo5AR+udTRPt WLZrsiB/aAL0gxahewzH0FLJmb/4YMrN8tCCe26xaKNgTmM8eVw5VtYPk8zE5bn3/rbB URnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="fJN0/POd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q24-20020a656858000000b005b969c62b27si11955689pgt.747.2023.11.16.04.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 04:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="fJN0/POd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 75AE08183F05; Thu, 16 Nov 2023 04:08:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345246AbjKPMIV (ORCPT + 99 others); Thu, 16 Nov 2023 07:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345243AbjKPMIU (ORCPT ); Thu, 16 Nov 2023 07:08:20 -0500 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [IPv6:2001:41d0:1004:224b::bc]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBA2CB4 for ; Thu, 16 Nov 2023 04:08:15 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700136493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k9oetIw2tFldJiOGCUKM2J/cABhuLHaFmSF5ziLE1Pg=; b=fJN0/POdxJ2qznbqNjU2TFEX8CyZdzr61R3U8qfTAtTrnZ5ECyVrFppcRpHoppC3dUMUZM ARrpL7w5VXh4t4g/uvKOK80LOUSfv5BbyKlUAo1CkCAsOeSEv5MM7H/40kq7FbbEEHz5ze 6UmPZPgVjJfxp2BbOoOKoTC/5htG+oo= Date: Thu, 16 Nov 2023 20:07:59 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib Content-Language: en-US To: Dmitry Baryshkov Cc: Phong LE , Neil Armstrong , Maxime Ripard , Sui Jingfeng , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent Pinchart , Thomas Zimmermann References: <20231114150130.497915-1-sui.jingfeng@linux.dev> <20231114150130.497915-9-sui.jingfeng@linux.dev> <1b59d647-c345-4260-b07b-22abb70ae17a@linux.dev> <7b85d057-3d66-435a-a657-dd69067b6bef@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng In-Reply-To: <7b85d057-3d66-435a-a657-dd69067b6bef@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 04:08:41 -0800 (PST) On 2023/11/16 19:53, Sui Jingfeng wrote: > Hi, > > > On 2023/11/16 19:29, Dmitry Baryshkov wrote: >> On Thu, 16 Nov 2023 at 13:18, Sui Jingfeng >> wrote: >>> Hi, >>> >>> >>> On 2023/11/15 00:30, Dmitry Baryshkov wrote: >>>>> + >>>>> +               ctx->connector = connector; >>>>> +       } >>>>> >>>>>           if (ctx->info->id == ID_IT66121) { >>>>>                   ret = regmap_write_bits(ctx->regmap, >>>>> IT66121_CLK_BANK_REG, >>>>> @@ -1632,16 +1651,13 @@ static const char * const >>>>> it66121_supplies[] = { >>>>>           "vcn33", "vcn18", "vrf12" >>>>>    }; >>>>> >>>>> -static int it66121_probe(struct i2c_client *client) >>>>> +int it66121_create_bridge(struct i2c_client *client, bool >>>>> of_support, >>>>> +                         bool hpd_support, bool audio_support, >>>>> +                         struct drm_bridge **bridge) >>>>>    { >>>>> +       struct device *dev = &client->dev; >>>>>           int ret; >>>>>           struct it66121_ctx *ctx; >>>>> -       struct device *dev = &client->dev; >>>>> - >>>>> -       if (!i2c_check_functionality(client->adapter, >>>>> I2C_FUNC_I2C)) { >>>>> -               dev_err(dev, "I2C check functionality failed.\n"); >>>>> -               return -ENXIO; >>>>> -       } >>>>> >>>>>           ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); >>>>>           if (!ctx) >>>>> @@ -1649,24 +1665,19 @@ static int it66121_probe(struct i2c_client >>>>> *client) >>>>> >>>>>           ctx->dev = dev; >>>>>           ctx->client = client; >>>>> -       ctx->info = i2c_get_match_data(client); >>>>> - >>>>> -       ret = it66121_of_read_bus_width(dev, &ctx->bus_width); >>>>> -       if (ret) >>>>> -               return ret; >>>>> - >>>>> -       ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); >>>>> -       if (ret) >>>>> -               return ret; >>>>> - >>>>> -       i2c_set_clientdata(client, ctx); >>>>>           mutex_init(&ctx->lock); >>>>> >>>>> -       ret = devm_regulator_bulk_get_enable(dev, >>>>> ARRAY_SIZE(it66121_supplies), >>>>> - it66121_supplies); >>>>> -       if (ret) { >>>>> -               dev_err(dev, "Failed to enable power supplies\n"); >>>>> -               return ret; >>>>> +       if (of_support) { >>>>> +               ret = it66121_of_read_bus_width(dev, >>>>> &ctx->bus_width); >>>>> +               if (ret) >>>>> +                       return ret; >>>>> + >>>>> +               ret = it66121_of_get_next_bridge(dev, >>>>> &ctx->next_bridge); >>>>> +               if (ret) >>>>> +                       return ret; >>>>> +       } else { >>>>> +               ctx->bus_width = 24; >>>>> +               ctx->next_bridge = NULL; >>>>>           } >>>> A better alternative would be to turn OF calls into fwnode calls and >>>> to populate the fwnode properties. See >>>> drivers/platform/x86/intel/chtwc_int33fe.c for example. >>> >>> Honestly, I don't want to leave any scratch(breadcrumbs). >>> I'm worries about that turn OF calls into fwnode calls will leave >>> something unwanted. >>> >>> Because I am not sure if fwnode calls will make sense in the DT >>> world, while my patch >>> *still* be useful in the DT world. >> fwnode calls work for both DT and non-DT cases. In the DT case they >> work with DT nodes and properties. In the non-DT case, they work with >> manually populated properties. >> >>> Because the newly introduced it66121_create_bridge() >>> function is a core. I think It's better leave this task to a more >>> advance programmer. >>> if there have use case. It can be introduced at a latter time, >>> probably parallel with >>> the DT. >>> >>> I think DT and/or ACPI is best for integrated devices, but it66121 >>> display bridges is >>> a i2c slave device. Personally, I think slave device shouldn't be >>> standalone. I'm more >>> prefer to turn this driver to support hot-plug, even remove the >>> device on the run time >>> freely when detach and allow reattach. Like the I2C EEPROM device in >>> the monitor (which >>> contains the EDID, with I2C slave address 0x50). The I2C EEPROM >>> device *also* don't has >>> a corresponding struct device representation in linux kernel. >> It has. See i2c_client::dev. > > No, what I mean is that there don't have a device driver for > monitor(display) hardware entity. > And the drm_do_probe_ddc_edid() is the static linked driver, which is > similar with the idea > this series want to express. > > >>> so I still think It is best to make this drivers functional as a >>> static lib, but I want >>> to hear you to say more. Why it would be a *better* alternative to >>> turn OF calls into >>> fwnode calls? what are the potential benefits? >> Because then you can populate device properties from your root device. >> Because it allows the platform to specify the bus width instead of >> hardcoding 24 bits (which might work in your case, but might not be >> applicable to another user next week). > > > No, this problem can be easily solved. Simply add another argument. > > ``` > > int it66121_create_bridge(struct i2c_client *client, bool of_support, >                           bool hpd_support, bool audio_support, u32 > bus_width, >                           struct drm_bridge **bridge); > ``` > > >> Anyway, even without fwnode, I'd strongly suggest you to drop the >> it66121_create_bridge() as it is now and start by populating the i2c >> bus from your root device. > > This will force all non-DT users to add the similar code patter at the > display controller side, > which is another kind of duplication. The monitor is also as I2C slave > device, can be abstract > as a identify drm bridges in theory, I guess. > 'identify' -> 'identity' > >> Then you will need some way (fwnode?) to >> discover the bridge chain. And at the last point you will get into the >> device data and/or properties business. >> > No, leave that chance to a more better programmer and forgive me please, > too difficult, I'm afraid of not able to solve. Thanks a lot for the > trust! > >