Skip to content

Commit c3a1aab

Browse files
MarijnS95lumag
authored andcommitted
drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
As per the FIXME this code is entirely duplicate with what is already provided inside drm_dsc_compute_rc_parameters(), supposedly because that function was yielding "incorrect" results while in reality the panel driver(s?) used for testing were providing incorrect parameters. For example, this code from downstream assumed dsc->bits_per_pixel to contain an integer value, whereas the upstream drm_dsc_config struct stores it with 4 fractional bits. drm_dsc_compute_rc_parameters() already accounts for this feat while the panel driver used for testing [1] wasn't, hence making drm_dsc_compute_rc_parameters() seem like it was returning an incorrect result. Other users of dsc->bits_per_pixel inside dsi_populate_dsc_params() also treat it in the same erroneous way, and will be addressed in a separate patch. In the end, using drm_dsc_compute_rc_parameters() spares both a lot of duplicate code and erratic behaviour. [1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1 Fixes: b908032 ("drm/msm/dsi: add support for dsc data") Reviewed-by: Abhinav Kumar <[email protected]> Signed-off-by: Marijn Suijten <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/508939/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 0ca870c commit c3a1aab

File tree

1 file changed

+6
-58
lines changed

1 file changed

+6
-58
lines changed

drivers/gpu/drm/msm/dsi/dsi_host.c

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <video/mipi_display.h>
2323

24+
#include <drm/display/drm_dsc_helper.h>
2425
#include <drm/drm_of.h>
2526

2627
#include "dsi.h"
@@ -1749,14 +1750,6 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
17491750

17501751
static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
17511752
{
1752-
int mux_words_size;
1753-
int groups_per_line, groups_total;
1754-
int min_rate_buffer_size;
1755-
int hrd_delay;
1756-
int pre_num_extra_mux_bits, num_extra_mux_bits;
1757-
int slice_bits;
1758-
int data;
1759-
int final_value, final_scale;
17601753
int i;
17611754

17621755
dsc->rc_model_size = 8192;
@@ -1782,11 +1775,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
17821775
if (dsc->bits_per_pixel != 8)
17831776
dsc->initial_offset = 2048; /* bpp = 12 */
17841777

1785-
mux_words_size = 48; /* bpc == 8/10 */
1786-
if (dsc->bits_per_component == 12)
1787-
mux_words_size = 64;
1778+
if (dsc->bits_per_component <= 10)
1779+
dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
1780+
else
1781+
dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
17881782

1789-
dsc->mux_word_size = mux_words_size;
17901783
dsc->initial_xmit_delay = 512;
17911784
dsc->initial_scale_value = 32;
17921785
dsc->first_line_bpg_offset = 12;
@@ -1798,52 +1791,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
17981791
dsc->rc_quant_incr_limit0 = 11;
17991792
dsc->rc_quant_incr_limit1 = 11;
18001793

1801-
/* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
1802-
* params are calculated
1803-
*/
1804-
groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
1805-
dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
1806-
1807-
/* rbs-min */
1808-
min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
1809-
dsc->initial_xmit_delay * dsc->bits_per_pixel +
1810-
groups_per_line * dsc->first_line_bpg_offset;
1811-
1812-
hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->bits_per_pixel);
1813-
1814-
dsc->initial_dec_delay = hrd_delay - dsc->initial_xmit_delay;
1815-
1816-
dsc->initial_scale_value = 8 * dsc->rc_model_size /
1817-
(dsc->rc_model_size - dsc->initial_offset);
1818-
1819-
slice_bits = 8 * dsc->slice_chunk_size * dsc->slice_height;
1820-
1821-
groups_total = groups_per_line * dsc->slice_height;
1822-
1823-
data = dsc->first_line_bpg_offset * 2048;
1824-
1825-
dsc->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->slice_height - 1));
1826-
1827-
pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->bits_per_component + 4) - 2);
1828-
1829-
num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size -
1830-
((slice_bits - pre_num_extra_mux_bits) % mux_words_size));
1831-
1832-
data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
1833-
dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
1834-
1835-
data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
1836-
final_value = dsc->rc_model_size - data + num_extra_mux_bits;
1837-
dsc->final_offset = final_value;
1838-
1839-
final_scale = 8 * dsc->rc_model_size / (dsc->rc_model_size - final_value);
1840-
1841-
data = (final_scale - 9) * (dsc->nfl_bpg_offset + dsc->slice_bpg_offset);
1842-
dsc->scale_increment_interval = (2048 * dsc->final_offset) / data;
1843-
1844-
dsc->scale_decrement_interval = groups_per_line / (dsc->initial_scale_value - 8);
1845-
1846-
return 0;
1794+
return drm_dsc_compute_rc_parameters(dsc);
18471795
}
18481796

18491797
static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)

0 commit comments

Comments
 (0)