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

Commit e1823ed1 authored by Praneeth Paladugu's avatar Praneeth Paladugu
Browse files

msm: vidc: Add support to read venus version through debugfs



Currently Venus release version is printed in kernel logs. So
to get venus version user needs to run video playback\encoding
everytime. Storing version in debugfs is handy.

Change-Id: I6d93c374a4402d41f3912b71f20fb68305d9d742
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent 62b3314e
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -73,7 +73,9 @@ static ssize_t core_info_read(struct file *file, char __user *buf,
{
	struct msm_vidc_core *core = file->private_data;
	struct hfi_device *hdev;
	int i = 0;
	struct hal_fw_info fw_info;
	int i = 0, rc = 0;

	if (!core || !core->device) {
		dprintk(VIDC_ERR, "Invalid params, core: %p\n", core);
		return 0;
@@ -83,19 +85,20 @@ static ssize_t core_info_read(struct file *file, char __user *buf,
	write_str(&dbg_buf, "===============================\n");
	write_str(&dbg_buf, "CORE %d: %p\n", core->id, core);
	write_str(&dbg_buf, "===============================\n");
	write_str(&dbg_buf, "state: %d\n", core->state);
	write_str(&dbg_buf, "base addr: %#x\n",
		call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data,
					FW_BASE_ADDRESS));
	write_str(&dbg_buf, "register_base: %#x\n",
		call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data,
					FW_REGISTER_BASE));
	write_str(&dbg_buf, "register_size: %u\n",
		call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data,
					FW_REGISTER_SIZE));
	write_str(&dbg_buf, "irq: %u\n",
		call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data,
					FW_IRQ));
	write_str(&dbg_buf, "Core state: %d\n", core->state);
	rc = call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data, &fw_info);
	if (rc) {
		dprintk(VIDC_WARN, "Failed to read FW info\n");
		goto err_fw_info;
	}

	write_str(&dbg_buf, "FW version : %s\n", &fw_info.version);
	write_str(&dbg_buf, "base addr: 0x%x\n", fw_info.base_addr);
	write_str(&dbg_buf, "register_base: 0x%x\n", fw_info.register_base);
	write_str(&dbg_buf, "register_size: %u\n", fw_info.register_size);
	write_str(&dbg_buf, "irq: %u\n", fw_info.irq);

