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

Commit 497fe775 authored by Abhinav Kumar's avatar Abhinav Kumar
Browse files

disp: msm: add VDC-m parameter calculation support



Add support to calculate the parameters needed to configure
the VDC-m encoder. These are also needed to configure the PPS
command which shall be sent to the decoder.

Change-Id: I36db93f7555aee34b5b893e389a7eb88d0e05f68
Signed-off-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent 10996c18
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ msm_drm-$(CONFIG_DRM_MSM_SDE) += sde/sde_crtc.o \
	sde/sde_fence.o \
	sde/sde_hw_qdss.o \
	sde_dsc_helper.o \
	sde_vdc_helper.o \

msm_drm-$(CONFIG_DRM_SDE_WB) += sde/sde_wb.o \
	sde/sde_encoder_phys_wb.o \
+22 −2
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include "dsi_ctrl_hw.h"
#include "dsi_parser.h"
#include "sde_dsc_helper.h"
#include "sde_vdc_helper.h"

/**
 * topology is currently defined by a set of following 3 values:
@@ -2366,12 +2367,13 @@ static int dsi_panel_parse_dsc_params(struct dsi_display_mode *mode,
}

static int dsi_panel_parse_vdc_params(struct dsi_display_mode *mode,
				struct dsi_parser_utils *utils)
	struct dsi_parser_utils *utils, int traffic_mode, int panel_mode)
{
	u32 data;
	int rc = -EINVAL;
	const char *compression;
	struct dsi_display_mode_priv_info *priv_info;
	int intf_width;

	if (!mode || !mode->priv_info)
		return -EINVAL;
@@ -2389,6 +2391,9 @@ static int dsi_panel_parse_vdc_params(struct dsi_display_mode *mode,
		return 0;
	}

	priv_info->vdc.panel_mode = panel_mode;
	priv_info->vdc.traffic_mode = traffic_mode;

	rc = utils->read_u32(utils->data, "qcom,vdc-version", &data);
	if (rc) {
		priv_info->vdc.version_major = 0x1;
@@ -2477,6 +2482,8 @@ static int dsi_panel_parse_vdc_params(struct dsi_display_mode *mode,
		rc = -EINVAL;
		goto error;
	}

	intf_width = mode->timing.h_active;
	priv_info->vdc.slice_per_pkt = data;

	priv_info->vdc.frame_width = mode->timing.h_active;
@@ -2523,6 +2530,14 @@ static int dsi_panel_parse_vdc_params(struct dsi_display_mode *mode,
	}
	priv_info->vdc.source_color_space = data;

	rc = sde_vdc_populate_config(&priv_info->vdc,
		intf_width, traffic_mode);
	if (rc) {
		DSI_DEBUG("failed populating vdc config\n");
		rc = -EINVAL;
		goto error;
	}

	mode->timing.vdc_enabled = true;
	mode->timing.vdc = &priv_info->vdc;

@@ -3555,6 +3570,8 @@ int dsi_panel_get_mode(struct dsi_panel *panel,
	struct dsi_display_mode_priv_info *prv_info;
	u32 child_idx = 0;
	int rc = 0, num_timings;
	int traffic_mode;
	int panel_mode;
	void *utils_data = NULL;

	if (!panel || !mode) {
@@ -3589,6 +3606,8 @@ int dsi_panel_get_mode(struct dsi_panel *panel,
	}

	utils_data = utils->data;
	traffic_mode = panel->video_config.traffic_mode;
	panel_mode = panel->panel_mode;

	dsi_for_each_child_node(timings_np, child_np) {
		if (index != child_idx++)
@@ -3608,7 +3627,8 @@ int dsi_panel_get_mode(struct dsi_panel *panel,
			goto parse_fail;
		}

		rc = dsi_panel_parse_vdc_params(mode, utils);
		rc = dsi_panel_parse_vdc_params(mode, utils, traffic_mode,
			panel_mode);
		if (rc) {
			DSI_ERR("failed to parse vdc params, rc=%d\n", rc);
			goto parse_fail;
+213 −19
Original line number Diff line number Diff line
@@ -361,34 +361,228 @@ struct msm_display_dsc_info {
 * @version_minor:              minor version number of VDC encoder.
 * @source_color_space:         source color space of VDC encoder
 * @chroma_format:              chroma_format of VDC encoder.
 * @slice_height:            slice height configuration of encoder.
 * @slice_width:             slice width configuration of encoder.
 * @bytes_in_slice:          number of bytes per slice .
 * @slice_per_pkt:           number of slices per packet.
 * @mppf_bpc_r_y:               MPPF bpc for R/Y color component
 * @mppf_bpc_g_cb:              MPPF bpc for G/Cb color component
 * @mppf_bpc_b_cr:              MPPF bpc for B/Cr color component
 * @mppf_bpc_y:                 MPPF bpc for Y color component
 * @mppf_bpc_co:                MPPF bpc for Co color component
 * @mppf_bpc_cg:                MPPF bpc for Cg color component
 * @flatqp_vf_fbls:             flatness qp very flat FBLs
 * @flatqp_vf_nbls:             flatness qp very flat NBLs
 * @flatqp_sw_fbls:             flatness qp somewhat flat FBLs
 * @flatqp_sw_nbls:             flatness qp somewhat flat NBLs
 * @chroma_samples:             number of chroma samples
 * @split_panel_enable:         indicates whether split panel is enabled
 * @panel_mode:                 indicates panel is in video or cmd mode
 * @traffic_mode:               indicates burst/non-burst mode
 * @flatness_qp_lut:            LUT used to determine flatness QP
 * @max_qp_lut:                 LUT used to determine maximum QP
 * @tar_del_lut:                LUT used to calculate RC target rate
 * @lbda_brate_lut:             lambda bitrate LUT for encoder
 * @lbda_bf_lut:                lambda buffer fullness lut for encoder
 * @lbda_brate_lut_interp:      interpolated lambda bitrate LUT
 * @lbda_bf_lut_interp:         interpolated lambda buffer fullness lut
 * @num_of_active_ss:           number of active soft slices
 * @bits_per_component:         number of bits per component.
 * @max_pixels_per_line:        maximum pixels per line
 * @max_pixels_per_hs_line:     maximum pixels per hs line
 * @max_lines_per_frame:        maximum lines per frame
 * @max_lines_per_slice:        maximum lines per slice
 * @chunk_size:                 chunk size for encoder
 * @chunk_size_bits:            number of bits in the chunk
 * @avg_block_bits:             average block bits
 * @per_chunk_pad_bits:         number of bits per chunk pad
 * @tot_pad_bits:               total padding bits
 * @rc_stuffing_bits:           rate control stuffing bits
 * @chunk_adj_bits:             number of adjacent bits in the chunk
 * @rc_buf_init_size_temp:      temporary rate control buffer init size
 * @init_tx_delay_temp:         initial tx delay
 * @rc_buffer_init_size:        rate control buffer init size
 * @rc_init_tx_delay:           rate control buffer init tx delay
 * @rc_init_tx_delay_px_times:  rate control buffer init tx
 *                              delay times pixels
 * @rc_buffer_max_size:         max size of rate control buffer
 * @rc_tar_rate_scale_temp_a:   rate control target rate scale parameter
 * @rc_tar_rate_scale_temp_b:	rate control target rate scale parameter
 * @rc_tar_rate_scale:          rate control target rate scale
 * @block_max_bits:             max bits in the block
 * @rc_lambda_bitrate_scale:    rate control lambda bitrate scale
 * @rc_buffer_fullness_scale:   rate control lambda fullness scale
 * @rc_fullness_offset_thresh:  rate control lambda fullness threshold
 * @ramp_blocks:                number of ramp blocks
 * @bits_per_pixel:             number of bits per pixel.
 * @num_extra_mux_bits_init:    initial value of number of extra mux bits
 * @extra_crop_bits:            number of extra crop bits
 * @num_extra_mux_bits:         value of number of extra mux bits
 * @mppf_bits_comp_0:           mppf bits in color component 0
 * @mppf_bits_comp_1:           mppf bits in color component 1
 * @mppf_bits_comp_2:           mppf bits in color component 2
 * @min_block_bits:             min number of block bits
 * @slice_height:               slice height configuration of encoder.
 * @slice_width:                slice width configuration of encoder.
 * @frame_width:                frame width configuration of encoder
 * @frame_height:               frame height configuration of encoder
 * @bytes_in_slice:             Number of bytes in slice.
 * @bytes_per_pkt:              Number of bytes in packet.
 * @eol_byte_num:               Valid bytes at the end of line.
 * @pclk_per_line:              Compressed width.
 * @slice_per_pkt:              Number of slices per packet.
 * @pkt_per_line:               Number of packets per line.
 * @min_ssm_delay:              Min Sub-stream multiplexing delay
 * @max_ssm_delay:              Max Sub-stream multiplexing delay
 * @input_ssm_out_latency:      input Sub-stream multiplexing output latency
 * @input_ssm_out_latency_min:  min input Sub-stream multiplexing output latency
 * @obuf_latency:               Output buffer latency
 * @base_hs_latency:            base hard-slice latency
 * @base_hs_latency_min:        base hard-slice min latency
 * @base_hs_latency_pixels:     base hard-slice latency pixels
 * @base_hs_latency_pixels_min: base hard-slice latency pixels(min)
 * @base_initial_lines:         base initial lines
 * @base_top_up:                base top up
 * @output_rate:                output rate
 * @output_rate_ratio_100:      output rate times 100
 * @burst_accum_pixels:         burst accumulated pixels
 * @ss_initial_lines:           soft-slice initial lines
 * @burst_initial_lines:        burst mode initial lines
 * @initial_lines:              initial lines
 * @obuf_base:                  output buffer base
 * @obuf_extra_ss0:             output buffer extra ss0
 * @obuf_extra_ss1:             output buffer extra ss1
 * @obuf_extra_burst:           output buffer extra burst
 * @obuf_ss0:                   output buffer ss0
 * @obuf_ss1:                   output buffer ss1
 * @obuf_margin_words:          output buffer margin words
 * @ob0_max_addr:               output buffer 0 max address
 * @ob1_max_addr:               output buffer 1 max address
 * @slice_width_orig:           original slice width
 * @r2b0_max_addr:              r2b0 max addr
 * @r2b1_max_addr:              r1b1 max addr
 * @slice_num_px:               number of pixels per slice
 * @rc_target_rate_threshold:   rate control target rate threshold
 * @rc_fullness_offset_slope:   rate control fullness offset slop
 * @pps_delay_ms:               Post PPS command delay in milliseconds.
 * @version_release:            release version of VDC encoder.
 * @slice_num_bits:             number of bits per slice
 * @ramp_bits:                  number of ramp bits
 */
