Skip to content

Commit fba4d19

Browse files
Navid Assadianalexdeucher
authored andcommitted
drm/amd/display: Add opp recout adjustment
[Why] For subsampled YUV output formats, more pixels can get fetched and be used for scaling. [How] Add the adjustment to the calculated recout, so the viewport covers the corresponding pixels on the source plane. Signed-off-by: Navid Assadian <Navid.Assadian@amd.com> Reviewed-by: Samson Tam <Samson.Tam@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 86f06bc commit fba4d19

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ static struct spl_rect shift_rec(const struct spl_rect *rec_in, int x, int y)
7676
return rec_out;
7777
}
7878

79+
static void spl_opp_adjust_rect(struct spl_rect *rec, const struct spl_opp_adjust *adjust)
80+
{
81+
if ((rec->x + adjust->x) >= 0)
82+
rec->x += adjust->x;
83+
84+
if ((rec->y + adjust->y) >= 0)
85+
rec->y += adjust->y;
86+
87+
if ((rec->width + adjust->width) >= 1)
88+
rec->width += adjust->width;
89+
90+
if ((rec->height + adjust->height) >= 1)
91+
rec->height += adjust->height;
92+
}
93+
7994
static struct spl_rect calculate_plane_rec_in_timing_active(
8095
struct spl_in *spl_in,
8196
const struct spl_rect *rec_in)
@@ -723,13 +738,15 @@ static void spl_handle_3d_recout(struct spl_in *spl_in, struct spl_rect *recout)
723738
}
724739
}
725740

726-
static void spl_clamp_viewport(struct spl_rect *viewport)
741+
static void spl_clamp_viewport(struct spl_rect *viewport, int min_viewport_size)
727742
{
743+
if (min_viewport_size == 0)
744+
min_viewport_size = MIN_VIEWPORT_SIZE;
728745
/* Clamp minimum viewport size */
729-
if (viewport->height < MIN_VIEWPORT_SIZE)
730-
viewport->height = MIN_VIEWPORT_SIZE;
731-
if (viewport->width < MIN_VIEWPORT_SIZE)
732-
viewport->width = MIN_VIEWPORT_SIZE;
746+
if (viewport->height < min_viewport_size)
747+
viewport->height = min_viewport_size;
748+
if (viewport->width < min_viewport_size)
749+
viewport->width = min_viewport_size;
733750
}
734751

735752
static enum scl_mode spl_get_dscl_mode(const struct spl_in *spl_in,
@@ -1764,6 +1781,8 @@ static bool spl_calculate_number_of_taps(struct spl_in *spl_in, struct spl_scrat
17641781
spl_calculate_recout(spl_in, spl_scratch, spl_out);
17651782
/* depends on pixel format */
17661783
spl_calculate_scaling_ratios(spl_in, spl_scratch, spl_out);
1784+
/* Adjust recout for opp if needed */
1785+
spl_opp_adjust_rect(&spl_scratch->scl_data.recout, &spl_in->basic_in.opp_recout_adjust);
17671786
/* depends on scaling ratios and recout, does not calculate offset yet */
17681787
spl_calculate_viewport_size(spl_in, spl_scratch);
17691788

@@ -1800,7 +1819,7 @@ bool spl_calculate_scaler_params(struct spl_in *spl_in, struct spl_out *spl_out)
18001819
// Handle 3d recout
18011820
spl_handle_3d_recout(spl_in, &spl_scratch.scl_data.recout);
18021821
// Clamp
1803-
spl_clamp_viewport(&spl_scratch.scl_data.viewport);
1822+
spl_clamp_viewport(&spl_scratch.scl_data.viewport, spl_in->min_viewport_size);
18041823

18051824
// Save all calculated parameters in dscl_prog_data structure to program hw registers
18061825
spl_set_dscl_prog_data(spl_in, &spl_scratch, spl_out, enable_easf_v, enable_easf_h, enable_isharp);

drivers/gpu/drm/amd/display/dc/sspl/dc_spl_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ struct spl_out {
427427

428428
// SPL inputs
429429

430+
// opp extra adjustment for rect
431+
struct spl_opp_adjust {
432+
int x;
433+
int y;
434+
int width;
435+
int height;
436+
};
437+
430438
// Basic input information
431439
struct basic_in {
432440
enum spl_pixel_format format; // Pixel Format
@@ -444,6 +452,7 @@ struct basic_in {
444452
} num_slices_recout_width;
445453
} num_h_slices_recout_width_align;
446454
int mpc_h_slice_index; // previous mpc_combine_v - split_idx
455+
struct spl_opp_adjust opp_recout_adjust;
447456
// Inputs for adaptive scaler - TODO
448457
enum spl_transfer_func_type tf_type; /* Transfer function type */
449458
enum spl_transfer_func_predefined tf_predefined_type; /* Transfer function predefined type */
@@ -535,6 +544,7 @@ struct spl_in {
535544
bool is_hdr_on;
536545
int h_active;
537546
int v_active;
547+
int min_viewport_size;
538548
int sdr_white_level_nits;
539549
enum sharpen_policy sharpen_policy;
540550
};

0 commit comments

Comments
 (0)