Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55246ba7 authored by Ravikishore Pampana's avatar Ravikishore Pampana Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: tfe: Add support to TFE driver



TFE is thin front end hardware that capture and process the
real time image. Support is added to enable the TFE
hardware.

CRs-Fixed: 2545590
Change-Id: Ie8efef77fabeeea28d70380c398089e6351e35e3
Signed-off-by: default avatarRavikishore Pampana <rpampana@codeaurora.org>
parent 3d5af3d2
Loading
Loading
Loading
Loading
+61 −8
Original line number Diff line number Diff line
@@ -376,6 +376,38 @@ static const char *__cam_isp_resource_handle_id_to_type(
	}
}

static const char *__cam_isp_tfe_resource_handle_id_to_type(
	uint32_t resource_handle)
{

	switch (resource_handle) {
	case CAM_ISP_TFE_OUT_RES_FULL:
		return "FULL";
	case CAM_ISP_TFE_OUT_RES_RAW_DUMP:
		return "RAW_DUMP";
	case CAM_ISP_TFE_OUT_RES_PDAF:
		return "PDAF";
	case CAM_ISP_TFE_OUT_RES_RDI_0:
		return "RDI_0";
	case CAM_ISP_TFE_OUT_RES_RDI_1:
		return "RDI_1";
	case CAM_ISP_TFE_OUT_RES_RDI_2:
		return "RDI_2";
	case CAM_ISP_TFE_OUT_RES_STATS_HDR_BE:
		return "STATS_HDR_BE";
	case CAM_ISP_TFE_OUT_RES_STATS_HDR_BHIST:
		return "STATS_HDR_BHIST";
	case CAM_ISP_TFE_OUT_RES_STATS_TL_BG:
		return "STATS_TL_BG";
	case CAM_ISP_TFE_OUT_RES_STATS_BF:
		return "STATS_BF";
	case CAM_ISP_TFE_OUT_RES_STATS_AWB_BG:
		return "STATS_AWB_BG";
	default:
		return "CAM_ISP_Invalid_Resource_Type";
	}
}

