136 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.3 */4 5#ifndef _DPU_HW_PINGPONG_H6#define _DPU_HW_PINGPONG_H7 8#include "dpu_hw_catalog.h"9#include "dpu_hw_mdss.h"10#include "dpu_hw_util.h"11 12#define DITHER_MATRIX_SZ 1613 14struct dpu_hw_pingpong;15 16/**17 * struct dpu_hw_dither_cfg - dither feature structure18 * @flags: for customizing operations19 * @temporal_en: temperal dither enable20 * @c0_bitdepth: c0 component bit depth21 * @c1_bitdepth: c1 component bit depth22 * @c2_bitdepth: c2 component bit depth23 * @c3_bitdepth: c2 component bit depth24 * @matrix: dither strength matrix25 */26struct dpu_hw_dither_cfg {27 u64 flags;28 u32 temporal_en;29 u32 c0_bitdepth;30 u32 c1_bitdepth;31 u32 c2_bitdepth;32 u32 c3_bitdepth;33 u32 matrix[DITHER_MATRIX_SZ];34};35 36/**37 *38 * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions39 * Assumption is these functions will be called after clocks are enabled40 * @enable_tearcheck: program and enable tear check block41 * @disable_tearcheck: disable able tear check block42 * @setup_dither : function to program the dither hw block43 * @get_line_count: obtain current vertical line counter44 */45struct dpu_hw_pingpong_ops {46 /**47 * enables vysnc generation and sets up init value of48 * read pointer and programs the tear check cofiguration49 */50 int (*enable_tearcheck)(struct dpu_hw_pingpong *pp,51 struct dpu_hw_tear_check *cfg);52 53 /**54 * disables tear check block55 */56 int (*disable_tearcheck)(struct dpu_hw_pingpong *pp);57 58 /**59 * read, modify, write to either set or clear listening to external TE60 * @Return: 1 if TE was originally connected, 0 if not, or -ERROR61 */62 int (*connect_external_te)(struct dpu_hw_pingpong *pp,63 bool enable_external_te);64 65 /**66 * Obtain current vertical line counter67 */68 u32 (*get_line_count)(struct dpu_hw_pingpong *pp);69 70 /**71 * Disable autorefresh if enabled72 */73 void (*disable_autorefresh)(struct dpu_hw_pingpong *pp, uint32_t encoder_id, u16 vdisplay);74 75 /**76 * Setup dither matix for pingpong block77 */78 void (*setup_dither)(struct dpu_hw_pingpong *pp,79 struct dpu_hw_dither_cfg *cfg);80 /**81 * Enable DSC82 */83 int (*enable_dsc)(struct dpu_hw_pingpong *pp);84 85 /**86 * Disable DSC87 */88 void (*disable_dsc)(struct dpu_hw_pingpong *pp);89 90 /**91 * Setup DSC92 */93 int (*setup_dsc)(struct dpu_hw_pingpong *pp);94};95 96struct dpu_hw_merge_3d;97 98struct dpu_hw_pingpong {99 struct dpu_hw_blk base;100 struct dpu_hw_blk_reg_map hw;101 102 /* pingpong */103 enum dpu_pingpong idx;104 const struct dpu_pingpong_cfg *caps;105 struct dpu_hw_merge_3d *merge_3d;106 107 /* ops */108 struct dpu_hw_pingpong_ops ops;109};110 111/**112 * to_dpu_hw_pingpong - convert base object dpu_hw_base to container113 * @hw: Pointer to base hardware block114 * return: Pointer to hardware block container115 */116static inline struct dpu_hw_pingpong *to_dpu_hw_pingpong(struct dpu_hw_blk *hw)117{118 return container_of(hw, struct dpu_hw_pingpong, base);119}120 121/**122 * dpu_hw_pingpong_init() - initializes the pingpong driver for the passed123 * pingpong catalog entry.124 * @dev: Corresponding device for devres management125 * @cfg: Pingpong catalog entry for which driver object is required126 * @addr: Mapped register io address of MDP127 * @mdss_rev: dpu core's major and minor versions128 * Return: Error code or allocated dpu_hw_pingpong context129 */130struct dpu_hw_pingpong *dpu_hw_pingpong_init(struct drm_device *dev,131 const struct dpu_pingpong_cfg *cfg,132 void __iomem *addr,133 const struct dpu_mdss_version *mdss_rev);134 135#endif /*_DPU_HW_PINGPONG_H */136