diff mbox series

[22/25] media: venus: helpers, hfi, vdec: Set actual plane constraints to FW

Message ID 20210222160300.1811121-23-bryan.odonoghue@linaro.org (mailing list archive)
State Superseded
Headers show
Series media: venus: Enable 6xx support | expand

Commit Message

Bryan O'Donoghue Feb. 22, 2021, 4:02 p.m. UTC
From: Dikshita Agarwal <dikshita@codeaurora.org>

Set actual plane alignments to FW with
HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO to calculate
correct buffer size.

bod: Fixed fall-through error in pkt_session_set_property_6xx() switch

Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/platform/qcom/venus/helpers.c  | 21 ++++++++++++++++++++
 drivers/media/platform/qcom/venus/helpers.h  |  1 +
 drivers/media/platform/qcom/venus/hfi_cmds.c | 13 ++++++++++++
 drivers/media/platform/qcom/venus/vdec.c     |  4 ++++
 4 files changed, 39 insertions(+)

Comments

Stanimir Varbanov Feb. 25, 2021, 8 a.m. UTC | #1
On 2/22/21 6:02 PM, Bryan O'Donoghue wrote:
> From: Dikshita Agarwal <dikshita@codeaurora.org>
> 
> Set actual plane alignments to FW with
> HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO to calculate
> correct buffer size.
> 
> bod: Fixed fall-through error in pkt_session_set_property_6xx() switch
> 
> Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  drivers/media/platform/qcom/venus/helpers.c  | 21 ++++++++++++++++++++
>  drivers/media/platform/qcom/venus/helpers.h  |  1 +
>  drivers/media/platform/qcom/venus/hfi_cmds.c | 13 ++++++++++++
>  drivers/media/platform/qcom/venus/vdec.c     |  4 ++++
>  4 files changed, 39 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index f0413236a56f..49c52ef1084a 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -1113,6 +1113,27 @@ int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode)
>  }
>  EXPORT_SYMBOL_GPL(venus_helper_set_work_mode);
>  
> +int venus_helper_set_format_constraints(struct venus_inst *inst)
> +{
> +	const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO;
> +	struct hfi_uncompressed_plane_actual_constraints_info pconstraint;
> +
> +	pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
> +	pconstraint.num_planes = 2;
> +	pconstraint.plane_format[0].stride_multiples = 128;
> +	pconstraint.plane_format[0].max_stride = 8192;
> +	pconstraint.plane_format[0].min_plane_buffer_height_multiple = 32;
> +	pconstraint.plane_format[0].buffer_alignment = 256;
> +
> +	pconstraint.plane_format[1].stride_multiples = 128;
> +	pconstraint.plane_format[1].max_stride = 8192;
> +	pconstraint.plane_format[1].min_plane_buffer_height_multiple = 16;
> +	pconstraint.plane_format[1].buffer_alignment = 256;
> +
> +	return hfi_session_set_property(inst, ptype, &pconstraint);

I wonder shouldn't we set this property for v6 only? Or mark this
property as not supported for v1 up to v4.  Otherwise, I would expect
regressions on the older v1 - v4.

> +}
> +EXPORT_SYMBOL_GPL(venus_helper_set_format_constraints);
> +
>  int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
>  			      unsigned int output_bufs,
>  			      unsigned int output2_bufs)
> diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
> index 351093845499..98106e6eee85 100644
> --- a/drivers/media/platform/qcom/venus/helpers.h
> +++ b/drivers/media/platform/qcom/venus/helpers.h
> @@ -33,6 +33,7 @@ int venus_helper_set_output_resolution(struct venus_inst *inst,
>  				       unsigned int width, unsigned int height,
>  				       u32 buftype);
>  int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode);
> +int venus_helper_set_format_constraints(struct venus_inst *inst);
>  int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
>  			      unsigned int output_bufs,
>  			      unsigned int output2_bufs);
> diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c
> index 4f7565834469..cc282b0df8c3 100644
> --- a/drivers/media/platform/qcom/venus/hfi_cmds.c
> +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c
> @@ -1249,6 +1249,19 @@ pkt_session_set_property_6xx(struct hfi_session_set_property_pkt *pkt,
>  	pkt->data[0] = ptype;
>  
>  	switch (ptype) {
> +	case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: {
> +		struct hfi_uncompressed_plane_actual_constraints_info *in = pdata;
> +		struct hfi_uncompressed_plane_actual_constraints_info *info = prop_data;
> +
> +		info->buffer_type = in->buffer_type;
> +		info->num_planes = in->num_planes;
> +		info->plane_format[0] = in->plane_format[0];
> +		if (in->num_planes > 1)
> +			info->plane_format[1] = in->plane_format[1];
> +
> +		pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
> +		break;
> +	}
>  	case HFI_PROPERTY_CONFIG_HEIC_FRAME_QUALITY: {
>  		struct hfi_heic_frame_quality *in = pdata, *cq = prop_data;
>  
> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
> index 84c16f33e01b..88ac40ce12e6 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -698,6 +698,10 @@ static int vdec_output_conf(struct venus_inst *inst)
>  	if (ret)
>  		return ret;
>  
> +	ret = venus_helper_set_format_constraints(inst);
> +	if (ret)
> +		return ret;
> +
>  	if (inst->dpb_fmt) {
>  		ret = venus_helper_set_multistream(inst, false, true);
>  		if (ret)
>
Bryan O'Donoghue March 12, 2021, 2:58 a.m. UTC | #2
On 25/02/2021 08:00, Stanimir Varbanov wrote:
> 
> 
> On 2/22/21 6:02 PM, Bryan O'Donoghue wrote:
>> From: Dikshita Agarwal <dikshita@codeaurora.org>
>>
>> Set actual plane alignments to FW with
>> HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO to calculate
>> correct buffer size.
>>
>> bod: Fixed fall-through error in pkt_session_set_property_6xx() switch
>>
>> Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>> ---
>>   drivers/media/platform/qcom/venus/helpers.c  | 21 ++++++++++++++++++++
>>   drivers/media/platform/qcom/venus/helpers.h  |  1 +
>>   drivers/media/platform/qcom/venus/hfi_cmds.c | 13 ++++++++++++
>>   drivers/media/platform/qcom/venus/vdec.c     |  4 ++++
>>   4 files changed, 39 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
>> index f0413236a56f..49c52ef1084a 100644
>> --- a/drivers/media/platform/qcom/venus/helpers.c
>> +++ b/drivers/media/platform/qcom/venus/helpers.c
>> @@ -1113,6 +1113,27 @@ int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode)
>>   }
>>   EXPORT_SYMBOL_GPL(venus_helper_set_work_mode);
>>   
>> +int venus_helper_set_format_constraints(struct venus_inst *inst)
>> +{
>> +	const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO;
>> +	struct hfi_uncompressed_plane_actual_constraints_info pconstraint;
>> +
>> +	pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
>> +	pconstraint.num_planes = 2;
>> +	pconstraint.plane_format[0].stride_multiples = 128;
>> +	pconstraint.plane_format[0].max_stride = 8192;
>> +	pconstraint.plane_format[0].min_plane_buffer_height_multiple = 32;
>> +	pconstraint.plane_format[0].buffer_alignment = 256;
>> +
>> +	pconstraint.plane_format[1].stride_multiples = 128;
>> +	pconstraint.plane_format[1].max_stride = 8192;
>> +	pconstraint.plane_format[1].min_plane_buffer_height_multiple = 16;
>> +	pconstraint.plane_format[1].buffer_alignment = 256;
>> +
>> +	return hfi_session_set_property(inst, ptype, &pconstraint);
> 
> I wonder shouldn't we set this property for v6 only? Or mark this
> property as not supported for v1 up to v4.  Otherwise, I would expect
> regressions on the older v1 - v4.

BTW you're right, this breaks 1xx.
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index f0413236a56f..49c52ef1084a 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -1113,6 +1113,27 @@  int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode)
 }
 EXPORT_SYMBOL_GPL(venus_helper_set_work_mode);
 
+int venus_helper_set_format_constraints(struct venus_inst *inst)
+{
+	const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO;
+	struct hfi_uncompressed_plane_actual_constraints_info pconstraint;
+
+	pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
+	pconstraint.num_planes = 2;
+	pconstraint.plane_format[0].stride_multiples = 128;
+	pconstraint.plane_format[0].max_stride = 8192;
+	pconstraint.plane_format[0].min_plane_buffer_height_multiple = 32;
+	pconstraint.plane_format[0].buffer_alignment = 256;
+
+	pconstraint.plane_format[1].stride_multiples = 128;
+	pconstraint.plane_format[1].max_stride = 8192;
+	pconstraint.plane_format[1].min_plane_buffer_height_multiple = 16;
+	pconstraint.plane_format[1].buffer_alignment = 256;
+
+	return hfi_session_set_property(inst, ptype, &pconstraint);
+}
+EXPORT_SYMBOL_GPL(venus_helper_set_format_constraints);
+
 int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
 			      unsigned int output_bufs,
 			      unsigned int output2_bufs)
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index 351093845499..98106e6eee85 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -33,6 +33,7 @@  int venus_helper_set_output_resolution(struct venus_inst *inst,
 				       unsigned int width, unsigned int height,
 				       u32 buftype);
 int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode);
