197fb5e8dSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
209c2845eSStanimir Varbanov /*
309c2845eSStanimir Varbanov * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
409c2845eSStanimir Varbanov * Copyright (C) 2017 Linaro Ltd.
509c2845eSStanimir Varbanov */
6c73c23f3SGustavo A. R. Silva #include <linux/overflow.h>
709c2845eSStanimir Varbanov #include <linux/errno.h>
809c2845eSStanimir Varbanov #include <linux/hash.h>
909c2845eSStanimir Varbanov
1009c2845eSStanimir Varbanov #include "hfi_cmds.h"
1109c2845eSStanimir Varbanov
1209c2845eSStanimir Varbanov static enum hfi_version hfi_ver;
1309c2845eSStanimir Varbanov
pkt_sys_init(struct hfi_sys_init_pkt * pkt,u32 arch_type)1409c2845eSStanimir Varbanov void pkt_sys_init(struct hfi_sys_init_pkt *pkt, u32 arch_type)
1509c2845eSStanimir Varbanov {
1609c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
1709c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_INIT;
1809c2845eSStanimir Varbanov pkt->arch_type = arch_type;
1909c2845eSStanimir Varbanov }
2009c2845eSStanimir Varbanov
pkt_sys_pc_prep(struct hfi_sys_pc_prep_pkt * pkt)2109c2845eSStanimir Varbanov void pkt_sys_pc_prep(struct hfi_sys_pc_prep_pkt *pkt)
2209c2845eSStanimir Varbanov {
2309c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
2409c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_PC_PREP;
2509c2845eSStanimir Varbanov }
2609c2845eSStanimir Varbanov
pkt_sys_idle_indicator(struct hfi_sys_set_property_pkt * pkt,u32 enable)2709c2845eSStanimir Varbanov void pkt_sys_idle_indicator(struct hfi_sys_set_property_pkt *pkt, u32 enable)
2809c2845eSStanimir Varbanov {
2909c2845eSStanimir Varbanov struct hfi_enable *hfi = (struct hfi_enable *)&pkt->data[1];
3009c2845eSStanimir Varbanov
31c73c23f3SGustavo A. R. Silva pkt->hdr.size = struct_size(pkt, data, 1) + sizeof(*hfi);
3209c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
3309c2845eSStanimir Varbanov pkt->num_properties = 1;
3409c2845eSStanimir Varbanov pkt->data[0] = HFI_PROPERTY_SYS_IDLE_INDICATOR;
3509c2845eSStanimir Varbanov hfi->enable = enable;
3609c2845eSStanimir Varbanov }
3709c2845eSStanimir Varbanov
pkt_sys_debug_config(struct hfi_sys_set_property_pkt * pkt,u32 mode,u32 config)3809c2845eSStanimir Varbanov void pkt_sys_debug_config(struct hfi_sys_set_property_pkt *pkt, u32 mode,
3909c2845eSStanimir Varbanov u32 config)
4009c2845eSStanimir Varbanov {
4109c2845eSStanimir Varbanov struct hfi_debug_config *hfi;
4209c2845eSStanimir Varbanov
43c73c23f3SGustavo A. R. Silva pkt->hdr.size = struct_size(pkt, data, 1) + sizeof(*hfi);
4409c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
4509c2845eSStanimir Varbanov pkt->num_properties = 1;
4609c2845eSStanimir Varbanov pkt->data[0] = HFI_PROPERTY_SYS_DEBUG_CONFIG;
4709c2845eSStanimir Varbanov hfi = (struct hfi_debug_config *)&pkt->data[1];
4809c2845eSStanimir Varbanov hfi->config = config;
4909c2845eSStanimir Varbanov hfi->mode = mode;
5009c2845eSStanimir Varbanov }
5109c2845eSStanimir Varbanov
pkt_sys_coverage_config(struct hfi_sys_set_property_pkt * pkt,u32 mode)5209c2845eSStanimir Varbanov void pkt_sys_coverage_config(struct hfi_sys_set_property_pkt *pkt, u32 mode)
5309c2845eSStanimir Varbanov {
54c73c23f3SGustavo A. R. Silva pkt->hdr.size = struct_size(pkt, data, 2);
5509c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
5609c2845eSStanimir Varbanov pkt->num_properties = 1;
5709c2845eSStanimir Varbanov pkt->data[0] = HFI_PROPERTY_SYS_CONFIG_COVERAGE;
5809c2845eSStanimir Varbanov pkt->data[1] = mode;
5909c2845eSStanimir Varbanov }
6009c2845eSStanimir Varbanov
pkt_sys_ubwc_config(struct hfi_sys_set_property_pkt * pkt,const struct hfi_ubwc_config * hfi)61b228cf38SVikash Garodia void pkt_sys_ubwc_config(struct hfi_sys_set_property_pkt *pkt, const struct hfi_ubwc_config *hfi)
62b228cf38SVikash Garodia {
63b228cf38SVikash Garodia pkt->hdr.size = struct_size(pkt, data, 1) + sizeof(*hfi);
64b228cf38SVikash Garodia pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
65b228cf38SVikash Garodia pkt->num_properties = 1;
66b228cf38SVikash Garodia pkt->data[0] = HFI_PROPERTY_SYS_UBWC_CONFIG;
67b228cf38SVikash Garodia memcpy(&pkt->data[1], hfi, sizeof(*hfi));
68b228cf38SVikash Garodia }
69b228cf38SVikash Garodia
pkt_sys_set_resource(struct hfi_sys_set_resource_pkt * pkt,u32 id,u32 size,u32 addr,void * cookie)7009c2845eSStanimir Varbanov int pkt_sys_set_resource(struct hfi_sys_set_resource_pkt *pkt, u32 id, u32 size,
7109c2845eSStanimir Varbanov u32 addr, void *cookie)
7209c2845eSStanimir Varbanov {
7309c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
7409c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_SET_RESOURCE;
7509c2845eSStanimir Varbanov pkt->resource_handle = hash32_ptr(cookie);
7609c2845eSStanimir Varbanov
7709c2845eSStanimir Varbanov switch (id) {
7809c2845eSStanimir Varbanov case VIDC_RESOURCE_OCMEM:
7909c2845eSStanimir Varbanov case VIDC_RESOURCE_VMEM: {
8009c2845eSStanimir Varbanov struct hfi_resource_ocmem *res =
8109c2845eSStanimir Varbanov (struct hfi_resource_ocmem *)&pkt->resource_data[0];
8209c2845eSStanimir Varbanov
8309c2845eSStanimir Varbanov res->size = size;
8409c2845eSStanimir Varbanov res->mem = addr;
8509c2845eSStanimir Varbanov pkt->resource_type = HFI_RESOURCE_OCMEM;
86a0eadbe9SGustavo A. R. Silva pkt->hdr.size += sizeof(*res);
8709c2845eSStanimir Varbanov break;
8809c2845eSStanimir Varbanov }
8909c2845eSStanimir Varbanov case VIDC_RESOURCE_NONE:
9009c2845eSStanimir Varbanov default:
9109c2845eSStanimir Varbanov return -ENOTSUPP;
9209c2845eSStanimir Varbanov }
9309c2845eSStanimir Varbanov
9409c2845eSStanimir Varbanov return 0;
9509c2845eSStanimir Varbanov }
9609c2845eSStanimir Varbanov
pkt_sys_unset_resource(struct hfi_sys_release_resource_pkt * pkt,u32 id,u32 size,void * cookie)9709c2845eSStanimir Varbanov int pkt_sys_unset_resource(struct hfi_sys_release_resource_pkt *pkt, u32 id,
9809c2845eSStanimir Varbanov u32 size, void *cookie)
9909c2845eSStanimir Varbanov {
10009c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
10109c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_RELEASE_RESOURCE;
10209c2845eSStanimir Varbanov pkt->resource_handle = hash32_ptr(cookie);
10309c2845eSStanimir Varbanov
10409c2845eSStanimir Varbanov switch (id) {
10509c2845eSStanimir Varbanov case VIDC_RESOURCE_OCMEM:
10609c2845eSStanimir Varbanov case VIDC_RESOURCE_VMEM:
10709c2845eSStanimir Varbanov pkt->resource_type = HFI_RESOURCE_OCMEM;
10809c2845eSStanimir Varbanov break;
10909c2845eSStanimir Varbanov case VIDC_RESOURCE_NONE:
11009c2845eSStanimir Varbanov break;
11109c2845eSStanimir Varbanov default:
11209c2845eSStanimir Varbanov return -ENOTSUPP;
11309c2845eSStanimir Varbanov }
11409c2845eSStanimir Varbanov
11509c2845eSStanimir Varbanov return 0;
11609c2845eSStanimir Varbanov }
11709c2845eSStanimir Varbanov
pkt_sys_ping(struct hfi_sys_ping_pkt * pkt,u32 cookie)11809c2845eSStanimir Varbanov void pkt_sys_ping(struct hfi_sys_ping_pkt *pkt, u32 cookie)
11909c2845eSStanimir Varbanov {
12009c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
12109c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_PING;
12209c2845eSStanimir Varbanov pkt->client_data = cookie;
12309c2845eSStanimir Varbanov }
12409c2845eSStanimir Varbanov
pkt_sys_power_control(struct hfi_sys_set_property_pkt * pkt,u32 enable)12509c2845eSStanimir Varbanov void pkt_sys_power_control(struct hfi_sys_set_property_pkt *pkt, u32 enable)
12609c2845eSStanimir Varbanov {
12709c2845eSStanimir Varbanov struct hfi_enable *hfi = (struct hfi_enable *)&pkt->data[1];
12809c2845eSStanimir Varbanov
129c73c23f3SGustavo A. R. Silva pkt->hdr.size = struct_size(pkt, data, 1) + sizeof(*hfi);
13009c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
13109c2845eSStanimir Varbanov pkt->num_properties = 1;
13209c2845eSStanimir Varbanov pkt->data[0] = HFI_PROPERTY_SYS_CODEC_POWER_PLANE_CTRL;
13309c2845eSStanimir Varbanov hfi->enable = enable;
13409c2845eSStanimir Varbanov }
13509c2845eSStanimir Varbanov
pkt_sys_ssr_cmd(struct hfi_sys_test_ssr_pkt * pkt,u32 trigger_type)13609c2845eSStanimir Varbanov int pkt_sys_ssr_cmd(struct hfi_sys_test_ssr_pkt *pkt, u32 trigger_type)
13709c2845eSStanimir Varbanov {
13809c2845eSStanimir Varbanov switch (trigger_type) {
13909c2845eSStanimir Varbanov case HFI_TEST_SSR_SW_ERR_FATAL:
14009c2845eSStanimir Varbanov case HFI_TEST_SSR_SW_DIV_BY_ZERO:
14109c2845eSStanimir Varbanov case HFI_TEST_SSR_HW_WDOG_IRQ:
14209c2845eSStanimir Varbanov break;
14309c2845eSStanimir Varbanov default:
14409c2845eSStanimir Varbanov return -EINVAL;
14509c2845eSStanimir Varbanov }
14609c2845eSStanimir Varbanov
14709c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
14809c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_TEST_SSR;
14909c2845eSStanimir Varbanov pkt->trigger_type = trigger_type;
15009c2845eSStanimir Varbanov
15109c2845eSStanimir Varbanov return 0;
15209c2845eSStanimir Varbanov }
15309c2845eSStanimir Varbanov
pkt_sys_image_version(struct hfi_sys_get_property_pkt * pkt)15409c2845eSStanimir Varbanov void pkt_sys_image_version(struct hfi_sys_get_property_pkt *pkt)
15509c2845eSStanimir Varbanov {
15609c2845eSStanimir Varbanov pkt->hdr.size = sizeof(*pkt);
15709c2845eSStanimir Varbanov pkt->hdr.pkt_type = HFI_CMD_SYS_GET_PROPERTY;
15809c2845eSStanimir Varbanov pkt->num_properties = 1;
159d604a7bfSRicardo Ribalda pkt->data = HFI_PROPERTY_SYS_IMAGE_VERSION;
16009c2845eSStanimir Varbanov }
16109c2845eSStanimir Varbanov
pkt_session_init(struct hfi_session_init_pkt * pkt,void * cookie,u32 session_type,u32 codec)16209c2845eSStanimir Varbanov int pkt_session_init(struct hfi_session_init_pkt *pkt, void *cookie,
16309c2845eSStanimir Varbanov u32 session_type, u32 codec)
16409c2845eSStanimir Varbanov {
16509c2845eSStanimir Varbanov if (!pkt || !cookie || !codec)
16609c2845eSStanimir Varbanov return -EINVAL;
16709c2845eSStanimir Varbanov
16809c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
16909c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SYS_SESSION_INIT;
17009c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
17109c2845eSStanimir Varbanov pkt->session_domain = session_type;
17209c2845eSStanimir Varbanov pkt->session_codec = codec;
17309c2845eSStanimir Varbanov
17409c2845eSStanimir Varbanov return 0;
17509c2845eSStanimir Varbanov }
17609c2845eSStanimir Varbanov
pkt_session_cmd(struct hfi_session_pkt * pkt,u32 pkt_type,void * cookie)17709c2845eSStanimir Varbanov void pkt_session_cmd(struct hfi_session_pkt *pkt, u32 pkt_type, void *cookie)
17809c2845eSStanimir Varbanov {
17909c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
18009c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = pkt_type;
18109c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
18209c2845eSStanimir Varbanov }
18309c2845eSStanimir Varbanov
pkt_session_set_buffers(struct hfi_session_set_buffers_pkt * pkt,void * cookie,struct hfi_buffer_desc * bd)18409c2845eSStanimir Varbanov int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt,
18509c2845eSStanimir Varbanov void *cookie, struct hfi_buffer_desc *bd)
18609c2845eSStanimir Varbanov {
18709c2845eSStanimir Varbanov unsigned int i;
18809c2845eSStanimir Varbanov
18909c2845eSStanimir Varbanov if (!cookie || !pkt || !bd)
19009c2845eSStanimir Varbanov return -EINVAL;
19109c2845eSStanimir Varbanov
19209c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_BUFFERS;
19309c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
19409c2845eSStanimir Varbanov pkt->buffer_size = bd->buffer_size;
19509c2845eSStanimir Varbanov pkt->min_buffer_size = bd->buffer_size;
19609c2845eSStanimir Varbanov pkt->num_buffers = bd->num_buffers;
19709c2845eSStanimir Varbanov
19809c2845eSStanimir Varbanov if (bd->buffer_type == HFI_BUFFER_OUTPUT ||
19909c2845eSStanimir Varbanov bd->buffer_type == HFI_BUFFER_OUTPUT2) {
20009c2845eSStanimir Varbanov struct hfi_buffer_info *bi;
20109c2845eSStanimir Varbanov
20209c2845eSStanimir Varbanov pkt->extradata_size = bd->extradata_size;
20340c02059SGustavo A. R. Silva pkt->shdr.hdr.size = sizeof(*pkt) +
20440c02059SGustavo A. R. Silva bd->num_buffers * sizeof(*bi);
20509c2845eSStanimir Varbanov bi = (struct hfi_buffer_info *)pkt->buffer_info;
20609c2845eSStanimir Varbanov for (i = 0; i < pkt->num_buffers; i++) {
20709c2845eSStanimir Varbanov bi->buffer_addr = bd->device_addr;
20809c2845eSStanimir Varbanov bi->extradata_addr = bd->extradata_addr;
20909c2845eSStanimir Varbanov }
21009c2845eSStanimir Varbanov } else {
21109c2845eSStanimir Varbanov pkt->extradata_size = 0;
212e03ac408SGustavo A. R. Silva pkt->shdr.hdr.size = struct_size(pkt, buffer_info,
213e03ac408SGustavo A. R. Silva bd->num_buffers);
21409c2845eSStanimir Varbanov for (i = 0; i < pkt->num_buffers; i++)
21509c2845eSStanimir Varbanov pkt->buffer_info[i] = bd->device_addr;
21609c2845eSStanimir Varbanov }
21709c2845eSStanimir Varbanov
21809c2845eSStanimir Varbanov pkt->buffer_type = bd->buffer_type;
21909c2845eSStanimir Varbanov
22009c2845eSStanimir Varbanov return 0;
22109c2845eSStanimir Varbanov }
22209c2845eSStanimir Varbanov
pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt * pkt,void * cookie,struct hfi_buffer_desc * bd)22309c2845eSStanimir Varbanov int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt,
22409c2845eSStanimir Varbanov void *cookie, struct hfi_buffer_desc *bd)
22509c2845eSStanimir Varbanov {
22609c2845eSStanimir Varbanov unsigned int i;
22709c2845eSStanimir Varbanov
22809c2845eSStanimir Varbanov if (!cookie || !pkt || !bd)
22909c2845eSStanimir Varbanov return -EINVAL;
23009c2845eSStanimir Varbanov
23109c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_RELEASE_BUFFERS;
23209c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
23309c2845eSStanimir Varbanov pkt->buffer_size = bd->buffer_size;
23409c2845eSStanimir Varbanov pkt->num_buffers = bd->num_buffers;
23509c2845eSStanimir Varbanov
23609c2845eSStanimir Varbanov if (bd->buffer_type == HFI_BUFFER_OUTPUT ||
23709c2845eSStanimir Varbanov bd->buffer_type == HFI_BUFFER_OUTPUT2) {
23809c2845eSStanimir Varbanov struct hfi_buffer_info *bi;
23909c2845eSStanimir Varbanov
24009c2845eSStanimir Varbanov bi = (struct hfi_buffer_info *)pkt->buffer_info;
24109c2845eSStanimir Varbanov for (i = 0; i < pkt->num_buffers; i++) {
24209c2845eSStanimir Varbanov bi->buffer_addr = bd->device_addr;
24309c2845eSStanimir Varbanov bi->extradata_addr = bd->extradata_addr;
24409c2845eSStanimir Varbanov }
24509c2845eSStanimir Varbanov pkt->shdr.hdr.size =
24640c02059SGustavo A. R. Silva sizeof(struct hfi_session_set_buffers_pkt) +
24740c02059SGustavo A. R. Silva bd->num_buffers * sizeof(*bi);
24809c2845eSStanimir Varbanov } else {
24909c2845eSStanimir Varbanov for (i = 0; i < pkt->num_buffers; i++)
25009c2845eSStanimir Varbanov pkt->buffer_info[i] = bd->device_addr;
25109c2845eSStanimir Varbanov
25209c2845eSStanimir Varbanov pkt->extradata_size = 0;
25309c2845eSStanimir Varbanov pkt->shdr.hdr.size =
254cdddb626SGustavo A. R. Silva struct_size_t(struct hfi_session_set_buffers_pkt,
255e03ac408SGustavo A. R. Silva buffer_info, bd->num_buffers);
25609c2845eSStanimir Varbanov }
25709c2845eSStanimir Varbanov
25809c2845eSStanimir Varbanov pkt->response_req = bd->response_required;
25909c2845eSStanimir Varbanov pkt->buffer_type = bd->buffer_type;
26009c2845eSStanimir Varbanov
26109c2845eSStanimir Varbanov return 0;
26209c2845eSStanimir Varbanov }
26309c2845eSStanimir Varbanov
pkt_session_etb_decoder(struct hfi_session_empty_buffer_compressed_pkt * pkt,void * cookie,struct hfi_frame_data * in_frame)26409c2845eSStanimir Varbanov int pkt_session_etb_decoder(struct hfi_session_empty_buffer_compressed_pkt *pkt,
26509c2845eSStanimir Varbanov void *cookie, struct hfi_frame_data *in_frame)
26609c2845eSStanimir Varbanov {
26783af5738SStanimir Varbanov if (!cookie)
26809c2845eSStanimir Varbanov return -EINVAL;
26909c2845eSStanimir Varbanov
27009c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
27109c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_EMPTY_BUFFER;
27209c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
27309c2845eSStanimir Varbanov pkt->time_stamp_hi = upper_32_bits(in_frame->timestamp);
27409c2845eSStanimir Varbanov pkt->time_stamp_lo = lower_32_bits(in_frame->timestamp);
27509c2845eSStanimir Varbanov pkt->flags = in_frame->flags;
27609c2845eSStanimir Varbanov pkt->mark_target = in_frame->mark_target;
27709c2845eSStanimir Varbanov pkt->mark_data = in_frame->mark_data;
27809c2845eSStanimir Varbanov pkt->offset = in_frame->offset;
27909c2845eSStanimir Varbanov pkt->alloc_len = in_frame->alloc_len;
28009c2845eSStanimir Varbanov pkt->filled_len = in_frame->filled_len;
28109c2845eSStanimir Varbanov pkt->input_tag = in_frame->clnt_data;
28209c2845eSStanimir Varbanov pkt->packet_buffer = in_frame->device_addr;
28309c2845eSStanimir Varbanov
28409c2845eSStanimir Varbanov return 0;
28509c2845eSStanimir Varbanov }
28609c2845eSStanimir Varbanov
pkt_session_etb_encoder(struct hfi_session_empty_buffer_uncompressed_plane0_pkt * pkt,void * cookie,struct hfi_frame_data * in_frame)28709c2845eSStanimir Varbanov int pkt_session_etb_encoder(
28809c2845eSStanimir Varbanov struct hfi_session_empty_buffer_uncompressed_plane0_pkt *pkt,
28909c2845eSStanimir Varbanov void *cookie, struct hfi_frame_data *in_frame)
29009c2845eSStanimir Varbanov {
29109c2845eSStanimir Varbanov if (!cookie || !in_frame->device_addr)
29209c2845eSStanimir Varbanov return -EINVAL;
29309c2845eSStanimir Varbanov
29409c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
29509c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_EMPTY_BUFFER;
29609c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
29709c2845eSStanimir Varbanov pkt->view_id = 0;
29809c2845eSStanimir Varbanov pkt->time_stamp_hi = upper_32_bits(in_frame->timestamp);
29909c2845eSStanimir Varbanov pkt->time_stamp_lo = lower_32_bits(in_frame->timestamp);
30009c2845eSStanimir Varbanov pkt->flags = in_frame->flags;
30109c2845eSStanimir Varbanov pkt->mark_target = in_frame->mark_target;
30209c2845eSStanimir Varbanov pkt->mark_data = in_frame->mark_data;
30309c2845eSStanimir Varbanov pkt->offset = in_frame->offset;
30409c2845eSStanimir Varbanov pkt->alloc_len = in_frame->alloc_len;
30509c2845eSStanimir Varbanov pkt->filled_len = in_frame->filled_len;
30609c2845eSStanimir Varbanov pkt->input_tag = in_frame->clnt_data;
30709c2845eSStanimir Varbanov pkt->packet_buffer = in_frame->device_addr;
30809c2845eSStanimir Varbanov pkt->extradata_buffer = in_frame->extradata_addr;
30909c2845eSStanimir Varbanov
31009c2845eSStanimir Varbanov return 0;
31109c2845eSStanimir Varbanov }
31209c2845eSStanimir Varbanov
pkt_session_ftb(struct hfi_session_fill_buffer_pkt * pkt,void * cookie,struct hfi_frame_data * out_frame)31309c2845eSStanimir Varbanov int pkt_session_ftb(struct hfi_session_fill_buffer_pkt *pkt, void *cookie,
31409c2845eSStanimir Varbanov struct hfi_frame_data *out_frame)
31509c2845eSStanimir Varbanov {
31609c2845eSStanimir Varbanov if (!cookie || !out_frame || !out_frame->device_addr)
31709c2845eSStanimir Varbanov return -EINVAL;
31809c2845eSStanimir Varbanov
31909c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
32009c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_FILL_BUFFER;
32109c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
32209c2845eSStanimir Varbanov
32309c2845eSStanimir Varbanov if (out_frame->buffer_type == HFI_BUFFER_OUTPUT)
32409c2845eSStanimir Varbanov pkt->stream_id = 0;
32509c2845eSStanimir Varbanov else if (out_frame->buffer_type == HFI_BUFFER_OUTPUT2)
32609c2845eSStanimir Varbanov pkt->stream_id = 1;
32709c2845eSStanimir Varbanov
32809c2845eSStanimir Varbanov pkt->output_tag = out_frame->clnt_data;
32909c2845eSStanimir Varbanov pkt->packet_buffer = out_frame->device_addr;
33009c2845eSStanimir Varbanov pkt->extradata_buffer = out_frame->extradata_addr;
33109c2845eSStanimir Varbanov pkt->alloc_len = out_frame->alloc_len;
33209c2845eSStanimir Varbanov pkt->filled_len = out_frame->filled_len;
33309c2845eSStanimir Varbanov pkt->offset = out_frame->offset;
334*87210c80SRicardo Ribalda pkt->data = out_frame->extradata_size;
33509c2845eSStanimir Varbanov
33609c2845eSStanimir Varbanov return 0;
33709c2845eSStanimir Varbanov }
33809c2845eSStanimir Varbanov
pkt_session_parse_seq_header(struct hfi_session_parse_sequence_header_pkt * pkt,void * cookie,u32 seq_hdr,u32 seq_hdr_len)33909c2845eSStanimir Varbanov int pkt_session_parse_seq_header(
34009c2845eSStanimir Varbanov struct hfi_session_parse_sequence_header_pkt *pkt,
34109c2845eSStanimir Varbanov void *cookie, u32 seq_hdr, u32 seq_hdr_len)
34209c2845eSStanimir Varbanov {
34309c2845eSStanimir Varbanov if (!cookie || !seq_hdr || !seq_hdr_len)
34409c2845eSStanimir Varbanov return -EINVAL;
34509c2845eSStanimir Varbanov
34609c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
34709c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER;
34809c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
34909c2845eSStanimir Varbanov pkt->header_len = seq_hdr_len;
35009c2845eSStanimir Varbanov pkt->packet_buffer = seq_hdr;
35109c2845eSStanimir Varbanov
35209c2845eSStanimir Varbanov return 0;
35309c2845eSStanimir Varbanov }
35409c2845eSStanimir Varbanov
pkt_session_get_seq_hdr(struct hfi_session_get_sequence_header_pkt * pkt,void * cookie,u32 seq_hdr,u32 seq_hdr_len)35509c2845eSStanimir Varbanov int pkt_session_get_seq_hdr(struct hfi_session_get_sequence_header_pkt *pkt,
35609c2845eSStanimir Varbanov void *cookie, u32 seq_hdr, u32 seq_hdr_len)
35709c2845eSStanimir Varbanov {
35809c2845eSStanimir Varbanov if (!cookie || !seq_hdr || !seq_hdr_len)
35909c2845eSStanimir Varbanov return -EINVAL;
36009c2845eSStanimir Varbanov
36109c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
36209c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_SEQUENCE_HEADER;
36309c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
36409c2845eSStanimir Varbanov pkt->buffer_len = seq_hdr_len;
36509c2845eSStanimir Varbanov pkt->packet_buffer = seq_hdr;
36609c2845eSStanimir Varbanov
36709c2845eSStanimir Varbanov return 0;
36809c2845eSStanimir Varbanov }
36909c2845eSStanimir Varbanov
pkt_session_flush(struct hfi_session_flush_pkt * pkt,void * cookie,u32 type)37009c2845eSStanimir Varbanov int pkt_session_flush(struct hfi_session_flush_pkt *pkt, void *cookie, u32 type)
37109c2845eSStanimir Varbanov {
37209c2845eSStanimir Varbanov switch (type) {
37309c2845eSStanimir Varbanov case HFI_FLUSH_INPUT:
37409c2845eSStanimir Varbanov case HFI_FLUSH_OUTPUT:
37509c2845eSStanimir Varbanov case HFI_FLUSH_OUTPUT2:
37609c2845eSStanimir Varbanov case HFI_FLUSH_ALL:
37709c2845eSStanimir Varbanov break;
37809c2845eSStanimir Varbanov default:
37909c2845eSStanimir Varbanov return -EINVAL;
38009c2845eSStanimir Varbanov }
38109c2845eSStanimir Varbanov
38209c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
38309c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH;
38409c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
38509c2845eSStanimir Varbanov pkt->flush_type = type;
38609c2845eSStanimir Varbanov
38709c2845eSStanimir Varbanov return 0;
38809c2845eSStanimir Varbanov }
38909c2845eSStanimir Varbanov
pkt_session_get_property_1x(struct hfi_session_get_property_pkt * pkt,void * cookie,u32 ptype)39009c2845eSStanimir Varbanov static int pkt_session_get_property_1x(struct hfi_session_get_property_pkt *pkt,
39109c2845eSStanimir Varbanov void *cookie, u32 ptype)
39209c2845eSStanimir Varbanov {
39309c2845eSStanimir Varbanov switch (ptype) {
39409c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT:
39509c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS:
39609c2845eSStanimir Varbanov break;
39709c2845eSStanimir Varbanov default:
39809c2845eSStanimir Varbanov return -EINVAL;
39909c2845eSStanimir Varbanov }
40009c2845eSStanimir Varbanov
40109c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
40209c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_PROPERTY;
40309c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
40409c2845eSStanimir Varbanov pkt->num_properties = 1;
405886115c4SRicardo Ribalda pkt->data = ptype;
40609c2845eSStanimir Varbanov
40709c2845eSStanimir Varbanov return 0;
40809c2845eSStanimir Varbanov }
40909c2845eSStanimir Varbanov
pkt_session_set_property_1x(struct hfi_session_set_property_pkt * pkt,void * cookie,u32 ptype,void * pdata)41009c2845eSStanimir Varbanov static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt,
41109c2845eSStanimir Varbanov void *cookie, u32 ptype, void *pdata)
41209c2845eSStanimir Varbanov {
4132b2e6488SStanimir Varbanov void *prop_data;
41409c2845eSStanimir Varbanov int ret = 0;
41509c2845eSStanimir Varbanov
41609c2845eSStanimir Varbanov if (!pkt || !cookie || !pdata)
41709c2845eSStanimir Varbanov return -EINVAL;
41809c2845eSStanimir Varbanov
4192b2e6488SStanimir Varbanov prop_data = &pkt->data[1];
4202b2e6488SStanimir Varbanov
42109c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
42209c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY;
42309c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
42409c2845eSStanimir Varbanov pkt->num_properties = 1;
425f3105f0aSStanimir Varbanov pkt->data[0] = ptype;
42609c2845eSStanimir Varbanov
42709c2845eSStanimir Varbanov switch (ptype) {
42809c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_FRAME_RATE: {
42909c2845eSStanimir Varbanov struct hfi_framerate *in = pdata, *frate = prop_data;
43009c2845eSStanimir Varbanov
43109c2845eSStanimir Varbanov frate->buffer_type = in->buffer_type;
43209c2845eSStanimir Varbanov frate->framerate = in->framerate;
43309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*frate);
43409c2845eSStanimir Varbanov break;
43509c2845eSStanimir Varbanov }
43609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT: {
43709c2845eSStanimir Varbanov struct hfi_uncompressed_format_select *in = pdata;
43809c2845eSStanimir Varbanov struct hfi_uncompressed_format_select *hfi = prop_data;
43909c2845eSStanimir Varbanov
44009c2845eSStanimir Varbanov hfi->buffer_type = in->buffer_type;
44109c2845eSStanimir Varbanov hfi->format = in->format;
44209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi);
44309c2845eSStanimir Varbanov break;
44409c2845eSStanimir Varbanov }
44509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_FRAME_SIZE: {
44609c2845eSStanimir Varbanov struct hfi_framesize *in = pdata, *fsize = prop_data;
44709c2845eSStanimir Varbanov
44809c2845eSStanimir Varbanov fsize->buffer_type = in->buffer_type;
44909c2845eSStanimir Varbanov fsize->height = in->height;
45009c2845eSStanimir Varbanov fsize->width = in->width;
45109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*fsize);
45209c2845eSStanimir Varbanov break;
45309c2845eSStanimir Varbanov }
45409c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_REALTIME: {
45509c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
45609c2845eSStanimir Varbanov
45709c2845eSStanimir Varbanov en->enable = in->enable;
45809c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
45909c2845eSStanimir Varbanov break;
46009c2845eSStanimir Varbanov }
46109c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: {
46209c2845eSStanimir Varbanov struct hfi_buffer_count_actual *in = pdata, *count = prop_data;
46309c2845eSStanimir Varbanov
46409c2845eSStanimir Varbanov count->count_actual = in->count_actual;
46509c2845eSStanimir Varbanov count->type = in->type;
46609c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count);
46709c2845eSStanimir Varbanov break;
46809c2845eSStanimir Varbanov }
46909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL: {
47009c2845eSStanimir Varbanov struct hfi_buffer_size_actual *in = pdata, *sz = prop_data;
47109c2845eSStanimir Varbanov
47209c2845eSStanimir Varbanov sz->size = in->size;
47309c2845eSStanimir Varbanov sz->type = in->type;
47409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*sz);
47509c2845eSStanimir Varbanov break;
47609c2845eSStanimir Varbanov }
47709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_DISPLAY_HOLD_COUNT_ACTUAL: {
47809c2845eSStanimir Varbanov struct hfi_buffer_display_hold_count_actual *in = pdata;
47909c2845eSStanimir Varbanov struct hfi_buffer_display_hold_count_actual *count = prop_data;
48009c2845eSStanimir Varbanov
48109c2845eSStanimir Varbanov count->hold_count = in->hold_count;
48209c2845eSStanimir Varbanov count->type = in->type;
48309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count);
48409c2845eSStanimir Varbanov break;
48509c2845eSStanimir Varbanov }
48609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT: {
48709c2845eSStanimir Varbanov struct hfi_nal_stream_format_select *in = pdata;
48809c2845eSStanimir Varbanov struct hfi_nal_stream_format_select *fmt = prop_data;
48909c2845eSStanimir Varbanov
49009c2845eSStanimir Varbanov fmt->format = in->format;
49109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*fmt);
49209c2845eSStanimir Varbanov break;
49309c2845eSStanimir Varbanov }
49409c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER: {
49509c2845eSStanimir Varbanov u32 *in = pdata;
49609c2845eSStanimir Varbanov
49709c2845eSStanimir Varbanov switch (*in) {
49809c2845eSStanimir Varbanov case HFI_OUTPUT_ORDER_DECODE:
49909c2845eSStanimir Varbanov case HFI_OUTPUT_ORDER_DISPLAY:
50009c2845eSStanimir Varbanov break;
50109c2845eSStanimir Varbanov default:
50209c2845eSStanimir Varbanov ret = -EINVAL;
50309c2845eSStanimir Varbanov break;
50409c2845eSStanimir Varbanov }
50509c2845eSStanimir Varbanov
50609c2845eSStanimir Varbanov pkt->data[1] = *in;
50709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
50809c2845eSStanimir Varbanov break;
50909c2845eSStanimir Varbanov }
51009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE: {
51109c2845eSStanimir Varbanov struct hfi_enable_picture *in = pdata, *en = prop_data;
51209c2845eSStanimir Varbanov
51309c2845eSStanimir Varbanov en->picture_type = in->picture_type;
51409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
51509c2845eSStanimir Varbanov break;
51609c2845eSStanimir Varbanov }
51709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: {
51809c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
51909c2845eSStanimir Varbanov
52009c2845eSStanimir Varbanov en->enable = in->enable;
52109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
52209c2845eSStanimir Varbanov break;
52309c2845eSStanimir Varbanov }
524938beb48SDikshita Agarwal case HFI_PROPERTY_PARAM_VDEC_ENABLE_SUFFICIENT_SEQCHANGE_EVENT:
52509c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER: {
52609c2845eSStanimir Varbanov struct hfi_enable *in = pdata;
52709c2845eSStanimir Varbanov struct hfi_enable *en = prop_data;
52809c2845eSStanimir Varbanov
52909c2845eSStanimir Varbanov en->enable = in->enable;
53009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
53109c2845eSStanimir Varbanov break;
53209c2845eSStanimir Varbanov }
53309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM: {
53409c2845eSStanimir Varbanov struct hfi_multi_stream *in = pdata, *multi = prop_data;
53509c2845eSStanimir Varbanov
53609c2845eSStanimir Varbanov multi->buffer_type = in->buffer_type;
53709c2845eSStanimir Varbanov multi->enable = in->enable;
53809c2845eSStanimir Varbanov multi->width = in->width;
53909c2845eSStanimir Varbanov multi->height = in->height;
54009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi);
54109c2845eSStanimir Varbanov break;
54209c2845eSStanimir Varbanov }
54309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: {
54409c2845eSStanimir Varbanov struct hfi_display_picture_buffer_count *in = pdata;
54509c2845eSStanimir Varbanov struct hfi_display_picture_buffer_count *count = prop_data;
54609c2845eSStanimir Varbanov
54709c2845eSStanimir Varbanov count->count = in->count;
54809c2845eSStanimir Varbanov count->enable = in->enable;
54909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count);
55009c2845eSStanimir Varbanov break;
55109c2845eSStanimir Varbanov }
55209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_DIVX_FORMAT: {
55309c2845eSStanimir Varbanov u32 *in = pdata;
55409c2845eSStanimir Varbanov
55509c2845eSStanimir Varbanov switch (*in) {
55609c2845eSStanimir Varbanov case HFI_DIVX_FORMAT_4:
55709c2845eSStanimir Varbanov case HFI_DIVX_FORMAT_5:
55809c2845eSStanimir Varbanov case HFI_DIVX_FORMAT_6:
55909c2845eSStanimir Varbanov break;
56009c2845eSStanimir Varbanov default:
56109c2845eSStanimir Varbanov ret = -EINVAL;
56209c2845eSStanimir Varbanov break;
56309c2845eSStanimir Varbanov }
56409c2845eSStanimir Varbanov
56509c2845eSStanimir Varbanov pkt->data[1] = *in;
56609c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
56709c2845eSStanimir Varbanov break;
56809c2845eSStanimir Varbanov }
56909c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: {
57009c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
57109c2845eSStanimir Varbanov
57209c2845eSStanimir Varbanov en->enable = in->enable;
57309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
57409c2845eSStanimir Varbanov break;
57509c2845eSStanimir Varbanov }
57609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER: {
57709c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
57809c2845eSStanimir Varbanov
57909c2845eSStanimir Varbanov en->enable = in->enable;
58009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
58109c2845eSStanimir Varbanov break;
58209c2845eSStanimir Varbanov }
58309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE: {
58409c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
58509c2845eSStanimir Varbanov
58609c2845eSStanimir Varbanov en->enable = in->enable;
58709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
58809c2845eSStanimir Varbanov break;
58909c2845eSStanimir Varbanov }
59009c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER: {
59109c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
59209c2845eSStanimir Varbanov
59309c2845eSStanimir Varbanov en->enable = in->enable;
59409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
59509c2845eSStanimir Varbanov break;
59609c2845eSStanimir Varbanov }
59709c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME:
59809c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32);
59909c2845eSStanimir Varbanov break;
60009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MPEG4_SHORT_HEADER:
60109c2845eSStanimir Varbanov break;
60209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MPEG4_AC_PREDICTION:
60309c2845eSStanimir Varbanov break;
60409c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE: {
60509c2845eSStanimir Varbanov struct hfi_bitrate *in = pdata, *brate = prop_data;
60609c2845eSStanimir Varbanov
60709c2845eSStanimir Varbanov brate->bitrate = in->bitrate;
60809c2845eSStanimir Varbanov brate->layer_id = in->layer_id;
60909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*brate);
61009c2845eSStanimir Varbanov break;
61109c2845eSStanimir Varbanov }
61209c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: {
61309c2845eSStanimir Varbanov struct hfi_bitrate *in = pdata, *hfi = prop_data;
61409c2845eSStanimir Varbanov
61509c2845eSStanimir Varbanov hfi->bitrate = in->bitrate;
61609c2845eSStanimir Varbanov hfi->layer_id = in->layer_id;
61709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi);
61809c2845eSStanimir Varbanov break;
61909c2845eSStanimir Varbanov }
62009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: {
62109c2845eSStanimir Varbanov struct hfi_profile_level *in = pdata, *pl = prop_data;
62209c2845eSStanimir Varbanov
62309c2845eSStanimir Varbanov pl->level = in->level;
62409c2845eSStanimir Varbanov pl->profile = in->profile;
62509c2845eSStanimir Varbanov if (pl->profile <= 0)
62609c2845eSStanimir Varbanov /* Profile not supported, falling back to high */
62709c2845eSStanimir Varbanov pl->profile = HFI_H264_PROFILE_HIGH;
62809c2845eSStanimir Varbanov
62909c2845eSStanimir Varbanov if (!pl->level)
63009c2845eSStanimir Varbanov /* Level not supported, falling back to 1 */
63109c2845eSStanimir Varbanov pl->level = 1;
63209c2845eSStanimir Varbanov
63309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*pl);
63409c2845eSStanimir Varbanov break;
63509c2845eSStanimir Varbanov }
63609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL: {
63709c2845eSStanimir Varbanov struct hfi_h264_entropy_control *in = pdata, *hfi = prop_data;
63809c2845eSStanimir Varbanov
63909c2845eSStanimir Varbanov hfi->entropy_mode = in->entropy_mode;
64009c2845eSStanimir Varbanov if (hfi->entropy_mode == HFI_H264_ENTROPY_CABAC)
64109c2845eSStanimir Varbanov hfi->cabac_model = in->cabac_model;
64209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hfi);
64309c2845eSStanimir Varbanov break;
64409c2845eSStanimir Varbanov }
64509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_RATE_CONTROL: {
64609c2845eSStanimir Varbanov u32 *in = pdata;
64709c2845eSStanimir Varbanov
64809c2845eSStanimir Varbanov switch (*in) {
64909c2845eSStanimir Varbanov case HFI_RATE_CONTROL_OFF:
65009c2845eSStanimir Varbanov case HFI_RATE_CONTROL_CBR_CFR:
65109c2845eSStanimir Varbanov case HFI_RATE_CONTROL_CBR_VFR:
65209c2845eSStanimir Varbanov case HFI_RATE_CONTROL_VBR_CFR:
65309c2845eSStanimir Varbanov case HFI_RATE_CONTROL_VBR_VFR:
65469ff4b2cSStanimir Varbanov case HFI_RATE_CONTROL_CQ:
65509c2845eSStanimir Varbanov break;
65609c2845eSStanimir Varbanov default:
65709c2845eSStanimir Varbanov ret = -EINVAL;
65809c2845eSStanimir Varbanov break;
65909c2845eSStanimir Varbanov }
66009c2845eSStanimir Varbanov
66109c2845eSStanimir Varbanov pkt->data[1] = *in;
66209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
66309c2845eSStanimir Varbanov break;
66409c2845eSStanimir Varbanov }
66509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION: {
66609c2845eSStanimir Varbanov struct hfi_mpeg4_time_resolution *in = pdata, *res = prop_data;
66709c2845eSStanimir Varbanov
66809c2845eSStanimir Varbanov res->time_increment_resolution = in->time_increment_resolution;
66909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*res);
67009c2845eSStanimir Varbanov break;
67109c2845eSStanimir Varbanov }
67209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION: {
67309c2845eSStanimir Varbanov struct hfi_mpeg4_header_extension *in = pdata, *ext = prop_data;
67409c2845eSStanimir Varbanov
67509c2845eSStanimir Varbanov ext->header_extension = in->header_extension;
67609c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ext);
67709c2845eSStanimir Varbanov break;
67809c2845eSStanimir Varbanov }
67909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL: {
68009c2845eSStanimir Varbanov struct hfi_h264_db_control *in = pdata, *db = prop_data;
68109c2845eSStanimir Varbanov
68209c2845eSStanimir Varbanov switch (in->mode) {
68309c2845eSStanimir Varbanov case HFI_H264_DB_MODE_DISABLE:
68409c2845eSStanimir Varbanov case HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY:
68509c2845eSStanimir Varbanov case HFI_H264_DB_MODE_ALL_BOUNDARY:
68609c2845eSStanimir Varbanov break;
68709c2845eSStanimir Varbanov default:
68809c2845eSStanimir Varbanov ret = -EINVAL;
68909c2845eSStanimir Varbanov break;
69009c2845eSStanimir Varbanov }
69109c2845eSStanimir Varbanov
69209c2845eSStanimir Varbanov db->mode = in->mode;
69309c2845eSStanimir Varbanov db->slice_alpha_offset = in->slice_alpha_offset;
69409c2845eSStanimir Varbanov db->slice_beta_offset = in->slice_beta_offset;
69509c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*db);
69609c2845eSStanimir Varbanov break;
69709c2845eSStanimir Varbanov }
69809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_SESSION_QP: {
69909c2845eSStanimir Varbanov struct hfi_quantization *in = pdata, *quant = prop_data;
70009c2845eSStanimir Varbanov
70109c2845eSStanimir Varbanov quant->qp_i = in->qp_i;
70209c2845eSStanimir Varbanov quant->qp_p = in->qp_p;
70309c2845eSStanimir Varbanov quant->qp_b = in->qp_b;
70409c2845eSStanimir Varbanov quant->layer_id = in->layer_id;
70509c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*quant);
70609c2845eSStanimir Varbanov break;
70709c2845eSStanimir Varbanov }
70809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE: {
70909c2845eSStanimir Varbanov struct hfi_quantization_range *in = pdata, *range = prop_data;
71009c2845eSStanimir Varbanov u32 min_qp, max_qp;
71109c2845eSStanimir Varbanov
71209c2845eSStanimir Varbanov min_qp = in->min_qp;
71309c2845eSStanimir Varbanov max_qp = in->max_qp;
71409c2845eSStanimir Varbanov
71509c2845eSStanimir Varbanov /* We'll be packing in the qp, so make sure we
71609c2845eSStanimir Varbanov * won't be losing data when masking
71709c2845eSStanimir Varbanov */
71809c2845eSStanimir Varbanov if (min_qp > 0xff || max_qp > 0xff) {
71909c2845eSStanimir Varbanov ret = -ERANGE;
72009c2845eSStanimir Varbanov break;
72109c2845eSStanimir Varbanov }
72209c2845eSStanimir Varbanov
72309c2845eSStanimir Varbanov /* When creating the packet, pack the qp value as
72409c2845eSStanimir Varbanov * 0xiippbb, where ii = qp range for I-frames,
72509c2845eSStanimir Varbanov * pp = qp range for P-frames, etc.
72609c2845eSStanimir Varbanov */
72709c2845eSStanimir Varbanov range->min_qp = min_qp | min_qp << 8 | min_qp << 16;
72809c2845eSStanimir Varbanov range->max_qp = max_qp | max_qp << 8 | max_qp << 16;
72909c2845eSStanimir Varbanov range->layer_id = in->layer_id;
73009c2845eSStanimir Varbanov
73109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*range);
73209c2845eSStanimir Varbanov break;
73309c2845eSStanimir Varbanov }
73409c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_VC1_PERF_CFG: {
73509c2845eSStanimir Varbanov struct hfi_vc1e_perf_cfg_type *in = pdata, *perf = prop_data;
73609c2845eSStanimir Varbanov
73709c2845eSStanimir Varbanov memcpy(perf->search_range_x_subsampled,
73809c2845eSStanimir Varbanov in->search_range_x_subsampled,
73909c2845eSStanimir Varbanov sizeof(perf->search_range_x_subsampled));
74009c2845eSStanimir Varbanov memcpy(perf->search_range_y_subsampled,
74109c2845eSStanimir Varbanov in->search_range_y_subsampled,
74209c2845eSStanimir Varbanov sizeof(perf->search_range_y_subsampled));
74309c2845eSStanimir Varbanov
74409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*perf);
74509c2845eSStanimir Varbanov break;
74609c2845eSStanimir Varbanov }
74709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES: {
74809c2845eSStanimir Varbanov struct hfi_max_num_b_frames *bframes = prop_data;
74909c2845eSStanimir Varbanov u32 *in = pdata;
75009c2845eSStanimir Varbanov
75109c2845eSStanimir Varbanov bframes->max_num_b_frames = *in;
75209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*bframes);
75309c2845eSStanimir Varbanov break;
75409c2845eSStanimir Varbanov }
75509c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD: {
75609c2845eSStanimir Varbanov struct hfi_intra_period *in = pdata, *intra = prop_data;
75709c2845eSStanimir Varbanov
75809c2845eSStanimir Varbanov intra->pframes = in->pframes;
75909c2845eSStanimir Varbanov intra->bframes = in->bframes;
76009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra);
76109c2845eSStanimir Varbanov break;
76209c2845eSStanimir Varbanov }
76309c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD: {
76409c2845eSStanimir Varbanov struct hfi_idr_period *in = pdata, *idr = prop_data;
76509c2845eSStanimir Varbanov
76609c2845eSStanimir Varbanov idr->idr_period = in->idr_period;
76709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*idr);
76809c2845eSStanimir Varbanov break;
76909c2845eSStanimir Varbanov }
77009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR: {
77109c2845eSStanimir Varbanov struct hfi_conceal_color *color = prop_data;
77209c2845eSStanimir Varbanov u32 *in = pdata;
77309c2845eSStanimir Varbanov
7744ef6039fSStanimir Varbanov color->conceal_color = *in & 0xff;
7754ef6039fSStanimir Varbanov color->conceal_color |= ((*in >> 10) & 0xff) << 8;
7764ef6039fSStanimir Varbanov color->conceal_color |= ((*in >> 20) & 0xff) << 16;
77709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*color);
77809c2845eSStanimir Varbanov break;
77909c2845eSStanimir Varbanov }
78009c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VPE_OPERATIONS: {
78109c2845eSStanimir Varbanov struct hfi_operations_type *in = pdata, *ops = prop_data;
78209c2845eSStanimir Varbanov
78309c2845eSStanimir Varbanov switch (in->rotation) {
78409c2845eSStanimir Varbanov case HFI_ROTATE_NONE:
78509c2845eSStanimir Varbanov case HFI_ROTATE_90:
78609c2845eSStanimir Varbanov case HFI_ROTATE_180:
78709c2845eSStanimir Varbanov case HFI_ROTATE_270:
78809c2845eSStanimir Varbanov break;
78909c2845eSStanimir Varbanov default:
79009c2845eSStanimir Varbanov ret = -EINVAL;
79109c2845eSStanimir Varbanov break;
79209c2845eSStanimir Varbanov }
79309c2845eSStanimir Varbanov
79409c2845eSStanimir Varbanov switch (in->flip) {
79509c2845eSStanimir Varbanov case HFI_FLIP_NONE:
79609c2845eSStanimir Varbanov case HFI_FLIP_HORIZONTAL:
79709c2845eSStanimir Varbanov case HFI_FLIP_VERTICAL:
79809c2845eSStanimir Varbanov break;
79909c2845eSStanimir Varbanov default:
80009c2845eSStanimir Varbanov ret = -EINVAL;
80109c2845eSStanimir Varbanov break;
80209c2845eSStanimir Varbanov }
80309c2845eSStanimir Varbanov
80409c2845eSStanimir Varbanov ops->rotation = in->rotation;
80509c2845eSStanimir Varbanov ops->flip = in->flip;
80609c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ops);
80709c2845eSStanimir Varbanov break;
80809c2845eSStanimir Varbanov }
80909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH: {
81009c2845eSStanimir Varbanov struct hfi_intra_refresh *in = pdata, *intra = prop_data;
81109c2845eSStanimir Varbanov
81209c2845eSStanimir Varbanov switch (in->mode) {
81309c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_NONE:
81409c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_ADAPTIVE:
81509c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_CYCLIC:
81609c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE:
81709c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_RANDOM:
81809c2845eSStanimir Varbanov break;
81909c2845eSStanimir Varbanov default:
82009c2845eSStanimir Varbanov ret = -EINVAL;
82109c2845eSStanimir Varbanov break;
82209c2845eSStanimir Varbanov }
82309c2845eSStanimir Varbanov
82409c2845eSStanimir Varbanov intra->mode = in->mode;
82509c2845eSStanimir Varbanov intra->air_mbs = in->air_mbs;
82609c2845eSStanimir Varbanov intra->air_ref = in->air_ref;
82709c2845eSStanimir Varbanov intra->cir_mbs = in->cir_mbs;
82809c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra);
82909c2845eSStanimir Varbanov break;
83009c2845eSStanimir Varbanov }
83109c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_CONTROL: {
83209c2845eSStanimir Varbanov struct hfi_multi_slice_control *in = pdata, *multi = prop_data;
83309c2845eSStanimir Varbanov
83409c2845eSStanimir Varbanov switch (in->multi_slice) {
83509c2845eSStanimir Varbanov case HFI_MULTI_SLICE_OFF:
83609c2845eSStanimir Varbanov case HFI_MULTI_SLICE_GOB:
83709c2845eSStanimir Varbanov case HFI_MULTI_SLICE_BY_MB_COUNT:
83809c2845eSStanimir Varbanov case HFI_MULTI_SLICE_BY_BYTE_COUNT:
83909c2845eSStanimir Varbanov break;
84009c2845eSStanimir Varbanov default:
84109c2845eSStanimir Varbanov ret = -EINVAL;
84209c2845eSStanimir Varbanov break;
84309c2845eSStanimir Varbanov }
84409c2845eSStanimir Varbanov
84509c2845eSStanimir Varbanov multi->multi_slice = in->multi_slice;
84609c2845eSStanimir Varbanov multi->slice_size = in->slice_size;
84709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi);
84809c2845eSStanimir Varbanov break;
84909c2845eSStanimir Varbanov }
85009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_SLICE_DELIVERY_MODE: {
85109c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
85209c2845eSStanimir Varbanov
85309c2845eSStanimir Varbanov en->enable = in->enable;
85409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
85509c2845eSStanimir Varbanov break;
85609c2845eSStanimir Varbanov }
85709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_VUI_TIMING_INFO: {
85809c2845eSStanimir Varbanov struct hfi_h264_vui_timing_info *in = pdata, *vui = prop_data;
85909c2845eSStanimir Varbanov
86009c2845eSStanimir Varbanov vui->enable = in->enable;
86109c2845eSStanimir Varbanov vui->fixed_framerate = in->fixed_framerate;
86209c2845eSStanimir Varbanov vui->time_scale = in->time_scale;
86309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*vui);
86409c2845eSStanimir Varbanov break;
86509c2845eSStanimir Varbanov }
86609c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VPE_DEINTERLACE: {
86709c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
86809c2845eSStanimir Varbanov
86909c2845eSStanimir Varbanov en->enable = in->enable;
87009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
87109c2845eSStanimir Varbanov break;
87209c2845eSStanimir Varbanov }
87309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_GENERATE_AUDNAL: {
87409c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
87509c2845eSStanimir Varbanov
87609c2845eSStanimir Varbanov en->enable = in->enable;
87709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
87809c2845eSStanimir Varbanov break;
87909c2845eSStanimir Varbanov }
88009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: {
88109c2845eSStanimir Varbanov struct hfi_buffer_alloc_mode *in = pdata, *mode = prop_data;
88209c2845eSStanimir Varbanov
88309c2845eSStanimir Varbanov mode->type = in->type;
88409c2845eSStanimir Varbanov mode->mode = in->mode;
88509c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*mode);
88609c2845eSStanimir Varbanov break;
88709c2845eSStanimir Varbanov }
88809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY: {
88909c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
89009c2845eSStanimir Varbanov
89109c2845eSStanimir Varbanov en->enable = in->enable;
89209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
89309c2845eSStanimir Varbanov break;
89409c2845eSStanimir Varbanov }
89509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC: {
89609c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
89709c2845eSStanimir Varbanov
89809c2845eSStanimir Varbanov en->enable = in->enable;
89909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
90009c2845eSStanimir Varbanov break;
90109c2845eSStanimir Varbanov }
90209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_PRESERVE_TEXT_QUALITY: {
90309c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
90409c2845eSStanimir Varbanov
90509c2845eSStanimir Varbanov en->enable = in->enable;
90609c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
90709c2845eSStanimir Varbanov break;
90809c2845eSStanimir Varbanov }
90909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_SCS_THRESHOLD: {
91009c2845eSStanimir Varbanov struct hfi_scs_threshold *thres = prop_data;
91109c2845eSStanimir Varbanov u32 *in = pdata;
91209c2845eSStanimir Varbanov
91309c2845eSStanimir Varbanov thres->threshold_value = *in;
91409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*thres);
91509c2845eSStanimir Varbanov break;
91609c2845eSStanimir Varbanov }
91709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_MVC_BUFFER_LAYOUT: {
91809c2845eSStanimir Varbanov struct hfi_mvc_buffer_layout_descp_type *in = pdata;
91909c2845eSStanimir Varbanov struct hfi_mvc_buffer_layout_descp_type *mvc = prop_data;
92009c2845eSStanimir Varbanov
92109c2845eSStanimir Varbanov switch (in->layout_type) {
92209c2845eSStanimir Varbanov case HFI_MVC_BUFFER_LAYOUT_TOP_BOTTOM:
92309c2845eSStanimir Varbanov case HFI_MVC_BUFFER_LAYOUT_SEQ:
92409c2845eSStanimir Varbanov break;
92509c2845eSStanimir Varbanov default:
92609c2845eSStanimir Varbanov ret = -EINVAL;
92709c2845eSStanimir Varbanov break;
92809c2845eSStanimir Varbanov }
92909c2845eSStanimir Varbanov
93009c2845eSStanimir Varbanov mvc->layout_type = in->layout_type;
93109c2845eSStanimir Varbanov mvc->bright_view_first = in->bright_view_first;
93209c2845eSStanimir Varbanov mvc->ngap = in->ngap;
93309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*mvc);
93409c2845eSStanimir Varbanov break;
93509c2845eSStanimir Varbanov }
93609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_LTRMODE: {
93709c2845eSStanimir Varbanov struct hfi_ltr_mode *in = pdata, *ltr = prop_data;
93809c2845eSStanimir Varbanov
93909c2845eSStanimir Varbanov switch (in->ltr_mode) {
94009c2845eSStanimir Varbanov case HFI_LTR_MODE_DISABLE:
94109c2845eSStanimir Varbanov case HFI_LTR_MODE_MANUAL:
94209c2845eSStanimir Varbanov case HFI_LTR_MODE_PERIODIC:
94309c2845eSStanimir Varbanov break;
94409c2845eSStanimir Varbanov default:
94509c2845eSStanimir Varbanov ret = -EINVAL;
94609c2845eSStanimir Varbanov break;
94709c2845eSStanimir Varbanov }
94809c2845eSStanimir Varbanov
94909c2845eSStanimir Varbanov ltr->ltr_mode = in->ltr_mode;
95009c2845eSStanimir Varbanov ltr->ltr_count = in->ltr_count;
95109c2845eSStanimir Varbanov ltr->trust_mode = in->trust_mode;
95209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr);
95309c2845eSStanimir Varbanov break;
95409c2845eSStanimir Varbanov }
95509c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_USELTRFRAME: {
95609c2845eSStanimir Varbanov struct hfi_ltr_use *in = pdata, *ltr_use = prop_data;
95709c2845eSStanimir Varbanov
95809c2845eSStanimir Varbanov ltr_use->frames = in->frames;
95909c2845eSStanimir Varbanov ltr_use->ref_ltr = in->ref_ltr;
96009c2845eSStanimir Varbanov ltr_use->use_constrnt = in->use_constrnt;
96109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_use);
96209c2845eSStanimir Varbanov break;
96309c2845eSStanimir Varbanov }
96409c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME: {
96509c2845eSStanimir Varbanov struct hfi_ltr_mark *in = pdata, *ltr_mark = prop_data;
96609c2845eSStanimir Varbanov
96709c2845eSStanimir Varbanov ltr_mark->mark_frame = in->mark_frame;
96809c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_mark);
96909c2845eSStanimir Varbanov break;
97009c2845eSStanimir Varbanov }
97109c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER: {
97209c2845eSStanimir Varbanov u32 *in = pdata;
97309c2845eSStanimir Varbanov
97409c2845eSStanimir Varbanov pkt->data[1] = *in;
97509c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
97609c2845eSStanimir Varbanov break;
97709c2845eSStanimir Varbanov }
97809c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER: {
97909c2845eSStanimir Varbanov u32 *in = pdata;
98009c2845eSStanimir Varbanov
98109c2845eSStanimir Varbanov pkt->data[1] = *in;
98209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
98309c2845eSStanimir Varbanov break;
98409c2845eSStanimir Varbanov }
98509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP: {
98609c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
98709c2845eSStanimir Varbanov
98809c2845eSStanimir Varbanov en->enable = in->enable;
98909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
99009c2845eSStanimir Varbanov break;
99109c2845eSStanimir Varbanov }
99209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_INITIAL_QP: {
99309c2845eSStanimir Varbanov struct hfi_initial_quantization *in = pdata, *quant = prop_data;
99409c2845eSStanimir Varbanov
99509c2845eSStanimir Varbanov quant->init_qp_enable = in->init_qp_enable;
99609c2845eSStanimir Varbanov quant->qp_i = in->qp_i;
99709c2845eSStanimir Varbanov quant->qp_p = in->qp_p;
99809c2845eSStanimir Varbanov quant->qp_b = in->qp_b;
99909c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*quant);
100009c2845eSStanimir Varbanov break;
100109c2845eSStanimir Varbanov }
100209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VPE_COLOR_SPACE_CONVERSION: {
100309c2845eSStanimir Varbanov struct hfi_vpe_color_space_conversion *in = pdata;
100409c2845eSStanimir Varbanov struct hfi_vpe_color_space_conversion *csc = prop_data;
100509c2845eSStanimir Varbanov
100609c2845eSStanimir Varbanov memcpy(csc->csc_matrix, in->csc_matrix,
100709c2845eSStanimir Varbanov sizeof(csc->csc_matrix));
100809c2845eSStanimir Varbanov memcpy(csc->csc_bias, in->csc_bias, sizeof(csc->csc_bias));
100909c2845eSStanimir Varbanov memcpy(csc->csc_limit, in->csc_limit, sizeof(csc->csc_limit));
101009c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*csc);
101109c2845eSStanimir Varbanov break;
101209c2845eSStanimir Varbanov }
101309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_VPX_ERROR_RESILIENCE_MODE: {
101409c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
101509c2845eSStanimir Varbanov
101609c2845eSStanimir Varbanov en->enable = in->enable;
101709c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
101809c2845eSStanimir Varbanov break;
101909c2845eSStanimir Varbanov }
102009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_H264_NAL_SVC_EXT: {
102109c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
102209c2845eSStanimir Varbanov
102309c2845eSStanimir Varbanov en->enable = in->enable;
102409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
102509c2845eSStanimir Varbanov break;
102609c2845eSStanimir Varbanov }
102709c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_PERF_MODE: {
102809c2845eSStanimir Varbanov u32 *in = pdata;
102909c2845eSStanimir Varbanov
103009c2845eSStanimir Varbanov pkt->data[1] = *in;
103109c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
103209c2845eSStanimir Varbanov break;
103309c2845eSStanimir Varbanov }
103409c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_HIER_B_MAX_NUM_ENH_LAYER: {
103509c2845eSStanimir Varbanov u32 *in = pdata;
103609c2845eSStanimir Varbanov
103709c2845eSStanimir Varbanov pkt->data[1] = *in;
103809c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) * 2;
103909c2845eSStanimir Varbanov break;
104009c2845eSStanimir Varbanov }
104109c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_NONCP_OUTPUT2: {
104209c2845eSStanimir Varbanov struct hfi_enable *in = pdata, *en = prop_data;
104309c2845eSStanimir Varbanov
104409c2845eSStanimir Varbanov en->enable = in->enable;
104509c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*en);
104609c2845eSStanimir Varbanov break;
104709c2845eSStanimir Varbanov }
104809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_HIER_P_HYBRID_MODE: {
104909c2845eSStanimir Varbanov struct hfi_hybrid_hierp *in = pdata, *hierp = prop_data;
105009c2845eSStanimir Varbanov
105109c2845eSStanimir Varbanov hierp->layers = in->layers;
105209c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hierp);
105309c2845eSStanimir Varbanov break;
105409c2845eSStanimir Varbanov }
105515447d18SStanimir Varbanov case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: {
105615447d18SStanimir Varbanov struct hfi_uncompressed_plane_actual_info *in = pdata;
105715447d18SStanimir Varbanov struct hfi_uncompressed_plane_actual_info *info = prop_data;
105815447d18SStanimir Varbanov
105915447d18SStanimir Varbanov info->buffer_type = in->buffer_type;
106015447d18SStanimir Varbanov info->num_planes = in->num_planes;
106115447d18SStanimir Varbanov info->plane_format[0] = in->plane_format[0];
106215447d18SStanimir Varbanov if (in->num_planes > 1)
106315447d18SStanimir Varbanov info->plane_format[1] = in->plane_format[1];
106415447d18SStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
106515447d18SStanimir Varbanov break;
106615447d18SStanimir Varbanov }
106722beb839SStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI:
106822beb839SStanimir Varbanov return -ENOTSUPP;
106909c2845eSStanimir Varbanov
107009c2845eSStanimir Varbanov /* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */
107109c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS:
107209c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_PRIORITY:
107309c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_BATCH_INFO:
107409c2845eSStanimir Varbanov case HFI_PROPERTY_SYS_IDLE_INDICATOR:
107509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED:
107609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_INTERLACE_FORMAT_SUPPORTED:
107709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_CHROMA_SITE:
107809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_PROPERTIES_SUPPORTED:
107909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED:
108009c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED:
108109c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SUPPORTED:
108209c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_MULTI_VIEW_FORMAT:
108309c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_MAX_SEQUENCE_HEADER_SIZE:
108409c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_CODEC_SUPPORTED:
108509c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_MULTI_VIEW_SELECT:
108609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_MB_QUANTIZATION:
108709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_NUM_CONCEALED_MB:
108809c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_H264_ENTROPY_SWITCHING:
108909c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_INFO:
109009c2845eSStanimir Varbanov default:
109109c2845eSStanimir Varbanov return -EINVAL;
109209c2845eSStanimir Varbanov }
109309c2845eSStanimir Varbanov
109409c2845eSStanimir Varbanov return ret;
109509c2845eSStanimir Varbanov }
109609c2845eSStanimir Varbanov
109709c2845eSStanimir Varbanov static int
pkt_session_get_property_3xx(struct hfi_session_get_property_pkt * pkt,void * cookie,u32 ptype)109809c2845eSStanimir Varbanov pkt_session_get_property_3xx(struct hfi_session_get_property_pkt *pkt,
109909c2845eSStanimir Varbanov void *cookie, u32 ptype)
110009c2845eSStanimir Varbanov {
110109c2845eSStanimir Varbanov int ret = 0;
110209c2845eSStanimir Varbanov
110309c2845eSStanimir Varbanov if (!pkt || !cookie)
110409c2845eSStanimir Varbanov return -EINVAL;
110509c2845eSStanimir Varbanov
110609c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(struct hfi_session_get_property_pkt);
110709c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_GET_PROPERTY;
110809c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
110909c2845eSStanimir Varbanov pkt->num_properties = 1;
111009c2845eSStanimir Varbanov
111109c2845eSStanimir Varbanov switch (ptype) {
111209c2845eSStanimir Varbanov case HFI_PROPERTY_CONFIG_VDEC_ENTROPY:
1113886115c4SRicardo Ribalda pkt->data = HFI_PROPERTY_CONFIG_VDEC_ENTROPY;
111409c2845eSStanimir Varbanov break;
111509c2845eSStanimir Varbanov default:
111609c2845eSStanimir Varbanov ret = pkt_session_get_property_1x(pkt, cookie, ptype);
111709c2845eSStanimir Varbanov break;
111809c2845eSStanimir Varbanov }
111909c2845eSStanimir Varbanov
112009c2845eSStanimir Varbanov return ret;
112109c2845eSStanimir Varbanov }
112209c2845eSStanimir Varbanov
112309c2845eSStanimir Varbanov static int
pkt_session_set_property_3xx(struct hfi_session_set_property_pkt * pkt,void * cookie,u32 ptype,void * pdata)112409c2845eSStanimir Varbanov pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt,
112509c2845eSStanimir Varbanov void *cookie, u32 ptype, void *pdata)
112609c2845eSStanimir Varbanov {
11272b2e6488SStanimir Varbanov void *prop_data;
112809c2845eSStanimir Varbanov int ret = 0;
112909c2845eSStanimir Varbanov
113009c2845eSStanimir Varbanov if (!pkt || !cookie || !pdata)
113109c2845eSStanimir Varbanov return -EINVAL;
113209c2845eSStanimir Varbanov
11332b2e6488SStanimir Varbanov prop_data = &pkt->data[1];
11342b2e6488SStanimir Varbanov
113509c2845eSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
113609c2845eSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY;
113709c2845eSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
113809c2845eSStanimir Varbanov pkt->num_properties = 1;
1139f3105f0aSStanimir Varbanov pkt->data[0] = ptype;
114009c2845eSStanimir Varbanov
114109c2845eSStanimir Varbanov /*
114209c2845eSStanimir Varbanov * Any session set property which is different in 3XX packetization
114309c2845eSStanimir Varbanov * should be added as a new case below. All unchanged session set
114409c2845eSStanimir Varbanov * properties will be handled in the default case.
114509c2845eSStanimir Varbanov */
114609c2845eSStanimir Varbanov switch (ptype) {
114709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM: {
114809c2845eSStanimir Varbanov struct hfi_multi_stream *in = pdata;
114909c2845eSStanimir Varbanov struct hfi_multi_stream_3x *multi = prop_data;
115009c2845eSStanimir Varbanov
115109c2845eSStanimir Varbanov multi->buffer_type = in->buffer_type;
115209c2845eSStanimir Varbanov multi->enable = in->enable;
115309c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*multi);
115409c2845eSStanimir Varbanov break;
115509c2845eSStanimir Varbanov }
115609c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH: {
115709c2845eSStanimir Varbanov struct hfi_intra_refresh *in = pdata;
115809c2845eSStanimir Varbanov struct hfi_intra_refresh_3x *intra = prop_data;
115909c2845eSStanimir Varbanov
116009c2845eSStanimir Varbanov switch (in->mode) {
116109c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_NONE:
116209c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_ADAPTIVE:
116309c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_CYCLIC:
116409c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE:
116509c2845eSStanimir Varbanov case HFI_INTRA_REFRESH_RANDOM:
116609c2845eSStanimir Varbanov break;
116709c2845eSStanimir Varbanov default:
116809c2845eSStanimir Varbanov ret = -EINVAL;
116909c2845eSStanimir Varbanov break;
117009c2845eSStanimir Varbanov }
117109c2845eSStanimir Varbanov
117209c2845eSStanimir Varbanov intra->mode = in->mode;
117309c2845eSStanimir Varbanov intra->mbs = in->cir_mbs;
117409c2845eSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*intra);
117509c2845eSStanimir Varbanov break;
117609c2845eSStanimir Varbanov }
117709c2845eSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER:
117809c2845eSStanimir Varbanov /* for 3xx fw version session_continue is used */
117909c2845eSStanimir Varbanov break;
118009c2845eSStanimir Varbanov default:
118109c2845eSStanimir Varbanov ret = pkt_session_set_property_1x(pkt, cookie, ptype, pdata);
118209c2845eSStanimir Varbanov break;
118309c2845eSStanimir Varbanov }
118409c2845eSStanimir Varbanov
118509c2845eSStanimir Varbanov return ret;
118609c2845eSStanimir Varbanov }
118709c2845eSStanimir Varbanov
11886b183680SStanimir Varbanov static int
pkt_session_set_property_4xx(struct hfi_session_set_property_pkt * pkt,void * cookie,u32 ptype,void * pdata)11896b183680SStanimir Varbanov pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
11906b183680SStanimir Varbanov void *cookie, u32 ptype, void *pdata)
11916b183680SStanimir Varbanov {
11926b183680SStanimir Varbanov void *prop_data;
11936b183680SStanimir Varbanov
11946b183680SStanimir Varbanov if (!pkt || !cookie || !pdata)
11956b183680SStanimir Varbanov return -EINVAL;
11966b183680SStanimir Varbanov
11976b183680SStanimir Varbanov prop_data = &pkt->data[1];
11986b183680SStanimir Varbanov
11996b183680SStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
12006b183680SStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY;
12016b183680SStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
12026b183680SStanimir Varbanov pkt->num_properties = 1;
12036b183680SStanimir Varbanov pkt->data[0] = ptype;
12046b183680SStanimir Varbanov
12056b183680SStanimir Varbanov /*
12066b183680SStanimir Varbanov * Any session set property which is different in 3XX packetization
12076b183680SStanimir Varbanov * should be added as a new case below. All unchanged session set
12086b183680SStanimir Varbanov * properties will be handled in the default case.
12096b183680SStanimir Varbanov */
12106b183680SStanimir Varbanov switch (ptype) {
12116b183680SStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: {
12126b183680SStanimir Varbanov struct hfi_buffer_count_actual *in = pdata;
12136b183680SStanimir Varbanov struct hfi_buffer_count_actual_4xx *count = prop_data;
12146b183680SStanimir Varbanov
12156b183680SStanimir Varbanov count->count_actual = in->count_actual;
12166b183680SStanimir Varbanov count->type = in->type;
12176b183680SStanimir Varbanov count->count_min_host = in->count_actual;
12186b183680SStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count);
12196b183680SStanimir Varbanov break;
12206b183680SStanimir Varbanov }
12216b183680SStanimir Varbanov case HFI_PROPERTY_PARAM_WORK_MODE: {
12226b183680SStanimir Varbanov struct hfi_video_work_mode *in = pdata, *wm = prop_data;
12236b183680SStanimir Varbanov
12246b183680SStanimir Varbanov wm->video_work_mode = in->video_work_mode;
12256b183680SStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*wm);
12266b183680SStanimir Varbanov break;
12276b183680SStanimir Varbanov }
12286b183680SStanimir Varbanov case HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE: {
12296b183680SStanimir Varbanov struct hfi_videocores_usage_type *in = pdata, *cu = prop_data;
12306b183680SStanimir Varbanov
12316b183680SStanimir Varbanov cu->video_core_enable_mask = in->video_core_enable_mask;
12326b183680SStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu);
12336b183680SStanimir Varbanov break;
12346b183680SStanimir Varbanov }
12359172652dSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI: {
12369172652dSStanimir Varbanov struct hfi_hdr10_pq_sei *in = pdata, *hdr10 = prop_data;
12379172652dSStanimir Varbanov
12389172652dSStanimir Varbanov memcpy(hdr10, in, sizeof(*hdr10));
12399172652dSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*hdr10);
12409172652dSStanimir Varbanov break;
12419172652dSStanimir Varbanov }
12426e2202caSStanimir Varbanov case HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR: {
12436e2202caSStanimir Varbanov struct hfi_conceal_color_v4 *color = prop_data;
12446e2202caSStanimir Varbanov u32 *in = pdata;
12456e2202caSStanimir Varbanov
12466e2202caSStanimir Varbanov color->conceal_color_8bit = *in & 0xff;
12476e2202caSStanimir Varbanov color->conceal_color_8bit |= ((*in >> 10) & 0xff) << 8;
12486e2202caSStanimir Varbanov color->conceal_color_8bit |= ((*in >> 20) & 0xff) << 16;
12496e2202caSStanimir Varbanov color->conceal_color_10bit = *in;
12506e2202caSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*color);
12516e2202caSStanimir Varbanov break;
12526e2202caSStanimir Varbanov }
12539172652dSStanimir Varbanov
1254bfee75f7SMansur Alisha Shaik case HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8: {
1255bfee75f7SMansur Alisha Shaik struct hfi_h264_8x8_transform *in = pdata, *tm = prop_data;
1256bfee75f7SMansur Alisha Shaik
1257bfee75f7SMansur Alisha Shaik tm->enable_type = in->enable_type;
1258bfee75f7SMansur Alisha Shaik pkt->shdr.hdr.size += sizeof(u32) + sizeof(*tm);
1259bfee75f7SMansur Alisha Shaik break;
1260bfee75f7SMansur Alisha Shaik }
126190655e2eSViswanath Boma case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2: {
126290655e2eSViswanath Boma struct hfi_quantization_range_v2 *in = pdata, *range = prop_data;
126390655e2eSViswanath Boma u32 min_qp, max_qp;
1264bfee75f7SMansur Alisha Shaik
126590655e2eSViswanath Boma min_qp = in->min_qp.qp_packed;
126690655e2eSViswanath Boma max_qp = in->max_qp.qp_packed;
126790655e2eSViswanath Boma
126890655e2eSViswanath Boma /* We'll be packing in the qp, so make sure we
126990655e2eSViswanath Boma * won't be losing data when masking
127090655e2eSViswanath Boma */
127190655e2eSViswanath Boma if (min_qp > 0xff || max_qp > 0xff)
127290655e2eSViswanath Boma return -ERANGE;
127390655e2eSViswanath Boma
127490655e2eSViswanath Boma range->min_qp.layer_id = 0xFF;
127590655e2eSViswanath Boma range->max_qp.layer_id = 0xFF;
127690655e2eSViswanath Boma range->min_qp.qp_packed = (min_qp & 0xFF) | ((min_qp & 0xFF) << 8) |
127790655e2eSViswanath Boma ((min_qp & 0xFF) << 16);
127890655e2eSViswanath Boma range->max_qp.qp_packed = (max_qp & 0xFF) | ((max_qp & 0xFF) << 8) |
127990655e2eSViswanath Boma ((max_qp & 0xFF) << 16);
128090655e2eSViswanath Boma range->min_qp.enable = 7;
128190655e2eSViswanath Boma range->max_qp.enable = 7;
128290655e2eSViswanath Boma pkt->shdr.hdr.size += sizeof(u32) + sizeof(*range);
128390655e2eSViswanath Boma break;
128490655e2eSViswanath Boma }
12856b183680SStanimir Varbanov case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
12863d7f0d71SStanimir Varbanov case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
12873d7f0d71SStanimir Varbanov case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
12884b997dbbSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_SESSION_QP:
12894b997dbbSStanimir Varbanov case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE:
12906b183680SStanimir Varbanov /* not implemented on Venus 4xx */
12910aaddaafSMalathi Gottam return -ENOTSUPP;
12926b183680SStanimir Varbanov default:
12936b183680SStanimir Varbanov return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata);
12946b183680SStanimir Varbanov }
12956b183680SStanimir Varbanov
12966b183680SStanimir Varbanov return 0;
12976b183680SStanimir Varbanov }
12986b183680SStanimir Varbanov
129969ff4b2cSStanimir Varbanov static int
pkt_session_set_property_6xx(struct hfi_session_set_property_pkt * pkt,void * cookie,u32 ptype,void * pdata)130069ff4b2cSStanimir Varbanov pkt_session_set_property_6xx(struct hfi_session_set_property_pkt *pkt,
130169ff4b2cSStanimir Varbanov void *cookie, u32 ptype, void *pdata)
130269ff4b2cSStanimir Varbanov {
130369ff4b2cSStanimir Varbanov void *prop_data;
130469ff4b2cSStanimir Varbanov
130569ff4b2cSStanimir Varbanov if (!pkt || !cookie || !pdata)
130669ff4b2cSStanimir Varbanov return -EINVAL;
130769ff4b2cSStanimir Varbanov
130869ff4b2cSStanimir Varbanov prop_data = &pkt->data[1];
130969ff4b2cSStanimir Varbanov
131069ff4b2cSStanimir Varbanov pkt->shdr.hdr.size = sizeof(*pkt);
131169ff4b2cSStanimir Varbanov pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY;
131269ff4b2cSStanimir Varbanov pkt->shdr.session_id = hash32_ptr(cookie);
131369ff4b2cSStanimir Varbanov pkt->num_properties = 1;
131469ff4b2cSStanimir Varbanov pkt->data[0] = ptype;
131569ff4b2cSStanimir Varbanov
131669ff4b2cSStanimir Varbanov switch (ptype) {
1317bc28936bSDikshita Agarwal case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: {
1318bc28936bSDikshita Agarwal struct hfi_uncompressed_plane_actual_constraints_info *in = pdata;
1319bc28936bSDikshita Agarwal struct hfi_uncompressed_plane_actual_constraints_info *info = prop_data;
1320bc28936bSDikshita Agarwal
1321bc28936bSDikshita Agarwal info->buffer_type = in->buffer_type;
1322bc28936bSDikshita Agarwal info->num_planes = in->num_planes;
1323bc28936bSDikshita Agarwal info->plane_format[0] = in->plane_format[0];
1324bc28936bSDikshita Agarwal if (in->num_planes > 1)
1325bc28936bSDikshita Agarwal info->plane_format[1] = in->plane_format[1];
1326bc28936bSDikshita Agarwal
1327bc28936bSDikshita Agarwal pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
1328bc28936bSDikshita Agarwal break;
1329bc28936bSDikshita Agarwal }
133069ff4b2cSStanimir Varbanov case HFI_PROPERTY_CONFIG_HEIC_FRAME_QUALITY: {
133169ff4b2cSStanimir Varbanov struct hfi_heic_frame_quality *in = pdata, *cq = prop_data;
133269ff4b2cSStanimir Varbanov
133369ff4b2cSStanimir Varbanov cq->frame_quality = in->frame_quality;
133469ff4b2cSStanimir Varbanov pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cq);
133569ff4b2cSStanimir Varbanov break;
13364ef6039fSStanimir Varbanov }
13376483a8cbSDikshita Agarwal case HFI_PROPERTY_PARAM_WORK_ROUTE: {
13386483a8cbSDikshita Agarwal struct hfi_video_work_route *in = pdata, *wr = prop_data;
13396483a8cbSDikshita Agarwal
13406483a8cbSDikshita Agarwal wr->video_work_route = in->video_work_route;
13416483a8cbSDikshita Agarwal pkt->shdr.hdr.size += sizeof(u32) + sizeof(*wr);
13426483a8cbSDikshita Agarwal break;
13436483a8cbSDikshita Agarwal }
13444ef6039fSStanimir Varbanov default:
134569ff4b2cSStanimir Varbanov return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata);
134669ff4b2cSStanimir Varbanov }
134769ff4b2cSStanimir Varbanov
134869ff4b2cSStanimir Varbanov return 0;
134969ff4b2cSStanimir Varbanov }
135069ff4b2cSStanimir Varbanov
pkt_session_get_property(struct hfi_session_get_property_pkt * pkt,void * cookie,u32 ptype)135109c2845eSStanimir Varbanov int pkt_session_get_property(struct hfi_session_get_property_pkt *pkt,
135209c2845eSStanimir Varbanov void *cookie, u32 ptype)
135309c2845eSStanimir Varbanov {
135409c2845eSStanimir Varbanov if (hfi_ver == HFI_VERSION_1XX)
135509c2845eSStanimir Varbanov return pkt_session_get_property_1x(pkt, cookie, ptype);
135609c2845eSStanimir Varbanov
135709c2845eSStanimir Varbanov return pkt_session_get_property_3xx(pkt, cookie, ptype);
135809c2845eSStanimir Varbanov }
135909c2845eSStanimir Varbanov
pkt_session_set_property(struct hfi_session_set_property_pkt * pkt,void * cookie,u32 ptype,void * pdata)136009c2845eSStanimir Varbanov int pkt_session_set_property(struct hfi_session_set_property_pkt *pkt,
136109c2845eSStanimir Varbanov void *cookie, u32 ptype, void *pdata)
136209c2845eSStanimir Varbanov {
136309c2845eSStanimir Varbanov if (hfi_ver == HFI_VERSION_1XX)
136409c2845eSStanimir Varbanov return pkt_session_set_property_1x(pkt, cookie, ptype, pdata);
136509c2845eSStanimir Varbanov
13666b183680SStanimir Varbanov if (hfi_ver == HFI_VERSION_3XX)
136709c2845eSStanimir Varbanov return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata);
13686b183680SStanimir Varbanov
136969ff4b2cSStanimir Varbanov if (hfi_ver == HFI_VERSION_4XX)
13706b183680SStanimir Varbanov return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata);
137169ff4b2cSStanimir Varbanov
137269ff4b2cSStanimir Varbanov return pkt_session_set_property_6xx(pkt, cookie, ptype, pdata);
137309c2845eSStanimir Varbanov }
137409c2845eSStanimir Varbanov
pkt_set_version(enum hfi_version version)137509c2845eSStanimir Varbanov void pkt_set_version(enum hfi_version version)
137609c2845eSStanimir Varbanov {
137709c2845eSStanimir Varbanov hfi_ver = version;
137809c2845eSStanimir Varbanov }
1379