Commit 77c45766 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: ipu-bridge: Only keep PLD around while parsing

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: default avatarAndy Shevchenko <andy@kernel.org>
Reviewed-by: default avatarDaniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent d3cb5f61
...@@ -112,23 +112,39 @@ static u32 ipu_bridge_parse_rotation(struct ipu_sensor *sensor) ...@@ -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 default orientation\n");
return V4L2_FWNODE_ORIENTATION_EXTERNAL;
}
switch (pld->panel) {
case ACPI_PLD_PANEL_FRONT: case ACPI_PLD_PANEL_FRONT:
return V4L2_FWNODE_ORIENTATION_FRONT; orientation = V4L2_FWNODE_ORIENTATION_FRONT;
break;
case ACPI_PLD_PANEL_BACK: 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_TOP:
case ACPI_PLD_PANEL_LEFT: case ACPI_PLD_PANEL_LEFT:
case ACPI_PLD_PANEL_RIGHT: case ACPI_PLD_PANEL_RIGHT:
case ACPI_PLD_PANEL_UNKNOWN: case ACPI_PLD_PANEL_UNKNOWN:
return V4L2_FWNODE_ORIENTATION_EXTERNAL; orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL;
break;
default: default:
dev_warn(&sensor->adev->dev, "Unknown _PLD panel value %d\n", dev_warn(&adev->dev, "Unknown _PLD panel val %d\n", pld->panel);
sensor->pld->panel); orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL;
return V4L2_FWNODE_ORIENTATION_EXTERNAL; break;
} }
ACPI_FREE(pld);
return orientation;
} }
static void ipu_bridge_create_fwnode_properties( static void ipu_bridge_create_fwnode_properties(
...@@ -140,7 +156,7 @@ static void ipu_bridge_create_fwnode_properties( ...@@ -140,7 +156,7 @@ static void ipu_bridge_create_fwnode_properties(
enum v4l2_fwnode_orientation orientation; enum v4l2_fwnode_orientation orientation;
rotation = ipu_bridge_parse_rotation(sensor); rotation = ipu_bridge_parse_rotation(sensor);
orientation = ipu_bridge_parse_orientation(sensor); orientation = ipu_bridge_parse_orientation(sensor->adev);
sensor->prop_names = prop_names; sensor->prop_names = prop_names;
...@@ -279,7 +295,6 @@ static void ipu_bridge_unregister_sensors(struct ipu_bridge *bridge) ...@@ -279,7 +295,6 @@ static void ipu_bridge_unregister_sensors(struct ipu_bridge *bridge)
for (i = 0; i < bridge->n_sensors; i++) { for (i = 0; i < bridge->n_sensors; i++) {
sensor = &bridge->sensors[i]; sensor = &bridge->sensors[i];
software_node_unregister_node_group(sensor->group); software_node_unregister_node_group(sensor->group);
ACPI_FREE(sensor->pld);
acpi_dev_put(sensor->adev); acpi_dev_put(sensor->adev);
i2c_unregister_device(sensor->vcm_i2c_client); i2c_unregister_device(sensor->vcm_i2c_client);
} }
...@@ -291,7 +306,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, ...@@ -291,7 +306,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg,
struct fwnode_handle *fwnode, *primary; struct fwnode_handle *fwnode, *primary;
struct ipu_sensor *sensor; struct ipu_sensor *sensor;
struct acpi_device *adev; struct acpi_device *adev;
acpi_status status;
int ret; int ret;
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { 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, ...@@ -326,17 +340,11 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg,
sensor->ssdb.vcmtype = 0; 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) { if (sensor->ssdb.lanes > IPU_MAX_LANES) {
dev_err(&adev->dev, dev_err(&adev->dev,
"Number of lanes in SSDB is invalid\n"); "Number of lanes in SSDB is invalid\n");
ret = -EINVAL; ret = -EINVAL;
goto err_free_pld; goto err_put_adev;
} }
ipu_bridge_create_fwnode_properties(sensor, bridge, cfg); ipu_bridge_create_fwnode_properties(sensor, bridge, cfg);
...@@ -344,7 +352,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *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); ret = software_node_register_node_group(sensor->group);
if (ret) if (ret)
goto err_free_pld; goto err_put_adev;
fwnode = software_node_fwnode(&sensor->swnodes[ fwnode = software_node_fwnode(&sensor->swnodes[
SWNODE_SENSOR_HID]); SWNODE_SENSOR_HID]);
...@@ -370,8 +378,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, ...@@ -370,8 +378,6 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg,
err_free_swnodes: err_free_swnodes:
software_node_unregister_node_group(sensor->group); software_node_unregister_node_group(sensor->group);
err_free_pld:
ACPI_FREE(sensor->pld);
err_put_adev: err_put_adev:
acpi_dev_put(adev); acpi_dev_put(adev);
return ret; return ret;
......
...@@ -124,7 +124,6 @@ struct ipu_sensor { ...@@ -124,7 +124,6 @@ struct ipu_sensor {
struct ipu_node_names node_names; struct ipu_node_names node_names;
struct ipu_sensor_ssdb ssdb; struct ipu_sensor_ssdb ssdb;
struct acpi_pld_info *pld;
struct ipu_property_names prop_names; struct ipu_property_names prop_names;
struct property_entry ep_properties[5]; struct property_entry ep_properties[5];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment