Skip to content

Commit 8466a14

Browse files
committed
drm/i915: Replace to_bpp_int() with fxp_q4_to_int()
Replace the to_bpp_int() helper defined by the driver with the equivalent fxp_q4_to_int() helper defined by DRM core. v2: Rebase on the s/drm_x16/fxp_q4 change. Acked-by: Jani Nikula <[email protected]> Signed-off-by: Imre Deak <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3196763 commit 8466a14

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

drivers/gpu/drm/i915/display/icl_dsi.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <drm/display/drm_dsc_helper.h>
2929
#include <drm/drm_atomic_helper.h>
30+
#include <drm/drm_fixed.h>
3031
#include <drm/drm_mipi_dsi.h>
3132

3233
#include "i915_reg.h"
@@ -330,7 +331,7 @@ static int afe_clk(struct intel_encoder *encoder,
330331
int bpp;
331332

332333
if (crtc_state->dsc.compression_enable)
333-
bpp = to_bpp_int(crtc_state->dsc.compressed_bpp_x16);
334+
bpp = fxp_q4_to_int(crtc_state->dsc.compressed_bpp_x16);
334335
else
335336
bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
336337

@@ -863,7 +864,7 @@ gen11_dsi_set_transcoder_timings(struct intel_encoder *encoder,
863864
* compressed and non-compressed bpp.
864865
*/
865866
if (crtc_state->dsc.compression_enable) {
866-
mul = to_bpp_int(crtc_state->dsc.compressed_bpp_x16);
867+
mul = fxp_q4_to_int(crtc_state->dsc.compressed_bpp_x16);
867868
div = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
868869
}
869870

@@ -887,7 +888,7 @@ gen11_dsi_set_transcoder_timings(struct intel_encoder *encoder,
887888
int bpp, line_time_us, byte_clk_period_ns;
888889

889890
if (crtc_state->dsc.compression_enable)
890-
bpp = to_bpp_int(crtc_state->dsc.compressed_bpp_x16);
891+
bpp = fxp_q4_to_int(crtc_state->dsc.compressed_bpp_x16);
891892
else
892893
bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
893894

@@ -1470,7 +1471,7 @@ static void gen11_dsi_get_timings(struct intel_encoder *encoder,
14701471
&pipe_config->hw.adjusted_mode;
14711472

14721473
if (pipe_config->dsc.compressed_bpp_x16) {
1473-
int div = to_bpp_int(pipe_config->dsc.compressed_bpp_x16);
1474+
int div = fxp_q4_to_int(pipe_config->dsc.compressed_bpp_x16);
14741475
int mul = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
14751476

14761477
adjusted_mode->crtc_htotal =

drivers/gpu/drm/i915/display/intel_display.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <drm/drm_atomic_uapi.h>
4040
#include <drm/drm_damage_helper.h>
4141
#include <drm/drm_edid.h>
42+
#include <drm/drm_fixed.h>
4243
#include <drm/drm_fourcc.h>
4344
#include <drm/drm_probe_helper.h>
4445
#include <drm/drm_rect.h>
@@ -4679,7 +4680,7 @@ intel_modeset_pipe_config(struct intel_atomic_state *state,
46794680
crtc_state->fec_enable = limits->force_fec_pipes & BIT(crtc->pipe);
46804681
crtc_state->max_link_bpp_x16 = limits->max_bpp_x16[crtc->pipe];
46814682

4682-
if (crtc_state->pipe_bpp > to_bpp_int(crtc_state->max_link_bpp_x16)) {
4683+
if (crtc_state->pipe_bpp > fxp_q4_to_int(crtc_state->max_link_bpp_x16)) {
46834684
drm_dbg_kms(&i915->drm,
46844685
"[CRTC:%d:%s] Link bpp limited to " BPP_X16_FMT "\n",
46854686
crtc->base.base.id, crtc->base.name,

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,18 +2200,13 @@ to_intel_frontbuffer(struct drm_framebuffer *fb)
22002200
return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
22012201
}
22022202

2203-
static inline int to_bpp_int(int bpp_x16)
2204-
{
2205-
return bpp_x16 >> 4;
2206-
}
2207-
22082203
static inline int to_bpp_frac(int bpp_x16)
22092204
{
22102205
return bpp_x16 & 0xf;
22112206
}
22122207

22132208
#define BPP_X16_FMT "%d.%04d"
2214-
#define BPP_X16_ARGS(bpp_x16) to_bpp_int(bpp_x16), (to_bpp_frac(bpp_x16) * 625)
2209+
#define BPP_X16_ARGS(bpp_x16) fxp_q4_to_int(bpp_x16), (to_bpp_frac(bpp_x16) * 625)
22152210

22162211
static inline int to_bpp_int_roundup(int bpp_x16)
22172212
{

drivers/gpu/drm/i915/display/intel_dp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,8 +1694,8 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
16941694
int bpp, i, lane_count, clock = intel_dp_mode_clock(pipe_config, conn_state);
16951695
int mode_rate, link_rate, link_avail;
16961696

1697-
for (bpp = to_bpp_int(limits->link.max_bpp_x16);
1698-
bpp >= to_bpp_int(limits->link.min_bpp_x16);
1697+
for (bpp = fxp_q4_to_int(limits->link.max_bpp_x16);
1698+
bpp >= fxp_q4_to_int(limits->link.min_bpp_x16);
16991699
bpp -= 2 * 3) {
17001700
int link_bpp = intel_dp_output_bpp(pipe_config->output_format, bpp);
17011701

@@ -2113,7 +2113,7 @@ static int dsc_compute_compressed_bpp(struct intel_dp *intel_dp,
21132113
adjusted_mode->hdisplay,
21142114
pipe_config->joiner_pipes);
21152115
dsc_max_bpp = min(dsc_max_bpp, dsc_joiner_max_bpp);
2116-
dsc_max_bpp = min(dsc_max_bpp, to_bpp_int(limits->link.max_bpp_x16));
2116+
dsc_max_bpp = min(dsc_max_bpp, fxp_q4_to_int(limits->link.max_bpp_x16));
21172117

21182118
if (DISPLAY_VER(i915) >= 13)
21192119
return xelpd_dsc_compute_link_config(intel_dp, connector, pipe_config, limits,
@@ -2270,7 +2270,7 @@ static int intel_edp_dsc_compute_pipe_bpp(struct intel_dp *intel_dp,
22702270
pipe_config,
22712271
pipe_bpp / 3);
22722272
dsc_max_bpp = dsc_sink_max_bpp ? min(dsc_sink_max_bpp, dsc_src_max_bpp) : dsc_src_max_bpp;
2273-
dsc_max_bpp = min(dsc_max_bpp, to_bpp_int(limits->link.max_bpp_x16));
2273+
dsc_max_bpp = min(dsc_max_bpp, fxp_q4_to_int(limits->link.max_bpp_x16));
22742274

22752275
/* Compressed BPP should be less than the Input DSC bpp */
22762276
dsc_max_bpp = min(dsc_max_bpp, pipe_bpp - 1);

drivers/gpu/drm/i915/display/intel_dp_mst.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
309309
* YUV420 is only half of the pipe bpp value.
310310
*/
311311
slots = intel_dp_mst_find_vcpi_slots_for_bpp(encoder, crtc_state,
312-
to_bpp_int(limits->link.max_bpp_x16),
313-
to_bpp_int(limits->link.min_bpp_x16),
312+
fxp_q4_to_int(limits->link.max_bpp_x16),
313+
fxp_q4_to_int(limits->link.min_bpp_x16),
314314
limits,
315315
conn_state, 2 * 3, false);
316316

@@ -375,7 +375,7 @@ static int intel_dp_dsc_mst_compute_link_config(struct intel_encoder *encoder,
375375
crtc_state,
376376
max_bpp / 3);
377377
max_compressed_bpp = min(max_compressed_bpp,
378-
to_bpp_int(limits->link.max_bpp_x16));
378+
fxp_q4_to_int(limits->link.max_bpp_x16));
379379

380380
min_compressed_bpp = intel_dp_dsc_sink_min_compressed_bpp(crtc_state);
381381
min_compressed_bpp = max(min_compressed_bpp,

drivers/gpu/drm/i915/display/intel_fdi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ int intel_fdi_link_freq(struct drm_i915_private *i915,
306306
bool intel_fdi_compute_pipe_bpp(struct intel_crtc_state *crtc_state)
307307
{
308308
int pipe_bpp = min(crtc_state->pipe_bpp,
309-
to_bpp_int(crtc_state->max_link_bpp_x16));
309+
fxp_q4_to_int(crtc_state->max_link_bpp_x16));
310310

311311
pipe_bpp = rounddown(pipe_bpp, 2 * 3);
312312

drivers/gpu/drm/i915/display/intel_vdsc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/limits.h>
99

1010
#include <drm/display/drm_dsc_helper.h>
11+
#include <drm/drm_fixed.h>
1112

1213
#include "i915_drv.h"
1314
#include "intel_crtc.h"
@@ -76,7 +77,7 @@ intel_vdsc_set_min_max_qp(struct drm_dsc_config *vdsc_cfg, int buf,
7677
static void
7778
calculate_rc_params(struct drm_dsc_config *vdsc_cfg)
7879
{
79-
int bpp = to_bpp_int(vdsc_cfg->bits_per_pixel);
80+
int bpp = fxp_q4_to_int(vdsc_cfg->bits_per_pixel);
8081
int bpc = vdsc_cfg->bits_per_component;
8182
int qp_bpc_modifier = (bpc - 8) * 2;
8283
int uncompressed_bpg_rate;
@@ -263,7 +264,7 @@ int intel_dsc_compute_params(struct intel_crtc_state *pipe_config)
263264
struct intel_crtc *crtc = to_intel_crtc(pipe_config->uapi.crtc);
264265
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
265266
struct drm_dsc_config *vdsc_cfg = &pipe_config->dsc.config;
266-
u16 compressed_bpp = to_bpp_int(pipe_config->dsc.compressed_bpp_x16);
267+
u16 compressed_bpp = fxp_q4_to_int(pipe_config->dsc.compressed_bpp_x16);
267268
int err;
268269
int ret;
269270

0 commit comments

Comments
 (0)