+int venus_helper_set_format_constraints(struct venus_inst *inst);
 int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs,
 			      unsigned int output_bufs,
 			      unsigned int output2_bufs);
diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c
index 4f7565834469..cc282b0df8c3 100644
--- a/drivers/media/platform/qcom/venus/hfi_cmds.c
+++ b/drivers/media/platform/qcom/venus/hfi_cmds.c
@@ -1249,6 +1249,19 @@  pkt_session_set_property_6xx(struct hfi_session_set_property_pkt *pkt,
 	pkt->data[0] = ptype;
 
 	switch (ptype) {
+	case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: {
+		struct hfi_uncompressed_plane_actual_constraints_info *in = pdata;
+		struct hfi_uncompressed_plane_actual_constraints_info *info = prop_data;
+
+		info->buffer_type = in->buffer_type;
+		info->num_planes = in->num_planes;
+		info->plane_format[0] = in->plane_format[0];
+		if (in->num_planes > 1)
+			info->plane_format[1] = in->plane_format[1];
+
+		pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
+		break;
+	}
 	case HFI_PROPERTY_CONFIG_HEIC_FRAME_QUALITY: {
 		struct hfi_heic_frame_quality *in = pdata, *cq = prop_data;
 
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 84c16f33e01b..88ac40ce12e6 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -698,6 +698,10 @@  static int vdec_output_conf(struct venus_inst *inst)
 	if (ret)
 		return ret;
 
+	ret = venus_helper_set_format_constraints(inst);
+	if (ret)
+		return ret;
+
 	if (inst->dpb_fmt) {
 		ret = venus_helper_set_multistream(inst, false, true);
 		if (ret)