From patchwork Wed Mar 29 10:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 668472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CB80C761A6 for ; Wed, 29 Mar 2023 10:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbjC2KKO (ORCPT ); Wed, 29 Mar 2023 06:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjC2KKI (ORCPT ); Wed, 29 Mar 2023 06:10:08 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD1A40F1; Wed, 29 Mar 2023 03:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680084603; x=1711620603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=igUd0juBFbhD3FwzVTuXMvHpiXPrEjnaBBZ84sDqCiM=; b=ZLRL24hg9sLLwSbbjDY8H+124h/TsEoaYVEyfRet4+nvorGnqXlQE6fK LGkGO9+fRZCOyNAplj64IYlL4zPFnjhw3EUoG5OrT8DkhmMBaDCARzZWO +djzhQ5Gn4VO2vyFGSnZle2v1x5SC0vG2ytl+OACEzWcB+VNL08wqw5Wy pE6NgRN3W1NqV9EdFRz3XZdEGruFy47+mx2/XcH1Rp0Wj7SS5H0ylrnG7 El7oO+WUHkJEz/1Z6sJ409yRlplfPJeW2QSCXV0C2fBlvZvAagTrODqt0 CM045amrGhV1h6BXdjZUVTaUjuKikGV19cl0W0lFg5kLM7VolNO4d5Gcu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="343256250" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="343256250" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 03:10:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="773517724" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="773517724" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 03:10:01 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 34A4812259B; Wed, 29 Mar 2023 13:09:59 +0300 (EEST) From: Sakari Ailus To: linux-acpi@vger.kernel.org Cc: linux-media@vger.kernel.org, rafael@kernel.org, andriy.shevchenko@linux.intel.com, heikki.krogerus@linux.intel.com Subject: [PATCH v8 07/10] ACPI: property: Dig "rotation" property for devices with CSI2 _CRS Date: Wed, 29 Mar 2023 13:09:48 +0300 Message-Id: <20230329100951.1522322-8-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230329100951.1522322-1-sakari.ailus@linux.intel.com> References: <20230329100951.1522322-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Dig "rotation" property value for devices with _CRS CSI2 resource descriptor. The value comes from _PLD (physical location of device) object, if it exists for the device. This way camera sensor drivers that know the "rotation" property do not need to care about _PLD on ACPI. Signed-off-by: Sakari Ailus --- drivers/acpi/mipi.c | 17 +++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/acpi/mipi.c b/drivers/acpi/mipi.c index 03079f78bd2c..0232cc123ead 100644 --- a/drivers/acpi/mipi.c +++ b/drivers/acpi/mipi.c @@ -652,10 +652,12 @@ static void init_port_csi2_remote(struct acpi_device *device, */ void acpi_init_swnodes(struct acpi_device *device) { + struct fwnode_handle *fwnode = acpi_fwnode_handle(device); struct acpi_device_software_nodes *ads; struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER }; acpi_handle handle = acpi_device_handle(device); struct fwnode_handle *primary; + unsigned int prop_index = 0; acpi_status status; unsigned int i; int ret; @@ -664,6 +666,21 @@ void acpi_init_swnodes(struct acpi_device *device) if (!ads) return; + /* + * Check if "rotation" property exists and if it doesn't but there's a + * _PLD object, then get the rotation value from there. + */ + if (!fwnode_property_present(fwnode, "rotation")) { + struct acpi_pld_info *pld; + + status = acpi_get_physical_device_location(handle, &pld); + if (ACPI_SUCCESS(status)) { + ads->dev_props[NEXT_PROPERTY(prop_index, DEV_ROTATION)] = + PROPERTY_ENTRY_U32("rotation", pld->rotation * 45U); + kfree(pld); + } + } + status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); if (ACPI_FAILURE(status)) { acpi_handle_warn(handle, "cannot get path name\n"); diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 29d1e4d49d0c..83a89797a122 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -361,6 +361,7 @@ struct acpi_device_data { struct acpi_gpio_mapping; enum acpi_device_swnode_dev_props { + ACPI_DEVICE_SWNODE_DEV_ROTATION, ACPI_DEVICE_SWNODE_DEV_NUM_OF, ACPI_DEVICE_SWNODE_DEV_NUM_ENTRIES };