.. | .. |
---|
23 | 23 | * |
---|
24 | 24 | */ |
---|
25 | 25 | |
---|
| 26 | +#include <linux/slab.h> |
---|
| 27 | + |
---|
| 28 | +#include "resource.h" |
---|
26 | 29 | #include "dm_services.h" |
---|
27 | 30 | #include "dce_calcs.h" |
---|
28 | 31 | #include "dc.h" |
---|
.. | .. |
---|
151 | 154 | |
---|
152 | 155 | |
---|
153 | 156 | |
---|
154 | | - if (data->d0_underlay_mode == bw_def_none) { d0_underlay_enable = 0; } |
---|
155 | | - else { |
---|
156 | | - d0_underlay_enable = 1; |
---|
157 | | - } |
---|
158 | | - if (data->d1_underlay_mode == bw_def_none) { d1_underlay_enable = 0; } |
---|
159 | | - else { |
---|
160 | | - d1_underlay_enable = 1; |
---|
161 | | - } |
---|
| 157 | + if (data->d0_underlay_mode == bw_def_none) |
---|
| 158 | + d0_underlay_enable = false; |
---|
| 159 | + else |
---|
| 160 | + d0_underlay_enable = true; |
---|
| 161 | + if (data->d1_underlay_mode == bw_def_none) |
---|
| 162 | + d1_underlay_enable = false; |
---|
| 163 | + else |
---|
| 164 | + d1_underlay_enable = true; |
---|
162 | 165 | data->number_of_underlay_surfaces = d0_underlay_enable + d1_underlay_enable; |
---|
163 | 166 | switch (data->underlay_surface_type) { |
---|
164 | 167 | case bw_def_420: |
---|
.. | .. |
---|
283 | 286 | data->cursor_width_pixels[2] = bw_int_to_fixed(0); |
---|
284 | 287 | data->cursor_width_pixels[3] = bw_int_to_fixed(0); |
---|
285 | 288 | /* graphics surface parameters from spreadsheet*/ |
---|
286 | | - fbc_enabled = 0; |
---|
287 | | - lpt_enabled = 0; |
---|
| 289 | + fbc_enabled = false; |
---|
| 290 | + lpt_enabled = false; |
---|
288 | 291 | for (i = 4; i <= maximum_number_of_surfaces - 3; i++) { |
---|
289 | 292 | if (i < data->number_of_displays + 4) { |
---|
290 | 293 | if (i == 4 && data->d0_underlay_mode == bw_def_underlay_only) { |
---|
.. | .. |
---|
335 | 338 | data->access_one_channel_only[i] = 0; |
---|
336 | 339 | } |
---|
337 | 340 | if (data->fbc_en[i] == 1) { |
---|
338 | | - fbc_enabled = 1; |
---|
| 341 | + fbc_enabled = true; |
---|
339 | 342 | if (data->lpt_en[i] == 1) { |
---|
340 | | - lpt_enabled = 1; |
---|
| 343 | + lpt_enabled = true; |
---|
341 | 344 | } |
---|
342 | 345 | } |
---|
343 | 346 | data->cursor_width_pixels[i] = bw_int_to_fixed(vbios->cursor_width); |
---|
.. | .. |
---|
2792 | 2795 | data->lpt_en[num_displays + 4] = false; |
---|
2793 | 2796 | data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total); |
---|
2794 | 2797 | data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total); |
---|
2795 | | - data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_khz, 1000); |
---|
| 2798 | + data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_100hz, 10000); |
---|
2796 | 2799 | data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width); |
---|
2797 | 2800 | data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4]; |
---|
2798 | 2801 | data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.height); |
---|
.. | .. |
---|
2850 | 2853 | data->src_height[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.height); |
---|
2851 | 2854 | data->src_width[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.width); |
---|
2852 | 2855 | data->pitch_in_pixels[num_displays * 2 + j] = bw_int_to_fixed( |
---|
2853 | | - pipe[i].bottom_pipe->plane_state->plane_size.grph.surface_pitch); |
---|
| 2856 | + pipe[i].bottom_pipe->plane_state->plane_size.surface_pitch); |
---|
2854 | 2857 | data->h_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.h_taps); |
---|
2855 | 2858 | data->v_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.v_taps); |
---|
2856 | 2859 | data->h_scale_ratio[num_displays * 2 + j] = fixed31_32_to_bw_fixed( |
---|
.. | .. |
---|
2881 | 2884 | |
---|
2882 | 2885 | /* Pipes without underlay after */ |
---|
2883 | 2886 | for (i = 0; i < pipe_count; i++) { |
---|
| 2887 | + unsigned int pixel_clock_100hz; |
---|
2884 | 2888 | if (!pipe[i].stream || pipe[i].bottom_pipe) |
---|
2885 | 2889 | continue; |
---|
2886 | 2890 | |
---|
.. | .. |
---|
2889 | 2893 | data->lpt_en[num_displays + 4] = false; |
---|
2890 | 2894 | data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total); |
---|
2891 | 2895 | data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total); |
---|
2892 | | - data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_khz, 1000); |
---|
| 2896 | + pixel_clock_100hz = pipe[i].stream->timing.pix_clk_100hz; |
---|
| 2897 | + if (pipe[i].stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) |
---|
| 2898 | + pixel_clock_100hz *= 2; |
---|
| 2899 | + data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pixel_clock_100hz, 10000); |
---|
2893 | 2900 | if (pipe[i].plane_state) { |
---|
2894 | 2901 | data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width); |
---|
2895 | 2902 | data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4]; |
---|
.. | .. |
---|
2971 | 2978 | data->number_of_displays = num_displays; |
---|
2972 | 2979 | } |
---|
2973 | 2980 | |
---|
| 2981 | +static bool all_displays_in_sync(const struct pipe_ctx pipe[], |
---|
| 2982 | + int pipe_count) |
---|
| 2983 | +{ |
---|
| 2984 | + const struct pipe_ctx *active_pipes[MAX_PIPES]; |
---|
| 2985 | + int i, num_active_pipes = 0; |
---|
| 2986 | + |
---|
| 2987 | + for (i = 0; i < pipe_count; i++) { |
---|
| 2988 | + if (!pipe[i].stream || pipe[i].top_pipe) |
---|
| 2989 | + continue; |
---|
| 2990 | + |
---|
| 2991 | + active_pipes[num_active_pipes++] = &pipe[i]; |
---|
| 2992 | + } |
---|
| 2993 | + |
---|
| 2994 | + if (!num_active_pipes) |
---|
| 2995 | + return false; |
---|
| 2996 | + |
---|
| 2997 | + for (i = 1; i < num_active_pipes; ++i) { |
---|
| 2998 | + if (!resource_are_streams_timing_synchronizable( |
---|
| 2999 | + active_pipes[0]->stream, active_pipes[i]->stream)) { |
---|
| 3000 | + return false; |
---|
| 3001 | + } |
---|
| 3002 | + } |
---|
| 3003 | + |
---|
| 3004 | + return true; |
---|
| 3005 | +} |
---|
| 3006 | + |
---|
2974 | 3007 | /** |
---|
2975 | 3008 | * Return: |
---|
2976 | 3009 | * true - Display(s) configuration supported. |
---|
.. | .. |
---|
2992 | 3025 | |
---|
2993 | 3026 | populate_initial_data(pipe, pipe_count, data); |
---|
2994 | 3027 | |
---|
2995 | | - /*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/ |
---|
2996 | | - calcs_output->all_displays_in_sync = false; |
---|
| 3028 | + if (ctx->dc->config.multi_mon_pp_mclk_switch) |
---|
| 3029 | + calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count); |
---|
| 3030 | + else |
---|
| 3031 | + calcs_output->all_displays_in_sync = false; |
---|
2997 | 3032 | |
---|
2998 | 3033 | if (data->number_of_displays != 0) { |
---|
2999 | 3034 | uint8_t yclk_lvl, sclk_lvl; |
---|
.. | .. |
---|
3230 | 3265 | bw_fixed_to_int(bw_mul(data-> |
---|
3231 | 3266 | stutter_exit_watermark[9], bw_int_to_fixed(1000))); |
---|
3232 | 3267 | |
---|
3233 | | - calcs_output->stutter_entry_wm_ns[0].b_mark = |
---|
3234 | | - bw_fixed_to_int(bw_mul(data-> |
---|
3235 | | - stutter_entry_watermark[4], bw_int_to_fixed(1000))); |
---|
3236 | | - calcs_output->stutter_entry_wm_ns[1].b_mark = |
---|
3237 | | - bw_fixed_to_int(bw_mul(data-> |
---|
3238 | | - stutter_entry_watermark[5], bw_int_to_fixed(1000))); |
---|
3239 | | - calcs_output->stutter_entry_wm_ns[2].b_mark = |
---|
3240 | | - bw_fixed_to_int(bw_mul(data-> |
---|
3241 | | - stutter_entry_watermark[6], bw_int_to_fixed(1000))); |
---|
3242 | | - if (ctx->dc->caps.max_slave_planes) { |
---|
3243 | | - calcs_output->stutter_entry_wm_ns[3].b_mark = |
---|
| 3268 | + calcs_output->stutter_entry_wm_ns[0].b_mark = |
---|
3244 | 3269 | bw_fixed_to_int(bw_mul(data-> |
---|
3245 | | - stutter_entry_watermark[0], bw_int_to_fixed(1000))); |
---|
3246 | | - calcs_output->stutter_entry_wm_ns[4].b_mark = |
---|
| 3270 | + stutter_entry_watermark[4], bw_int_to_fixed(1000))); |
---|
| 3271 | + calcs_output->stutter_entry_wm_ns[1].b_mark = |
---|
3247 | 3272 | bw_fixed_to_int(bw_mul(data-> |
---|
3248 | | - stutter_entry_watermark[1], bw_int_to_fixed(1000))); |
---|
3249 | | - } else { |
---|
3250 | | - calcs_output->stutter_entry_wm_ns[3].b_mark = |
---|
| 3273 | + stutter_entry_watermark[5], bw_int_to_fixed(1000))); |
---|
| 3274 | + calcs_output->stutter_entry_wm_ns[2].b_mark = |
---|
3251 | 3275 | bw_fixed_to_int(bw_mul(data-> |
---|
3252 | | - stutter_entry_watermark[7], bw_int_to_fixed(1000))); |
---|
3253 | | - calcs_output->stutter_entry_wm_ns[4].b_mark = |
---|
| 3276 | + stutter_entry_watermark[6], bw_int_to_fixed(1000))); |
---|
| 3277 | + if (ctx->dc->caps.max_slave_planes) { |
---|
| 3278 | + calcs_output->stutter_entry_wm_ns[3].b_mark = |
---|
| 3279 | + bw_fixed_to_int(bw_mul(data-> |
---|
| 3280 | + stutter_entry_watermark[0], bw_int_to_fixed(1000))); |
---|
| 3281 | + calcs_output->stutter_entry_wm_ns[4].b_mark = |
---|
| 3282 | + bw_fixed_to_int(bw_mul(data-> |
---|
| 3283 | + stutter_entry_watermark[1], bw_int_to_fixed(1000))); |
---|
| 3284 | + } else { |
---|
| 3285 | + calcs_output->stutter_entry_wm_ns[3].b_mark = |
---|
| 3286 | + bw_fixed_to_int(bw_mul(data-> |
---|
| 3287 | + stutter_entry_watermark[7], bw_int_to_fixed(1000))); |
---|
| 3288 | + calcs_output->stutter_entry_wm_ns[4].b_mark = |
---|
| 3289 | + bw_fixed_to_int(bw_mul(data-> |
---|
| 3290 | + stutter_entry_watermark[8], bw_int_to_fixed(1000))); |
---|
| 3291 | + } |
---|
| 3292 | + calcs_output->stutter_entry_wm_ns[5].b_mark = |
---|
3254 | 3293 | bw_fixed_to_int(bw_mul(data-> |
---|
3255 | | - stutter_entry_watermark[8], bw_int_to_fixed(1000))); |
---|
3256 | | - } |
---|
3257 | | - calcs_output->stutter_entry_wm_ns[5].b_mark = |
---|
3258 | | - bw_fixed_to_int(bw_mul(data-> |
---|
3259 | | - stutter_entry_watermark[9], bw_int_to_fixed(1000))); |
---|
| 3294 | + stutter_entry_watermark[9], bw_int_to_fixed(1000))); |
---|
3260 | 3295 | |
---|
3261 | 3296 | calcs_output->urgent_wm_ns[0].b_mark = |
---|
3262 | 3297 | bw_fixed_to_int(bw_mul(data-> |
---|