struct msm_display_vdc_info {
	u8 version_major;
	u8 version_minor;
	u8 chroma_format;

	u8 source_color_space;
	u8 chroma_format;
	u8 mppf_bpc_r_y;
	u8 mppf_bpc_g_cb;
	u8 mppf_bpc_b_cr;
	u8 mppf_bpc_y;
	u8 mppf_bpc_co;
	u8 mppf_bpc_cg;
	u8 flatqp_vf_fbls;
	u8 flatqp_vf_nbls;
	u8 flatqp_sw_fbls;
	u8 flatqp_sw_nbls;
	u8 chroma_samples;
	u8 split_panel_enable;
	u8 panel_mode;
	u8 traffic_mode;

	u16 flatness_qp_lut[8];
	u16 max_qp_lut[8];
	u16 tar_del_lut[16];
	u16 lbda_brate_lut[16];
	u16 lbda_bf_lut[16];
	u16 lbda_brate_lut_interp[64];
	u16 lbda_bf_lut_interp[64];

	u8 num_of_active_ss;
	u8 bits_per_component;

	u16 max_pixels_per_line;
	u16 max_pixels_per_hs_line;
	u16 max_lines_per_frame;
	u16 max_lines_per_slice;

	u16 chunk_size;
	u16 chunk_size_bits;

