From patchwork Fri Jun 30 11:06:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13298057 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 75D79EB64D7 for ; Fri, 30 Jun 2023 11:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232361AbjF3LIY (ORCPT ); Fri, 30 Jun 2023 07:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232287AbjF3LIN (ORCPT ); Fri, 30 Jun 2023 07:08:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D2D33C23 for ; Fri, 30 Jun 2023 04:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688123240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fnWfZg5wiC6/snkX394UKpQhyttleq5UmO5Ux+4wPW0=; b=fmR6KiCMXQQ7MOM5sE5oCKAsEKfR5RjZrZ3U5YjSbcBWVZI4kz5IlXBWaVpc2m9u+b0x0X 1P3dryolsBID/aSU7asPSYwjf1QKt//aTCJ1a39PKbJr1gaZixlRhc1o2mipQY8AKSBmyp pg9Z5InBdiHCd7HS3+vK1oAZ80ZBPuA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-583-vUgzk1nSPDeiVd-Ow8NQ8Q-1; Fri, 30 Jun 2023 07:07:18 -0400 X-MC-Unique: vUgzk1nSPDeiVd-Ow8NQ8Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4595B8019DC; Fri, 30 Jun 2023 11:07:15 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.193.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB455492B02; Fri, 30 Jun 2023 11:07:13 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Laurent Pinchart , Daniel Scally Cc: Hans de Goede , Mauro Carvalho Chehab , Andy Shevchenko , Kate Hsuan , Hao Yao , Bingbu Cao , linux-media@vger.kernel.org Subject: [PATCH v2 07/15] media: ipu-bridge: Only keep PLD around while parsing Date: Fri, 30 Jun 2023 13:06:35 +0200 Message-ID: <20230630110643.209761-8-hdegoede@redhat.com> In-Reply-To: <20230630110643.209761-1-hdegoede@redhat.com> References: <20230630110643.209761-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is no need to keep a reference to the PLD struct around, it is only used once the get the sensor orientation. Make ipu_bridge_parse_orientation() also get + put the PLD. This is a preparation patch for making the ipu-bridge code more generic so that it can be shared with the atomisp driver. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Reviewed-by: Daniel Scally --- drivers/media/pci/intel/ipu-bridge.c | 48 ++++++++++++++++------------ drivers/media/pci/intel/ipu-bridge.h | 1 - 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 8e91d9b3e0fe..3a984d688b42 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -112,23 +112,39 @@ static u32 ipu_bridge_parse_rotation(struct ipu_sensor *sensor) } } -static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct ipu_sensor *sensor) +static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_device *adev) { - switch (sensor->pld->panel) { + enum v4l2_fwnode_orientation orientation; + struct acpi_pld_info *pld; + acpi_status status; + + status = acpi_get_physical_device_location(adev->handle, &pld); + if (ACPI_FAILURE(status)) { + dev_warn(&adev->dev, "_PLD call failed using unknown orientation\n"); + return V4L2_FWNODE_ORIENTATION_EXTERNAL; + } + + switch (pld->panel) { case ACPI_PLD_PANEL_FRONT: - return V4L2_FWNODE_ORIENTATION_FRONT; + orientation = V4L2_FWNODE_ORIENTATION_FRONT; + break; case ACPI_PLD_PANEL_BACK: - return V4L2_FWNODE_ORIENTATION_BACK; + orientation = V4L2_FWNODE_ORIENTATION_BACK; + break; case ACPI_PLD_PANEL_TOP: case ACPI_PLD_PANEL_LEFT: case ACPI_PLD_PANEL_RIGHT: case ACPI_PLD_PANEL_UNKNOWN: - return V4L2_FWNODE_ORIENTATION_EXTERNAL; + orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL; + break; default: - dev_warn(&sensor->adev->dev, "Unknown _PLD panel value %d\n", - sensor->pld->panel); - return V4L2_FWNODE_ORIENTATION_EXTERNAL; + dev_warn(&adev->dev, "Unknown _PLD panel val %d\n", pld->panel); + orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL; + break; } + + ACPI_FREE(pld); + return orientation; } static void ipu_bridge_create_fwnode_properties( @@ -140,7 +156,7 @@ static void ipu_bridge_create_fwnode_properties( enum v4l2_fwnode_orientation orientation; rotation = ipu_bridge_parse_rotation(sensor); - orientation = ipu_bridge_parse_orientation(sensor); + orientation = ipu_bridge_parse_orientation(sensor->adev); sensor->prop_names = prop_names; @@ -279,7 +295,6 @@ static void ipu_bridge_unregister_sensors(struct ipu_bridge *bridge) for (i = 0; i < bridge->n_sensors; i++) { sensor = &bridge->sensors[i]; software_node_unregister_node_group(sensor->group); - ACPI_FREE(sensor->pld); acpi_dev_put(sensor->adev); i2c_unregister_device(sensor->vcm_i2c_client); } @@ -291,7 +306,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, struct fwnode_handle *fwnode, *primary; struct ipu_sensor *sensor; struct acpi_device *adev; - acpi_status status; int ret; for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { @@ -326,17 +340,11 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, sensor->ssdb.vcmtype = 0; } - status = acpi_get_physical_device_location(adev->handle, &sensor->pld); - if (ACPI_FAILURE(status)) { - ret = -ENODEV; - goto err_put_adev; - } - if (sensor->ssdb.lanes > IPU_MAX_LANES) { dev_err(&adev->dev, "Number of lanes in SSDB is invalid\n"); ret = -EINVAL; - goto err_free_pld; + goto err_put_adev; } ipu_bridge_create_fwnode_properties(sensor, bridge, cfg); @@ -344,7 +352,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, ret = software_node_register_node_group(sensor->group); if (ret) - goto err_free_pld; + goto err_put_adev; fwnode = software_node_fwnode(&sensor->swnodes[ SWNODE_SENSOR_HID]); @@ -370,8 +378,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, err_free_swnodes: software_node_unregister_node_group(sensor->group); -err_free_pld: - ACPI_FREE(sensor->pld); err_put_adev: acpi_dev_put(adev); return ret; diff --git a/drivers/media/pci/intel/ipu-bridge.h b/drivers/media/pci/intel/ipu-bridge.h index 6cb68e3344dc..907ca833a7c1 100644 --- a/drivers/media/pci/intel/ipu-bridge.h +++ b/drivers/media/pci/intel/ipu-bridge.h @@ -124,7 +124,6 @@ struct ipu_sensor { struct ipu_node_names node_names; struct ipu_sensor_ssdb ssdb; - struct acpi_pld_info *pld; struct ipu_property_names prop_names; struct property_entry ep_properties[5];