0440-drm-vc4-Add-support-for-feeding-DSI-encoders-from-th.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From d41850b2bd8ad77636e344c5fed1ebda0d77a9bc Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Wed, 10 Feb 2016 16:17:29 -0800
  4. Subject: [PATCH] drm/vc4: Add support for feeding DSI encoders from the pixel
  5. valve.
  6. Signed-off-by: Eric Anholt <eric@anholt.net>
  7. ---
  8. drivers/gpu/drm/vc4/vc4_crtc.c | 30 +++++++++++++++++-------------
  9. drivers/gpu/drm/vc4/vc4_regs.h | 2 ++
  10. 2 files changed, 19 insertions(+), 13 deletions(-)
  11. --- a/drivers/gpu/drm/vc4/vc4_crtc.c
  12. +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
  13. @@ -210,38 +210,40 @@ static u32 vc4_get_fifo_full_level(u32 f
  14. }
  15. /*
  16. - * Returns the clock select bit for the connector attached to the
  17. - * CRTC.
  18. + * Returns the encoder attached to the CRTC.
  19. + *
  20. + * VC4 can only scan out to one encoder at a type, while the DRM core
  21. + * allows drivers to push pixels to more than one encoder from the
  22. + * same CRTC.
  23. */
  24. -static int vc4_get_clock_select(struct drm_crtc *crtc)
  25. +static struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc *crtc)
  26. {
  27. struct drm_connector *connector;
  28. drm_for_each_connector(connector, crtc->dev) {
  29. if (connector->state->crtc == crtc) {
  30. - struct drm_encoder *encoder = connector->encoder;
  31. - struct vc4_encoder *vc4_encoder =
  32. - to_vc4_encoder(encoder);
  33. -
  34. - return vc4_encoder->clock_select;
  35. + return connector->encoder;
  36. }
  37. }
  38. - return -1;
  39. + return NULL;
  40. }
  41. static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
  42. {
  43. struct drm_device *dev = crtc->dev;
  44. struct vc4_dev *vc4 = to_vc4_dev(dev);
  45. + struct drm_encoder *encoder = vc4_get_crtc_encoder(crtc);
  46. + struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
  47. struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
  48. struct drm_crtc_state *state = crtc->state;
  49. struct drm_display_mode *mode = &state->adjusted_mode;
  50. bool interlace = mode->flags & DRM_MODE_FLAG_INTERLACE;
  51. u32 vactive = (mode->vdisplay >> (interlace ? 1 : 0));
  52. - u32 format = PV_CONTROL_FORMAT_24;
  53. - bool debug_dump_regs = false;
  54. - int clock_select = vc4_get_clock_select(crtc);
  55. + bool is_dsi = (vc4_encoder->type == VC4_ENCODER_TYPE_DSI0 ||
  56. + vc4_encoder->type == VC4_ENCODER_TYPE_DSI1);
  57. + u32 format = is_dsi ? PV_CONTROL_FORMAT_DSIV_24 : PV_CONTROL_FORMAT_24;
  58. + bool debug_dump_regs = true;
  59. if (debug_dump_regs) {
  60. DRM_INFO("CRTC %d regs before:\n", drm_crtc_index(crtc));
  61. @@ -289,6 +291,7 @@ static void vc4_crtc_mode_set_nofb(struc
  62. CRTC_WRITE(PV_V_CONTROL,
  63. PV_VCONTROL_CONTINUOUS |
  64. + (is_dsi ? PV_VCONTROL_DSI : 0) |
  65. (interlace ? PV_VCONTROL_INTERLACE : 0));
  66. CRTC_WRITE(PV_CONTROL,
  67. @@ -298,7 +301,8 @@ static void vc4_crtc_mode_set_nofb(struc
  68. PV_CONTROL_CLR_AT_START |
  69. PV_CONTROL_TRIGGER_UNDERFLOW |
  70. PV_CONTROL_WAIT_HSTART |
  71. - VC4_SET_FIELD(clock_select, PV_CONTROL_CLK_SELECT) |
  72. + VC4_SET_FIELD(vc4_encoder->clock_select,
  73. + PV_CONTROL_CLK_SELECT) |
  74. PV_CONTROL_FIFO_CLR |
  75. PV_CONTROL_EN);
  76. --- a/drivers/gpu/drm/vc4/vc4_regs.h
  77. +++ b/drivers/gpu/drm/vc4/vc4_regs.h
  78. @@ -184,6 +184,8 @@
  79. #define PV_V_CONTROL 0x04
  80. # define PV_VCONTROL_INTERLACE BIT(4)
  81. +# define PV_VCONTROL_DSI BIT(3)
  82. +# define PV_VCONTROL_COMMAND BIT(2)
  83. # define PV_VCONTROL_CONTINUOUS BIT(1)
  84. # define PV_VCONTROL_VIDEN BIT(0)