sun4i_frontend.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017 Free Electrons
  4. * Maxime Ripard <maxime.ripard@free-electrons.com>
  5. */
  6. #ifndef _SUN4I_FRONTEND_H_
  7. #define _SUN4I_FRONTEND_H_
  8. #include <linux/list.h>
  9. #define SUN4I_FRONTEND_EN_REG 0x000
  10. #define SUN4I_FRONTEND_EN_EN BIT(0)
  11. #define SUN4I_FRONTEND_FRM_CTRL_REG 0x004
  12. #define SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL BIT(23)
  13. #define SUN4I_FRONTEND_FRM_CTRL_FRM_START BIT(16)
  14. #define SUN4I_FRONTEND_FRM_CTRL_COEF_RDY BIT(1)
  15. #define SUN4I_FRONTEND_FRM_CTRL_REG_RDY BIT(0)
  16. #define SUN4I_FRONTEND_BYPASS_REG 0x008
  17. #define SUN4I_FRONTEND_BYPASS_CSC_EN BIT(1)
  18. #define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020
  19. #define SUN4I_FRONTEND_LINESTRD0_REG 0x040
  20. #define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c
  21. #define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8)
  22. #define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4)
  23. #define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps)
  24. #define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c
  25. #define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt)
  26. #define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100
  27. #define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))
  28. #define SUN4I_FRONTEND_CH0_OUTSIZE_REG 0x104
  29. #define SUN4I_FRONTEND_OUTSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))
  30. #define SUN4I_FRONTEND_CH0_HORZFACT_REG 0x108
  31. #define SUN4I_FRONTEND_HORZFACT(i, f) (((i) << 16) | (f))
  32. #define SUN4I_FRONTEND_CH0_VERTFACT_REG 0x10c
  33. #define SUN4I_FRONTEND_VERTFACT(i, f) (((i) << 16) | (f))
  34. #define SUN4I_FRONTEND_CH0_HORZPHASE_REG 0x110
  35. #define SUN4I_FRONTEND_CH0_VERTPHASE0_REG 0x114
  36. #define SUN4I_FRONTEND_CH0_VERTPHASE1_REG 0x118
  37. #define SUN4I_FRONTEND_CH1_INSIZE_REG 0x200
  38. #define SUN4I_FRONTEND_CH1_OUTSIZE_REG 0x204
  39. #define SUN4I_FRONTEND_CH1_HORZFACT_REG 0x208
  40. #define SUN4I_FRONTEND_CH1_VERTFACT_REG 0x20c
  41. #define SUN4I_FRONTEND_CH1_HORZPHASE_REG 0x210
  42. #define SUN4I_FRONTEND_CH1_VERTPHASE0_REG 0x214
  43. #define SUN4I_FRONTEND_CH1_VERTPHASE1_REG 0x218
  44. #define SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i) (0x400 + i * 4)
  45. #define SUN4I_FRONTEND_CH0_HORZCOEF1_REG(i) (0x480 + i * 4)
  46. #define SUN4I_FRONTEND_CH0_VERTCOEF_REG(i) (0x500 + i * 4)
  47. #define SUN4I_FRONTEND_CH1_HORZCOEF0_REG(i) (0x600 + i * 4)
  48. #define SUN4I_FRONTEND_CH1_HORZCOEF1_REG(i) (0x680 + i * 4)
  49. #define SUN4I_FRONTEND_CH1_VERTCOEF_REG(i) (0x700 + i * 4)
  50. struct clk;
  51. struct device_node;
  52. struct drm_plane;
  53. struct regmap;
  54. struct reset_control;
  55. struct sun4i_frontend {
  56. struct list_head list;
  57. struct device *dev;
  58. struct device_node *node;
  59. struct clk *bus_clk;
  60. struct clk *mod_clk;
  61. struct clk *ram_clk;
  62. struct regmap *regs;
  63. struct reset_control *reset;
  64. };
  65. extern const struct of_device_id sun4i_frontend_of_table[];
  66. int sun4i_frontend_init(struct sun4i_frontend *frontend);
  67. void sun4i_frontend_exit(struct sun4i_frontend *frontend);
  68. int sun4i_frontend_enable(struct sun4i_frontend *frontend);
  69. void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend,
  70. struct drm_plane *plane);
  71. void sun4i_frontend_update_coord(struct sun4i_frontend *frontend,
  72. struct drm_plane *plane);
  73. int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
  74. struct drm_plane *plane, uint32_t out_fmt);
  75. #endif /* _SUN4I_FRONTEND_H_ */