sde_hw_cdm.h 3.7 KB

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