// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/bitfield.h>
#include "iris_hfi_gen2.h"
#include "iris_hfi_gen2_packet.h"
#define UNSPECIFIED_COLOR_FORMAT 5
#define NUM_SYS_INIT_PACKETS 8
#define NUM_COMV_AV1 18
#define SYS_INIT_PKT_SIZE (sizeof(struct iris_hfi_header) + \
NUM_SYS_INIT_PACKETS * (sizeof(struct iris_hfi_packet) + sizeof(u32)))
#define SYS_IFPC_PKT_SIZE (sizeof(struct iris_hfi_header) + \
sizeof(struct iris_hfi_packet) + sizeof(u32))
#define SYS_NO_PAYLOAD_PKT_SIZE (sizeof(struct iris_hfi_header) + \
sizeof(struct iris_hfi_packet))
static int iris_hfi_gen2_sys_init(struct iris_core *core)
{
struct iris_hfi_header *hdr;
int ret;
hdr = kzalloc(SYS_INIT_PKT_SIZE, GFP_KERNEL);
if (!hdr)
return -ENOMEM;
iris_hfi_gen2_packet_sys_init(core, hdr);
ret = iris_hfi_queue_cmd_write_locked(core, hdr, hdr->size);
kfree(hdr);
return ret;
}
static int iris_hfi_gen2_sys_image_version(struct iris_core *core)
{
struct iris_hfi_header *hdr;
int ret;
hdr = kzalloc(SYS_NO_PAYLOAD_PKT_SIZE, GFP_KERNEL);
if (!hdr)
return -ENOMEM;
iris_hfi_gen2_packet_image_version(core, hdr);
ret = iris_hfi_queue_cmd_write_locked(core, hdr, hdr->size);
kfree(hdr);
return ret;
}
static int iris_hfi_gen2_sys_interframe_powercollapse(struct iris_core *core)
{
struct iris_hfi_header *hdr;
int ret;
hdr = kzalloc(SYS_IFPC_PKT_SIZE, GFP_KERNEL);
if (!hdr)
return -ENOMEM;
iris_hfi_gen2_packet_sys_interframe_powercollapse(core, hdr);
ret = iris_hfi_queue_cmd_write_locked(core, hdr, hdr->size);
kfree(hdr);
return ret;
}
static int iris_hfi_gen2_sys_pc_prep(struct iris_core *core)
{
struct iris_hfi_header *hdr;
int ret;
hdr = kzalloc(SYS_NO_PAYLOAD_PKT_SIZE, GFP_KERNEL);
if