	u16 avg_block_bits;
	u16 per_chunk_pad_bits;
	u16 tot_pad_bits;
	u16 rc_stuffing_bits;
	u16 chunk_adj_bits;
	u16 rc_buf_init_size_temp;
	u16 init_tx_delay_temp;
	u16 rc_buffer_init_size;
	u16 rc_init_tx_delay;
	u16 rc_init_tx_delay_px_times;
	u16 rc_buffer_max_size;
	u16 rc_tar_rate_scale_temp_a;
	u16 rc_tar_rate_scale_temp_b;
	u16 rc_tar_rate_scale;
	u16 block_max_bits;
	u16 rc_lambda_bitrate_scale;
	u16 rc_buffer_fullness_scale;
	u16 rc_fullness_offset_thresh;
	u16 ramp_blocks;
	u16 bits_per_pixel;
	u16 num_extra_mux_bits_init;
	u16 extra_crop_bits;
	u16 num_extra_mux_bits;
	u16 mppf_bits_comp_0;
	u16 mppf_bits_comp_1;
	u16 mppf_bits_comp_2;
	u16 min_block_bits;

	int slice_height;
	int slice_width;
	int bytes_in_slice;
	int slice_per_pkt;
	int bits_per_component;
	int bits_per_pixel;
	int frame_width;
	int frame_height;

