|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | 2 | /* |
3 | | - * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. |
4 | 3 | * Copyright (C) 2013 Red Hat |
| 4 | + * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. |
| 5 | + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| 6 | + * |
5 | 7 | * Author: Rob Clark <[email protected]> |
6 | 8 | */ |
7 | 9 |
|
|
22 | 24 | #include "dpu_hw_ctl.h" |
23 | 25 | #include "dpu_hw_dspp.h" |
24 | 26 | #include "dpu_hw_dsc.h" |
| 27 | +#include "dpu_hw_merge3d.h" |
25 | 28 | #include "dpu_formats.h" |
26 | 29 | #include "dpu_encoder_phys.h" |
27 | 30 | #include "dpu_crtc.h" |
@@ -1838,6 +1841,86 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc) |
1838 | 1841 | DPU_ATRACE_END("encoder_kickoff"); |
1839 | 1842 | } |
1840 | 1843 |
|
| 1844 | +static void dpu_encoder_helper_reset_mixers(struct dpu_encoder_phys *phys_enc) |
| 1845 | +{ |
| 1846 | + struct dpu_hw_mixer_cfg mixer; |
| 1847 | + int i, num_lm; |
| 1848 | + u32 flush_mask = 0; |
| 1849 | + struct dpu_global_state *global_state; |
| 1850 | + struct dpu_hw_blk *hw_lm[2]; |
| 1851 | + struct dpu_hw_mixer *hw_mixer[2]; |
| 1852 | + struct dpu_hw_ctl *ctl = phys_enc->hw_ctl; |
| 1853 | + |
| 1854 | + memset(&mixer, 0, sizeof(mixer)); |
| 1855 | + |
| 1856 | + /* reset all mixers for this encoder */ |
| 1857 | + if (phys_enc->hw_ctl->ops.clear_all_blendstages) |
| 1858 | + phys_enc->hw_ctl->ops.clear_all_blendstages(phys_enc->hw_ctl); |
| 1859 | + |
| 1860 | + global_state = dpu_kms_get_existing_global_state(phys_enc->dpu_kms); |
| 1861 | + |
| 1862 | + num_lm = dpu_rm_get_assigned_resources(&phys_enc->dpu_kms->rm, global_state, |
| 1863 | + phys_enc->parent->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm)); |
| 1864 | + |
| 1865 | + for (i = 0; i < num_lm; i++) { |
| 1866 | + hw_mixer[i] = to_dpu_hw_mixer(hw_lm[i]); |
| 1867 | + flush_mask = phys_enc->hw_ctl->ops.get_bitmask_mixer(ctl, hw_mixer[i]->idx); |
| 1868 | + if (phys_enc->hw_ctl->ops.update_pending_flush) |
| 1869 | + phys_enc->hw_ctl->ops.update_pending_flush(ctl, flush_mask); |
| 1870 | + |
| 1871 | + /* clear all blendstages */ |
| 1872 | + if (phys_enc->hw_ctl->ops.setup_blendstage) |
| 1873 | + phys_enc->hw_ctl->ops.setup_blendstage(ctl, hw_mixer[i]->idx, NULL); |
| 1874 | + } |
| 1875 | +} |
| 1876 | + |
| 1877 | +void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc) |
| 1878 | +{ |
| 1879 | + struct dpu_hw_ctl *ctl = phys_enc->hw_ctl; |
| 1880 | + struct dpu_hw_intf_cfg intf_cfg = { 0 }; |
| 1881 | + int i; |
| 1882 | + struct dpu_encoder_virt *dpu_enc; |
| 1883 | + |
| 1884 | + dpu_enc = to_dpu_encoder_virt(phys_enc->parent); |
| 1885 | + |
| 1886 | + phys_enc->hw_ctl->ops.reset(ctl); |
| 1887 | + |
| 1888 | + dpu_encoder_helper_reset_mixers(phys_enc); |
| 1889 | + |
| 1890 | + for (i = 0; i < dpu_enc->num_phys_encs; i++) { |
| 1891 | + if (dpu_enc->phys_encs[i] && phys_enc->hw_intf->ops.bind_pingpong_blk) |
| 1892 | + phys_enc->hw_intf->ops.bind_pingpong_blk( |
| 1893 | + dpu_enc->phys_encs[i]->hw_intf, false, |
| 1894 | + dpu_enc->phys_encs[i]->hw_pp->idx); |
| 1895 | + |
| 1896 | + /* mark INTF flush as pending */ |
| 1897 | + if (phys_enc->hw_ctl->ops.update_pending_flush_intf) |
| 1898 | + phys_enc->hw_ctl->ops.update_pending_flush_intf(phys_enc->hw_ctl, |
| 1899 | + dpu_enc->phys_encs[i]->hw_intf->idx); |
| 1900 | + } |
| 1901 | + |
| 1902 | + /* reset the merge 3D HW block */ |
| 1903 | + if (phys_enc->hw_pp->merge_3d) { |
| 1904 | + phys_enc->hw_pp->merge_3d->ops.setup_3d_mode(phys_enc->hw_pp->merge_3d, |
| 1905 | + BLEND_3D_NONE); |
| 1906 | + if (phys_enc->hw_ctl->ops.update_pending_flush_merge_3d) |
| 1907 | + phys_enc->hw_ctl->ops.update_pending_flush_merge_3d(ctl, |
| 1908 | + phys_enc->hw_pp->merge_3d->idx); |
| 1909 | + } |
| 1910 | + |
| 1911 | + intf_cfg.stream_sel = 0; /* Don't care value for video mode */ |
| 1912 | + intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); |
| 1913 | + if (phys_enc->hw_pp->merge_3d) |
| 1914 | + intf_cfg.merge_3d = phys_enc->hw_pp->merge_3d->idx; |
| 1915 | + |
| 1916 | + if (ctl->ops.reset_intf_cfg) |
| 1917 | + ctl->ops.reset_intf_cfg(ctl, &intf_cfg); |
| 1918 | + |
| 1919 | + ctl->ops.trigger_flush(ctl); |
| 1920 | + ctl->ops.trigger_start(ctl); |
| 1921 | + ctl->ops.clear_pending_flush(ctl); |
| 1922 | +} |
| 1923 | + |
1841 | 1924 | void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc) |
1842 | 1925 | { |
1843 | 1926 | struct dpu_encoder_virt *dpu_enc; |
|
0 commit comments