From patchwork Tue Mar 28 10:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 667930 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 A6651C77B6F for ; Tue, 28 Mar 2023 10:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjC1KCi (ORCPT ); Tue, 28 Mar 2023 06:02:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbjC1KCO (ORCPT ); Tue, 28 Mar 2023 06:02:14 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E729D619C; Tue, 28 Mar 2023 03:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679997734; x=1711533734; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k2wXv6cEvPP8j8J/b9F7VttPHh08sa/YyVhSeBf27tE=; b=P7uT350ZDdQBzlEA2R/j6UTR1vsgdEYKmoMjv/5V3yJv3mLzi/gnGOGH LHcOl/O55EwFCn2Rn04tyU0BrQ2T4rxhfqnaawFMznhEgKPzC39zhuF36 xBe60qoVV+M1WUW+36IbLWn3ZNtcqe5KQ2yRm1Z4KOpP8vwpt93kTI5nE APEk2D3FsBGPlhFiKn105P/wFDzrF32UgZVMXAE40kFELY4EA845ix9O1 yt3COZOaHP2+mZJrBguwKbBGFsVvm8zCqbIKSyUGF6eRvRPggAd8hk2i1 47iRA6PpOQDJGDG+TF80sWixxqNdmOfQAa4784SnNczuuAbydTAg0Puu4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="324420015" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="324420015" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 03:02:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10662"; a="753078552" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="753078552" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 03:02:10 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id D3D9A122499; Tue, 28 Mar 2023 13:02:07 +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 v6 07/10] ACPI: property: Dig "rotation" property for devices with CSI2 _CRS Date: Tue, 28 Mar 2023 13:01:56 +0300 Message-Id: <20230328100159.1457160-9-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230328100159.1457160-1-sakari.ailus@linux.intel.com> References: <20230328100159.1457160-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 315f076b9208..9f29bf231eaf 100644 --- a/drivers/acpi/mipi.c +++ b/drivers/acpi/mipi.c @@ -654,10 +654,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; @@ -666,6 +668,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 e05d1c1f6ac2..f73e65a21b89 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 };