	int bytes_in_slice;
	int bytes_per_pkt;
	int eol_byte_num;
	int pclk_per_line;
	int slice_per_pkt;
	int pkt_per_line;

	int min_ssm_delay;
	int max_ssm_delay;
	int input_ssm_out_latency;
	int input_ssm_out_latency_min;
	int obuf_latency;
	int base_hs_latency;
	int base_hs_latency_min;
	int base_hs_latency_pixels;
	int base_hs_latency_pixels_min;
	int base_initial_lines;
	int base_top_up;
	int output_rate;
	int output_rate_ratio_100;
	int burst_accum_pixels;
	int ss_initial_lines;
	int burst_initial_lines;
	int initial_lines;
	int obuf_base;
	int obuf_extra_ss0;
	int obuf_extra_ss1;
	int obuf_extra_burst;
	int obuf_ss0;
	int obuf_ss1;
	int obuf_margin_words;
	int ob0_max_addr;
	int ob1_max_addr;
	int slice_width_orig;
	int r2b0_max_addr;
	int r2b1_max_addr;

	u32 slice_num_px;
	u32 rc_target_rate_threshold;
	u32 rc_fullness_offset_slope;
	u32 pps_delay_ms;
	u32 version_release;

	u64 slice_num_bits;
	u64 ramp_bits;
};

/**

msm/sde_vdc_helper.c

0 → 100644
+792 −0

File added.

Preview size limit exceeded, changes collapsed.

msm/sde_vdc_helper.h

0 → 100644
+49 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
 */

#ifndef __SDE_VDC_HELPER_H__
#define __SDE_VDC_HELPER_H__

#include "msm_drv.h"

#define VDC_BPP(bits_per_pixel) (bits_per_pixel >> 4)

#define VDC_NUM_BUF_RANGES (DSC_NUM_BUF_RANGES - 1)

#define VDC_FLAT_QP_LUT_SIZE 8
#define VDC_MAX_QP_LUT_SIZE 8
#define VDC_TAR_DEL_LUT_SIZE 16
#define VDC_LBDA_BRATE_LUT_SIZE 16
#define VDC_LBDA_BF_LUT_SIZE 16
#define VDC_LBDA_BRATE_REG_SIZE 64

#define VDC_VIDEO_MODE 0
#define VDC_CMD_MODE 1

#define VDC_TRAFFIC_SYNC_PULSES 0
#define VDC_TRAFFIC_SYNC_START_EVENTS 1
#define VDC_TRAFFIC_BURST_MODE 2

#define MAX_PIPELINE_LATENCY 68
#define OB_DATA_WIDTH 128
#define OUT_BUF_FULL_THRESH 2
#define OUT_BUF_UF_MARGIN 3
#define OUT_BUF_OF_MARGIN_TC_10 5
#define OUT_BUF_OF_MARGIN_OB 3
#define OUTPUT_DATA_WIDTH 64
#define OB0_RAM_DEPTH 912
#define OB1_RAM_DEPTH 736

#define SSM_MAX_SE_SIZE 128
#define RC_TARGET_RATE_EXTRA_FTBLS 2

#define NUM_ACTIVE_HS 1
#define MAX_PIXELS_PER_HS_LINE 5120

int sde_vdc_populate_config(struct msm_display_vdc_info *vdc_info,
	int intf_width, int traffic_mode);

#endif /* __SDE_VDC_HELPER_H__ */