Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp413821rwb; Tue, 13 Dec 2022 20:02:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6rOXtJGKCxMlY9A62YcLZS9ZaZ7yqg/M9RKhNXpIsrFybQOXNw/fmW2sbSUxi06/rPoeho X-Received: by 2002:a17:90a:ad81:b0:219:64d0:9e39 with SMTP id s1-20020a17090aad8100b0021964d09e39mr23691924pjq.12.1670990545210; Tue, 13 Dec 2022 20:02:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670990545; cv=none; d=google.com; s=arc-20160816; b=McW8vd5sGHbHoSiJbUJBDd0+jfNU3krPPHAhCM+kjibwGuuF9Wmf0+QhykusSn1rwV /O1N8DKpN+//9xYX9tySn/P/pgidG+YDSg3NWGkmstNKTpzzBKmUNkKeIVqX1jPWxcaH Nkiilr7rEWyBelVGXZJkzIH6s9xA3fA6jUcu5SZOh6j9vostf+JV+im8SpzF8MXkbZSB jKF5QnSnQ4tUg/kbqPgFU8TCUkHWtwT88hHblBzmKm6smao8mZhJjrwMUb2e5Lu7xoby OyTpoyuJO+/O45Vx2eAgHdNpBPsG3f2b+fkIreASxX+0DTSEE+gB7Dr+lCgyZguCSe9r Wq8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7V81I7/6cXuMLmxZ37PeqznBsJ4nPakQoFmc2FnuMBY=; b=xoXl7pqfJ6NBpXMqhRElZ5QVUSOfsUIxi4KMZ5T2J7rmQ7GFEBDfJk/RnLXCi0nVSI xdrZFXViskd1FDDrRf9AS4JRL67MCNTctKNRfS5SIfnyxne1dFKUNpkXfYe8WjYXt/Fa r895/NdbO3x+aelFJO/5peteJSQTHzXw+Wmtbfuj+KCwfCnGItNC5xH8EWaxFYSAZGjf zxeL42BQJutcNPd2qg24LRC/VFPUS6G7IjlK74WJwPMJDmppMn8lyj52LLisoXuY/2KC cCaG/89c3p2YTE/vHAiDspZJiMdTdebMQTz9LpBAJoPmkaOsyDnZEA8Xj0m9ghNkPztz 2L3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QPwDFNK4; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob6-20020a17090b390600b0020d4dc7fa97si901492pjb.110.2022.12.13.20.02.15; Tue, 13 Dec 2022 20:02:25 -0800 (PST) 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=@chromium.org header.s=google header.b=QPwDFNK4; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237044AbiLND3X (ORCPT + 70 others); Tue, 13 Dec 2022 22:29:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236844AbiLND3V (ORCPT ); Tue, 13 Dec 2022 22:29:21 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E008222BB for ; Tue, 13 Dec 2022 19:29:20 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id v8so20760461edi.3 for ; Tue, 13 Dec 2022 19:29:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7V81I7/6cXuMLmxZ37PeqznBsJ4nPakQoFmc2FnuMBY=; b=QPwDFNK4iHik4Qj1VBQSba9paFPp0BZHz5RpWnwBvrz86c95+2CR5cHbCvi1qdqL/c tzt+SMCEV6bZOdnU6m5DeVeNMj1DWGbiaxbmLuNaGvD3IDGdYVlUmLYRZz8IPM3T3SE1 VrK87+UCUn8KMGAGDT/ts1oXftw0UOhW9R3LI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=7V81I7/6cXuMLmxZ37PeqznBsJ4nPakQoFmc2FnuMBY=; b=XJXfNZbpAdFiBaPeV3gen07Rmh0qz4vuxOeUiL499wOiRSA7nPYP2imgAZSMQsD8J2 EMi95oQAEhTQfsAy2qxQ53drXlVbiyk0jpUVqDG9T/y7b0VFeW1FyhJk2uigxRgHfZg8 yCmUI/9wXd4/IRWg98BklPqfUlFn6bgabirPoUcHanF0bQ/O9B+LLbEyxgJzGFHDz+B6 RodpDfC3yor2eUY0pfJrr6iwJEObARH2SYjCcv495n5tzjQs8ZRTFBg4ASJpwGwAjUIG 2mTdT43cLrrXXlaWM/MBnGjuK66oeQKS5raxWq9Q0tsoKY7U4moG4UBVjrrbdtTlt0wG H7OQ== X-Gm-Message-State: ANoB5pnlxsZg5drh5rwEm+lRt7BrygWhKFzcLDSc1ZpV0tN68CgoCNxw DvFESJi9SXQlhTCOFam4gq6b7TeekZekIw7ZV9UKzg== X-Received: by 2002:a05:6402:1397:b0:467:78f2:d81f with SMTP id b23-20020a056402139700b0046778f2d81fmr66824025edv.88.1670988558697; Tue, 13 Dec 2022 19:29:18 -0800 (PST) MIME-Version: 1.0 References: <20221103091243.96036-1-allen.chen@ite.com.tw> <20221103091243.96036-3-allen.chen@ite.com.tw> In-Reply-To: From: Pin-yen Lin Date: Wed, 14 Dec 2022 11:29:07 +0800 Message-ID: Subject: Re: [PATCH v7 2/2] drm/bridge: add it6505 driver to read data-lanes and link-frequencies from dt To: allen Cc: Jau-Chih Tseng , Hermes Wu , Kenneth Hung , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , "open list:DRM DRIVERS" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Friendly ping. Pin-yen Pin-yen On Mon, Nov 21, 2022 at 1:39 PM Pin-yen Lin wrote: > > Hi all, > Friendly ping on this patch. > > Regards, > Pin-yen > > On Thu, Nov 3, 2022 at 5:13 PM allen wrote: > > > > From: allen chen > > > > Add driver to read data-lanes and link-frequencies from dt property to > > restrict output bandwidth. > > > > Signed-off-by: Allen chen > > Signed-off-by: Pin-yen Lin > > --- > > drivers/gpu/drm/bridge/ite-it6505.c | 80 +++++++++++++++++++++++++++-- > > 1 file changed, 77 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c > > index a4302492cf8df..ed4536cde3140 100644 > > --- a/drivers/gpu/drm/bridge/ite-it6505.c > > +++ b/drivers/gpu/drm/bridge/ite-it6505.c > > @@ -437,6 +437,8 @@ struct it6505 { > > bool powered; > > bool hpd_state; > > u32 afe_setting; > > + u32 max_dpi_pixel_clock; > > + u32 max_lane_count; > > enum hdcp_state hdcp_status; > > struct delayed_work hdcp_work; > > struct work_struct hdcp_wait_ksv_list; > > @@ -1476,7 +1478,8 @@ static void it6505_parse_link_capabilities(struct it6505 *it6505) > > it6505->lane_count = link->num_lanes; > > DRM_DEV_DEBUG_DRIVER(dev, "Sink support %d lanes training", > > it6505->lane_count); > > - it6505->lane_count = min_t(int, it6505->lane_count, MAX_LANE_COUNT); > > + it6505->lane_count = min_t(int, it6505->lane_count, > > + it6505->max_lane_count); > > > > it6505->branch_device = drm_dp_is_branch(it6505->dpcd); > > DRM_DEV_DEBUG_DRIVER(dev, "Sink %sbranch device", > > @@ -2912,7 +2915,7 @@ it6505_bridge_mode_valid(struct drm_bridge *bridge, > > if (mode->flags & DRM_MODE_FLAG_INTERLACE) > > return MODE_NO_INTERLACE; > > > > - if (mode->clock > DPI_PIXEL_CLK_MAX) > > + if (mode->clock > it6505->max_dpi_pixel_clock) > > return MODE_CLOCK_HIGH; > > > > it6505->video_info.clock = mode->clock; > > @@ -3099,10 +3102,32 @@ static int it6505_init_pdata(struct it6505 *it6505) > > return 0; > > } > > > > +static int it6505_get_data_lanes_count(const struct device_node *endpoint, > > + const unsigned int min, > > + const unsigned int max) > > +{ > > + int ret; > > + > > + ret = of_property_count_u32_elems(endpoint, "data-lanes"); > > + if (ret < 0) > > + return ret; > > + > > + if (ret < min || ret > max) > > + return -EINVAL; > > + > > + return ret; > > +} > > + > > static void it6505_parse_dt(struct it6505 *it6505) > > { > > struct device *dev = &it6505->client->dev; > > + struct device_node *np = dev->of_node, *ep = NULL; > > + int len; > > + u64 link_frequencies; > > + u32 data_lanes[4]; > > u32 *afe_setting = &it6505->afe_setting; > > + u32 *max_lane_count = &it6505->max_lane_count; > > + u32 *max_dpi_pixel_clock = &it6505->max_dpi_pixel_clock; > > > > it6505->lane_swap_disabled = > > device_property_read_bool(dev, "no-laneswap"); > > @@ -3118,7 +3143,56 @@ static void it6505_parse_dt(struct it6505 *it6505) > > } else { > > *afe_setting = 0; > > } > > - DRM_DEV_DEBUG_DRIVER(dev, "using afe_setting: %d", *afe_setting); > > + > > + ep = of_graph_get_endpoint_by_regs(np, 1, 0); > > + of_node_put(ep); > > + > > + if (ep) { > > + len = it6505_get_data_lanes_count(ep, 1, 4); > > + > > + if (len > 0 && len != 3) { > > + of_property_read_u32_array(ep, "data-lanes", > > + data_lanes, len); > > + *max_lane_count = len; > > + } else { > > + *max_lane_count = MAX_LANE_COUNT; > > + dev_err(dev, "error data-lanes, use default"); > > + } > > + } else { > > + *max_lane_count = MAX_LANE_COUNT; > > + dev_err(dev, "error endpoint, use default"); > > + } > > + > > + ep = of_graph_get_endpoint_by_regs(np, 0, 0); > > + of_node_put(ep); > > + > > + if (ep) { > > + len = of_property_read_variable_u64_array(ep, > > + "link-frequencies", > > + &link_frequencies, 0, > > + 1); > > + if (len >= 0) { > > + do_div(link_frequencies, 1000); > > + if (link_frequencies > 297000) { > > + dev_err(dev, > > + "max pixel clock error, use default"); > > + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; > > + } else { > > + *max_dpi_pixel_clock = link_frequencies; > > + } > > + } else { > > + dev_err(dev, "error link frequencies, use default"); > > + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; > > + } > > + } else { > > + dev_err(dev, "error endpoint, use default"); > > + *max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX; > > + } > > + > > + DRM_DEV_DEBUG_DRIVER(dev, "using afe_setting: %u, max_lane_count: %u", > > + it6505->afe_setting, it6505->max_lane_count); > > + DRM_DEV_DEBUG_DRIVER(dev, "using max_dpi_pixel_clock: %u kHz", > > + it6505->max_dpi_pixel_clock); > > } > > > > static ssize_t receive_timing_debugfs_show(struct file *file, char __user *buf, > > -- > > 2.25.1 > >