mdp5_smp.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2014, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2013 Red Hat
  4. * Author: Rob Clark <robdclark@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __MDP5_SMP_H__
  19. #define __MDP5_SMP_H__
  20. #include <drm/drm_print.h>
  21. #include "msm_drv.h"
  22. /*
  23. * SMP - Shared Memory Pool:
  24. *
  25. * SMP blocks are shared between all the clients, where each plane in
  26. * a scanout buffer is a SMP client. Ie. scanout of 3 plane I420 on
  27. * pipe VIG0 => 3 clients: VIG0_Y, VIG0_CB, VIG0_CR.
  28. *
  29. * Based on the size of the attached scanout buffer, a certain # of
  30. * blocks must be allocated to that client out of the shared pool.
  31. *
  32. * In some hw, some blocks are statically allocated for certain pipes
  33. * and CANNOT be re-allocated (eg: MMB0 and MMB1 both tied to RGB0).
  34. *
  35. *
  36. * Atomic SMP State:
  37. *
  38. * On atomic updates that modify SMP configuration, the state is cloned
  39. * (copied) and modified. For test-only, or in cases where atomic
  40. * update fails (or if we hit ww_mutex deadlock/backoff condition) the
  41. * new state is simply thrown away.
  42. *
  43. * Because the SMP registers are not double buffered, updates are a
  44. * two step process:
  45. *
  46. * 1) in _prepare_commit() we configure things (via read-modify-write)
  47. * for the newly assigned pipes, so we don't take away blocks
  48. * assigned to pipes that are still scanning out
  49. * 2) in _complete_commit(), after vblank/etc, we clear things for the
  50. * released clients, since at that point old pipes are no longer
  51. * scanning out.
  52. */
  53. struct mdp5_smp_state {
  54. /* global state of what blocks are in use: */
  55. mdp5_smp_state_t state;
  56. /* per client state of what blocks they are using: */
  57. mdp5_smp_state_t client_state[MAX_CLIENTS];
  58. /* assigned pipes (hw updated at _prepare_commit()): */
  59. unsigned long assigned;
  60. /* released pipes (hw updated at _complete_commit()): */
  61. unsigned long released;
  62. };
  63. struct mdp5_kms;
  64. struct mdp5_smp;
  65. /*
  66. * SMP module prototypes:
  67. * mdp5_smp_init() returns a SMP @handler,
  68. * which is then used to call the other mdp5_smp_*(handler, ...) functions.
  69. */
  70. struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms,
  71. const struct mdp5_smp_block *cfg);
  72. void mdp5_smp_destroy(struct mdp5_smp *smp);
  73. void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p);
  74. uint32_t mdp5_smp_calculate(struct mdp5_smp *smp,
  75. const struct mdp_format *format,
  76. u32 width, bool hdecim);
  77. int mdp5_smp_assign(struct mdp5_smp *smp, struct mdp5_smp_state *state,
  78. enum mdp5_pipe pipe, uint32_t blkcfg);
  79. void mdp5_smp_release(struct mdp5_smp *smp, struct mdp5_smp_state *state,
  80. enum mdp5_pipe pipe);
  81. void mdp5_smp_prepare_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);
  82. void mdp5_smp_complete_commit(struct mdp5_smp *smp, struct mdp5_smp_state *state);
  83. #endif /* __MDP5_SMP_H__ */