From patchwork Sun Aug 23 10:45:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11731537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCC9A913 for ; Sun, 23 Aug 2020 10:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA77F2072D for ; Sun, 23 Aug 2020 10:45:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aItt62qv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbgHWKpy (ORCPT ); Sun, 23 Aug 2020 06:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgHWKpv (ORCPT ); Sun, 23 Aug 2020 06:45:51 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B2CAC061573 for ; Sun, 23 Aug 2020 03:45:51 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id v12so6429240ljc.10 for ; Sun, 23 Aug 2020 03:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5Ial+5Nc2noRZ86O2pflKJVs+D+LQzvwReDE5AsQdzA=; b=aItt62qvVreI4OM2AS2Q+YTqggP7BNM3sCjEGwXFZC58BOmxs/kQK9OFI8jsO6uZ61 doqW+ay95V1oLxkD2+dE1qf11Y74yrFDJDXQjS4W+DZc7nj9MvZDnf9g7EY0G5Ras6Jz 5pxaxxcM1Ilzz3KUFu24KJTf+HStBQeRqe2SscXZ1CDXVHoYNAs2ifKA9//FR1TjIimU RoBksC8E0f2q5o1uF1+fJxqWM9zd3JJ2M0DShvMzYPlvg69yp6v0z1qVcEBEw4ryY6Ut p4gLOIbd82E+B2oMsdlTcLyAkBwQXlDnxoia7Fp9UFsSzqlp3pMbzNlIbZxiPJ0F9SKb O1dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=5Ial+5Nc2noRZ86O2pflKJVs+D+LQzvwReDE5AsQdzA=; b=IT44S2JYNH16j65uL6hrDZ7cL7K2JLwVyW0U/4ET7Q5j906+PL0gam/C4n4xTPWQH9 +tOwIWzS9kaLmRWSQ6dyLEFfNX+Gjxss2Thka1vmCeLFW5DVjmI++873RvhJOnaRPbOq vwlHrIeo1MRZdhGp9xLLWsn7IA3C6yd897WlMrPewznlIO+n11hf1iiL5HwdOrC/P8DV iwvOHSpbhqrTqMS1M9tr1QOU179DRqg65V9z/kYEXMKH8EI1hSiocUcFABR7MlBdKdHY UO8leYuxc3UCf97g7jHVvfDlvPtzjrTUKOVQqF6lzlwbC5OQw/S5vSdxVI4QHbIQcdIo tw/g== X-Gm-Message-State: AOAM5332wiDezQpDHXrym8/HFEPBUrFTbz5uHAaw7AujQqfCPzboAcmi kmBPJeZr801h++jWmPIwzNY= X-Google-Smtp-Source: ABdhPJztYredDYbqfU9prjYz75+tcEG+VEa9+w5D5KdAPAb1lS6xXhdElhL7Vs2yxI5jNwov/E162w== X-Received: by 2002:a2e:a40b:: with SMTP id p11mr455753ljn.97.1598179548601; Sun, 23 Aug 2020 03:45:48 -0700 (PDT) Received: from saturn.localdomain ([2a00:fd00:805f:db00:2509:20d7:e461:9c16]) by smtp.gmail.com with ESMTPSA id h13sm1516301lji.134.2020.08.23.03.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 03:45:47 -0700 (PDT) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Jingoo Han , Lee Jones , Daniel Thompson Cc: Daniel Vetter , Sam Ravnborg , Alex Deucher , amd-gfx@lists.freedesktop.org, Andrzej Hajda , =?utf-8?q?Christian_K=C3=B6nig?= , Chris Wilson , Ezequiel Garcia , Hans de Goede , Hoegeun Kwon , Inki Dae , Jani Nikula , Jernej Skrabec , Jonas Karlman , Joonas Lahtinen , Jyri Sarha , Kieran Bingham , Konrad Dybcio , Laurent Pinchart , Linus Walleij , linux-renesas-soc@vger.kernel.org, Maarten Lankhorst , Manasi Navare , Neil Armstrong , Patrik Jakobsson , =?utf-8?q?Pawe=C5=82_Chmie?= =?utf-8?q?l?= , Philippe CORNU , Rob Clark , Robert Chiras , Rodrigo Vivi , Sebastian Reichel , Thierry Reding , Tomi Valkeinen , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Vinay Simha BN , Wambui Karuga , Zheng Bin Subject: [PATCH v2 0/24] backlight: add init macros and accessors Date: Sun, 23 Aug 2020 12:45:08 +0200 Message-Id: <20200823104532.1024798-1-sam@ravnborg.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The first patch trims backlight_update_status() so it can be called with a NULL backlight_device. Then the caller do not need to add this check just to avoid a NULL reference. The backlight drivers uses several different patterns when registering a backlight: - Register backlight and assign properties later - Define a local backlight_properties variable and use memset - Define a const backlight_properties and assign relevant properties On top of this there was differences in what members was assigned. To align how backlight drivers are initialized introduce following helper macros: - DECLARE_BACKLIGHT_INIT_FIRMWARE() - DECLARE_BACKLIGHT_INIT_PLATFORM() - DECLARE_BACKLIGHT_INIT_RAW() The macros are introduced in patch 2. The backlight drivers used direct access to backlight_properties. Encapsulate these in get/set access operations resulting in following benefits: - The access methods can be called with a NULL pointer so logic around the access can be made simpler. - The update_brightness and enable_brightness simplifies the users - The code is in most cases more readable with the access operations. - When everyone uses the access methods refactoring in the backlight core is simpler. The get/set operations are introduced in patch 3. The gpio backlight driver received a small overhaul in a set of three patches. The result is a smaller and more readable driver. The remaining patches updates all backlight users in drivers/gpu/drm/* With this patch set all of drivers/gpu/drm/: - All backlight references to FB_BLANK* are gone from drm/* - All direct references to backlight properties are gone - All panel drivers uses the devm_ variant for registering backlight Daniel Vetter had some concerns with this for future updates, but we are aligned now and can update if refoctoring demands it - All panel drivers uses the backlight support in drm_panel Individual patches are only sent to the people listed in the patch + a few more. Please check https://lore.kernel.org/dri-devel/ for the full series. v2: - Documented BACKLIGHT_PROPS as it may be used by drivers - Dropped backlight_set_power_{on,off}, they were a mistake (Daniel) - Added backlight_update_brightness() and use it (Daniel) - Added backlight_enable_brightness() and use it - Moved remaining drm_panel driver to use backlight support in drm_panel - gpio backlight driver overhaul The patches are made on top of the for-backlight-next branch at https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git The branch needs v5.8-rc1 backported to build as dev_err_probe() is used. The first 6 patches are candidates for the backlight tree. If they are applied then this should preferably be to an immutable branch we can merge to drm-misc-next where the drm patches shall go. The drm patches has known conflics and shall *not* be applied to the backlight tree, they are included in this patchset to show how the new functions are used. Diffstat for the drm bits alone looks nice: 25 files changed, 243 insertions(+), 460 deletions(-) Feedback welcome! Sam Cc: Alex Deucher Cc: amd-gfx@lists.freedesktop.org Cc: Andrzej Hajda Cc: Christian König Cc: Chris Wilson Cc: Daniel Thompson Cc: Ezequiel Garcia Cc: Hans de Goede Cc: Hoegeun Kwon Cc: Inki Dae Cc: Jani Nikula Cc: Jernej Skrabec Cc: Jingoo Han Cc: Jonas Karlman Cc: Joonas Lahtinen Cc: Jyri Sarha Cc: Kieran Bingham Cc: Konrad Dybcio Cc: Laurent Pinchart Cc: Lee Jones Cc: Linus Walleij Cc: linux-renesas-soc@vger.kernel.org Cc: Maarten Lankhorst Cc: Manasi Navare Cc: Neil Armstrong Cc: Patrik Jakobsson Cc: Paweł Chmiel Cc: Philippe CORNU Cc: Rob Clark Cc: Robert Chiras Cc: Rodrigo Vivi Cc: Sam Ravnborg Cc: Sebastian Reichel Cc: Thierry Reding Cc: Tomi Valkeinen Cc: "Ville Syrjälä" Cc: Vinay Simha BN Cc: Wambui Karuga Cc: Zheng Bin Sam Ravnborg (24): backlight: Silently fail backlight_update_status() if no device backlight: Add DECLARE_* macro for device registration backlight: Add get/set operations for brightness properties backlight: gpio: Introduce backlight_{enable,disable} backlight: gpio: Use dev_err_probe() backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW drm/gma500: Backlight update drm/panel: asus-z00t-tm5p5-n35596: Backlight update drm/panel: jdi-lt070me05000: Backlight update drm/panel: novatek-nt35510: Backlight update drm/panel: orisetech-otm8009a: Backlight update drm/panel: raydium-rm67191: Backlight update drm/panel: samsung-s6e63m0: Backlight update drm/panel: samsung-s6e63j0x03: Backlight update drm/panel: samsung-s6e3ha2: Backlight update drm/panel: sony-acx424akp: Backlight update drm/panel: sony-acx565akm: Backlight update drm/bridge: parade-ps8622: Backlight update drm/tilcdc: Backlight update drm/radeon: Backlight update drm/amdgpu/atom: Backlight update drm/i915: Backlight update drm/omap: display: Backlight update drm/shmobile: Backlight update drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 19 +-- drivers/gpu/drm/bridge/parade-ps8622.c | 43 ++++--- drivers/gpu/drm/gma500/backlight.c | 34 +---- drivers/gpu/drm/gma500/cdv_device.c | 24 ++-- drivers/gpu/drm/gma500/mdfld_device.c | 9 +- drivers/gpu/drm/gma500/oaktrail_device.c | 10 +- drivers/gpu/drm/gma500/opregion.c | 2 +- drivers/gpu/drm/gma500/psb_device.c | 10 +- drivers/gpu/drm/gma500/psb_drv.c | 7 +- drivers/gpu/drm/i915/display/intel_panel.c | 88 ++++++------- drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 37 +----- .../gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c | 15 +-- drivers/gpu/drm/panel/panel-jdi-lt070me05000.c | 54 ++------ drivers/gpu/drm/panel/panel-novatek-nt35510.c | 9 +- drivers/gpu/drm/panel/panel-orisetech-otm8009a.c | 14 +-- drivers/gpu/drm/panel/panel-raydium-rm67191.c | 11 +- drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 70 +++++------ drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c | 53 ++++---- drivers/gpu/drm/panel/panel-samsung-s6e63m0.c | 25 ++-- drivers/gpu/drm/panel/panel-sony-acx424akp.c | 49 ++------ drivers/gpu/drm/panel/panel-sony-acx565akm.c | 47 +++---- drivers/gpu/drm/radeon/atombios_encoders.c | 24 ++-- drivers/gpu/drm/radeon/radeon_legacy_encoders.c | 16 +-- drivers/gpu/drm/shmobile/shmob_drm_backlight.c | 20 ++- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 9 +- drivers/video/backlight/gpio_backlight.c | 41 +++--- include/linux/backlight.h | 140 +++++++++++++++++++++ 27 files changed, 400 insertions(+), 480 deletions(-) Acked-by: Linus Walleij Acked-by: Daniel Thompson