From patchwork Sun Aug 9 21:51:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247578 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp4349760ilo; Sun, 9 Aug 2020 14:52:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzMO7HU0etHxgppmfz5QKzSKkWEaYkc5OFx7lVDtVZ8eXrbgsViXcSO3svPo6oC83PxHoN X-Received: by 2002:a17:902:a50e:: with SMTP id s14mr20085523plq.164.1597009922627; Sun, 09 Aug 2020 14:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597009922; cv=none; d=google.com; s=arc-20160816; b=W5J3R/nKPzuyq2Mb2Y8yl0JolPeXCDcKhE14JJHiu/RixsQ4HfOWES+v7s9KcQ0Hpb bwTpfWIU3pooiYoF1Nrw3MfJktj8OmS/Q/Y6cqQ8DIM1b+mobVMO3o7z9iuenkcMJaHs JWpoXx9MwHdkPrUTksk5ZAo0rBTcWRYs1M4UhmAWsa1IqyBRAY2zoXoa7dxgd923AJLd YBhZyL+oX39LFEwfjBztFejWhl5TR9HGAzHhK7P/Ta96XuklrdOursEkRDlk90MhufDd KOBomeaZMlJvp2/Q+Af50/Y4VPEo/0reI8oVSZCUk5OyPhX6xHtFceRdc/3rVyTnyOfE 59dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=jNU0WGAGo5IP0J5plhtHKFHYumT2YeP6MMZN3NTW9lE=; b=Gixjwt0TaxC/GkffLgLrQNF/TDTZUaRVVqyGCPrfdS0MnEPCV098YPbsGr7nLBba5K Yy+bWzmyo/e44++Mc/7kCjQBhw3cTJGEeEKGtCjatASIsbOYtqYwSLRA3X8G1MqDrGcg C7WDdoz+fl1UY6U8a3zy24p7rotKbBPvGXrjq9/lWj4B7O0+/FO9M5u34L1Rd5DLOFlB fxxQ52F6jgYiTfizdmOkBZzGAWHATMZpDA0NfVf6EdKm6UqfQSCCx7C5dh4/qWEN8lhL HRgTJaSos768v+jLf43KaT8LFs2J3mVZ4NfXh7cTNRwyI7mhkDLsIguTaXGuFRmDZWQz SduQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JKQgEOLm; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x17si10455853plb.302.2020.08.09.14.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:52:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JKQgEOLm; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD7EF6E0AA; Sun, 9 Aug 2020 21:51:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id E836D6E0AA for ; Sun, 9 Aug 2020 21:51:56 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id 185so7523696ljj.7 for ; Sun, 09 Aug 2020 14:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1ByE3BCTHRLC4VafLeXjT5kewKqYMYL9Xds0gaKzSn0=; b=JKQgEOLmxT226irsiRGOZ1J71vXPGfImRoAUhL/PXb2UeDlpbopC4V3JSJCbXunHwA cwRgCsAPMkcrdzDro8NtBrRfIN04mm/fL1rz9kv97hzMFfBxzY8Hx5bjFFqxBV3YpeXN Uy2EABzO7e9HDgd1cNa9J0LmpdKJdevNDNnRgtl2Q3+kBb1MwdZ8ecJAy5Zk44YjFHXz KRtmGo9uBJ8MLczJ9+5Upn2xD4BiKUeCBO6Nq3bp4Zi6pU0gniM8a2i1xPbKOeCwgJ+Y irC0KOrYhi2PoV0spECDdAM0M0BvqDUfD3qFhzSCLdIT+t3m/U00iiZ65GcIjkA8uETl nczg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1ByE3BCTHRLC4VafLeXjT5kewKqYMYL9Xds0gaKzSn0=; b=KkGLkzAO7AW8GjFmG1XGpeohU/H00RAxR/+LktJ/8D9/b9duy1eHkUxUatxDJgc2ji zkgZHeaheQgVRiANSg7cBfnqpLDuXlKmNali2liKTj7Mu51wqJfcKA0ZcF623sAhadG6 q04/ggDesqYtzInIVIvQ59H9g/eL7EmzHhCKlkwvQyuoi+MO6dYgCAtO4OKT3YuUnWfp wox/nArgzyNU587yjd8s0WwyCRsF447PZHh44rXCjzJNeiKgqNHD77VHGCS2HOgCFuvL Gkb7OaMelVQCUyLTG3I3BeAmq5c3sQkvgUlx7w8wRvJ+uOFfSHzpUNQwFUbyjPDinVkE fWFw== X-Gm-Message-State: AOAM533iXZST/O8kDytziK4oPfQf5KAgCNXa9YIP3TPJayLBiEwzGlmb jAo5EmELFoyRA6kxJC2yirUC5g== X-Received: by 2002:a2e:b814:: with SMTP id u20mr10544600ljo.202.1597009915326; Sun, 09 Aug 2020 14:51:55 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id t20sm8277045ljd.12.2020.08.09.14.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 14:51:54 -0700 (PDT) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , Stephan Gerhold , =?utf-8?q?Pawe=C5=82_Chmiel?= Subject: [PATCH 3/4] drm/panel: s6e63m0: Add reading functionality Date: Sun, 9 Aug 2020 23:51:03 +0200 Message-Id: <20200809215104.1830206-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200809215104.1830206-1-linus.walleij@linaro.org> References: <20200809215104.1830206-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This adds code to send read commands to read a single byte from the display, in order to perform MTP ID look-up of the mounted panel on the s6e63m0 controller. This is needed for proper biasing on the DSI variants. Cc: Stephan Gerhold Cc: Paweł Chmiel Signed-off-by: Linus Walleij --- .../gpu/drm/panel/panel-samsung-s6e63m0-dsi.c | 19 ++++++++++++++++++- .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 14 +++++++++++++- drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 11 +++++++++++ drivers/gpu/drm/panel/panel-samsung-s6e63m0.h | 1 + 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c index f4927a6ce26d..2ec9e7900791 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c @@ -16,6 +16,22 @@ #define MCS_GLOBAL_PARAM 0xb0 #define S6E63M0_DSI_MAX_CHUNK 15 /* CMD + 15 bytes max */ +static int s6e63m0_dsi_dcs_read(struct device *dev, const u8 cmd, u8 *data) +{ + struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); + int ret; + + ret = mipi_dsi_dcs_read(dsi, cmd, data, 1); + if (ret < 0) { + DRM_DEV_ERROR(dev, "could not read DCS CMD %02x\n", cmd); + return ret; + } + + DRM_DEV_INFO(dev, "DSI read CMD %02x = %02x\n", cmd, *data); + + return 0; +} + static int s6e63m0_dsi_dcs_write(struct device *dev, const u8 *data, size_t len) { struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); @@ -90,7 +106,8 @@ static int s6e63m0_dsi_probe(struct mipi_dsi_device *dsi) MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_VIDEO_BURST; - ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_write, true); + ret = s6e63m0_probe(dev, s6e63m0_dsi_dcs_read, s6e63m0_dsi_dcs_write, + true); if (ret) return ret; diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c index 0587eac52f2a..3b1a2a3a44ea 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c @@ -11,6 +11,17 @@ #define DATA_MASK 0x100 +static int s6e63m0_spi_dcs_read(struct device *dev, const u8 cmd, u8 *data) +{ + /* + * FIXME: implement reading DCS commands over SPI so we can + * properly identify which physical panel is connected. + */ + *data = 0; + + return 0; +} + static int s6e63m0_spi_write_word(struct device *dev, u16 data) { struct spi_device *spi = to_spi_device(dev); @@ -60,7 +71,8 @@ static int s6e63m0_spi_probe(struct spi_device *spi) DRM_DEV_ERROR(dev, "spi setup failed.\n"); return ret; } - return s6e63m0_probe(dev, s6e63m0_spi_dcs_write, false); + return s6e63m0_probe(dev, s6e63m0_spi_dcs_read, s6e63m0_spi_dcs_write, + false); } static int s6e63m0_spi_remove(struct spi_device *spi) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c index c6d17e938955..b25021bdd724 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.c @@ -87,6 +87,7 @@ static u8 const s6e63m0_gamma_22[NUM_GAMMA_LEVELS][GAMMA_TABLE_COUNT] = { struct s6e63m0 { struct device *dev; + int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val); int (*dcs_write)(struct device *dev, const u8 *data, size_t len); struct drm_panel panel; struct backlight_device *bl_dev; @@ -136,6 +137,14 @@ static int s6e63m0_clear_error(struct s6e63m0 *ctx) return ret; } +static void s6e63m0_dcs_read(struct s6e63m0 *ctx, const u8 cmd, u8 *data) +{ + if (ctx->error < 0) + return; + + ctx->error = ctx->dcs_read(ctx->dev, cmd, data); +} + static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len) { if (ctx->error < 0 || len == 0) @@ -403,6 +412,7 @@ static int s6e63m0_backlight_register(struct s6e63m0 *ctx) } int s6e63m0_probe(struct device *dev, + int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val), int (*dcs_write)(struct device *dev, const u8 *data, size_t len), bool dsi_mode) { @@ -413,6 +423,7 @@ int s6e63m0_probe(struct device *dev, if (!ctx) return -ENOMEM; + ctx->dcs_read = dcs_read; ctx->dcs_write = dcs_write; dev_set_drvdata(dev, ctx); diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h index 229e23b0c97a..c669fec91763 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0.h @@ -4,6 +4,7 @@ #define _PANEL_SAMSUNG_S6E63M0_H int s6e63m0_probe(struct device *dev, + int (*dcs_read)(struct device *dev, const u8 cmd, u8 *val), int (*dcs_write)(struct device *dev, const u8 *data, size_t len), bool dsi_mode);