sde_hw_cdm.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_CDM_H
  6. #define _SDE_HW_CDM_H
  7. #include "sde_hw_mdss.h"
  8. #include "sde_hw_top.h"
  9. struct sde_hw_cdm;
  10. struct sde_hw_cdm_cfg {
  11. u32 output_width;
  12. u32 output_height;
  13. u32 output_bit_depth;
  14. u32 h_cdwn_type;
  15. u32 v_cdwn_type;
  16. const struct sde_format *output_fmt;
  17. u32 output_type;
  18. int flags;
  19. int pp_id;
  20. };
  21. enum sde_hw_cdwn_type {
  22. CDM_CDWN_DISABLE,
  23. CDM_CDWN_PIXEL_DROP,
  24. CDM_CDWN_AVG,
  25. CDM_CDWN_COSITE,
  26. CDM_CDWN_OFFSITE,
  27. };
  28. enum sde_hw_cdwn_output_type {
  29. CDM_CDWN_OUTPUT_HDMI,
  30. CDM_CDWN_OUTPUT_WB,
  31. };
  32. enum sde_hw_cdwn_output_bit_depth {
  33. CDM_CDWN_OUTPUT_8BIT,
  34. CDM_CDWN_OUTPUT_10BIT,
  35. };
  36. /**
  37. * struct sde_hw_cdm_ops : Interface to the chroma down Hw driver functions
  38. * Assumption is these functions will be called after
  39. * clocks are enabled
  40. * @setup_csc: Programs the csc matrix
  41. * @setup_cdwn: Sets up the chroma down sub module
  42. * @enable: Enables the output to interface and programs the
  43. * output packer
  44. * @disable: Puts the cdm in bypass mode
  45. * @bind_pingpong_blk: enable/disable the connection with pingpong which
  46. * will feed pixels to this cdm
  47. */
  48. struct sde_hw_cdm_ops {
  49. /**
  50. * Programs the CSC matrix for conversion from RGB space to YUV space,
  51. * it is optional to call this function as this matrix is automatically
  52. * set during initialization, user should call this if it wants
  53. * to program a different matrix than default matrix.
  54. * @cdm: Pointer to the chroma down context structure
  55. * @data Pointer to CSC configuration data
  56. * return: 0 if success; error code otherwise
  57. */
  58. int (*setup_csc_data)(struct sde_hw_cdm *cdm,
  59. struct sde_csc_cfg *data);
  60. /**
  61. * Programs the Chroma downsample part.
  62. * @cdm Pointer to chroma down context
  63. */
  64. int (*setup_cdwn)(struct sde_hw_cdm *cdm,
  65. struct sde_hw_cdm_cfg *cfg);
  66. /**
  67. * Enable the CDM module
  68. * @cdm Pointer to chroma down context
  69. */
  70. int (*enable)(struct sde_hw_cdm *cdm,
  71. struct sde_hw_cdm_cfg *cfg);
  72. /**
  73. * Disable the CDM module
  74. * @cdm Pointer to chroma down context
  75. */
  76. void (*disable)(struct sde_hw_cdm *cdm);
  77. /**
  78. * Enable/disable the connection with pingpong
  79. * @cdm Pointer to chroma down context
  80. * @enable Enable/disable control
  81. * @pp pingpong block id.
  82. */
  83. void (*bind_pingpong_blk)(struct sde_hw_cdm *cdm,
  84. bool enable,
  85. const enum sde_pingpong pp);
  86. };
  87. struct sde_hw_cdm {
  88. struct sde_hw_blk_reg_map hw;
  89. /* chroma down */
  90. const struct sde_cdm_cfg *caps;
  91. enum sde_cdm idx;
  92. /* mdp top hw driver */
  93. struct sde_hw_mdp *hw_mdp;
  94. /* ops */
  95. struct sde_hw_cdm_ops ops;
  96. };
  97. /**
  98. * to_sde_hw_cdm - convert base hw object to sde_hw_cdm container
  99. * @hw: Pointer to hardware block register map object
  100. * return: Pointer to hardware block container
  101. */
  102. static inline struct sde_hw_cdm *to_sde_hw_cdm(struct sde_hw_blk_reg_map *hw)
  103. {
  104. return container_of(hw, struct sde_hw_cdm, hw);
  105. }
  106. /**
  107. * sde_hw_cdm_init - initializes the cdm hw driver object.
  108. * should be called once before accessing every cdm.
  109. * @idx: cdm index for which driver object is required
  110. * @addr: mapped register io address of MDP
  111. * @m : pointer to mdss catalog data
  112. * @hw_mdp: pointer to mdp top hw driver object
  113. */
  114. struct sde_hw_blk_reg_map *sde_hw_cdm_init(enum sde_cdm idx,
  115. void __iomem *addr,
  116. struct sde_mdss_cfg *m,
  117. struct sde_hw_mdp *hw_mdp);
  118. /**
  119. * sde_hw_cdm_destroy - destroys CDM driver context
  120. * @hw: Pointer to hardware block register map object
  121. */
  122. void sde_hw_cdm_destroy(struct sde_hw_blk_reg_map *hw);
  123. #endif /*_SDE_HW_CDM_H */