err_fw_info:
	for (i = SYS_MSG_START; i < SYS_MSG_END; i++) {
		write_str(&dbg_buf, "completions[%d]: %s\n", i,
			completion_done(&core->completions[SYS_MSG_INDEX(i)]) ?
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <media/msm_vidc.h>
#include <media/msm_media_info.h>

#include "vidc_hfi_api.h"
#include "vidc_hfi_api.h"

#define MSM_VIDC_DRV_NAME "msm_vidc_driver"
+35 −32
Original line number Diff line number Diff line
@@ -4266,52 +4266,55 @@ static void __unload_fw(struct venus_hfi_device *device)
	__deinit_resources(device);
}

static int venus_hfi_get_fw_info(void *dev, enum fw_info info)
static int venus_hfi_get_fw_info(void *dev, struct hal_fw_info *fw_info)
{
	int rc = 0;
	int i = 0, j = 0;
	struct venus_hfi_device *device = dev;
	u32 smem_block_size = 0;
	u8 *smem_table_ptr;
	char version[VENUS_VERSION_LENGTH];
	const u32 smem_image_index_venus = 14 * 128;

	if (!device) {
		dprintk(VIDC_ERR, "%s Invalid paramter: %p\n",
			__func__, device);
	if (!device || !fw_info) {
		dprintk(VIDC_ERR,
			"%s Invalid parameter: device = %pK fw_info = %pK\n",
			__func__, device, fw_info);
		return -EINVAL;
	}

	mutex_lock(&device->lock);

	switch (info) {
	case FW_BASE_ADDRESS:
		rc = (u32)device->hal_data->firmware_base;
		if ((phys_addr_t)rc != device->hal_data->firmware_base) {
			dprintk(VIDC_INFO,
				"%s: firmware_base (%pa) truncated to %#x",
				__func__, &device->hal_data->firmware_base, rc);
		}
		break;
	smem_table_ptr = smem_get_entry(SMEM_IMAGE_VERSION_TABLE,
			&smem_block_size, 0, SMEM_ANY_HOST_FLAG);
	if (smem_table_ptr &&
			((smem_image_index_venus +
			  VENUS_VERSION_LENGTH) <= smem_block_size))
		memcpy(version,
			smem_table_ptr + smem_image_index_venus,
			VENUS_VERSION_LENGTH);

	case FW_REGISTER_BASE:
		rc = (u32)device->res->register_base;
		if ((phys_addr_t)rc != device->res->register_base) {
			dprintk(VIDC_INFO,
				"%s: register_base (%pa) truncated to %#x",
				__func__, &device->res->register_base, rc);
		}
		break;
	while (version[i++] != 'V' && i < VENUS_VERSION_LENGTH)
		;

	case FW_REGISTER_SIZE:
		rc = device->hal_data->register_size;
		break;
	if (i == VENUS_VERSION_LENGTH - 1) {
		dprintk(VIDC_WARN, "Venus version string is not proper\n");
		fw_info->version[0] = '\0';
		goto fail_version_string;
	}

	case FW_IRQ:
		rc = device->hal_data->irq;
		break;
	for (i--; i < VENUS_VERSION_LENGTH && j < VENUS_VERSION_LENGTH; i++)
		fw_info->version[j++] = version[i];
	fw_info->version[j] = '\0';

	default:
		dprintk(VIDC_ERR, "Invalid fw info requested\n");
	}
fail_version_string:
	dprintk(VIDC_DBG, "F/W version retrieved : %s\n", fw_info->version);
	fw_info->base_addr = device->hal_data->firmware_base;
	fw_info->register_base = device->res->register_base;
	fw_info->register_size = device->hal_data->register_size;
	fw_info->irq = device->hal_data->irq;

	mutex_unlock(&device->lock);
	return rc;
	return 0;
}

static int venus_hfi_get_core_capabilities(void *dev)
+10 −9
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@
#define HAL_MAX_MATRIX_COEFFS 9
#define HAL_MAX_BIAS_COEFFS 3
#define HAL_MAX_LIMIT_COEFFS 6
#define VENUS_VERSION_LENGTH 128

enum vidc_status {
	VIDC_ERR_NONE = 0x0,
@@ -1030,6 +1031,14 @@ struct vidc_seq_hdr {
	u32 seq_hdr_len;
};

struct hal_fw_info {
	char version[VENUS_VERSION_LENGTH];
	phys_addr_t base_addr;
	int register_base;
	int register_size;
	int irq;
};

enum hal_flush {
	HAL_FLUSH_INPUT,
	HAL_FLUSH_OUTPUT,
@@ -1325,14 +1334,6 @@ enum msm_vidc_hfi_type {
	VIDC_HFI_VENUS,
};

enum fw_info {
	FW_BASE_ADDRESS,
	FW_REGISTER_BASE,
	FW_REGISTER_SIZE,
	FW_IRQ,
	FW_INFO_MAX,
};

enum msm_vidc_thermal_level {
	VIDC_THERMAL_NORMAL = 0,
	VIDC_THERMAL_LOW,
@@ -1447,7 +1448,7 @@ struct hfi_device {
						unsigned long instant_bitrate);
	int (*vote_bus)(void *dev, struct vidc_bus_vote_data *data,
			int num_data);
	int (*get_fw_info)(void *dev, enum fw_info info);
	int (*get_fw_info)(void *dev, struct hal_fw_info *fw_info);
	int (*session_clean)(void *sess);
	int (*get_core_capabilities)(void *dev);
	int (*suspend)(void *dev);