static uint64_t __cam_isp_ctx_get_event_ts(uint32_t evt_id, void *evt_data)
{
	uint64_t ts = 0;
@@ -471,9 +503,11 @@ static void __cam_isp_ctx_send_sof_timestamp(
}

static void __cam_isp_ctx_handle_buf_done_fail_log(
	uint64_t request_id, struct cam_isp_ctx_req *req_isp)
	uint64_t request_id, struct cam_isp_ctx_req *req_isp,
	uint32_t isp_device_type)
{
	int i;
	const char *handle_type;

	if (req_isp->num_fence_map_out >= CAM_ISP_CTX_RES_MAX) {
		CAM_ERR(CAM_ISP,
@@ -490,10 +524,18 @@ static void __cam_isp_ctx_handle_buf_done_fail_log(
		"Resource Handles that fail to generate buf_done in prev frame");
	for (i = 0; i < req_isp->num_fence_map_out; i++) {
		if (req_isp->fence_map_out[i].sync_id != -1) {
			if (isp_device_type == CAM_IFE_DEVICE_TYPE)
				handle_type =
				__cam_isp_resource_handle_id_to_type(
				req_isp->fence_map_out[i].resource_handle);
			else
				handle_type =
				__cam_isp_tfe_resource_handle_id_to_type(
				req_isp->fence_map_out[i].resource_handle);

			CAM_WARN(CAM_ISP,
			"Resource_Handle: [%s][0x%x] Sync_ID: [0x%x]",
			__cam_isp_resource_handle_id_to_type(
			req_isp->fence_map_out[i].resource_handle),
			handle_type,
			req_isp->fence_map_out[i].resource_handle,
			req_isp->fence_map_out[i].sync_id);
		}
@@ -512,6 +554,7 @@ static int __cam_isp_ctx_handle_buf_done_for_request(
	struct cam_isp_ctx_req  *req_isp;
	struct cam_context *ctx = ctx_isp->base;
	uint64_t buf_done_req_id;
	const char *handle_type;

	trace_cam_buf_done("ISP", ctx, req);

@@ -541,11 +584,18 @@ static int __cam_isp_ctx_handle_buf_done_for_request(
		}

		if (req_isp->fence_map_out[j].sync_id == -1) {
			if (ctx_isp->isp_device_type == CAM_IFE_DEVICE_TYPE)
				handle_type =
				__cam_isp_resource_handle_id_to_type(
				req_isp->fence_map_out[i].resource_handle);
			else
				handle_type =
				__cam_isp_tfe_resource_handle_id_to_type(
				req_isp->fence_map_out[i].resource_handle);

			CAM_WARN(CAM_ISP,
				"Duplicate BUF_DONE for req %lld : i=%d, j=%d, res=%s",
				req->request_id, i, j,
				__cam_isp_resource_handle_id_to_type(
				done->resource_handle[i]));
				req->request_id, i, j, handle_type);

			if (done_next_req) {
				done_next_req->resource_handle
@@ -1967,7 +2017,8 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
			active_req_isp =
				(struct cam_isp_ctx_req *) active_req->req_priv;
			__cam_isp_ctx_handle_buf_done_fail_log(
				active_req->request_id, active_req_isp);
				active_req->request_id, active_req_isp,
				ctx_isp->isp_device_type);
		}

		rc = -EFAULT;
@@ -4345,7 +4396,8 @@ int cam_isp_context_init(struct cam_isp_context *ctx,
	struct cam_context *ctx_base,
	struct cam_req_mgr_kmd_ops *crm_node_intf,
	struct cam_hw_mgr_intf *hw_intf,
	uint32_t ctx_id)
	uint32_t ctx_id,
	uint32_t isp_device_type)

{
	int rc = -1;
@@ -4369,6 +4421,7 @@ int cam_isp_context_init(struct cam_isp_context *ctx,
	ctx->substate_machine = cam_isp_ctx_activated_state_machine;
	ctx->substate_machine_irq = cam_isp_ctx_activated_state_machine_irq;
	ctx->init_timestamp = jiffies_to_msecs(jiffies);
	ctx->isp_device_type = isp_device_type;

	for (i = 0; i < CAM_CTX_REQ_MAX; i++) {
		ctx->req_base[i].req_priv = &ctx->req_isp[i];
+6 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/spinlock.h>
#include <media/cam_isp.h>
#include <media/cam_defs.h>
#include <media/cam_tfe.h>

#include "cam_context.h"
#include "cam_isp_hw_mgr_intf.h"
@@ -177,6 +178,7 @@ struct cam_isp_context_state_monitor {
 * @init_received:             Indicate whether init config packet is received
 * @split_acquire:             Indicate whether a separate acquire is expected
 * @init_timestamp:            Timestamp at which this context is initialized
 * @isp_device_type            ISP device type
 *
 */
struct cam_isp_context {
@@ -207,6 +209,7 @@ struct cam_isp_context {
	bool                                  init_received;
	bool                                  split_acquire;
	unsigned int                          init_timestamp;
	uint32_t                              isp_device_type;
};

/**
@@ -218,13 +221,15 @@ struct cam_isp_context {
 * @bridge_ops:         Bridge call back funciton
 * @hw_intf:            ISP hw manager interface
 * @ctx_id:             ID for this context
 * @isp_device_type     Isp device type
 *
 */
int cam_isp_context_init(struct cam_isp_context *ctx,
	struct cam_context *ctx_base,
	struct cam_req_mgr_kmd_ops *bridge_ops,
	struct cam_hw_mgr_intf *hw_intf,
	uint32_t ctx_id);
	uint32_t ctx_id,
	uint32_t isp_device_type);

/**
 * cam_isp_context_deinit()
+22 −3
Original line number Diff line number Diff line
@@ -117,12 +117,30 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
	int i;
	struct cam_hw_mgr_intf         hw_mgr_intf;
	struct cam_node               *node;
	const char                    *compat_str = NULL;
	uint32_t                       isp_device_type;

	int iommu_hdl = -1;

	rc = of_property_read_string_index(pdev->dev.of_node, "arch-compat", 0,
		(const char **)&compat_str);

	g_isp_dev.sd.internal_ops = &cam_isp_subdev_internal_ops;
	/* Initialize the v4l2 subdevice first. (create cam_node) */
	if (strnstr(compat_str, "ife", strlen(compat_str))) {
		rc = cam_subdev_probe(&g_isp_dev.sd, pdev, CAM_ISP_DEV_NAME,
		CAM_IFE_DEVICE_TYPE);
		isp_device_type = CAM_IFE_DEVICE_TYPE;
	} else if (strnstr(compat_str, "tfe", strlen(compat_str))) {
		rc = cam_subdev_probe(&g_isp_dev.sd, pdev, CAM_ISP_DEV_NAME,
		CAM_TFE_DEVICE_TYPE);
		isp_device_type = CAM_TFE_DEVICE_TYPE;
	} else  {
		CAM_ERR(CAM_ISP, "Invalid ISP hw type %s", compat_str);
		rc = -EINVAL;
		goto err;
	}

	if (rc) {
		CAM_ERR(CAM_ISP, "ISP cam_subdev_probe failed!");
		goto err;
@@ -130,7 +148,7 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
	node = (struct cam_node *) g_isp_dev.sd.token;

	memset(&hw_mgr_intf, 0, sizeof(hw_mgr_intf));
	rc = cam_isp_hw_mgr_init(pdev->dev.of_node, &hw_mgr_intf, &iommu_hdl);
	rc = cam_isp_hw_mgr_init(compat_str, &hw_mgr_intf, &iommu_hdl);
	if (rc != 0) {
		CAM_ERR(CAM_ISP, "Can not initialized ISP HW manager!");
		goto unregister;
@@ -141,7 +159,8 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
			&g_isp_dev.ctx[i],
			&node->crm_node_intf,
			&node->hw_mgr_intf,
			i);
			i,
			isp_device_type);
		if (rc) {
			CAM_ERR(CAM_ISP, "ISP context init failed!");
			goto unregister;
+1 −1
Original line number Diff line number Diff line
@@ -14,4 +14,4 @@ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include
ccflags-y += -I$(src)

obj-$(CONFIG_SPECTRA_CAMERA) += hw_utils/ isp_hw/
obj-$(CONFIG_SPECTRA_CAMERA) += cam_isp_hw_mgr.o cam_ife_hw_mgr.o
obj-$(CONFIG_SPECTRA_CAMERA) += cam_isp_hw_mgr.o cam_ife_hw_mgr.o cam_tfe_hw_mgr.o
+7 −8
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 */

#include "cam_isp_hw_mgr_intf.h"
#include "cam_ife_hw_mgr.h"
#include "cam_debug_util.h"
#include "cam_tfe_hw_mgr.h"


int cam_isp_hw_mgr_init(struct device_node *of_node,
int cam_isp_hw_mgr_init(const char   *device_name_str,
	struct cam_hw_mgr_intf *hw_mgr, int *iommu_hdl)
{
	int rc = 0;
	const char *compat_str = NULL;

	rc = of_property_read_string_index(of_node, "arch-compat", 0,
		(const char **)&compat_str);

	if (strnstr(compat_str, "ife", strlen(compat_str)))
	if (strnstr(device_name_str, "ife", strlen(device_name_str)))
		rc = cam_ife_hw_mgr_init(hw_mgr, iommu_hdl);
	else if (strnstr(device_name_str, "tfe", strlen(device_name_str)))
		rc = cam_tfe_hw_mgr_init(hw_mgr, iommu_hdl);
	else {
		CAM_ERR(CAM_ISP, "Invalid ISP hw type");
		CAM_ERR(CAM_ISP, "Invalid ISP hw type :%s", device_name_str);
		rc = -EINVAL;
	}

Loading