sun8i_mixer.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. */
  9. #ifndef _SUN8I_MIXER_H_
  10. #define _SUN8I_MIXER_H_
  11. #include <linux/clk.h>
  12. #include <linux/regmap.h>
  13. #include <linux/reset.h>
  14. #include "sunxi_engine.h"
  15. #define SUN8I_MIXER_MAX_CHAN_COUNT 4
  16. #define SUN8I_MIXER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1))
  17. #define SUN8I_MIXER_COORD(x, y) ((y) << 16 | (x))
  18. #define SUN8I_MIXER_GLOBAL_CTL 0x0
  19. #define SUN8I_MIXER_GLOBAL_STATUS 0x4
  20. #define SUN8I_MIXER_GLOBAL_DBUFF 0x8
  21. #define SUN8I_MIXER_GLOBAL_SIZE 0xc
  22. #define SUN8I_MIXER_GLOBAL_CTL_RT_EN 0x1
  23. #define SUN8I_MIXER_GLOBAL_DBUFF_ENABLE 0x1
  24. #define SUN8I_MIXER_BLEND_FCOLOR_CTL 0x1000
  25. #define SUN8I_MIXER_BLEND_ATTR_FCOLOR(x) (0x1004 + 0x10 * (x) + 0x0)
  26. #define SUN8I_MIXER_BLEND_ATTR_INSIZE(x) (0x1004 + 0x10 * (x) + 0x4)
  27. #define SUN8I_MIXER_BLEND_ATTR_OFFSET(x) (0x1004 + 0x10 * (x) + 0x8)
  28. #define SUN8I_MIXER_BLEND_ROUTE 0x1080
  29. #define SUN8I_MIXER_BLEND_PREMULTIPLY 0x1084
  30. #define SUN8I_MIXER_BLEND_BKCOLOR 0x1088
  31. #define SUN8I_MIXER_BLEND_OUTSIZE 0x108c
  32. #define SUN8I_MIXER_BLEND_MODE(x) (0x1090 + 0x04 * (x))
  33. #define SUN8I_MIXER_BLEND_CK_CTL 0x10b0
  34. #define SUN8I_MIXER_BLEND_CK_CFG 0x10b4
  35. #define SUN8I_MIXER_BLEND_CK_MAX(x) (0x10c0 + 0x04 * (x))
  36. #define SUN8I_MIXER_BLEND_CK_MIN(x) (0x10e0 + 0x04 * (x))
  37. #define SUN8I_MIXER_BLEND_OUTCTL 0x10fc
  38. /* The following numbers are some still unknown magic numbers */
  39. #define SUN8I_MIXER_BLEND_ATTR_FCOLOR_DEF 0xff000000
  40. #define SUN8I_MIXER_BLEND_FCOLOR_CTL_DEF 0x00000101
  41. #define SUN8I_MIXER_BLEND_PREMULTIPLY_DEF 0x0
  42. #define SUN8I_MIXER_BLEND_BKCOLOR_DEF 0xff000000
  43. #define SUN8I_MIXER_BLEND_MODE_DEF 0x03010301
  44. #define SUN8I_MIXER_BLEND_CK_CTL_DEF 0x0
  45. #define SUN8I_MIXER_BLEND_OUTCTL_INTERLACED BIT(1)
  46. /*
  47. * VI channels are not used now, but the support of them may be introduced in
  48. * the future.
  49. */
  50. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch, layer) \
  51. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x0)
  52. #define SUN8I_MIXER_CHAN_UI_LAYER_SIZE(ch, layer) \
  53. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x4)
  54. #define SUN8I_MIXER_CHAN_UI_LAYER_COORD(ch, layer) \
  55. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x8)
  56. #define SUN8I_MIXER_CHAN_UI_LAYER_PITCH(ch, layer) \
  57. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0xc)
  58. #define SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch, layer) \
  59. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x10)
  60. #define SUN8I_MIXER_CHAN_UI_LAYER_BOT_LADDR(ch, layer) \
  61. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x14)
  62. #define SUN8I_MIXER_CHAN_UI_LAYER_FCOLOR(ch, layer) \
  63. (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x18)
  64. #define SUN8I_MIXER_CHAN_UI_TOP_HADDR(ch) (0x2000 + 0x1000 * (ch) + 0x80)
  65. #define SUN8I_MIXER_CHAN_UI_BOT_HADDR(ch) (0x2000 + 0x1000 * (ch) + 0x84)
  66. #define SUN8I_MIXER_CHAN_UI_OVL_SIZE(ch) (0x2000 + 0x1000 * (ch) + 0x88)
  67. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN BIT(0)
  68. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_MASK GENMASK(2, 1)
  69. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_MASK GENMASK(11, 8)
  70. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MASK GENMASK(31, 24)
  71. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_DEF (1 << 1)
  72. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_ARGB8888 (0 << 8)
  73. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_XRGB8888 (4 << 8)
  74. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_RGB888 (8 << 8)
  75. #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_DEF (0xff << 24)
  76. /*
  77. * These sub-engines are still unknown now, the EN registers are here only to
  78. * be used to disable these sub-engines.
  79. */
  80. #define SUN8I_MIXER_VSU_EN 0x20000
  81. #define SUN8I_MIXER_GSU1_EN 0x30000
  82. #define SUN8I_MIXER_GSU2_EN 0x40000
  83. #define SUN8I_MIXER_GSU3_EN 0x50000
  84. #define SUN8I_MIXER_FCE_EN 0xa0000
  85. #define SUN8I_MIXER_BWS_EN 0xa2000
  86. #define SUN8I_MIXER_LTI_EN 0xa4000
  87. #define SUN8I_MIXER_PEAK_EN 0xa6000
  88. #define SUN8I_MIXER_ASE_EN 0xa8000
  89. #define SUN8I_MIXER_FCC_EN 0xaa000
  90. #define SUN8I_MIXER_DCSC_EN 0xb0000
  91. struct sun8i_mixer_cfg {
  92. int vi_num;
  93. int ui_num;
  94. };
  95. struct sun8i_mixer {
  96. struct sunxi_engine engine;
  97. const struct sun8i_mixer_cfg *cfg;
  98. struct reset_control *reset;
  99. struct clk *bus_clk;
  100. struct clk *mod_clk;
  101. };
  102. static inline struct sun8i_mixer *
  103. engine_to_sun8i_mixer(struct sunxi_engine *engine)
  104. {
  105. return container_of(engine, struct sun8i_mixer, engine);
  106. }
  107. void sun8i_mixer_layer_enable(struct sun8i_mixer *mixer,
  108. int layer, bool enable);
  109. int sun8i_mixer_update_layer_coord(struct sun8i_mixer *mixer,
  110. int layer, struct drm_plane *plane);
  111. int sun8i_mixer_update_layer_formats(struct sun8i_mixer *mixer,
  112. int layer, struct drm_plane *plane);
  113. int sun8i_mixer_update_layer_buffer(struct sun8i_mixer *mixer,
  114. int layer, struct drm_plane *plane);
  115. #endif /* _SUN8I_MIXER_H_ */